aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-08-26 18:58:04 +0000
committerPedro Alves <palves@redhat.com>2011-08-26 18:58:04 +0000
commite5798bef38435b582d9fc1c51efbf36b2b7fbe20 (patch)
tree82b51d91a77c81a21e766912d8076e06b1516cb2 /gdb
parentedb2aadf8b9b8b968917fad4727f039f0e10f7fb (diff)
downloadgdb-e5798bef38435b582d9fc1c51efbf36b2b7fbe20.zip
gdb-e5798bef38435b582d9fc1c51efbf36b2b7fbe20.tar.gz
gdb-e5798bef38435b582d9fc1c51efbf36b2b7fbe20.tar.bz2
2011-08-26 Pedro Alves <pedro@codesourcery.com>
gdb/ * common/linux-osdata.c (get_cores_used_by_process): Don't assume opening /proc/PID/task always succeeds.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/common/linux-osdata.c32
2 files changed, 22 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5179af7..140b3c6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-26 Pedro Alves <pedro@codesourcery.com>
+
+ * common/linux-osdata.c (get_cores_used_by_process): Don't assume
+ opening /proc/PID/task always succeeds.
+
2011-08-26 Aleksandar Ristovski <aristovski@qnx.com>
* linespec.c (symtab_from_filename): Check for the end of string.
diff --git a/gdb/common/linux-osdata.c b/gdb/common/linux-osdata.c
index 78659d4..a356bb8 100644
--- a/gdb/common/linux-osdata.c
+++ b/gdb/common/linux-osdata.c
@@ -259,27 +259,29 @@ get_cores_used_by_process (pid_t pid, int *cores)
sprintf (taskdir, "/proc/%d/task", pid);
dir = opendir (taskdir);
-
- while ((dp = readdir (dir)) != NULL)
+ if (dir)
{
- pid_t tid;
- int core;
+ while ((dp = readdir (dir)) != NULL)
+ {
+ pid_t tid;
+ int core;
- if (!isdigit (dp->d_name[0])
- || NAMELEN (dp) > sizeof ("4294967295") - 1)
- continue;
+ if (!isdigit (dp->d_name[0])
+ || NAMELEN (dp) > sizeof ("4294967295") - 1)
+ continue;
- tid = atoi (dp->d_name);
- core = linux_common_core_of_thread (ptid_build (pid, tid, 0));
+ tid = atoi (dp->d_name);
+ core = linux_common_core_of_thread (ptid_build (pid, tid, 0));
- if (core >= 0)
- {
- ++cores[core];
- ++task_count;
+ if (core >= 0)
+ {
+ ++cores[core];
+ ++task_count;
+ }
}
- }
- closedir (dir);
+ closedir (dir);
+ }
return task_count;
}