From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id E51733858405; Fri, 29 Apr 2022 22:23:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E51733858405 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 ordinary breakpoints to vtable ops X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5ad71d67aef6b2885fcaf52b9151af6e28e9648a X-Git-Newrev: 7dd8e7ae28cb656651ed12af5b045b55cdeb9df6 Message-Id: <20220429222330.E51733858405@sourceware.org> Date: Fri, 29 Apr 2022 22:23:30 +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:31 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7dd8e7ae28cb= 656651ed12af5b045b55cdeb9df6 commit 7dd8e7ae28cb656651ed12af5b045b55cdeb9df6 Author: Tom Tromey Date: Sat Jan 15 15:46:54 2022 -0700 Convert ordinary breakpoints to vtable ops =20 This converts "ordinary" breakpoint to use vtable_breakpoint_ops. Recall that an ordinary breakpoint is both the kind normally created by users, and also a base class used by other classes. Diff: --- gdb/ada-lang.c | 4 +- gdb/breakpoint.c | 95 +++++++++++++++++-------------------= ---- gdb/breakpoint.h | 1 - gdb/mi/mi-cmd-break.c | 2 +- gdb/python/py-finishbreakpoint.c | 2 +- 5 files changed, 45 insertions(+), 59 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 69698a1b99a..c1f2ee867ec 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12206,7 +12206,7 @@ re_set_exception (struct breakpoint *b) =20 /* Call the base class's method. This updates the catchpoint's locations. */ - bkpt_breakpoint_ops.re_set (b); + b->re_set (); =20 /* Reparse the exception conditional expressions. One for each location. */ @@ -13891,7 +13891,7 @@ initialize_ada_catchpoint_ops (void) initialize_breakpoint_ops (); =20 ops =3D &catch_exception_breakpoint_ops; - *ops =3D bkpt_breakpoint_ops; + *ops =3D vtable_breakpoint_ops; ops->allocate_location =3D allocate_location_exception; ops->re_set =3D re_set_exception; ops->check_status =3D check_status_exception; diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 275860fee15..8131c71ad80 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -234,10 +234,6 @@ static int strace_marker_p (struct breakpoint *b); (user breakpoints, internal and momentary breakpoints, etc.). */ static struct breakpoint_ops bkpt_base_breakpoint_ops; =20 -/* The breakpoint_ops structure to be used in regular user created - breakpoints. */ -struct breakpoint_ops bkpt_breakpoint_ops; - /* Breakpoints set on probes. */ static struct breakpoint_ops bkpt_probe_breakpoint_ops; =20 @@ -250,6 +246,10 @@ struct breakpoint_ops dprintf_breakpoint_ops; /* The structure to be used in regular breakpoints. */ struct ordinary_breakpoint : public base_breakpoint { + int resources_needed (const struct bp_location *) override; + enum print_stop_action print_it (struct bpstat *bs) override; + void print_mention () override; + void print_recreate (struct ui_file *fp) override; }; =20 /* Internal breakpoints. */ @@ -8810,7 +8810,7 @@ breakpoint_ops_for_event_location_type (enum event_lo= cation_type location_type, if (location_type =3D=3D PROBE_LOCATION) return &bkpt_probe_breakpoint_ops; else - return &bkpt_breakpoint_ops; + return &vtable_breakpoint_ops; } } =20 @@ -8823,7 +8823,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 ? &vtable_breakpoint_ops : &bkpt_breakpoint_ops; + return &vtable_breakpoint_ops; } =20 /* See breakpoint.h. */ @@ -11877,105 +11877,100 @@ dprintf_breakpoint_hit (const struct bp_locatio= n *bl, return bl->owner->breakpoint_hit (bl, aspace, bp_addr, ws); } =20 -static int -bkpt_resources_needed (const struct bp_location *bl) +int +ordinary_breakpoint::resources_needed (const struct bp_location *bl) { - gdb_assert (bl->owner->type =3D=3D bp_hardware_breakpoint); + gdb_assert (type =3D=3D bp_hardware_breakpoint); =20 return 1; } =20 -static enum print_stop_action -bkpt_print_it (bpstat *bs) +enum print_stop_action +ordinary_breakpoint::print_it (bpstat *bs) { - struct breakpoint *b; const struct bp_location *bl; int bp_temp; struct ui_out *uiout =3D current_uiout; =20 - gdb_assert (bs->bp_location_at !=3D NULL); - bl =3D bs->bp_location_at.get (); - b =3D bs->breakpoint_at; =20 - bp_temp =3D b->disposition =3D=3D disp_del; + bp_temp =3D disposition =3D=3D disp_del; if (bl->address !=3D bl->requested_address) breakpoint_adjustment_warning (bl->requested_address, bl->address, - b->number, 1); - annotate_breakpoint (b->number); + number, 1); + annotate_breakpoint (number); maybe_print_thread_hit_breakpoint (uiout); =20 if (uiout->is_mi_like_p ()) { uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); - uiout->field_string ("disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (disposition)); } if (bp_temp) uiout->message ("Temporary breakpoint %pF, ", - signed_field ("bkptno", b->number)); + signed_field ("bkptno", number)); else uiout->message ("Breakpoint %pF, ", - signed_field ("bkptno", b->number)); + signed_field ("bkptno", number)); =20 return PRINT_SRC_AND_LOC; } =20 -static void -bkpt_print_mention (struct breakpoint *b) +void +ordinary_breakpoint::print_mention () { if (current_uiout->is_mi_like_p ()) return; =20 - switch (b->type) + switch (type) { case bp_breakpoint: case bp_gnu_ifunc_resolver: - if (b->disposition =3D=3D disp_del) + if (disposition =3D=3D disp_del) gdb_printf (_("Temporary breakpoint")); else gdb_printf (_("Breakpoint")); - gdb_printf (_(" %d"), b->number); - if (b->type =3D=3D bp_gnu_ifunc_resolver) + gdb_printf (_(" %d"), number); + if (type =3D=3D bp_gnu_ifunc_resolver) gdb_printf (_(" at gnu-indirect-function resolver")); break; case bp_hardware_breakpoint: - gdb_printf (_("Hardware assisted breakpoint %d"), b->number); + gdb_printf (_("Hardware assisted breakpoint %d"), number); break; case bp_dprintf: - gdb_printf (_("Dprintf %d"), b->number); + gdb_printf (_("Dprintf %d"), number); break; } =20 - say_where (b); + say_where (this); } =20 -static void -bkpt_print_recreate (struct breakpoint *tp, struct ui_file *fp) +void +ordinary_breakpoint::print_recreate (struct ui_file *fp) { - if (tp->type =3D=3D bp_breakpoint && tp->disposition =3D=3D disp_del) + if (type =3D=3D bp_breakpoint && disposition =3D=3D disp_del) gdb_printf (fp, "tbreak"); - else if (tp->type =3D=3D bp_breakpoint) + else if (type =3D=3D bp_breakpoint) gdb_printf (fp, "break"); - else if (tp->type =3D=3D bp_hardware_breakpoint - && tp->disposition =3D=3D disp_del) + else if (type =3D=3D bp_hardware_breakpoint + && disposition =3D=3D disp_del) gdb_printf (fp, "thbreak"); - else if (tp->type =3D=3D bp_hardware_breakpoint) + else if (type =3D=3D bp_hardware_breakpoint) gdb_printf (fp, "hbreak"); else internal_error (__FILE__, __LINE__, - _("unhandled breakpoint type %d"), (int) tp->type); + _("unhandled breakpoint type %d"), (int) type); =20 - gdb_printf (fp, " %s", - event_location_to_string (tp->location.get ())); + gdb_printf (fp, " %s", event_location_to_string (location.get ())); =20 /* Print out extra_string if this breakpoint is pending. It might contain, for example, conditions that were set by the user. */ - if (tp->loc =3D=3D NULL && tp->extra_string !=3D NULL) - gdb_printf (fp, " %s", tp->extra_string.get ()); + if (loc =3D=3D NULL && extra_string !=3D NULL) + gdb_printf (fp, " %s", extra_string.get ()); =20 - print_recreate_thread (tp, fp); + print_recreate_thread (this, fp); } =20 std::vector @@ -14562,17 +14557,9 @@ initialize_breakpoint_ops (void) ops =3D &bkpt_base_breakpoint_ops; *ops =3D vtable_breakpoint_ops; =20 - /* The breakpoint_ops structure to be used in regular breakpoints. */ - ops =3D &bkpt_breakpoint_ops; - *ops =3D bkpt_base_breakpoint_ops; - ops->resources_needed =3D bkpt_resources_needed; - ops->print_it =3D bkpt_print_it; - ops->print_mention =3D bkpt_print_mention; - ops->print_recreate =3D bkpt_print_recreate; - /* Ranged breakpoints. */ ops =3D &ranged_breakpoint_ops; - *ops =3D bkpt_breakpoint_ops; + *ops =3D vtable_breakpoint_ops; ops->breakpoint_hit =3D breakpoint_hit_ranged_breakpoint; ops->resources_needed =3D resources_needed_ranged_breakpoint; ops->print_it =3D print_it_ranged_breakpoint; @@ -14583,7 +14570,7 @@ initialize_breakpoint_ops (void) =20 /* Probe breakpoints. */ ops =3D &bkpt_probe_breakpoint_ops; - *ops =3D bkpt_breakpoint_ops; + *ops =3D vtable_breakpoint_ops; ops->insert_location =3D bkpt_probe_insert_location; ops->remove_location =3D bkpt_probe_remove_location; ops->create_sals_from_location =3D bkpt_probe_create_sals_from_location; @@ -14603,7 +14590,7 @@ initialize_breakpoint_ops (void) ops->decode_location =3D strace_marker_decode_location; =20 ops =3D &dprintf_breakpoint_ops; - *ops =3D bkpt_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; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index de1ef5ef6b3..c1379870436 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 bkpt_breakpoint_ops; extern struct breakpoint_ops dprintf_breakpoint_ops; extern struct breakpoint_ops vtable_breakpoint_ops; =20 diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index a5c78529dd1..0b8ae5d5910 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -332,7 +332,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command= , char **argv, int argc) else { type_wanted =3D hardware ? bp_hardware_breakpoint : bp_breakpoint; - ops =3D &bkpt_breakpoint_ops; + ops =3D &vtable_breakpoint_ops; } =20 if (is_explicit) diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpo= int.c index 083694fbcce..015eb3c08f7 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -305,7 +305,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObje= ct *kwargs) bp_breakpoint, 0, AUTO_BOOLEAN_TRUE, - &bkpt_breakpoint_ops, + &vtable_breakpoint_ops, 0, 1, internal_bp, 0); } catch (const gdb_exception &except)