From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 048273857836; Fri, 29 Apr 2022 22:23:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 048273857836 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 Ada catchpoints to vtable ops X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 7dd8e7ae28cb656651ed12af5b045b55cdeb9df6 X-Git-Newrev: ae72050b7f8454ef2c0763f5548cc2cd873e27e0 Message-Id: <20220429222336.048273857836@sourceware.org> Date: Fri, 29 Apr 2022 22:23:36 +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:36 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dae72050b7f84= 54ef2c0763f5548cc2cd873e27e0 commit ae72050b7f8454ef2c0763f5548cc2cd873e27e0 Author: Tom Tromey Date: Sat Jan 15 16:10:58 2022 -0700 Convert Ada catchpoints to vtable ops =20 This converts Ada catchpoints to use vtable_breakpoint_ops. Diff: --- gdb/ada-lang.c | 156 ++++++++++++++++++++++++-----------------------------= ---- 1 file changed, 65 insertions(+), 91 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c1f2ee867ec..1ef955d142b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12129,6 +12129,14 @@ struct ada_catchpoint : public breakpoint { } =20 + struct bp_location *allocate_location () override; + void re_set () override; + void check_status (struct bpstat *bs) override; + enum print_stop_action print_it (struct bpstat *bs) override; + bool print_one (struct bp_location **) override; + void print_mention () override; + void print_recreate (struct ui_file *fp) override; + /* The name of the specific exception the user specified. */ std::string excep_string; =20 @@ -12187,30 +12195,28 @@ create_excep_cond_exprs (struct ada_catchpoint *c, } } =20 -/* Implement the ALLOCATE_LOCATION method in the breakpoint_ops - structure for all exception catchpoint kinds. */ +/* Implement the ALLOCATE_LOCATION method in the structure for all + exception catchpoint kinds. */ =20 -static struct bp_location * -allocate_location_exception (struct breakpoint *self) +struct bp_location * +ada_catchpoint::allocate_location () { - return new ada_catchpoint_location (self); + return new ada_catchpoint_location (this); } =20 -/* Implement the RE_SET method in the breakpoint_ops structure for all - exception catchpoint kinds. */ +/* Implement the RE_SET method in the structure for all exception + catchpoint kinds. */ =20 -static void -re_set_exception (struct breakpoint *b) +void +ada_catchpoint::re_set () { - struct ada_catchpoint *c =3D (struct ada_catchpoint *) b; - /* Call the base class's method. This updates the catchpoint's locations. */ - b->re_set (); + this->breakpoint::re_set (); =20 /* Reparse the exception conditional expressions. One for each location. */ - create_excep_cond_exprs (c, c->m_kind); + create_excep_cond_exprs (this, m_kind); } =20 /* Returns true if we should stop for this breakpoint hit. If the @@ -12278,36 +12284,35 @@ should_stop_exception (const struct bp_location *= bl) return stop; } =20 -/* Implement the CHECK_STATUS method in the breakpoint_ops structure - for all exception catchpoint kinds. */ +/* Implement the CHECK_STATUS method in the structure for all + exception catchpoint kinds. */ =20 -static void -check_status_exception (bpstat *bs) +void +ada_catchpoint::check_status (bpstat *bs) { bs->stop =3D should_stop_exception (bs->bp_location_at.get ()); } =20 -/* Implement the PRINT_IT method in the breakpoint_ops structure - for all exception catchpoint kinds. */ +/* Implement the PRINT_IT method in the structure for all exception + catchpoint kinds. */ =20 -static enum print_stop_action -print_it_exception (bpstat *bs) +enum print_stop_action +ada_catchpoint::print_it (bpstat *bs) { struct ui_out *uiout =3D current_uiout; - struct breakpoint *b =3D bs->breakpoint_at; =20 - annotate_catchpoint (b->number); + annotate_catchpoint (number); =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)); } =20 - uiout->text (b->disposition =3D=3D disp_del + uiout->text (disposition =3D=3D disp_del ? "\nTemporary catchpoint " : "\nCatchpoint "); - uiout->field_signed ("bkptno", b->number); + uiout->field_signed ("bkptno", number); uiout->text (", "); =20 /* ada_exception_name_addr relies on the selected frame being the @@ -12317,14 +12322,13 @@ print_it_exception (bpstat *bs) ada_find_printable_frame). */ select_frame (get_current_frame ()); =20 - struct ada_catchpoint *c =3D (struct ada_catchpoint *) b; - switch (c->m_kind) + switch (m_kind) { case ada_catch_exception: case ada_catch_exception_unhandled: case ada_catch_handlers: { - const CORE_ADDR addr =3D ada_exception_name_addr (c->m_kind, b); + const CORE_ADDR addr =3D ada_exception_name_addr (m_kind, this); char exception_name[256]; =20 if (addr !=3D 0) @@ -12348,7 +12352,7 @@ print_it_exception (bpstat *bs) it clearer to the user which kind of catchpoint just got hit. We used ui_out_text to make sure that this extra info does not pollute the exception name in the MI case. */ - if (c->m_kind =3D=3D ada_catch_exception_unhandled) + if (m_kind =3D=3D ada_catch_exception_unhandled) uiout->text ("unhandled "); uiout->field_string ("exception-name", exception_name); } @@ -12377,14 +12381,13 @@ print_it_exception (bpstat *bs) return PRINT_SRC_AND_LOC; } =20 -/* Implement the PRINT_ONE method in the breakpoint_ops structure - for all exception catchpoint kinds. */ +/* Implement the PRINT_ONE method in the structure for all exception + catchpoint kinds. */ =20 -static bool -print_one_exception (struct breakpoint *b, struct bp_location **last_loc) +bool +ada_catchpoint::print_one (struct bp_location **last_loc) {=20 struct ui_out *uiout =3D current_uiout; - struct ada_catchpoint *c =3D (struct ada_catchpoint *) b; struct value_print_options opts; =20 get_user_print_options (&opts); @@ -12393,13 +12396,13 @@ print_one_exception (struct breakpoint *b, struct= bp_location **last_loc) uiout->field_skip ("addr"); =20 annotate_field (5); - switch (c->m_kind) + switch (m_kind) { case ada_catch_exception: - if (!c->excep_string.empty ()) + if (!excep_string.empty ()) { std::string msg =3D string_printf (_("`%s' Ada exception"), - c->excep_string.c_str ()); + excep_string.c_str ()); =20 uiout->field_string ("what", msg); } @@ -12413,11 +12416,11 @@ print_one_exception (struct breakpoint *b, struct= bp_location **last_loc) break; =20 case ada_catch_handlers: - if (!c->excep_string.empty ()) + if (!excep_string.empty ()) { uiout->field_fmt ("what", _("`%s' Ada exception handlers"), - c->excep_string.c_str ()); + excep_string.c_str ()); } else uiout->field_string ("what", "all Ada exceptions handlers"); @@ -12438,24 +12441,23 @@ print_one_exception (struct breakpoint *b, struct= bp_location **last_loc) /* Implement the PRINT_MENTION method in the breakpoint_ops structure for all exception catchpoint kinds. */ =20 -static void -print_mention_exception (struct breakpoint *b) +void +ada_catchpoint::print_mention () { - struct ada_catchpoint *c =3D (struct ada_catchpoint *) b; struct ui_out *uiout =3D current_uiout; =20 - uiout->text (b->disposition =3D=3D disp_del ? _("Temporary catchpoint ") + uiout->text (disposition =3D=3D disp_del ? _("Temporary catchpoint ") : _("Catchpoint ")); - uiout->field_signed ("bkptno", b->number); + uiout->field_signed ("bkptno", number); uiout->text (": "); =20 - switch (c->m_kind) + switch (m_kind) { case ada_catch_exception: - if (!c->excep_string.empty ()) + if (!excep_string.empty ()) { std::string info =3D string_printf (_("`%s' Ada exception"), - c->excep_string.c_str ()); + excep_string.c_str ()); uiout->text (info); } else @@ -12467,11 +12469,11 @@ print_mention_exception (struct breakpoint *b) break; =20 case ada_catch_handlers: - if (!c->excep_string.empty ()) + if (!excep_string.empty ()) { std::string info =3D string_printf (_("`%s' Ada exception handlers"), - c->excep_string.c_str ()); + excep_string.c_str ()); uiout->text (info); } else @@ -12488,20 +12490,18 @@ print_mention_exception (struct breakpoint *b) } } =20 -/* Implement the PRINT_RECREATE method in the breakpoint_ops structure - for all exception catchpoint kinds. */ +/* Implement the PRINT_RECREATE method in the structure for all + exception catchpoint kinds. */ =20 -static void -print_recreate_exception (struct breakpoint *b, struct ui_file *fp) +void +ada_catchpoint::print_recreate (struct ui_file *fp) { - struct ada_catchpoint *c =3D (struct ada_catchpoint *) b; - - switch (c->m_kind) + switch (m_kind) { case ada_catch_exception: gdb_printf (fp, "catch exception"); - if (!c->excep_string.empty ()) - gdb_printf (fp, " %s", c->excep_string.c_str ()); + if (!excep_string.empty ()) + gdb_printf (fp, " %s", excep_string.c_str ()); break; =20 case ada_catch_exception_unhandled: @@ -12519,18 +12519,15 @@ print_recreate_exception (struct breakpoint *b, s= truct ui_file *fp) default: internal_error (__FILE__, __LINE__, _("unexpected catchpoint type")); } - print_recreate_thread (b, fp); + print_recreate_thread (this, fp); } =20 -/* Virtual table for breakpoint type. */ -static struct breakpoint_ops catch_exception_breakpoint_ops; - /* See ada-lang.h. */ =20 bool is_ada_exception_catchpoint (breakpoint *bp) { - return bp->ops =3D=3D &catch_exception_breakpoint_ops; + return dynamic_cast (bp) !=3D nullptr; } =20 /* Split the arguments specified in a "catch exception" command. =20 @@ -12710,7 +12707,7 @@ ada_exception_catchpoint_cond_string (const char *e= xcep_string, =20 static struct symtab_and_line ada_exception_sal (enum ada_exception_catchpoint_kind ex, - std::string *addr_string, const struct breakpoint_ops **ops) + std::string *addr_string) { const char *sym_name; struct symbol *sym; @@ -12732,9 +12729,6 @@ ada_exception_sal (enum ada_exception_catchpoint_ki= nd ex, /* Set ADDR_STRING. */ *addr_string =3D sym_name; =20 - /* Set OPS. */ - *ops =3D &catch_exception_breakpoint_ops; - return find_function_start_sal (sym, 1); } =20 @@ -12763,12 +12757,12 @@ create_ada_exception_catchpoint (struct gdbarch *= gdbarch, int from_tty) { std::string addr_string; - const struct breakpoint_ops *ops =3D NULL; - struct symtab_and_line sal =3D ada_exception_sal (ex_kind, &addr_string,= &ops); + struct symtab_and_line sal =3D ada_exception_sal (ex_kind, &addr_string); =20 std::unique_ptr c (new ada_catchpoint (ex_kind)); init_ada_exception_breakpoint (c.get (), gdbarch, sal, addr_string.c_str= (), - ops, tempflag, disabled, from_tty); + &vtable_breakpoint_ops, + tempflag, disabled, from_tty); c->excep_string =3D excep_string; create_excep_cond_exprs (c.get (), ex_kind); if (!cond_string.empty ()) @@ -13883,24 +13877,6 @@ static ada_language ada_language_defn; static struct cmd_list_element *set_ada_list; static struct cmd_list_element *show_ada_list; =20 -static void -initialize_ada_catchpoint_ops (void) -{ - struct breakpoint_ops *ops; - - initialize_breakpoint_ops (); - - ops =3D &catch_exception_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; - ops->print_it =3D print_it_exception; - ops->print_one =3D print_one_exception; - ops->print_mention =3D print_mention_exception; - ops->print_recreate =3D print_recreate_exception; -} - /* This module's 'new_objfile' observer. */ =20 static void @@ -13941,8 +13917,6 @@ void _initialize_ada_language (); void _initialize_ada_language () { - initialize_ada_catchpoint_ops (); - add_setshow_prefix_cmd ("ada", no_class, _("Prefix command for changing Ada-specific settings."),