$ gdb --write hello
GNU gdb (Debian 7.12-6) 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 hello...done.
(gdb) disassemble /mr drawing
Dump of assembler code for function drawing:
6 {
0x00000000000007d0 <+0>: 55 push %rbp
0x00000000000007d1 <+1>: 48 89 e5 mov %rsp,%rbp
0x00000000000007d4 <+4>: 48 83 ec 10 sub $0x10,%rsp
0x00000000000007d8 <+8>: 89 7d fc mov %edi,-0x4(%rbp)
7 if (n != 0)
0x00000000000007db <+11>: 83 7d fc 00 cmpl $0x0,-0x4(%rbp)
0x00000000000007df <+15>: 74 0e je 0x7ef <drawing+31>
8 puts ("Try again?\nAll you need is a dollar, and a dream.");
0x00000000000007e1 <+17>: 48 8d 3d 40 01 00 00 lea 0x140(%rip),%rdi # 0x928
0x00000000000007e8 <+24>: e8 53 fe ff ff callq 0x640 <puts@plt>
9 else
10 puts ("You win $3000!");
0x00000000000007ef <+31>: 48 8d 3d 64 01 00 00 lea 0x164(%rip),%rdi # 0x95a
0x00000000000007f6 <+38>: e8 45 fe ff ff callq 0x640 <puts@plt>
11 }
0x00000000000007ed <+29>: eb 0c jmp 0x7fb <drawing+43>
0x00000000000007fb <+43>: 90 nop
0x00000000000007fc <+44>: c9 leaveq
0x00000000000007fd <+45>: c3 retq
End of assembler dump.
(gdb) set variable *(short*)0x00000000000007df=0x0ceb
(gdb) disassemble /mr drawing
Dump of assembler code for function drawing:
6 {
0x00000000000007d0 <+0>: 55 push %rbp
0x00000000000007d1 <+1>: 48 89 e5 mov %rsp,%rbp
0x00000000000007d4 <+4>: 48 83 ec 10 sub $0x10,%rsp
0x00000000000007d8 <+8>: 89 7d fc mov %edi,-0x4(%rbp)
7 if (n != 0)
0x00000000000007db <+11>: 83 7d fc 00 cmpl $0x0,-0x4(%rbp)
0x00000000000007df <+15>: eb 0c jmp 0x7ed <drawing+29>
8 puts ("Try again?\nAll you need is a dollar, and a dream.");
0x00000000000007e1 <+17>: 48 8d 3d 40 01 00 00 lea 0x140(%rip),%rdi # 0x928
0x00000000000007e8 <+24>: e8 53 fe ff ff callq 0x640 <puts@plt>
9 else
10 puts ("You win $3000!");
0x00000000000007ef <+31>: 48 8d 3d 64 01 00 00 lea 0x164(%rip),%rdi # 0x95a
0x00000000000007f6 <+38>: e8 45 fe ff ff callq 0x640 <puts@plt>
11 }
0x00000000000007ed <+29>: eb 0c jmp 0x7fb <drawing+43>
0x00000000000007fb <+43>: 90 nop
0x00000000000007fc <+44>: c9 leaveq
0x00000000000007fd <+45>: c3 retq
End of assembler dump.
(gdb) q
Segmentation fault