public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Fwd: A typo of yours or a misunderstanding of mine?
       [not found] <CAKH9Og9zZkZ7egk+xa3LsaPYiVy2ziRsBZMFEvUWfUDWDCFC2w@mail.gmail.com>
@ 2021-11-18 17:19 ` Z J Hu
  2021-11-18 18:06   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Z J Hu @ 2021-11-18 17:19 UTC (permalink / raw)
  To: gdb

I have been asked to forward my question about gdb documentation to you.

---------- Forwarded message ---------
From: Z J Hu <zihu88@gmail.com>
Date: Wed, Nov 17, 2021 at 9:11 AM
Subject: A typo of yours or a misunderstanding of mine?
To: <sourcemaster@sourceware.org>


Dear Sourceware Team,

Hope this email finds you well.

When I'm reading the content in "
https://sourceware.org/gdb/onlinedocs/gdb/Memory.html", I find a statement
for 'x/-3uh' command as: "You can also specify a negative repeat count to
examine memory backward from the given address. For example, ‘x/-3uh 0x54320’
prints three halfwords (h) at 0x54314, 0x54328, and 0x5431c." Should
0x54314 be 0x54324 instead? I don't know what machine word size would be
for this statement, and it gives me some hard time to understand. Could you
clear it for me?

Thanks,
-Zielnik Hu

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

* Re: Fwd: A typo of yours or a misunderstanding of mine?
  2021-11-18 17:19 ` Fwd: A typo of yours or a misunderstanding of mine? Z J Hu
@ 2021-11-18 18:06   ` Tom de Vries
  2021-11-18 18:15     ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2021-11-18 18:06 UTC (permalink / raw)
  To: Z J Hu, gdb

On 11/18/21 6:19 PM, Z J Hu via Gdb wrote:
> I have been asked to forward my question about gdb documentation to you.
> 
> ---------- Forwarded message ---------
> From: Z J Hu <zihu88@gmail.com>
> Date: Wed, Nov 17, 2021 at 9:11 AM
> Subject: A typo of yours or a misunderstanding of mine?
> To: <sourcemaster@sourceware.org>
> 
> 
> Dear Sourceware Team,
> 
> Hope this email finds you well.
> 
> When I'm reading the content in "
> https://sourceware.org/gdb/onlinedocs/gdb/Memory.html", I find a statement
> for 'x/-3uh' command as: "You can also specify a negative repeat count to
> examine memory backward from the given address. For example, ‘x/-3uh 0x54320’
> prints three halfwords (h) at 0x54314, 0x54328, and 0x5431c." Should
> 0x54314 be 0x54324 instead? I don't know what machine word size would be
> for this statement, and it gives me some hard time to understand. Could you
> clear it for me?
> 

Hi,

I did an experiment, to understand the behaviour:
...
$ cat -n test.c
     1  #define N 256
     2
     3  unsigned short data[N];
     4
     5  int
     6  main (void)
     7  {
     8    int i;
     9    for (i = 0; i < N; ++i)
    10      data[i] = i;
    11
    12    return 0;
    13  }
$ gcc test.c -g
$ gdb -q -batch a.out -ex "set trace-commands on" -ex "b 12" -ex run -ex
"p &data[10]" -ex "x/-3uh &data[10]"
+b 12
Breakpoint 1 at 0x4004c3: file test.c, line 12.
+run

Breakpoint 1, main () at test.c:12
12        return 0;
+p &data[10]
$1 = (unsigned short *) 0x601074 <data+20>
+x/-3uh &data[10]
0x60106e <data+14>:     7       8       9
$
...

Based on this, I'd say you caught a typo in the docs, and the example in
the docs should mention the addresses 0x54314, 0x54318, and 0x5431c.

Thanks for bringing this to our attention, I'll commit a fix shortly.

Thanks,
- Tom



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

* Re: Fwd: A typo of yours or a misunderstanding of mine?
  2021-11-18 18:06   ` Tom de Vries
@ 2021-11-18 18:15     ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2021-11-18 18:15 UTC (permalink / raw)
  To: Z J Hu, gdb

On 11/18/21 7:06 PM, Tom de Vries via Gdb wrote:
> the docs should mention the addresses 0x54314, 0x54318, and 0x5431c.

Hmm, I only just realized that half means is 2 bytes, and this series is
4-bytes spaced.

So, it should be:
...
0x5431a, 0x5431c, and 0x5431e.
...

Thanks,
- Tom

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

end of thread, other threads:[~2021-11-18 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKH9Og9zZkZ7egk+xa3LsaPYiVy2ziRsBZMFEvUWfUDWDCFC2w@mail.gmail.com>
2021-11-18 17:19 ` Fwd: A typo of yours or a misunderstanding of mine? Z J Hu
2021-11-18 18:06   ` Tom de Vries
2021-11-18 18:15     ` Tom de Vries

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