linux low: Make the arch code free arch_process_info
authorSimon Marchi <simon.marchi@ericsson.com>
Thu, 12 Oct 2017 20:49:27 +0000 (16:49 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 12 Oct 2017 20:49:27 +0000 (16:49 -0400)
For the same reason as the previous patch, we need to make the
arch-specific code free the arch_process_info structure it allocates.

gdb/gdbserver/ChangeLog:

* linux-low.h (struct linux_target_ops) <delete_process>: New
field.
* linux-low.c (linux_mourn): Call the_low_target.delete_process.
* linux-aarch64-low.c (aarch64_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-arm-low.c (arm_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-bfin-low.c (struct linux_target_ops): Likewise.
* linux-crisv32-low.c (struct linux_target_ops): Likewise.
* linux-m32r-low.c (struct linux_target_ops): Likewise.
* linux-mips-low.c (mips_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-ppc-low.c (struct linux_target_ops): Likewise.
* linux-s390-low.c (struct linux_target_ops): Likewise.
* linux-sh-low.c (struct linux_target_ops): Likewise.
* linux-tic6x-low.c (struct linux_target_ops): Likewise.
* linux-tile-low.c (struct linux_target_ops): Likewise.
* linux-x86-low.c (x86_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-xtensa-low.c (struct linux_target_ops): Likewise.

16 files changed:
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-aarch64-low.c
gdb/gdbserver/linux-arm-low.c
gdb/gdbserver/linux-bfin-low.c
gdb/gdbserver/linux-crisv32-low.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/linux-low.h
gdb/gdbserver/linux-m32r-low.c
gdb/gdbserver/linux-mips-low.c
gdb/gdbserver/linux-ppc-low.c
gdb/gdbserver/linux-s390-low.c
gdb/gdbserver/linux-sh-low.c
gdb/gdbserver/linux-tic6x-low.c
gdb/gdbserver/linux-tile-low.c
gdb/gdbserver/linux-x86-low.c
gdb/gdbserver/linux-xtensa-low.c

index 1edb8495fd5928f1314bc7c9109eb65ef2751b0b..3902e91b64a6852d38aa4a96d3cda8c7cfda5980 100644 (file)
@@ -1,3 +1,26 @@
+2017-10-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * linux-low.h (struct linux_target_ops) <delete_process>: New
+       field.
+       * linux-low.c (linux_mourn): Call the_low_target.delete_process.
+       * linux-aarch64-low.c (aarch64_linux_delete_process): New.
+       (struct linux_target_ops): Add delete_process callback.
+       * linux-arm-low.c (arm_delete_process): New.
+       (struct linux_target_ops): Add delete_process callback.
+       * linux-bfin-low.c (struct linux_target_ops): Likewise.
+       * linux-crisv32-low.c (struct linux_target_ops): Likewise.
+       * linux-m32r-low.c (struct linux_target_ops): Likewise.
+       * linux-mips-low.c (mips_linux_delete_process): New.
+       (struct linux_target_ops): Add delete_process callback.
+       * linux-ppc-low.c (struct linux_target_ops): Likewise.
+       * linux-s390-low.c (struct linux_target_ops): Likewise.
+       * linux-sh-low.c (struct linux_target_ops): Likewise.
+       * linux-tic6x-low.c (struct linux_target_ops): Likewise.
+       * linux-tile-low.c (struct linux_target_ops): Likewise.
+       * linux-x86-low.c (x86_linux_delete_process): New.
+       (struct linux_target_ops): Add delete_process callback.
+       * linux-xtensa-low.c (struct linux_target_ops): Likewise.
+
 2017-10-12  Simon Marchi  <simon.marchi@ericsson.com>
 
        * linux-aarch64-low.c (the_low_target): Add thread delete
index ed6a9931d2e24948abe6a0cb8004623eaab82e4b..6d5c4e54235de92b0c2beb60d13ee1a200d84c45 100644 (file)
@@ -429,7 +429,7 @@ aarch64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
   return 0;
 }
 
-/* Implementation of linux_target_ops method "linux_new_process".  */
+/* Implementation of linux_target_ops method "new_process".  */
 
 static struct arch_process_info *
 aarch64_linux_new_process (void)
@@ -441,6 +441,14 @@ aarch64_linux_new_process (void)
   return info;
 }
 
+/* Implementation of linux_target_ops method "delete_process".  */
+
+static void
+aarch64_linux_delete_process (struct arch_process_info *info)
+{
+  xfree (info);
+}
+
 /* Implementation of linux_target_ops method "linux_new_fork".  */
 
 static void
@@ -2990,6 +2998,7 @@ struct linux_target_ops the_low_target =
   NULL, /* supply_ptrace_register */
   aarch64_linux_siginfo_fixup,
   aarch64_linux_new_process,
+  aarch64_linux_delete_process,
   aarch64_linux_new_thread,
   aarch64_linux_delete_thread,
   aarch64_linux_new_fork,
index b27c47e84c4ffe15a4ebba517f78688baca2e4ec..e12e3d2c0305fe4f72b5e1a031f8cde296d77662 100644 (file)
@@ -640,6 +640,14 @@ arm_new_process (void)
   return info;
 }
 
+/* Called when a process is being deleted.  */
+
+static void
+arm_delete_process (struct arch_process_info *info)
+{
+  xfree (info);
+}
+
 /* Called when a new thread is detected.  */
 static void
 arm_new_thread (struct lwp_info *lwp)
@@ -1060,6 +1068,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   arm_new_process,
+  arm_delete_process,
   arm_new_thread,
   arm_delete_thread,
   arm_new_fork,
index 175152c4598cf69258a1b13fcae4ec55b44761f0..72419469083fb872d7c9c3e175a4e0a54be823c0 100644 (file)
@@ -135,6 +135,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index 79111048faeab75aa5c05b802540df166753f7c2..d6081d48e7b40059fda51e23e734ca88110cb809 100644 (file)
@@ -415,6 +415,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index a762b8f0818c09ffa79e51b8fcae57f5857abff9..f32c629f8d650ad2b064f01eb4f62b8cd0025999 100644 (file)
@@ -1687,7 +1687,10 @@ linux_mourn (struct process_info *process)
 
   /* Freeing all private data.  */
   priv = process->priv;
-  free (priv->arch_private);
+  if (the_low_target.delete_process != NULL)
+    the_low_target.delete_process (priv->arch_private);
+  else
+    gdb_assert (priv->arch_private == NULL);
   free (priv);
   process->priv = NULL;
 
index 9c69dece96d5515b002c4907da01b94f0ea52324..eda452fc585748847c8405e3acc6abdaa8996661 100644 (file)
@@ -189,6 +189,10 @@ struct linux_target_ops
      allocate it here.  */
   struct arch_process_info * (*new_process) (void);
 
+  /* Hook to call when a process is being deleted.  If extra per-process
+     architecture-specific data is needed, delete it here.  */
+  void (*delete_process) (struct arch_process_info *info);
+
   /* Hook to call when a new thread is detected.
      If extra per-thread architecture-specific data is needed,
      allocate it here.  */
index b947fa065857d811c1519a2ba438c86a84f96a56..af42ab427d14affb05869c248c513993dfcea73e 100644 (file)
@@ -134,6 +134,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index ec26c2a8c56c91bf8f96636cf790225406193cd3..b30fbba3d798d637798b50121ef7e031140eb1ec 100644 (file)
@@ -327,6 +327,15 @@ mips_linux_new_process (void)
   return info;
 }
 
+/* This is the implementation of linux_target_ops method
+   delete_process.  */
+
+static void
+mips_linux_delete_process (struct arch_process_info *info)
+{
+  xfree (info);
+}
+
 /* This is the implementation of linux_target_ops method new_thread.
    Mark the watch registers as changed, so the threads' copies will
    be updated.  */
@@ -900,6 +909,7 @@ struct linux_target_ops the_low_target = {
   NULL,
   NULL, /* siginfo_fixup */
   mips_linux_new_process,
+  mips_linux_delete_process,
   mips_linux_new_thread,
   mips_linux_delete_thread,
   mips_linux_new_fork,
index f31a47b5f198d48f394019c7d8fc6959ab757e31..a2c6cc4b94d4eb22c8c62a7582a5d29343b074d4 100644 (file)
@@ -3124,6 +3124,7 @@ struct linux_target_ops the_low_target = {
   ppc_supply_ptrace_register,
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index 1a4c3407fbc0f989202ecc733d345b3f556863a2..0cf75acae1d646e5e4e44e3bef3e80bd1ab568b2 100644 (file)
@@ -2829,6 +2829,7 @@ struct linux_target_ops the_low_target = {
   s390_supply_ptrace_register,
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index 273062faa08a3363cb67e86cacb76f03b41ba550..3c612b39e08d0ebe7f7a87a4ad1bdcd254d341e8 100644 (file)
@@ -164,6 +164,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index 8b2a6f35ca8ea85200bd5dec407aa357b8798c98..7a32f7e01282041c874f4cf7f93d113b3e9c405c 100644 (file)
@@ -397,6 +397,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index c5b344bd631df8091ecd3e97d7d75bc46caeaf89..0069748c0aca9d567d9a6de9ebc61af0a824d557 100644 (file)
@@ -196,6 +196,7 @@ struct linux_target_ops the_low_target =
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */
index 9597502dfcade503f5cfcae11082bbe84cebaa8a..153858c5f578d39ac2624a86388402bfc7c2be1e 100644 (file)
@@ -617,6 +617,14 @@ x86_linux_new_process (void)
   return info;
 }
 
+/* Called when a process is being deleted.  */
+
+static void
+x86_linux_delete_process (struct arch_process_info *info)
+{
+  xfree (info);
+}
+
 /* Target routine for linux_new_fork.  */
 
 static void
@@ -2866,6 +2874,7 @@ struct linux_target_ops the_low_target =
   /* need to fix up i386 siginfo if host is amd64 */
   x86_siginfo_fixup,
   x86_linux_new_process,
+  x86_linux_delete_process,
   x86_linux_new_thread,
   x86_linux_delete_thread,
   x86_linux_new_fork,
index 5f2566cc0b0c81bb39cc17354fd54feb12167f61..beda11634363f48d8c84c9171b8d8b6d66614104 100644 (file)
@@ -288,6 +288,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* supply_ptrace_register */
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
+  NULL, /* delete_process */
   NULL, /* new_thread */
   NULL, /* delete_thread */
   NULL, /* new_fork */