Skip to content

Instantly share code, notes, and snippets.

@nehaljwani
Last active January 13, 2022 20:24
Show Gist options
  • Save nehaljwani/a321fe0b47a0972dc0372a1b6a9664d8 to your computer and use it in GitHub Desktop.
Save nehaljwani/a321fe0b47a0972dc0372a1b6a9664d8 to your computer and use it in GitHub Desktop.
GDB Cheetsheet
=======================================================================================================================================
You can run gdb with --args parameter,
gdb --args executablename arg1 arg2 arg3
If you want it to run automatically, place some commands in a file (e.g. 'run') and give it as argument: -x /tmp/cmds. Optionally you can run with -batch mode.
gdb -batch -x /tmp/cmds --args executablename arg1 arg2 arg3
=======================================================================================================================================
You can dynamically allocate some space and use it to store a new variable. Depending on what you mean by "scope of the current function" it may not be what you want.
But here is how it looks like, when you have function func() that takes a pointer to an output parameter:
set $foo = malloc(sizeof(struct funcOutStruct))
call func($foo)
p *$foo
call free($foo)
=======================================================================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment