Hacker Public Radio

HPR3284: Introduction to gdb


Listen Later

Frustrated by gdb tutorials that are either too complicated or too simple? I think this might be an actually-useful tutorial to help you see how and why gdb can be useful. Anyway, it's the path I followed to finding a use for the mysterious gdb, so maybe it will work for you.
To follow along with this episode, here's some simple yet buggy code. This compiles but crashes when run.
#include <iostream>
#include <stdlib.h> // rand
#include <stdio.h> // printf
using namespace std;
int main () {
srand (time(NULL));
int penguin = rand() % 8;
cout << "This is a message from your friendly codern" << endl;
int kiwi = 3;
printf("penguin is set to is %sn", penguin);
printf("kiwi is set to is %sn", kiwi);
return 0;
} // main
To compile it and see it crash, do this:
$ g++ example.cpp
$ ./a.out
To compile it with debug symbols so you can step through it in gdb, do this:
$ g++ -g -o debugtest example.cpp
$ gdb debugtest
You can now follow along with this tutorial.
For extra credit, try compiling this with clang++ instead!
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

290 Listeners

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec by Jerry Bell and Andrew Kalat

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec

372 Listeners

LINUX Unplugged by Jupiter Broadcasting

LINUX Unplugged

268 Listeners

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast) by Johannes B. Ullrich

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast)

651 Listeners

Curious Cases by BBC Radio 4

Curious Cases

820 Listeners

The Strong Towns Podcast by Strong Towns

The Strong Towns Podcast

422 Listeners

Late Night Linux by The Late Night Linux Family

Late Night Linux

164 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,061 Listeners

Cybersecurity Today by Jim Love

Cybersecurity Today

179 Listeners

CISO Series Podcast by David Spark, Mike Johnson, and Andy Ellis

CISO Series Podcast

189 Listeners

TechCrunch Daily Crunch by TechCrunch

TechCrunch Daily Crunch

42 Listeners

Strict Scrutiny by Crooked Media

Strict Scrutiny

5,794 Listeners

2.5 Admins by The Late Night Linux Family

2.5 Admins

98 Listeners

Cyber Security Headlines by CISO Series

Cyber Security Headlines

139 Listeners

What the Hack? by DeleteMe

What the Hack?

228 Listeners