These instructions will help you debug programs, including the chromium browser on your chromium os netbook.
and build Chrome like normal. If you need a 32-bit build, then add "target_arch=ia32" to GYP_DEFINES. It would be:
export GYP_DEFINES="chromeos=1 target_arch=ia32"
We recommend that developers use gdb to debug their Chromium-based OS. The gdb is already included in the chromium os image. You can chroot into your mounted image or open a new terminal in an existing system with an installed copy of Chromium OS.
To get this code on the netbook you can put it someplace accessible via http and use wget on the netbook.
# Remount the root drive read / write
Each time you reboot you'll need to get access to your built program. You could copy it from your build directory, but it's easier to use sshfs to mount that directory directly on the netbook. Also, chrome will be too large to debug natively on the netbook. Instead you'll need to use gdbserver. So do this:
Set up sshfs here.
# Open port so that gdbserver can be reached
The built chrome will be at /tmp/chrome/src/out/Debug/chrome. You can run it from there to test, or within gdbserver. Make sure you run chrome/gdbserver at the netbook's command prompt, not from your remote ssh session.
# Run gdb server, listening on port 1234 (opened in iptables command above)
sudo gdbserver :1234 /tmp/chrome/src/BOARD-NAME_out/Debug/chrome
First build a cross-gdb on your host machine (inside the chroot).
On your host machine run gdb and make sure you set the sysroot to point to the top of your chroot so that gdb can find the proper shared objects.
On your host machine you can connect to this gdb server:
(gdb) target remote IP.ADDR.OF.NETBOOK:1234
The program is now paused and you have control over it from your host machine. To start execution:
If you want to pass command-line arguments, do so on the target machine at the end of the gdbserver command line.
You should follow the Linux debugging tips for help debugging Chromium.
You can debug smaller programs directly. By default, we strip out many of the debugging symbols when creating our debian packages. To ensure that you have the debugging symbols for a particular package, check the rules file under package_source_dir/debian/rules ... and ensure dh_strip is not located anywhere in this file (generally in binary-arch or build-arch rules).
To get started, run
To debug an already running program use:
To debug a new program use:
(gdb) start filenameFor commands while you have a running program:
(gdb) help runningIf you step through a program and start getting jibberish (read: addresses as opposed to source code and line numbers) then you need to include the symbols when building the package. Go back to the debian rules file and make sure -g is in the compiler flags and dh_strip is not anywhere in there.
Chrome logs from the login screen can be found under
Enabling core dumps
Core dumps are disabled by default. To turn it on:
sudo touch /mnt/stateful_partition/etc/enable_chromium_coredumps
Core files will be generated in the directory
Once you have a core file, you can load it to gdb.
gdb /opt/google/chrome/chrome core.chrome.1234
Note: Core files can easily fill up your stateful partition, which can cause various issues. Please clean them up regularly.
emerge/cros deploy strips debug symbols by default, and loading a core file into gdb may not give you much info without these symbols.
To preserve debug symbols, compile chrome for chromeos with the following environment variables (in chroot).
The 2nd one will exclude webkit debug symbols which is quite large and probably not
useful for debugging chrome on chromeos. If you want to have webkit debug symbols, you may skip it.
If you are planning to use gmerge to build and copy a debug chrome image with symbols, you will need to create an image with a larger rootfs size, e.g.:
(chroot) ./build_image --adjust_part='ROOT-A:+1G' --noenable_rootfs_verification test
(Run ./build_image --help for default values)
If you are using a pre-built test image (ex, from buildbot artifacts), download the "debug" archive file (which should contain files like debug/*.debug),
extract to /usr/local/lib (ex, Chrome's debug file should be /usr/local/lib/opt/google/chrome/chrome.debug), and start GDB.
You may want to kill currently running chrome and run your own copy (via sshfs for example), or want to leave
the state when chrome crashes. To do that, you need to tell session manager not to restart chrome by creating a file:
Note that this is temp file, so you need to re-create the file when you restart chromium os.