From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6C8513858002; Fri, 29 Apr 2022 22:22:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C8513858002 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Convert tracepoints to vtable ops X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 3a29292356cd26830dd771cf8ada376d132280a6 X-Git-Newrev: 779dcceba7ee2af97a95d9978fc9ef949837a27a Message-Id: <20220429222255.6C8513858002@sourceware.org> Date: Fri, 29 Apr 2022 22:22:55 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2022 22:22:55 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D779dcceba7ee= 2af97a95d9978fc9ef949837a27a commit 779dcceba7ee2af97a95d9978fc9ef949837a27a Author: Tom Tromey Date: Sat Jan 15 09:57:44 2022 -0700 Convert tracepoints to vtable ops =20 This converts tracepoints to use vtable_breakpoint_ops. Diff: --- gdb/breakpoint.c | 102 ++++++++++++++++++++--------------------------= ---- gdb/breakpoint.h | 15 +++++++- gdb/mi/mi-cmd-break.c | 4 +- 3 files changed, 56 insertions(+), 65 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index d3a1bea399f..5a133e1c31b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8744,7 +8744,7 @@ breakpoint_ops_for_event_location_type (enum event_lo= cation_type location_type, if (location_type =3D=3D PROBE_LOCATION) return &tracepoint_probe_breakpoint_ops; else - return &tracepoint_breakpoint_ops; + return &vtable_breakpoint_ops; } else { @@ -8764,7 +8764,7 @@ breakpoint_ops_for_event_location (const struct event= _location *location, if (location !=3D nullptr) return breakpoint_ops_for_event_location_type (event_location_type (location), is_tracepoint); - return is_tracepoint ? &tracepoint_breakpoint_ops : &bkpt_breakpoint_ops; + return is_tracepoint ? &vtable_breakpoint_ops : &bkpt_breakpoint_ops; } =20 /* See breakpoint.h. */ @@ -12117,98 +12117,90 @@ bkpt_probe_decode_location (struct breakpoint *b, =20 /* The breakpoint_ops structure to be used in tracepoints. */ =20 -static void -tracepoint_re_set (struct breakpoint *b) +void +tracepoint::re_set () { - breakpoint_re_set_default (b); + breakpoint_re_set_default (this); } =20 -static int -tracepoint_breakpoint_hit (const struct bp_location *bl, - const address_space *aspace, CORE_ADDR bp_addr, - const target_waitstatus &ws) +int +tracepoint::breakpoint_hit (const struct bp_location *bl, + const address_space *aspace, CORE_ADDR bp_addr, + const target_waitstatus &ws) { /* By definition, the inferior does not report stops at tracepoints. */ return 0; } =20 -static void -tracepoint_print_one_detail (const struct breakpoint *self, - struct ui_out *uiout) +void +tracepoint::print_one_detail (struct ui_out *uiout) const { - struct tracepoint *tp =3D (struct tracepoint *) self; - if (!tp->static_trace_marker_id.empty ()) + if (!static_trace_marker_id.empty ()) { - gdb_assert (self->type =3D=3D bp_static_tracepoint); + gdb_assert (type =3D=3D bp_static_tracepoint); =20 uiout->message ("\tmarker id is %pF\n", string_field ("static-tracepoint-marker-string-id", - tp->static_trace_marker_id.c_str ())); + static_trace_marker_id.c_str ())); } } =20 -static void -tracepoint_print_mention (struct breakpoint *b) +void +tracepoint::print_mention () { if (current_uiout->is_mi_like_p ()) return; =20 - switch (b->type) + switch (type) { case bp_tracepoint: gdb_printf (_("Tracepoint")); - gdb_printf (_(" %d"), b->number); + gdb_printf (_(" %d"), number); break; case bp_fast_tracepoint: gdb_printf (_("Fast tracepoint")); - gdb_printf (_(" %d"), b->number); + gdb_printf (_(" %d"), number); break; case bp_static_tracepoint: gdb_printf (_("Static tracepoint")); - gdb_printf (_(" %d"), b->number); + gdb_printf (_(" %d"), number); break; default: internal_error (__FILE__, __LINE__, - _("unhandled tracepoint type %d"), (int) b->type); + _("unhandled tracepoint type %d"), (int) type); } =20 - say_where (b); + say_where (this); } =20 -static void -tracepoint_print_recreate (struct breakpoint *self, struct ui_file *fp) +void +tracepoint::print_recreate (struct ui_file *fp) { - struct tracepoint *tp =3D (struct tracepoint *) self; - - if (self->type =3D=3D bp_fast_tracepoint) + if (type =3D=3D bp_fast_tracepoint) gdb_printf (fp, "ftrace"); - else if (self->type =3D=3D bp_static_tracepoint) + else if (type =3D=3D bp_static_tracepoint) gdb_printf (fp, "strace"); - else if (self->type =3D=3D bp_tracepoint) + else if (type =3D=3D bp_tracepoint) gdb_printf (fp, "trace"); else internal_error (__FILE__, __LINE__, - _("unhandled tracepoint type %d"), (int) self->type); + _("unhandled tracepoint type %d"), (int) type); =20 - gdb_printf (fp, " %s", - event_location_to_string (self->location.get ())); - print_recreate_thread (self, fp); + gdb_printf (fp, " %s", event_location_to_string (location.get ())); + print_recreate_thread (this, fp); =20 - if (tp->pass_count) - gdb_printf (fp, " passcount %d\n", tp->pass_count); + if (pass_count) + gdb_printf (fp, " passcount %d\n", pass_count); } =20 -static std::vector -tracepoint_decode_location (struct breakpoint *b, - struct event_location *location, - struct program_space *search_pspace) +std::vector +tracepoint::decode_location (struct event_location *location, + struct program_space *search_pspace) { - return decode_location_default (b, location, search_pspace); + return decode_location_default (this, location, search_pspace); } =20 -struct breakpoint_ops tracepoint_breakpoint_ops; - /* Virtual table for tracepoints on static probes. */ =20 static void @@ -13858,7 +13850,7 @@ ftrace_command (const char *arg, int from_tty) bp_fast_tracepoint /* type_wanted */, 0 /* Ignore count */, pending_break_support, - &tracepoint_breakpoint_ops, + &vtable_breakpoint_ops, from_tty, 1 /* enabled */, 0 /* internal */, 0); @@ -13881,7 +13873,7 @@ strace_command (const char *arg, int from_tty) } else { - ops =3D &tracepoint_breakpoint_ops; + ops =3D &vtable_breakpoint_ops; location =3D string_to_event_location (&arg, current_language); } =20 @@ -13963,7 +13955,7 @@ create_tracepoint_from_upload (struct uploaded_tp *= utp) utp->type /* type_wanted */, 0 /* Ignore count */, pending_break_support, - &tracepoint_breakpoint_ops, + &vtable_breakpoint_ops, 0 /* from_tty */, utp->enabled /* enabled */, 0 /* internal */, @@ -14565,27 +14557,15 @@ initialize_breakpoint_ops (void) ops->create_sals_from_location =3D bkpt_probe_create_sals_from_location; ops->decode_location =3D bkpt_probe_decode_location; =20 - /* Tracepoints. */ - ops =3D &tracepoint_breakpoint_ops; - *ops =3D base_breakpoint_ops; - ops->re_set =3D tracepoint_re_set; - ops->breakpoint_hit =3D tracepoint_breakpoint_hit; - ops->print_one_detail =3D tracepoint_print_one_detail; - ops->print_mention =3D tracepoint_print_mention; - ops->print_recreate =3D tracepoint_print_recreate; - ops->create_sals_from_location =3D create_sals_from_location_default; - ops->create_breakpoints_sal =3D create_breakpoints_sal_default; - ops->decode_location =3D tracepoint_decode_location; - /* Probe tracepoints. */ ops =3D &tracepoint_probe_breakpoint_ops; - *ops =3D tracepoint_breakpoint_ops; + *ops =3D vtable_breakpoint_ops; ops->create_sals_from_location =3D tracepoint_probe_create_sals_from_loc= ation; ops->decode_location =3D tracepoint_probe_decode_location; =20 /* Static tracepoints with marker (`-m'). */ ops =3D &strace_marker_breakpoint_ops; - *ops =3D tracepoint_breakpoint_ops; + *ops =3D vtable_breakpoint_ops; ops->create_sals_from_location =3D strace_marker_create_sals_from_locati= on; ops->create_breakpoints_sal =3D strace_marker_create_breakpoints_sal; ops->decode_location =3D strace_marker_decode_location; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 3d7a59076f0..7d62c0ac459 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1032,6 +1032,18 @@ extern bool is_exception_catchpoint (breakpoint *bp); =20 struct tracepoint : public breakpoint { + void re_set () override; + int breakpoint_hit (const struct bp_location *bl, + 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_recreate (struct ui_file *fp) override; + std::vector decode_location + (struct event_location *location, + struct program_space *search_pspace) override; + + /* Number of times this tracepoint should single-step and collect additional data. */ long step_count; @@ -1461,7 +1473,6 @@ extern void tbreak_command (const char *, int); =20 extern struct breakpoint_ops base_breakpoint_ops; extern struct breakpoint_ops bkpt_breakpoint_ops; -extern struct breakpoint_ops tracepoint_breakpoint_ops; extern struct breakpoint_ops dprintf_breakpoint_ops; extern struct breakpoint_ops vtable_breakpoint_ops; =20 @@ -1516,7 +1527,7 @@ extern void install_breakpoint (int internal, std::un= ique_ptr &&b, /* Returns the breakpoint ops appropriate for use with with LOCATION and according to IS_TRACEPOINT. Use this to ensure, for example, that you = pass the correct ops to create_breakpoint for probe locations. If LOCATION = is - NULL, returns bkpt_breakpoint_ops (or tracepoint_breakpoint_ops, if + NULL, returns bkpt_breakpoint_ops (or vtable_breakpoint_ops, if IS_TRACEPOINT is true). */ =20 extern const struct breakpoint_ops *breakpoint_ops_for_event_location diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 05eac3553ae..a5c78529dd1 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -180,7 +180,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command= , char **argv, int argc) symbol_name_match_type match_type =3D symbol_name_match_type::WILD; enum bptype type_wanted; event_location_up location; - struct breakpoint_ops *ops; + const struct breakpoint_ops *ops; int is_explicit =3D 0; struct explicit_location explicit_loc; std::string extra_string; @@ -322,7 +322,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command= , char **argv, int argc) A simulator or an emulator could conceivably implement fast regular non-jump based tracepoints. */ type_wanted =3D hardware ? bp_fast_tracepoint : bp_tracepoint; - ops =3D &tracepoint_breakpoint_ops; + ops =3D breakpoint_ops_for_event_location (nullptr, true); } else if (dprintf) {