views:

67

answers:

2

I'd like to go through a binary file my teacher gave me line by line to check addresses on the stack and the contents of different registers, but I'm not extremely familiar with using gdb. Although I have the C code, we're supposed to work entirely from a binary file. Here are the commands I've used so far:

(gdb) file SomeCode

Which gives me this message:

Reading symbols from ../overflow/SomeCode ...(no debugging symbols found)...done.

Then I use :

(gdb) disas main

which gives me all of the assembly. I wanted to set up a break point and use the "next" command, but none of the commands I tried work. Does anyone know the syntax I would use?

A: 

try using ni which is nexti. equivalent is si which is step instruction

aaa
when I try just ni, next, step, etc after the "file SomeCode" command or after "disas main" it says "the program is not being run". If I try to do "run ./SomeCode" it says permission denied. Any idea what I'm missing?
@user first set break point, run, next: `break main`, `run`, `stepi`. read manual, it explains pretty well. I do not mean to put you off, manual is really excellent source to learn debugging. also, you can use help command , example, `help break`
aaa
@user if you are still struggling, post your commands, I will point out where you make the missstake.
aaa
I recompiled from the C file and it seems to be working now. I think the binary file my teacher gave me wasn't compiled with the -g switch. Thanks for your help though
A: 

nexti if you want to jump over function calls. stepi if you want to enter a function call.

The following documentation is very helpful; it has a list of all the important commands you could use on gdb.

X86-64: http://csapp.cs.cmu.edu/public/docs/gdbnotes-x86-64.pdf

IA32: http://csapp.cs.cmu.edu/public/docs/gdbnotes-ia32.pdf

Catie