Re: GDB: "/opt/google/chrome/chrome": not in executable format: File truncated

1,152 views
Skip to first unread message

Denis Glotov

unread,
Jun 27, 2011, 4:19:30 PM6/27/11
to Chromium OS dev
Hi devs!

If I use 
FEATURES=nostrip emerge-x86-alex chromeos-chrome
to build Chrome within chroot and keep the binary not stripped, gdb cannot load the resulting chrome image:

(cr) ((b4c1382...)) glotov@glotov-z600 ~/trunk/src/scripts $ sudo chroot /build/x86-alex/
bash: /dev/null: Is a directory
glotov-z600 / # gdb
GNU gdb (Gentoo 7.1 p1) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
(gdb) file /opt/google/chrome/chrome
"/opt/google/chrome/chrome": not in executable format: File truncated
(gdb) quit
glotov-z600 / # which gdb
/usr/bin/gdb
glotov-z600 / # file /usr/bin/gdb
/usr/bin/gdb: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped


If I don't use FEATURES=nostrip, the strip command takes place during the build:

strip: i686-pc-linux-gnu-strip --strip-debug --keep-file-symbols
   opt/google/chrome/libosmesa.so
   opt/google/chrome/libffmpegsumo.so
   opt/google/chrome/chrome-sandbox

and gdb still refuses symbols, although now it have them in /usr/lib/debug/opt/google/chrome/chrome.debug:

Reading symbols from /opt/google/chrome/chrome...`/usr/lib/debug/opt/google/chrome/chrome.debug': can't read symbols: File truncated.

Have anything changed with the way to get symbols for debugging?

Note. My normal defines are:
declare -x BOARD=x86-alex 
declare -x BUILDTYPE=Release
declare -x CHROME_ORIGIN=LOCAL_SOURCE
declare -x FEATURES="-usersandbox" 
declare -x USE="-build_tests internal chrome_internal"
declare -x KEEP_CHROME_DEBUG_SYMBOLS=1

--
Thank you,
Denis

Daniel Erat

unread,
Jun 27, 2011, 7:45:44 PM6/27/11
to glo...@chromium.org, Chromium OS dev
gdb meant what it said: /opt/google/chrome/chrome is truncated because an unstripped Chrome binary is too large to fit on a default-sized Chrome OS root partition.

With KEEP_CHROME_DEBUG_SYMBOLS enabled, you should at least get (some) function names in gdb backtraces.

I believe that some engineers build unstripped Chrome binaries on their workstations, sshfs-mount the directories on their Chrome OS devices, and run it that way.  I think that I've seen email describing the procedure.

In the recent past, I've copied unstripped Chrome binaries and the related resources and libcros library somewhere under /home/chronos on my device and symlinked /opt/google/chrome to the new directory.  This works too.

--
Chromium OS Developers mailing list: chromiu...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en

Scott Byer

unread,
Jun 27, 2011, 8:23:20 PM6/27/11
to Daniel Erat, glo...@chromium.org, Chromium OS dev
You can actually get an unstripped chrome, with webkit symbols even if you're so inclined, if you have build_image bump out the partition and fs sizes:  --rootfs_partition_size=2048 --rootfs_size=1874 --rootfs_hash_pad=16

Makes the write of the image to the USB stick take longer, but you can get full stack traces and debugging information from a remote attached gdb that way.

A combination of:
and

also seems to work, I'm still trying to get that process smoother for myself.

-Scott

(putting notes in the docs on what I find once I have things working nicely is on my to-do list)

Denis Glotov

unread,
Jun 28, 2011, 2:58:13 AM6/28/11
to Daniel Erat, Chromium OS dev
I forgot to mention two things (in order to keep the mail concise).
1. I run GDB on the host, chrooted to ~/chromiumos/chroot/build/x86-alex/. So I thing that size restrictions should not harm the debugger, or could they?
2. I compiled with Clang. This must be the main problem. To verify this, I just recompiled everything with g++ in usual way and GDB accepted symbols. So it must be some Clang symbols incompatibility. Currently investigating...

--
Thank you,
Denis

Rahul Chaturvedi

unread,
Jun 29, 2011, 1:29:11 AM6/29/11
to glo...@chromium.org, Daniel Erat, Chromium OS dev
I think you might be running into a known issue with remote debugging chrome on cros. There is a workaround for it with the disable_pie flag.

It's not a good idea to keep debug symbols in the binary - you can always load them from the symbol file instead.
Even if you use sshfs to load the unstripped binary, you'll likely run out of memory very quickly.

Instead, if you want to use remote debugging for chrome, follow the following steps and they should work even with a stripped binary,

  • Build chromeos-chrome with EXTRA_BUILD_ARGS="disable_pie=1"
  • Either build_image to get the chrome binary on a new image or gmerge it
then,

  • gdb /path/to/your/unstripped/chrome/binary

once gdb loads,

  • set sysroot /path/to/your/build/root/inside/cros/chroot
  • set solib-absolute-prefix /path/to/your/build/root/inside/cros/chroot
  • directory /path/to/chrome/src
  • target remote IP:PORT
and your symbols should work fine.


/rkc

Scott Byer

unread,
Jun 29, 2011, 12:36:42 PM6/29/11
to Rahul Chaturvedi, glo...@chromium.org, Daniel Erat, Chromium OS dev

Rahul Chaturvedi

unread,
Jul 10, 2011, 10:23:42 PM7/10/11
to scot...@chromium.org, glo...@chromium.org, Daniel Erat, Chromium OS dev
I've added the information about disable_pie to https://sites.google.com/a/chromium.org/dev/chromium-os/how-tos-and-troubleshooting/remote-debugging
I also added the solib-absolute-prefix setup line to the instructions for gdb, since that should be there for all binaries being remote debugged anyway.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages