public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Remove breakpoint ops initialization
Date: Fri, 29 Apr 2022 22:24:36 +0000 (GMT)	[thread overview]
Message-ID: <20220429222436.D31FA3858405@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8613a476b198e67ecd645cf74befe9a0dad255b3

commit 8613a476b198e67ecd645cf74befe9a0dad255b3
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jan 16 19:23:48 2022 -0700

    Remove breakpoint ops initialization
    
    initialize_breakpoint_ops does not do much any more, so remove it in
    favor of statically-initialize objects.

Diff:
---
 gdb/breakpoint.c | 70 +++++++++++++++++++++++++-------------------------------
 gdb/breakpoint.h |  2 --
 2 files changed, 31 insertions(+), 41 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0e59a1ab3aa..b6541b5bdb7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -234,11 +234,34 @@ static bool is_masked_watchpoint (const struct breakpoint *b);
 
 static int strace_marker_p (struct breakpoint *b);
 
+static void bkpt_probe_create_sals_from_location
+     (struct event_location *location,
+      struct linespec_result *canonical,
+      enum bptype type_wanted);
+static void tracepoint_probe_create_sals_from_location
+     (struct event_location *location,
+      struct linespec_result *canonical,
+      enum bptype type_wanted);
+
+struct breakpoint_ops base_breakpoint_ops =
+{
+  create_sals_from_location_default,
+  create_breakpoints_sal_default,
+};
+
 /* Breakpoints set on probes.  */
-static struct breakpoint_ops bkpt_probe_breakpoint_ops;
+static struct breakpoint_ops bkpt_probe_breakpoint_ops =
+{
+  bkpt_probe_create_sals_from_location,
+  create_breakpoints_sal_default,
+};
 
 /* Tracepoints set on probes.  */
-static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
+static struct breakpoint_ops tracepoint_probe_breakpoint_ops =
+{
+  tracepoint_probe_create_sals_from_location,
+  create_breakpoints_sal_default,
+};
 
 /* The structure to be used in regular breakpoints.  */
 struct ordinary_breakpoint : public base_breakpoint
@@ -11608,12 +11631,6 @@ breakpoint::decode_location (struct event_location *location,
   internal_error_pure_virtual_called ();
 }
 
-struct breakpoint_ops base_breakpoint_ops =
-{
-  create_sals_from_location_default,
-  create_breakpoints_sal_default,
-};
-
 /* Default breakpoint_ops methods.  */
 
 void
@@ -12227,7 +12244,12 @@ static_marker_tracepoint::decode_location (struct event_location *location,
     error (_("marker %s not found"), static_trace_marker_id.c_str ());
 }
 
-static struct breakpoint_ops strace_marker_breakpoint_ops;
+/* Static tracepoints with marker (`-m').  */
+static struct breakpoint_ops strace_marker_breakpoint_ops =
+{
+  strace_marker_create_sals_from_location,
+  strace_marker_create_breakpoints_sal,
+};
 
 static int
 strace_marker_p (struct breakpoint *b)
@@ -14344,34 +14366,6 @@ breakpoint_free_objfile (struct objfile *objfile)
       loc->symtab = NULL;
 }
 
-void
-initialize_breakpoint_ops (void)
-{
-  static int initialized = 0;
-
-  struct breakpoint_ops *ops;
-
-  if (initialized)
-    return;
-  initialized = 1;
-
-  /* Probe breakpoints.  */
-  ops = &bkpt_probe_breakpoint_ops;
-  *ops = base_breakpoint_ops;
-  ops->create_sals_from_location = bkpt_probe_create_sals_from_location;
-
-  /* Probe tracepoints.  */
-  ops = &tracepoint_probe_breakpoint_ops;
-  *ops = base_breakpoint_ops;
-  ops->create_sals_from_location = tracepoint_probe_create_sals_from_location;
-
-  /* Static tracepoints with marker (`-m').  */
-  ops = &strace_marker_breakpoint_ops;
-  *ops = base_breakpoint_ops;
-  ops->create_sals_from_location = strace_marker_create_sals_from_location;
-  ops->create_breakpoints_sal = strace_marker_create_breakpoints_sal;
-}
-
 /* Chain containing all defined "enable breakpoint" subcommands.  */
 
 static struct cmd_list_element *enablebreaklist = NULL;
@@ -14386,8 +14380,6 @@ _initialize_breakpoint ()
 {
   struct cmd_list_element *c;
 
-  initialize_breakpoint_ops ();
-
   gdb::observers::solib_unloaded.attach (disable_breakpoints_in_unloaded_shlib,
 					 "breakpoint");
   gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile,
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 64f06a98b37..2d4a89fb3e6 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1400,8 +1400,6 @@ extern void tbreak_command (const char *, int);
 
 extern struct breakpoint_ops base_breakpoint_ops;
 
-extern void initialize_breakpoint_ops (void);
-
 /* Arguments to pass as context to some catch command handlers.  */
 #define CATCH_PERMANENT ((void *) (uintptr_t) 0)
 #define CATCH_TEMPORARY ((void *) (uintptr_t) 1)


                 reply	other threads:[~2022-04-29 22:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429222436.D31FA3858405@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).