#include "probe.h"
#include "location.h"
#include <vector>
+#include "common/array-view.h"
+#include "cli/cli-script.h"
struct value;
struct block;
struct breakpoint_ops
{
- /* Destructor. Releases everything from SELF (but not SELF
- itself). */
- void (*dtor) (struct breakpoint *self);
-
/* Allocate a location for this breakpoint. */
struct bp_location * (*allocate_location) (struct breakpoint *);
This function is called inside `create_breakpoint'. */
void (*create_breakpoints_sal) (struct gdbarch *,
struct linespec_result *,
- char *, char *,
+ gdb::unique_xmalloc_ptr<char>,
+ gdb::unique_xmalloc_ptr<char>,
enum bptype, enum bpdisp, int, int,
int, const struct breakpoint_ops *,
int, int, int, unsigned);
/* Given the location (second parameter), this method decodes it and
- provides the SAL locations related to it. For ordinary
+ returns the SAL locations related to it. For ordinary
breakpoints, it calls `decode_line_full'. If SEARCH_PSPACE is
not NULL, symbol search is restricted to just that program space.
This function is called inside `location_to_sals'. */
- void (*decode_location) (struct breakpoint *b,
- const struct event_location *location,
- struct program_space *search_pspace,
- struct symtabs_and_lines *sals);
+ std::vector<symtab_and_line> (*decode_location)
+ (struct breakpoint *b,
+ const struct event_location *location,
+ struct program_space *search_pspace);
/* Return true if this breakpoint explains a signal. See
bpstat_explains_signal. */
typedef struct bp_location *bp_location_p;
DEF_VEC_P(bp_location_p);
-/* A reference-counted struct command_line. This lets multiple
- breakpoints share a single command list. This is an implementation
+/* A reference-counted struct command_line. This is an implementation
detail to the breakpoints module. */
-struct counted_command_line;
+typedef std::shared_ptr<command_line> counted_command_line;
/* Some targets (e.g., embedded PowerPC) need two debug registers to set
a watchpoint over a memory region. If this flag is true, GDB will use
struct breakpoint
{
+ virtual ~breakpoint ();
+
/* Methods associated with this breakpoint. */
- const struct breakpoint_ops *ops;
+ const breakpoint_ops *ops = NULL;
- struct breakpoint *next;
+ breakpoint *next = NULL;
/* Type of breakpoint. */
- enum bptype type;
+ bptype type = bp_none;
/* Zero means disabled; remember the info but don't break here. */
- enum enable_state enable_state;
+ enum enable_state enable_state = bp_enabled;
/* What to do with this breakpoint after we hit it. */
- enum bpdisp disposition;
+ bpdisp disposition = disp_del;
/* Number assigned to distinguish breakpoints. */
- int number;
+ int number = 0;
/* Location(s) associated with this high-level breakpoint. */
- struct bp_location *loc;
+ bp_location *loc = NULL;
- /* Non-zero means a silent breakpoint (don't print frame info if we
- stop here). */
- unsigned char silent;
- /* Non-zero means display ADDR_STRING to the user verbatim. */
- unsigned char display_canonical;
+ /* True means a silent breakpoint (don't print frame info if we stop
+ here). */
+ bool silent = false;
+ /* True means display ADDR_STRING to the user verbatim. */
+ bool display_canonical = false;
/* Number of stops at this breakpoint that should be continued
automatically before really stopping. */
- int ignore_count;
+ int ignore_count = 0;
/* Number of stops at this breakpoint before it will be
disabled. */
- int enable_count;
+ int enable_count = 0;
/* Chain of command lines to execute when this breakpoint is
hit. */
- struct counted_command_line *commands;
+ counted_command_line commands;
/* Stack depth (address of frame). If nonzero, break only if fp
equals this. */
- struct frame_id frame_id;
+ struct frame_id frame_id = null_frame_id;
/* The program space used to set the breakpoint. This is only set
for breakpoints which are specific to a program space; for
non-thread-specific ordinary breakpoints this is NULL. */
- struct program_space *pspace;
+ program_space *pspace = NULL;
/* Location we used to set the breakpoint. */
event_location_up location;
/* The filter that should be passed to decode_line_full when
re-setting this breakpoint. This may be NULL, but otherwise is
allocated with xmalloc. */
- char *filter;
+ char *filter = NULL;
/* For a ranged breakpoint, the location we used to find the end of
the range. */
event_location_up location_range_end;
/* Architecture we used to set the breakpoint. */
- struct gdbarch *gdbarch;
+ struct gdbarch *gdbarch = NULL;
/* Language we used to set the breakpoint. */
- enum language language;
+ enum language language = language_unknown;
/* Input radix we used to set the breakpoint. */
- int input_radix;
+ int input_radix = 0;
/* String form of the breakpoint condition (malloc'd), or NULL if
there is no condition. */
- char *cond_string;
+ char *cond_string = NULL;
/* String form of extra parameters, or NULL if there are none.
Malloc'd. */
- char *extra_string;
+ char *extra_string = NULL;
/* Holds the address of the related watchpoint_scope breakpoint when
using watchpoints on local variables (might the concept of a
related breakpoint be useful elsewhere, if not just call it the
watchpoint_scope breakpoint or something like that. FIXME). */
- struct breakpoint *related_breakpoint;
+ breakpoint *related_breakpoint = NULL;
/* Thread number for thread-specific breakpoint, or -1 if don't
care. */
- int thread;
+ int thread = -1;
/* Ada task number for task-specific breakpoint, or 0 if don't
care. */
- int task;
+ int task = 0;
/* Count of the number of times this breakpoint was taken, dumped
with the info, but not used for anything else. Useful for seeing
how many times you hit a break prior to the program aborting, so
you can back up to just before the abort. */
- int hit_count;
+ int hit_count = 0;
/* Is breakpoint's condition not yet parsed because we found no
location initially so had no context to parse the condition
in. */
- int condition_not_parsed;
+ int condition_not_parsed = 0;
/* With a Python scripting enabled GDB, store a reference to the
Python object that has been associated with this breakpoint.
This is always NULL for a GDB that is not script enabled. It can
sometimes be NULL for enabled GDBs as not all breakpoint types
are tracked by the scripting language API. */
- struct gdbpy_breakpoint_object *py_bp_object;
+ gdbpy_breakpoint_object *py_bp_object = NULL;
/* Same as py_bp_object, but for Scheme. */
- struct gdbscm_breakpoint_object *scm_bp_object;
+ gdbscm_breakpoint_object *scm_bp_object = NULL;
};
-/* An instance of this type is used to represent a watchpoint. It
- includes a "struct breakpoint" as a kind of base class; users
- downcast to "struct breakpoint *" when needed. */
+/* An instance of this type is used to represent a watchpoint. */
-struct watchpoint
+struct watchpoint : public breakpoint
{
- /* The base class. */
- struct breakpoint base;
+ ~watchpoint () override;
/* String form of exp to use for displaying to the user (malloc'd),
or NULL if none. */
extern int is_watchpoint (const struct breakpoint *bpt);
/* An instance of this type is used to represent all kinds of
- tracepoints. It includes a "struct breakpoint" as a kind of base
- class; users downcast to "struct breakpoint *" when needed. */
+ tracepoints. */
-struct tracepoint
+struct tracepoint : public breakpoint
{
- /* The base class. */
- struct breakpoint base;
-
/* Number of times this tracepoint should single-step and collect
additional data. */
long step_count;
struct bpstats
{
+ bpstats ();
+ bpstats (struct bp_location *bl, bpstat **bs_link_pointer);
+ ~bpstats ();
+
+ bpstats (const bpstats &);
+ bpstats &operator= (const bpstats &) = delete;
+
/* Linked list because there can be more than one breakpoint at
the same place, and a bpstat reflects the fact that all have
been hit. */
struct breakpoint *breakpoint_at;
/* The associated command list. */
- struct counted_command_line *commands;
+ counted_command_line commands;
/* Old value associated with a watchpoint. */
struct value *old_val;
struct address_space *aspace2,
CORE_ADDR addr2);
-extern void until_break_command (char *, int, int);
+extern void until_break_command (const char *, int, int);
/* Initialize a struct bp_location. */
-extern void update_breakpoint_locations (struct breakpoint *b,
- struct program_space *filter_pspace,
- struct symtabs_and_lines sals,
- struct symtabs_and_lines sals_end);
+extern void update_breakpoint_locations
+ (struct breakpoint *b,
+ struct program_space *filter_pspace,
+ gdb::array_view<const symtab_and_line> sals,
+ gdb::array_view<const symtab_and_line> sals_end);
extern void breakpoint_re_set (void);
extern void hbreak_command_wrapper (char *, int);
extern void thbreak_command_wrapper (char *, int);
extern void rbreak_command_wrapper (char *, int);
-extern void watch_command_wrapper (char *, int, int);
-extern void awatch_command_wrapper (char *, int, int);
-extern void rwatch_command_wrapper (char *, int, int);
+extern void watch_command_wrapper (const char *, int, int);
+extern void awatch_command_wrapper (const char *, int, int);
+extern void rwatch_command_wrapper (const char *, int, int);
extern void tbreak_command (char *, int);
extern struct breakpoint_ops base_breakpoint_ops;
init_ada_exception_breakpoint (struct breakpoint *b,
struct gdbarch *gdbarch,
struct symtab_and_line sal,
- char *addr_string,
+ const char *addr_string,
const struct breakpoint_ops *ops,
int tempflag,
int enabled,
the internal breakpoint count. If UPDATE_GLL is non-zero,
update_global_location_list will be called. */
-extern void install_breakpoint (int internal, struct breakpoint *b,
+extern void install_breakpoint (int internal, std::unique_ptr<breakpoint> &&b,
int update_gll);
/* Flags that can be passed down to create_breakpoint, etc., to affect
extern int create_breakpoint (struct gdbarch *gdbarch,
const struct event_location *location,
- char *cond_string, int thread,
- char *extra_string,
+ const char *cond_string, int thread,
+ const char *extra_string,
int parse_extra,
int tempflag, enum bptype wanted_type,
int ignore_count,
extern void add_solib_catchpoint (const char *arg, int is_load, int is_temp,
int enabled);
-/* Enable breakpoints and delete when hit. Called with ARG == NULL
- deletes all breakpoints. */
-extern void delete_command (char *arg, int from_tty);
-
/* Create and insert a new software single step breakpoint for the
current thread. May be called multiple times; each time will add a
new location to the set of potential addresses the next instruction