Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howto:gdb [2018/01/06 12:58] – [Debug Build] Mention that debugging release builds is still useful. digital man | howto:gdb [2024/11/04 02:56] (current) – [Debug Synchronet for *nix using GDB] Ad bug character to title digital man | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Debug Synchronet for *nix using GDB ====== | + | ====== |
| You can either run Synchronet ('' | You can either run Synchronet ('' | ||
| Line 20: | Line 20: | ||
| You can run '' | You can run '' | ||
| current user profile (0 = disabled, non-zero or " | current user profile (0 = disabled, non-zero or " | ||
| - | " | + | " |
| - | configured for no core file generation, check for a call to '' | + | |
| - | in your ''/ | + | |
| - | :!: Linux Sysops: | + | On Debian Linux (at least), you can enable unlimited core file generation as the default for |
| - | lines in your ''/ | + | all (non-root) users by adding the following line to ''/ |
| + | < | ||
| + | * | ||
| + | </ | ||
| + | |||
| + | If you're running sbbs daemonzied (e.g. as a *nix service), you may need to edit your service | ||
| + | start up script (e.g. ''/ | ||
| + | ulimit -c unlimited | ||
| + | |||
| + | Of in the '' | ||
| + | LimitCORE=infinity | ||
| + | |||
| + | :!: **Linux Sysops**:\\ | ||
| + | To help locate sbbs crash core files, | ||
| # Controls whether core dumps will append the PID to the core filename. | # Controls whether core dumps will append the PID to the core filename. | ||
| Line 34: | Line 45: | ||
| This will place core files with the name '' | This will place core files with the name '' | ||
| instead of '' | instead of '' | ||
| + | To reload the modified sysctl configuration files, run | ||
| + | $ / | ||
| + | |||
| + | Also, if you're using the '' | ||
| + | fs.suid_dumpable = 2 | ||
| + | | ||
| + | You can also set '' | ||
| + | $ echo 2 > / | ||
| + | | ||
| ===== Debugging ===== | ===== Debugging ===== | ||
| Line 41: | Line 61: | ||
| or (if debugging with a core file): | or (if debugging with a core file): | ||
| # gdb / | # gdb / | ||
| + | or (if attaching to an existing running instance, reading the PID from ''/ | ||
| + | # gdb / | ||
| + | or (if attaching to an existing running instance, using '' | ||
| + | # gdb -p $(pidof sbbs) | ||
| - | B. Run Synchronet (if no core file used): | + | B. Run Synchronet |
| (gdb) run -nd | (gdb) run -nd | ||
| C. After segfault or other crash (or when using a core), display back-trace: | C. After segfault or other crash (or when using a core), display back-trace: | ||
| (gdb) bt | (gdb) bt | ||
| + | or (if more details are needed): | ||
| + | (gdb) bt full | ||
| D. If (and only if) the last line of the output looks like this: | D. If (and only if) the last line of the output looks like this: | ||
| Line 55: | Line 81: | ||
| E. Copy and paste in e-mail to rob[at]synchro[dot]net or post in one of the Synchronet [[support|discussion groups]]. | E. Copy and paste in e-mail to rob[at]synchro[dot]net or post in one of the Synchronet [[support|discussion groups]]. | ||
| - | Note: When debugging a running '' | + | **TIP:**\\ |
| + | To run Synchronet (non-daemonized) directly from the GNU debugger without having to type " | ||
| + | # gdb -ex run --args sbbs -nd | ||
| + | |||
| + | ==== Root Access ==== | ||
| + | |||
| + | If the '' | ||
| + | |||
| + | Attaching to process 21848 | ||
| + | ptrace: Operation not permitted. | ||
| + | (gdb) | ||
| + | |||
| + | If you get this error, try attaching again as root (e.g. run with '' | ||
| + | |||
| + | ==== Handling SIGPIPE ==== | ||
| + | |||
| + | When debugging a //running// '' | ||
| (gdb) handle SIGPIPE nostop noprint pass | (gdb) handle SIGPIPE nostop noprint pass | ||
| + | | ||
| + | Alternatively, | ||
| + | handle SIGPIPE nostop noprint pass | ||
| + | | ||
| + | ===== Thread Snapshot ===== | ||
| + | |||
| + | To attach to a running sbbs process and quickly collect a snapshot of backtraces from all running threads (remember, obtain root privileges first, e.g. with '' | ||
| + | $ gdb -p $(pidof sbbs) -batch -ex " | ||
| ===== See Also ===== | ===== See Also ===== | ||
| - | * [[:howto:|howto index]] | + | * [[:howto:|How-To |
| + | * [[https:// | ||
| {{tag> | {{tag> | ||