top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Debugging Android Code

+1 vote
546 views

Can any one please guide me to debug Android code. I tried to use GDB and GDBServer for this but couldn't succeed.

posted Aug 23, 2013 by Sheetal Chauhan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
you can use gdb and gdbserver. Please Google.
I already googled and tried _gdb_ and _gdbserver_ to debug aosp code. Like I attach gdb server with _NETD_ process on mobile device and from remote gdb client the source path of android _NETD_ code locations. but from (GDB) TARGET REMOTE X.X.X.X:XXXX command can't debug it as running binary doesn't have debugging symbol details. Even (GDB) FILE \'ANDROID/ROOT/LOCATION/SYSTEM/NETD\' couldn't help.

While googling found some pointers to debug ndk/jni apps, but not aosp code. Can you tell me what I am missing here?

1 Answer

+1 vote

Easy answer is to use gdbclient function defined in envsetup.sh. you must source in it before building android. To have symbols, you need to define so-search-path in gdb. libraries and binaries at out/target/product/armv9/system/ are all stripped. check out out/target/product/armv9/symbols instead.

answer Aug 23, 2013 by Meenal Mishra
Similar Questions
+1 vote

How can we debug the Android framework Java code? i know how I can debug the c/c++ code with the help of GDB server etc, but I searched a lot on Google but did not get the solution, currently i am totally relying on Logs but I really need something to Debug the java code inside framework and etc?
please give me some pointers or some details about debugging AOSP framework java code?

+1 vote

I found that most released apps(including system apps) can be debugged on the emulator by the way following:
1. install the app on the emulator, and launch it
2. run adb shell ps to get the pid of the app
3. run adb jdwp, if you find the pid in the output, then you can attach to the app by running
adb forward tcp:1234 jdwp:$pid_you_find and jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=1234
4. you can use commands such as "classes" to see the classes of the app, even "stop" to set breakpoint and "eval" to run many functions and see the members of the objects.
I have 2 questions:
1. Why these tricks fail on the phones? What's the difference between the rom of emulator and phones?
2. How to avoid my app being debugged through such way?

0 votes

We are running debian linux stable (Jessie) with apache 2.4.10 and mod_wsgi 4.3.0-1 on a x86_64 machine. Our application is written in python 2.7 and django 1.8.

The list of modules as reported by apachectl -M are:Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_worker_module (shared) negotiation_module (shared) perl_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) status_module (shared) wsgi_module (shared)

We were getting segmentation faults when rest api clients were making requests. The apache error log has the following messages:

[Mon Jul 27 09:04:38.375433 2015] [core:notice] [pid 32693:tid 140315326191488] AH00052: child pid 32700 exit signal Segmentation fault (11)
[Mon Jul 27 09:04:38.375556 2015] [core:notice] [pid 32693:tid 140315326191488] AH00052: child pid 32701 exit signal Segmentation fault (11)

I have enabled core dumps by setting ulimit to unlimited and adding core dump config directive in the apache2.conf file.
but the core dumps are not happening. When I tried to debug using gdb (gdb /usr/sbin/apache2), the environment variables are not getting read. Any clues on how to go about this?

...