Here are a few debugging tools from the GNU developer toolkit. They are commonly available in most of the Linux distribution. My Linux box runs Ubuntu 12.10.
1. objdump: display hexadecimal and assembly representations of machine languages of an executable.
typical usage: objdump -D 'name-of-the-executable'
You need to understand assembly language to be able to tell what's in output.
2. gdb: debugger to allow programmer to step through a compiled program and examine program memory and processor registers.
A GDB session can be launched as followed:
gdb -q 'name-of-the-executable'
Then one can interactively enter commands to control the start, pause, quit the program, or set breakpoints and examine register values. Common commands used in gdb are:
-break 'function_name': set breakpoint at the entry of a function
-run: start the program (until breakpoint)
-disassemble function: disassemble a function into assembly language
-info registers: see the values in the registers
-info register name-of-register: see the values stored in a particular register
-x/Nxw $name-of-register: examine the content of the memory, pointed by the register. N indicates the number of words to after that starting address.
-x/i: examine the assembly instruction pointed by an address.
-x/s: examine the string pointed by an address.
-continue: continue (until the next breakpoint or the end of the program)
-quit: quit the program
3. Hexdump: to display the hexadecimal content of a file. Common options:
- hexdump -C filename: to display the content of the file in hex, one byte at a time, followed by character
- hexdump -x filename: to display the content of the file in hex, two bytes at a time.
No comments:
Post a Comment