public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
@ 2010-08-24  2:10 Hui Zhu
  2010-08-24  3:06 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Hui Zhu @ 2010-08-24  2:10 UTC (permalink / raw)
  To: gdb-patches ml; +Cc: Eli Zaretskii

Hi,

I found that *$esp@300 cannot work on GDB,  for example:
actions
Enter actions for tracepoint 4, one per line.
End with a line saying just "end".
>collect *$esp@300
Attempt to dereference a generic pointer.

But *(unsigned char *)$esp@300 can work:
actions
Enter actions for tracepoint 4, one per line.
End with a line saying just "end".
>collect *(unsigned char *)$esp@300
>end

I make a patch for it.  Please help me review it.

Thanks,
Hui

2010-08-24  Hui Zhu  <teawater@gmail.com>

	* gdb.texinfo (Tracepoint Restrictions): Change *$esp@300
	to *(unsigned char *)$esp@300.

---
 doc/gdb.texinfo |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/doc/gdb.texinfo
+++ b/doc/gdb.texinfo
@@ -10390,7 +10390,7 @@ by @code{ptr}.
 @item
 It is not possible to collect a complete stack backtrace at a
 tracepoint.  Instead, you may collect the registers and a few hundred
-bytes from the stack pointer with something like @code{*$esp@@300}
+bytes from the stack pointer with something like @code{*(unsigned
char *)$esp@@300}
 (adjust to use the name of the actual stack pointer register on your
 target architecture, and the amount of stack you wish to capture).
 Then the @code{backtrace} command will show a partial backtrace when

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24  2:10 [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300 Hui Zhu
@ 2010-08-24  3:06 ` Eli Zaretskii
  2010-08-24  3:30   ` Hui Zhu
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2010-08-24  3:06 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb-patches

> From: Hui Zhu <teawater@gmail.com>
> Date: Tue, 24 Aug 2010 10:10:19 +0800
> Cc: Eli Zaretskii <eliz@gnu.org>
> 
> But *(unsigned char *)$esp@300 can work:

What about *(int *)$esp@300 ?

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24  3:06 ` Eli Zaretskii
@ 2010-08-24  3:30   ` Hui Zhu
  2010-08-24 17:08     ` Eli Zaretskii
  2010-08-24 17:33     ` Michael Snyder
  0 siblings, 2 replies; 10+ messages in thread
From: Hui Zhu @ 2010-08-24  3:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Tue, Aug 24, 2010 at 11:07, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Hui Zhu <teawater@gmail.com>
>> Date: Tue, 24 Aug 2010 10:10:19 +0800
>> Cc: Eli Zaretskii <eliz@gnu.org>
>>
>> But *(unsigned char *)$esp@300 can work:
>
> What about *(int *)$esp@300 ?
>

It will make trace collect 1200.
If "unsigned char" is too big, what about *(char *)$esp@300?

Thanks,
Hui

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24  3:30   ` Hui Zhu
@ 2010-08-24 17:08     ` Eli Zaretskii
  2010-08-24 17:35       ` Michael Snyder
  2010-08-24 17:33     ` Michael Snyder
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2010-08-24 17:08 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb-patches

> From: Hui Zhu <teawater@gmail.com>
> Date: Tue, 24 Aug 2010 11:30:03 +0800
> Cc: gdb-patches@sourceware.org
> 
> If "unsigned char" is too big, what about *(char *)$esp@300?

"char" is better, but not because of the length.

However, what I really meant is to ask whether *$esp should indeed
refuse to work, or is that a bug?

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24  3:30   ` Hui Zhu
  2010-08-24 17:08     ` Eli Zaretskii
@ 2010-08-24 17:33     ` Michael Snyder
  2010-08-24 17:58       ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2010-08-24 17:33 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Eli Zaretskii, gdb-patches

Hui Zhu wrote:
> On Tue, Aug 24, 2010 at 11:07, Eli Zaretskii <eliz@gnu.org> wrote:
>>> From: Hui Zhu <teawater@gmail.com>
>>> Date: Tue, 24 Aug 2010 10:10:19 +0800
>>> Cc: Eli Zaretskii <eliz@gnu.org>
>>>
>>> But *(unsigned char *)$esp@300 can work:
>> What about *(int *)$esp@300 ?
>>
> 
> It will make trace collect 1200.
> If "unsigned char" is too big, what about *(char *)$esp@300?

But 300 words might be good too.  What about:

+bytes from the stack pointer with something like @code{*
(char *)$esp@@300}, or 300 words with @code{*(int *)$esp@@300}.

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24 17:08     ` Eli Zaretskii
@ 2010-08-24 17:35       ` Michael Snyder
  2010-08-24 18:00         ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2010-08-24 17:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Hui Zhu, gdb-patches

Eli Zaretskii wrote:
>> From: Hui Zhu <teawater@gmail.com>
>> Date: Tue, 24 Aug 2010 11:30:03 +0800
>> Cc: gdb-patches@sourceware.org
>>
>> If "unsigned char" is too big, what about *(char *)$esp@300?
> 
> "char" is better, but not because of the length.
> 
> However, what I really meant is to ask whether *$esp should indeed
> refuse to work, or is that a bug?

I imagine it must have worked at one time...

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24 17:33     ` Michael Snyder
@ 2010-08-24 17:58       ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2010-08-24 17:58 UTC (permalink / raw)
  To: Michael Snyder; +Cc: teawater, gdb-patches

> Date: Tue, 24 Aug 2010 10:32:58 -0700
> From: Michael Snyder <msnyder@vmware.com>
> CC: Eli Zaretskii <eliz@gnu.org>, 
>  "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> 
> Hui Zhu wrote:
> > On Tue, Aug 24, 2010 at 11:07, Eli Zaretskii <eliz@gnu.org> wrote:
> >>> From: Hui Zhu <teawater@gmail.com>
> >>> Date: Tue, 24 Aug 2010 10:10:19 +0800
> >>> Cc: Eli Zaretskii <eliz@gnu.org>
> >>>
> >>> But *(unsigned char *)$esp@300 can work:
> >> What about *(int *)$esp@300 ?
> >>
> > 
> > It will make trace collect 1200.
> > If "unsigned char" is too big, what about *(char *)$esp@300?
> 
> But 300 words might be good too.  What about:
> 
> +bytes from the stack pointer with something like @code{*
> (char *)$esp@@300}, or 300 words with @code{*(int *)$esp@@300}.

Fine with me.

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24 17:35       ` Michael Snyder
@ 2010-08-24 18:00         ` Eli Zaretskii
  2010-08-24 18:07           ` Michael Snyder
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2010-08-24 18:00 UTC (permalink / raw)
  To: Michael Snyder; +Cc: teawater, gdb-patches

> Date: Tue, 24 Aug 2010 10:35:34 -0700
> From: Michael Snyder <msnyder@vmware.com>
> CC: Hui Zhu <teawater@gmail.com>, 
>  "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> 
> Eli Zaretskii wrote:
> >> From: Hui Zhu <teawater@gmail.com>
> >> Date: Tue, 24 Aug 2010 11:30:03 +0800
> >> Cc: gdb-patches@sourceware.org
> >>
> >> If "unsigned char" is too big, what about *(char *)$esp@300?
> > 
> > "char" is better, but not because of the length.
> > 
> > However, what I really meant is to ask whether *$esp should indeed
> > refuse to work, or is that a bug?
> 
> I imagine it must have worked at one time...

If we-all think now that it's okay for *$esp not to work, then let's
fix the docs and be done.

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24 18:00         ` Eli Zaretskii
@ 2010-08-24 18:07           ` Michael Snyder
  2010-08-24 18:37             ` Pedro Alves
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2010-08-24 18:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: teawater, gdb-patches

Eli Zaretskii wrote:
>> Date: Tue, 24 Aug 2010 10:35:34 -0700
>> From: Michael Snyder <msnyder@vmware.com>
>> CC: Hui Zhu <teawater@gmail.com>, 
>>  "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>>
>> Eli Zaretskii wrote:
>>>> From: Hui Zhu <teawater@gmail.com>
>>>> Date: Tue, 24 Aug 2010 11:30:03 +0800
>>>> Cc: gdb-patches@sourceware.org
>>>>
>>>> If "unsigned char" is too big, what about *(char *)$esp@300?
>>> "char" is better, but not because of the length.
>>>
>>> However, what I really meant is to ask whether *$esp should indeed
>>> refuse to work, or is that a bug?
>> I imagine it must have worked at one time...
> 
> If we-all think now that it's okay for *$esp not to work, then let's
> fix the docs and be done.

I think the reason it doesn't work now is that it's typed as a void pointer.

(gdb) pt $esp
type = void *

Probably it used to be typed as a char * or something.

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

* Re: [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300
  2010-08-24 18:07           ` Michael Snyder
@ 2010-08-24 18:37             ` Pedro Alves
  0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2010-08-24 18:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Michael Snyder, Eli Zaretskii, teawater

On Tuesday 24 August 2010 19:07:17, Michael Snyder wrote:
> I think the reason it doesn't work now is that it's typed as a void pointer.
> 
> (gdb) pt $esp
> type = void *
> 
> Probably it used to be typed as a char * or something.

Dereferencing void* used to "work" in agent expressions,
but since it is forbidden in normal expressions, 

 (gdb) p *$sp
 Attempt to dereference a generic pointer.

the agent expression code was fixed to behave the same:

2010-02-11  Pedro Alves  <pedro@codesourcery.com>

        * ax-gdb.c (gen_deref): Don't allow dereferencing void pointers.

Let's just fix the docs.

-- 
Pedro Alves

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

end of thread, other threads:[~2010-08-24 18:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24  2:10 [Doc]tracepoint: change *$esp@300 to *(unsigned char *)$esp@300 Hui Zhu
2010-08-24  3:06 ` Eli Zaretskii
2010-08-24  3:30   ` Hui Zhu
2010-08-24 17:08     ` Eli Zaretskii
2010-08-24 17:35       ` Michael Snyder
2010-08-24 18:00         ` Eli Zaretskii
2010-08-24 18:07           ` Michael Snyder
2010-08-24 18:37             ` Pedro Alves
2010-08-24 17:33     ` Michael Snyder
2010-08-24 17:58       ` Eli Zaretskii

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).