Skip to content

Steps to debug Webkit using Eclipse.



Here are the steps to debug Webkit in Linux using Eclipse. This has been reproduced here verbatim from
here
.I am currently verifying these steps.



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 <br>

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
[/cpp]
“adb forward tcp:5039 tcp:5039”.
[/cpp]
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.

07th July : Update : We are getting an error with system/bin/linker.Need to fix it to load the symbols properly.