This page describes the basics for using a custom build of the Gnu debugger (gdb) to debug Native Client applications on 64-bit Windows.NOTE: We are in the process of implementing a modified version of GDB that can do a better job of debugging Native Client modules on Windows. In the mean time, this page explains how you can get some of the benefits through an interim solution. BuildingDebugging on x86-64Currently you can download a pre-built build of gdb using the nacl_sdk. Steps:
The debugger will be installed into nacl_sdk\gdb_builds\gdb-win-builds as gdb-win64-remote-x86-64.exe If you still want to build your own debugger, here are the instructions:
Debugging on i386The instructions for building a version of gdb to debug a 32-bit nexe are very similar to the instructions for building a 64 bit build. Instead of MinGW for 64 bit machines, you need plain old mingw32 which can be obtained here: http://sourceforge.net/projects/mingw/files/latest/download For step 10, you need to specify a 32 bit linux architecture as your target instead of a 64 bit architecture. Using gdb to debugFollow these instructions to debug a NaCl module running in Chrome on 64-bit Windows.
Setting up Visual StudioAdd the gdb script from the previous section to the Visual Studio project to make it easy to retrieve and modify.I’ve modified the build.scons to copy the gdb script into a directory containing the nexe and the sources. This is the directory where I start gdb.exe. It is convenient to have Visual Studio run a bat file on execution, i.e., when the developer presses Ctrl-F5. This bat file should also be added to the project to make it easy to find and modify. Here is an example: @echo off start c:\work\102105\chrome.exe --incognito --enable-nacl --no-sandbox ^ --show-fps-counter --enable-nacl-debug ^ http://localhost:5103/apps_nacl/tentacles/out/tentacles.html cd c:\work\apps_nacl\tentacles\out c:\work\gdb\gdb-7.3.50.20110902\build\gdb\gdb.exe --command=tentacles.gdb The 32 bit version of the debug server can be found in the main Pepper Bundle of the SDK, under debugger\nacl-gdb-server\Release The 64 bit version can be found in the same bundle, under debugger\nacl-gdb-server\Release Start out-of-process debug server by: $>nacl-gdb_server [options] --program "program to debug" where options are:
--port <number> : port to listen for a TCP connection, default is 4014
--cm : compatibility mode - if specified, behaves exactly as in-process debug stub
Example:
$>nacl-gdb_server --port 4014 --cm --program "c:\chrome.exe --incognito http://localhost:5103/hello_world_c/hello_world.html"
Note: there's no need to specify --no-sandbox flag.
Type Ctrl-C or 'quit' to exit. Example output: nacl-gdb_server v0.5 64-bits ... <<<<[10/19/11 21:18:57.367] [TR100.2] Starting process [D:\src\\chrome-win32\chro
me.exe --incognito http://localhost:5103/hello_world_c/hello_world.html]...
>>>>
<<<<[10/19/11 21:18:59.324] [OutputDebugString] [{7AA7C9CF-89EC-4ed3-8DAD-6DC84302AB11} -versio
n 1 -event AppCreate -nap 000000000024E070 -mem_start 0000000C00000000 -user_entry_pt 000000000
002CBC0 -initial_entry_pt 000000000FC00200] pid=6428 tid=5040
>>>>
<<<<[10/19/11 21:18:59.328] [OutputDebugString] [{7AA7C9CF-89EC-4ed3-8DAD-6DC84302AB11} -versio
n 1 -event ThreadCreate -natp 00000000414F06C0] pid=6428 tid=4800
>>>>
<<<<[10/19/11 21:18:59.328] [TR100.5] NaClThreadStart mem_base=0000000C00000000 entry_point=000
000000002CBC0 thread_id=4800
>>>>
<<<<[10/19/11 21:18:59.329] [TR100.6] CompatibilityMode: setting breakpoint at 0000000C0002CBC0
>>>>
<<<<[10/19/11 21:18:59.331] [TR100.7] Halted: pid=6428 tid=4800
debugevent=dwDebugEventCode=0x1 dwProcessId=0x191C dwThreadId=0x12C0 NaClEventId=0
>>>>
CreateSockAddr : on INADDR_LOOPBACK
<<<<[10/19/11 21:18:59.338] [TR100.1] Started listening on port 4014 ...
>>>>
<<<<[10/19/11 21:18:59.339] [TR100.8] CompatibilityMode: hit breakpoint>>>>
You can start gdb and connect to the debug server now.
Look at the line with "[TR100.5] NaClThreadStart mem_base=0000000C00000000". This is your NaCl base address:
gdb> add-symbol-file <NEXE_PROJECT_NAME>_x86_64_dbg.nexe [0xC00000000 +text_section_address] Make sure you are running 32-bit debug server on 32-bit windows, and 64-bit debug server on 64-bit Windows.
|
