This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] lwp_info: Make the arch code free arch_lwp_info


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=466eeceef409597388dd2b4e8b907cf080bedcf1

commit 466eeceef409597388dd2b4e8b907cf080bedcf1
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Thu Oct 12 16:48:22 2017 -0400

    lwp_info: Make the arch code free arch_lwp_info
    
    I have the goal of "poisoning" the XNEW/xfree-family of functions, so
    that we catch their usages with non-POD types.  A few things need to be
    fixed in the mean time, this is one.
    
    The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
    private lwp data of type arch_lwp_info.  However, that type is opaque
    from its point of view, as its defined differently in each arch-specific
    implementation.  This trips on the std::is_pod<T> check, since the
    compiler can't tell whether the type is POD or not if it doesn't know
    about it.
    
    My initial patch [1] made a class hierarchy with a virtual destructor.
    However, as Pedro pointed out, we only have one native architecture at
    the time built in gdb and gdbserver, so that's overkill.  Instead, we
    can move the responsibility of free'ing arch_lwp_info to the arch code
    (which is also the one that allocated it in the first place).  This is
    what this patch does.
    
    Also, I had the concern that if we wanted to use C++ features in these
    structures, we would have a problem with the one-definition rule.
    However, since a build will only have one version of arch_lwp_info,
    that's not a problem.
    
    There are changes in arch-specific files, I was only able to built-test
    this patch with the following cross-compilers:
    
      aarch64-linux-gnu
      alpha-linux-gnu
      arm-linux-gnueabihf
      hppa-linux-gnu
      m68k-linux-gnu
      mips64el-linux-gnuabi64
      powerpc64-linux-gnu
      s390x-linux-gnu
      sh4-linux-gnu
      sparc64-linux-gnu
      x86_64-linux-gnu
      x86_64-w64-mingw32
    
    A buildbot run didn't find any regression.
    
    [1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html
    
    gdb/ChangeLog:
    
    	* linux-nat.h (linux_nat_set_delete_thread): New declaration.
    	* linux-nat.c (linux_nat_delete_thread): New variable.
    	(lwp_free): Invoke linux_nat_delete_thread if set.
    	(linux_nat_set_delete_thread): New function.
    	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
    	thread delete callback.
    	* arm-linux-nat.c (arm_linux_delete_thread): New function.
    	(_initialize_arm_linux_nat): Assign thread delete callback.
    	* s390-linux-nat.c (s390_delete_thread): New function.
    	(_initialize_s390_nat): Assign thread delete callback.
    	* x86-linux-nat.c (x86_linux_add_target): Likewise.
    	* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
    	function.
    	* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
    	declaration.
    	* nat/x86-linux.c (x86_linux_delete_thread): New function.
    	* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
    
    gdb/gdbserver/ChangeLog:
    
    	* linux-aarch64-low.c (the_low_target): Add thread delete
    	callback.
    	* linux-arm-low.c (arm_delete_thread): New function.
    	(the_low_target): Add thread delete callback.
    	* linux-bfin-low.c (the_low_target): Likewise.
    	* linux-crisv32-low.c (the_low_target): Likewise.
    	* linux-low.c (delete_lwp): Invoke delete_thread callback if
    	set.
    	* linux-low.h (struct linux_target_ops) <delete_thread>: New
    	field.
    	* linux-m32r-low.c (the_low_target): Add thread delete callback.
    	* linux-mips-low.c (mips_linux_delete_thread): New function.
    	(the_low_target): Add thread delete callback.
    	* linux-ppc-low.c (the_low_target): Likewise.
    	* linux-s390-low.c (the_low_target): Likewise.
    	* linux-sh-low.c (the_low_target): Likewise.
    	* linux-tic6x-low.c (the_low_target): Likewise.
    	* linux-tile-low.c (the_low_target): Likewise.
    	* linux-x86-low.c (the_low_target): Likewise.
    	* linux-xtensa-low.c (the_low_target): Likewise.

Diff:
---
 gdb/ChangeLog                     | 20 ++++++++++++++++++++
 gdb/aarch64-linux-nat.c           |  1 +
 gdb/arm-linux-nat.c               |  9 +++++++++
 gdb/gdbserver/ChangeLog           | 23 +++++++++++++++++++++++
 gdb/gdbserver/linux-aarch64-low.c |  1 +
 gdb/gdbserver/linux-arm-low.c     |  9 +++++++++
 gdb/gdbserver/linux-bfin-low.c    |  1 +
 gdb/gdbserver/linux-crisv32-low.c |  1 +
 gdb/gdbserver/linux-low.c         |  7 ++++++-
 gdb/gdbserver/linux-low.h         |  4 ++++
 gdb/gdbserver/linux-m32r-low.c    |  1 +
 gdb/gdbserver/linux-mips-low.c    |  9 +++++++++
 gdb/gdbserver/linux-ppc-low.c     |  1 +
 gdb/gdbserver/linux-s390-low.c    |  1 +
 gdb/gdbserver/linux-sh-low.c      |  1 +
 gdb/gdbserver/linux-tic6x-low.c   |  1 +
 gdb/gdbserver/linux-tile-low.c    |  1 +
 gdb/gdbserver/linux-x86-low.c     |  1 +
 gdb/gdbserver/linux-xtensa-low.c  |  1 +
 gdb/linux-nat.c                   | 21 ++++++++++++++++++++-
 gdb/linux-nat.h                   |  3 +++
 gdb/nat/aarch64-linux.c           |  8 ++++++++
 gdb/nat/aarch64-linux.h           |  3 +++
 gdb/nat/x86-linux.c               |  8 ++++++++
 gdb/nat/x86-linux.h               |  4 ++++
 gdb/s390-linux-nat.c              |  9 +++++++++
 gdb/x86-linux-nat.c               |  1 +
 27 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 532c2b9..2126c33 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
+2017-10-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* linux-nat.h (linux_nat_set_delete_thread): New declaration.
+	* linux-nat.c (linux_nat_delete_thread): New variable.
+	(lwp_free): Invoke linux_nat_delete_thread if set.
+	(linux_nat_set_delete_thread): New function.
+	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
+	thread delete callback.
+	* arm-linux-nat.c (arm_linux_delete_thread): New function.
+	(_initialize_arm_linux_nat): Assign thread delete callback.
+	* s390-linux-nat.c (s390_delete_thread): New function.
+	(_initialize_s390_nat): Assign thread delete callback.
+	* x86-linux-nat.c (x86_linux_add_target): Likewise.
+	* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
+	function.
+	* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
+	declaration.
+	* nat/x86-linux.c (x86_linux_delete_thread): New function.
+	* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
+
 2017-10-09  Tom Tromey  <tom@tromey.com>
 
 	* tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 6ad6f66..4feaec3 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -837,6 +837,7 @@ _initialize_aarch64_linux_nat (void)
   /* Register the target.  */
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, aarch64_linux_new_thread);
+  linux_nat_set_delete_thread (t, aarch64_linux_delete_thread);
   linux_nat_set_new_fork (t, aarch64_linux_new_fork);
   linux_nat_set_forget_process (t, aarch64_forget_process);
   linux_nat_set_prepare_to_resume (t, aarch64_linux_prepare_to_resume);
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index fc66063..8b25ff7 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -1202,6 +1202,14 @@ arm_linux_new_thread (struct lwp_info *lp)
   lp->arch_private = info;
 }
 
+/* Function to call when a thread is being deleted.  */
+
+static void
+arm_linux_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
 /* Called when resuming a thread.
    The hardware debug registers are updated when there is any change.  */
 
@@ -1313,6 +1321,7 @@ _initialize_arm_linux_nat (void)
 
   /* Handle thread creation and exit.  */
   linux_nat_set_new_thread (t, arm_linux_new_thread);
+  linux_nat_set_delete_thread (t, arm_linux_delete_thread);
   linux_nat_set_prepare_to_resume (t, arm_linux_prepare_to_resume);
 
   /* Handle process creation and exit.  */
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 5bcd717..1edb849 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,26 @@
+2017-10-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* linux-aarch64-low.c (the_low_target): Add thread delete
+	callback.
+	* linux-arm-low.c (arm_delete_thread): New function.
+	(the_low_target): Add thread delete callback.
+	* linux-bfin-low.c (the_low_target): Likewise.
+	* linux-crisv32-low.c (the_low_target): Likewise.
+	* linux-low.c (delete_lwp): Invoke delete_thread callback if
+	set.
+	* linux-low.h (struct linux_target_ops) <delete_thread>: New
+	field.
+	* linux-m32r-low.c (the_low_target): Add thread delete callback.
+	* linux-mips-low.c (mips_linux_delete_thread): New function.
+	(the_low_target): Add thread delete callback.
+	* linux-ppc-low.c (the_low_target): Likewise.
+	* linux-s390-low.c (the_low_target): Likewise.
+	* linux-sh-low.c (the_low_target): Likewise.
+	* linux-tic6x-low.c (the_low_target): Likewise.
+	* linux-tile-low.c (the_low_target): Likewise.
+	* linux-x86-low.c (the_low_target): Likewise.
+	* linux-xtensa-low.c (the_low_target): Likewise.
+
 2017-10-06  Yuanhui Zhang  <asmwarrior@gmail.com>
 
 	* win32-low.c: Include "common-inferior.h".
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 334310b..ed6a993 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -2991,6 +2991,7 @@ struct linux_target_ops the_low_target =
   aarch64_linux_siginfo_fixup,
   aarch64_linux_new_process,
   aarch64_linux_new_thread,
