public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/18] Minor breakpoint cleanups
@ 2022-05-02 22:15 Tom Tromey
  2022-05-02 22:15 ` [PATCH 01/18] Change print_recreate_thread to a method Tom Tromey
                   ` (18 more replies)
  0 siblings, 19 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches

Now that the C++-fication of breakpoints has gone in, here are some
patches to tidy a few breakpoint APIs -- more use of bool and of
const; constructors for various subclasses; and some init_* function
deletion.

It would be nice to remove the remaining init_* functions.  There's
also some other worthwhile cleanups, like moving some fields into
subclasses (maybe related_breakpoint?), or removing the "pure
virtual"s.  I haven't really attempted any of these.

Regression tested on x86-64 Fedora 34.  Let me know what you think.

Tom



^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/18] Change print_recreate_thread to a method
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 02/18] Remove breakpoint::ops Tom Tromey
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes print_recreate_thread to be a method on breakpoint.  This
function is only used as a helper by print_recreate methods, so I
thought this transformation made sense.
---
 gdb/ada-lang.c            |  2 +-
 gdb/break-catch-exec.c    |  2 +-
 gdb/break-catch-fork.c    |  2 +-
 gdb/break-catch-syscall.c |  2 +-
 gdb/break-catch-throw.c   |  2 +-
 gdb/breakpoint.c          | 22 +++++++++++-----------
 gdb/breakpoint.h          | 21 +++++++++++----------
 7 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 54bcd86ee7f..5f6f16716fe 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12519,7 +12519,7 @@ ada_catchpoint::print_recreate (struct ui_file *fp)
       default:
 	internal_error (__FILE__, __LINE__, _("unexpected catchpoint type"));
     }
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* See ada-lang.h.  */
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index ac4ea18ee65..2ae9ebf2e30 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -144,7 +144,7 @@ void
 exec_catchpoint::print_recreate (struct ui_file *fp)
 {
   gdb_printf (fp, "catch exec");
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* This function attempts to parse an optional "if <cond>" clause
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index eb88e78ed3a..75e32af0b85 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -172,7 +172,7 @@ void
 fork_catchpoint::print_recreate (struct ui_file *fp)
 {
   gdb_printf (fp, "catch %s", is_vfork ? "vfork" : "fork");
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 static void
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 3b160bf9a04..ff2566b830c 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -331,7 +331,7 @@ syscall_catchpoint::print_recreate (struct ui_file *fp)
 	gdb_printf (fp, " %d", s.number);
     }
 
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Returns non-zero if 'b' is a syscall catchpoint.  */
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 4b79e0ffcba..8742bc9c861 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -338,7 +338,7 @@ exception_catchpoint::print_recreate (struct ui_file *fp)
       gdb_printf (fp, "rethrow");
       break;
     }
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Implement the "allocate_location" method for throw and catch
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7241b7b6985..3a2d37e8462 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9335,7 +9335,7 @@ ranged_breakpoint::print_recreate (struct ui_file *fp)
   gdb_printf (fp, "break-range %s, %s",
 	      event_location_to_string (location.get ()),
 	      event_location_to_string (location_range_end.get ()));
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Find the address where the end of the breakpoint range should be
@@ -9739,7 +9739,7 @@ watchpoint::print_recreate (struct ui_file *fp)
     }
 
   gdb_printf (fp, " %s", exp_string.get ());
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Implement the "explains_signal" method for watchpoints.  */
@@ -9927,7 +9927,7 @@ masked_watchpoint::print_recreate (struct ui_file *fp)
 
   gdb_printf (fp, " %s mask 0x%s", exp_string.get (),
 	      phex (hw_wp_mask, sizeof (CORE_ADDR)));
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Tell whether the given watchpoint is a masked hardware watchpoint.  */
@@ -11807,7 +11807,7 @@ ordinary_breakpoint::print_recreate (struct ui_file *fp)
   if (loc == NULL && extra_string != NULL)
     gdb_printf (fp, " %s", extra_string.get ());
 
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 std::vector<symtab_and_line>
@@ -12055,7 +12055,7 @@ tracepoint::print_recreate (struct ui_file *fp)
 		    _("unhandled tracepoint type %d"), (int) type);
 
   gdb_printf (fp, " %s", event_location_to_string (location.get ()));
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 
   if (pass_count)
     gdb_printf (fp, "  passcount %d\n", pass_count);
@@ -12112,7 +12112,7 @@ dprintf_breakpoint::print_recreate (struct ui_file *fp)
   gdb_printf (fp, "dprintf %s,%s",
 	      event_location_to_string (location.get ()),
 	      extra_string.get ());
-  print_recreate_thread (this, fp);
+  print_recreate_thread (fp);
 }
 
 /* Implement the "after_condition_true" method for dprintf.
@@ -14044,13 +14044,13 @@ get_tracepoint_by_number (const char **arg,
 }
 
 void
-print_recreate_thread (struct breakpoint *b, struct ui_file *fp)
+breakpoint::print_recreate_thread (struct ui_file *fp) const
 {
-  if (b->thread != -1)
-    gdb_printf (fp, " thread %d", b->thread);
+  if (thread != -1)
+    gdb_printf (fp, " thread %d", thread);
 
-  if (b->task != 0)
-    gdb_printf (fp, " task %d", b->task);
+  if (task != 0)
+    gdb_printf (fp, " task %d", task);
 
   gdb_printf (fp, "\n");
 }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 1322bc1b9b9..7d4e8740cf0 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -586,15 +586,6 @@ struct breakpoint_ops
 				  int, int, int, unsigned);
 };
 
-/* Helper for breakpoint_ops->print_recreate implementations.  Prints
-   the "thread" or "task" condition of B, and then a newline.
-
-   Necessary because most breakpoint implementations accept
-   thread/task conditions at the end of the spec line, like "break foo
-   thread 1", which needs outputting before any breakpoint-type
-   specific extra command necessary for B's recreation.  */
-extern void print_recreate_thread (struct breakpoint *b, struct ui_file *fp);
-
 enum watchpoint_triggered
 {
   /* This watchpoint definitely did not trigger.  */
@@ -742,7 +733,6 @@ struct breakpoint
     /* Nothing to do.  */
   }
 
-
   /* Return a range of this breakpoint's locations.  */
   bp_location_range locations ();
 
@@ -846,6 +836,17 @@ struct breakpoint
 
   /* Same as py_bp_object, but for Scheme.  */
   gdbscm_breakpoint_object *scm_bp_object = NULL;
+
+protected:
+
+  /* Helper for breakpoint_ops->print_recreate implementations.  Prints
+     the "thread" or "task" condition of B, and then a newline.
+
+     Necessary because most breakpoint implementations accept
+     thread/task conditions at the end of the spec line, like "break foo
+     thread 1", which needs outputting before any breakpoint-type
+     specific extra command necessary for B's recreation.  */
+  void print_recreate_thread (struct ui_file *fp) const;
 };
 
 /* The structure to be inherit by all kinds of breakpoints (real
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 02/18] Remove breakpoint::ops
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
  2022-05-02 22:15 ` [PATCH 01/18] Change print_recreate_thread to a method Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 03/18] Boolify breakpoint::explains_signal Tom Tromey
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The breakpoint::ops field is set but never used.  This removes it.
---
 gdb/breakpoint.c | 99 ++++++++++++++++--------------------------------
 gdb/breakpoint.h |  3 --
 2 files changed, 33 insertions(+), 69 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3a2d37e8462..7e8fae92ffb 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -113,8 +113,7 @@ static int can_use_hardware_watchpoint
 static void mention (struct breakpoint *);
 
 static struct breakpoint *set_raw_breakpoint_without_location (struct gdbarch *,
-							       enum bptype,
-							       const struct breakpoint_ops *);
+							       enum bptype);
 static struct bp_location *add_location_to_breakpoint (struct breakpoint *,
 						       const struct symtab_and_line *);
 
@@ -122,13 +121,11 @@ static struct bp_location *add_location_to_breakpoint (struct breakpoint *,
    static.  */
 static struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
 					      struct symtab_and_line,
-					      enum bptype,
-					      const struct breakpoint_ops *);
+					      enum bptype);
 
 static struct breakpoint *
   momentary_breakpoint_from_master (struct breakpoint *orig,
 				    enum bptype type,
-				    const struct breakpoint_ops *ops,
 				    int loc_enabled);
 
 static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int);
@@ -3251,15 +3248,14 @@ set_breakpoint_number (int internal, struct breakpoint *b)
 
 static struct breakpoint *
 create_internal_breakpoint (struct gdbarch *gdbarch,
-			    CORE_ADDR address, enum bptype type,
-			    const struct breakpoint_ops *ops)
+			    CORE_ADDR address, enum bptype type)
 {
   symtab_and_line sal;
   sal.pc = address;
   sal.section = find_pc_overlay (sal.pc);
   sal.pspace = current_program_space;
 
-  breakpoint *b = set_raw_breakpoint (gdbarch, sal, type, ops);
+  breakpoint *b = set_raw_breakpoint (gdbarch, sal, type);
   b->number = internal_breakpoint_number--;
   b->disposition = disp_donttouch;
 
@@ -3363,8 +3359,7 @@ create_overlay_event_breakpoint (void)
 
       addr = bp_objfile_data->overlay_msym.value_address ();
       b = create_internal_breakpoint (objfile->arch (), addr,
-				      bp_overlay_event,
-				      &base_breakpoint_ops);
+				      bp_overlay_event);
       initialize_explicit_location (&explicit_loc);
       explicit_loc.function_name = ASTRDUP (func_name);
       b->location = new_explicit_location (&explicit_loc);
@@ -3423,8 +3418,7 @@ create_longjmp_master_breakpoint_probe (objfile *objfile)
 
       b = create_internal_breakpoint (gdbarch,
 				      p->get_relocated_address (objfile),
-				      bp_longjmp_master,
-				      &base_breakpoint_ops);
+				      bp_longjmp_master);
       b->location = new_probe_location ("-probe-stap libc:longjmp");
       b->enable_state = bp_disabled;
     }
@@ -3472,8 +3466,7 @@ create_longjmp_master_breakpoint_names (objfile *objfile)
 	}
 
       addr = bp_objfile_data->longjmp_msym[i].value_address ();
-      b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
-				      &base_breakpoint_ops);
+      b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master);
       initialize_explicit_location (&explicit_loc);
       explicit_loc.function_name = ASTRDUP (func_name);
       b->location = new_explicit_location (&explicit_loc);
@@ -3556,8 +3549,7 @@ create_std_terminate_master_breakpoint (void)
 
 	  addr = bp_objfile_data->terminate_msym.value_address ();
 	  b = create_internal_breakpoint (objfile->arch (), addr,
-					  bp_std_terminate_master,
-					  &base_breakpoint_ops);
+					  bp_std_terminate_master);
 	  initialize_explicit_location (&explicit_loc);
 	  explicit_loc.function_name = ASTRDUP (func_name);
 	  b->location = new_explicit_location (&explicit_loc);
@@ -3609,8 +3601,7 @@ create_exception_master_breakpoint_probe (objfile *objfile)
     {
       b = create_internal_breakpoint (gdbarch,
 				      p->get_relocated_address (objfile),
-				      bp_exception_master,
-				      &base_breakpoint_ops);
+				      bp_exception_master);
       b->location = new_probe_location ("-probe-stap libgcc:unwind");
       b->enable_state = bp_disabled;
     }
@@ -3655,8 +3646,7 @@ create_exception_master_breakpoint_hook (objfile *objfile)
   addr = bp_objfile_data->exception_msym.value_address ();
   addr = gdbarch_convert_from_func_ptr_addr
     (gdbarch, addr, current_inferior ()->top_target ());
-  b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
-				  &base_breakpoint_ops);
+  b = create_internal_breakpoint (gdbarch, addr, bp_exception_master);
   initialize_explicit_location (&explicit_loc);
   explicit_loc.function_name = ASTRDUP (func_name);
   b->location = new_explicit_location (&explicit_loc);
@@ -7230,12 +7220,8 @@ add_to_breakpoint_chain (std::unique_ptr<breakpoint> &&b)
 static void
 init_raw_breakpoint_without_location (struct breakpoint *b,
 				      struct gdbarch *gdbarch,
-				      enum bptype bptype,
-				      const struct breakpoint_ops *ops)
+				      enum bptype bptype)
 {
-  gdb_assert (ops != NULL);
-
-  b->ops = ops;
   b->type = bptype;
   b->gdbarch = gdbarch;
   b->language = current_language->la_language;
@@ -7248,12 +7234,11 @@ init_raw_breakpoint_without_location (struct breakpoint *b,
 
 static struct breakpoint *
 set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
-				     enum bptype bptype,
-				     const struct breakpoint_ops *ops)
+				     enum bptype bptype)
 {
   std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
 
-  init_raw_breakpoint_without_location (b.get (), gdbarch, bptype, ops);
+  init_raw_breakpoint_without_location (b.get (), gdbarch, bptype);
   return add_to_breakpoint_chain (std::move (b));
 }
 
@@ -7319,10 +7304,9 @@ get_sal_arch (struct symtab_and_line sal)
 
 static void
 init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch,
-		     struct symtab_and_line sal, enum bptype bptype,
-		     const struct breakpoint_ops *ops)
+		     struct symtab_and_line sal, enum bptype bptype)
 {
-  init_raw_breakpoint_without_location (b, gdbarch, bptype, ops);
+  init_raw_breakpoint_without_location (b, gdbarch, bptype);
 
   add_location_to_breakpoint (b, &sal);
 
@@ -7353,12 +7337,11 @@ init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch,
 
 static struct breakpoint *
 set_raw_breakpoint (struct gdbarch *gdbarch,
-		    struct symtab_and_line sal, enum bptype bptype,
-		    const struct breakpoint_ops *ops)
+		    struct symtab_and_line sal, enum bptype bptype)
 {
   std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
 
-  init_raw_breakpoint (b.get (), gdbarch, sal, bptype, ops);
+  init_raw_breakpoint (b.get (), gdbarch, sal, bptype);
   return add_to_breakpoint_chain (std::move (b));
 }
 
@@ -7385,8 +7368,7 @@ set_longjmp_breakpoint (struct thread_info *tp, struct frame_id frame)
 
 	/* longjmp_breakpoint_ops ensures INITIATING_FRAME is cleared again
 	   after their removal.  */
-	clone = momentary_breakpoint_from_master (b, type,
-						  &base_breakpoint_ops, 1);
+	clone = momentary_breakpoint_from_master (b, type, 1);
 	clone->thread = thread;
       }
 
@@ -7432,7 +7414,6 @@ set_longjmp_breakpoint_for_call_dummy (void)
 	struct breakpoint *new_b;
 
 	new_b = momentary_breakpoint_from_master (b, bp_longjmp_call_dummy,
-						  &base_breakpoint_ops,
 						  1);
 	new_b->thread = inferior_thread ()->global_num;
 
@@ -7563,8 +7544,7 @@ set_std_terminate_breakpoint (void)
     if (b->pspace == current_program_space
 	&& b->type == bp_std_terminate_master)
       {
-	momentary_breakpoint_from_master (b, bp_std_terminate,
-					  &base_breakpoint_ops, 1);
+	momentary_breakpoint_from_master (b, bp_std_terminate, 1);
       }
 }
 
@@ -7582,8 +7562,7 @@ create_thread_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
 {
   struct breakpoint *b;
 
-  b = create_internal_breakpoint (gdbarch, address, bp_thread_event,
-				  &base_breakpoint_ops);
+  b = create_internal_breakpoint (gdbarch, address, bp_thread_event);
 
   b->enable_state = bp_enabled;
   /* location has to be used or breakpoint_re_set will delete me.  */
@@ -7605,8 +7584,7 @@ struct lang_and_radix
 struct breakpoint *
 create_jit_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
 {
-  return create_internal_breakpoint (gdbarch, address, bp_jit_event,
-				     &base_breakpoint_ops);
+  return create_internal_breakpoint (gdbarch, address, bp_jit_event);
 }
 
 /* Remove JIT code registration and unregistration breakpoint(s).  */
@@ -7650,8 +7628,7 @@ create_solib_event_breakpoint_1 (struct gdbarch *gdbarch, CORE_ADDR address,
 {
   struct breakpoint *b;
 
-  b = create_internal_breakpoint (gdbarch, address, bp_shlib_event,
-				  &base_breakpoint_ops);
+  b = create_internal_breakpoint (gdbarch, address, bp_shlib_event);
   update_global_location_list_nothrow (insert_mode);
   return b;
 }
@@ -7835,8 +7812,7 @@ init_catchpoint (struct breakpoint *b,
   symtab_and_line sal;
   sal.pspace = current_program_space;
 
-  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint,
-		       &base_breakpoint_ops);
+  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint);
 
   if (cond_string == nullptr)
     b->cond_string.reset ();
@@ -7970,8 +7946,7 @@ new_single_step_breakpoint (int thread, struct gdbarch *gdbarch)
 {
   std::unique_ptr<breakpoint> b (new momentary_breakpoint ());
 
-  init_raw_breakpoint_without_location (b.get (), gdbarch, bp_single_step,
-					&base_breakpoint_ops);
+  init_raw_breakpoint_without_location (b.get (), gdbarch, bp_single_step);
 
   b->disposition = disp_donttouch;
   b->frame_id = null_frame_id;
@@ -7996,7 +7971,7 @@ set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
      tail-called one.  */
   gdb_assert (!frame_id_artificial_p (frame_id));
 
-  b = set_raw_breakpoint (gdbarch, sal, type, &base_breakpoint_ops);
+  b = set_raw_breakpoint (gdbarch, sal, type);
   b->enable_state = bp_enabled;
   b->disposition = disp_donttouch;
   b->frame_id = frame_id;
@@ -8015,12 +7990,11 @@ set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
 static struct breakpoint *
 momentary_breakpoint_from_master (struct breakpoint *orig,
 				  enum bptype type,
-				  const struct breakpoint_ops *ops,
 				  int loc_enabled)
 {
   struct breakpoint *copy;
 
-  copy = set_raw_breakpoint_without_location (orig->gdbarch, type, ops);
+  copy = set_raw_breakpoint_without_location (orig->gdbarch, type);
   copy->loc = copy->allocate_location ();
   set_breakpoint_location_function (copy->loc);
 
@@ -8055,8 +8029,7 @@ clone_momentary_breakpoint (struct breakpoint *orig)
   if (orig == NULL)
     return NULL;
 
-  gdb_assert (orig->ops == &base_breakpoint_ops);
-  return momentary_breakpoint_from_master (orig, orig->type, orig->ops, 0);
+  return momentary_breakpoint_from_master (orig, orig->type, 0);
 }
 
 breakpoint_up
@@ -8352,7 +8325,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 
       if (&sal == &sals[0])
 	{
-	  init_raw_breakpoint (b, gdbarch, sal, type, ops);
+	  init_raw_breakpoint (b, gdbarch, sal, type);
 	  b->thread = thread;
 	  b->task = task;
 
@@ -9013,7 +8986,7 @@ create_breakpoint (struct gdbarch *gdbarch,
     {
       std::unique_ptr <breakpoint> b = new_breakpoint_from_type (type_wanted);
 
-      init_raw_breakpoint_without_location (b.get (), gdbarch, type_wanted, ops);
+      init_raw_breakpoint_without_location (b.get (), gdbarch, type_wanted);
       b->location = copy_event_location (location);
 
       if (parse_extra)
@@ -9461,8 +9434,7 @@ break_range_command (const char *arg, int from_tty)
   /* Now set up the breakpoint.  */
   std::unique_ptr<breakpoint> br (new ranged_breakpoint ());
   init_raw_breakpoint (br.get (), get_current_arch (),
-		       sal_start, bp_hardware_breakpoint,
-		       &base_breakpoint_ops);
+		       sal_start, bp_hardware_breakpoint);
   b = add_to_breakpoint_chain (std::move (br));
 
   set_breakpoint_count (breakpoint_count + 1);
@@ -10155,8 +10127,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
 
 	  scope_breakpoint
 	    = create_internal_breakpoint (caller_arch, caller_pc,
-					  bp_watchpoint_scope,
-					  &base_breakpoint_ops);
+					  bp_watchpoint_scope);
 
 	  /* create_internal_breakpoint could invalidate WP_FRAME.  */
 	  wp_frame = NULL;
@@ -10196,8 +10167,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
     w.reset (new masked_watchpoint ());
   else
     w.reset (new watchpoint ());
-  init_raw_breakpoint_without_location (w.get (), nullptr, bp_type,
-					&base_breakpoint_ops);
+  init_raw_breakpoint_without_location (w.get (), nullptr, bp_type);
 
   w->thread = thread;
   w->task = task;
@@ -10650,8 +10620,7 @@ init_ada_exception_breakpoint (struct breakpoint *b,
 	 enough for now, though.  */
     }
 
-  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint,
-		       &base_breakpoint_ops);
+  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint);
 
   b->enable_state = enabled ? bp_enabled : bp_disabled;
   b->disposition = tempflag ? disp_del : disp_donttouch;
@@ -12779,8 +12748,6 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 {
   struct gdb_exception exception;
 
-  gdb_assert (b->ops != NULL);
-
   std::vector<symtab_and_line> sals;
 
   try
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 7d4e8740cf0..b0ca4e98eb4 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -736,9 +736,6 @@ struct breakpoint
   /* Return a range of this breakpoint's locations.  */
   bp_location_range locations ();
 
-  /* Methods associated with this breakpoint.  */
-  const breakpoint_ops *ops = NULL;
-
   breakpoint *next = NULL;
   /* Type of breakpoint.  */
   bptype type = bp_none;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 03/18] Boolify breakpoint::explains_signal
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
  2022-05-02 22:15 ` [PATCH 01/18] Change print_recreate_thread to a method Tom Tromey
  2022-05-02 22:15 ` [PATCH 02/18] Remove breakpoint::ops Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 04/18] Move works_in_software_mode to watchpoint Tom Tromey
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes breakpoint::explains_signal to return bool.
---
 gdb/break-catch-sig.c | 6 +++---
 gdb/breakpoint.c      | 6 +++---
 gdb/breakpoint.h      | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 8f6d3967718..7f73b9e5981 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -51,7 +51,7 @@ struct signal_catchpoint : public breakpoint
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
-  int explains_signal (enum gdb_signal) override;
+  bool explains_signal (enum gdb_signal) override;
 
   /* Signal numbers used for the 'catch signal' feature.  If no signal
      has been specified for filtering, it is empty.  Otherwise,
@@ -297,10 +297,10 @@ signal_catchpoint::print_recreate (struct ui_file *fp)
 
 /* Implement the "explains_signal" method for signal catchpoints.  */
 
-int
+bool
 signal_catchpoint::explains_signal (enum gdb_signal sig)
 {
-  return 1;
+  return true;
 }
 
 /* Create a new signal catchpoint.  TEMPFLAG is true if this should be
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7e8fae92ffb..2521e95ce70 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9716,15 +9716,15 @@ watchpoint::print_recreate (struct ui_file *fp)
 
 /* Implement the "explains_signal" method for watchpoints.  */
 
-int
+bool
 watchpoint::explains_signal (enum gdb_signal sig)
 {
   /* A software watchpoint cannot cause a signal other than
      GDB_SIGNAL_TRAP.  */
   if (type == bp_watchpoint && sig != GDB_SIGNAL_TRAP)
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 
 struct masked_watchpoint : public watchpoint
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index b0ca4e98eb4..ec3a8309b51 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -721,9 +721,9 @@ struct breakpoint
 
   /* Return true if this breakpoint explains a signal.  See
      bpstat_explains_signal.  */
-  virtual int explains_signal (enum gdb_signal)
+  virtual bool explains_signal (enum gdb_signal)
   {
-    return 1;
+    return true;
   }
 
   /* Called after evaluating the breakpoint's condition,
@@ -882,7 +882,7 @@ struct watchpoint : public breakpoint
   enum print_stop_action print_it (struct bpstat *bs) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
-  int explains_signal (enum gdb_signal) override;
+  bool explains_signal (enum gdb_signal) override;
 
   /* String form of exp to use for displaying to the user (malloc'd),
      or NULL if none.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 04/18] Move works_in_software_mode to watchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (2 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 03/18] Boolify breakpoint::explains_signal Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 05/18] Constify breakpoint::print_it Tom Tromey
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

works_in_software_mode is only useful for watchpoints.  This patch
moves it from breakpoint to watchpoint, and changes it to return bool.
---
 gdb/breakpoint.c | 16 +++++-----------
 gdb/breakpoint.h | 12 ++++++------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2521e95ce70..41e827bfca7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2144,7 +2144,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
 		= target_can_use_hardware_watchpoint (type, i, other_type_used);
 	      if (target_resources_ok <= 0)
 		{
-		  int sw_mode = b->works_in_software_mode ();
+		  bool sw_mode = b->works_in_software_mode ();
 
 		  if (target_resources_ok == 0 && !sw_mode)
 		    error (_("Target does not support this type of "
@@ -9558,7 +9558,7 @@ watchpoint::resources_needed (const struct bp_location *bl)
 /* Implement the "works_in_software_mode" method for hardware
    watchpoints.  */
 
-int
+bool
 watchpoint::works_in_software_mode () const
 {
   /* Read and access watchpoints only work with hardware support.  */
@@ -9733,7 +9733,7 @@ struct masked_watchpoint : public watchpoint
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
   int resources_needed (const struct bp_location *) override;
-  int works_in_software_mode () const override;
+  bool works_in_software_mode () const override;
   enum print_stop_action print_it (struct bpstat *bs) override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () override;
@@ -9771,10 +9771,10 @@ masked_watchpoint::resources_needed (const struct bp_location *bl)
 /* Implement the "works_in_software_mode" method for masked hardware
    watchpoints.  */
 
-int
+bool
 masked_watchpoint::works_in_software_mode () const
 {
-  return 0;
+  return false;
 }
 
 /* Implement the "print_it" method for masked hardware
@@ -11550,12 +11550,6 @@ breakpoint::breakpoint_hit (const struct bp_location *bl,
   internal_error_pure_virtual_called ();
 }
 
-int
-breakpoint::works_in_software_mode () const
-{
-  internal_error_pure_virtual_called ();
-}
-
 int
 breakpoint::resources_needed (const struct bp_location *bl)
 {
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index ec3a8309b51..bbacbca15fb 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -668,11 +668,6 @@ struct breakpoint
      the breakpoint or watchpoint needs one debug register.  */
   virtual int resources_needed (const struct bp_location *);
 
-  /* Tell whether we can downgrade from a hardware watchpoint to a software
-     one.  If not, the user will not be able to enable the watchpoint when
-     there are not enough hardware resources available.  */
-  virtual int works_in_software_mode () const;
-
   /* The normal print routine for this breakpoint, called when we
      hit it.  */
   virtual enum print_stop_action print_it (struct bpstat *bs);
@@ -878,7 +873,12 @@ struct watchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   void check_status (struct bpstat *bs) override;
   int resources_needed (const struct bp_location *) override;
-  int works_in_software_mode () const override;
+
+  /* Tell whether we can downgrade from a hardware watchpoint to a software
+     one.  If not, the user will not be able to enable the watchpoint when
+     there are not enough hardware resources available.  */
+  virtual bool works_in_software_mode () const;
+
   enum print_stop_action print_it (struct bpstat *bs) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 05/18] Constify breakpoint::print_it
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (3 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 04/18] Move works_in_software_mode to watchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 06/18] Constify breakpoint::print_one Tom Tromey
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies breakpoint::print_it.  Doing this pointed out some
code in ada-lang.c that can be simplified a little as well.
---
 gdb/ada-lang.c            | 14 ++++++--------
 gdb/break-catch-exec.c    |  4 ++--
 gdb/break-catch-fork.c    |  4 ++--
 gdb/break-catch-load.c    |  4 ++--
 gdb/break-catch-sig.c     |  4 ++--
 gdb/break-catch-syscall.c |  4 ++--
 gdb/break-catch-throw.c   |  4 ++--
 gdb/breakpoint.c          | 24 ++++++++++++------------
 gdb/breakpoint.h          |  4 ++--
 9 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 5f6f16716fe..7d03e33bdaa 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11969,8 +11969,7 @@ ada_unhandled_exception_name_addr_from_raise (void)
    Return zero if the address could not be computed, or if not relevant.  */
 
 static CORE_ADDR
