aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2009-01-05 23:11:48 +0000
committerDoug Evans <dje@google.com>2009-01-05 23:11:48 +0000
commit0e21c1ec8e45706de9a13129de9e4ab7195deb35 (patch)
tree21711db3d4d639d10e88da3574107910d15e4d08 /gdb
parent5171e6b382aadd794cb3f634c5370be1ba2cb0b2 (diff)
downloadbinutils-0e21c1ec8e45706de9a13129de9e4ab7195deb35.zip
binutils-0e21c1ec8e45706de9a13129de9e4ab7195deb35.tar.gz
binutils-0e21c1ec8e45706de9a13129de9e4ab7195deb35.tar.bz2
* linux-low.c (linux_attach_lwp): Add some comments/fixmes.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog4
-rw-r--r--gdb/gdbserver/linux-low.c35
2 files changed, 33 insertions, 6 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 7c4d073..873a513 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,9 @@
2008-12-13 Doug Evans <dje@google.com>
+ * linux-low.c (linux_attach_lwp): Add some comments/fixmes.
+
+2008-12-13 Doug Evans <dje@google.com>
+
* utils.c (xmalloc,xcalloc,xstrdup): New fns.
* server.h (ATTR_MALLOC): New macro.
(xmalloc,xcalloc,xstrdup): Declare.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c8b07eb..3556204 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -326,6 +326,8 @@ linux_attach_lwp (unsigned long pid)
strerror (errno), errno);
}
+ /* FIXME: This intermittently fails.
+ We need to wait for SIGSTOP first. */
ptrace (PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACECLONE);
new_process = (struct process_info *) add_process (pid);
@@ -333,15 +335,36 @@ linux_attach_lwp (unsigned long pid)
new_thread_notify (thread_id_to_gdb_id (new_process->lwpid));
/* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH
- brings it to a halt. We should ignore that SIGSTOP and resume the process
- (unless this is the first process, in which case the flag will be cleared
- in linux_attach).
+ brings it to a halt.
+
+ There are several cases to consider here:
+
+ 1) gdbserver has already attached to the process and is being notified
+ of a new thread that is being created.
+ In this case we should ignore that SIGSTOP and resume the process.
+ This is handled below by setting stop_expected = 1.
+
+ 2) This is the first thread (the process thread), and we're attaching
+ to it via attach_inferior.
+ In this case we want the process thread to stop.
+ This is handled by having linux_attach clear stop_expected after
+ we return.
+ ??? If the process already has several threads we leave the other
+ threads running.
+
+ 3) GDB is connecting to gdbserver and is requesting an enumeration of all
+ existing threads.
+ In this case we want the thread to stop.
+ FIXME: This case is currently not properly handled.
+ We should wait for the SIGSTOP but don't. Things work apparently
+ because enough time passes between when we ptrace (ATTACH) and when
+ gdb makes the next ptrace call on the thread.
On the other hand, if we are currently trying to stop all threads, we
should treat the new thread as if we had sent it a SIGSTOP. This works
- because we are guaranteed that add_process added us to the end of the
- list, and so the new thread has not yet reached wait_for_sigstop (but
- will). */
+ because we are guaranteed that the add_process call above added us to the
+ end of the list, and so the new thread has not yet reached
+ wait_for_sigstop (but will). */
if (! stopping_threads)
new_process->stop_expected = 1;
}