Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What useful GDB scripts have you used/written?

People use gdb on and off for debugging, of course there are lots of other debugging tools across the varied OSes, with and without GUI and, maybe other fancy IDE features.

I would like to know what useful gdb scripts you have written and liked.
While, I do not mean a dump of commands in a something.gdb file that you source to pull out a bunch of data, if that made your day, go ahead and talk about it.

  • Lets think conditional processing, control loops and functions written for more elegant and refined programming to debug and, maybe even for whitebox testing
  • Things get interesting when you start debugging remote systems (say, over a serial/ethernet interface)
  • And, what if the target is a multi-processor (and, multithreaded) system

Let me put a simple case as an example...
Say,

A script that traversed serially over entries
to locate a bad entry in a large hash-table
that is implemented on an embedded platform.

That helped me debug a broken hash-table once.

like image 371
nik Avatar asked Jul 07 '09 19:07

nik


People also ask

What is GDB in C?

Gdb is a debugger for C (and C++). It allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line.


1 Answers

This script, not written by me, pretty prints STL containers, such as vector, map, etc: http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt

Totally awesome.

like image 65
Artem Russakovskii Avatar answered Sep 21 '22 11:09

Artem Russakovskii