Commit graph

1410 commits

Author SHA1 Message Date
Pedro Alves
ef4848c75f More breakpoint_ops parameter elimination
Remove breakpoint_ops parameters from a few functions that don't need
it.

Change-Id: Ifcf5e1cc688184acbf5e19b8ea60138ebe63cf28
2022-05-20 20:41:00 +01:00
Pedro Alves
ff733ec228 Make a few functions work with base_breakpoint instead of breakpoint
This makes tracepoints inherit from base_breakpoint, since their
locations are code locations.  If we do that, then we can eliminate
tracepoint::re_set and tracepoint::decode_location, as they are doing
the same as the base_breakpoint implementations.

With this, all breakpoint types created by new_breakpoint_from_type
are code breakpoints, i.e., base_breakpoint subclasses, and thus we
can make it return a base_breakpoint pointer.

Finally, init_breakpoint_sal can take a base_breakpoint pointer as
"self" pointer too.  This will let us convert this function to a
base_breakpoint ctor in a following patch.

Change-Id: I3a4073ff1a4c865f525588095c18dc42b744cb54
2022-05-20 20:41:00 +01:00
Pedro Alves
b925bf21e0 ranged_breakpoint: move initialization to ctor
Move initialization of ranged_breakpoint's fields to its ctor.

Change-Id: If7b842861f3cc6a429ea329d45598b5852283ba3
2022-05-20 20:41:00 +01:00
Pedro Alves
27a62b4359 ranged_breakpoint: use install_breakpoint
This commit replaces a chunk of code in break_range_command by an
equivalent call to install_breakpoint.

Change-Id: I31c06cabd36f5be91740aab029265f678aa78e35
2022-05-20 20:41:00 +01:00
Pedro Alves
f317d1eb2a ranged_breakpoint: don't use init_raw_breakpoint
ranged_breakpoint's ctor already sets the breakpoint's type to
bp_hardware_breakpoint.

Since this is a "regular" breakpoint, b->pspace should remain NULL.

Thus, the only thing init_raw_breakpoint is needed for, is to add the
breakpoint's location.  Do that directly.

Change-Id: I1505de94c3919881c2b300437e2c0da9b05f76bd
2022-05-20 20:41:00 +01:00
Pedro Alves
1c2cbcf1de Make structs breakpoint/base_breakpoint/catchpoint be abstract
You should never instanciate these types directly.

Change-Id: I8086c74c415eadbd44924bb0ef20f34b5b97ee6f
2022-05-20 20:40:59 +01:00
Pedro Alves
0661562829 add_location_to_breakpoint -> breakpoint::add_location
Make add_location_to_breakpoint be a method of struct breakpoint.

A patch later in the series will move this to base_breakpoint, but for
now, it needs to be here.

Change-Id: I5bdc2ec1a7c2d66f26f51bf6f6adc8384a90b129
2022-05-20 20:40:59 +01:00
Tom Tromey
fed1c982de Introduce catchpoint class
This introduces a catchpoint class that is used as the base class for
all catchpoints.  init_catchpoint is rewritten to be a constructor
instead.

This changes the hierarchy a little -- some catchpoints now inherit
from base_breakpoint whereas previously they did not.  This isn't a
problem, as long as re_set is redefined in catchpoint.
2022-05-06 12:03:35 -06:00
Tom Tromey
73063f5180 Remove init_raw_breakpoint_without_location
This removes init_raw_breakpoint_without_location, replacing it with a
constructor on 'breakpoint' itself.  The subclasses and callers are
all updated.
2022-05-06 12:03:35 -06:00
Tom Tromey
4d1ae55893 Constify breakpoint::print_recreate
This constifies breakpoint::print_recreate.
2022-05-06 12:03:34 -06:00
Tom Tromey
b713485d66 Constify breakpoint::print_mention
This constifies breakpoint::print_mention.
2022-05-06 12:03:34 -06:00
Tom Tromey
a67bcaba1c Constify breakpoint::print_one
This constifies breakpoint::print_one.
2022-05-06 12:03:34 -06:00
Tom Tromey
7bd8631327 Constify breakpoint::print_it
This constifies breakpoint::print_it.  Doing this pointed out some
code in ada-lang.c that can be simplified a little as well.
2022-05-06 12:03:34 -06:00
Tom Tromey
5a61e17687 Move works_in_software_mode to watchpoint
works_in_software_mode is only useful for watchpoints.  This patch
moves it from breakpoint to watchpoint, and changes it to return bool.
2022-05-06 12:03:34 -06:00
Tom Tromey
a6860f3ad2 Boolify breakpoint::explains_signal
This changes breakpoint::explains_signal to return bool.
2022-05-06 12:03:34 -06:00
Tom Tromey
9efa3c7fa3 Remove breakpoint::ops
The breakpoint::ops field is set but never used.  This removes it.
2022-05-06 12:03:34 -06:00
Tom Tromey
04d0163c3f Change print_recreate_thread to a method
This changes print_recreate_thread to be a method on breakpoint.  This
function is only used as a helper by print_recreate methods, so I
thought this transformation made sense.
2022-05-06 12:03:34 -06:00
Simon Marchi
03ada39ea5 gdb: remove type_wanted parameter from a few functions
The type_wanted value, passed down to the create_sals_from_location
callback, is never used.  Remove it.

