Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* How does one get static procedure names?
@ 2009-10-27 18:36 Bruce Korb
  2009-10-27 18:56 ` Paul Pluzhnikov
  0 siblings, 1 reply; 8+ messages in thread
From: Bruce Korb @ 2009-10-27 18:36 UTC (permalink / raw)
  To: gdb, gdb

Hi,

I know GDB has some way to do it, but I couldn't locate
the code that does it.  A pointer on where to look would
be really helpful and greatly appreciated!

Thank you in advance.

Regards, Bruce


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

* Re: How does one get static procedure names?
  2009-10-27 18:36 How does one get static procedure names? Bruce Korb
@ 2009-10-27 18:56 ` Paul Pluzhnikov
  2009-10-27 19:11   ` Bruce Korb
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Pluzhnikov @ 2009-10-27 18:56 UTC (permalink / raw)
  To: Bruce Korb; +Cc: gdb, gdb

On Tue, Oct 27, 2009 at 11:32 AM, Bruce Korb <bruce.korb@gmail.com> wrote:

> I know GDB has some way to do it, but I couldn't locate
> the code that does it.  A pointer on where to look would
> be really helpful and greatly appreciated!

Your question is rather unclear :-(

Are you looking for
A) how to set a breakpoint in a static procedure in GDB, or
B) how to find an address of a given static function in a given executable, or
C) a list of all static functions in a given executable, or
D) something else (if so, what exactly?)

Cheers,
-- 
Paul Pluzhnikov


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

* Re: How does one get static procedure names?
  2009-10-27 18:56 ` Paul Pluzhnikov
@ 2009-10-27 19:11   ` Bruce Korb
  2009-10-27 19:31     ` Daniel Jacobowitz
  2009-10-27 20:10     ` Andreas Schwab
  0 siblings, 2 replies; 8+ messages in thread
From: Bruce Korb @ 2009-10-27 19:11 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb, gdb

On Tue, Oct 27, 2009 at 11:40 AM, Paul Pluzhnikov
<ppluzhnikov@google.com> wrote:
> On Tue, Oct 27, 2009 at 11:32 AM, Bruce Korb <bruce.korb@gmail.com> wrote:
>
>> I know GDB has some way to do it, but I couldn't locate
>> the code that does it.  A pointer on where to look would
>> be really helpful and greatly appreciated!
>
> Your question is rather unclear :-(

Sorry.   When you do a "bt" using gdb, you see the function
names, whether they be "static" or have global (external)
linkage.  The function backtrace_symbols(), on the other
hand, doe *not* print static scope function names.  Even if
it takes some work, I'd like to "fix" the constraint.  However,
I wasn't able to decipher the gdb source well enough to figure
out how it accomplished this feat.  So, is there some place
in the GDB source where I ought to be looking?

Thank you!

Regards, Bruce


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

* Re: How does one get static procedure names?
  2009-10-27 19:11   ` Bruce Korb
@ 2009-10-27 19:31     ` Daniel Jacobowitz
  2009-10-27 19:37       ` Bruce Korb
  2009-10-27 20:10     ` Andreas Schwab
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2009-10-27 19:31 UTC (permalink / raw)
  To: Bruce Korb; +Cc: Paul Pluzhnikov, gdb, gdb

On Tue, Oct 27, 2009 at 11:56:46AM -0700, Bruce Korb wrote:
> Sorry.   When you do a "bt" using gdb, you see the function
> names, whether they be "static" or have global (external)
> linkage.  The function backtrace_symbols(), on the other
> hand, doe *not* print static scope function names.  Even if
> it takes some work, I'd like to "fix" the constraint.  However,
> I wasn't able to decipher the gdb source well enough to figure
> out how it accomplished this feat.  So, is there some place
> in the GDB source where I ought to be looking?

You can't readily do so.  backtrace_symbols is using the dynamic
symbol table, which is loaded into memory.  Local symbols are not
added to the dynamic symbol table.

GDB reads both the local symbol table and the DWARF/stabs debug
information.

You'd need an additional symbol table reader which read them off disk
instead of out of RAM.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: How does one get static procedure names?
  2009-10-27 19:31     ` Daniel Jacobowitz
