Skip to content
Search

Debugging

lastmod 2025-03-08created 2017-01-3027 edits

Debug (debug), debugging (debugging), or fixing refers to the testing process of finding errors in the correctness or logic (bugs) of a computer program. It is also called debugging (debugging) or fixing. Common debugging methods include checks during testing, testing with machines, and testing with real data.

Binary Tools

A set of tools for binary debugging:

GUI Disassembler

Tip/Trick

Python gdb debugging

See Gdb#Python gdb debugging.

Finding the crash location

Find the address where the crash occurred, then use addr2line to locate it.

Example:

$ addr2line -fe a.out 0x8048767

Segfault debugging

Configure GCC with --enable-checking. Compile it with -g -O0 so that you can use gdb.

Compile your test case with -v -da -Q.

  • -Q: will show which function in the test case is causing it to crash.
  • -v: shows how cc1 was invoked (useful for invoking cc1 manually in gdb).
  • -da: dumps the RTL to a file after each stage.

Next, use gdb to get a stack trace:

bash$ gdb cc1
gdb> run arguments
(cc1 will stop at the segmentation fault)
gdb> where
gdb> list

Print out the values of interesting variables, e.g., the ones in the statement which got the segmentation fault. You can use the pt and pr macros from the gdbinit.in file to display GCC data. For example, if there is a value of type tree named t, and a value of type rtx named r, you can use these commands:

gdb> source .gdbinit
gdb> print t
gdb> pt
gdb> print r
gdb> pr
gdb> pt

See also

Favorite site

Tip & Guide

MSVC

Guide

References


  1. Reverse_engineering_-_Understanding_what_a_Linux_binary_is_doing.pdf ↩

  2. Jh4hj.tistory.com_-stack_trace-_backtrace_implementation.pdf ↩

  3. Jh4hj.tistory.com_-_program_dynamic_trace_tools.pdf ↩

  4. Jh4hj.tistory.com_-_friend_of_memory_debuggin.pdf ↩

author Zer0 sitemap