Skip to Main Content
The Art of Debugging with GDB, DDD, and Eclipse
book

The Art of Debugging with GDB, DDD, and Eclipse

by Norman Matloff, Peter Jay Salzman
September 2008
Intermediate to advanced content levelIntermediate to advanced
280 pages
6h 31m
English
No Starch Press
Content preview from The Art of Debugging with GDB, DDD, and Eclipse

GDB's Own Variables

In addition to the variables you declare in your program, GDB also provides mechanisms for others.

Making Use of the Value History

Output values from GDB's print command are labeled $1, $2, and so on, with these quantities collectively being called the value history. They can be used to produce shortcuts in future print commands that you issue.

For instance, consider the bintree example from Our Main Example Code. Part of a GDB session might look like this:

(gdb) p tmp->left
$1 = (struct node *) 0x80496a8
(gdb) p *(tmp->left)
$2 = {val = 5, left = 0x0, right = 0x0}
(gdb) p *$1
$3 = {val = 5, left = 0x0, right = 0x0}

What happened here is that after we printed out the value of the pointer tmp->left and found it to be nonzero, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning x64 Assembly Programming: From Novice to AVX Professional

Beginning x64 Assembly Programming: From Novice to AVX Professional

Jo Van Hoey
Command-Line Rust

Command-Line Rust

Ken Youens-Clark
Modern CMake for C++

Modern CMake for C++

Rafał Świdziński

Publisher Resources

ISBN: 9781593271749Errata Page