Skip to content

Commit 87f8919

Browse files
committed
GDB : debug share library on android device
1 parent d002a6e commit 87f8919

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

debug/android_gdb.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,73 @@ gdb_config内容如下供参考
8989
set solib-search-path /path/to/android_src/out/target/product/rk3288/symbols/system/lib
9090
file /path/to/android_src/out/target/product/rk3288/symbols/system/xbin/gout1
9191

92+
### 实例1(android上动态库bluetooth.default.so调试)
93+
94+
错误日志如下(size > GKI_MAX_BUF_SIZE)
95+
96+
--------- beginning of crash
97+
01-14 04:19:10.896 1404 1471 F libc : system/bt/hci/src/buffer_allocator.c:26: buffer_alloc: assertion "size <= GKI_MAX_BUF_SIZE" failed
98+
01-14 04:19:10.897 1404 1471 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 1471 (bluedroid wake/)
99+
01-14 04:19:10.898 234 234 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
100+
01-14 04:19:10.899 234 234 F DEBUG : Revision: '0'
101+
01-14 04:19:10.899 234 234 F DEBUG : ABI: 'arm'
102+
01-14 04:19:10.899 234 234 F DEBUG : pid: 1404, tid: 1471, name: bluedroid wake/ >>> com.android.bluetooth <<<
103+
01-14 04:19:10.899 234 234 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
104+
01-14 04:19:10.915 234 234 F DEBUG : Abort message: 'system/bt/hci/src/buffer_allocator.c:26: buffer_alloc: assertion "size <= GKI_MAX_BUF_SIZE" failed'
105+
01-14 04:19:10.915 234 234 F DEBUG : r0 00000000 r1 000005bf r2 00000006 r3 a0c16978
106+
01-14 04:19:10.915 234 234 F DEBUG : r4 a0c16980 r5 a0c16930 r6 00000000 r7 0000010c
107+
01-14 04:19:10.915 234 234 F DEBUG : r8 0000930f r9 0000930f sl a15e8f48 fp a15e8ecc
108+
01-14 04:19:10.915 234 234 F DEBUG : ip 00000006 sp a0c16390 lr b6ca7ec9 pc b6caa2b8 cpsr 400f0010
109+
01-14 04:19:10.926 234 234 F DEBUG :
110+
01-14 04:19:10.926 234 234 F DEBUG : backtrace:
111+
01-14 04:19:10.926 234 234 F DEBUG : #00 pc 000442b8 /system/lib/libc.so (tgkill+12)
112+
01-14 04:19:10.926 234 234 F DEBUG : #01 pc 00041ec5 /system/lib/libc.so (pthread_kill+32)
113+
01-14 04:19:10.926 234 234 F DEBUG : #02 pc 0001badf /system/lib/libc.so (raise+10)
114+
01-14 04:19:10.927 234 234 F DEBUG : #03 pc 00018c91 /system/lib/libc.so (__libc_android_abort+34)
115+
01-14 04:19:10.927 234 234 F DEBUG : #04 pc 00016784 /system/lib/libc.so (abort+4)
116+
01-14 04:19:10.927 234 234 F DEBUG : #05 pc 0001a6f3 /system/lib/libc.so (__libc_fatal+16)
117+
01-14 04:19:10.927 234 234 F DEBUG : #06 pc 00018d19 /system/lib/libc.so (__assert2+20)
118+
01-14 04:19:10.927 234 234 F DEBUG : #07 pc 000edabd /system/lib/hw/bluetooth.default.so
119+
01-14 04:19:10.927 234 234 F DEBUG : #08 pc 000f05ed /system/lib/hw/bluetooth.default.so
120+
01-14 04:19:10.927 234 234 F DEBUG : #09 pc 000ef03f /system/lib/hw/bluetooth.default.so
121+
01-14 04:19:10.927 234 234 F DEBUG : #10 pc 000ee02f /system/lib/hw/bluetooth.default.so
122+
01-14 04:19:10.927 234 234 F DEBUG : #11 pc 000fad73 /system/lib/hw/bluetooth.default.so
123+
01-14 04:19:10.927 234 234 F DEBUG : #12 pc 000fbccf /system/lib/hw/bluetooth.default.so
124+
01-14 04:19:10.927 234 234 F DEBUG : #13 pc 000417c7 /system/lib/libc.so (_ZL15__pthread_startPv+30)
125+
01-14 04:19:10.927 234 234 F DEBUG : #14 pc 00019313 /system/lib/libc.so (__start_thread+6)
126+
01-14 04:19:11.343 234 234 F DEBUG :
127+
01-14 04:19:11.343 234 234 F DEBUG : Tombstone written to: /data/tombstones/tombstone_01
128+
129+
欲调试的库bluetooth.default.so被进程com.android.bluetooth使用
130+
131+
所以可以将gdbserver附加到该进程即可
132+
133+
在android设备上执行(gdb attach到blue的进程上)
134+
135+
gdbserver :1234 --attach `ps | grep bluetooth | busybox1.11 awk '{print $2}'`
136+
137+
gdb配置文件内容如下(ble_cfg)
138+
139+
layout split
140+
shell adb forward tcp:4321 tcp:1234
141+
target remote localhost:4321
142+
set solib-absolute-prefix /home/zeroway/android6.0/out/target/product/rk3288/symbols
143+
set solib-search-path /home/zeroway/android6.0/out/target/product/rk3288/symbols/system/lib
144+
145+
在主机上启动gdb(进入后source ble_cfg)
146+
并在system/bt/hci/src/buffer_allocator.c中函数(buffer_alloc)打断点
147+
148+
./prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-gdb
149+
(gdb) source ble_cfg
150+
(gdb) b buffer_alloc
151+
(gdb) continue
152+
153+
设置条件断点
154+
155+
(gdb) b buffer_alloc if size > 4096
156+
157+
在android设备上操作蓝牙(比如刷新操作)之后就能停在buffer_alloc函数
158+
92159
## 通过串口调试内核
93160

94161
### 配置内核

0 commit comments

Comments
 (0)