Breakpoints and Commands — save time!
-In order to display some specific information when we reach a breakpoint,
-we can achieve this by (gdb)command command in gdb.
(gdb) command 1
-Type commands for breakpoint(s) 1, one per line.
-End with a line saying just "end".
->print arr
->print size
->end
-Here, the argument to "command" is the index of the breakpoint to which -these print commands will be associated to.
-define your own commands
-In order to define bunch of command give it a name like a alias
-we can use define <alias>.
(gdb) define log
-Type commands for definition of "log".
-End with a line saying just "end".
->info args
->info frame
->bt
->end
-Temporary breakpoint 1, main () at array.c:34
-34 int main () {
-(gdb) log
-No arguments.
-Stack level 0, frame at 0x7fffffffe230:
- rip = 0x555555555217 in main (array.c:34); saved rip = 0x7ffff7c2a1ca
- source language c.
- Arglist at 0x7fffffffe220, args:
- Locals at 0x7fffffffe220, Previous frame's sp is 0x7fffffffe230
- Saved registers:
- rbp at 0x7fffffffe220, rip at 0x7fffffffe228
-#0 main () at array.c:34
-To redefine the same alias like in the above example 'log' we can use
-the same command define log