Debbuging webkit using gdb ?

1,836 views
Skip to first unread message

oleberre

unread,
Aug 4, 2009, 12:36:52 PM8/4/09
to android-platform
Hi

I am trying to find a solution to debug webkit while running the
emulator.

I am trying to attach GDB to the emulator process but then, symbols of
libwebcore.so are not loaded
automatically.

If I try to add them, I have an error,or a warning ? (see below) :

(gdb) add-symbol-file ./out/target/product/generic/symbols/system/lib/
libwebcore.so
The address where ./out/target/product/generic/symbols/system/lib/
libwebcore.so has been loaded is missing

I honestly do not know if I go in the right direction.
So, does anybody have an idea how I could debug webkit ?

Thanks in advance.
Olivier.

Percy

unread,
Aug 5, 2009, 4:58:23 AM8/5/09
to android-platform
I also want to how to debug webkit,If somebody have found the
methord,please Let's know.

Leon Scroggins III

unread,
Aug 10, 2009, 11:03:53 AM8/10/09
to android-platform
Unfortunately, this isn't published anywhere publicly. Here is how it
is done:

Debug Native C++ Code:
To get meaningful debug info, you do need to build WebCore with -
O0. It is simple. Add the following to your buildspec.mk and rebuild
webcore and xml2.
If you don't have buildspec.mk under the root directory yet, please
copy build/buildspec.mk.default to the root (android/)
DEBUG_MODULE_libwebcore:=true
DEBUG_MODULE_libxml2:=true
TARGET_CUSTOM_DEBUG_CFLAGS:=-O0 -mlong-calls
Add "ADDITIONAL_BUILD_PROPERTIES += debug.db.uid=100000" so that it
will wait for you to connect gdb when crashed. Use "rm out/target/
product/dream/
system/build.prop" to make sure it takes effect.
To rebuild webcore and xml2:
make clean-libwebcore clean-libxml2 && make

Note: If you get system image is too large, you can manually
change vendor/htc/dream/BoardConfig.mk, and set
BOARD_SYSTEMIMAGE_MAX_SIZE to a bigger number, e.g., 94371840
(sapphire's cap).

Debugging native code on emulator is much better now.
Start emulator and activate browser.
In a different shell, do "gdbclient app_process :5039 browser"
It should connect to emulator now, and you should see following (the
first three lines) in gdb. Type "c" for continue.
__futex_wait () at system/bionic/arch-arm/bionic/atomics_arm.S:121
121 ldmia sp!, {r4, r7}
Current language: auto; currently asm
(gdb) c
Continuing.
If you want to use Eclipse, it will be easier if you have Eclipse
3.3 instead of 3.2 (on Mac). Here is how to set up debug
configuration.

Run -> Debug..., select C/C++ Local Application, then click New.
Give a name to your configuration, like release_native, select android
project, and android/out/target/product/dream/symbols/system/bin/
app_process for the application.
In Debugger tab, select GDB Server for the debugger.
Under Debugger Options choose Main tab first, enter android/prebuilt/
darwin-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gdb as GDB debugger.
Choose TCP for connection and use 5039 as port.
Then under Shared Libraries, add android/out/target/product/dream/
symbols/system/lib.
Davidc: Not sure if the is the same for everyone, but I had to reduce
the length of the paths to avoid GDB timing out. To do this, remove
the paths set in the Source tab, and add the path to the files you are
debugging.

To debug an application with Eclipse, you need to gdbserver on the
target (emulator or hw) and forward the port
In a shell, do "adb forward tcp:5039 tcp:5039".
In the shell, do "adb shell gdbserver :5039 --attach `pid browser`".
Start the debugger in Eclipse

If you have trouble to use Eclipse to debug native on Linux, you can
use gdb. To use gdb, you need to create a ~/.gdbinit with following
content:
file ./out/target/product/dream/symbols/system/bin/app_process
set solib-search-path ./out/target/product/dream/symbols/
system/lib
target remote localhost:5039

It does exact the same thing as Eclipse setup. Then you can start
gdb from android/ directory:
./prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gdb

To debug native code before the browser has fully started:
Open DevTools application, select Development Settings
Select Debug App at the top, and pick the browser from the list
(com.android.Browser)
Click 'Wait for debugger'
Go back to home and launch the browser
Follow from step #2 in the steps described above under "Debugging
native code on emulator is much better now."
At this point, GDB is attached but the browser is still waiting for
the Java debugger
Attach the Java debugger and the browser will automatically continue

oleberre

unread,
Aug 11, 2009, 7:39:31 AM8/11/09
to android-platform
Thank you very much.

I will give it a try as soon as possible.

Regards.
Olivier

oleberre

unread,
Aug 11, 2009, 11:48:40 AM8/11/09
to android-platform
Cool, it is working :-)

Even if I have a few warnings like this one :

warning: .dynamic section for "/mydroid/out/target/product/generic/
symbols/system/lib/libsonivox.so" is not at the expected address
(wrong library or version mismatch?)


Also, I was able to set a break point using the line number, but not
using a name function but this is not so
bothering.

Thanks again.
That will really make things easier.

Regards.

Olivier.
Reply all
Reply to author
Forward
0 new messages