I'm trying to run multiple commands on a single line, e.g
(gdb) info threads; c
Args must be numbers or '$' variables.
But it looks like gdb doesn't support so. Any ideas?
I'm trying to run multiple commands on a single line, e.g
(gdb) info threads; c
Args must be numbers or '$' variables.
But it looks like gdb doesn't support so. Any ideas?
Use define
command to define your own command:
(gdb) define mycommand
Type commands for definition of "mycommand".
End with a line saying just "end".
>info threads
>c
>end
(gdb) mycommand
For detailed information, you can refer: https://sourceware.org/gdb/onlinedocs/gdb/Define.html#Define.
gdb doesn't have a syntax for this. So, you can't do it.
If you want to be able to run canned sequences, see the "define" command.
You can achieve it by first putting the breakpoints and then use the "command inside GDB and mention all the commands which should gets executed when this particular breakpoints hits. This way we can automate our debugging session as well.
(gdb) help command
Set commands to be executed when a breakpoint is hit. Give breakpoint number as argument after "commands". With no argument, the targeted breakpoint is the last one set. The commands themselves follow starting on the next line. Type a line containing "end" to indicate the end of them. Give "silent" as the first line to make the breakpoint silent; then no output is printed when it is hit, except what the commands print.
(gdb) break main
Breakpoint 1 at 0x40113e: file thread.cpp, line 19.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x000000000040113e in main() at thread.cpp:19
(gdb) commands 1
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>info locals
>print argc
>print argv
>backtrace
>end
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x000000000040113e in main() at thread.cpp:19
info locals
print argc
print argv
backtrace
(gdb)