Bug 634660 - "heap" command sometimes not available
"heap" command sometimes not available
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Jan Kratochvil
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2010-09-16 12:20 EDT by Dave Malcolm
Modified: 2010-10-05 09:15 EDT (History)
3 users (show)

See Also:
Fixed In Version: gdb-7.2-16.fc14
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-10-05 09:15:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dave Malcolm 2010-09-16 12:20:13 EDT
Description of problem:
I tried attaching to gedit, but "heap" was not available; the hooks were not autoloaded

"Reading symbols from /lib64/libc.so.6...Reading symbols from /usr/lib/debug/lib64/libc-2.12.90.so.debug...done."
whereas my hooks are in: /usr/share/gdb/auto-load/lib64/ld-2.12.90.so-gdb.py
do we need them in both?  or to be moved?

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
  $ gedit&
  $ gdb attach $(pidof -x gedit)
  (gdb) heap
Actual results:
Undefined command: "heap".  Try "help".

Expected results:
Report on heap usage within gdb process

Additional info:
Seems to locate when invoked in this form:
  $ gedit
  (gdb) run
  (gdb) heap
Comment 1 Dave Malcolm 2010-09-21 19:02:28 EDT
libc.so.6 contains numerous malloc-related symbols:

$ eu-readelf -s /lib64/libc.so.6|grep malloc|wc -l

and contains "main_arena".

$ eu-readelf -s /lib64/libc.so.6|grep main_arena
 1118: 00000032ccd8b180   2184 OBJECT  LOCAL  DEFAULT       34 main_arena

ld-2.12.90.so contains just two "malloc" functions, which are marked as "WEAK":
$ eu-readelf -s /lib64/ld-2.12.90.so|grep malloc
   23: 00000032cc615fe0     13 FUNC    WEAK   DEFAULT       11 malloc@@GLIBC_2.2.5
  470: 00000032cc615fe0     13 FUNC    WEAK   DEFAULT       11 malloc

and does not contain "main_arena".

Looks like I should be autoloading the code based on whether libc.so is loaded, not ld.
Comment 2 Dave Malcolm 2010-09-21 19:26:14 EDT
I tried fixing this on a F14 x86_64 vm, but it didn't work.

I tried moving the hook for this code:
and to 

but in each case no autoloading occurred when attaching to a "gedit" process.

$ strace gdb attach $(pidof -x gedit) 2>&1 | grep gdb.py
shows very few files being autoloaded.

gdb folks: any ideas why:
  $ gedit &
  $ gdb attach $(pidof -x gedit)
wouldn't have gdb try to autoload -gdb.py files for the various DSOs making up the gedit process?

(reassigning to "gdb" for advice on the above; feel free to reassign back to "gdb-heap")
Comment 3 Jan Kratochvil 2010-09-22 04:35:46 EDT
It works for spawned executables but not for attached executables.
gdbpy_global_auto_load is temporarily suppressed there.
Comment 4 Jan Kratochvil 2010-09-22 05:27:48 EDT
Upstream post:
[patch] python: load *-gdb.py for shlibs during attach
Comment 5 Fedora Update System 2010-09-22 05:28:53 EDT
gdb-7.2-7.fc14 has been submitted as an update for Fedora 14.
Comment 6 Dave Malcolm 2010-09-22 11:15:33 EDT
I was using gdb-7.2-3.fc14.x86_64

Trying new gdb: gdb-7.2-7.fc14.x86_64

strace on the new gdb confirms that it's trying to load -gdb.py files for the
various dynamically-loaded DSOs.  Thanks!

As it happens, the test case above now works, in that "ld" is linked into any
process using libc, so this happens to also fix the gdb-heap issue described in
comment #0.

In particular, it tried to load:

The last of these seems like the most appropriate place for my hooks.

But given that it's also loading relative to "ld.so", this works, without
needing to change gdb-heap.

Marking as VERIFIED.
Comment 7 Fedora Update System 2010-09-22 14:43:18 EDT
gdb-7.2-7.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gdb'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/gdb-7.2-7.fc14
Comment 8 Fedora Update System 2010-09-25 10:12:26 EDT
gdb-7.2-12.fc14 has been submitted as an update for Fedora 14.
Comment 9 Fedora Update System 2010-09-27 11:29:14 EDT
gdb-7.2-15.fc14 has been submitted as an update for Fedora 14.
Comment 10 Fedora Update System 2010-09-28 19:57:51 EDT
gdb-7.2-16.fc14 has been submitted as an update for Fedora 14.
Comment 11 Fedora Update System 2010-10-05 09:15:25 EDT
gdb-7.2-16.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.