Last active
January 13, 2022 20:24
-
-
Save nehaljwani/a321fe0b47a0972dc0372a1b6a9664d8 to your computer and use it in GitHub Desktop.
GDB Cheetsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======================================================================================================================================= | |
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