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.
gcc -ggdb
will tell it to create debugging symbols for gdb when it's compiling the code. e.g. by runningenv CFLAGS="-ggdb" ./configure && make
while inside the tor sourcecode directory.