Change-Id: Ic363ee13f6af593a3e875ff7fe46de130cdc190c
2022-05-02 16:14:23 -04:00
Tom Tromey
eee031e253 Remove create_breakpoints_sal_default
create_breakpoints_sal_default is just a simple wrapper, so remove it.
2022-04-29 16:14:32 -06:00
Tom Tromey
ee89d0a4e8 Remove allocate_bp_location
allocate_bp_location is just a small wrapper for a method call, so
inline it everywhere.
2022-04-29 16:14:32 -06:00
Tom Tromey
a678887d09 Constify breakpoint_ops
Now that all breakpoint_ops are statically initialized, they can all
be made const.
2022-04-29 16:14:32 -06:00
Tom Tromey
8613a476b1 Remove breakpoint ops initialization
initialize_breakpoint_ops does not do much any more, so remove it in
favor of statically-initialize objects.
2022-04-29 16:14:32 -06:00
Tom Tromey
a0cd5f080b Remove vtable_breakpoint_ops
There's no need to have vtable_breakpoint_ops any more, so remove it
in favor of base_breakpoint_ops.
2022-04-29 16:14:32 -06:00
Tom Tromey
c47614fef9 Remove most fields from breakpoint_ops
At this point, all implementations of breakpoints use the vtable.  So,
we can now remove most function pointers from breakpoint_ops and
switch to using methods directly in the callers.  Only the two "static
virtual" methods remain in breakpoint_ops.
2022-04-29 16:14:32 -06:00
Tom Tromey
b3316ff153 Remove breakpoint_ops from init_catchpoint
init_catchpoint is only ever passed a single breakpoint_ops pointer,
so remove the parameter.
2022-04-29 16:14:32 -06:00
Tom Tromey
a48ddc0d6a Remove breakpoint_ops from init_ada_exception_breakpoint
init_ada_exception_breakpoint is only ever passed a single
breakpoint_ops structure, so remove the parameter.
2022-04-29 16:14:32 -06:00
Tom Tromey
8d89123dc2 Merge probe and ordinary tracepoints
Right now, probe tracepoints are handled by a separate ops object.
However, they differ only in a small way from ordinary tracepoints,
and furthermore can be distinguished by their event location.

This patch merges the two cases, just as was done for breakpoints.
2022-04-29 16:14:32 -06:00
Tom Tromey
5d926615e9 Merge probe and ordinary breakpoints
Right now, probe breakpoints are handled by a separate ops object.
However, they differ only in a small way from ordinary breakpoints,
and furthermore can be distinguished by their "probe" object.

This patch merges the two cases.  This avoids having to introduce a
new bp_ constant (which can be quite subtle to do correctly) and a new
subclass.
2022-04-29 16:14:32 -06:00
Tom Tromey
823b50f385 Remove bkpt_base_breakpoint_ops
An earlier patch removed the last use of bkpt_base_breakpoint_ops, so
remove the object entirely.
2022-04-29 16:14:32 -06:00
Tom Tromey
6d7a8c568b Convert static marker tracepoints to vtable ops
This converts static marker tracepoints to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
7b572efb48 Add bp_static_marker_tracepoint
Because the actual construction of a breakpoint is buried deep in
create_breakpoint, at present it's necessary to have a new bp_
enumerator constant any time a new subclass is needed.  Static marker
tracepoints are one such case, so this patch introduces
bp_static_marker_tracepoint and updates various spots to recognize it.
2022-04-29 16:14:31 -06:00
Tom Tromey
ec45bb676c Convert ranged breakpoints to vtable ops
This converts ranged breakpoints to use vtable_breakpoint_ops.  This
requires introducing a new ranged_breakpoint type, but this is
relatively simple because ranged breakpoints can only be created by
break_range_command.
2022-04-29 16:14:31 -06:00
Tom Tromey
f293a0b5d6 Convert dprintf to vtable ops
This converts dprintf to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
7dd8e7ae28 Convert ordinary breakpoints to vtable ops
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.
2022-04-29 16:14:31 -06:00
Tom Tromey
5ad71d67ae Change inheritance of dprintf
The dprintf breakpoint ops is mostly a copy of bpkt_breakpoint_ops,
except it's written out explicitly -- and, importantly, there's
nothing that bpkt_breakpoint_ops overrides that dprintf does not.
This changes dprintf to simply inherit directly, and updates struct
dprintf_breakpoint to reflect the change as well.
2022-04-29 16:14:31 -06:00
Tom Tromey
1fd30a4730 Convert momentary breakpoints to vtable ops
This converts momentary breakpoints to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
c359fff502 Convert internal breakpoints to vtable ops
This converts internal breakpoints to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
2b5ab5b851 Convert base breakpoints to vtable ops
This converts base breakpoints to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
098f12723d Add some new subclasses of breakpoint
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.

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.
2022-04-29 16:14:31 -06:00
Tom Tromey
779dcceba7 Convert tracepoints to vtable ops
This converts tracepoints to use vtable_breakpoint_ops.
2022-04-29 16:14:31 -06:00
Tom Tromey
3a29292356 Convert watchpoints to vtable ops
This converts watchpoints and masked watchpoints. to use
vtable_breakpoint_ops.  For masked watchpoints, a new subclass must be
introduced, and watch_command_1 is changed to create one.
2022-04-29 16:14:31 -06:00
Tom Tromey
4c6a92b11d Add a vtable-based breakpoint ops
This adds methods to struct breakpoint.  Each method has a similar
signature to a corresponding function in breakpoint_ops, with the
exceptions of create_sals_from_location and create_breakpoints_sal,
which can't be virtual methods on breakpoint -- they are only used
during the construction of breakpoints.

Then, this adds a new vtable_breakpoint_ops structure and populates it
with functions that simply forward a call from breakpoint_ops to the
corresponding virtual method.  These are all done with lambdas,
because they are just a stepping stone -- by the end of the series,
this structure will be deleted.
2022-04-29 16:14:30 -06:00
Tom Tromey
c01e038bd2 Return bool from breakpoint_ops::print_one
This changes breakpoint_ops::print_one to return bool, and updates all
the implementations and the caller.  The caller is changed so that a
NULL check is no longer needed -- something that will be impossible
with a real method.
2022-04-29 16:14:30 -06:00
Tom Tromey
6689579725 Delete some unnecessary wrapper functions
This patch deletes a few unnecessary wrapper functions from
breakpoint.c.
2022-04-29 16:14:30 -06:00
Tom Tromey
16922ea6ad Add an assertion to clone_momentary_breakpoint
This adds an assertion to clone_momentary_breakpoint.  This will
eventually be removed, but in the meantime is is useful for helping
convince oneself that momentary breakpoints will always use
momentary_breakpoint_ops.  This understanding will help when cleaning
up the code later.
2022-04-29 16:14:30 -06:00
Tom Tromey
4e9e993a7e Boolify print_solib_event
Change print_solib_event to accept a bool parameter and update the
callers.
2022-04-29 16:14:30 -06:00
Tom Tromey
2f9ee862bc Move "catch load" to a new file
The "catch load" code is reasonably self-contained, and so this patch
moves it out of breakpoint.c and into a new file, break-catch-load.c.
One function from breakpoint.c, print_solib_event, now has to be
exposed, but this seems pretty reasonable.
2022-04-29 16:14:30 -06:00
Enze Li
a5c69b1e49 gdb: fix using clear command to delete non-user breakpoints(PR cli/7161)
The clear command shouldn't delete momentary and internal breakpoints,
nor internal breakpoints created via Python's gdb.Breakpoint.

This patch fixes this issue and adds a testcase.

Regression tested on x86_64 openSUSE Tumbleweed(VERSION_ID="20220413").

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7161
2022-04-18 21:40:31 +08:00
Simon Marchi
60f62e2b83 gdb: remove MSYMBOL_TYPE macro
Add a getter and a setter for a minimal symbol's type.  Remove the
corresponding macro and adjust all callers.

Change-Id: I89900df5ffa5687133fe1a16b2e0d4684e67a77d
2022-04-11 10:46:07 -04:00
Simon Marchi
4aeddc50d7 gdb: remove symbol value macros
Remove all macros related to getting and setting some symbol value:

    #define SYMBOL_VALUE(symbol)           (symbol)->value.ivalue
    #define SYMBOL_VALUE_ADDRESS(symbol)                         \
    #define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value)    \
    #define SYMBOL_VALUE_BYTES(symbol)     (symbol)->value.bytes
    #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
    #define SYMBOL_BLOCK_VALUE(symbol)     (symbol)->value.block
    #define SYMBOL_VALUE_CHAIN(symbol)     (symbol)->value.chain
    #define MSYMBOL_VALUE(symbol)          (symbol)->value.ivalue
    #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0)
    #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                         \
    #define BMSYMBOL_VALUE_ADDRESS(symbol) \
    #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value)   \
    #define MSYMBOL_VALUE_BYTES(symbol)    (symbol)->value.bytes
    #define MSYMBOL_BLOCK_VALUE(symbol)    (symbol)->value.block

Replace them with equivalent methods on the appropriate objects.

Change-Id: Iafdab3b8eefc6dc2fd895aa955bf64fafc59ed50
2022-04-11 10:45:36 -04:00