Bug 17331 - Inconsistencies between gdb -batch and interactive
Summary: Inconsistencies between gdb -batch and interactive
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-29 20:37 UTC by David E. Narváez
Modified: 2014-08-29 20:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David E. Narváez 2014-08-29 20:37:47 UTC
While trying to get the backtrace of all threads I get this from gdb -batch:

$ ~/local-gdb/bin/gdb -batch -x ~/test-gdb-commands -p `pidof kwrite`

Thread 1 (process 14068):
#0  0xc5079a9d in ?? ()
Backtrace stopped: Cannot access memory at address 0x6668c40

While running it interactively I get:

(gdb) thread apply all bt

Thread 1 (process 14089):
#0  0x00007fba06affa9d in poll () from /lib/libc.so.6
#1  0x00007fba02deff14 in ?? () from /usr/lib64/libglib-2.0.so.0
#2  0x00007fba02df001c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#3  0x00007fba0542dc7e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#4  0x00007fba05ab1356 in ?? () from /usr/lib64/qt4/libQtGui.so.4
#5  0x00007fba053ffd7f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#6  0x00007fba05400075 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#7  0x00007fba05405189 in QCoreApplication::exec() () from /usr/lib64/qt4/libQtCore.so.4
#8  0x00007fba06fafdf3 in kdemain () from /usr/lib64/libkdeinit4_kwrite.so
#9  0x00007fba06a42a65 in __libc_start_main () from /lib/libc.so.6
#10 0x00000000004006de in _start ()

The contents of test-gdb-commands are

$ more ~/test-gdb-commands 
thread apply all bt

This is

$ ~/local-gdb/bin/gdb --version
GNU gdb (GDB) 7.8.50.20140829-cvs

and this all works correctly in

$ gdb --version
GNU gdb (Gentoo 7.7 p1) 7.7

One thing I noticed is that my intsalled version (GDB 7.7) prints threads with the format

Thread 1 (Thread 0x7f6151f9a780 (LWP 14252))

so it is printing from linux-thread-db.c (thread_db_pid_to_str) while the new version prints from thread.c (normal_pid_to_str) so I wonder if this has anything to do with the inconsistency.