-ada_exception_name_addr_1 (enum ada_exception_catchpoint_kind ex,
-			   struct breakpoint *b)
+ada_exception_name_addr_1 (enum ada_exception_catchpoint_kind ex)
 {
   struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
 
@@ -12068,14 +12067,13 @@ ada_exception_message (void)
    and zero is returned.  */
 
 static CORE_ADDR
-ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
-			 struct breakpoint *b)
+ada_exception_name_addr (enum ada_exception_catchpoint_kind ex)
 {
   CORE_ADDR result = 0;
 
   try
     {
-      result = ada_exception_name_addr_1 (ex, b);
+      result = ada_exception_name_addr_1 (ex);
     }
 
   catch (const gdb_exception_error &e)
@@ -12132,7 +12130,7 @@ struct ada_catchpoint : public base_breakpoint
   struct bp_location *allocate_location () override;
   void re_set () override;
   void check_status (struct bpstat *bs) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -12297,7 +12295,7 @@ ada_catchpoint::check_status (bpstat *bs)
    catchpoint kinds.  */
 
 enum print_stop_action
-ada_catchpoint::print_it (bpstat *bs)
+ada_catchpoint::print_it (const bpstat *bs) const
 {
   struct ui_out *uiout = current_uiout;
 
@@ -12328,7 +12326,7 @@ ada_catchpoint::print_it (bpstat *bs)
       case ada_catch_exception_unhandled:
       case ada_catch_handlers:
 	{
-	  const CORE_ADDR addr = ada_exception_name_addr (m_kind, this);
+	  const CORE_ADDR addr = ada_exception_name_addr (m_kind);
 	  char exception_name[256];
 
 	  if (addr != 0)
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 2ae9ebf2e30..89fa3935b62 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -43,7 +43,7 @@ struct exec_catchpoint : public breakpoint
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -81,7 +81,7 @@ exec_catchpoint::breakpoint_hit (const struct bp_location *bl,
 }
 
 enum print_stop_action
-exec_catchpoint::print_it (bpstat *bs)
+exec_catchpoint::print_it (const bpstat *bs) const
 {
   struct ui_out *uiout = current_uiout;
 
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 75e32af0b85..bf4437e0f27 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -41,7 +41,7 @@ struct fork_catchpoint : public breakpoint
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -98,7 +98,7 @@ fork_catchpoint::breakpoint_hit (const struct bp_location *bl,
 /* Implement the "print_it" method for fork catchpoints.  */
 
 enum print_stop_action
-fork_catchpoint::print_it (bpstat *bs)
+fork_catchpoint::print_it (const bpstat *bs) const
 {
   struct ui_out *uiout = current_uiout;
 
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 7c927396e3a..d0ef182a49e 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -43,7 +43,7 @@ struct solib_catchpoint : public breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   void check_status (struct bpstat *bs) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -127,7 +127,7 @@ solib_catchpoint::check_status (struct bpstat *bs)
 }
 
 enum print_stop_action
-solib_catchpoint::print_it (bpstat *bs)
+solib_catchpoint::print_it (const bpstat *bs) const
 {
   struct breakpoint *b = bs->breakpoint_at;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 7f73b9e5981..77ecb466250 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -47,7 +47,7 @@ struct signal_catchpoint : public breakpoint
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -183,7 +183,7 @@ signal_catchpoint::breakpoint_hit (const struct bp_location *bl,
 /* Implement the "print_it" method for signal catchpoints.  */
 
 enum print_stop_action
-signal_catchpoint::print_it (bpstat *bs)
+signal_catchpoint::print_it (const bpstat *bs) const
 {
   struct target_waitstatus last;
   const char *signal_name;
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index ff2566b830c..5b7cd1a9eb7 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -44,7 +44,7 @@ struct syscall_catchpoint : public breakpoint
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -180,7 +180,7 @@ syscall_catchpoint::breakpoint_hit (const struct bp_location *bl,
 /* Implement the "print_it" method for syscall catchpoints.  */
 
 enum print_stop_action
-syscall_catchpoint::print_it (bpstat *bs)
+syscall_catchpoint::print_it (const bpstat *bs) const
 {
   struct ui_out *uiout = current_uiout;
   struct breakpoint *b = bs->breakpoint_at;
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 8742bc9c861..6b3601a6fd0 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -68,7 +68,7 @@ static const struct exception_names exception_functions[] =
 struct exception_catchpoint : public base_breakpoint
 {
   void re_set () override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -228,7 +228,7 @@ exception_catchpoint::re_set ()
 }
 
 enum print_stop_action
-exception_catchpoint::print_it (bpstat *bs)
+exception_catchpoint::print_it (const bpstat *bs) const
 {
   struct ui_out *uiout = current_uiout;
   int bp_temp;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 41e827bfca7..e6158e6589b 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -259,7 +259,7 @@ static const struct breakpoint_ops tracepoint_probe_breakpoint_ops =
 struct ordinary_breakpoint : public base_breakpoint
 {
   int resources_needed (const struct bp_location *) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 };
@@ -269,7 +269,7 @@ struct internal_breakpoint : public base_breakpoint
 {
   void re_set () override;
   void check_status (struct bpstat *bs) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () override;
 };
 
@@ -278,7 +278,7 @@ struct momentary_breakpoint : public base_breakpoint
 {
   void re_set () override;
   void check_status (struct bpstat *bs) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () override;
 };
 
@@ -302,7 +302,7 @@ struct ranged_breakpoint : public ordinary_breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   int resources_needed (const struct bp_location *) override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (struct bp_location **) override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () override;
@@ -9207,7 +9207,7 @@ ranged_breakpoint::resources_needed (const struct bp_location *bl)
 /* Implement the "print_it" method for ranged breakpoints.  */
 
 enum print_stop_action
-ranged_breakpoint::print_it (bpstat *bs)
+ranged_breakpoint::print_it (const bpstat *bs) const
 {
   struct bp_location *bl = loc;
   struct ui_out *uiout = current_uiout;
@@ -9566,7 +9566,7 @@ watchpoint::works_in_software_mode () const
 }
 
 enum print_stop_action
-watchpoint::print_it (bpstat *bs)
+watchpoint::print_it (const bpstat *bs) const
 {
   struct breakpoint *b;
   enum print_stop_action result;
@@ -9734,7 +9734,7 @@ struct masked_watchpoint : public watchpoint
 		       enum remove_bp_reason reason) override;
   int resources_needed (const struct bp_location *) override;
   bool works_in_software_mode () const override;
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -9781,7 +9781,7 @@ masked_watchpoint::works_in_software_mode () const
    watchpoints.  */
 
 enum print_stop_action
-masked_watchpoint::print_it (bpstat *bs)
+masked_watchpoint::print_it (const bpstat *bs) const
 {
   struct breakpoint *b = bs->breakpoint_at;
   struct ui_out *uiout = current_uiout;
@@ -11557,7 +11557,7 @@ breakpoint::resources_needed (const struct bp_location *bl)
 }
 
 enum print_stop_action
-breakpoint::print_it (bpstat *bs)
+breakpoint::print_it (const bpstat *bs) const
 {
   internal_error_pure_virtual_called ();
 }
@@ -11686,7 +11686,7 @@ ordinary_breakpoint::resources_needed (const struct bp_location *bl)
 }
 
 enum print_stop_action
-ordinary_breakpoint::print_it (bpstat *bs)
+ordinary_breakpoint::print_it (const bpstat *bs) const
 {
   const struct bp_location *bl;
   int bp_temp;
@@ -11827,7 +11827,7 @@ internal_breakpoint::check_status (bpstat *bs)
 }
 
 enum print_stop_action
-internal_breakpoint::print_it (bpstat *bs)
+internal_breakpoint::print_it (const bpstat *bs) const
 {
   switch (type)
     {
@@ -11894,7 +11894,7 @@ momentary_breakpoint::check_status (bpstat *bs)
 }
 
 enum print_stop_action
-momentary_breakpoint::print_it (bpstat *bs)
+momentary_breakpoint::print_it (const bpstat *bs) const
 {
   return PRINT_UNKNOWN;
 }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index bbacbca15fb..194452a3ee3 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -670,7 +670,7 @@ struct breakpoint
 
   /* The normal print routine for this breakpoint, called when we
      hit it.  */
-  virtual enum print_stop_action print_it (struct bpstat *bs);
+  virtual enum print_stop_action print_it (const bpstat *bs) const;
 
   /* Display information about this breakpoint, for "info
      breakpoints".  Returns false if this method should use the
@@ -879,7 +879,7 @@ struct watchpoint : public breakpoint
      there are not enough hardware resources available.  */
   virtual bool works_in_software_mode () const;
 
-  enum print_stop_action print_it (struct bpstat *bs) override;
+  enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
   bool explains_signal (enum gdb_signal) override;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 06/18] Constify breakpoint::print_one
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (4 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 05/18] Constify breakpoint::print_it Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 07/18] Constify breakpoint::print_mention Tom Tromey
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies breakpoint::print_one.
---
 gdb/ada-lang.c            |  4 ++--
 gdb/break-catch-exec.c    |  4 ++--
 gdb/break-catch-fork.c    |  4 ++--
 gdb/break-catch-load.c    |  4 ++--
 gdb/break-catch-sig.c     |  4 ++--
 gdb/break-catch-syscall.c |  4 ++--
 gdb/break-catch-throw.c   |  4 ++--
 gdb/breakpoint.c          | 10 +++++-----
 gdb/breakpoint.h          |  4 ++--
 9 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7d03e33bdaa..68d160a0190 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12131,7 +12131,7 @@ struct ada_catchpoint : public base_breakpoint
   void re_set () override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 
@@ -12383,7 +12383,7 @@ ada_catchpoint::print_it (const bpstat *bs) const
    catchpoint kinds.  */
 
 bool
-ada_catchpoint::print_one (struct bp_location **last_loc)
+ada_catchpoint::print_one (bp_location **last_loc) const
 { 
   struct ui_out *uiout = current_uiout;
   struct value_print_options opts;
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 89fa3935b62..9a89d7717ea 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -44,7 +44,7 @@ struct exec_catchpoint : public breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 
@@ -105,7 +105,7 @@ exec_catchpoint::print_it (const bpstat *bs) const
 }
 
 bool
-exec_catchpoint::print_one (struct bp_location **last_loc)
+exec_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index bf4437e0f27..1d01b95f018 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -42,7 +42,7 @@ struct fork_catchpoint : public breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 
@@ -129,7 +129,7 @@ fork_catchpoint::print_it (const bpstat *bs) const
 /* Implement the "print_one" method for fork catchpoints.  */
 
 bool
-fork_catchpoint::print_one (struct bp_location **last_loc)
+fork_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index d0ef182a49e..ce62aaf53d6 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -44,7 +44,7 @@ struct solib_catchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 
@@ -147,7 +147,7 @@ solib_catchpoint::print_it (const bpstat *bs) const
 }
 
 bool
-solib_catchpoint::print_one (struct bp_location **locs)
+solib_catchpoint::print_one (bp_location **locs) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 77ecb466250..8ded60374c9 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -48,7 +48,7 @@ struct signal_catchpoint : public breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
   bool explains_signal (enum gdb_signal) override;
@@ -204,7 +204,7 @@ signal_catchpoint::print_it (const bpstat *bs) const
 /* Implement the "print_one" method for signal catchpoints.  */
 
 bool
-signal_catchpoint::print_one (struct bp_location **last_loc)
+signal_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 5b7cd1a9eb7..e7810cb711c 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -45,7 +45,7 @@ struct syscall_catchpoint : public breakpoint
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
 
@@ -231,7 +231,7 @@ syscall_catchpoint::print_it (const bpstat *bs) const
 /* Implement the "print_one" method for syscall catchpoints.  */
 
 bool
-syscall_catchpoint::print_one (struct bp_location **last_loc)
+syscall_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 6b3601a6fd0..759391c7ad3 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -69,7 +69,7 @@ struct exception_catchpoint : public base_breakpoint
 {
   void re_set () override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
   void print_one_detail (struct ui_out *) const override;
@@ -253,7 +253,7 @@ exception_catchpoint::print_it (const bpstat *bs) const
 }
 
 bool
-exception_catchpoint::print_one (struct bp_location **last_loc)
+exception_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index e6158e6589b..195fa302a6d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -303,7 +303,7 @@ struct ranged_breakpoint : public ordinary_breakpoint
 		      const target_waitstatus &ws) override;
   int resources_needed (const struct bp_location *) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  bool print_one (struct bp_location **) override;
+  bool print_one (bp_location **) const override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
@@ -5922,7 +5922,7 @@ wrap_indent_at_field (struct ui_out *uiout, const char *col_name)
 */
 
 static const char *
-bp_condition_evaluator (struct breakpoint *b)
+bp_condition_evaluator (const breakpoint *b)
 {
   char host_evals = 0;
   char target_evals = 0;
@@ -5975,7 +5975,7 @@ bp_location_condition_evaluator (struct bp_location *bl)
 /* Print the LOC location out of the list of B->LOC locations.  */
 
 static void
-print_breakpoint_location (struct breakpoint *b,
+print_breakpoint_location (const breakpoint *b,
 			   struct bp_location *loc)
 {
   struct ui_out *uiout = current_uiout;
@@ -9240,7 +9240,7 @@ ranged_breakpoint::print_it (const bpstat *bs) const
 /* Implement the "print_one" method for ranged breakpoints.  */
 
 bool
-ranged_breakpoint::print_one (struct bp_location **last_loc)
+ranged_breakpoint::print_one (bp_location **last_loc) const
 {
   struct bp_location *bl = loc;
   struct value_print_options opts;
@@ -11514,7 +11514,7 @@ say_where (struct breakpoint *b)
 
 /* See breakpoint.h.  */
 
-bp_location_range breakpoint::locations ()
+bp_location_range breakpoint::locations () const
 {
   return bp_location_range (this->loc);
 }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 194452a3ee3..1b399d47384 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -675,7 +675,7 @@ struct breakpoint
   /* Display information about this breakpoint, for "info
      breakpoints".  Returns false if this method should use the
      default behavior.  */
-  virtual bool print_one (struct bp_location **)
+  virtual bool print_one (bp_location **) const
   {
     return false;
   }
@@ -729,7 +729,7 @@ struct breakpoint
   }
 
   /* Return a range of this breakpoint's locations.  */
-  bp_location_range locations ();
+  bp_location_range locations () const;
 
   breakpoint *next = NULL;
   /* Type of breakpoint.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 07/18] Constify breakpoint::print_mention
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (5 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 06/18] Constify breakpoint::print_one Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 08/18] Constify breakpoint::print_recreate Tom Tromey
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies breakpoint::print_mention.
---
 gdb/ada-lang.c            |  4 ++--
 gdb/break-catch-exec.c    |  4 ++--
 gdb/break-catch-fork.c    |  4 ++--
 gdb/break-catch-load.c    |  4 ++--
 gdb/break-catch-sig.c     |  4 ++--
 gdb/break-catch-syscall.c |  4 ++--
 gdb/break-catch-throw.c   |  4 ++--
 gdb/breakpoint.c          | 32 ++++++++++++++++----------------
 gdb/breakpoint.h          |  6 +++---
 9 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 68d160a0190..c5b9d08a91e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12132,7 +12132,7 @@ struct ada_catchpoint : public base_breakpoint
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 
   /* The name of the specific exception the user specified.  */
@@ -12440,7 +12440,7 @@ ada_catchpoint::print_one (bp_location **last_loc) const
    for all exception catchpoint kinds.  */
 
 void
-ada_catchpoint::print_mention ()
+ada_catchpoint::print_mention () const
 {
   struct ui_out *uiout = current_uiout;
 
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 9a89d7717ea..5cb08bde184 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -45,7 +45,7 @@ struct exec_catchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 
   /* Filename of a program whose exec triggered this catchpoint.
@@ -133,7 +133,7 @@ exec_catchpoint::print_one (bp_location **last_loc) const
 }
 
 void
-exec_catchpoint::print_mention ()
+exec_catchpoint::print_mention () const
 {
   gdb_printf (_("Catchpoint %d (exec)"), number);
 }
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 1d01b95f018..1fbea571112 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -43,7 +43,7 @@ struct fork_catchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 
   /* True if the breakpoint is for vfork, false for fork.  */
@@ -160,7 +160,7 @@ fork_catchpoint::print_one (bp_location **last_loc) const
 /* Implement the "print_mention" method for fork catchpoints.  */
 
 void
-fork_catchpoint::print_mention ()
+fork_catchpoint::print_mention () const
 {
   gdb_printf (_("Catchpoint %d (%s)"), number,
 	      is_vfork ? "vfork" : "fork");
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index ce62aaf53d6..7f2efd57de2 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -45,7 +45,7 @@ struct solib_catchpoint : public breakpoint
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 
   /* True for "catch load", false for "catch unload".  */
@@ -189,7 +189,7 @@ solib_catchpoint::print_one (bp_location **locs) const
 }
 
 void
-solib_catchpoint::print_mention ()
+solib_catchpoint::print_mention () const
 {
   gdb_printf (_("Catchpoint %d (%s)"), number,
 	      is_load ? "load" : "unload");
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 8ded60374c9..6665c9eaab0 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -49,7 +49,7 @@ struct signal_catchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
   bool explains_signal (enum gdb_signal) override;
 
@@ -255,7 +255,7 @@ signal_catchpoint::print_one (bp_location **last_loc) const
 /* Implement the "print_mention" method for signal catchpoints.  */
 
 void
-signal_catchpoint::print_mention ()
+signal_catchpoint::print_mention () const
 {
   if (!signals_to_be_caught.empty ())
     {
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index e7810cb711c..721a87c66b6 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -46,7 +46,7 @@ struct syscall_catchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 
   /* Syscall numbers used for the 'catch syscall' feature.  If no
@@ -284,7 +284,7 @@ syscall_catchpoint::print_one (bp_location **last_loc) const
 /* Implement the "print_mention" method for syscall catchpoints.  */
 
 void
-syscall_catchpoint::print_mention ()
+syscall_catchpoint::print_mention () const
 {
   struct gdbarch *gdbarch = loc->gdbarch;
 
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 759391c7ad3..1ab518f02c0 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -70,7 +70,7 @@ struct exception_catchpoint : public base_breakpoint
   void re_set () override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
   void print_one_detail (struct ui_out *) const override;
   void check_status (struct bpstat *bs) override;
@@ -302,7 +302,7 @@ exception_catchpoint::print_one_detail (struct ui_out *uiout) const
 }
 
 void
-exception_catchpoint::print_mention ()
+exception_catchpoint::print_mention () const
 {
   struct ui_out *uiout = current_uiout;
   int bp_temp;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 195fa302a6d..ddb198523ca 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -110,7 +110,7 @@ static std::vector<symtab_and_line> decode_location_default
 static int can_use_hardware_watchpoint
     (const std::vector<value_ref_ptr> &vals);
 
-static void mention (struct breakpoint *);
+static void mention (const breakpoint *);
 
 static struct breakpoint *set_raw_breakpoint_without_location (struct gdbarch *,
 							       enum bptype);
@@ -260,7 +260,7 @@ struct ordinary_breakpoint : public base_breakpoint
 {
   int resources_needed (const struct bp_location *) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 };
 
@@ -270,7 +270,7 @@ struct internal_breakpoint : public base_breakpoint
   void re_set () override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  void print_mention () override;
+  void print_mention () const override;
 };
 
 /* Momentary breakpoints.  */
@@ -279,7 +279,7 @@ struct momentary_breakpoint : public base_breakpoint
   void re_set () override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
-  void print_mention () override;
+  void print_mention () const override;
 };
 
 /* DPrintf breakpoints.  */
@@ -305,7 +305,7 @@ struct ranged_breakpoint : public ordinary_breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_one_detail (struct ui_out *) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 };
 
@@ -8050,7 +8050,7 @@ set_momentary_breakpoint_at_pc (struct gdbarch *gdbarch, CORE_ADDR pc,
 /* Tell the user we have just set a breakpoint B.  */
 
 static void
-mention (struct breakpoint *b)
+mention (const breakpoint *b)
 {
   b->print_mention ();
   current_uiout->text ("\n");
@@ -9287,7 +9287,7 @@ ranged_breakpoint::print_one_detail (struct ui_out *uiout) const
 /* Implement the "print_mention" method for ranged breakpoints.  */
 
 void
-ranged_breakpoint::print_mention ()
+ranged_breakpoint::print_mention () const
 {
   struct bp_location *bl = loc;
   struct ui_out *uiout = current_uiout;
@@ -9654,7 +9654,7 @@ watchpoint::print_it (const bpstat *bs) const
 /* Implement the "print_mention" method for hardware watchpoints.  */
 
 void
-watchpoint::print_mention ()
+watchpoint::print_mention () const
 {
   struct ui_out *uiout = current_uiout;
   const char *tuple_name;
@@ -9736,7 +9736,7 @@ struct masked_watchpoint : public watchpoint
   bool works_in_software_mode () const override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_one_detail (struct ui_out *) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
 };
 
@@ -9845,7 +9845,7 @@ masked_watchpoint::print_one_detail (struct ui_out *uiout) const
    watchpoints.  */
 
 void
-masked_watchpoint::print_mention ()
+masked_watchpoint::print_mention () const
 {
   struct ui_out *uiout = current_uiout;
   const char *tuple_name;
@@ -11442,7 +11442,7 @@ bpstat_remove_breakpoint_callback (struct thread_info *th, void *data)
    callbacks.  */
 
 static void
-say_where (struct breakpoint *b)
+say_where (const breakpoint *b)
 {
   struct value_print_options opts;
 
@@ -11563,7 +11563,7 @@ breakpoint::print_it (const bpstat *bs) const
 }
 
 void
-breakpoint::print_mention ()
+breakpoint::print_mention () const
 {
   internal_error_pure_virtual_called ();
 }
@@ -11719,7 +11719,7 @@ ordinary_breakpoint::print_it (const bpstat *bs) const
 }
 
 void
-ordinary_breakpoint::print_mention ()
+ordinary_breakpoint::print_mention () const
 {
   if (current_uiout->is_mi_like_p ())
     return;
@@ -11871,7 +11871,7 @@ internal_breakpoint::print_it (const bpstat *bs) const
 }
 
 void
-internal_breakpoint::print_mention ()
+internal_breakpoint::print_mention () const
 {
   /* Nothing to mention.  These breakpoints are internal.  */
 }
@@ -11900,7 +11900,7 @@ momentary_breakpoint::print_it (const bpstat *bs) const
 }
 
 void
-momentary_breakpoint::print_mention ()
+momentary_breakpoint::print_mention () const
 {
   /* Nothing to mention.  These breakpoints are internal.  */
 }
@@ -11975,7 +11975,7 @@ tracepoint::print_one_detail (struct ui_out *uiout) const
 }
 
 void
-tracepoint::print_mention ()
+tracepoint::print_mention () const
 {
   if (current_uiout->is_mi_like_p ())
     return;
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 1b399d47384..4f27262ef20 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -699,7 +699,7 @@ struct breakpoint
 
   /* Display information about this breakpoint after setting it
      (roughly speaking; this is called from "mention").  */
-  virtual void print_mention ();
+  virtual void print_mention () const;
 
   /* Print to FP the CLI command that recreates this breakpoint.  */
   virtual void print_recreate (struct ui_file *fp);
@@ -880,7 +880,7 @@ struct watchpoint : public breakpoint
   virtual bool works_in_software_mode () const;
 
   enum print_stop_action print_it (const bpstat *bs) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
   bool explains_signal (enum gdb_signal) override;
 
@@ -961,7 +961,7 @@ struct tracepoint : public breakpoint
 		      const address_space *aspace, CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
   void print_one_detail (struct ui_out *uiout) const override;
-  void print_mention () override;
+  void print_mention () const override;
   void print_recreate (struct ui_file *fp) override;
   std::vector<symtab_and_line> decode_location
        (struct event_location *location,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 08/18] Constify breakpoint::print_recreate
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (6 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 07/18] Constify breakpoint::print_mention Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 09/18] Remove unnecessary line from catch_exec_command_1 Tom Tromey
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies breakpoint::print_recreate.
---
 gdb/ada-lang.c            |  4 ++--
 gdb/break-catch-exec.c    |  4 ++--
 gdb/break-catch-fork.c    |  4 ++--
 gdb/break-catch-load.c    |  4 ++--
 gdb/break-catch-sig.c     |  4 ++--
 gdb/break-catch-syscall.c |  4 ++--
 gdb/break-catch-throw.c   |  4 ++--
 gdb/breakpoint.c          | 22 +++++++++++-----------
 gdb/breakpoint.h          |  6 +++---
 9 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c5b9d08a91e..b11808acb71 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12133,7 +12133,7 @@ struct ada_catchpoint : public base_breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 
   /* The name of the specific exception the user specified.  */
   std::string excep_string;
@@ -12492,7 +12492,7 @@ ada_catchpoint::print_mention () const
    exception catchpoint kinds.  */
 
 void
-ada_catchpoint::print_recreate (struct ui_file *fp)
+ada_catchpoint::print_recreate (struct ui_file *fp) const
 {
   switch (m_kind)
     {
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 5cb08bde184..00a0263ac0d 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -46,7 +46,7 @@ struct exec_catchpoint : public breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 
   /* Filename of a program whose exec triggered this catchpoint.
      This field is only valid immediately after this catchpoint has
@@ -141,7 +141,7 @@ exec_catchpoint::print_mention () const
 /* Implement the "print_recreate" method for exec catchpoints.  */
 
 void
-exec_catchpoint::print_recreate (struct ui_file *fp)
+exec_catchpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "catch exec");
   print_recreate_thread (fp);
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 1fbea571112..e8d613f062d 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -44,7 +44,7 @@ struct fork_catchpoint : public breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 
   /* True if the breakpoint is for vfork, false for fork.  */
   bool is_vfork;
@@ -169,7 +169,7 @@ fork_catchpoint::print_mention () const
 /* Implement the "print_recreate" method for fork catchpoints.  */
 
 void
-fork_catchpoint::print_recreate (struct ui_file *fp)
+fork_catchpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "catch %s", is_vfork ? "vfork" : "fork");
   print_recreate_thread (fp);
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 7f2efd57de2..99aa185ad85 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -46,7 +46,7 @@ struct solib_catchpoint : public breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 
   /* True for "catch load", false for "catch unload".  */
   bool is_load;
@@ -196,7 +196,7 @@ solib_catchpoint::print_mention () const
 }
 
 void
-solib_catchpoint::print_recreate (struct ui_file *fp)
+solib_catchpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "%s %s",
 	      disposition == disp_del ? "tcatch" : "catch",
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 6665c9eaab0..c42b0fd1c01 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -50,7 +50,7 @@ struct signal_catchpoint : public breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
   bool explains_signal (enum gdb_signal) override;
 
   /* Signal numbers used for the 'catch signal' feature.  If no signal
@@ -281,7 +281,7 @@ signal_catchpoint::print_mention () const
 /* Implement the "print_recreate" method for signal catchpoints.  */
 
 void
-signal_catchpoint::print_recreate (struct ui_file *fp)
+signal_catchpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "catch signal");
 
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 721a87c66b6..bcdf0f117a5 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -47,7 +47,7 @@ struct syscall_catchpoint : public breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 
   /* Syscall numbers used for the 'catch syscall' feature.  If no
      syscall has been specified for filtering, it is empty.
@@ -314,7 +314,7 @@ syscall_catchpoint::print_mention () const
 /* Implement the "print_recreate" method for syscall catchpoints.  */
 
 void
-syscall_catchpoint::print_recreate (struct ui_file *fp)
+syscall_catchpoint::print_recreate (struct ui_file *fp) const
 {
   struct gdbarch *gdbarch = loc->gdbarch;
 
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 1ab518f02c0..a10334e9ae0 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -71,7 +71,7 @@ struct exception_catchpoint : public base_breakpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
   void print_one_detail (struct ui_out *) const override;
   void check_status (struct bpstat *bs) override;
   struct bp_location *allocate_location () override;
@@ -320,7 +320,7 @@ exception_catchpoint::print_mention () const
    catchpoints.  */
 
 void
-exception_catchpoint::print_recreate (struct ui_file *fp)
+exception_catchpoint::print_recreate (struct ui_file *fp) const
 {
   int bp_temp;
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ddb198523ca..ef8a7001834 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -261,7 +261,7 @@ struct ordinary_breakpoint : public base_breakpoint
   int resources_needed (const struct bp_location *) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 };
 
 /* Internal breakpoints.  */
@@ -290,7 +290,7 @@ struct dprintf_breakpoint : public ordinary_breakpoint
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
 		      const target_waitstatus &ws) override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
   void after_condition_true (struct bpstat *bs) override;
 };
 
@@ -306,7 +306,7 @@ struct ranged_breakpoint : public ordinary_breakpoint
   bool print_one (bp_location **) const override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 };
 
 /* Static tracepoints with marker (`-m').  */
@@ -9303,7 +9303,7 @@ ranged_breakpoint::print_mention () const
 /* Implement the "print_recreate" method for ranged breakpoints.  */
 
 void
-ranged_breakpoint::print_recreate (struct ui_file *fp)
+ranged_breakpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "break-range %s, %s",
 	      event_location_to_string (location.get ()),
@@ -9691,7 +9691,7 @@ watchpoint::print_mention () const
 /* Implement the "print_recreate" method for watchpoints.  */
 
 void
-watchpoint::print_recreate (struct ui_file *fp)
+watchpoint::print_recreate (struct ui_file *fp) const
 {
   switch (type)
     {
@@ -9737,7 +9737,7 @@ struct masked_watchpoint : public watchpoint
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
 };
 
 /* Implement the "insert" method for masked hardware watchpoints.  */
@@ -9879,7 +9879,7 @@ masked_watchpoint::print_mention () const
    watchpoints.  */
 
 void
-masked_watchpoint::print_recreate (struct ui_file *fp)
+masked_watchpoint::print_recreate (struct ui_file *fp) const
 {
   switch (type)
     {
@@ -11569,7 +11569,7 @@ breakpoint::print_mention () const
 }
 
 void
-breakpoint::print_recreate (struct ui_file *fp)
+breakpoint::print_recreate (struct ui_file *fp) const
 {
   internal_error_pure_virtual_called ();
 }
@@ -11748,7 +11748,7 @@ ordinary_breakpoint::print_mention () const
 }
 
 void
-ordinary_breakpoint::print_recreate (struct ui_file *fp)
+ordinary_breakpoint::print_recreate (struct ui_file *fp) const
 {
   if (type == bp_breakpoint && disposition == disp_del)
     gdb_printf (fp, "tbreak");
@@ -12004,7 +12004,7 @@ tracepoint::print_mention () const
 }
 
 void
-tracepoint::print_recreate (struct ui_file *fp)
+tracepoint::print_recreate (struct ui_file *fp) const
 {
   if (type == bp_fast_tracepoint)
     gdb_printf (fp, "ftrace");
@@ -12070,7 +12070,7 @@ dprintf_breakpoint::re_set ()
 /* Implement the "print_recreate" method for dprintf.  */
 
 void
-dprintf_breakpoint::print_recreate (struct ui_file *fp)
+dprintf_breakpoint::print_recreate (struct ui_file *fp) const
 {
   gdb_printf (fp, "dprintf %s,%s",
 	      event_location_to_string (location.get ()),
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 4f27262ef20..5db165dbf49 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -702,7 +702,7 @@ struct breakpoint
   virtual void print_mention () const;
 
   /* Print to FP the CLI command that recreates this breakpoint.  */
-  virtual void print_recreate (struct ui_file *fp);
+  virtual void print_recreate (struct ui_file *fp) const;
 
   /* Given the location (second parameter), this method decodes it and
      returns the SAL locations related to it.  For ordinary
@@ -881,7 +881,7 @@ struct watchpoint : public breakpoint
 
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
   bool explains_signal (enum gdb_signal) override;
 
   /* String form of exp to use for displaying to the user (malloc'd),
@@ -962,7 +962,7 @@ struct tracepoint : public breakpoint
 		      const target_waitstatus &ws) override;
   void print_one_detail (struct ui_out *uiout) const override;
   void print_mention () const override;
-  void print_recreate (struct ui_file *fp) override;
+  void print_recreate (struct ui_file *fp) const override;
   std::vector<symtab_and_line> decode_location
        (struct event_location *location,
 	struct program_space *search_pspace) override;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 09/18] Remove unnecessary line from catch_exec_command_1
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (7 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 08/18] Constify breakpoint::print_recreate Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 10/18] Add constructor to fork_catchpoint Tom Tromey
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

catch_exec_command_1 clears the new catchpoint's "exec_pathname"
field, but this is already done by virtue of calling "new".
---
 gdb/break-catch-exec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 00a0263ac0d..fbdc1c20e50 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -205,7 +205,6 @@ catch_exec_command_1 (const char *arg, int from_tty,
 
   std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ());
   init_catchpoint (c.get (), gdbarch, temp, cond_string);
-  c->exec_pathname.reset ();
 
   install_breakpoint (0, std::move (c), 1);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 10/18] Add constructor to fork_catchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (8 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 09/18] Remove unnecessary line from catch_exec_command_1 Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 11/18] Add constructor to solib_catchpoint Tom Tromey
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to fork_catchpoint and simplifies the caller.
---
 gdb/break-catch-fork.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index e8d613f062d..3ad4bafcf1c 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -34,6 +34,11 @@
 
 struct fork_catchpoint : public breakpoint
 {
+  explicit fork_catchpoint (bool is_vfork_)
+    : is_vfork (is_vfork_)
+  {
+  }
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -52,7 +57,7 @@ struct fork_catchpoint : public breakpoint
   /* Process id of a child process whose forking triggered this
      catchpoint.  This field is only valid immediately after this
      catchpoint has triggered.  */
-  ptid_t forked_inferior_pid;
+  ptid_t forked_inferior_pid = null_ptid;
 };
 
 /* Implement the "insert" method for fork catchpoints.  */
@@ -180,11 +185,9 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
 				    bool temp, const char *cond_string,
 				    bool is_vfork)
 {
-  std::unique_ptr<fork_catchpoint> c (new fork_catchpoint ());
+  std::unique_ptr<fork_catchpoint> c (new fork_catchpoint (is_vfork));
 
   init_catchpoint (c.get (), gdbarch, temp, cond_string);
-  c->is_vfork = is_vfork;
-  c->forked_inferior_pid = null_ptid;
 
   install_breakpoint (0, std::move (c), 1);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 11/18] Add constructor to solib_catchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (9 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 10/18] Add constructor to fork_catchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 12/18] Add constructor to signal_catchpoint Tom Tromey
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to solib_catchpoint and simplifies the caller.
---
 gdb/break-catch-load.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 99aa185ad85..3e3bed2f861 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -35,6 +35,15 @@
 
 struct solib_catchpoint : public breakpoint
 {
+  solib_catchpoint (bool is_load_, const char *arg)
+    : is_load (is_load_),
+      regex (arg == nullptr ? nullptr : make_unique_xstrdup (arg)),
+      compiled (arg == nullptr
+		? nullptr
+		: new compiled_regex (arg, REG_NOSUB, _("Invalid regexp")))
+  {
+  }
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -216,17 +225,11 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (!arg)
     arg = "";
   arg = skip_spaces (arg);
+  if (*arg == '\0')
+    arg = nullptr;
 
-  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint ());
-
-  if (*arg != '\0')
-    {
-      c->compiled.reset (new compiled_regex (arg, REG_NOSUB,
-					     _("Invalid regexp")));
-      c->regex = make_unique_xstrdup (arg);
-    }
+  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (is_load, arg));
 
-  c->is_load = is_load;
   init_catchpoint (c.get (), gdbarch, is_temp, NULL);
 
   c->enable_state = enabled ? bp_enabled : bp_disabled;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 12/18] Add constructor to signal_catchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (10 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 11/18] Add constructor to solib_catchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 13/18] Add constructor to syscall_catchpoint Tom Tromey
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to signal_catchpoint and simplifies the
caller.
---
 gdb/break-catch-sig.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index c42b0fd1c01..1c29a057d60 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -40,6 +40,12 @@
 
 struct signal_catchpoint : public breakpoint
 {
+  signal_catchpoint (std::vector<gdb_signal> &&sigs, bool catch_all_)
+    : signals_to_be_caught (std::move (sigs)),
+      catch_all (catch_all_)
+  {
+  }
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -316,10 +322,9 @@ create_signal_catchpoint (int tempflag, std::vector<gdb_signal> &&filter,
 {
   struct gdbarch *gdbarch = get_current_arch ();
 
-  std::unique_ptr<signal_catchpoint> c (new signal_catchpoint ());
+  std::unique_ptr<signal_catchpoint> c
+    (new signal_catchpoint (std::move (filter), catch_all));
   init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
-  c->signals_to_be_caught = std::move (filter);
-  c->catch_all = catch_all;
 
   install_breakpoint (0, std::move (c), 1);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 13/18] Add constructor to syscall_catchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (11 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 12/18] Add constructor to signal_catchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 14/18] Add constructor to exception_catchpoint Tom Tromey
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to syscall_catchpoint and simplifies the
caller.
---
 gdb/break-catch-syscall.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index bcdf0f117a5..d25d7ba7c5e 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -37,6 +37,11 @@
 
 struct syscall_catchpoint : public breakpoint
 {
+  explicit syscall_catchpoint (std::vector<int> &&calls)
+    : syscalls_to_be_caught (std::move (calls))
+  {
+  }
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -347,9 +352,9 @@ create_syscall_event_catchpoint (int tempflag, std::vector<int> &&filter)
 {
   struct gdbarch *gdbarch = get_current_arch ();
 
-  std::unique_ptr<syscall_catchpoint> c (new syscall_catchpoint ());
+  std::unique_ptr<syscall_catchpoint> c
+    (new syscall_catchpoint (std::move (filter)));
   init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
-  c->syscalls_to_be_caught = std::move (filter);
 
   install_breakpoint (0, std::move (c), 1);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 14/18] Add constructor to exception_catchpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (12 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 13/18] Add constructor to syscall_catchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 15/18] Disable copying for breakpoint Tom Tromey
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a constructor to exception_catchpoint and simplifies the
caller.
---
 gdb/break-catch-throw.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index a10334e9ae0..59e73da2c28 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -67,6 +67,17 @@ static const struct exception_names exception_functions[] =
 
 struct exception_catchpoint : public base_breakpoint
 {
+  exception_catchpoint (enum exception_event_kind kind_,
+			std::string &&except_rx)
+    : kind (kind_),
+      exception_rx (std::move (except_rx)),
+      pattern (exception_rx.empty ()
+	       ? nullptr
+	       : new compiled_regex (exception_rx.c_str (), REG_NOSUB,
+				     _("invalid type-matching regexp")))
+  {
+  }
+
   void re_set () override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   bool print_one (bp_location **) const override;
@@ -355,20 +366,10 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
 			  const char *cond_string,
 			  enum exception_event_kind ex_event, int from_tty)
 {
-  std::unique_ptr<compiled_regex> pattern;
-
-  if (!except_rx.empty ())
-    {
-      pattern.reset (new compiled_regex (except_rx.c_str (), REG_NOSUB,
-					 _("invalid type-matching regexp")));
-    }
-
-  std::unique_ptr<exception_catchpoint> cp (new exception_catchpoint ());
+  std::unique_ptr<exception_catchpoint> cp
+    (new exception_catchpoint (ex_event, std::move (except_rx)));
 
   init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string);
-  cp->kind = ex_event;
-  cp->exception_rx = std::move (except_rx);
-  cp->pattern = std::move (pattern);
 
   cp->re_set ();
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 15/18] Disable copying for breakpoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (13 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 14/18] Add constructor to exception_catchpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 16/18] Remove init_raw_breakpoint_without_location Tom Tromey
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

It seems to me that breakpoint should use DISABLE_COPY_AND_ASSIGN.
This patch does this.
---
 gdb/breakpoint.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 5db165dbf49..6923478f60a 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -620,6 +620,9 @@ using bp_location_range = next_range<bp_location>;
 
 struct breakpoint
 {
+  breakpoint () = default;
+  DISABLE_COPY_AND_ASSIGN (breakpoint);
+
   virtual ~breakpoint () = default;
 
   /* Allocate a location for this breakpoint.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 16/18] Remove init_raw_breakpoint_without_location
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (14 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 15/18] Disable copying for breakpoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-03 19:26   ` Pedro Alves
  2022-05-02 22:15 ` [PATCH 17/18] Add initializers to tracepoint Tom Tromey
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes init_raw_breakpoint_without_location, replacing it with a
constructor on 'breakpoint' itself.  The subclasses and callers are
all updated.
---
 gdb/ada-lang.c            |  8 ++--
 gdb/break-catch-exec.c    |  7 ++-
 gdb/break-catch-fork.c    |  8 ++--
 gdb/break-catch-load.c    |  8 ++--
 gdb/break-catch-sig.c     |  8 ++--
 gdb/break-catch-syscall.c |  7 +--
 gdb/break-catch-throw.c   | 12 +++--
 gdb/breakpoint.c          | 95 ++++++++++++++++++++-------------------
 gdb/breakpoint.h          | 24 +++++++---
 9 files changed, 105 insertions(+), 72 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b11808acb71..8333671c48b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12122,8 +12122,10 @@ class ada_catchpoint_location : public bp_location
 
 struct ada_catchpoint : public base_breakpoint
 {
-  explicit ada_catchpoint (enum ada_exception_catchpoint_kind kind)
-    : m_kind (kind)
+  ada_catchpoint (struct gdbarch *gdbarch_,
+		  enum ada_exception_catchpoint_kind kind)
+    : base_breakpoint (gdbarch_, bp_catchpoint),
+      m_kind (kind)
   {
   }
 
@@ -12757,7 +12759,7 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch,
   std::string addr_string;
   struct symtab_and_line sal = ada_exception_sal (ex_kind, &addr_string);
 
-  std::unique_ptr<ada_catchpoint> c (new ada_catchpoint (ex_kind));
+  std::unique_ptr<ada_catchpoint> c (new ada_catchpoint (gdbarch, ex_kind));
   init_ada_exception_breakpoint (c.get (), gdbarch, sal, addr_string.c_str (),
 				 tempflag, disabled, from_tty);
   c->excep_string = excep_string;
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index fbdc1c20e50..c828b50cc62 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -36,6 +36,11 @@
 
 struct exec_catchpoint : public breakpoint
 {
+  explicit exec_catchpoint (struct gdbarch *gdbarch)
+    : breakpoint (gdbarch, bp_catchpoint)
+  {
+  }
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -203,7 +208,7 @@ catch_exec_command_1 (const char *arg, int from_tty,
   if ((*arg != '\0') && !isspace (*arg))
     error (_("Junk at end of arguments."));
 
-  std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ());
+  std::unique_ptr<exec_catchpoint> c (new exec_catchpoint (gdbarch));
   init_catchpoint (c.get (), gdbarch, temp, cond_string);
 
   install_breakpoint (0, std::move (c), 1);
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 3ad4bafcf1c..05dd674a66c 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -34,8 +34,9 @@
 
 struct fork_catchpoint : public breakpoint
 {
-  explicit fork_catchpoint (bool is_vfork_)
-    : is_vfork (is_vfork_)
+  explicit fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_)
+    : breakpoint (gdbarch, bp_catchpoint),
+      is_vfork (is_vfork_)
   {
   }
 
@@ -185,7 +186,8 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
 				    bool temp, const char *cond_string,
 				    bool is_vfork)
 {
-  std::unique_ptr<fork_catchpoint> c (new fork_catchpoint (is_vfork));
+  std::unique_ptr<fork_catchpoint> c (new fork_catchpoint (gdbarch,
+							   is_vfork));
 
   init_catchpoint (c.get (), gdbarch, temp, cond_string);
 
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 3e3bed2f861..8579f4e3b23 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -35,8 +35,9 @@
 
 struct solib_catchpoint : public breakpoint
 {
-  solib_catchpoint (bool is_load_, const char *arg)
-    : is_load (is_load_),
+  solib_catchpoint (struct gdbarch *gdbarch, bool is_load_, const char *arg)
+    : breakpoint (gdbarch, bp_catchpoint),
+      is_load (is_load_),
       regex (arg == nullptr ? nullptr : make_unique_xstrdup (arg)),
       compiled (arg == nullptr
 		? nullptr
@@ -228,7 +229,8 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (*arg == '\0')
     arg = nullptr;
 
-  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (is_load, arg));
+  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (gdbarch,
+							     is_load, arg));
 
   init_catchpoint (c.get (), gdbarch, is_temp, NULL);
 
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 1c29a057d60..4430dd0b2b8 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -40,8 +40,10 @@
 
 struct signal_catchpoint : public breakpoint
 {
-  signal_catchpoint (std::vector<gdb_signal> &&sigs, bool catch_all_)
-    : signals_to_be_caught (std::move (sigs)),
+  signal_catchpoint (struct gdbarch *gdbarch, std::vector<gdb_signal> &&sigs,
+		     bool catch_all_)
+    : breakpoint (gdbarch, bp_catchpoint),
+      signals_to_be_caught (std::move (sigs)),
       catch_all (catch_all_)
   {
   }
@@ -323,7 +325,7 @@ create_signal_catchpoint (int tempflag, std::vector<gdb_signal> &&filter,
   struct gdbarch *gdbarch = get_current_arch ();
 
   std::unique_ptr<signal_catchpoint> c
-    (new signal_catchpoint (std::move (filter), catch_all));
+    (new signal_catchpoint (gdbarch, std::move (filter), catch_all));
   init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
 
   install_breakpoint (0, std::move (c), 1);
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index d25d7ba7c5e..5ed15ac8bf9 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -37,8 +37,9 @@
 
 struct syscall_catchpoint : public breakpoint
 {
-  explicit syscall_catchpoint (std::vector<int> &&calls)
-    : syscalls_to_be_caught (std::move (calls))
+  syscall_catchpoint (struct gdbarch *gdbarch, std::vector<int> &&calls)
+    : breakpoint (gdbarch, bp_catchpoint),
+      syscalls_to_be_caught (std::move (calls))
   {
   }
 
@@ -353,7 +354,7 @@ create_syscall_event_catchpoint (int tempflag, std::vector<int> &&filter)
   struct gdbarch *gdbarch = get_current_arch ();
 
   std::unique_ptr<syscall_catchpoint> c
-    (new syscall_catchpoint (std::move (filter)));
+    (new syscall_catchpoint (gdbarch, std::move (filter)));
   init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
 
   install_breakpoint (0, std::move (c), 1);
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 59e73da2c28..0237af7b2a7 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -67,9 +67,11 @@ static const struct exception_names exception_functions[] =
 
 struct exception_catchpoint : public base_breakpoint
 {
-  exception_catchpoint (enum exception_event_kind kind_,
+  exception_catchpoint (struct gdbarch *gdbarch,
+			enum exception_event_kind kind_,
 			std::string &&except_rx)
-    : kind (kind_),
+    : base_breakpoint (gdbarch, bp_catchpoint),
+      kind (kind_),
       exception_rx (std::move (except_rx)),
       pattern (exception_rx.empty ()
 	       ? nullptr
@@ -366,10 +368,12 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
 			  const char *cond_string,
 			  enum exception_event_kind ex_event, int from_tty)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+
   std::unique_ptr<exception_catchpoint> cp
-    (new exception_catchpoint (ex_event, std::move (except_rx)));
+    (new exception_catchpoint (gdbarch, ex_event, std::move (except_rx)));
 
-  init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string);
+  init_catchpoint (cp.get (), gdbarch, tempflag, cond_string);
 
   cp->re_set ();
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ef8a7001834..4c7542a52c8 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -258,6 +258,8 @@ static const struct breakpoint_ops tracepoint_probe_breakpoint_ops =
 /* The structure to be used in regular breakpoints.  */
 struct ordinary_breakpoint : public base_breakpoint
 {
+  using base_breakpoint::base_breakpoint;
+
   int resources_needed (const struct bp_location *) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
   void print_mention () const override;
@@ -267,6 +269,8 @@ struct ordinary_breakpoint : public base_breakpoint
 /* Internal breakpoints.  */
 struct internal_breakpoint : public base_breakpoint
 {
+  using base_breakpoint::base_breakpoint;
+
   void re_set () override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
@@ -276,6 +280,8 @@ struct internal_breakpoint : public base_breakpoint
 /* Momentary breakpoints.  */
 struct momentary_breakpoint : public base_breakpoint
 {
+  using base_breakpoint::base_breakpoint;
+
   void re_set () override;
   void check_status (struct bpstat *bs) override;
   enum print_stop_action print_it (const bpstat *bs) const override;
@@ -285,6 +291,8 @@ struct momentary_breakpoint : public base_breakpoint
 /* DPrintf breakpoints.  */
 struct dprintf_breakpoint : public ordinary_breakpoint
 {
+  using ordinary_breakpoint::ordinary_breakpoint;
+
   void re_set () override;
   int breakpoint_hit (const struct bp_location *bl,
 		      const address_space *aspace,
@@ -297,6 +305,11 @@ struct dprintf_breakpoint : public ordinary_breakpoint
 /* Ranged breakpoints.  */
 struct ranged_breakpoint : public ordinary_breakpoint
 {
+  explicit ranged_breakpoint (struct gdbarch *gdbarch)
+    : ordinary_breakpoint (gdbarch, bp_hardware_breakpoint)
+  {
+  }
+
   int breakpoint_hit (const struct bp_location *bl,
 		      const address_space *aspace,
 		      CORE_ADDR bp_addr,
@@ -312,6 +325,8 @@ struct ranged_breakpoint : public ordinary_breakpoint
 /* Static tracepoints with marker (`-m').  */
 struct static_marker_tracepoint : public tracepoint
 {
+  using tracepoint::tracepoint;
+
   std::vector<symtab_and_line> decode_location
        (struct event_location *location,
 	struct program_space *search_pspace) override;
@@ -1193,6 +1208,8 @@ check_no_tracepoint_commands (struct command_line *commands)
 
 struct longjmp_breakpoint : public momentary_breakpoint
 {
+  using momentary_breakpoint::momentary_breakpoint;
+
   ~longjmp_breakpoint () override;
 };
 
@@ -1219,7 +1236,7 @@ is_tracepoint (const struct breakpoint *b)
    TYPE.  */
 
 static std::unique_ptr<breakpoint>
-new_breakpoint_from_type (bptype type)
+new_breakpoint_from_type (struct gdbarch *gdbarch, bptype type)
 {
   breakpoint *b;
 
@@ -1227,21 +1244,21 @@ new_breakpoint_from_type (bptype type)
     {
     case bp_breakpoint:
     case bp_hardware_breakpoint:
-      b = new ordinary_breakpoint ();
+      b = new ordinary_breakpoint (gdbarch, type);
       break;
 
     case bp_fast_tracepoint:
     case bp_static_tracepoint:
     case bp_tracepoint:
-      b = new tracepoint ();
+      b = new tracepoint (gdbarch, type);
       break;
 
     case bp_static_marker_tracepoint:
-      b = new static_marker_tracepoint ();
+      b = new static_marker_tracepoint (gdbarch, type);
       break;
 
     case bp_dprintf:
-      b = new dprintf_breakpoint ();
+      b = new dprintf_breakpoint (gdbarch, type);
       break;
 
     case bp_overlay_event:
@@ -1251,12 +1268,12 @@ new_breakpoint_from_type (bptype type)
     case bp_thread_event:
     case bp_jit_event:
     case bp_shlib_event:
-      b = new internal_breakpoint ();
+      b = new internal_breakpoint (gdbarch, type);
       break;
 
     case bp_longjmp:
     case bp_exception:
-      b = new longjmp_breakpoint ();
+      b = new longjmp_breakpoint (gdbarch, type);
       break;
 
     case bp_watchpoint_scope:
@@ -1270,7 +1287,7 @@ new_breakpoint_from_type (bptype type)
     case bp_call_dummy:
     case bp_until:
     case bp_std_terminate:
-      b = new momentary_breakpoint ();
+      b = new momentary_breakpoint (gdbarch, type);
       break;
 
     default:
@@ -7215,20 +7232,6 @@ add_to_breakpoint_chain (std::unique_ptr<breakpoint> &&b)
   return result;
 }
 
-/* Initializes breakpoint B with type BPTYPE and no locations yet.  */
-
-static void
-init_raw_breakpoint_without_location (struct breakpoint *b,
-				      struct gdbarch *gdbarch,
-				      enum bptype bptype)
-{
-  b->type = bptype;
-  b->gdbarch = gdbarch;
-  b->language = current_language->la_language;
-  b->input_radix = input_radix;
-  b->related_breakpoint = b;
-}
-
 /* Helper to set_raw_breakpoint below.  Creates a breakpoint
    that has type BPTYPE and has no locations as yet.  */
 
@@ -7236,9 +7239,8 @@ static struct breakpoint *
 set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
 				     enum bptype bptype)
 {
-  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
+  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (gdbarch, bptype);
 
-  init_raw_breakpoint_without_location (b.get (), gdbarch, bptype);
   return add_to_breakpoint_chain (std::move (b));
 }
 
@@ -7303,11 +7305,9 @@ get_sal_arch (struct symtab_and_line sal)
    information regarding the creation of a new breakpoint.  */
 
 static void
-init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch,
-		     struct symtab_and_line sal, enum bptype bptype)
+init_raw_breakpoint (struct breakpoint *b, struct symtab_and_line sal,
+		     enum bptype bptype)
 {
-  init_raw_breakpoint_without_location (b, gdbarch, bptype);
-
   add_location_to_breakpoint (b, &sal);
 
   if (bptype != bp_catchpoint)
@@ -7339,9 +7339,9 @@ static struct breakpoint *
 set_raw_breakpoint (struct gdbarch *gdbarch,
 		    struct symtab_and_line sal, enum bptype bptype)
 {
-  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
+  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (gdbarch, bptype);
 
-  init_raw_breakpoint (b.get (), gdbarch, sal, bptype);
+  init_raw_breakpoint (b.get (), sal, bptype);
   return add_to_breakpoint_chain (std::move (b));
 }
 
@@ -7812,7 +7812,9 @@ init_catchpoint (struct breakpoint *b,
   symtab_and_line sal;
   sal.pspace = current_program_space;
 
-  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint);
+  /* This should already have been set in the constructor.  */
+  gdb_assert (b->type == bp_catchpoint);
+  init_raw_breakpoint (b, sal, bp_catchpoint);
 
   if (cond_string == nullptr)
     b->cond_string.reset ();
@@ -7944,9 +7946,8 @@ enable_breakpoints_after_startup (void)
 static struct breakpoint *
 new_single_step_breakpoint (int thread, struct gdbarch *gdbarch)
 {
-  std::unique_ptr<breakpoint> b (new momentary_breakpoint ());
-
-  init_raw_breakpoint_without_location (b.get (), gdbarch, bp_single_step);
+  std::unique_ptr<breakpoint> b (new momentary_breakpoint (gdbarch,
+							   bp_single_step));
 
   b->disposition = disp_donttouch;
   b->frame_id = null_frame_id;
@@ -8325,7 +8326,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 
       if (&sal == &sals[0])
 	{
-	  init_raw_breakpoint (b, gdbarch, sal, type);
+	  init_raw_breakpoint (b, sal, type);
 	  b->thread = thread;
 	  b->task = task;
 
@@ -8435,7 +8436,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
 		       int enabled, int internal, unsigned flags,
 		       int display_canonical)
 {
-  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (type);
+  std::unique_ptr<breakpoint> b = new_breakpoint_from_type (gdbarch, type);
 
   init_breakpoint_sal (b.get (), gdbarch,
 		       sals, std::move (location),
@@ -8984,9 +8985,8 @@ create_breakpoint (struct gdbarch *gdbarch,
     }
   else
     {
-      std::unique_ptr <breakpoint> b = new_breakpoint_from_type (type_wanted);
-
-      init_raw_breakpoint_without_location (b.get (), gdbarch, type_wanted);
+      std::unique_ptr <breakpoint> b = new_breakpoint_from_type (gdbarch,
+								 type_wanted);
       b->location = copy_event_location (location);
 
       if (parse_extra)
@@ -9432,9 +9432,8 @@ break_range_command (const char *arg, int from_tty)
     }
 
   /* Now set up the breakpoint.  */
-  std::unique_ptr<breakpoint> br (new ranged_breakpoint ());
-  init_raw_breakpoint (br.get (), get_current_arch (),
-		       sal_start, bp_hardware_breakpoint);
+  std::unique_ptr<breakpoint> br (new ranged_breakpoint (get_current_arch ()));
+  init_raw_breakpoint (br.get (), sal_start, bp_hardware_breakpoint);
   b = add_to_breakpoint_chain (std::move (br));
 
   set_breakpoint_count (breakpoint_count + 1);
@@ -9729,6 +9728,8 @@ watchpoint::explains_signal (enum gdb_signal sig)
 
 struct masked_watchpoint : public watchpoint
 {
+  using watchpoint::watchpoint;
+
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
@@ -10164,10 +10165,9 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
 
   std::unique_ptr<watchpoint> w;
   if (use_mask)
-    w.reset (new masked_watchpoint ());
+    w.reset (new masked_watchpoint (nullptr, bp_type));
   else
-    w.reset (new watchpoint ());
-  init_raw_breakpoint_without_location (w.get (), nullptr, bp_type);
+    w.reset (new watchpoint (nullptr, bp_type));
 
   w->thread = thread;
   w->task = task;
@@ -10620,7 +10620,7 @@ init_ada_exception_breakpoint (struct breakpoint *b,
 	 enough for now, though.  */
     }
 
-  init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint);
+  init_raw_breakpoint (b, sal, bp_catchpoint);
 
   b->enable_state = enabled ? bp_enabled : bp_disabled;
   b->disposition = tempflag ? disp_del : disp_donttouch;
@@ -12154,7 +12154,8 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
       event_location_up location
 	= copy_event_location (canonical->location.get ());
 
-      std::unique_ptr<tracepoint> tp (new tracepoint ());
+      std::unique_ptr<tracepoint> tp (new tracepoint (gdbarch,
+						      type_wanted));
       init_breakpoint_sal (tp.get (), gdbarch, lsal.sals[i],
 			   std::move (location), NULL,
 			   std::move (cond_string),
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 6923478f60a..356af45accd 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -620,7 +620,15 @@ using bp_location_range = next_range<bp_location>;
 
 struct breakpoint
 {
-  breakpoint () = default;
+  breakpoint (struct gdbarch *gdbarch_, enum bptype bptype)
+    : type (bptype),
+      gdbarch (gdbarch_),
+      language (current_language->la_language),
+      input_radix (::input_radix),
+      related_breakpoint (this)
+  {
+  }
+
   DISABLE_COPY_AND_ASSIGN (breakpoint);
 
   virtual ~breakpoint () = default;
@@ -784,11 +792,11 @@ struct breakpoint
   event_location_up location_range_end;
 
   /* Architecture we used to set the breakpoint.  */
-  struct gdbarch *gdbarch = NULL;
+  struct gdbarch *gdbarch;
   /* Language we used to set the breakpoint.  */
-  enum language language = language_unknown;
+  enum language language;
   /* Input radix we used to set the breakpoint.  */
-  int input_radix = 0;
+  int input_radix;
   /* String form of the breakpoint condition (malloc'd), or NULL if
      there is no condition.  */
   gdb::unique_xmalloc_ptr<char> cond_string;
@@ -801,7 +809,7 @@ struct breakpoint
      using watchpoints on local variables (might the concept of a
      related breakpoint be useful elsewhere, if not just call it the
      watchpoint_scope breakpoint or something like that.  FIXME).  */
-  breakpoint *related_breakpoint = NULL;
+  breakpoint *related_breakpoint;
 
   /* Thread number for thread-specific breakpoint, or -1 if don't
      care.  */
@@ -849,6 +857,8 @@ struct breakpoint
    breakpoints, etc.).  */
 struct base_breakpoint : public breakpoint
 {
+  using breakpoint::breakpoint;
+
   void re_set () override;
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
@@ -866,6 +876,8 @@ struct base_breakpoint : public breakpoint
 
 struct watchpoint : public breakpoint
 {
+  using breakpoint::breakpoint;
+
   void re_set () override;
   int insert_location (struct bp_location *) override;
   int remove_location (struct bp_location *,
@@ -959,6 +971,8 @@ extern bool is_exception_catchpoint (breakpoint *bp);
 
 struct tracepoint : public breakpoint
 {
+  using breakpoint::breakpoint;
+
   void re_set () override;
   int breakpoint_hit (const struct bp_location *bl,
 		      const address_space *aspace, CORE_ADDR bp_addr,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 17/18] Add initializers to tracepoint
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (15 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 16/18] Remove init_raw_breakpoint_without_location Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
  2022-05-03 19:33 ` [PATCH 00/18] Minor breakpoint cleanups Pedro Alves
  18 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds some initializers to tracepoint.  I think right now these
may not be needed, due to obscure rules about zero initialization.
However, this will change in the next patch, and anyway it is clearer
to be explicit.
---
 gdb/breakpoint.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 356af45accd..d244e8daec0 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -987,18 +987,18 @@ struct tracepoint : public breakpoint
 
   /* Number of times this tracepoint should single-step and collect
      additional data.  */
-  long step_count;
+  long step_count = 0;
 
   /* Number of times this tracepoint should be hit before
      disabling/ending.  */
-  int pass_count;
+  int pass_count = 0;
 
   /* The number of the tracepoint on the target.  */
-  int number_on_target;
+  int number_on_target = 0;
 
   /* The total space taken by all the trace frames for this
      tracepoint.  */
-  ULONGEST traceframe_usage;
+  ULONGEST traceframe_usage = 0;
 
   /* The static tracepoint marker id, if known.  */
   std::string static_trace_marker_id;
@@ -1009,7 +1009,7 @@ struct tracepoint : public breakpoint
      the array of markers we found for the given marker ID for which
      this static tracepoint corresponds.  When resetting breakpoints,
      we will use this index to try to find the same marker again.  */
-  int static_trace_marker_id_idx;
+  int static_trace_marker_id_idx = 0;
 };
 
 \f
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 18/18] Introduce catchpoint class
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (16 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 17/18] Add initializers to tracepoint Tom Tromey
@ 2022-05-02 22:15 ` Tom Tromey
  2022-05-03 19:32   ` Pedro Alves
  2022-05-07  2:19   ` Simon Marchi
  2022-05-03 19:33 ` [PATCH 00/18] Minor breakpoint cleanups Pedro Alves
  18 siblings, 2 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-02 22:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a catchpoint class that is used as the base class for
all catchpoints.  init_catchpoint is rewritten to be a constructor
instead.

This changes the hierarchy a little -- some catchpoints now inherit
from base_breakpoint whereas previously they did not.  This isn't a
problem, as long as re_set is redefined in catchpoint.
---
 gdb/break-catch-exec.c    | 10 +++++-----
 gdb/break-catch-fork.c    | 13 ++++++-------
 gdb/break-catch-load.c    | 13 +++++++------
 gdb/break-catch-sig.c     | 10 +++++-----
 gdb/break-catch-syscall.c |  1 -
 gdb/break-catch-throw.c   | 10 +++++-----
 gdb/breakpoint.c          | 19 +++++++------------
 gdb/breakpoint.h          | 22 ++++++++++++++--------
 8 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index c828b50cc62..07417ee499c 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -34,10 +34,10 @@
    A breakpoint is really of this type iff its ops pointer points to
    CATCH_EXEC_BREAKPOINT_OPS.  */
 
-struct exec_catchpoint : public breakpoint
+struct exec_catchpoint : public catchpoint
 {
-  explicit exec_catchpoint (struct gdbarch *gdbarch)
-    : breakpoint (gdbarch, bp_catchpoint)
+  exec_catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string)
+    : catchpoint (gdbarch, temp, cond_string)
   {
   }
 
@@ -208,8 +208,8 @@ catch_exec_command_1 (const char *arg, int from_tty,
   if ((*arg != '\0') && !isspace (*arg))
     error (_("Junk at end of arguments."));
 
-  std::unique_ptr<exec_catchpoint> c (new exec_catchpoint (gdbarch));
-  init_catchpoint (c.get (), gdbarch, temp, cond_string);
+  std::unique_ptr<exec_catchpoint> c
+    (new exec_catchpoint (gdbarch, temp, cond_string));
 
   install_breakpoint (0, std::move (c), 1);
 }
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index 05dd674a66c..1f8deec6a62 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -32,10 +32,11 @@
    catchpoint.  A breakpoint is really of this type iff its ops pointer points
    to CATCH_FORK_BREAKPOINT_OPS.  */
 
-struct fork_catchpoint : public breakpoint
+struct fork_catchpoint : public catchpoint
 {
-  explicit fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_)
-    : breakpoint (gdbarch, bp_catchpoint),
+  fork_catchpoint (struct gdbarch *gdbarch, bool temp,
+		   const char *cond_string, bool is_vfork_)
+    : catchpoint (gdbarch, temp, cond_string),
       is_vfork (is_vfork_)
   {
   }
@@ -186,10 +187,8 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
 				    bool temp, const char *cond_string,
 				    bool is_vfork)
 {
-  std::unique_ptr<fork_catchpoint> c (new fork_catchpoint (gdbarch,
-							   is_vfork));
-
-  init_catchpoint (c.get (), gdbarch, temp, cond_string);
+  std::unique_ptr<fork_catchpoint> c
+    (new fork_catchpoint (gdbarch, temp, cond_string, is_vfork));
 
   install_breakpoint (0, std::move (c), 1);
 }
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 8579f4e3b23..617ee2b694d 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -33,10 +33,12 @@
    A breakpoint is really of this type iff its ops pointer points to
    CATCH_SOLIB_BREAKPOINT_OPS.  */
 
-struct solib_catchpoint : public breakpoint
+struct solib_catchpoint : public catchpoint
 {
-  solib_catchpoint (struct gdbarch *gdbarch, bool is_load_, const char *arg)
-    : breakpoint (gdbarch, bp_catchpoint),
+  solib_catchpoint (struct gdbarch *gdbarch, bool temp,
+		    const char *cond_string,
+		    bool is_load_, const char *arg)
+    : catchpoint (gdbarch, temp, cond_string),
       is_load (is_load_),
       regex (arg == nullptr ? nullptr : make_unique_xstrdup (arg)),
       compiled (arg == nullptr
@@ -229,11 +231,10 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (*arg == '\0')
     arg = nullptr;
 
-  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (gdbarch,
+  std::unique_ptr<solib_catchpoint> c (new solib_catchpoint (gdbarch, is_temp,
+							     nullptr,
 							     is_load, arg));
 
-  init_catchpoint (c.get (), gdbarch, is_temp, NULL);
-
   c->enable_state = enabled ? bp_enabled : bp_disabled;
 
   install_breakpoint (0, std::move (c), 1);
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 4430dd0b2b8..57a6255dc33 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -38,11 +38,12 @@
 /* An instance of this type is used to represent a signal
    catchpoint.  */
 
-struct signal_catchpoint : public breakpoint
+struct signal_catchpoint : public catchpoint
 {
-  signal_catchpoint (struct gdbarch *gdbarch, std::vector<gdb_signal> &&sigs,
+  signal_catchpoint (struct gdbarch *gdbarch, bool temp,
+		     std::vector<gdb_signal> &&sigs,
 		     bool catch_all_)
-    : breakpoint (gdbarch, bp_catchpoint),
+    : catchpoint (gdbarch, temp, nullptr),
       signals_to_be_caught (std::move (sigs)),
       catch_all (catch_all_)
   {
@@ -325,8 +326,7 @@ create_signal_catchpoint (int tempflag, std::vector<gdb_signal> &&filter,
   struct gdbarch *gdbarch = get_current_arch ();
 
   std::unique_ptr<signal_catchpoint> c
-    (new signal_catchpoint (gdbarch, std::move (filter), catch_all));
-  init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
+    (new signal_catchpoint (gdbarch, tempflag, std::move (filter), catch_all));
 
   install_breakpoint (0, std::move (c), 1);
 }
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 5ed15ac8bf9..d79ced47a12 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -355,7 +355,6 @@ create_syscall_event_catchpoint (int tempflag, std::vector<int> &&filter)
 
   std::unique_ptr<syscall_catchpoint> c
     (new syscall_catchpoint (gdbarch, std::move (filter)));
-  init_catchpoint (c.get (), gdbarch, tempflag, nullptr);
 
   install_breakpoint (0, std::move (c), 1);
 }
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 0237af7b2a7..f15fa531519 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -65,12 +65,13 @@ static const struct exception_names exception_functions[] =
 
 /* The type of an exception catchpoint.  */
 
-struct exception_catchpoint : public base_breakpoint
+struct exception_catchpoint : public catchpoint
 {
   exception_catchpoint (struct gdbarch *gdbarch,
+			bool temp, const char *cond_string,
 			enum exception_event_kind kind_,
 			std::string &&except_rx)
-    : base_breakpoint (gdbarch, bp_catchpoint),
+    : catchpoint (gdbarch, temp, cond_string),
       kind (kind_),
       exception_rx (std::move (except_rx)),
       pattern (exception_rx.empty ()
@@ -371,9 +372,8 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
   struct gdbarch *gdbarch = get_current_arch ();
 
   std::unique_ptr<exception_catchpoint> cp
-    (new exception_catchpoint (gdbarch, ex_event, std::move (except_rx)));
-
-  init_catchpoint (cp.get (), gdbarch, tempflag, cond_string);
+    (new exception_catchpoint (gdbarch, tempflag, cond_string,
+			       ex_event, std::move (except_rx)));
 
   cp->re_set ();
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 4c7542a52c8..9abc1443d96 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7804,23 +7804,18 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
 
 /* See breakpoint.h.  */
 
-void
-init_catchpoint (struct breakpoint *b,
-		 struct gdbarch *gdbarch, bool temp,
-		 const char *cond_string)
+catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp,
+			const char *cond_string_)
+  : base_breakpoint (gdbarch, bp_catchpoint)
 {
   symtab_and_line sal;
   sal.pspace = current_program_space;
 
-  /* This should already have been set in the constructor.  */
-  gdb_assert (b->type == bp_catchpoint);
-  init_raw_breakpoint (b, sal, bp_catchpoint);
+  init_raw_breakpoint (this, sal, bp_catchpoint);
 
-  if (cond_string == nullptr)
-    b->cond_string.reset ();
-  else
-    b->cond_string = make_unique_xstrdup (cond_string);
-  b->disposition = temp ? disp_del : disp_donttouch;
+  if (cond_string_ != nullptr)
+    cond_string = make_unique_xstrdup (cond_string_);
+  disposition = temp ? disp_del : disp_donttouch;
 }
 
 void
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index d244e8daec0..ac738fd7c2d 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1012,6 +1012,20 @@ struct tracepoint : public breakpoint
   int static_trace_marker_id_idx = 0;
 };
 
+/* The base class for catchpoints.  */
+
+struct catchpoint : public base_breakpoint
+{
+  /* If TEMP is true, then make the breakpoint temporary.  If
+     COND_STRING is not NULL, then store it in the breakpoint.  */
+  catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string);
+
+  void re_set () override
+  {
+    /* For catchpoints, the default is to do nothing.  */
+  }
+};
+
 \f
 /* The following stuff is an abstract data type "bpstat" ("breakpoint
    status").  This provides the ability to determine whether we have
@@ -1440,14 +1454,6 @@ extern void
 				 int enabled,
 				 int from_tty);
 
-/* Initialize a new breakpoint of the bp_catchpoint kind.  If TEMP
-   is true, then make the breakpoint temporary.  If COND_STRING is
-   not NULL, then store it in the breakpoint.  */
-
-extern void init_catchpoint (struct breakpoint *b,
-			     struct gdbarch *gdbarch, bool temp,
-			     const char *cond_string);
-
 /* Add breakpoint B on the breakpoint list, and notify the user, the
    target and breakpoint_created observers of its existence.  If
    INTERNAL is non-zero, the breakpoint number will be allocated from
-- 
2.34.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 16/18] Remove init_raw_breakpoint_without_location
  2022-05-02 22:15 ` [PATCH 16/18] Remove init_raw_breakpoint_without_location Tom Tromey
@ 2022-05-03 19:26   ` Pedro Alves
  2022-05-03 22:43     ` Tom Tromey
  0 siblings, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2022-05-03 19:26 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2022-05-02 23:15, Tom Tromey wrote:
> --- a/gdb/break-catch-fork.c
> +++ b/gdb/break-catch-fork.c
> @@ -34,8 +34,9 @@
>  
>  struct fork_catchpoint : public breakpoint
>  {
> -  explicit fork_catchpoint (bool is_vfork_)
> -    : is_vfork (is_vfork_)
> +  explicit fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_)
> +    : breakpoint (gdbarch, bp_catchpoint),
> +      is_vfork (is_vfork_)
>    {
>    }

This one could drop the "explicit" too.  (You did that to other types.)

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
@ 2022-05-03 19:32   ` Pedro Alves
  2022-05-03 23:02     ` Tom Tromey
  2022-05-07  2:19   ` Simon Marchi
  1 sibling, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2022-05-03 19:32 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2022-05-02 23:15, Tom Tromey wrote:
> This introduces a catchpoint class that is used as the base class for
> all catchpoints.  init_catchpoint is rewritten to be a constructor
> instead.
> 
> This changes the hierarchy a little -- some catchpoints now inherit
> from base_breakpoint whereas previously they did not.  This isn't a
> problem, as long as re_set is redefined in catchpoint.

This hierarchy change stretches things a bit.  By inheriting base_breakpoint,
this is saying that catchpoints is-a software/hardware breakpoint, while
most catchpoints are not.  Catchpoints are exactly the event points that
are _not_ some PC location that execution traps at.  Catchpoints that end up being
a breakpoint under the hood, like exception_catchpoint, I'd say should be more like
as-a base_breakpoint than is-a base_breakpoint, though that isn't very nicely
expressible doable today, I think.  Alternatively, we could have two different base classes,
one for catchpoints (signal, syscalls, etc.), and another for breakpoint-like catchpoints.

But I suppose in the end either change wouldn't simplify much, if anything.

So despite my eyebrow raising, I'm OK with your patch.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/18] Minor breakpoint cleanups
  2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
                   ` (17 preceding siblings ...)
  2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
@ 2022-05-03 19:33 ` Pedro Alves
  2022-05-06 18:03   ` Tom Tromey
  18 siblings, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2022-05-03 19:33 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2022-05-02 23:15, Tom Tromey wrote:
> Now that the C++-fication of breakpoints has gone in, here are some
> patches to tidy a few breakpoint APIs -- more use of bool and of
> const; constructors for various subclasses; and some init_* function
> deletion.
> 
> It would be nice to remove the remaining init_* functions.  There's
> also some other worthwhile cleanups, like moving some fields into
> subclasses (maybe related_breakpoint?), or removing the "pure
> virtual"s.  I haven't really attempted any of these.
> 
> Regression tested on x86-64 Fedora 34.  Let me know what you think.
> 

I read the series, I sent a couple replies, but overall it looks
good to me.  Please push.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 16/18] Remove init_raw_breakpoint_without_location
  2022-05-03 19:26   ` Pedro Alves
@ 2022-05-03 22:43     ` Tom Tromey
  0 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-03 22:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

>> struct fork_catchpoint : public breakpoint
>> {
>> -  explicit fork_catchpoint (bool is_vfork_)
>> -    : is_vfork (is_vfork_)
>> +  explicit fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_)
>> +    : breakpoint (gdbarch, bp_catchpoint),
>> +      is_vfork (is_vfork_)
>> {
>> }

Pedro> This one could drop the "explicit" too.  (You did that to other
Pedro> types.)

I fixed this.

Tom

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-03 19:32   ` Pedro Alves
@ 2022-05-03 23:02     ` Tom Tromey
  2022-05-04 11:37       ` Pedro Alves
  0 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2022-05-03 23:02 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>> This changes the hierarchy a little -- some catchpoints now inherit
>> from base_breakpoint whereas previously they did not.  This isn't a
>> problem, as long as re_set is redefined in catchpoint.

Pedro> This hierarchy change stretches things a bit.  By inheriting
Pedro> base_breakpoint, this is saying that catchpoints is-a
Pedro> software/hardware breakpoint, while most catchpoints are not.
Pedro> Catchpoints are exactly the event points that are _not_ some PC
Pedro> location that execution traps at.
...

Pedro> But I suppose in the end either change wouldn't simplify much, if anything.

Well, another option might be to add another constructor to breakpoint
itself.  Then the hierarchy wouldn't have to change, just which
constructors are visible.

It seems a little weird that these all call init_raw_breakpoint, which
calls add_location_to_breakpoint.  Maybe I need to look into that.

Tom

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-03 23:02     ` Tom Tromey
@ 2022-05-04 11:37       ` Pedro Alves
  0 siblings, 0 replies; 31+ messages in thread
From: Pedro Alves @ 2022-05-04 11:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2022-05-04 00:02, Tom Tromey wrote:
>>> This changes the hierarchy a little -- some catchpoints now inherit
>>> from base_breakpoint whereas previously they did not.  This isn't a
>>> problem, as long as re_set is redefined in catchpoint.
> 
> Pedro> This hierarchy change stretches things a bit.  By inheriting
> Pedro> base_breakpoint, this is saying that catchpoints is-a
> Pedro> software/hardware breakpoint, while most catchpoints are not.
> Pedro> Catchpoints are exactly the event points that are _not_ some PC
> Pedro> location that execution traps at.
> ...
> 
> Pedro> But I suppose in the end either change wouldn't simplify much, if anything.
> 
> Well, another option might be to add another constructor to breakpoint
> itself.  Then the hierarchy wouldn't have to change, just which
> constructors are visible.
> 
> It seems a little weird that these all call init_raw_breakpoint, which
> calls add_location_to_breakpoint.  Maybe I need to look into that.

Yeah, agreed on init_raw_breakpoint.  AMD's GPU backend needs a custom
internal breakpoint for shared library events, and I need to rework how that's
created after the breakpoints C++-ification.  Yesterday I was looking at
it, and the current WIP prototype I was going for (on top of current master)
is something was like this:

 struct amd_dbgapi_target_solib_breakpoint : public base_breakpoint
 {
   amd_dbgapi_target_solib_breakpoint (struct gdbarch *gdbarch_, CORE_ADDR address)
     : base_breakpoint ()
   {
     /* Should be a ctor.  */

     symtab_and_line sal;
     sal.pc = address;
     sal.section = find_pc_overlay (sal.pc);
     sal.pspace = current_program_space;

     init_raw_breakpoint (this, gdbarch_, sal, bp_breakpoint, nullptr);
   }

   // These do custom things.
   void re_set () override;
   void check_status (struct bpstat *bs) override;
 };

....

    std::unique_ptr<breakpoint> b_up
      (new amd_dbgapi_target_solib_breakpoint (section->objfile->arch (),
					       address));

    install_breakpoint (true, std::move (b_up), 1);

...

I.e., I exported init_raw_breakpoint, but I think it should be a ctor instead.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 00/18] Minor breakpoint cleanups
  2022-05-03 19:33 ` [PATCH 00/18] Minor breakpoint cleanups Pedro Alves
@ 2022-05-06 18:03   ` Tom Tromey
  0 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2022-05-06 18:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

Pedro> I read the series, I sent a couple replies, but overall it looks
Pedro> good to me.  Please push.

Sorry about the delay, I'm doing it now.

Tom

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
  2022-05-03 19:32   ` Pedro Alves
@ 2022-05-07  2:19   ` Simon Marchi
  2022-05-07 16:07     ` Tom Tromey
  1 sibling, 1 reply; 31+ messages in thread
From: Simon Marchi @ 2022-05-07  2:19 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches



On 2022-05-02 18:15, Tom Tromey wrote:
> This introduces a catchpoint class that is used as the base class for
> all catchpoints.  init_catchpoint is rewritten to be a constructor
> instead.
> 
> This changes the hierarchy a little -- some catchpoints now inherit
> from base_breakpoint whereas previously they did not.  This isn't a
> problem, as long as re_set is redefined in catchpoint.

Hi Tom,

This causes some regressions:

$ ./gdb -q --data-directory=data-directory -nx -ex "catch syscall"
/home/smarchi/src/binutils-gdb/gdb/break-catch-syscall.c:295:34: runtime error: member access within null pointer of type 'struct bp_location'

The affected tests are

gdb.base/catch-syscall.exp
gdb.guile/scm-breakpoint.exp
gdb.mi/mi-breakpoint-changed.exp

Simon

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-07  2:19   ` Simon Marchi
@ 2022-05-07 16:07     ` Tom Tromey
  2022-05-07 19:31       ` Simon Marchi
  0 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2022-05-07 16:07 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

Simon> This causes some regressions:

It turns out my test-result comparison script doesn't really note gdb
crashes.  They probably show up under "missing tests" -- but I've gotten
a bit too used to just ignoring that.

It would be better if a crash always showed up as a FAIL.

Anyway... still my fault, I'm not trying to shift the blame.

I'll send the fix shortly.

Tom

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-07 16:07     ` Tom Tromey
@ 2022-05-07 19:31       ` Simon Marchi
  2022-05-16 18:22         ` Tom Tromey
  0 siblings, 1 reply; 31+ messages in thread
From: Simon Marchi @ 2022-05-07 19:31 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches



On 2022-05-07 12:07, Tom Tromey wrote:
> Simon> This causes some regressions:
> 
> It turns out my test-result comparison script doesn't really note gdb
> crashes.  They probably show up under "missing tests" -- but I've gotten
> a bit too used to just ignoring that.
> 
> It would be better if a crash always showed up as a FAIL.
> 
> Anyway... still my fault, I'm not trying to shift the blame.
> 
> I'll send the fix shortly.
> 
> Tom

In this case, they appear as "UNRESOLVED":

UNRESOLVED: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall

Does your script consider those as a failure?

Simon

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-07 19:31       ` Simon Marchi
@ 2022-05-16 18:22         ` Tom Tromey
  2022-05-16 19:29           ` Simon Marchi
  0 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2022-05-16 18:22 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>> It turns out my test-result comparison script doesn't really note gdb
>> crashes.  They probably show up under "missing tests" -- but I've gotten
>> a bit too used to just ignoring that.
>> 
>> It would be better if a crash always showed up as a FAIL.

Simon> In this case, they appear as "UNRESOLVED":

Simon> UNRESOLVED: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall

Simon> Does your script consider those as a failure?

No... does this show up in the gdb.sum file?

FWIW my script is here: https://github.com/tromey/gdb-testing-scripts
I'm curious what other people use.  Maybe I can just switch scripts.

Tom

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 18/18] Introduce catchpoint class
  2022-05-16 18:22         ` Tom Tromey
@ 2022-05-16 19:29           ` Simon Marchi
  0 siblings, 0 replies; 31+ messages in thread
From: Simon Marchi @ 2022-05-16 19:29 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches



On 2022-05-16 14:22, Tom Tromey wrote:
>>> It turns out my test-result comparison script doesn't really note gdb
>>> crashes.  They probably show up under "missing tests" -- but I've gotten
>>> a bit too used to just ignoring that.
>>>
>>> It would be better if a crash always showed up as a FAIL.
> 
> Simon> In this case, they appear as "UNRESOLVED":
> 
> Simon> UNRESOLVED: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall
> 
> Simon> Does your script consider those as a failure?
> 
> No... does this show up in the gdb.sum file?

In theory, yes.

> FWIW my script is here: https://github.com/tromey/gdb-testing-scripts
> I'm curious what other people use.  Maybe I can just switch scripts.

Now I use a CI job that filters out a list of known failures.  That list
is only allowed to shrink, which is why I'm bugging people when I see new
failures, it makes my CI job fail :).

Simon

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2022-05-16 19:29 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
2022-05-02 22:15 ` [PATCH 01/18] Change print_recreate_thread to a method Tom Tromey
2022-05-02 22:15 ` [PATCH 02/18] Remove breakpoint::ops Tom Tromey
2022-05-02 22:15 ` [PATCH 03/18] Boolify breakpoint::explains_signal Tom Tromey
2022-05-02 22:15 ` [PATCH 04/18] Move works_in_software_mode to watchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 05/18] Constify breakpoint::print_it Tom Tromey
2022-05-02 22:15 ` [PATCH 06/18] Constify breakpoint::print_one Tom Tromey
2022-05-02 22:15 ` [PATCH 07/18] Constify breakpoint::print_mention Tom Tromey
2022-05-02 22:15 ` [PATCH 08/18] Constify breakpoint::print_recreate Tom Tromey
2022-05-02 22:15 ` [PATCH 09/18] Remove unnecessary line from catch_exec_command_1 Tom Tromey
2022-05-02 22:15 ` [PATCH 10/18] Add constructor to fork_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 11/18] Add constructor to solib_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 12/18] Add constructor to signal_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 13/18] Add constructor to syscall_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 14/18] Add constructor to exception_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 15/18] Disable copying for breakpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 16/18] Remove init_raw_breakpoint_without_location Tom Tromey
2022-05-03 19:26   ` Pedro Alves
2022-05-03 22:43     ` Tom Tromey
2022-05-02 22:15 ` [PATCH 17/18] Add initializers to tracepoint Tom Tromey
2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
2022-05-03 19:32   ` Pedro Alves
2022-05-03 23:02     ` Tom Tromey
2022-05-04 11:37       ` Pedro Alves
2022-05-07  2:19   ` Simon Marchi
2022-05-07 16:07     ` Tom Tromey
2022-05-07 19:31       ` Simon Marchi
2022-05-16 18:22         ` Tom Tromey
2022-05-16 19:29           ` Simon Marchi
2022-05-03 19:33 ` [PATCH 00/18] Minor breakpoint cleanups Pedro Alves
2022-05-06 18:03   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).