c - Find executable that a core dump was generated against -


is there way embed version info such git commit hash in elf executable such can retrieved core dumps generated it?

see this question git hash.

then, change build procedure (e.g. makefile) include it. instance, generate 1 line c file with

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

then link program _prog_hash.c , remove file after linking. add timestamping information e.g.

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

then use gdb or strings on binary executable find it.

you may want declare extern const char program_git_hash[]; in header file, , perhaps display (e.g. when passing --version option program)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -