Bug 634660 - "heap" command sometimes not available
Summary: "heap" command sometimes not available
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 14
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-16 16:20 UTC by Dave Malcolm
Modified: 2010-10-05 13:15 UTC (History)
3 users (show)

Fixed In Version: gdb-7.2-16.fc14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-10-05 13:15:39 UTC
Type: ---


Attachments (Terms of Use)

Description Dave Malcolm 2010-09-16 16:20:13 UTC
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):
gdb-heap-0.5-1.fc14.x86_64

How reproducible:
100%

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
  CtrlC
  (gdb) heap

Comment 1 Dave Malcolm 2010-09-21 23:02:28 UTC
libc.so.6 contains numerous malloc-related symbols:

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

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 23:26:14 UTC
I tried fixing this on a F14 x86_64 vm, but it didn't work.

I tried moving the hook for this code:
  /usr/share/gdb/auto-load/lib64/ld-2.12.90.so-gdb.py
to:
  /usr/share/gdb/auto-load/lib64/libc.so.6-gdb.py
and to 
  /usr/share/gdb/auto-load/lib64/libc-2.19.90.so-gdb.py

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 08:35:46 UTC
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 09:27:48 UTC
Upstream post:
[patch] python: load *-gdb.py for shlibs during attach
http://sourceware.org/ml/gdb-patches/2010-09/msg00365.html

Comment 5 Fedora Update System 2010-09-22 09:28:53 UTC
gdb-7.2-7.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gdb-7.2-7.fc14

Comment 6 Dave Malcolm 2010-09-22 15:15:33 UTC
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:
  /usr/lib/debug/lib64/libc-2.12.90.so.debug-gdb.py
  /usr/lib/debug/usr/lib/debug/lib64/libc-2.12.90.so.debug-gdb.py
  /usr/share/gdb/auto-load/usr/lib/debug/lib64/libc-2.12.90.so.debug-gdb.py
  /lib64/libc-2.12.90.so-gdb.py
  /usr/lib/debug/lib64/libc-2.12.90.so-gdb.py
  /usr/share/gdb/auto-load/lib64/libc-2.12.90.so-gdb.py

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 18:43:18 UTC
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 14:12:26 UTC
gdb-7.2-12.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gdb-7.2-12.fc14

Comment 9 Fedora Update System 2010-09-27 15:29:14 UTC
gdb-7.2-15.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gdb-7.2-15.fc14

Comment 10 Fedora Update System 2010-09-28 23:57:51 UTC
gdb-7.2-16.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gdb-7.2-16.fc14

Comment 11 Fedora Update System 2010-10-05 13:15:25 UTC
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.