+  aarch64_linux_delete_thread,
   aarch64_linux_new_fork,
   aarch64_linux_prepare_to_resume,
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 5a3f465..b27c47e 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -655,6 +655,14 @@ arm_new_thread (struct lwp_info *lwp)
   lwp->arch_private = info;
 }
 
+/* Function to call when a thread is being deleted.  */
+
+static void
+arm_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
 static void
 arm_new_fork (struct process_info *parent, struct process_info *child)
 {
@@ -1053,6 +1061,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   arm_new_process,
   arm_new_thread,
+  arm_delete_thread,
   arm_new_fork,
   arm_prepare_to_resume,
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-bfin-low.c b/gdb/gdbserver/linux-bfin-low.c
index d43b05d..175152c 100644
--- a/gdb/gdbserver/linux-bfin-low.c
+++ b/gdb/gdbserver/linux-bfin-low.c
@@ -136,6 +136,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c
index 5b3888e..7911104 100644
--- a/gdb/gdbserver/linux-crisv32-low.c
+++ b/gdb/gdbserver/linux-crisv32-low.c
@@ -416,6 +416,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 54005c1..a762b8f 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -414,7 +414,12 @@ delete_lwp (struct lwp_info *lwp)
     debug_printf ("deleting %ld\n", lwpid_of (thr));
 
   remove_thread (thr);
-  free (lwp->arch_private);
+
+  if (the_low_target.delete_thread != NULL)
+    the_low_target.delete_thread (lwp->arch_private);
+  else
+    gdb_assert (lwp->arch_private == NULL);
+
   free (lwp);
 }
 
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 0ece7bc..9c69dec 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -194,6 +194,10 @@ struct linux_target_ops
      allocate it here.  */
   void (*new_thread) (struct lwp_info *);
 
+  /* Hook to call when a thread is being deleted.  If extra per-thread
+     architecture-specific data is needed, delete it here.  */
+  void (*delete_thread) (struct arch_lwp_info *);
+
   /* Hook to call, if any, when a new fork is attached.  */
   void (*new_fork) (struct process_info *parent, struct process_info *child);
 
diff --git a/gdb/gdbserver/linux-m32r-low.c b/gdb/gdbserver/linux-m32r-low.c
index b3ee11a..b947fa0 100644
--- a/gdb/gdbserver/linux-m32r-low.c
+++ b/gdb/gdbserver/linux-m32r-low.c
@@ -135,6 +135,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c
index b4a83b0..ec26c2a 100644
--- a/gdb/gdbserver/linux-mips-low.c
+++ b/gdb/gdbserver/linux-mips-low.c
@@ -341,6 +341,14 @@ mips_linux_new_thread (struct lwp_info *lwp)
   lwp->arch_private = info;
 }
 
