summaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-03-05 21:07:46 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-03-05 21:07:46 +0000
commit6eea6d8513cb9b44099f5c134fcec16e3b69e601 (patch)
treeaed473f1b85a3294035dfe0125f6c579d44b4942 /gdb/linux-nat.c
parent925e936bfb1aac0ef9167d0e4e77633c476f28ed (diff)
downloadgdb-6eea6d8513cb9b44099f5c134fcec16e3b69e601.tar.gz
gdb/
Code cleanup. * common/linux-osdata.c (linux_common_core_of_thread): New function comment. * linux-nat.c (linux_nat_wait_1): Replace linux_nat_core_of_thread_1 call by linux_common_core_of_thread. (linux_nat_core_of_thread_1): Remove. * linux-nat.h (linux_nat_core_of_thread_1): Remove declaration. * linux-thread-db.c: Include linux-osdata.h. (update_thread_core): Replace linux_nat_core_of_thread_1 call by linux_common_core_of_thread.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c67
1 files changed, 1 insertions, 66 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 553dfdbd614..e3a5e9d973f 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4000,7 +4000,7 @@ retry:
|| ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
lp->core = -1;
else
- lp->core = linux_nat_core_of_thread_1 (lp->ptid);
+ lp->core = linux_common_core_of_thread (lp->ptid);
return lp->ptid;
}
@@ -5189,71 +5189,6 @@ linux_nat_thread_address_space (struct target_ops *t, ptid_t ptid)
return inf->aspace;
}
-int
-linux_nat_core_of_thread_1 (ptid_t ptid)
-{
- struct cleanup *back_to;
- char *filename;
- FILE *f;
- char *content = NULL;
- char *p;
- char *ts = 0;
- int content_read = 0;
- int i;
- int core;
-
- filename = xstrprintf ("/proc/%d/task/%ld/stat",
- GET_PID (ptid), GET_LWP (ptid));
- back_to = make_cleanup (xfree, filename);
-
- f = fopen (filename, "r");
- if (!f)
- {
- do_cleanups (back_to);
- return -1;
- }
-
- make_cleanup_fclose (f);
-
- for (;;)
- {
- int n;
-
- content = xrealloc (content, content_read + 1024);
- n = fread (content + content_read, 1, 1024, f);
- content_read += n;
- if (n < 1024)
- {
- content[content_read] = '\0';
- break;
- }
- }
-
- make_cleanup (xfree, content);
-
- p = strchr (content, '(');
-
- /* Skip ")". */
- if (p != NULL)
- p = strchr (p, ')');
- if (p != NULL)
- p++;
-
- /* If the first field after program name has index 0, then core number is
- the field with index 36. There's no constant for that anywhere. */
- if (p != NULL)
- p = strtok_r (p, " ", &ts);
- for (i = 0; p != NULL && i != 36; ++i)
- p = strtok_r (NULL, " ", &ts);
-
- if (p == NULL || sscanf (p, "%d", &core) == 0)
- core = -1;
-
- do_cleanups (back_to);
-
- return core;
-}
-
/* Return the cached value of the processor core for thread PTID. */
static int