From 093da43d2adb4497dfec8afbb4eeaf2425668fdd Mon Sep 17 00:00:00 2001 From: Mohamed Bouhaouel Date: Fri, 30 Jun 2023 10:10:15 +0200 Subject: gdb, breakpoint: add a destructor to the watchpoint struct Make sure to unlink the related breakpoint when the watchpoint instance is deleted. This prevents having a wp-related breakpoint that is linked to a NULL watchpoint (e.g. the watchpoint instance is being deleted when the 'watch' command fails). With the below scenario, having such a left out breakpoint will lead to a GDB hang, and this is due to an infinite loop when deleting all inferior breakpoints. Scenario: (gdb) set can-use-hw-watchpoints 0 (gdb) awatch Can't set read/access watchpoint when hardware watchpoints are disabled. (gdb) rwatch Can't set read/access watchpoint when hardware watchpoints are disabled. (gdb) >> HANG << Signed-off-by: Mohamed Bouhaouel Reviewed-by: Bruno Larsen --- gdb/breakpoint.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gdb/breakpoint.h') diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 1a73d08..e75efc9 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1000,6 +1000,9 @@ struct watchpoint : public breakpoint void print_recreate (struct ui_file *fp) const override; bool explains_signal (enum gdb_signal) override; + /* Destructor for WATCHPOINT. */ + ~watchpoint (); + /* String form of exp to use for displaying to the user (malloc'd), or NULL if none. */ gdb::unique_xmalloc_ptr exp_string; -- cgit v1.1