![]() Tracing debugging can often be more helpful than postmortem debugging. In this case, it was executing exit() and flushing stdio buffers. This tells us what happened before the program exited. hellow-static -f | grep -v "?:0" | uniq | less If your executable hasn't been built with debugging information - the static libc.a in Debian/Ubuntu isn't built with debugging enabled - you can pass the -f option to addr2line to print function names as well, and then filter out the useless "?:0" lines: work/glibc/posix/./sysdeps/unix/sysv/linux/i386/_exit.S:30Īddr2line prints "?:0" for addresses that it can't find in debugging information. Also, pipe through uniq to remove duplicate lines: This tool is part of binutils and translates addresses to source code filenames and line numbers using the debugging information in the executable. To make this intelligible, all we have to do is pipe the output of itrace through addr2line. Here's what we get if we run itrace on a simple statically-linked executable: The first part is a tool called itrace, which starts a subprocess and single-steps its execution using Linux's ptrace() system call and prints the process's eip and esp registers (instruction pointer and stack pointer) at every step. So, here's how to create a debugger with a single shell pipeline (plus a small C program) that works on statically-linked executables. I found another way to do debugging, using a trace of the program's execution. However, that didn't help when the process died by jumping to address 0, or when it jumped to _start when running atexit handlers. (I should point out that gdb has since been ported.) Often I could look up the address with addr2line or objdump -d to find the cause of the problem. gdb (or strace -i) could tell me the value of the instruction pointer when the process crashed, but it couldn't produce a backtrace because it didn't know how to read memory with NaCl's x86 segmentation setup. I faced that problem when porting glibc to Native Client. Gdb can be really useful for debugging when it prints the information you want, but sometimes it will fail to give a useful backtrace, and it can be hard to find out what happened just before your process crashed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |