Find executable that a core dump was generated against Find executable that a core dump was generated against unix unix

Find executable that a core dump was generated against


See this question to get the git hash.

Then, change your build procedure (e.g. your Makefile) to include it. For instance, generate a one line C file with

  git log --pretty=format:'const char program_git_hash[] = "%H";' \      -n 1 > _prog_hash.c

then link your program with _prog_hash.c and remove that file after linking.You could add timestamping information with e.g.

 date +'const char program_timestamp="%c";%n' >> _prog_hash.c

Then you could use gdb or strings on the binary executable to find it.

You may want to declare extern const char program_git_hash[]; in some header file, and perhaps display it (e.g. when passing the --version option to your program)