From: Marc Khouzam <marc.khouzam@ericsson.com>
To: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: [Patch] Fix for MI selecting an exited thread
Date: Fri, 20 Apr 2012 21:28:00 -0000 [thread overview]
Message-ID: <F7CE05678329534C957159168FA70DEC579290052E@EUSAACMS0703.eamcs.ericsson.se> (raw)
Hi,
Eclipse is sometimes hitting what I feel is a GDB/MI bug.
When trying to resume an entire inferior in all-stop,
GDB can end up selecting a thread that does not exist anymore.
The below session shows a program that starts a second thread
that exists immediately. Then, I interrupt the inferior with ^C
and try to resume it using an MI command. Because I don't specify
an actual thread but the entire process (thread-group), MI randomly
chooses a thread to use, in this case, the exited thread.
I suggest that MI should only choose a live thread when randomly
selecting one. The below patch does this with no regressions.
Ok?
Session showing the bug:
=======================
> gdb.7.5 a.out
GNU gdb (GDB) 7.4.50.20120420-cvs
(gdb) l
1 #include <pthread.h>
2
3 void* run(void* arg) { return 0; }
4
5 int main(int argc, char** argv) {
6 pthread_t tid;
7 pthread_create(&tid, NULL, &run, NULL);
8 while(1) { }
9 }
(gdb) r
Starting program: /home/lmckhou/testing/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
[New Thread 0xb7fe5b70 (LWP 4645)]
[Thread 0xb7fe5b70 (LWP 4645) exited]
^C
Program received signal SIGINT, Interrupt.
main (argc=1, argv=0xbffff794) at hello.cpp:8
8 while(1) { }
(gdb) interpreter-exec mi "-exec-continue --thread-group i1"
^error,msg="Cannot execute this command without a live selected thread."
(gdb) inf thr
Id Target Id Frame
1 Thread 0xb7fe7b30 (LWP 4641) main (argc=1, argv=0xbffff794) at hello.cpp:8
The current thread <Thread ID 2> has terminated. See `help thread'.
Patch:
=====
2012-04-20 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_execute): Choose a live thread not just
any thread.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.215
diff -u -r1.215 mi-main.c
--- gdb/mi/mi-main.c 27 Mar 2012 19:08:37 -0000 1.215
+++ gdb/mi/mi-main.c 20 Apr 2012 19:47:35 -0000
@@ -2066,7 +2066,7 @@
provide --thread if it wishes to operate on a specific
thread. */
if (inf->pid != 0)
- tp = any_thread_of_process (inf->pid);
+ tp = any_live_thread_of_process (inf->pid);
switch_to_thread (tp ? tp->ptid : null_ptid);
set_current_program_space (inf->pspace);
}
next reply other threads:[~2012-04-20 19:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 21:28 Marc Khouzam [this message]
2012-04-21 3:06 ` asmwarrior
2012-04-21 3:12 ` asmwarrior
2012-04-21 10:12 ` Marc Khouzam
2012-04-24 13:22 ` Pedro Alves
2012-04-24 14:17 ` Marc Khouzam
2012-04-24 14:19 ` Pedro Alves
2012-04-24 15:04 ` Marc Khouzam
2012-04-24 15:02 ` Marc Khouzam
2012-04-24 15:05 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F7CE05678329534C957159168FA70DEC579290052E@EUSAACMS0703.eamcs.ericsson.se \
--to=marc.khouzam@ericsson.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox