* guessing where address belongs to
2008-03-04 9:21 guessing where address belongs to Yakov Lerner
@ 2008-03-04 8:16 ` Yakov Lerner
2008-03-04 9:51 ` Andreas Schwab
2008-03-05 16:15 ` Eli Zaretskii
2 siblings, 0 replies; 11+ messages in thread
From: Yakov Lerner @ 2008-03-04 8:16 UTC (permalink / raw)
To: gdb
I have large running app, and some address X, which is a valid pointer.
I'd like to find out what object it belongs to, at least approximately.
Is there command to have gdb guess which memory object this
address belongs to (which function ... which stack frame .. which static
object .. which head object )?
Thanks
Yakov
^ permalink raw reply [flat|nested] 11+ messages in thread
* guessing where address belongs to
@ 2008-03-04 9:21 Yakov Lerner
2008-03-04 8:16 ` Yakov Lerner
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Yakov Lerner @ 2008-03-04 9:21 UTC (permalink / raw)
To: gdb
I have large running app, and some address X, which is a valid pointer.
I'd like to find out what object it belongs to, at least approximately.
Is there command to have gdb guess which memory object this
address belongs to (which function ... which stack frame .. which static
object .. which head object )?
Thanks
Yakov
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-04 9:21 guessing where address belongs to Yakov Lerner
2008-03-04 8:16 ` Yakov Lerner
@ 2008-03-04 9:51 ` Andreas Schwab
2008-03-05 16:15 ` Eli Zaretskii
2 siblings, 0 replies; 11+ messages in thread
From: Andreas Schwab @ 2008-03-04 9:51 UTC (permalink / raw)
To: Yakov Lerner; +Cc: gdb
"Yakov Lerner" <iler.ml@gmail.com> writes:
> Is there command to have gdb guess which memory object this
> address belongs to (which function ... which stack frame .. which static
> object .. which head object )?
If the object has a symbol attached you can use print/a.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-04 9:21 guessing where address belongs to Yakov Lerner
2008-03-04 8:16 ` Yakov Lerner
2008-03-04 9:51 ` Andreas Schwab
@ 2008-03-05 16:15 ` Eli Zaretskii
2008-03-05 19:56 ` Michael Snyder
2 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2008-03-05 16:15 UTC (permalink / raw)
To: Yakov Lerner; +Cc: gdb
> Date: Tue, 4 Mar 2008 10:15:42 +0200
> From: "Yakov Lerner" <iler.ml@gmail.com>
>
> Is there command to have gdb guess which memory object this
> address belongs to (which function ... which stack frame .. which static
> object .. which head object )?
I think you want "info symbol".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-05 16:15 ` Eli Zaretskii
@ 2008-03-05 19:56 ` Michael Snyder
[not found] ` <f36b08ee0803052138u6749eoba4d0186afb7ecbc@mail.gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: Michael Snyder @ 2008-03-05 19:56 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Yakov Lerner, gdb
On Tue, 2008-03-04 at 21:42 +0200, Eli Zaretskii wrote:
> > Date: Tue, 4 Mar 2008 10:15:42 +0200
> > From: "Yakov Lerner" <iler.ml@gmail.com>
> >
> > Is there command to have gdb guess which memory object this
> > address belongs to (which function ... which stack frame .. which static
> > object .. which head object )?
>
> I think you want "info symbol".
That will help -- if the address is associated with a symbol.
For stack and heap pointers it's not always helpful.
I don't think there is a single command to do what you want,
but "info target" will be helpful -- it will show all loaded
sections and their memory ranges. You can fit the address into
one of them (if it fits). "info file" is an alias for this
(I think).
This shows the sections for shared libraries too, which is a plus.
Maybe if you can mock up a spec for what it is you want,
it wouldn't be that difficult to implement a new command
for it...
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
[not found] ` <f36b08ee0803052138u6749eoba4d0186afb7ecbc@mail.gmail.com>
@ 2008-03-06 6:54 ` Yakov Lerner
2008-03-06 10:46 ` Andreas Schwab
2008-03-06 20:27 ` Michael Snyder
1 sibling, 1 reply; 11+ messages in thread
From: Yakov Lerner @ 2008-03-06 6:54 UTC (permalink / raw)
To: gdb
On Wed, Mar 5, 2008 at 9:51 PM, Michael Snyder <msnyder@specifix.com> wrote:
>
>
>
> On Tue, 2008-03-04 at 21:42 +0200, Eli Zaretskii wrote:
> > > Date: Tue, 4 Mar 2008 10:15:42 +0200
> > > From: "Yakov Lerner" <iler.ml@gmail.com>
> > >
> > > Is there command to have gdb guess which memory object this
> > > address belongs to (which function ... which stack frame .. which static
> > > object .. which head object )?
I meant "heap object"
>
>
>
> >
> > I think you want "info symbol".
>
> That will help -- if the address is associated with a symbol.
> For stack and heap pointers it's not always helpful.
>
> I don't think there is a single command to do what you want,
> but "info target" will be helpful -- it will show all loaded
> sections and their memory ranges. You can fit the address into
> one of them (if it fits). "info file" is an alias for this
> (I think).
>
> This shows the sections for shared libraries too, which is a plus.
>
>
> Maybe if you can mock up a spec for what it is you want,
> it wouldn't be that difficult to implement a new command
> for it...
Ok, I will try to spec it. Regarding guessing of the
"heap objects", I have this question:
Gdb has no integration with malloc, correct ?
Gdb has no way of enumerating all malloced
pieces ("heap objects"), correct ?
Or gdb does have a way of guessing which "heap
object" some address X (that points inside the heap) belongs to ?
Yakov
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-06 6:54 ` Yakov Lerner
@ 2008-03-06 10:46 ` Andreas Schwab
2008-03-06 13:13 ` Yakov Lerner
2008-03-06 20:28 ` Michael Snyder
0 siblings, 2 replies; 11+ messages in thread
From: Andreas Schwab @ 2008-03-06 10:46 UTC (permalink / raw)
To: Yakov Lerner; +Cc: gdb
"Yakov Lerner" <iler.ml@gmail.com> writes:
> Gdb has no integration with malloc, correct ?
> Gdb has no way of enumerating all malloced
> pieces ("heap objects"), correct ?
>
> Or gdb does have a way of guessing which "heap
> object" some address X (that points inside the heap) belongs to ?
The details are highly dependent on the malloc implementation. There is
no way to find that out without intimate knowledge of the
implementation.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-06 10:46 ` Andreas Schwab
@ 2008-03-06 13:13 ` Yakov Lerner
2008-03-06 20:37 ` Michael Snyder
2008-03-06 20:28 ` Michael Snyder
1 sibling, 1 reply; 11+ messages in thread
From: Yakov Lerner @ 2008-03-06 13:13 UTC (permalink / raw)
To: Andreas Schwab, gdb
On Thu, Mar 6, 2008 at 12:05 PM, Andreas Schwab <schwab@suse.de> wrote:
> "Yakov Lerner" <iler.ml@gmail.com> writes:
>
> > Gdb has no integration with malloc, correct ?
> > Gdb has no way of enumerating all malloced
> > pieces ("heap objects"), correct ?
> >
> > Or gdb does have a way of guessing which "heap
> > object" some address X (that points inside the heap) belongs to ?
>
> The details are highly dependent on the malloc implementation. There is
> no way to find that out without intimate knowledge of the
> implementation.
You don't need details of malloc guts for that.
It's enough to hook to the entry and return from malloc,free,realloc.
Yakov
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
[not found] ` <f36b08ee0803052138u6749eoba4d0186afb7ecbc@mail.gmail.com>
2008-03-06 6:54 ` Yakov Lerner
@ 2008-03-06 20:27 ` Michael Snyder
1 sibling, 0 replies; 11+ messages in thread
From: Michael Snyder @ 2008-03-06 20:27 UTC (permalink / raw)
To: Yakov Lerner; +Cc: gdb
On Thu, 2008-03-06 at 07:38 +0200, Yakov Lerner wrote:
> Ok, I will try to spec it. Regarding guessing of the
> "heap objects", I have this question:
>
> Gdb has no integration with malloc, correct ?
> Gdb has no way of enumerating all malloced
> pieces ("heap objects"), correct ?
>
> Or gdb does have a way of guessing which "heap
> object" some address X (that points inside the heap) belongs to ?
Nope -- the heap is just a big opaque blob.
GDB has no knowledge of what's inside it, and in fact
you're doing well if you can figure out where and how big
it is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-06 10:46 ` Andreas Schwab
2008-03-06 13:13 ` Yakov Lerner
@ 2008-03-06 20:28 ` Michael Snyder
1 sibling, 0 replies; 11+ messages in thread
From: Michael Snyder @ 2008-03-06 20:28 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Yakov Lerner, gdb
On Thu, 2008-03-06 at 11:05 +0100, Andreas Schwab wrote:
> "Yakov Lerner" <iler.ml@gmail.com> writes:
>
> > Gdb has no integration with malloc, correct ?
> > Gdb has no way of enumerating all malloced
> > pieces ("heap objects"), correct ?
> >
> > Or gdb does have a way of guessing which "heap
> > object" some address X (that points inside the heap) belongs to ?
>
> The details are highly dependent on the malloc implementation. There is
> no way to find that out without intimate knowledge of the
> implementation.
Yep, and there's no marriage between any given platform
and any given malloc implementation. Replacing the malloc
from glibc is a fairly common thing to do, for instance.
So gdb really has no idea what's in there...
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: guessing where address belongs to
2008-03-06 13:13 ` Yakov Lerner
@ 2008-03-06 20:37 ` Michael Snyder
0 siblings, 0 replies; 11+ messages in thread
From: Michael Snyder @ 2008-03-06 20:37 UTC (permalink / raw)
To: Yakov Lerner; +Cc: Andreas Schwab, gdb
On Thu, 2008-03-06 at 12:45 +0200, Yakov Lerner wrote:
> On Thu, Mar 6, 2008 at 12:05 PM, Andreas Schwab <schwab@suse.de> wrote:
> > "Yakov Lerner" <iler.ml@gmail.com> writes:
> >
> > > Gdb has no integration with malloc, correct ?
> > > Gdb has no way of enumerating all malloced
> > > pieces ("heap objects"), correct ?
> > >
> > > Or gdb does have a way of guessing which "heap
> > > object" some address X (that points inside the heap) belongs to ?
> >
> > The details are highly dependent on the malloc implementation. There is
> > no way to find that out without intimate knowledge of the
> > implementation.
>
> You don't need details of malloc guts for that.
>
> It's enough to hook to the entry and return from malloc,free,realloc.
Yep, and there are tools that do that -- but gdb isn't one of them.
OTOH, it would be possible to set user breakpoints at malloc and
free, and then write user gdb commands to collect whatever
information you want...
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-03-06 20:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-04 9:21 guessing where address belongs to Yakov Lerner
2008-03-04 8:16 ` Yakov Lerner
2008-03-04 9:51 ` Andreas Schwab
2008-03-05 16:15 ` Eli Zaretskii
2008-03-05 19:56 ` Michael Snyder
[not found] ` <f36b08ee0803052138u6749eoba4d0186afb7ecbc@mail.gmail.com>
2008-03-06 6:54 ` Yakov Lerner
2008-03-06 10:46 ` Andreas Schwab
2008-03-06 13:13 ` Yakov Lerner
2008-03-06 20:37 ` Michael Snyder
2008-03-06 20:28 ` Michael Snyder
2008-03-06 20:27 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox