1551 Commits

Author SHA1 Message Date
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
Simon Marchi
3c86fae3d9 gdb: remove symtab::objfile
Same idea as previous patch, but for symtab::objfile.  I find
it clearer without this wrapper, as it shows that the objfile is
common to all symtabs of a given compunit.  Otherwise, you could think
that each symtab (of a given compunit) can have a specific objfile.

Change-Id: Ifc0dbc7ec31a06eefa2787c921196949d5a6fcc6
2022-04-07 13:05:22 -04:00
Tom Tromey
49a82d50c0 Remove dbx mode
This patch removes gdb's dbx mode.  Regression tested on x86-64 Fedora
34.
2022-03-31 13:48:07 -06:00
Tom Tromey
6cb06a8cda Unify gdb printf functions
Now that filtered and unfiltered output can be treated identically, we
can unify the printf family of functions.  This is done under the name
"gdb_printf".  Most of this patch was written by script.
2022-03-29 12:46:24 -06:00
Tom Tromey
a11ac3b3e8 Unify gdb putc functions
Now that filtered and unfiltered output can be treated identically, we
can unify the putc family of functions.  This is done under the name
"gdb_putc".  Most of this patch was written by script.
2022-03-29 12:46:24 -06:00
Pedro Alves
d37e084783 Watchpoint followed by catchpoint misreports watchpoint (PR gdb/28621)
If GDB reports a watchpoint hit, and then the next event is not
TARGET_WAITKIND_STOPPED, but instead some event for which there's a
catchpoint, such that GDB calls bpstat_stop_status, GDB mistakenly
thinks the watchpoint triggered.  Vis, using foll-fork.c:

  (gdb) awatch v
  Hardware access (read/write) watchpoint 2: v
  (gdb) catch fork
  Catchpoint 3 (fork)
  (gdb) c
  Continuing.

  Hardware access (read/write) watchpoint 2: v

  Old value = 0
  New value = 5
  main () at gdb.base/foll-fork.c:16
  16        pid = fork ();
  (gdb)
  Continuing.

  Hardware access (read/write) watchpoint 2: v      <<<<
                                                    <<<< these lines are spurious
  Value = 5                                         <<<<

  Catchpoint 3 (forked process 1712369), arch_fork (ctid=0x7ffff7fa4810) at arch-fork.h:49
  49      arch-fork.h: No such file or directory.
  (gdb)

The problem is that when we handle the fork event, nothing called
watchpoints_triggered before calling bpstat_stop_status.  Thus, each
watchpoint's watchpoint_triggered field was still set to
watch_triggered_yes from the previous (real) watchpoint stop.
watchpoint_triggered is only current called in the handle_signal_stop
path, when handling TARGET_WAITKIND_STOPPED.

This fixes it by adding watchpoint_triggered calls in the other events
paths that call bpstat_stop_status.  But instead of adding them
explicitly, it adds a new function bpstat_stop_status_nowatch that
wraps bpstat_stop_status and calls watchpoint_triggered, and then
replaces most calls to bpstat_stop_status with calls to
bpstat_stop_status_nowatch.

This required constifying watchpoints_triggered.

New test included, which fails without the fix.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28621

Change-Id: I282b38c2eee428d25319af3bc842f9feafed461c
2022-03-21 17:27:17 +00:00
Tom Tromey
f6b3ad5440 Add constructor to bound_minimal_symbol
This adds a constructor to bound_minimal_symbol, to avoid a build
failure with clang that Simon pointed out.

I also took the opportunity to remove some redundant initializations,
and to change one use of push_back to emplace_back, as suggested by
Simon.
2022-02-18 12:58:35 -07:00
Lancelot SIX
573269a87c gdb: make thread_info::m_thread_fsm a std::unique_ptr
While working on function calls, I realized that the thread_fsm member
of struct thread_info is a raw pointer to a resource it owns.  This
commit changes the type of the thread_fsm member to a std::unique_ptr in
order to signify this ownership relationship and slightly ease resource
management (no need to manually call delete).

To ensure consistent use, the field is made a private member
(m_thread_fsm).  The setter method (set_thread_fsm) can then check
that it is incorrect to associate a FSM to a thread_info object if
another one is already in place.  This is ensured by an assertion.

The function run_inferior_call takes an argument as a pointer to a
call_thread_fsm and installs it in it in a thread_info instance.  Also
change this function's signature to accept a unique_ptr in order to
signify that the ownership of the call_thread_fsm is transferred during
the call.

No user visible change expected after this commit.

Tested on x86_64-linux with no regression observed.

Change-Id: Ia1224f72a4afa247801ce6650ce82f90224a9ae8
2022-02-07 06:12:06 -05:00
Simon Marchi
652099717d gdb: remove SYMTAB_OBJFILE macro
Remove the macro, replace with an equivalent method.

Change-Id: I8f9ecd290ad28502e53c1ceca5006ba78bf042eb
2022-02-06 16:03:46 -05:00
Simon Marchi
c615965258 gdb: remove SYMTAB_COMPUNIT macro, add getter/setter
Add a getter and a setter for a symtab's compunit_symtab.  Remove the
corresponding macro and adjust all callers.

For brevity, I chose the name "compunit" instead of "compunit_symtab"
the the field, getter and setter names.  Since we are already in symtab
context, the _symtab suffix seems redundant.

Change-Id: I4b9b731c96e3594f7733e75af1e3d01bc0e4fe92
2022-02-06 15:48:19 -05:00