public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* using bfd and shared libraries
@ 2003-06-23 17:59 Robert Schweikert
  2003-06-23 18:35 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Schweikert @ 2003-06-23 17:59 UTC (permalink / raw)
  To: gdb; +Cc: Robert Schweikert

Hi,

I am trying to come up with some basic memory tracking tools and one
thing I'd like to do is to write out the function/method in which memory
was being allocated. So far what I have found is that I can use
__builtin_return_address(0) to get the address of function on the stack
that allocates the memory. Then using bfd I can figure out the
function/method symbol. My problem now is that this works for monolithic
executables but not for executables with shared libraries. 

Since gdb handles shared libraries just fine and also uses bfd I was
hoping someone could provide some ideas on how to go about this, or
point me to the code in the gdb source, or to some documentation where
this issue is addressed.

Thanks,
Robert

-- 
Robert Schweikert <Robert.Schweikert@abaqus.com>
ABAQUS

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: using bfd and shared libraries
  2003-06-23 17:59 using bfd and shared libraries Robert Schweikert
@ 2003-06-23 18:35 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-06-23 18:35 UTC (permalink / raw)
  To: Robert Schweikert; +Cc: gdb, Robert Schweikert

On Mon, Jun 23, 2003 at 01:56:04PM -0400, Robert Schweikert wrote:
> Hi,
> 
> I am trying to come up with some basic memory tracking tools and one
> thing I'd like to do is to write out the function/method in which memory
> was being allocated. So far what I have found is that I can use
> __builtin_return_address(0) to get the address of function on the stack
> that allocates the memory. Then using bfd I can figure out the
> function/method symbol. My problem now is that this works for monolithic
> executables but not for executables with shared libraries. 
> 
> Since gdb handles shared libraries just fine and also uses bfd I was
> hoping someone could provide some ideas on how to go about this, or
> point me to the code in the gdb source, or to some documentation where
> this issue is addressed.

You really don't want to do it the same way GDB does...

If you're working on GNU/Linux, dl_iterate_phdr should give you what
you need.  Otherwise, investigate following the "struct link_map"
objects.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-23 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23 17:59 using bfd and shared libraries Robert Schweikert
2003-06-23 18:35 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).