This is the mail archive of the gdb-patches@sourceware.org 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: [PATCH][PR threads/15824] when get threads name failed from info threads with linux kernel version earlier than 2.6.33


On 08/16/2013 06:22 PM, Will Huang wrote:
   Sorry for mistakes. There is no gdb_fopen_cloexec in gdb-7.6.  Except that all comments are accepted.


Are you proposing a patch for GDB 7.6 tree only?  This problem exists
on mainline too. We post patch for mainline, and backport the patch to internal tree or older tree.

+
+static int
+linux_proc_get_string (pid_t lwpid, pid_t tid, char *target,
+                       size_t t_size, const char *field)
+{
+  size_t field_len = strlen (field);
+  FILE *status_file;
+  char buf[100];
+  int retval = -1;
+
+  if (tid > 0)
+    xsnprintf (buf, sizeof (buf), "/proc/%d/task/%d/status",
+               (int) lwpid, (int) tid);
+  else
+  {
+     /*if TID is zero, ingnore it*/

/* If TID is zero, ignore it.  */

+     xsnprintf (buf, sizeof (buf), "/proc/%d/status", (int) lwpid);
+  }
+
+  status_file = fopen (buf, "r");
+  if (status_file == NULL)
+    {
+      warning (_("unable to open /proc file '%s'"), buf);
+      return -1;
+    }
+
+  while (fgets (buf, sizeof (buf), status_file))
+    if (strncmp (buf, field, field_len) == 0 && buf[field_len] == ':')
+      {
+       size_t pos = field_len + 1;

Blank line is needed here.

diff -ruN ./gdb.org/linux-nat.c ./gdb/linux-nat.c
--- ./gdb.org/linux-nat.c       2013-02-13 22:59:49.000000000 +0800
+++ ./gdb/linux-nat.c   2013-08-16 17:55:19.000000000 +0800
@@ -4294,6 +4294,15 @@

        fclose (comm_file);
      }
+  else
+    {
+      static char comm[COMM_LEN + 1];
+      int size = linux_proc_get_thread_name ((pid_t) pid, (pid_t) lwp, comm, COMM_LEN + 1);

This line is too long.

Otherwise, I don't have comments to this patch.

--
Yao (éå)


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