This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: View memory content with gdb
- From: "Mahmood Naderan via gdb" <gdb at sourceware dot org>
- To: Ruslan Kabatsayev <b7 dot 10110111 at gmail dot com>, "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Thu, 5 Jul 2018 08:25:33 +0000 (UTC)
- Subject: Re: View memory content with gdb
- References: <319102187.2792322.1530734849586.ref@mail.yahoo.com> <319102187.2792322.1530734849586@mail.yahoo.com> <CAHEcG97K-Zy=hWCtChDbDrsrOxoBnquFTBqrPnLNOzJtq6Faag@mail.gmail.com> <1669861486.2935533.1530773490408@mail.yahoo.com> <CAHEcG95wWetm2kUQ8hz7v=NWw4w5vprN97z9ty1sKKnUxk=TBg@mail.gmail.com>
- Reply-to: Mahmood Naderan <nt_mahmood at yahoo dot com>
- Reply-to: Mahmood Naderan <nt_mahmood at yahoo dot com>
>No it doesn't. Stack grows downward when you extend it — by reserving
>bytes or by `push`ing onto it. But after you've reserved the space in
>it, further addressing of that space is via positive offsets to $rsp.
Agreed... I can now see that 61H is inserted into those locations
(gdb) info registers rsp
rsp 0x7fffffffde50 0x7fffffffde50
(gdb) x/8x 0x7fffffffde50
0x7fffffffde50: 0xffffdf58 0x00007fff 0x55554580 0x00000002
0x7fffffffde60: 0xffffdf50 0x00007fff 0x00000000 0x00000000
(gdb) next
7 return 0;
(gdb) x/10x 0x7fffffffde50
0x7fffffffde50: 0xffffdf58 0x00007fff 0x55554580 0x00000002
0x7fffffffde60: 0xffffdf50 0x61617fff 0x61616161 0x61616161
0x7fffffffde70: 0x55554600 0x00005555
I wonder why it didn't insert 61H starting from 0x7fffffffde50?
>You've set two breakpoints: first at `#include <stdio.h>`, and second>at `int main( int argc, char **argv )`, which are the lines 1 and 3 of
>your current source file, respectively.
But what I did seems to be correct!
Please see that although I set "break 1" and then "run", the program stops at strcpy line (line 6). That means it didn't set the breakpoint at the include line.
(gdb) break 1
Breakpoint 1 at 0x6bf: file mico.c, line 1.
(gdb) run aaaaaaaaa
Starting program: /home/mahmood/mico aaaaaaaaa
Breakpoint 1, main (argc=2, argv=0x7fffffffdf58) at mico.c:6
6 strcpy( buffer, argv[ 1 ] );
(gdb) p argv[1]
$1 = 0x7fffffffe302 "aaaaaaaaa"
Regards,
Mahmood