This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH][PR threads/15824] when get threads name failed from info threads with linux kernel version earlier than 2.6.33
- From: Yao Qi <yao at codesourcery dot com>
- To: Will Huang <will dot huang at aliyun-inc dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 16 Aug 2013 19:28:59 +0800
- Subject: Re: [PATCH][PR threads/15824] when get threads name failed from info threads with linux kernel version earlier than 2.6.33
- References: <00b201ce98a6$7cf69150$76e3b3f0$ at huang@aliyun-inc.com> <520D8D9A dot 3050003 at codesourcery dot com> <016701ce9a41$f39086d0$dab19470$ at huang@aliyun-inc.com> <520DF2E2 dot 3020407 at codesourcery dot com> <01a201ce9a6a$74436db0$5cca4910$ at huang@aliyun-inc.com>
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 (éå)