Search code examples
google-chromegoogle-chrome-extensiongdbgoogle-nativeclient

Chrome: Attaching nacl-gdb to packaged application loaded as an unpacked extension


I have built a simple NaCl application. For running the application I use technique 2 described in Nacl Developer's guide, which means that instead of running a local server I load my application as unpacked extension to chrome. The application runs fine so far.

Now I want to experiment with nacl-gdb and attach my application to it at startup. In the NaCl Developer's guide there are only instructions on how to attach nacl-gdb on an application that is run with local server(technique 1). I made a search to the internet and I ended up with the following approach in order to attach nacl-gdb for an application that is being ran with technique 2:

  1. I enabled "Native Client GDB-based debugging" flag of Chrome.
  2. I started chrome from a terminal like this: ./chrome "--nacl-gdb=gnome-terminal -- /media/sdb1/leonidasbo/AncientRoot/nacl_sdk/pepper_27/toolchain/linux_x86_glibc/bin/x86_64-nacl-gdb"
  3. When Chrome launched, I navigated to my application.

With this approach, Chrome automatically started nacl-gdb when I opened my application. However nacl-gdb tried to attach but with no success. The output was the following:

*This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=x86_64-nacl". Reading symbols from /opt/google/chrome/nacl_irt_x86_64.nexe...(no debugging symbols found)...done. Don't know how to attach. Try "help target". (gdb)*

It seems that gdb cannot attach to my application. I tried executing "target exec /path/to/my.nexe", but nothing changed. Am I missing something here? Is there any other way to debug applications loaded as unpacked extensions with nacl-gdb?

My OS is Ubuntu 12.04 and I am using pepper_27 of nacl_sdk. Chrome version is 27.0.1453.93.

Thanks


Solution

  • I assume you were using this guide, which I was using earlier as well. It is out of date. These are the real instructions. It seems that the way you attach the debugger has completely changed, and it is no longer possible to use --nacl-gdb (that is planned for removal). You must manually attach the debugger by following these steps.

    The full guide is here, but I'll summarize:

    1. Launch Chrome with chrome --enable-nacl --enable-nacl-debug --no-sandbox --disable-hang-monitor.
    2. Run <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/x86_64-nacl-gdb (with no arguments).
    3. Enter these commands into the gdb prompt:
      • (gdb) nacl-manifest <path-to-your-.nmf-file>
      • (gdb) nacl-irt <CHROME-DIR>/nacl_irt_x86_64.nexe
      • (gdb) target remote localhost:4014

    Now you can use gdb as normal. (If you just want to run the application until it crashes, start by typing continue.)