This replaces some casts to 'tracepoint *' with checked_static_cast.
Some functions are changed to accept a 'tracepoint *' now, for better
type safety.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
{
if (is_tracepoint (b))
{
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (b);
struct command_line *c;
struct command_line *while_stepping = 0;
while_stepping = c;
}
- validate_actionline (c->line, b);
+ validate_actionline (c->line, t);
}
if (while_stepping)
{
auto do_validate = [=] (const char *line)
{
- validate_actionline (line, b);
+ tracepoint *t
+ = gdb::checked_static_cast<tracepoint *> (b);
+ validate_actionline (line, t);
};
gdb::function_view<void (const char *)> validator;
if (is_tracepoint (b))
if (!part_of_multiple && is_tracepoint (b))
{
- struct tracepoint *tp = (struct tracepoint *) b;
+ tracepoint *tp = gdb::checked_static_cast<tracepoint *> (b);
if (tp->traceframe_usage)
{
if (is_tracepoint (b))
{
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (b);
if (!part_of_multiple && t->pass_count)
{
if (type == bp_static_tracepoint
|| type == bp_static_marker_tracepoint)
{
- auto *t = gdb::checked_static_cast<struct tracepoint *> (this);
+ auto *t = gdb::checked_static_cast<tracepoint *> (this);
struct static_tracepoint_marker marker;
if (strace_marker_p (this))
precisely because it confuses tools). */
static struct symtab_and_line
-update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
+update_static_tracepoint (tracepoint *tp, struct symtab_and_line sal)
{
- struct tracepoint *tp = (struct tracepoint *) b;
struct static_tracepoint_marker marker;
CORE_ADDR pc;
{
if (tp->static_trace_marker_id != marker.str_id)
warning (_("static tracepoint %d changed probed marker from %s to %s"),
- b->number, tp->static_trace_marker_id.c_str (),
+ tp->number, tp->static_trace_marker_id.c_str (),
marker.str_id.c_str ());
tp->static_trace_marker_id = std::move (marker.str_id);
warning (_("marker for static tracepoint %d (%s) not "
"found at previous line number"),
- b->number, tp->static_trace_marker_id.c_str ());
+ tp->number, tp->static_trace_marker_id.c_str ());
symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
sym = find_pc_sect_function (tpmarker->address, NULL);
uiout->field_signed ("line", sal2.line);
uiout->text ("\n");
- b->first_loc ().line_number = sal2.line;
- b->first_loc ().symtab = sym != NULL ? sal2.symtab : NULL;
+ tp->first_loc ().line_number = sal2.line;
+ tp->first_loc ().symtab = sym != NULL ? sal2.symtab : NULL;
std::unique_ptr<explicit_location_spec> els
(new explicit_location_spec ());
els->source_filename
= xstrdup (symtab_to_filename_for_display (sal2.symtab));
- els->line_offset.offset = b->first_loc ().line_number;
+ els->line_offset.offset = tp->first_loc ().line_number;
els->line_offset.sign = LINE_OFFSET_NONE;
- b->locspec = std::move (els);
+ tp->locspec = std::move (els);
/* Might be nice to check if function changed, and warn if
so. */
}
if (type == bp_static_tracepoint)
- sals[0] = update_static_tracepoint (this, sals[0]);
+ {
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (this);
+ sals[0] = update_static_tracepoint (t, sals[0]);
+ }
*found = 1;
}
};
if (is_tracepoint (b))
- break_command = read_command_lines_1 (reader, 1,
- [=] (const char *line)
+ {
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (b);
+ break_command = read_command_lines_1 (reader, 1,
+ [=] (const char *line)
{
- validate_actionline (line, b);
+ validate_actionline (line, t);
});
+ }
else
break_command = read_command_lines_1 (reader, 1, 0);
int get_trace_status (struct trace_status *ts) override;
- void get_tracepoint_status (struct breakpoint *tp, struct uploaded_tp *utp)
+ void get_tracepoint_status (tracepoint *tp, struct uploaded_tp *utp)
override;
void trace_stop () override;
std::vector<std::string> stepping_actions;
char *pkt;
struct breakpoint *b = loc->owner;
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (b);
struct remote_state *rs = get_remote_state ();
int ret;
const char *err_msg = _("Tracepoint packet too large for target.");
}
void
-remote_target::get_tracepoint_status (struct breakpoint *bp,
+remote_target::get_tracepoint_status (tracepoint *tp,
struct uploaded_tp *utp)
{
struct remote_state *rs = get_remote_state ();
char *reply;
- struct tracepoint *tp = (struct tracepoint *) bp;
size_t size = get_remote_packet_size ();
if (tp)
if (reply && *reply)
{
if (*reply == 'V')
- parse_tracepoint_status (reply + 1, bp, utp);
+ parse_tracepoint_status (reply + 1, tp, utp);
}
}
}
if (reply && *reply)
{
if (*reply == 'V')
- parse_tracepoint_status (reply + 1, bp, utp);
+ parse_tracepoint_status (reply + 1, tp, utp);
}
}
}
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_breakpoint_p(X) \
target_debug_do_print (host_address_to_string (X))
+#define target_debug_print_tracepoint_p(X) \
+ target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_uploaded_tp_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_uploaded_tp_pp(X) \
void trace_set_readonly_regions () override;
void trace_start () override;
int get_trace_status (struct trace_status *arg0) override;
- void get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp *arg1) override;
+ void get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1) override;
void trace_stop () override;
int trace_find (enum trace_find_type arg0, int arg1, CORE_ADDR arg2, CORE_ADDR arg3, int *arg4) override;
bool get_trace_state_variable_value (int arg0, LONGEST *arg1) override;
void trace_set_readonly_regions () override;
void trace_start () override;
int get_trace_status (struct trace_status *arg0) override;
- void get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp *arg1) override;
+ void get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1) override;
void trace_stop () override;
int trace_find (enum trace_find_type arg0, int arg1, CORE_ADDR arg2, CORE_ADDR arg3, int *arg4) override;
bool get_trace_state_variable_value (int arg0, LONGEST *arg1) override;
}
void
-target_ops::get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp *arg1)
+target_ops::get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1)
{
this->beneath ()->get_tracepoint_status (arg0, arg1);
}
void
-dummy_target::get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp *arg1)
+dummy_target::get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1)
{
tcomplain ();
}
void
-debug_target::get_tracepoint_status (struct breakpoint *arg0, struct uploaded_tp *arg1)
+debug_target::get_tracepoint_status (tracepoint *arg0, struct uploaded_tp *arg1)
{
gdb_printf (gdb_stdlog, "-> %s->get_tracepoint_status (...)\n", this->beneath ()->shortname ());
this->beneath ()->get_tracepoint_status (arg0, arg1);
gdb_printf (gdb_stdlog, "<- %s->get_tracepoint_status (", this->beneath ()->shortname ());
- target_debug_print_struct_breakpoint_p (arg0);
+ target_debug_print_tracepoint_p (arg0);
gdb_puts (", ", gdb_stdlog);
target_debug_print_struct_uploaded_tp_p (arg1);
gdb_puts (")\n", gdb_stdlog);
x86_xsave_layout
debug_target::fetch_x86_xsave_layout ()
{
- x86_xsave_layout result;
gdb_printf (gdb_stdlog, "-> %s->fetch_x86_xsave_layout (...)\n", this->beneath ()->shortname ());
- result = this->beneath ()->fetch_x86_xsave_layout ();
+ x86_xsave_layout result
+ = this->beneath ()->fetch_x86_xsave_layout ();
gdb_printf (gdb_stdlog, "<- %s->fetch_x86_xsave_layout (", this->beneath ()->shortname ());
gdb_puts (") = ", gdb_stdlog);
target_debug_print_x86_xsave_layout (result);
}
void
-target_get_tracepoint_status (breakpoint *tp, uploaded_tp *utp)
+target_get_tracepoint_status (tracepoint *tp, uploaded_tp *utp)
{
return current_inferior ()->top_target ()->get_tracepoint_status (tp, utp);
}
virtual int get_trace_status (struct trace_status *ts)
TARGET_DEFAULT_RETURN (-1);
- virtual void get_tracepoint_status (struct breakpoint *tp,
+ virtual void get_tracepoint_status (tracepoint *tp,
struct uploaded_tp *utp)
TARGET_DEFAULT_NORETURN (tcomplain ());
extern int target_get_trace_status (trace_status *ts);
-extern void target_get_tracepoint_status (breakpoint *tp, uploaded_tp *utp);
+extern void target_get_tracepoint_status (tracepoint *tp, uploaded_tp *utp);
extern void target_trace_stop ();
bool get_trace_state_variable_value (int tsv, LONGEST *val) override;
traceframe_info_up traceframe_info () override;
- void get_tracepoint_status (struct breakpoint *tp,
+ void get_tracepoint_status (tracepoint *tp,
struct uploaded_tp *utp) override;
};
}
void
-tfile_target::get_tracepoint_status (struct breakpoint *tp, struct uploaded_tp *utp)
+tfile_target::get_tracepoint_status (tracepoint *tp, struct uploaded_tp *utp)
{
/* Other bits of trace status were collected as part of opening the
trace files, so nothing to do here. */
struct collection_list;
-static counted_command_line all_tracepoint_actions (struct breakpoint *);
+static counted_command_line all_tracepoint_actions (tracepoint *);
static struct trace_status trace_status;
/* worker function */
void
-validate_actionline (const char *line, struct breakpoint *b)
+validate_actionline (const char *line, tracepoint *t)
{
struct cmd_list_element *c;
const char *tmp_p;
const char *p;
- struct tracepoint *t = (struct tracepoint *) b;
/* If EOF is typed, *line is NULL. */
if (line == NULL)
gdbarch_virtual_frame_pointer (tloc->gdbarch,
tloc->address, &frame_reg, &frame_offset);
- counted_command_line actions = all_tracepoint_actions (tloc->owner);
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (tloc->owner);
+ counted_command_line actions = all_tracepoint_actions (t);
encode_actions_1 (actions.get (), tloc, frame_reg, frame_offset,
tracepoint_list, stepping_list);
encode_actions_1 (breakpoint_commands (tloc->owner), tloc,
(long int) (ts->stop_time % 1000000));
/* Now report any per-tracepoint status available. */
- for (breakpoint &t : all_tracepoints ())
- target_get_tracepoint_status (&t, NULL);
+ for (breakpoint &b : all_tracepoints ())
+ {
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (&b);
+ target_get_tracepoint_status (t, nullptr);
+ }
}
/* Report the trace status to uiout, in a way suitable for MI, and not
/* Return the default collect actions of a tracepoint T. */
static counted_command_line
-all_tracepoint_actions (struct breakpoint *t)
+all_tracepoint_actions (tracepoint *t)
{
counted_command_line actions (nullptr, command_lines_deleter ());
select_frame (get_current_frame ());
- counted_command_line actions = all_tracepoint_actions (loc->owner);
+ tracepoint *t = gdb::checked_static_cast<tracepoint *> (loc->owner);
+ counted_command_line actions = all_tracepoint_actions (t);
trace_dump_actions (actions.get (), 0, stepping_frame, from_tty);
trace_dump_actions (breakpoint_commands (loc->owner), 0, stepping_frame,
/* Mark this location as already inserted. */
loc->inserted = 1;
- t = (struct tracepoint *) loc->owner;
+ t = gdb::checked_static_cast<tracepoint *> (loc->owner);
gdb_printf (_("Assuming tracepoint %d is same "
"as target's tracepoint %d at %s.\n"),
loc->owner->number, utp->number,
}
void
-parse_tracepoint_status (const char *p, struct breakpoint *bp,
+parse_tracepoint_status (const char *p, tracepoint *tp,
struct uploaded_tp *utp)
{
ULONGEST uval;
- struct tracepoint *tp = (struct tracepoint *) bp;
p = unpack_varlen_hex (p, &uval);
if (tp)
std::vector<std::string> *tdp_actions,
std::vector<std::string> *stepping_actions);
-extern void validate_actionline (const char *, struct breakpoint *);
+extern void validate_actionline (const char *, tracepoint *);
extern void validate_trace_state_variable_name (const char *name);
extern struct trace_state_variable *find_trace_state_variable (const char *name);
extern void parse_trace_status (const char *line, struct trace_status *ts);
-extern void parse_tracepoint_status (const char *p, struct breakpoint *tp,
+extern void parse_tracepoint_status (const char *p, tracepoint *tp,
struct uploaded_tp *utp);
extern void parse_tracepoint_definition (const char *line,