This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: calling glibc mallinfo() from GDB after attaching to a process?


Chris Markle <cmarkle@sendmail.com> wrote:
> I am getting exactly this seg fault when calling mallinfo(). Do later 
> versions of gdb deal better with this?

No, they don't.  I'm getting this seg fault with both gdb 6.2 and
gdb HEAD 2004-08-30.

This happens even when I use the debug version of glibc
with LD_LIBRARY_PATH=/usr/lib/debug.

However, this works:

  (gdb) print __libc_mallinfo()

Looking at "readelf -w /usr/lib/libc.so.6", there is a subprogram
named "__libc_mallinfo", but no subprogram named mallinfo.  "mallinfo"
is actually just a weak alias for "__libc_mallinfo".

It looks like gdb doesn't pick up the type information for "mallinfo".
That causes gdb to believe that "mallinfo" is a function that takes no
arguments and returns an integer.  So when gdb makes the call, it
neglects to use the struct return-value convention and mallinfo dies in
the assembly code that copies the struct return-value back to the
caller-specified area.

I have an old glibc: red hat linux 8, glibc 2.2.93-5-rh.
I don't know if this is better with newer glibc's.

Michael


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]