Skip to content

Instantly share code, notes, and snippets.

@kelunik
Last active December 17, 2019 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelunik/a5ae41c9a47bc29e965da1e6a5f5dd29 to your computer and use it in GitHub Desktop.
Save kelunik/a5ae41c9a47bc29e965da1e6a5f5dd29 to your computer and use it in GitHub Desktop.
gdb --batch --command=gdb.bt -return-child-result --args ./a.out
gcc -g test.c
set pagination off
set logging file gdb.txt
set logging on
init-if-undefined $_exitcode = -1
handle SIGTERM nostop print pass
handle SIGPIPE nostop noprint pass
run
if ($_exitcode == -1)
bt
end
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
char *buf;
buf = malloc(1<<31);
fgets(buf, 1024, stdin);
printf("%s\n", buf);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment