Tuesday, November 2, 2021

[SOLVED] enable core dump logging with bash script

Issue

There is a core dump file and I can use gdb to open and check the call stack. And I can export the content to gdb.txt by typing set logging on inside the gdb app. Now I'd like to use a script to realize it, bash or python whatever. Is it doable?


Solution

Try something like this:

#!/bin/bash
[ -z "$1" ] && { echo executable required; exit 1; }
[ -z "$2" ] && { echo core required; exit 1; }
gdb --ex bt -ex quit "$1" "$2"

You can do set logging on if you want, or use the stdout from this script (possible filtered).



Answered By - Allan Wind