This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: threads/1576: Linux 2.6 thread status path in /proc has changed


I filed this bug last night, with a patch. The patch could be a little cleaner, I guess. I shouldn't make assumptions about inlining the "get" functions. Take 2 is attached.

The details on the when the change crept into the kernel are a little sketchy, but you can get the gist of it here: http://www.ussg.iu.edu/hypermail/linux/kernel/0310.0/0052.html

Best regards,

- George

diff -Naur gdb+dejagnu-20031117/gdb-pre-2.6/lin-lwp.c gdb+dejagnu-20031117/gdb/lin-lwp.c
--- gdb+dejagnu-20031117/gdb-pre-2.6/lin-lwp.c	2003-10-08 13:05:56.000000000 -0700
+++ gdb+dejagnu-20031117/gdb/lin-lwp.c	2004-02-27 08:24:40.658222000 -0800
@@ -837,12 +837,12 @@
    the appropriate bits in PENDING, and return 1 - otherwise return 0.  */
 
 static int
-lin_lwp_has_pending (int pid, sigset_t *pending, sigset_t *flush_mask)
+lin_lwp_has_pending (ptid_t ptid, sigset_t *pending, sigset_t *flush_mask)
 {
   sigset_t blocked, ignored;
   int i;
 
-  linux_proc_pending_signals (pid, pending, &blocked, &ignored);
+  linux_proc_pending_signals (ptid, pending, &blocked, &ignored);
 
   if (!flush_mask)
     return 0;
@@ -894,7 +894,7 @@
 	lp->status = 0;
     }
 
-  while (lin_lwp_has_pending (GET_LWP (lp->ptid), &pending, flush_mask))
+  while (lin_lwp_has_pending (lp->ptid, &pending, flush_mask))
     {
       int ret;
       
diff -Naur gdb+dejagnu-20031117/gdb-pre-2.6/linux-nat.h gdb+dejagnu-20031117/gdb/linux-nat.h
--- gdb+dejagnu-20031117/gdb-pre-2.6/linux-nat.h	2003-09-13 19:04:44.000000000 -0700
+++ gdb+dejagnu-20031117/gdb/linux-nat.h	2004-02-27 08:24:40.677221000 -0800
@@ -67,7 +67,7 @@
 				   struct target_ops *target);
 
 /* Find process PID's pending signal set from /proc/pid/status.  */
-void linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored);
+void linux_proc_pending_signals (ptid_t ptid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored);
 
 /* linux-nat functions for handling fork events.  */
 extern void linux_record_stopped_pid (int pid);
diff -Naur gdb+dejagnu-20031117/gdb-pre-2.6/linux-proc.c gdb+dejagnu-20031117/gdb/linux-proc.c
--- gdb+dejagnu-20031117/gdb-pre-2.6/linux-proc.c	2003-10-01 13:36:56.000000000 -0700
+++ gdb+dejagnu-20031117/gdb/linux-proc.c	2004-02-27 08:33:45.348508000 -0800
@@ -689,19 +689,28 @@
    to match.  */
 
 void
-linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored)
+linux_proc_pending_signals (ptid_t ptid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored)
 {
   FILE *procfile;
   char buffer[MAXPATHLEN], fname[MAXPATHLEN];
-  int signum;
+  int signum, pid;
+  long lwp;
+
+  pid = ptid_get_pid (ptid);
+  lwp = ptid_get_lwp (ptid);
 
   sigemptyset (pending);
   sigemptyset (blocked);
   sigemptyset (ignored);
-  sprintf (fname, "/proc/%d/status", pid);
+  sprintf (fname, "/proc/%d/task/%ld/status", pid, lwp);
   procfile = fopen (fname, "r");
   if (procfile == NULL)
-    error ("Could not open %s", fname);
+    {
+      sprintf (fname, "/proc/%ld/status", lwp);
+      procfile = fopen (fname, "r");
+      if (procfile == NULL)
+	error ("Could not get status for task %ld", lwp);
+    }
 
   while (fgets (buffer, MAXPATHLEN, procfile) != NULL)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]