Difference between specifying executable on gdb commandline and using "target exec"
I'm trying to make a "gdb --python" script that analyzes a core dump
and sends a report to https://sentry.io. It is going well, except I
have hit a small (to me) unexpected problem - the stacktrace that I
get in my script is not as good as the stacktrace I get when running
gdb manually. I've dug a step further and found out that the problem
has nothing to do with python scripting, but really is caused by
specifying the executable with "target exec" from the gdb prompt
instead of specifying it in command line when invoking gdb.
I've attached the log output where "backtrace" is executed on the same
corefile and the same executable - the only difference is that in one
case the executable is specified as the argument to the gdb command
and in the other case gdb is started without any arguments and the
executable is specified with "target exec".
Am I doing something wrong or is this a bug?
I have reproduced the problem with these gdb versions:
* GNU gdb (GDB) Fedora 8.0.1-26.fc26
* GNU gdb (GDB) Red Hat Enterprise Linux 7.12-24.el7