@ 2009-10-27 19:37       ` Bruce Korb
  2009-10-27 19:43         ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Bruce Korb @ 2009-10-27 19:37 UTC (permalink / raw)
  To: Bruce Korb, Paul Pluzhnikov, gdb, gdb

On Tue, Oct 27, 2009 at 12:27 PM, Daniel Jacobowitz <drow@false.org> wrote:
> On Tue, Oct 27, 2009 at 11:56:46AM -0700, Bruce Korb wrote:
>> Sorry.   When you do a "bt" using gdb, you see the function
>> names, whether they be "static" or have global (external)
>> linkage.  The function backtrace_symbols(), on the other
>> hand, doe *not* print static scope function names.  Even if
>> it takes some work, I'd like to "fix" the constraint.  However,
>> I wasn't able to decipher the gdb source well enough to figure
>> out how it accomplished this feat.  So, is there some place
>> in the GDB source where I ought to be looking?
>
> You can't readily do so.  backtrace_symbols is using the dynamic
> symbol table, which is loaded into memory.  Local symbols are not
> added to the dynamic symbol table.
>
> GDB reads both the local symbol table and the DWARF/stabs debug
> information.
>
> You'd need an additional symbol table reader which read them off disk
> instead of out of RAM.

Exactly.  I know it'd be some work.  I think I need to
call:  dlopen(NULL, RTLD_NOW)

and then copy & fiddle code out of GDB.  yes?  :)
Or, do I have to figure out the actual file name and replace
NULL with that file name?  Either way....now what?
Just point me to some code & I ought to be okay.


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

* Re: How does one get static procedure names?
  2009-10-27 19:37       ` Bruce Korb
@ 2009-10-27 19:43         ` Daniel Jacobowitz
  2009-10-27 20:03           ` Bruce Korb
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2009-10-27 19:43 UTC (permalink / raw)
  To: Bruce Korb; +Cc: Paul Pluzhnikov, gdb, gdb

On Tue, Oct 27, 2009 at 12:33:39PM -0700, Bruce Korb wrote:
> Exactly.  I know it'd be some work.  I think I need to
> call:  dlopen(NULL, RTLD_NOW)

No.  You need to open the file and have your own ELF and symbol table
reader.  They are not in the area mapped by dlopen.

> and then copy & fiddle code out of GDB.  yes?  :)

GDB is almost certainly not where you want to get this code from.  We
just use BFD...

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: How does one get static procedure names?
  2009-10-27 19:43         ` Daniel Jacobowitz
@ 2009-10-27 20:03           ` Bruce Korb
  0 siblings, 0 replies; 8+ messages in thread
From: Bruce Korb @ 2009-10-27 20:03 UTC (permalink / raw)
  To: Bruce Korb, Paul Pluzhnikov, gdb, gdb

On Tue, Oct 27, 2009 at 12:37 PM, Daniel Jacobowitz <drow@false.org> wrote:
> On Tue, Oct 27, 2009 at 12:33:39PM -0700, Bruce Korb wrote:
>> Exactly.  I know it'd be some work.  I think I need to
>> call:  dlopen(NULL, RTLD_NOW)
>
> No.  You need to open the file and have your own ELF and symbol table
> reader.  They are not in the area mapped by dlopen.

OK.  Still not terribly hard:

    {
        static char const exe_fmt[] =
            "/proc/%d/exe";
        char bf[sizeof (exe_fmt) + 12];
        sprintf(bf, exe_fmt, getpid());
        path_len = readlink(bf, exe_path, sizeof (exe_path) - 1);
    }

(This is for Linux only...)

> GDB is almost certainly not where you want to get this code from.  We
> just use BFD...

Ah!  There we go.  That's what I was looking for.  Thank you!


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

* Re: How does one get static procedure names?
  2009-10-27 19:11   ` Bruce Korb
  2009-10-27 19:31     ` Daniel Jacobowitz
@ 2009-10-27 20:10     ` Andreas Schwab
  1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2009-10-27 20:10 UTC (permalink / raw)
  To: Bruce Korb; +Cc: Paul Pluzhnikov, gdb, gdb

Bruce Korb <bruce.korb@gmail.com> writes:

> Sorry.   When you do a "bt" using gdb, you see the function
> names, whether they be "static" or have global (external)
> linkage.  The function backtrace_symbols(), on the other
> hand, doe *not* print static scope function names.

backtrace_symbols can only deal with dynamic symbols, which are the only
ones available at runtime.  If you want to resolve normal symbols you
need to read them from the (unstripped) binary, like addr2line does.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

end of thread, other threads:[~2009-10-27 20:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-27 18:36 How does one get static procedure names? Bruce Korb
2009-10-27 18:56 ` Paul Pluzhnikov
2009-10-27 19:11   ` Bruce Korb
2009-10-27 19:31     ` Daniel Jacobowitz
2009-10-27 19:37       ` Bruce Korb
2009-10-27 19:43         ` Daniel Jacobowitz
2009-10-27 20:03           ` Bruce Korb
2009-10-27 20:10     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox