0

I want to modify tor source code and test it. Hence I want to run it under GDB in Ubuntu 14.04. I am able to attach GDB to it but when I want to print some value of the variable, it says no debugging symbol found. How do I build TOR with debug flag?

2
  • On which operating system? Linux?
    – kenorb
    May 11, 2015 at 11:43
  • Sorry, I should have mentioned it. I editted the question. I am using Ubuntu 14.04
    – viggy
    May 11, 2015 at 20:16

2 Answers 2

1

You need to compile tor with debug info, usually -d to be added in the Makefile in the CFLAGS= The gcc compiler will add in this case, part of the source code in the compiled program that are needed by gdb to display debug information.

0

Use the CFLAGS optional environment variable with autoconf's ./configure, e.g.

# Fetch the latest Tor source code (update the version yourself!) and signature
$ wget https://dist.torproject.org/tor-0.2.9.9.tar.gz{,.asc}
# Verify the signature
$ gpg --verify tor-0.2.9.9.tar.gz{.asc,}
# Extract the code
$ tar vxaf tor-0.2.9.9.tar.gz
$ cd tor-0.2.9.9
# Run the autoconf configuration script with CFLAGS defined in the environment to
# include "-ggdb", -g for debugging and gdb for best for gdb use
# see: https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Debugging-Options.html#Debugging-Options
$ env CFLAGS='-ggdb' ./configure #additional config options here
# Make as usual
$ make
# Your compiled ELF has debugging symbols
$ readelf -S src/or/tor
...
  [27] .debug_aranges    PROGBITS         0000000000000000  00378b79
       0000000000001a70  0000000000000000           0     0     1
  [28] .debug_info       PROGBITS         0000000000000000  0037a5e9
       0000000000145c12  0000000000000000           0     0     1
  [29] .debug_abbrev     PROGBITS         0000000000000000  004c01fb
       0000000000012b1b  0000000000000000           0     0     1
  [30] .debug_line       PROGBITS         0000000000000000  004d2d16
       000000000004ebe1  0000000000000000           0     0     1
  [31] .debug_str        PROGBITS         0000000000000000  005218f7
       0000000000036703  0000000000000001  MS       0     0     1
  [32] .debug_ranges     PROGBITS         0000000000000000  00557ffa
       0000000000000830  0000000000000000           0     0     1
...

You must log in to answer this question.

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