[www/squid] how to debug squid, and 1 simple error in source

Hi, I'm a newbie for FreeBSD & squid.
Here is my experience, how to debug squid.

* I run the below command to debug squid, and squid always died.
gdb --args /usr/local/sbin/squid -N -d 100 -X -f /usr/local/etc/squid/squid.conf
/usr/local/sbin/squid : squid program, I usally using the program I've built
(/usr/ports/www/squid/work/squid-4.13/src/squid)
-N : no parent/child process separation(very important for debuging or many sub process wil be forked)
-d 100 : debug log level, 9 is maximum value^^?
-X : for full debuging.
/usr/local/etc/squid/squid.conf : configiration file

* Error position: /usr/ports/www/squid/work/squid-4.13/src/tools.cc line 540
Code:
const char *
uniqueHostname(void)
{
    debugs(21, 3, HERE << " Config: '" << (Config.uniqueHostname ? &Config.uniqueHostname[0]: "{null
}") << "'"); // jcem - null check for Config.uniqueHostname
    return Config.uniqueHostname ? Config.uniqueHostname : getMyHostname();
}

* how to build squid & debug, short commands.
Code:
# in OPNsense you should copy [file]/usr/tools/config/20.7/make.conf[/file] to [file]/etc/make.conf[/file] and edit for your system settings.
cd /usr/ports/www/squid
setenv BATCH yes
setenv WITH_DEBUG_PORTS www/squid
make config
# check DEBUG - conflict with setenv WITH_DEBUG_PORTS www/squid???
# uncheck NIS - in 4.13, build failed if this feature included, why?
# uncheck PIE, RELRO - for gdb breakpoint for relocation table?  I'm not sure, or just use hb command for hardware breakpoint(not many breakpoints allowed).
make
#'make reinstall' if necessary
#or cp /usr/ports/www/squid/work/squid-4.13/src/squid /usr/local/sbin/squid
cd /usr/ports/www/squid/work/squid-4.13/src/
gdb --args /usr/ports/www/squid/work/squid-4.13/src/squid -N -d 100 -X -f /usr/local/etc/squid/squid.conf
 
Last edited:
Back
Top