SSH Tennel for Adb/GDB debug NDK

66 篇文章 0 订阅
54 篇文章 0 订阅


## Step 1 
OutSideHost/Linux build server/Remote  192.168.1.1 

root@OutSideHost:/localrepo/root/rm/jci/rm/engine$ netstat -an  --tcp  |grep 16000 

Make sure 16000/TCP is not used 

## Step 2   SSH tunnel  formward from 192.168.1.1:16000 to Windows ADB host/localhost:6000

Windows Adb  start SSH tunnel between Linux build server/Remote  and Windows ADB 

C:\Android\adb>ssh  -NR 16000:localhost:6000    root@192.168.1.1
root@192.168.1.1's password:
====>Forward  OutSideHost/Linux build server/Remote 192.168.1.1:16000 to  WindowsPC adb local TCP/6000

## make sure SSH tunnel on Linux build server/Remote  is Open/TCP/16000
root@OutSideHost:/localrepo/root/rm/jci/rm/engine$ netstat -an  --tcp  |grep 16000
tcp        0      0 127.0.0.1:16000         0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:16000               :::*                    LISTEN     

Or 

Putty ->SSH tunnel Setting for SSH root@192.168.1.1
===>4R16000  localhost:6000   ---> Select Remote  (forward) 

## Step 3 
Windows ( localhost:6000 )/Adb USB connects with Android Device 

C:\Android\adb>adb  forward tcp:6000   tcp:6000 ===>  Forward Windows locat TCP 6000 to Android Device TCP 6000
 
  TCP    127.0.0.1:6000         0.0.0.0:0              LISTENING


### Step 4 


Android device 

C:\Android\adb>adb  root

C:\Android\adb>adb  remount
remount succeeded
 
C:\Android\adb>adb  shell
azalea:/ # su
azalea:/ # ps  |grep xms
system    3276  1     63876  6284  futex_wait af2456bc S /system/bin/xmsore  
130|azalea:/ # gdbserver :6000  --attach   3276  -------->  Debug process/3276  
Attached; pid = 3276
Listening on port 6000

Or  start a new process
azalea:/ # kill  -9  3276
1|azalea:/ # gdbserver    :6000   /system/bin/xmsore   ( -w is not necessary)
Process /system/bin/xmsore created; pid = 1984
Listening on port 6000


### Step 5  === >  OutSideHost/Linux build server/Remote  192.168.1.1  start gdb debugging 
 
### must launch Gdb from Android_BUILD_TOP  folder  ---> ~/local/fmsng !!!!!!!!!!!!!

root@OutSideHost:~/local/fmsng$ ./prebuilts/gdb/linux-x86/bin/gdb     ~/local/fmsng/out/target/product/azalea/symbols/system/bin/xmsore
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/root/local/fmsng/out/target/product/azalea/symbols/system/bin/xmsore...done.
(gdb) target  remote  :16000
Remote debugging using :16000
Reading /system/bin/linker from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /system/bin/linker from remote target...
Reading symbols from target:/system/bin/linker...Reading /system/bin/.debug/linker from remote target...
(no debugging symbols found)...done.
############################################################
##########  set solib-absolute-prefix/locat symbol for debuging .  
########## This can be skipped if you launch Gdb from Android_BUILD_TOP  folder  ---> ~/local/fmsng !!!!!!!!!!!!!
############################################################
(gdb)   set solib-absolute-prefix  /home/root/local/fmsng/out/target/product/azalea/symbols
warning: .dynamic section for "/home/root/local/fmsng/out/target/product/azalea/symbols/system/bin/linker" is not at the expected address (wrong library or version mismatch?)
Reading symbols from /home/root/local/fmsng/out/target/product/azalea/symbols/system/bin/linker...done.
Reading symbols from /home/root/local/fmsng/out/target/product/azalea/symbols/system/bin/linker...done.
(gdb)  set solib-search-path   /home/root/local/fmsng/out/target/product/azalea/symbols/system/bin
Reading symbols from /home/root/local/fmsng/out/target/product/azalea/symbols/system/bin/linker...done.
(gdb) list
282     } // extern "C"
283
284     /*---------------------------------------------------------------------------
285     Module:  sig_handler
286     Purpose: Signal handler for termination signals
287     Inputs:  signo - signal number
288     ----------------------------------------------------------------------------*/
289     void sig_handler(int signo)
290     {
291       XXXXXXXXXX("DEBUG:in signal handler of number: %d", signo);
(gdb) b main
Breakpoint 1 at 0x2a064f4c: file XXXXXXXXXXX, line 296.
(gdb) c
Continuing.

Breakpoint 1, main (argc=0, argv=0x8) atXXXXXXX:296
296     {
(gdb) list
291       

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值