This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debug native system-level code (c++) of Android Sources (AOSP) with DS-5

I'm using DS-5 to debug native code of my custom android application and it works well, my question now is about android source code (AOSP) that i have recompiled.

It's possible to debug the system-level C++ code (with DS-5) ? For example debug native code of system_process ?

Thanks in advance,

Best Regards

  • DS-5 debug connects to an ARM enhanced version of gdb as you already know. You can debug native code in the Android system server (forked by zygote when the system boots up) with DS-5 and debug Java with DDMS. The simplest method to attach the debugger would be to create a new Android project in DS-5 and change the package name to system_process in the AndroidManifest.xml. Then you can go to the DDMS or DS-5 debugger views and attach to any thread you like. You can specify where the Android source is; frameworks/base and libcore contain most of the interesting Android code.

    If you want to catch system_process as it is forked by zygote at boot, you'll have to put system_process in to a loop as it starts, attach GDB and then break out of that loop (e.g. with a variable you edit from within GDB). I know that sounds like a bit of a hack but it is the only way I've able to successfully gotten the gdb server to attach to thread 1 so far. I'll see if I can work up a more elegant solution. Let me know if you have one already.

    Thanks,

    Matt

  • Debugging Android framework components is not that straight forward. The info available on Android source site leaves lot of information to imagination.

    If you want to debug Java services inside system server, please check Debugging Android Java Framework services.

    If you want to debug native application on an Android device, please check Debugging Android native applications.

    The trick to debug native code loaded by system_server is to select app_process as target executable. If you pick system_server, you will see lot of gdb weirdness.

  • hi ... i have this question too ...

    i tested the solution which Mr  Matthew Du Puy said ...

    i created an android project with "system_process" name

    but when i debug it connection failed showed up ...

    .............

    Failed target configuration:

    The script file ( run_nostart.py ) failed during execution:

    Timeout. PID not found!

    Failed target configuration:

    The script file ( run_nostart.py ) failed during execution:

    Timeout. PID not found!

    .......................

    1.JPG

    my debug configuration is

    2.JPG

    in the files tab i filled it like this

    3.JPG

    i did not know what must be apk file ..!! so i put original email app

    could u plz guide me ...

    is there any tutorial which explain how to debug aosp with ds-5 in arm level ....

    Thanks in advance,

    Best Regards

  • hi again ...

    i try this method  for debug  "com.android.phone" process

    this time we have exact and right apk file ....

    i change the simple app package name to "com.android.phone"

    but surprisingly this time despite other time ((try for debug system_process)) ds-5 script could not fine process information and debug button did not activated

    5.JPG 

    i try this whit the original project in AOSP in  packages/apps/Phone directory and result was the same

    what is the problem?

    Thanks in advance,mattdupuy

    Best Regards