+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
/* 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);
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. */
/* 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. */
+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".
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 */
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)
{
NULL, /* siginfo_fixup */
arm_new_process,
arm_new_thread,
+ arm_delete_thread,
arm_new_fork,
arm_prepare_to_resume,
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
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);
}
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);
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
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
NULL, /* siginfo_fixup */
mips_linux_new_process,
mips_linux_new_thread,
+ mips_linux_delete_thread,
mips_linux_new_fork,
mips_linux_prepare_to_resume
};
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
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,
NULL, /* siginfo_fixup */
NULL, /* new_process */
NULL, /* new_thread */
+ NULL, /* delete_thread */
NULL, /* new_fork */
NULL, /* prepare_to_resume */
NULL, /* process_qsupported */
/* 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;
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);
}
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
/* 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,
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. */
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);
/* 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)
{
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);
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
/* 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);
{
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);