Use GDB for debugging in Android emulator

Source: Internet
Author: User

I believe many developers would like to know how to use GDB in Android development. Today we will use GDB for debugging in Android emulator, so that you can learn about GDB debugging. There are two ways to debug GDB in the emulator of the Android mobile development platform: Use gdbserver directly or use GDB for debugging.

1. Use GDB server for debugging:

A. Download the gdb server http://www.billrocks.org/android_libs/bin/ for Android from the following link

B. Install the downloaded GDB server to your emulator.
1) Start emulator
2) download the gdb server to your emulator
Open a terminal and run:
$ ADB Shell
# CD Data
# Mkdir Bin
Run in another terminal:
$ ADB push gdbserver/data/bin

In this way, the gdbserver is downloaded to the emulator through the android ADB.

C. Run gdbserver:
#/Data/bin/gdbserver 10.0.2.2: 1234 [ARGs...]

D. Return to another terminal and map the Port:
$ Telnet local host 5554
Telnet to emulator and run the following command:
Redir add TCP: 1234: 1234

E. Run GDB on the third terminal:
$ GDB Test
Test is for debugging.ProgramAnd then run the following command on the gdb command line:
(GDB) target remote localhost: 1234

Then you can debug the program as you did with GDB.

2. Use local GDB for debugging.

A. Download the android debugging package from the following link. It is a binary file compiled using the android toolchain:

Http://ortegaalfredo.googlepages.com/android-debug.tbz

B. decompress the debugging package and download GDB to your emulator. If you have a real mobile phone, you can debug it as follows:
$ ADB push GDB/data/bin

C. Use ADB to connect to emulator

$ ADB Shell

When running GDB, the following information is displayed:

#/Data/bin/GDB

Dlopen failed on 'libthread _ dB. so.1 '-libthread_db.so.1: cannot open shared object file: no such file or directory
GDB will not be able to debug pthreads.

Gnu gdb 6.7
Copyright (c) 2007 Free Software Foundation, Inc.
License gplv3 +: gnu gpl Version 3 or later 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 "-- Host = arm-None-Linux-gnueabi -- target = ".
(GDB)

D. Then you can debug the program as you did with GDB.

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.