From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 12AC83858002; Fri, 29 Apr 2022 22:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12AC83858002 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 dprintf to vtable ops X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: ae72050b7f8454ef2c0763f5548cc2cd873e27e0 X-Git-Newrev: f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a Message-Id: <20220429222341.12AC83858002@sourceware.org> Date: Fri, 29 Apr 2022 22:23:41 +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:23:41 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df293a0b5d6b4= 29c3dd8a91e9d55831bfb4efd84a commit f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a Author: Tom Tromey Date: Sat Jan 15 16:28:06 2022 -0700 Convert dprintf to vtable ops =20 This converts dprintf to use vtable_breakpoint_ops. Diff: --- gdb/breakpoint.c | 63 ++++++++++++++++++++++++-----------------------= ---- gdb/breakpoint.h | 1 - gdb/mi/mi-cmd-break.c | 2 +- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8131c71ad80..b856bf937d3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -240,9 +240,6 @@ static struct breakpoint_ops bkpt_probe_breakpoint_ops; /* Tracepoints set on probes. */ static struct breakpoint_ops tracepoint_probe_breakpoint_ops; =20 -/* Dynamic printf class type. */ -struct breakpoint_ops dprintf_breakpoint_ops; - /* The structure to be used in regular breakpoints. */ struct ordinary_breakpoint : public base_breakpoint { @@ -273,6 +270,13 @@ struct momentary_breakpoint : public base_breakpoint /* DPrintf breakpoints. */ struct dprintf_breakpoint : public ordinary_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_recreate (struct ui_file *fp) override; + void after_condition_true (struct bpstat *bs) override; }; =20 /* The style in which to perform a dynamic printf. This is a user @@ -9159,7 +9163,7 @@ dprintf_command (const char *arg, int from_tty) 0, bp_dprintf, 0 /* Ignore count */, pending_break_support, - &dprintf_breakpoint_ops, + &vtable_breakpoint_ops, from_tty, 1 /* enabled */, 0 /* internal */, @@ -11860,10 +11864,11 @@ base_breakpoint::breakpoint_hit (const struct bp_= location *bl, return 1; } =20 -static int -dprintf_breakpoint_hit (const struct bp_location *bl, - const address_space *aspace, CORE_ADDR bp_addr, - const target_waitstatus &ws) +int +dprintf_breakpoint::breakpoint_hit (const struct bp_location *bl, + const address_space *aspace, + CORE_ADDR bp_addr, + const target_waitstatus &ws) { if (dprintf_style =3D=3D dprintf_style_agent && target_can_run_breakpoint_commands ()) @@ -11874,7 +11879,7 @@ dprintf_breakpoint_hit (const struct bp_location *b= l, return 0; } =20 - return bl->owner->breakpoint_hit (bl, aspace, bp_addr, ws); + return this->ordinary_breakpoint::breakpoint_hit (bl, aspace, bp_addr, w= s); } =20 int @@ -12273,15 +12278,13 @@ tracepoint_probe_decode_location (struct breakpoi= nt *b, return bkpt_probe_decode_location (b, location, search_pspace); } =20 -/* Dprintf breakpoint_ops methods. */ - -static void -dprintf_re_set (struct breakpoint *b) +void +dprintf_breakpoint::re_set () { - breakpoint_re_set_default (b); + breakpoint_re_set_default (this); =20 /* extra_string should never be non-NULL for dprintf. */ - gdb_assert (b->extra_string !=3D NULL); + gdb_assert (extra_string !=3D NULL); =20 /* 1 - connect to target 1, that can run breakpoint commands. 2 - create a dprintf, which resolves fine. @@ -12293,23 +12296,22 @@ dprintf_re_set (struct breakpoint *b) answers for target_can_run_breakpoint_commands(). Given absence of finer grained resetting, we get to do it all the time. */ - if (b->extra_string !=3D NULL) - update_dprintf_command_list (b); + if (extra_string !=3D NULL) + update_dprintf_command_list (this); } =20 -/* Implement the "print_recreate" breakpoint_ops method for dprintf. */ +/* Implement the "print_recreate" method for dprintf. */ =20 -static void -dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp) +void +dprintf_breakpoint::print_recreate (struct ui_file *fp) { gdb_printf (fp, "dprintf %s,%s", - event_location_to_string (tp->location.get ()), - tp->extra_string.get ()); - print_recreate_thread (tp, fp); + event_location_to_string (location.get ()), + extra_string.get ()); + print_recreate_thread (this, fp); } =20 -/* Implement the "after_condition_true" breakpoint_ops method for - dprintf. +/* Implement the "after_condition_true" method for dprintf. =20 dprintf's are implemented with regular commands in their command list, but we run the commands here instead of before presenting the @@ -12317,8 +12319,8 @@ dprintf_print_recreate (struct breakpoint *tp, stru= ct ui_file *fp) also makes it so that the commands of multiple dprintfs at the same address are all handled. */ =20 -static void -dprintf_after_condition_true (struct bpstat *bs) +void +dprintf_breakpoint::after_condition_true (struct bpstat *bs) { /* dprintf's never cause a stop. This wasn't set in the check_status hook instead because that would make the dprintf's @@ -14588,13 +14590,6 @@ initialize_breakpoint_ops (void) 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; - - ops =3D &dprintf_breakpoint_ops; - *ops =3D vtable_breakpoint_ops; - ops->re_set =3D dprintf_re_set; - ops->print_recreate =3D dprintf_print_recreate; - ops->after_condition_true =3D dprintf_after_condition_true; - ops->breakpoint_hit =3D dprintf_breakpoint_hit; } =20 /* Chain containing all defined "enable breakpoint" subcommands. */ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index c1379870436..7d8c4f3bc3a 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1490,7 +1490,6 @@ extern void rwatch_command_wrapper (const char *, int= , bool); extern void tbreak_command (const char *, int); =20 extern struct breakpoint_ops base_breakpoint_ops; -extern struct breakpoint_ops dprintf_breakpoint_ops; extern struct breakpoint_ops vtable_breakpoint_ops; =20 extern void initialize_breakpoint_ops (void); diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 0b8ae5d5910..fb034317a6e 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -327,7 +327,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command= , char **argv, int argc) else if (dprintf) { type_wanted =3D bp_dprintf; - ops =3D &dprintf_breakpoint_ops; + ops =3D &vtable_breakpoint_ops; } else {