These instructions will help you debug programs, including the chromium browser on your chromium os netbook.
export GYP_DEFINES="chromeos=1 target_arch=ia32"
and build Chrome like normal. You need the "ia32" part if you're building on a 64-bit Linux system. ChromeOS currently only runs in 32-bit mode and the 64-bit binary will give you a strange error if you try to run it.
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.
The chrome logs are disabled by default, as they can have private information in them. To turn them on:
sudo mount -o remount,rw /
sudo vi /sbin/session_manager_setup.sh
remove the comment character that begins this line:
The log will be written to the directory /home/chronos/user/log.
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 statefull partition, which can cause various issues. Please clean them up regularly.
gmerge 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 --rootfs_partition_size 2048 --rootfs_size 1850 --rootfs_hash_pad 16 --withdev --noenable_rootfs_verification --test
(Run ./build_image --help for default values)
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.