Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / breakpoint.h
index b13522e236b53169eadf94a8e8998acfb48d23fa..c30656971bb71d09e30ba5e6034447c63cab1243 100644 (file)
@@ -1,5 +1,5 @@
 /* Data structures associated with breakpoints in GDB.
-   Copyright (C) 1992-2020 Free Software Foundation, Inc.
+   Copyright (C) 1992-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -29,6 +29,7 @@
 #include <vector>
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
+#include "gdbsupport/refcounted-object.h"
 #include "cli/cli-script.h"
 
 struct block;
@@ -311,7 +312,7 @@ enum bp_loc_type
   bp_loc_other                 /* Miscellaneous...  */
 };
 
-class bp_location
+class bp_location : public refcounted_object
 {
 public:
   bp_location () = default;
@@ -329,9 +330,6 @@ public:
      the same parent breakpoint.  */
   bp_location *next = NULL;
 
-  /* The reference count.  */
-  int refc = 0;
-
   /* Type of this breakpoint location.  */
   bp_loc_type loc_type {};
 
@@ -510,6 +508,27 @@ public:
   const struct objfile *objfile = NULL;
 };
 
+/* A policy class for bp_location reference counting.  */
+struct bp_location_ref_policy
+{
+  static void incref (bp_location *loc)
+  {
+    loc->incref ();
+  }
+
+  static void decref (bp_location *loc)
+  {
+    gdb_assert (loc->refcount () > 0);
+    loc->decref ();
+    if (loc->refcount () == 0)
+      delete loc;
+  }
+};
+
+/* A gdb::ref_ptr that has been specialized for bp_location.  */
+typedef gdb::ref_ptr<bp_location, bp_location_ref_policy>
+     bp_location_ref_ptr;
+
 /* The possible return values for print_bpstat, print_it_normal,
    print_it_done, print_it_noop.  */
 enum print_stop_action
@@ -1130,7 +1149,6 @@ struct bpstats
   {
     bpstats ();
     bpstats (struct bp_location *bl, bpstat **bs_link_pointer);
-    ~bpstats ();
 
     bpstats (const bpstats &);
     bpstats &operator= (const bpstats &) = delete;
@@ -1155,7 +1173,7 @@ struct bpstats
        What this means is that we should not (in most cases) follow
        the `bpstat->bp_location->owner' link, but instead use the
        `breakpoint_at' field below.  */
-    struct bp_location *bp_location_at;
+    bp_location_ref_ptr bp_location_at;
 
     /* Breakpoint that caused the stop.  This is nullified if the
        breakpoint ends up being deleted.  See comments on
@@ -1300,9 +1318,9 @@ const char *bpdisp_text (enum bpdisp disp);
 
 extern void break_command (const char *, int);
 
-extern void watch_command_wrapper (const char *, int, int);
-extern void awatch_command_wrapper (const char *, int, int);
-extern void rwatch_command_wrapper (const char *, int, int);
+extern void watch_command_wrapper (const char *, int, bool);
+extern void awatch_command_wrapper (const char *, int, bool);
+extern void rwatch_command_wrapper (const char *, int, bool);
 extern void tbreak_command (const char *, int);
 
 extern struct breakpoint_ops base_breakpoint_ops;
This page took 0.024705 seconds and 4 git commands to generate.