Bug 141153

Summary: [GDB] Couldn't use gdb tool well for WebKit GTK
Product: WebKit Reporter: Park HyukWoo <clover2123>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs-noreply
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Linux   

Description Park HyukWoo 2015-02-02 04:16:16 PST
I built WebKit Gtk(revision 174059) on Ubuntu 14.04 with follow commands

$ Tools/Scripts/build-webkit --gtk --debug

and finally got MiniBrowser file in WebKitBuild/Debug/bin folder.

but when I debug MiniBrowser with gdb tool, I couldn't set breakpoints for it.

for example, I ran the following simple html file 

== test.html == 
<html>
<head>
<script>
window.onload = function() {
    var now = new Date();
    var a = 4;
    var c = Math.sqrt(4);
    alert("wow");
}
</script>
</head>
<body>
</body>
</html>

and set some breakpoints in WebCore and JavaScriptCore module 

but when I ran MiniBrowser in gdb, it finished execution(html load) without any break even if some breakpoints were set.

I ran MiniBrowser in gdb with follow commands

$ Tools/jhbuild/jhbuild-wrapper --gtk run gdb --args WebKitBuild/Debug/bin/MiniBrowser

$ b JSC::evaluate

$ b WebCore::Document::dispatchWindowLoadEvent



did i do something wrong? (maybe multi-thread issue?)

what should i do to debug WebCore/JavaScriptCore module in MiniBrowser?

I'm debugging MiniBrowser to know the loading sequence of html file in WebKit Gtk.
Comment 1 Park HyukWoo 2015-02-02 20:44:31 PST
[SOLVED]

I made a mistake for debugging WebProcess.
I wrote the debugging tips for others.

when you want to debug Web Process,
you should use gdb in remote terminal and attach to 'WebKitWebProcess' process.
because Web Process is executed in WebKitWebProcess not in MiniBrowser process.

So, just connect to WebKitWebProcess in gdb by following command

$ gdb -p <pid of WebKitWebProcess>

However that doesn't work in all cases, because the web process might already have crashed when you are trying to connect to it.

You can use the WEB_PROCESS_CMD_PREFIX environment variable for that purpose. If that variable is defined the web process will be run using its value as a prefix.

Example:

WEB_PROCESS_CMD_PREFIX='/usr/bin/gdbserver localhost:8080' WebKitBuild/Debug/bin/MiniBrowser

and in a different terminal:

$ libtool --mode=execute gdb WebKitBuild/Debug/bin/WebKitWebProcess
(gdb) target remote localhost:8080