Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get GDB to skip/ignore an instruction?

Tags:

gdb

I'm running through some assembly code in GDB trying to debug my program and I'd like to see what happens if I ignore an instruction entirely, is there a way to do this? (skip past it to the next line without executing it) without having to edit the source code and comment out the function and then recompile?

like image 812
Riptyde4 Avatar asked Nov 16 '13 05:11

Riptyde4


People also ask

How do I skip instructions in gdb?

Sure: jump *0x1234 will jump to instruction at address 0x1234 .

What does jump do in gdb?

Description. This command jumps the program counter to the specified location. The debugger resumes program execution at that point unless it encounters a breakpoint there.

How do you skip the line by line execution of function calling while debugging our program?

If you really want to skip a line, thus stepping to the next one but NOT executing it, you can use jump X (X being a line number). Be careful and use breakpoints, because using jump will make the debugger resume code execution from line X.

How do you stop an infinite loop in gdb?

Start calc from within gdb using the run command. It will go into an infinite loop. Press Ctrl-C (like before) to stop your program.


1 Answers

is there a way to do this

Sure: jump *0x1234 will jump to instruction at address 0x1234.

skip past it to the next line without executing it

"Next line" and assembly debugging rarely go together. As this answer shows, you can skip a line as well.

like image 163
Employed Russian Avatar answered Sep 28 '22 08:09

Employed Russian