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.
This commit is contained in:
parent
edb2aadf8b
commit
e5798bef38
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
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));
|
||||
|
||||
if (core >= 0)
|
||||
while ((dp = readdir (dir)) != NULL)
|
||||
{
|
||||
++cores[core];
|
||||
++task_count;
|
||||
}
|
||||
}
|
||||
pid_t tid;
|
||||
int core;
|
||||
|
||||
closedir (dir);
|
||||
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));
|
||||
|
||||
if (core >= 0)
|
||||
{
|
||||
++cores[core];
|
||||
++task_count;
|
||||
}
|
||||
}
|
||||
|
||||
closedir (dir);
|
||||
}
|
||||
|
||||
return task_count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user