summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2009-04-30 18:35:55 +0000
committerDoug Evans <dje@google.com>2009-04-30 18:35:55 +0000
commit5091eb23aa99df6443dc559d2da403ba7a24c406 (patch)
tree8c1a8e6b588ce9b02f7b13f7e841976a9866fb3a
parentdc621c3587c3f7d6e628812c86dd63c49a34ac72 (diff)
downloadbinutils-gdb-5091eb23aa99df6443dc559d2da403ba7a24c406.tar.gz
* inferiors.c (remove_process): Fix memory leak, free process.
* linux-low.c (linux_remove_process): New function. (linux_kill): Call it instead of remove_process. (linux_detach, linux_wait_1): Ditto.
-rw-r--r--gdb/gdbserver/ChangeLog7
-rw-r--r--gdb/gdbserver/inferiors.c5
-rw-r--r--gdb/gdbserver/linux-low.c16
3 files changed, 25 insertions, 3 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 8d4e2f288e3..a731bfff2e5 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-30 Doug Evans <dje@google.com>
+
+ * inferiors.c (remove_process): Fix memory leak, free process.
+ * linux-low.c (linux_remove_process): New function.
+ (linux_kill): Call it instead of remove_process.
+ (linux_detach, linux_wait_1): Ditto.
+
2009-04-19 Danny Backx <dannybackx@users.sourceforge.net>
* configure.srv: Add x86 Windows CE target.
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index f96438ef536..8d44d0160a2 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -427,12 +427,17 @@ add_process (int pid, int attached)
return process;
}
+/* Remove a process from the common process list and free the memory
+ allocated for it.
+ The caller is responsible for freeing private data first. */
+
void
remove_process (struct process_info *process)
{
clear_symbol_cache (&process->symbol_cache);
free_all_breakpoints (process);
remove_inferior (&all_processes, &process->head);
+ free (process);
}
struct process_info *
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index cb6b1b47df0..a6bad392c09 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -182,6 +182,16 @@ linux_add_process (int pid, int attached)
return proc;
}
+/* Remove a process from the common process list,
+ also freeing all private data. */
+
+static void
+linux_remove_process (struct process_info *process)
+{
+ free (process->private);
+ remove_process (process);
+}
+
/* Handle a GNU/Linux extended wait response. If we see a clone
event, we need to add the new LWP to our list (and not report the
trap to higher layers). */
@@ -565,7 +575,7 @@ linux_kill (int pid)
} while (lwpid > 0 && WIFSTOPPED (wstat));
delete_lwp (lwp);
- remove_process (process);
+ linux_remove_process (process);
return 0;
}
@@ -654,7 +664,7 @@ linux_detach (int pid)
delete_all_breakpoints ();
find_inferior (&all_threads, linux_detach_one_lwp, &pid);
- remove_process (process);
+ linux_remove_process (process);
return 0;
}
@@ -1273,7 +1283,7 @@ retry:
struct process_info *process = find_process_pid (pid);
delete_lwp (lwp);
- remove_process (process);
+ linux_remove_process (process);
current_inferior = NULL;