Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting gdb to automatically load binary from core file

Tags:

c++

gdb

Can I get gdb to automatically load the binary that's specified in the core file?

Given a core file I now usually do:

gdb -c corefile
GNU gdb 6.8
...
Core was generated by `/path/to/binary'

Then i copy-paste that and run:

gdb -c corefile /path/to/binary

It seems like an unnecessary two-step process and yet I don't seen an obvious way of doing it based on the man page. Am I missing something?

like image 598
naumcho Avatar asked Oct 11 '22 14:10

naumcho


1 Answers

You could just script it?

#!/bin/bash
gdb "`file "$1" | awk -F \' '{print $2}'`" "$1"
like image 106
Erik Avatar answered Oct 18 '22 05:10

Erik