Difference between specifying executable on gdb commandline and using "target exec"

Thomas Sondergaard <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAKxQmMssDw1bPJzZuh6-ybz8_6pF33wz2OwHCv+PF+CwKrOgjA@mail.gmail.com>
Hi,

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

Best regards,

Thomas Sondergaard
gdb-exec-on-command-line.txt (text/plain, 7.7 KB)
# /opt/rh/devtoolset-6/root/usr/bin/gdb /usr/bin/wfm
GNU gdb (GDB) Red Hat Enterprise Linux 7.12-24.el7
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/wfm...done.
(gdb) set pagination off
(gdb) set opaque-type-resolution off
(gdb) target core /tmp/core.8302
[New LWP 8302]
[New LWP 8308]
[New LWP 8305]
[New LWP 8306]
[New LWP 8307]
[New LWP 8303]
[New LWP 8304]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `wfm --evgeometry 1403x922+0+28'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
[Current thread is 1 (Thread 0x7fb857b75940 (LWP 8302))]
Missing separate debuginfos, use: debuginfo-install wfm-7.4.3-199.el7.snapshot.x86_64
(gdb) bt
#0  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007fb85ff40a28 in __GI_abort () at abort.c:119
#2  0x00007fb868a80fc6 in qtutility::qtutil::tracebackAndExitHandlerGUI (sig=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/qtutil.cc:488
#3  <signal handler called>
#4  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fb85ff408e8 in __GI_abort () at abort.c:90
#6  0x00007fb8689f5e7e in qtutility::DebugMenu::crashOwnProcess (this=0x1602e60) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/DebugMenu.cc:148
#7  0x00007fb860d5649e in QtPrivate::QSlotObjectBase::call (a=0x7fff3bd6a230, r=0x1602e60, this=<optimized out>) at ../../src/corelib/kernel/qobject_impl.h:124
#8  QMetaObject::activate (sender=sender@entry=0x15c27c0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fff3bd6a230) at kernel/qobject.cpp:3715
#9  0x00007fb860d569e7 in QMetaObject::activate (sender=sender@entry=0x15c27c0, m=m@entry=0x7fb861b01a20 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fff3bd6a230) at kernel/qobject.cpp:3595
#10 0x00007fb8615fdeb2 in QAction::triggered (this=this@entry=0x15c27c0, _t1=false) at .moc/moc_qaction.cpp:369
#11 0x00007fb8616009d0 in QAction::activate (this=0x15c27c0, event=<optimized out>) at kernel/qaction.cpp:1163
#12 0x00007fb86178a9e2 in QMenuPrivate::activateCausedStack (this=this@entry=0x1602ec0, causedStack=..., action=action@entry=0x15c27c0, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1130
#13 0x00007fb861790b66 in QMenuPrivate::activateAction (this=this@entry=0x1602ec0, action=action@entry=0x15c27c0, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1207
#14 0x00007fb861794d99 in QMenu::mouseReleaseEvent (this=<optimized out>, e=0x7fff3bd6a8a0) at widgets/qmenu.cpp:2634
#15 0x00007fb86164ca58 in QWidget::event (this=this@entry=0x1602e60, event=event@entry=0x7fff3bd6a8a0) at kernel/qwidget.cpp:9104
#16 0x00007fb8617957c3 in QMenu::event (this=0x1602e60, e=0x7fff3bd6a8a0) at widgets/qmenu.cpp:2753
#17 0x00007fb8616073bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x1602e60, e=0x7fff3bd6a8a0) at kernel/qapplication.cpp:3804
#18 0x00007fb86160d14e in QApplication::notify (this=this@entry=0x7fff3bd6b290, receiver=0x1602e60, e=0x7fff3bd6a8a0) at kernel/qapplication.cpp:3277
#19 0x00007fb868a206e2 in qtutility::ExceptionHandlingApplication::catchingNotify (this=0x7fff3bd6b290, receiver=<optimized out>, event=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/ExceptionHandlingApplication.cc:60
#20 0x00007fb860d2ed3a in QCoreApplication::notifyInternal2 (receiver=0x1602e60, event=0x7fff3bd6a8a0) at kernel/qcoreapplication.cpp:1015
#21 0x00007fb86160be45 in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x1602e60, event=event@entry=0x7fff3bd6a8a0, alienWidget=0x0, alienWidget@entry=0x1602e60, nativeWidget=0x1602e60, buttonDown=buttonDown@entry=0x7fb861b30cc0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true) at ../../src/corelib/kernel/qcoreapplication.h:225
#22 0x00007fb861667da7 in QWidgetWindow::handleMouseEvent (this=this@entry=0x16ddf00, event=event@entry=0x7fff3bd6ad00) at kernel/qwidgetwindow.cpp:501
#23 0x00007fb86166a0a3 in QWidgetWindow::event (this=0x16ddf00, event=0x7fff3bd6ad00) at kernel/qwidgetwindow.cpp:233
#24 0x00007fb8616073bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x16ddf00, e=0x7fff3bd6ad00) at kernel/qapplication.cpp:3804
#25 0x00007fb86160c8f6 in QApplication::notify (this=this@entry=0x7fff3bd6b290, receiver=0x16ddf00, e=0x7fff3bd6ad00) at kernel/qapplication.cpp:3561
#26 0x00007fb868a206e2 in qtutility::ExceptionHandlingApplication::catchingNotify (this=0x7fff3bd6b290, receiver=<optimized out>, event=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/ExceptionHandlingApplication.cc:60
#27 0x00007fb860d2ed3a in QCoreApplication::notifyInternal2 (receiver=receiver@entry=0x16ddf00, event=event@entry=0x7fff3bd6ad00) at kernel/qcoreapplication.cpp:1015
#28 0x00007fb86105f69b in QCoreApplication::sendSpontaneousEvent (event=0x7fff3bd6ad00, receiver=0x16ddf00) at ../../src/corelib/kernel/qcoreapplication.h:228
#29 QGuiApplicationPrivate::processMouseEvent (e=0x134d940) at kernel/qguiapplication.cpp:1877
#30 0x00007fb8610611d5 in QGuiApplicationPrivate::processWindowSystemEvent (e=<optimized out>) at kernel/qguiapplication.cpp:1661
#31 0x00007fb861041b2b in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:653
#32 0x00007fb8515500e0 in userEventSourceDispatch (source=<optimized out>) at eventdispatchers/qeventdispatcher_glib.cpp:70
#33 0x00007fb859f0e4c9 in g_main_dispatch (context=0x7fb8480016f0) at gmain.c:3201
#34 g_main_context_dispatch (context=context@entry=0x7fb8480016f0) at gmain.c:3854
#35 0x00007fb859f0e818 in g_main_context_iterate (context=context@entry=0x7fb8480016f0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3927
#36 0x00007fb859f0e8cc in g_main_context_iteration (context=0x7fb8480016f0, may_block=may_block@entry=1) at gmain.c:3988
#37 0x00007fb860d7d72f in QEventDispatcherGlib::processEvents (this=0x1315b90, flags=...) at kernel/qeventdispatcher_glib.cpp:417
#38 0x00007fb860d2dbaa in QEventLoop::exec (this=this@entry=0x7fff3bd6b0b0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:206
#39 0x00007fb860d3552c in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1285
#40 0x00007fb861056a5c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1607
#41 0x00007fb861604375 in QApplication::exec () at kernel/qapplication.cpp:2979
#42 0x000000000042ee13 in main_ (argc=<optimized out>, argv=argv@entry=0x7fff3bd6b428, app=...) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/wfm/src/main.cc:123
#43 0x000000000042a72e in main (argc=<optimized out>, argv=0x7fff3bd6b428) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/wfm/src/main.cc:151
(gdb)
gdb-using-target-exec-from-gdb-prompt.txt (text/plain, 7.9 KB)
# /opt/rh/devtoolset-6/root/usr/bin/gdb
GNU gdb (GDB) Red Hat Enterprise Linux 7.12-24.el7
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) set pagination off
(gdb) set opaque-type-resolution off
(gdb) target exec /usr/bin/wfm
(gdb) target core /tmp/core.8302
[New LWP 8302]
[New LWP 8308]
[New LWP 8305]
[New LWP 8306]
[New LWP 8307]
[New LWP 8303]
[New LWP 8304]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `wfm --evgeometry 1403x922+0+28'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
[Current thread is 1 (Thread 0x7fb857b75940 (LWP 8302))]
Missing separate debuginfos, use: debuginfo-install wfm-7.4.3-199.el7.snapshot.x86_64
(gdb) bt
#0  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007fb85ff40a28 in __GI_abort () at abort.c:119
#2  0x00007fb868a80fc6 in qtutility::qtutil::tracebackAndExitHandlerGUI (sig=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/qtutil.cc:488
#3  <signal handler called>
#4  0x00007fb85ff3f1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fb85ff408e8 in __GI_abort () at abort.c:90
#6  0x00007fb8689f5e7e in qtutility::DebugMenu::crashOwnProcess (this=0x1602e60) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/DebugMenu.cc:148
#7  0x00007fb860d5649e in QtPrivate::QSlotObjectBase::call (a=0x7fff3bd6a230, r=0x1602e60, this=<optimized out>) at ../../src/corelib/kernel/qobject_impl.h:124
#8  QMetaObject::activate (sender=sender@entry=0x15c27c0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fff3bd6a230) at kernel/qobject.cpp:3715
#9  0x00007fb860d569e7 in QMetaObject::activate (sender=sender@entry=0x15c27c0, m=m@entry=0x7fb861b01a20 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fff3bd6a230) at kernel/qobject.cpp:3595
#10 0x00007fb8615fdeb2 in QAction::triggered (this=this@entry=0x15c27c0, _t1=false) at .moc/moc_qaction.cpp:369
#11 0x00007fb8616009d0 in QAction::activate (this=0x15c27c0, event=<optimized out>) at kernel/qaction.cpp:1163
#12 0x00007fb86178a9e2 in QMenuPrivate::activateCausedStack (this=this@entry=0x1602ec0, causedStack=..., action=action@entry=0x15c27c0, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1130
#13 0x00007fb861790b66 in QMenuPrivate::activateAction (this=this@entry=0x1602ec0, action=action@entry=0x15c27c0, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1207
#14 0x00007fb861794d99 in QMenu::mouseReleaseEvent (this=<optimized out>, e=0x7fff3bd6a8a0) at widgets/qmenu.cpp:2634
#15 0x00007fb86164ca58 in QWidget::event (this=this@entry=0x1602e60, event=event@entry=0x7fff3bd6a8a0) at kernel/qwidget.cpp:9104
#16 0x00007fb8617957c3 in QMenu::event (this=0x1602e60, e=0x7fff3bd6a8a0) at widgets/qmenu.cpp:2753
#17 0x00007fb8616073bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x1602e60, e=0x7fff3bd6a8a0) at kernel/qapplication.cpp:3804
#18 0x00007fb86160d14e in QApplication::notify (this=this@entry=0x7fff3bd6b290, receiver=0x1602e60, e=0x7fff3bd6a8a0) at kernel/qapplication.cpp:3277
#19 0x00007fb868a206e2 in qtutility::ExceptionHandlingApplication::catchingNotify (this=0x7fff3bd6b290, receiver=<optimized out>, event=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/ExceptionHandlingApplication.cc:60
#20 0x00007fb860d2ed3a in QCoreApplication::notifyInternal2 (receiver=0x1602e60, event=0x7fff3bd6a8a0) at kernel/qcoreapplication.cpp:1015
#21 0x00007fb86160be45 in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x1602e60, event=event@entry=0x7fff3bd6a8a0, alienWidget=0x0, alienWidget@entry=0x1602e60, nativeWidget=0x1602e60, buttonDown=buttonDown@entry=0x7fb861b30cc0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true) at ../../src/corelib/kernel/qcoreapplication.h:225
#22 0x00007fb861667da7 in QWidgetWindow::handleMouseEvent (this=this@entry=0x16ddf00, event=event@entry=0x7fff3bd6ad00) at kernel/qwidgetwindow.cpp:501
#23 0x00007fb86166a0a3 in QWidgetWindow::event (this=0x16ddf00, event=0x7fff3bd6ad00) at kernel/qwidgetwindow.cpp:233
#24 0x00007fb8616073bc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x16ddf00, e=0x7fff3bd6ad00) at kernel/qapplication.cpp:3804
#25 0x00007fb86160c8f6 in QApplication::notify (this=this@entry=0x7fff3bd6b290, receiver=0x16ddf00, e=0x7fff3bd6ad00) at kernel/qapplication.cpp:3561
#26 0x00007fb868a206e2 in qtutility::ExceptionHandlingApplication::catchingNotify (this=0x7fff3bd6b290, receiver=<optimized out>, event=<optimized out>) at /home/jenkins/workspace/easyviz-7.4-packages/arch/rhel7_x86_64_ev6/qtutility/src/ExceptionHandlingApplication.cc:60
#27 0x00007fb860d2ed3a in QCoreApplication::notifyInternal2 (receiver=receiver@entry=0x16ddf00, event=event@entry=0x7fff3bd6ad00) at kernel/qcoreapplication.cpp:1015
#28 0x00007fb86105f69b in QCoreApplication::sendSpontaneousEvent (event=0x7fff3bd6ad00, receiver=0x16ddf00) at ../../src/corelib/kernel/qcoreapplication.h:228
#29 QGuiApplicationPrivate::processMouseEvent (e=0x134d940) at kernel/qguiapplication.cpp:1877
#30 0x00007fb8610611d5 in QGuiApplicationPrivate::processWindowSystemEvent (e=<optimized out>) at kernel/qguiapplication.cpp:1661
#31 0x00007fb861041b2b in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:653
#32 0x00007fb8515500e0 in userEventSourceDispatch (source=<optimized out>) at eventdispatchers/qeventdispatcher_glib.cpp:70
#33 0x00007fb859f0e4c9 in g_main_dispatch (context=0x7fb8480016f0) at gmain.c:3201
#34 g_main_context_dispatch (context=context@entry=0x7fb8480016f0) at gmain.c:3854
#35 0x00007fb859f0e818 in g_main_context_iterate (context=context@entry=0x7fb8480016f0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3927
#36 0x00007fb859f0e8cc in g_main_context_iteration (context=0x7fb8480016f0, may_block=may_block@entry=1) at gmain.c:3988
#37 0x00007fb860d7d72f in QEventDispatcherGlib::processEvents (this=0x1315b90, flags=...) at kernel/qeventdispatcher_glib.cpp:417
#38 0x00007fb860d2dbaa in QEventLoop::exec (this=this@entry=0x7fff3bd6b0b0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:206
#39 0x00007fb860d3552c in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1285
#40 0x000000000042ee13 in ?? ()
#41 0x0000000000000020 in ?? ()
#42 0x00007fb8645f0860 in ?? () from /lib64/libevbase.so.7.4
#43 0x00007fff3bd6b428 in ?? ()
#44 0x00007fb8697043c7 in _dl_runtime_resolve_sse_vex () at ../sysdeps/x86_64/dl-trampoline.h:212
#45 0x000000000042a72e in ?? ()
#46 0x0000000000482ec0 in ?? ()
#47 0x000000030000000b in ?? ()
#48 0x000000000000000b in ?? ()
#49 0x00007fb85ff8a10c in __GI___libc_malloc (bytes=140429935576848) at malloc.c:2897
#50 0x00000000011e9b10 in ?? ()
#51 0x0000000000000001 in ?? ()
#52 0x14d138c5962bdc00 in ?? ()
#53 0x0000000000492998 in ?? ()
#54 0x00000000012f5f80 in ?? ()
#55 0x00000000012f5f01 in ?? ()
#56 0x0000000000000000 in ?? ()
(gdb)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.