root@kali:~/ohm/stack_frame# gcc -g -o func func.c
root@kali:~/ohm/stack_frame# gdb func
GNU gdb (Debian 7.12-6+b1) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from func...done.
(gdb) break func.c :3
Breakpoint 1 at 0x656: file func.c, line 3.
(gdb) run
Starting program: /root/ohm/stack_frame/func 

Breakpoint 1, func (a=3, b=5) at func.c:4
4	    long x = 0;
(gdb) print $rdi
$1 = 3
(gdb) print $rsi
$2 = 5
(gdb) print &x
$3 = (long *) 0x7fffffffe078
(gdb) print &y
$4 = (long *) 0x7fffffffe070
(gdb) step
5	    long y = 0;
(gdb) step
6	    x = a * a;
(gdb) step
7	    y = b * b;
(gdb) step
9	    return x + y;
(gdb) x/32xw $rsp - 64
0x7fffffffe040:	0x000000c2	0x00000000	0xffffe076	0x00007fff
0x7fffffffe050:	0x00000001	0x00000000	0xf7abe905	0x00007fff
0x7fffffffe060:	0x00000005	0x00000000	0x00000003	0x00000000
0x7fffffffe070:	0x00000019	0x00000000	0x00000009	0x00000000
0x7fffffffe080:	0xffffe0a0	0x00007fff	0x555546a4	0x00005555
0x7fffffffe090:	0xffffe180	0x00007fff	0x00000000	0x00000000
0x7fffffffe0a0:	0x555546d0	0x00005555	0xf7a3fa87	0x00007fff
0x7fffffffe0b0:	0x00000000	0x00000000	0xffffe188	0x00007fff
(gdb) 

