gdb basics

Getting started with gdb , some notes on this

objdump (otool on osx) is a program to examine a binary.
To examine perl run the command

objdump -D /usr/bin/perl |grep -A40 main.:

Interesting to see the function call
objdump -D /usr/bin/perl |grep -A400 main.: |grep call

to get the output in intel syntax add the option -M

objdump -M intel ...

for the following c program

main() {
printf("hello world \n");

-g flag to give gcc access to source code
gcc -g prog.c

gdb commands to debug a c program
gdb -q a.out
set disassembly intel

break main
disassemble main

to dump a string stored in memory
x/s 0x... (memory address) in this prog we can check the string hello world stored at instruction mov

debugging perl
- Get the latest bleadperl from git
- Configure and install perl with debugging support sh Configure -DEBUGGING=both
gdb -q /usr/local/bin/perl
set disassembly intel
break main or break line number

nexti or n to step through
s to step through a subroutine

x/s variable to print the contents of a var

Leave a comment

About Kiran

user-pic I blog about Perl.