How working with user-defined commands in GDB can make you more productive

GDB versus the Python way

  1. Use the perhaps a bit old fashioned built-in user-defined GDB commands.
  2. Or, use the slightly more modern Python way of doing it.

GDB built-in user-defined commands

(gdb) define bugreport
> set pagination off
> thread apply all backtrace full
> shell uname -a
> end
(gdb)
(gdb) bugreport
(gdb) define bugreport
> set pagination off
> set logging file /tmp/bugreport.txt
> set logging on
> thread apply all backtrace full
> shell uname -a
> set logging off
> end
(gdb)
(gdb) bugreport
(gdb) shell cat /tmp/bugreport.txt

GDB hook command

(gdb) define hook - run
> set arg 3
> end
(gdb)

--

--

--

Undo is the time travel debugging company for Linux. We equip developers with the technology to understand complex code and fix bugs faster. https://undo.io

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

Recommended from Medium

GSoC’21 | Score Lab — A new chapter

Preventing Cascaded Overflow

Effective “arc length” of a non-full bin includes the arc lengths of the previous full bins.

Beginning Python Programming — Part 2

Transform Notion into RSS reader. Part 2 — Multiple RSS endpoints

High-level architecture - v2

String Manipulation [Python]

Best articles from 2021 by Marcin Moskala & Merry Xmas from Kt. Academy🎁

OKRs and KPIs, The difference and what they are meant for...

Calculating Boyer Moore Bad Character Table with examples

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
Undo Bytes

Undo Bytes

Undo is the time travel debugging company for Linux. We equip developers with the technology to understand complex code and fix bugs faster. https://undo.io

More from Medium

Undoing a git mistake: Squash & rewrite commits

GIT — Version Control System

30 useful git commands every developer should know