GDB Remote Debugging Android Process-Go

Source: Internet
Author: User

What is GDB

It is a powerful UNIX program debugging tool developed by the GNU organization, which we can use to debug C and C + + code on Android.
It can do 4 things mainly:
  1. Start your program at your own whim.
  2. When you set a breakpoint, the program executes to a breakpoint where it stops. (breakpoint can be an expression)
  3. After the program is stopped, you can see what happens in this program.
  4. Dynamically change the execution environment of the program.

GDB Remote Debugging schematic diagram


as
shown above, we need to use gdbserver to attach to the process we are debugging, and GDB communicates with the socket via ADBD and the gdbserver on the phone.

Remote Debugging Combat

  • Start gdbserver on your phone and attach the process you want to debug and specify the port on which to listen for debug commands (this port is the port on your phone)
$ adb shell# PS   #查看要调试进程的PID # gdbserver:1234--attach   #:1234 is the port number, 96 is the process ID
  • Using ADB to do port mapping, direct the port on the PC to the Gdbserver listening port on the phone
$ adb forward tcp:1234 tcp:1234   #端口映射, maps the 1234 port of the PC to the 1234 port of the phone
  • Start GDB start debugging with the specified PC port message
android_project_root/prebuilt/linux-x86/arm-eabi-4.4.3/$./arm-eabi-gdb   #使用项目下的gdb客户端去连接gdbserver, The type of GDB to choose for the mobile platform, the    version should be consistent with gdbserver.
<gdb> Target remote:1234   #连接本地的: 1234 Port, this port is mapped to the 1234 port of the phone. <gdb> file Xxx/out/target/xx...xx/symbols/system/bin/mediaserver   #加载可执行程序, pay attention to selecting symbols, if the process being debugged is an app process,    Choose App_process here. <gdb> set Solib-search-path xxx/out/target/xx...xx/symbols/system/lib   #加载所有的动态连接库, pay attention to choosing symbols. <gdb> bt   #查看调用堆栈 <gdb> list xxx/xxx. Xxx/xxx.cpp   #查看相关文件 <gdb> b    #在文件的第100行打断点 <gdb> c    #继续执行程序

Simplifying the commissioning process with Gdbclient

  • into the source project directory, the Environment configuration, the implementation of the build folder under the envsetup.sh and Choosecombo xx xx xx command, then you can use the gdbclient.
  • The ADB shell enters the phone and opens the Gdbserver as before.
  • On the PC side of the source root directory, the implementation of GDBCLIENT-E MEDIASERVER-P 1234 #从1234端口调试mediaserver

GDB Remote Debugging Android Process-Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.