GDB Module

Botman

Compatibility:

Description

This module serves the goal of sending backtraces of crashing programs, as they crash.
This module only works on botmans.
Every time a botman finds a new coredump, it will send a notification (see module notification).

Configuration

Botman

You need to create a configuration file (/etc/gotham/modules.conf.d/gdb.conf)
This configuration file will store the group to notify when a coredump is found, and the directory to watch for coredump creation.

{
   "notification" : "devs",
   "dir" : "/var/dumps/"
}


You also need to tell the GDB module how to invoc GDB to extract the backtrace.
Create the file /usr/local/share/gotham/modules.d/gdb/command and put:
thread apply all backtrace full


Query botmans through Alfred

It is possible to make alfred able to query botmans for you by combining the power of the spam and rewrite modules.
You can add the following JSON object as a new rule of the rewrite module’s configuration file:

{
    "name" : ".gdb list",
    "filter" : ".gdb list *",
    "rule" : "sed -r 's/^.gdb list (.*)/.spam \\1 .gdb list/'",
    "description" : ".gdb list <pattern>"
}, {
    "name" : ".gdb delete",
    "filter" : ".gdb delete *",
    "rule" : "sed -r 's/^.gdb delete *([^ ]*) (.*)/.spam \\1 .gdb delete \\2/'",
    "description" : ".gdb delete <licence_pattern> <coredump_pattern>"
}, {
    "name" : ".gdb fetch",
    "filter" : ".gdb fetch *",
    "rule" : "sed -r 's/^.gdb fetch *([^ ]*) (.*)/.spam \\1 .gdb fetch \\2/'",
    "description" : ".gdb fetch <licence_pattern> <coredump>"
}


Commands

Using the notification module, you will be warned when a new coredump is created.
There is nothing to do, once the notification group exists and you’re in. This is event-like messages.
Notification from botman-xxx@domain.lan : New coredump detected : /var/dumps/botman.35709.core
This command allows you to list every coredump found by botman.
For each coredump, you will know its size and creation date.
(30/07/2015 14:07:33) guillaume.friloux@botnet.master.com: .gdb list
(14:07:33) botman-xxx:
List of coredumps :
/var/dumps/xxxxx.9186.core188088322015/07/17 10:23:13
/var/dumps/yyyyyy.57024.core145571842015/07/17 10:23:22
/var/dumps/xxxxx.58349.core139591682015/07/17 10:29:06
/var/dumps/xxxxx.58469.core186777602015/07/17 11:07:50
/var/dumps/xxxxx.61550.core188907522015/07/17 14:52:41
/var/dumps/xxxxx.65589.core139632642015/07/17 15:23:42
/var/dumps/xxxxx.71316.core139673602015/07/17 16:06:41
Deleting a coredump.
You may want to delete a coredump to save diskspace, or make it easier to spot new coredumps.
(14:57:34) guillaume.friloux@botnet.master.com: .gdb delete xxxxx.58349.core
(14:57:34) botman-xxxx:
Deleted coredumps :
   /var/dumps/xxxxx.58349.core
This command allows the use of wildcards to delete multiple coredumps at once :
(15:59:41) guillaume.friloux@botnet.master.com: .gdb delete xxxxx.*
(15:59:41) botman-xxxx: 
Deleted coredumps :
   /var/dumps/xxxxx.9186.core
   /var/dumps/xxxxx.58469.core
   /var/dumps/xxxxx.61550.core
   /var/dumps/xxxxx.65589.core
   /var/dumps/xxxxx.71316.core
Retrieve backtrace from a coredump.
This commands makes it easier to retrieve backtrace from a coredump without actually connecting to the server.
(16:05:25) guillaume.friloux@botnet.master.com: .gdb fetch xxxxx.58587.core
(16:05:26) botman-xxxx: Coredump file : /var/dumps/xxxxx.58587.core
Core was generated by `xxxxx'.
Program terminated with signal 11, Segmentation fault.
#0  0x000000080312ab7a in select () from /lib/libc.so.7
[New Thread 805c06400 (LWP 100158/xxxxx)]

Thread 1 (Thread 805c06400 (LWP 100158/xxxxx)):
#0  0x000000080312ab7a in select () from /lib/libc.so.7
No symbol table info available.
#1  0x0000000802dccb32 in select () from /lib/libthr.so.3
No symbol table info available.
#2  0x0000000802518c52 in _ecore_main_select (timeout=29.945528479060158)
     at ecore_main.c:1480
     tv = {tv_sec = 29, tv_usec = 945528}
     t = (struct timeval *) 0x7fffffffebc0
     rfds = {__fds_bits = {11920, 0 <repeats 15 times>}}
     wfds = {__fds_bits = {0 <repeats 16 times>}}
     exfds = {__fds_bits = {0 <repeats 16 times>}}
     fdh = (Ecore_Fd_Handler *) 0x0
     l = (Eina_List *) 0x0
     max_fd = 13
     ret = 45709720
#3  0x0000000802517728 in _ecore_main_loop_iterate_internal (once_only=0)
     at ecore_main.c:1908
     next_time = 29.945528479060158
#4  0x00000008025178c4 in ecore_main_loop_begin () at ecore_main.c:960
No locals.
#5  0x0000000801572d75 in azy_server_run (server=<value optimized out>)
     at src/lib/azy/azy_server.c:314