]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: make install_breakpoint return a non-owning reference
authorPedro Alves <pedro@palves.net>
Fri, 23 Sep 2022 15:48:11 +0000 (11:48 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 2 Feb 2023 15:02:33 +0000 (10:02 -0500)
A following patch will want to install a breakpoint and then keep a
non-owning reference to it.  Make install_breakpoint return a non-owning
reference, to make that easy.

Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I2e8106a784021ff276ce251e24708cbdccc2d479
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/breakpoint.c
gdb/breakpoint.h

index 00cc2ab401c8de1e58afcd8d4b6cc1c6d034f05f..e25c5889ec4fb450d0b5331a79864e004ba7e517 100644 (file)
@@ -7956,7 +7956,7 @@ catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp,
   pspace = current_program_space;
 }
 
-void
+breakpoint *
 install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_gll)
 {
   breakpoint *b = add_to_breakpoint_chain (std::move (arg));
@@ -7969,6 +7969,8 @@ install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_
 
   if (update_gll)
     update_global_location_list (UGLL_MAY_INSERT);
+
+  return b;
 }
 
 static int
index 399bd03797750b412f9bb5f6800f1683ad3b7ab2..352e846853717b8dc34b813401a83da251b2a0ce 100644 (file)
@@ -1484,10 +1484,12 @@ extern void
    target and breakpoint_created observers of its existence.  If
    INTERNAL is non-zero, the breakpoint number will be allocated from
    the internal breakpoint count.  If UPDATE_GLL is non-zero,
-   update_global_location_list will be called.  */
+   update_global_location_list will be called.
 
-extern void install_breakpoint (int internal, std::unique_ptr<breakpoint> &&b,
-                               int update_gll);
+   Takes ownership of B, and returns a non-owning reference to it.  */
+
+extern breakpoint *install_breakpoint
+  (int internal, std::unique_ptr<breakpoint> &&b, int update_gll);
 
 /* Returns the breakpoint ops appropriate for use with with LOCSPEC
    and according to IS_TRACEPOINT.  Use this to ensure, for example,