+/* Function to call when a thread is being deleted.  */
+
+static void
+mips_linux_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
 /* Create a new mips_watchpoint and add it to the list.  */
 
 static void
@@ -893,6 +901,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   mips_linux_new_process,
   mips_linux_new_thread,
+  mips_linux_delete_thread,
   mips_linux_new_fork,
   mips_linux_prepare_to_resume
 };
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index 33a9feb..f31a47b 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -3125,6 +3125,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index d7aa31c..1a4c340 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -2830,6 +2830,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-sh-low.c b/gdb/gdbserver/linux-sh-low.c
index ac084c9..273062f 100644
--- a/gdb/gdbserver/linux-sh-low.c
+++ b/gdb/gdbserver/linux-sh-low.c
@@ -165,6 +165,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-tic6x-low.c b/gdb/gdbserver/linux-tic6x-low.c
index 8931d69..8b2a6f3 100644
--- a/gdb/gdbserver/linux-tic6x-low.c
+++ b/gdb/gdbserver/linux-tic6x-low.c
@@ -398,6 +398,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-tile-low.c b/gdb/gdbserver/linux-tile-low.c
index ee1f196..c5b344b 100644
--- a/gdb/gdbserver/linux-tile-low.c
+++ b/gdb/gdbserver/linux-tile-low.c
@@ -197,6 +197,7 @@ struct linux_target_ops the_low_target =
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 49f6b2d..9597502 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -2867,6 +2867,7 @@ struct linux_target_ops the_low_target =
   x86_siginfo_fixup,
   x86_linux_new_process,
   x86_linux_new_thread,
+  x86_linux_delete_thread,
   x86_linux_new_fork,
   x86_linux_prepare_to_resume,
   x86_linux_process_qsupported,
diff --git a/gdb/gdbserver/linux-xtensa-low.c b/gdb/gdbserver/linux-xtensa-low.c
index 214abdc..5f2566c 100644
--- a/gdb/gdbserver/linux-xtensa-low.c
+++ b/gdb/gdbserver/linux-xtensa-low.c
@@ -289,6 +289,7 @@ struct linux_target_ops the_low_target = {
   NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* new_thread */
+  NULL, /* delete_thread */
   NULL, /* new_fork */
   NULL, /* prepare_to_resume */
   NULL, /* process_qsupported */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 6080415..c89303c 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -197,6 +197,9 @@ static struct target_ops linux_ops_saved;
 /* The method to call, if any, when a new thread is attached.  */
 static void (*linux_nat_new_thread) (struct lwp_info *);
 
+/* The method to call, if any, when a thread is destroyed.  */
+static void (*linux_nat_delete_thread) (struct arch_lwp_info *);
+
 /* The method to call, if any, when a new fork is attached.  */
 static linux_nat_new_fork_ftype *linux_nat_new_fork;
 
@@ -839,7 +842,12 @@ static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
 static void
 lwp_free (struct lwp_info *lp)
 {
-  xfree (lp->arch_private);
+  /* Let the arch specific bits release arch_lwp_info.  */
+  if (linux_nat_delete_thread != NULL)
+    linux_nat_delete_thread (lp->arch_private);
+  else
+    gdb_assert (lp->arch_private == NULL);
+
   xfree (lp);
 }
 
@@ -4873,6 +4881,17 @@ linux_nat_set_new_thread (struct target_ops *t,
   linux_nat_new_thread = new_thread;
 }
 
+/* Register a method to call whenever a new thread is attached.  */
+void
+linux_nat_set_delete_thread (struct target_ops *t,
+			     void (*delete_thread) (struct arch_lwp_info *))
+{
+  /* Save the pointer.  We only support a single registered instance
+     of the GNU/Linux native target, so we do not need to map this to
+     T.  */
+  linux_nat_delete_thread = delete_thread;
+}
+
 /* See declaration in linux-nat.h.  */
 
 void
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 3378bd6..c002679 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -165,6 +165,9 @@ void linux_nat_add_target (struct target_ops *);
 /* Register a method to call whenever a new thread is attached.  */
 void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *));
 
