aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2010-05-14 23:41:05 +0000
committerMichael Snyder <msnyder@vmware.com>2010-05-14 23:41:05 +0000
commite0881a8e0fbb8bd5d4d14683390269b97e4e90d7 (patch)
tree60fe317865c5f6a2e987df4e590cf170bee3360f /gdb/linux-nat.c
parentabbb1732a91accadee3e1c00b75fc0a3f418fae7 (diff)
downloadgdb-e0881a8e0fbb8bd5d4d14683390269b97e4e90d7.zip
gdb-e0881a8e0fbb8bd5d4d14683390269b97e4e90d7.tar.gz
gdb-e0881a8e0fbb8bd5d4d14683390269b97e4e90d7.tar.bz2
2010-05-14 Michael Snyder <msnyder@vmware.com>
* jv-lang.c: White space. * jv-typeprint.c: White space. * jv-valprint.c: White space. * language.c: White space. * libunwind-frame.c: White space. * linespec.c: White space. * linux-nat.c: White space. * linux-record.c: White space. * linux-thread-db.c: White space.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c127
1 files changed, 70 insertions, 57 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2c791dc..8180248 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -368,6 +368,7 @@ static void
add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
{
struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+
new_pid->pid = pid;
new_pid->status = status;
new_pid->next = *listp;
@@ -383,6 +384,7 @@ pull_pid_from_list (struct simple_pid_list **listp, int pid, int *status)
if ((*p)->pid == pid)
{
struct simple_pid_list *next = (*p)->next;
+
*status = (*p)->status;
xfree (*p);
*p = next;
@@ -1646,6 +1648,7 @@ get_pending_status (struct lwp_info *lp, int *status)
else if (non_stop && !is_executing (lp->ptid))
{
struct thread_info *tp = find_thread_ptid (lp->ptid);
+
signo = tp->stop_signal;
}
else if (!non_stop)
@@ -1658,6 +1661,7 @@ get_pending_status (struct lwp_info *lp, int *status)
if (GET_LWP (lp->ptid) == GET_LWP (last_ptid))
{
struct thread_info *tp = find_thread_ptid (lp->ptid);
+
signo = tp->stop_signal;
}
}
@@ -3802,6 +3806,7 @@ linux_nat_kill (struct target_ops *ops)
else
{
ptid_t ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+
/* Stop all threads before killing them, since ptrace requires
that the thread is stopped to sucessfully PTRACE_KILL. */
iterate_over_lwps (ptid, stop_callback, NULL);
@@ -4340,6 +4345,7 @@ static char *
linux_spu_make_corefile_notes (bfd *obfd, char *note_data, int *note_size)
{
struct linux_spu_corefile_data args;
+
args.obfd = obfd;
args.note_data = note_data;
args.note_size = note_size;
@@ -4496,6 +4502,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty)
if ((procfile = fopen (fname1, "r")) != NULL)
{
struct cleanup *cleanup = make_cleanup_fclose (procfile);
+
if (fgets (buffer, sizeof (buffer), procfile))
printf_filtered ("cmdline = '%s'\n", buffer);
else
@@ -4591,6 +4598,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty)
if ((procfile = fopen (fname1, "r")) != NULL)
{
struct cleanup *cleanup = make_cleanup_fclose (procfile);
+
while (fgets (buffer, sizeof (buffer), procfile) != NULL)
puts_filtered (buffer);
do_cleanups (cleanup);
@@ -4921,8 +4929,8 @@ linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigse
static LONGEST
linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
- const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
/* We make the process list snapshot when the object starts to be
read. */
@@ -4942,7 +4950,7 @@ linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
if (offset == 0)
{
if (len_avail != -1 && len_avail != 0)
- obstack_free (&obstack, NULL);
+ obstack_free (&obstack, NULL);
len_avail = 0;
buf = NULL;
obstack_init (&obstack);
@@ -4950,60 +4958,63 @@ linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object,
dirp = opendir ("/proc");
if (dirp)
- {
- struct dirent *dp;
- while ((dp = readdir (dirp)) != NULL)
- {
- struct stat statbuf;
- char procentry[sizeof ("/proc/4294967295")];
-
- if (!isdigit (dp->d_name[0])
- || NAMELEN (dp) > sizeof ("4294967295") - 1)
- continue;
-
- sprintf (procentry, "/proc/%s", dp->d_name);
- if (stat (procentry, &statbuf) == 0
- && S_ISDIR (statbuf.st_mode))
- {
- char *pathname;
- FILE *f;
- char cmd[MAXPATHLEN + 1];
- struct passwd *entry;
-
- pathname = xstrprintf ("/proc/%s/cmdline", dp->d_name);
- entry = getpwuid (statbuf.st_uid);
-
- if ((f = fopen (pathname, "r")) != NULL)
- {
- size_t len = fread (cmd, 1, sizeof (cmd) - 1, f);
- if (len > 0)
- {
- int i;
- for (i = 0; i < len; i++)
- if (cmd[i] == '\0')
- cmd[i] = ' ';
- cmd[len] = '\0';
-
- obstack_xml_printf (
- &obstack,
- "<item>"
- "<column name=\"pid\">%s</column>"
- "<column name=\"user\">%s</column>"
- "<column name=\"command\">%s</column>"
- "</item>",
- dp->d_name,
- entry ? entry->pw_name : "?",
- cmd);
- }
- fclose (f);
- }
-
- xfree (pathname);
- }
- }
-
- closedir (dirp);
- }
+ {
+ struct dirent *dp;
+
+ while ((dp = readdir (dirp)) != NULL)
+ {
+ struct stat statbuf;
+ char procentry[sizeof ("/proc/4294967295")];
+
+ if (!isdigit (dp->d_name[0])
+ || NAMELEN (dp) > sizeof ("4294967295") - 1)
+ continue;
+
+ sprintf (procentry, "/proc/%s", dp->d_name);
+ if (stat (procentry, &statbuf) == 0
+ && S_ISDIR (statbuf.st_mode))
+ {
+ char *pathname;
+ FILE *f;
+ char cmd[MAXPATHLEN + 1];
+ struct passwd *entry;
+
+ pathname = xstrprintf ("/proc/%s/cmdline", dp->d_name);
+ entry = getpwuid (statbuf.st_uid);
+
+ if ((f = fopen (pathname, "r")) != NULL)
+ {
+ size_t len = fread (cmd, 1, sizeof (cmd) - 1, f);
+
+ if (len > 0)
+ {
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (cmd[i] == '\0')
+ cmd[i] = ' ';
+ cmd[len] = '\0';
+
+ obstack_xml_printf (
+ &obstack,
+ "<item>"
+ "<column name=\"pid\">%s</column>"
+ "<column name=\"user\">%s</column>"
+ "<column name=\"command\">%s</column>"
+ "</item>",
+ dp->d_name,
+ entry ? entry->pw_name : "?",
+ cmd);
+ }
+ fclose (f);
+ }
+
+ xfree (pathname);
+ }
+ }
+
+ closedir (dirp);
+ }
obstack_grow_str0 (&obstack, "</osdata>\n");
buf = obstack_finish (&obstack);
@@ -5478,6 +5489,7 @@ linux_nat_core_of_thread_1 (ptid_t ptid)
for (;;)
{
int n;
+
content = xrealloc (content, content_read + 1024);
n = fread (content + content_read, 1, 1024, f);
content_read += n;
@@ -5513,6 +5525,7 @@ int
linux_nat_core_of_thread (struct target_ops *ops, ptid_t ptid)
{
struct lwp_info *info = find_lwp_pid (ptid);
+
if (info)
return info->core;
return -1;