Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop gdb repeating last (third-party) command when pressing Enter

Tags:

gdb

I'm using some third party macros in gdb, which take a long time to run.

I keep pressing Enter, because my muscle memory does that.

This causes the macro to run again.

Is there any way that I can persuade gdb not to run the previous command on pressing Enter?

I found the dont-repeat documentation, but it seems that I have to add it to the user-defined command. These are third-party commands, and I don't particularly want to edit all of them.

Is there any way to turn this behaviour off globally? Or for specific commands (possibly with a wildcard/regex)?

like image 831
Roger Lipscombe Avatar asked Dec 18 '17 19:12

Roger Lipscombe


People also ask

How do I stop continuing gdb?

To stop your program while it is running, type "(ctrl) + c" (hold down the ctrl key and press c). gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program. To specify other places where gdb should stop, see the section on breakpoints below.

What does breakpoint do in gdb?

A breakpoint makes your program stop whenever a certain point in the program is reached. For each breakpoint, you can add conditions to control in finer detail whether your program stops.

What is Backtrace in gdb?

A backtrace is a summary of how your program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame zero), followed by its caller (frame one), and on up the stack.

How do you remove a breakpoint in gdb?

With the clear command you can delete breakpoints according to where they are in your program. With the delete command you can delete individual breakpoints, watchpoints, or catchpoints by specifying their breakpoint numbers.


1 Answers

These are third-party commands, and I don't particularly want to edit all of them.

For a specific command you can define pre hook, turning off repeating last command. This will let you to avoid editing them. For example you can define such pre hook for continue command:

(gdb) c
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) 
The program is not being run.
(gdb) define hook-continue
Type commands for definition of "hook-continue".
End with a line saying just "end".
>dont-repeat
>end
(gdb) c
The program is not being run.
(gdb) 
(gdb) 
(gdb) 
(gdb) 
(gdb) 

See hooks doc.

like image 133
ks1322 Avatar answered Sep 27 '22 22:09

ks1322