% `perf`, `gdb`, and x86 tricks and reference materials % Michael Stone % October 8, 2012 +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | $ perf record -g | [http://lwn.net/Articles/340010/](http://lwn.net/Articles/340010/) | | $ perf annotate | | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) layout asm | [gdb: "layout asm"](http://stackoverflow.com/questions/589653/switching-to-assembly-in-gdb) | | | [SO: Show current instruction in gdb](http://stackoverflow.com/questions/1902901/show-current-instruction-in-gdb) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) x/w $1234 | [gdb: "Examining memory"](http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Memory) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) break *fun* | [gdb: "Break Commands"](http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Break-Commands) | | commands | | | info registers | | | end | | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) run < input | [gdb: "Your Program's Input and Output"](http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Input_002fOutput) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) set {int} ($esp + 0x4) = 10 | [gdb: "Altering Execution"](http://sources.redhat.com/gdb/current/onlinedocs/gdb.html#Altering) | | (gdb) set $pc = 0x485 | | | (gdb) jump *0xabcdefgh | | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | (gdb) generate-core-file | [Generating core files from gdb](http://prefetch.net/blog/index.php/2006/12/21/generating-core-files-from-gdb/) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | gdb manual | [Red Hat](http://sources.redhat.com/gdb/current/onlinedocs/gdb.html) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | gdb cheat sheets | [Daniel Spiegel](http://faculty.kutztown.edu/spiegel/Debugging/DebugPrimer.htm) | | | | | | [Jim Binkley](http://web.cecs.pdx.edu/~jrb/cs201/lectures/handouts/gdbcomm.txt) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | IA-{32,64} references | [Intel IA-32 and IA-64 Instruction Set Architecture Reference Materials](http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | calling conventions | [x86 Calling Conventions](http://en.wikipedia.org/wiki/X86_calling_conventions) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | AT&T vs. Intel syntax | [symset](http://simon.baymoo.org/universe/tools/symset/symset.txt) | +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+