From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A65E53858422 for ; Thu, 18 Nov 2021 18:06:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A65E53858422 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 997A41FD38; Thu, 18 Nov 2021 18:06:08 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 83FF713D76; Thu, 18 Nov 2021 18:06:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mGnjHhCWlmH6ZAAAMHmgww (envelope-from ); Thu, 18 Nov 2021 18:06:08 +0000 Subject: Re: Fwd: A typo of yours or a misunderstanding of mine? To: Z J Hu , gdb@sourceware.org References: From: Tom de Vries Message-ID: Date: Thu, 18 Nov 2021 19:06:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2021 18:06:12 -0000 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 > Date: Wed, Nov 17, 2021 at 9:11 AM > Subject: A typo of yours or a misunderstanding of mine? > To: > > > 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 +x/-3uh &data[10] 0x60106e : 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