aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-05-18 17:11:25 +0000
committerPedro Alves <palves@redhat.com>2009-05-18 17:11:25 +0000
commit4d062f1ad566bb7f0eaed761db36788a7e981a28 (patch)
treec3728bfd05040f58971c32702491a7f2811558b1 /gdb/linux-nat.c
parentd90e17a74d28db7b3632eced357327ce2fb14f01 (diff)
downloadbinutils-4d062f1ad566bb7f0eaed761db36788a7e981a28.zip
binutils-4d062f1ad566bb7f0eaed761db36788a7e981a28.tar.gz
binutils-4d062f1ad566bb7f0eaed761db36788a7e981a28.tar.bz2
* linux-nat.h (linux_proc_get_tgid): Declare.
* linux-nat.c (linux_proc_get_tgid): New. * linux-thread-db.c (struct thread_db_info): New field `need_stale_parent_threads_check'. (add_thread_db_info): Set it. (find_new_threads_callback): Ignore stale fork parent threads. (thread_db_resume): New. (init_thread_db_ops): Install thread_db_resume.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 553d676..c3aa94f 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1129,6 +1129,34 @@ exit_lwp (struct lwp_info *lp)
delete_lwp (lp->ptid);
}
+/* Return an lwp's tgid, found in `/proc/PID/status'. */
+
+int
+linux_proc_get_tgid (int lwpid)
+{
+ FILE *status_file;
+ char buf[100];
+ int tgid = -1;
+
+ snprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid);
+ status_file = fopen (buf, "r");
+ if (status_file != NULL)
+ {
+ while (fgets (buf, sizeof (buf), status_file))
+ {
+ if (strncmp (buf, "Tgid:", 5) == 0)
+ {
+ tgid = strtoul (buf + strlen ("Tgid:"), NULL, 10);
+ break;
+ }
+ }
+
+ fclose (status_file);
+ }
+
+ return tgid;
+}
+
/* Detect `T (stopped)' in `/proc/PID/status'.
Other states including `T (tracing stop)' are reported as false. */