+/* Register a method to call whenever a new thread is deleted.  */
+void linux_nat_set_delete_thread (struct target_ops *,
+				  void (*) (struct arch_lwp_info *));
 
 /* Register a method to call whenever a new fork is attached.  */
 typedef void (linux_nat_new_fork_ftype) (struct lwp_info *parent,
diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c
index 388eee8..d7abee8 100644
--- a/gdb/nat/aarch64-linux.c
+++ b/gdb/nat/aarch64-linux.c
@@ -84,6 +84,14 @@ aarch64_linux_new_thread (struct lwp_info *lwp)
   lwp_set_arch_private_info (lwp, info);
 }
 
+/* See nat/aarch64-linux.h.  */
+
+void
+aarch64_linux_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
 /* Convert native siginfo FROM to the siginfo in the layout of the
    inferior's architecture TO.  */
 
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index 191e1c6..db98df4 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -122,6 +122,9 @@ void aarch64_linux_prepare_to_resume (struct lwp_info *lwp);
 
 void aarch64_linux_new_thread (struct lwp_info *lwp);
 
+/* Function to call when a thread is being deleted.  */
+void aarch64_linux_delete_thread (struct arch_lwp_info *arch_lwp);
+
 ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
 				       lwpid_t lwpid, int idx, void **base,
 				       int is_64bit_p);
diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
index b499e74..fc68106 100644
--- a/gdb/nat/x86-linux.c
+++ b/gdb/nat/x86-linux.c
@@ -68,6 +68,14 @@ x86_linux_new_thread (struct lwp_info *lwp)
 /* See nat/x86-linux.h.  */
 
 void
+x86_linux_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
+/* See nat/x86-linux.h.  */
+
+void
 x86_linux_prepare_to_resume (struct lwp_info *lwp)
 {
   x86_linux_update_debug_registers (lwp);
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index 1b7fee4..493c722 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -39,6 +39,10 @@ extern int lwp_debug_registers_changed (struct lwp_info *lwp);
 
 extern void x86_linux_new_thread (struct lwp_info *lwp);
 
+/* Function to call when a thread is being deleted.  */
+
+extern void x86_linux_delete_thread (struct arch_lwp_info *arch_lwp);
+
 /* Function to call prior to resuming a thread.  */
 
 extern void x86_linux_prepare_to_resume (struct lwp_info *lwp);
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 4d1b8b5..88ae575 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -789,6 +789,14 @@ s390_new_thread (struct lwp_info *lp)
   s390_mark_per_info_changed (lp);
 }
 
+/* Function to call when a thread is being deleted.  */
+
+static void
+s390_delete_thread (struct arch_lwp_info *arch_lwp)
+{
+  xfree (arch_lwp);
+}
+
 /* Iterator callback for s390_refresh_per_info.  */
 
 static int
@@ -1050,6 +1058,7 @@ _initialize_s390_nat (void)
   /* Register the target.  */
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, s390_new_thread);
+  linux_nat_set_delete_thread (t, s390_delete_thread);
   linux_nat_set_prepare_to_resume (t, s390_prepare_to_resume);
   linux_nat_set_forget_process (t, s390_forget_process);
   linux_nat_set_new_fork (t, s390_linux_new_fork);
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 4611527..ce56c2e 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -354,6 +354,7 @@ x86_linux_add_target (struct target_ops *t)
 {
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, x86_linux_new_thread);
+  linux_nat_set_delete_thread (t, x86_linux_delete_thread);
   linux_nat_set_new_fork (t, x86_linux_new_fork);
   linux_nat_set_forget_process (t, x86_forget_process);
   linux_nat_set_prepare_to_resume (t, x86_linux_prepare_to_resume);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]