设为首页 加入收藏

TOP

使用GDB调试Android Native 层代码(二)
2019-09-01 23:26:05 】 浏览:65
Tags:使用 GDB 调试 Android Native 代码
51
(gdb) n ---- 继续执行代码,可看到程序输出"Input numeric is bigger than 10."。我们通过修改寄存器的值,对程序代码的执行过程进行了控制。
main (argc=2, argv=0xbf89e694) at main.c:24
24 printf("Input numeric is bigger than 10./n");
(gdb) c
Continuing.
Input numeric is bigger than 10.

Program exited normally.
(gdb)
--------------example:
gdb 调试:
$adb shell

看看它的process id是多少

#ps | grep browser

记住你要的pid

启动gdbserver, 指定在哪个prot上监听client,指定调试哪个进程

#gdbserver :5039 --attach pid

开始cient端的工作

On your workstation, forward port 5039 to the device with adb: 不知道怎么翻译

打开一个新的终端

$adb forward tcp:5039 tcp:5039

$cd ~/mydroid

找一个最新版本的arm-eabi-gdb

$find -name arm-eabi-gdb

记住path

启动gdbclient

$/home/peipei/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gdb /home/peipei/mydroid/out/target/product/generic/symbols/system/bin/app_process

In gdb, Tell gdb where to find the shared libraries that will get loaded:

(gdb)set solib-absolute-prefix /home/peipei/mydroid/out/target/product/generic/symbols

(gdb)set solib-search-path /home/peipei/mydroid/out/target/product/generic/symbols/system/lib

小心,路径别写错,如果错了,gdb是不会告诉你的。

另外,要注意,两个路径都要指向symbols目录。

Connect to the device by issuing the gdb command:

(gdb)target remote :5039

The :5039 tells gdb to connect to the localhost port 5039, which is bridged to the device by adb.

You may need to inspire gdb to load some symbols by typing:

(gdb)shared

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Android Studio教程01-的工程和目.. 下一篇Windows Azure NotificationHub+F..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目