1

I am interested in debugging Tor to obtain the functions stack of the program. Studying it but haven't able to produce an output that displays functions stack / backtrace. Seems to only produce their addresses when I include "ggdb" using gdb.

Thank you

  • uh, is this specific to Tor or more just a general "How do I debug C base programs?" question? – cacahuatl Oct 21 '17 at 4:27
  • Well, not quite sure all C debugging processes apply to Tor, as I've tried debugging with gdb, which only produces addresses rather than the functions names. – rabiu mukhtar Oct 21 '17 at 14:40
  • That's because it's built without debugging symbols, so gdb can't convert addresses to symbol names. This is true for any C program built without debugging symbols. gcc -ggdb will tell it to create debugging symbols for gdb when it's compiling the code. e.g. by running env CFLAGS="-ggdb" ./configure && make while inside the tor sourcecode directory. – cacahuatl Oct 21 '17 at 22:54
1

You'll want to compile it with debugging symbols while building it from source.

The Tor Project distributes debugging symbols for Tor Browser, but I do not believe they do so for Tor (building Tor Browser is a much bigger undertaking, so providing the symbols makes it easier).

Under Linux (or most POSIX-like systems), the process should look something like this:

wget https://dist.torproject.org/tor-0.3.1.7.tar.gz{,.asc}
gpg --verify tor-0.3.1.7.tar.gz.asc tor-0.3.1.7.tar.gz
# Check the signature is good
tar vxaf tor-0.3.1.7.tar.gz
cd tor-0.3.1.7
env CFLAG='-ggdb' ./configure
# Add the -ggdb CFLAG to the make process
make
gdb src/or/tor
# gdb should report 'Reading symbols from src/or/tor...done.', you now have debugging symbols available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.