From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 7E023385842B; Fri, 29 Apr 2022 22:23:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E023385842B 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] Add some new subclasses of breakpoint X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 779dcceba7ee2af97a95d9978fc9ef949837a27a X-Git-Newrev: 098f12723d5c095c115d0a6121ef77816d6a796f Message-Id: <20220429222300.7E023385842B@sourceware.org> Date: Fri, 29 Apr 2022 22:23:00 +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:00 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D098f12723d5c= 095c115d0a6121ef77816d6a796f commit 098f12723d5c095c115d0a6121ef77816d6a796f Author: Tom Tromey Date: Sat Jan 15 13:37:28 2022 -0700 Add some new subclasses of breakpoint =20 This adds a few new subclasses of breakpoint. The inheritance hierarchy is chosen to reflect what's already present in initialize_breakpoint_ops -- it mirrors the way that the _ops structures are filled in. =20 This patch also changes new_breakpoint_from_type to create the correct sublcass based on bptype. This is important due to the somewhat inverted way in which create_breakpoint works; and in particular later patches will change some of these entries. Diff: --- gdb/breakpoint.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++-----= ---- gdb/breakpoint.h | 7 +++++ 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 5a133e1c31b..ab755972369 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -253,6 +253,26 @@ static struct breakpoint_ops tracepoint_probe_breakpoi= nt_ops; /* Dynamic printf class type. */ struct breakpoint_ops dprintf_breakpoint_ops; =20 +/* The structure to be used in regular breakpoints. */ +struct ordinary_breakpoint : public base_breakpoint +{ +}; + +/* Internal breakpoints. */ +struct internal_breakpoint : public base_breakpoint +{ +}; + +/* Momentary breakpoints. */ +struct momentary_breakpoint : public base_breakpoint +{ +}; + +/* DPrintf breakpoints. */ +struct dprintf_breakpoint : public base_breakpoint +{ +}; + /* The style in which to perform a dynamic printf. This is a user option because different output options have different tradeoffs; if GDB does the printing, there is better error handling if there @@ -1127,7 +1147,7 @@ check_no_tracepoint_commands (struct command_line *co= mmands) } } =20 -struct longjmp_breakpoint : public breakpoint +struct longjmp_breakpoint : public momentary_breakpoint { ~longjmp_breakpoint () override; }; @@ -1142,12 +1162,6 @@ is_tracepoint_type (bptype type) || type =3D=3D bp_static_tracepoint); } =20 -static bool -is_longjmp_type (bptype type) -{ - return type =3D=3D bp_longjmp || type =3D=3D bp_exception; -} - /* See breakpoint.h. */ =20 bool @@ -1164,12 +1178,55 @@ new_breakpoint_from_type (bptype type) { breakpoint *b; =20 - if (is_tracepoint_type (type)) - b =3D new tracepoint (); - else if (is_longjmp_type (type)) - b =3D new longjmp_breakpoint (); - else - b =3D new breakpoint (); + switch (type) + { + case bp_breakpoint: + case bp_hardware_breakpoint: + b =3D new ordinary_breakpoint (); + break; + + case bp_fast_tracepoint: + case bp_static_tracepoint: + case bp_tracepoint: + b =3D new tracepoint (); + break; + + case bp_dprintf: + b =3D new dprintf_breakpoint (); + break; + + case bp_overlay_event: + case bp_longjmp_master: + case bp_std_terminate_master: + case bp_exception_master: + case bp_thread_event: + case bp_jit_event: + case bp_shlib_event: + b =3D new internal_breakpoint (); + break; + + case bp_longjmp: + case bp_exception: + b =3D new longjmp_breakpoint (); + break; + + case bp_watchpoint_scope: + case bp_finish: + case bp_gnu_ifunc_resolver_return: + case bp_step_resume: + case bp_hp_step_resume: + case bp_longjmp_resume: + case bp_longjmp_call_dummy: + case bp_exception_resume: + case bp_call_dummy: + case bp_until: + case bp_std_terminate: + b =3D new momentary_breakpoint (); + break; + + default: + gdb_assert_not_reached ("invalid type"); + } =20 return std::unique_ptr (b); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 7d62c0ac459..a4b3ce17b01 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -940,6 +940,13 @@ struct breakpoint gdbscm_breakpoint_object *scm_bp_object =3D NULL; }; =20 +/* The structure to be inherit by all kinds of breakpoints (real + breakpoints, i.e., user "break" breakpoints, internal and momentary + breakpoints, etc.). */ +struct base_breakpoint : public breakpoint +{ +}; + /* An instance of this type is used to represent a watchpoint. */ =20 struct watchpoint : public breakpoint