Advanced debugging with gdb (Reverse execution , Pretty-Printer and Asan)

# Pretty print (pp)
python import sys
python sys.path.insert(1,'<path/to/qtcreator>/share/qtcreator/debugger/')
# normally /usr/share/qtcreator/debugger
python from gdbbridge import *
handle SIGPIPE nostop# Normal arguments to
set args -o test.txt
set substitute-path [original_path] [new_path]
set history filename ~/.gdb_history
set history save on
set history size 1000
# Use dir if code is referenced relative i.e. ../src
dir /home/where/source/is/found
gdb --configuration
#include <string.h>
class IString
IString(const char *txt) : pBuffer(text) {
char *pBuffer;
int numChars;
char text[10];
void fun() {
IString string1("This is a string that will not fit");
int main(int, char**)
IString string1("This string also do not fit");
char test[20];
fun();return 0;
from dumper import *
def qdump__IString(d, value):
d.putValue("[{0}, {1}]".format(value["Buff"], value["n"]))
if d.isExpanded():
with Children(d):
d.putSubItem("Buff", value["pBuffer"])
d.putSubItem("n", value["numChars"])
(gdb) set print pretty 1
ptype $_siginfo
p $_siginfo._sifields._sigfault.si_addrp $_exception
int *array = (int *) malloc (len * sizeof (int));
p *array@len
p/x (short[2])0x12345678

CentOS 7

yum install centos-release-scl
yum install devtoolset-9-gdb
import sys
sys.path.insert(0, '/usr/share/gcc-4.8.5/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)


-g3 -fsanitize=address,undefined
(gdb) rbreak ^__ubsan_handle_ __asan_report_error
(gdb) commands
(gdb) finish
(gdb) end




Software Engineer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

App Notifications If They Were Written By Classic Poets

How To Rewrite URLs with mod_rewrite for Apache on Debian 8

The Early Velocity Trap

Picture of a mouse looking for an escape route in several traps.

Serverless Supercharged — custom Transaction Log Tailing (TLT) implementation with Firebase Cloud…

How to install HEASoft, Sherpa and XSPEC extension on MacOS

We're giving away 5% of total supply as airdrop to 4,000 participant only

Running Python as a Scheduled Task (Windows)

Improve Your Skills By Improving Your Skills Page

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Olof Astrand

Olof Astrand

Software Engineer.

More from Medium

Knockin’ on the client’s door or Effective remote presentation

How to Excel as a Milliner

Meet Mojo— The Planning Tool That Prioritizes You

Week 5 — Audio Calptioning