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

3
  • uh, is this specific to Tor or more just a general "How do I debug C base programs?" question?
    – cacahuatl
    Commented Oct 21, 2017 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. Commented Oct 21, 2017 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
    Commented Oct 21, 2017 at 22:54

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .