#include "dummy-frame.h"
#include "interps.h"
#include "format.h"
+#include "location.h"
+#include "thread-fsm.h"
/* readline include files */
#include "readline/readline.h"
static void breakpoint_re_set_default (struct breakpoint *);
-static void create_sals_from_address_default (char **,
- struct linespec_result *,
- enum bptype, char *,
- char **);
+static void
+ create_sals_from_location_default (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted);
static void create_breakpoints_sal_default (struct gdbarch *,
struct linespec_result *,
const struct breakpoint_ops *,
int, int, int, unsigned);
-static void decode_linespec_default (struct breakpoint *, char **,
- struct symtabs_and_lines *);
+static void decode_location_default (struct breakpoint *b,
+ const struct event_location *location,
+ struct symtabs_and_lines *sals);
static void clear_command (char *, int);
static struct counted_command_line *
alloc_counted_command_line (struct command_line *commands)
{
- struct counted_command_line *result
- = xmalloc (sizeof (struct counted_command_line));
+ struct counted_command_line *result = XNEW (struct counted_command_line);
result->refc = 1;
result->commands = commands;
+
return result;
}
bp_objfile_data = objfile_data (objfile, breakpoint_objfile_key);
if (bp_objfile_data == NULL)
{
- bp_objfile_data = obstack_alloc (&objfile->objfile_obstack,
- sizeof (*bp_objfile_data));
+ bp_objfile_data =
+ XOBNEW (&objfile->objfile_obstack, struct breakpoint_objfile_data);
memset (bp_objfile_data, 0, sizeof (*bp_objfile_data));
set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
struct breakpoint *b;
struct breakpoint_objfile_data *bp_objfile_data;
CORE_ADDR addr;
+ struct explicit_location explicit_loc;
bp_objfile_data = get_breakpoint_objfile_data (objfile);
b = create_internal_breakpoint (get_objfile_arch (objfile), addr,
bp_overlay_event,
&internal_breakpoint_ops);
- b->addr_string = xstrdup (func_name);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
if (overlay_debugging == ovly_auto)
{
objfile),
bp_longjmp_master,
&internal_breakpoint_ops);
- b->addr_string = xstrdup ("-probe-stap libc:longjmp");
+ b->location
+ = new_probe_location ("-probe-stap libc:longjmp");
b->enable_state = bp_disabled;
}
struct breakpoint *b;
const char *func_name;
CORE_ADDR addr;
+ struct explicit_location explicit_loc;
if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym))
continue;
addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]);
b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
&internal_breakpoint_ops);
- b->addr_string = xstrdup (func_name);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
b->enable_state = bp_disabled;
}
}
{
struct breakpoint *b;
struct breakpoint_objfile_data *bp_objfile_data;
+ struct explicit_location explicit_loc;
bp_objfile_data = get_breakpoint_objfile_data (objfile);
b = create_internal_breakpoint (get_objfile_arch (objfile), addr,
bp_std_terminate_master,
&internal_breakpoint_ops);
- b->addr_string = xstrdup (func_name);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
b->enable_state = bp_disabled;
}
}
struct gdbarch *gdbarch;
struct breakpoint_objfile_data *bp_objfile_data;
CORE_ADDR addr;
+ struct explicit_location explicit_loc;
bp_objfile_data = get_breakpoint_objfile_data (objfile);
objfile),
bp_exception_master,
&internal_breakpoint_ops);
- b->addr_string = xstrdup ("-probe-stap libgcc:unwind");
+ b->location
+ = new_probe_location ("-probe-stap libgcc:unwind");
b->enable_state = bp_disabled;
}
¤t_target);
b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
&internal_breakpoint_ops);
- b->addr_string = xstrdup (func_name);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
b->enable_state = bp_disabled;
}
/* Without a symbolic address, we have little hope of the
pre-exec() address meaning the same thing in the post-exec()
a.out. */
- if (b->addr_string == NULL)
+ if (event_location_empty_p (b->location))
{
delete_breakpoint (b);
continue;
if (breakpoint_proceeded)
{
- if (interpreter_async && target_can_async_p ())
+ if (interpreter_async)
/* If we are in async mode, then the target might be still
running, not stopped at any breakpoint, so nothing for
us to do here -- just return to the event loop. */
struct frame_info *frame;
struct gdbarch *gdbarch;
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "handling bp_jit_event\n");
+
/* Switch terminal for any messages produced by
breakpoint_re_set. */
target_terminal_ours_for_output ();
retval.main_action = max (retval.main_action, this_action);
}
- /* These operations may affect the bs->breakpoint_at state so they are
- delayed after MAIN_ACTION is decided above. */
-
- if (jit_event)
- {
- if (debug_infrun)
- fprintf_unfiltered (gdb_stdlog, "bpstat_what: bp_jit_event\n");
+ return retval;
+}
- handle_jit_event ();
- }
+void
+bpstat_run_callbacks (bpstat bs_head)
+{
+ bpstat bs;
for (bs = bs_head; bs != NULL; bs = bs->next)
{
continue;
switch (b->type)
{
+ case bp_jit_event:
+ handle_jit_event ();
+ break;
case bp_gnu_ifunc_resolver:
gnu_ifunc_resolver_stop (b);
break;
break;
}
}
-
- return retval;
}
/* Nonzero if we should step constantly (e.g. watchpoints on machines
set_current_program_space (loc->pspace);
if (b->display_canonical)
- ui_out_field_string (uiout, "what", b->addr_string);
+ ui_out_field_string (uiout, "what",
+ event_location_to_string (b->location));
else if (loc && loc->symtab)
{
struct symbol *sym
do_cleanups (stb_chain);
}
else
- ui_out_field_string (uiout, "pending", b->addr_string);
+ {
+ ui_out_field_string (uiout, "pending",
+ event_location_to_string (b->location));
+ /* If extra_string is available, it could be holding a condition
+ or dprintf arguments. In either case, make sure it is printed,
+ too, but only for non-MI streams. */
+ if (!ui_out_is_mi_like_p (uiout) && b->extra_string != NULL)
+ {
+ if (b->type == bp_dprintf)
+ ui_out_text (uiout, ",");
+ else
+ ui_out_text (uiout, " ");
+ ui_out_text (uiout, b->extra_string);
+ }
+ }
if (loc && is_breakpoint (b)
&& breakpoint_condition_evaluation_mode () == condition_evaluation_target
ui_out_field_string (uiout, "original-location", w->exp_string);
}
- else if (b->addr_string)
- ui_out_field_string (uiout, "original-location", b->addr_string);
+ else if (b->location != NULL
+ && event_location_to_string (b->location) != NULL)
+ ui_out_field_string (uiout, "original-location",
+ event_location_to_string (b->location));
}
}
\f
/* Return true iff it is meaningful to use the address member of
- BPT. For some breakpoint types, the address member is irrelevant
- and it makes no sense to attempt to compare it to other addresses
- (or use it for any other purpose either).
+ BPT locations. For some breakpoint types, the locations' address members
+ are irrelevant and it makes no sense to attempt to compare them to other
+ addresses (or use them for any other purpose either).
More specifically, each of the following breakpoint types will
- always have a zero valued address and we don't want to mark
+ always have a zero valued location address and we don't want to mark
breakpoints of any of these types to be a duplicate of an actual
- breakpoint at address zero:
+ breakpoint location at address zero:
bp_watchpoint
bp_catchpoint
b->condition_not_parsed = 0;
b->py_bp_object = NULL;
b->related_breakpoint = b;
+ b->location = NULL;
}
/* Helper to set_raw_breakpoint below. Creates a breakpoint
&internal_breakpoint_ops);
b->enable_state = bp_enabled;
- /* addr_string has to be used or breakpoint_re_set will delete me. */
- b->addr_string
- = xstrprintf ("*%s", paddress (b->loc->gdbarch, b->loc->address));
+ /* location has to be used or breakpoint_re_set will delete me. */
+ b->location = new_address_location (b->loc->address);
update_global_location_list_nothrow (UGLL_MAY_INSERT);
gdb_assert (loc != NULL);
+ /* If we have a catchpoint or a watchpoint, just return 0. We should not
+ attempt to read from the addresses the locations of these breakpoint types
+ point to. program_breakpoint_here_p, below, will attempt to read
+ memory. */
+ if (!breakpoint_address_is_meaningful (loc->owner))
+ return 0;
+
cleanup = save_current_space_and_thread ();
switch_to_program_space_and_thread (loc->pspace);
gdb_assert (printf_line != NULL);
/* Manufacture a printf sequence. */
{
- struct command_line *printf_cmd_line
- = xmalloc (sizeof (struct command_line));
+ struct command_line *printf_cmd_line = XNEW (struct command_line);
printf_cmd_line->control_type = simple_control;
printf_cmd_line->body_count = 0;
}
}
-/* Create a breakpoint with SAL as location. Use ADDR_STRING
- as textual description of the location, and COND_STRING
+/* Create a breakpoint with SAL as location. Use LOCATION
+ as a description of the location, and COND_STRING
as condition expression. */
static void
init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
- struct symtabs_and_lines sals, char *addr_string,
+ struct symtabs_and_lines sals,
+ struct event_location *location,
char *filter, char *cond_string,
char *extra_string,
enum bptype type, enum bpdisp disposition,
{
/* We already know the marker exists, otherwise, we
wouldn't see a sal for it. */
- char *p = &addr_string[3];
- char *endp;
+ const char *p = &event_location_to_string (b->location)[3];
+ const char *endp;
char *marker_str;
- p = skip_spaces (p);
+ p = skip_spaces_const (p);
- endp = skip_to_space (p);
+ endp = skip_to_space_const (p);
marker_str = savestring (p, endp - p);
t->static_trace_marker_id = marker_str;
}
b->display_canonical = display_canonical;
- if (addr_string)
- b->addr_string = addr_string;
+ if (location != NULL)
+ b->location = location;
else
- /* addr_string has to be used or breakpoint_re_set will delete
- me. */
- b->addr_string
- = xstrprintf ("*%s", paddress (b->loc->gdbarch, b->loc->address));
+ b->location = new_address_location (b->loc->address);
b->filter = filter;
}
static void
create_breakpoint_sal (struct gdbarch *gdbarch,
- struct symtabs_and_lines sals, char *addr_string,
+ struct symtabs_and_lines sals,
+ struct event_location *location,
char *filter, char *cond_string,
char *extra_string,
enum bptype type, enum bpdisp disposition,
old_chain = make_cleanup (xfree, b);
init_breakpoint_sal (b, gdbarch,
- sals, addr_string,
+ sals, location,
filter, cond_string, extra_string,
type, disposition,
thread, task, ignore_count,
for (i = 0; VEC_iterate (linespec_sals, canonical->sals, i, lsal); ++i)
{
- /* Note that 'addr_string' can be NULL in the case of a plain
+ /* Note that 'location' can be NULL in the case of a plain
'break', without arguments. */
- char *addr_string = (canonical->addr_string
- ? xstrdup (canonical->addr_string)
- : NULL);
+ struct event_location *location
+ = (canonical->location != NULL
+ ? copy_event_location (canonical->location) : NULL);
char *filter_string = lsal->canonical ? xstrdup (lsal->canonical) : NULL;
- struct cleanup *inner = make_cleanup (xfree, addr_string);
+ struct cleanup *inner = make_cleanup_delete_event_location (location);
make_cleanup (xfree, filter_string);
create_breakpoint_sal (gdbarch, lsal->sals,
- addr_string,
+ location,
filter_string,
cond_string, extra_string,
type, disposition,
}
}
-/* Parse ADDRESS which is assumed to be a SAL specification possibly
+/* Parse LOCATION which is assumed to be a SAL specification possibly
followed by conditionals. On return, SALS contains an array of SAL
- addresses found. ADDR_STRING contains a vector of (canonical)
- address strings. ADDRESS points to the end of the SAL.
+ addresses found. LOCATION points to the end of the SAL (for
+ linespec locations).
The array and the line spec strings are allocated on the heap, it is
the caller's responsibility to free them. */
static void
-parse_breakpoint_sals (char **address,
+parse_breakpoint_sals (const struct event_location *location,
struct linespec_result *canonical)
{
- /* If no arg given, or if first arg is 'if ', use the default
- breakpoint. */
- if ((*address) == NULL || linespec_lexer_lex_keyword (*address))
- {
- /* The last displayed codepoint, if it's valid, is our default breakpoint
- address. */
- if (last_displayed_sal_is_valid ())
- {
- struct linespec_sals lsal;
- struct symtab_and_line sal;
- CORE_ADDR pc;
-
- init_sal (&sal); /* Initialize to zeroes. */
- lsal.sals.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line));
-
- /* Set sal's pspace, pc, symtab, and line to the values
- corresponding to the last call to print_frame_info.
- Be sure to reinitialize LINE with NOTCURRENT == 0
- as the breakpoint line number is inappropriate otherwise.
- find_pc_line would adjust PC, re-set it back. */
- get_last_displayed_sal (&sal);
- pc = sal.pc;
- sal = find_pc_line (pc, 0);
-
- /* "break" without arguments is equivalent to "break *PC"
- where PC is the last displayed codepoint's address. So
- make sure to set sal.explicit_pc to prevent GDB from
- trying to expand the list of sals to include all other
- instances with the same symtab and line. */
- sal.pc = pc;
- sal.explicit_pc = 1;
-
- lsal.sals.sals[0] = sal;
- lsal.sals.nelts = 1;
- lsal.canonical = NULL;
-
- VEC_safe_push (linespec_sals, canonical->sals, &lsal);
+ struct symtab_and_line cursal;
+
+ if (event_location_type (location) == LINESPEC_LOCATION)
+ {
+ const char *address = get_linespec_location (location);
+
+ if (address == NULL)
+ {
+ /* The last displayed codepoint, if it's valid, is our default
+ breakpoint address. */
+ if (last_displayed_sal_is_valid ())
+ {
+ struct linespec_sals lsal;
+ struct symtab_and_line sal;
+ CORE_ADDR pc;
+
+ init_sal (&sal); /* Initialize to zeroes. */
+ lsal.sals.sals = XNEW (struct symtab_and_line);
+
+ /* Set sal's pspace, pc, symtab, and line to the values
+ corresponding to the last call to print_frame_info.
+ Be sure to reinitialize LINE with NOTCURRENT == 0
+ as the breakpoint line number is inappropriate otherwise.
+ find_pc_line would adjust PC, re-set it back. */
+ get_last_displayed_sal (&sal);
+ pc = sal.pc;
+ sal = find_pc_line (pc, 0);
+
+ /* "break" without arguments is equivalent to "break *PC"
+ where PC is the last displayed codepoint's address. So
+ make sure to set sal.explicit_pc to prevent GDB from
+ trying to expand the list of sals to include all other
+ instances with the same symtab and line. */
+ sal.pc = pc;
+ sal.explicit_pc = 1;
+
+ lsal.sals.sals[0] = sal;
+ lsal.sals.nelts = 1;
+ lsal.canonical = NULL;
+
+ VEC_safe_push (linespec_sals, canonical->sals, &lsal);
+ return;
+ }
+ else
+ error (_("No default breakpoint address now."));
}
- else
- error (_("No default breakpoint address now."));
}
- else
+
+ /* Force almost all breakpoints to be in terms of the
+ current_source_symtab (which is decode_line_1's default).
+ This should produce the results we want almost all of the
+ time while leaving default_breakpoint_* alone.
+
+ ObjC: However, don't match an Objective-C method name which
+ may have a '+' or '-' succeeded by a '['. */
+ cursal = get_current_source_symtab_and_line ();
+ if (last_displayed_sal_is_valid ())
{
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ const char *address = NULL;
- /* Force almost all breakpoints to be in terms of the
- current_source_symtab (which is decode_line_1's default).
- This should produce the results we want almost all of the
- time while leaving default_breakpoint_* alone.
+ if (event_location_type (location) == LINESPEC_LOCATION)
+ address = get_linespec_location (location);
- ObjC: However, don't match an Objective-C method name which
- may have a '+' or '-' succeeded by a '['. */
- if (last_displayed_sal_is_valid ()
- && (!cursal.symtab
- || ((strchr ("+-", (*address)[0]) != NULL)
- && ((*address)[1] != '['))))
- decode_line_full (address, DECODE_LINE_FUNFIRSTLINE,
- get_last_displayed_symtab (),
- get_last_displayed_line (),
- canonical, NULL, NULL);
- else
- decode_line_full (address, DECODE_LINE_FUNFIRSTLINE,
- cursal.symtab, cursal.line, canonical, NULL, NULL);
+ if (!cursal.symtab
+ || (address != NULL
+ && strchr ("+-", address[0]) != NULL
+ && address[1] != '['))
+ {
+ decode_line_full (location, DECODE_LINE_FUNFIRSTLINE,
+ get_last_displayed_symtab (),
+ get_last_displayed_line (),
+ canonical, NULL, NULL);
+ return;
+ }
}
+
+ decode_line_full (location, DECODE_LINE_FUNFIRSTLINE,
+ cursal.symtab, cursal.line, canonical, NULL, NULL);
}
/* Decode a static tracepoint marker spec. */
static struct symtabs_and_lines
-decode_static_tracepoint_spec (char **arg_p)
+decode_static_tracepoint_spec (const char **arg_p)
{
VEC(static_tracepoint_marker_p) *markers = NULL;
struct symtabs_and_lines sals;
struct cleanup *old_chain;
- char *p = &(*arg_p)[3];
- char *endp;
+ const char *p = &(*arg_p)[3];
+ const char *endp;
char *marker_str;
int i;
- p = skip_spaces (p);
+ p = skip_spaces_const (p);
- endp = skip_to_space (p);
+ endp = skip_to_space_const (p);
marker_str = savestring (p, endp - p);
old_chain = make_cleanup (xfree, marker_str);
error (_("No known static tracepoint marker named %s"), marker_str);
sals.nelts = VEC_length(static_tracepoint_marker_p, markers);
- sals.sals = xmalloc (sizeof *sals.sals * sals.nelts);
+ sals.sals = XNEWVEC (struct symtab_and_line, sals.nelts);
for (i = 0; i < sals.nelts; i++)
{
return sals;
}
-/* Set a breakpoint. This function is shared between CLI and MI
- functions for setting a breakpoint. This function has two major
- modes of operations, selected by the PARSE_ARG parameter. If
- non-zero, the function will parse ARG, extracting location,
- condition, thread and extra string. Otherwise, ARG is just the
- breakpoint's location, with condition, thread, and extra string
- specified by the COND_STRING, THREAD and EXTRA_STRING parameters.
- If INTERNAL is non-zero, the breakpoint number will be allocated
- from the internal breakpoint count. Returns true if any breakpoint
- was created; false otherwise. */
+/* See breakpoint.h. */
int
create_breakpoint (struct gdbarch *gdbarch,
- char *arg, char *cond_string,
+ const struct event_location *location, char *cond_string,
int thread, char *extra_string,
- int parse_arg,
+ int parse_extra,
int tempflag, enum bptype type_wanted,
int ignore_count,
enum auto_boolean pending_break_support,
int from_tty, int enabled, int internal,
unsigned flags)
{
- char *copy_arg = NULL;
- char *addr_start = arg;
struct linespec_result canonical;
struct cleanup *old_chain;
struct cleanup *bkpt_chain = NULL;
gdb_assert (ops != NULL);
+ /* If extra_string isn't useful, set it to NULL. */
+ if (extra_string != NULL && *extra_string == '\0')
+ extra_string = NULL;
+
init_linespec_result (&canonical);
TRY
{
- ops->create_sals_from_address (&arg, &canonical, type_wanted,
- addr_start, ©_arg);
+ ops->create_sals_from_location (location, &canonical, type_wanted);
}
CATCH (e, RETURN_MASK_ERROR)
{
a pending breakpoint and selected yes, or pending
breakpoint behavior is on and thus a pending breakpoint
is defaulted on behalf of the user. */
- {
- struct linespec_sals lsal;
-
- copy_arg = xstrdup (addr_start);
- lsal.canonical = xstrdup (copy_arg);
- lsal.sals.nelts = 1;
- lsal.sals.sals = XNEW (struct symtab_and_line);
- init_sal (&lsal.sals.sals[0]);
- pending = 1;
- VEC_safe_push (linespec_sals, canonical.sals, &lsal);
- }
+ pending = 1;
}
else
throw_exception (e);
}
END_CATCH
- if (VEC_empty (linespec_sals, canonical.sals))
+ if (!pending && VEC_empty (linespec_sals, canonical.sals))
return 0;
/* Create a chain of things that always need to be cleaned up. */
breakpoint. */
if (!pending)
{
- if (parse_arg)
+ if (parse_extra)
{
char *rest;
struct linespec_sals *lsal;
sal is OK. When setting the breakpoint we'll
re-parse it in context of each sal. */
- find_condition_and_thread (arg, lsal->sals.sals[0].pc, &cond_string,
- &thread, &task, &rest);
+ find_condition_and_thread (extra_string, lsal->sals.sals[0].pc,
+ &cond_string, &thread, &task, &rest);
if (cond_string)
make_cleanup (xfree, cond_string);
if (rest)
make_cleanup (xfree, rest);
if (rest)
extra_string = rest;
+ else
+ extra_string = NULL;
}
else
{
- if (*arg != '\0')
- error (_("Garbage '%s' at end of location"), arg);
+ if (type_wanted != bp_dprintf
+ && extra_string != NULL && *extra_string != '\0')
+ error (_("Garbage '%s' at end of location"), extra_string);
/* Create a private copy of condition string. */
if (cond_string)
{
struct breakpoint *b;
- make_cleanup (xfree, copy_arg);
-
if (is_tracepoint_type (type_wanted))
{
struct tracepoint *t;
b = XNEW (struct breakpoint);
init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops);
+ b->location = copy_event_location (location);
- b->addr_string = copy_arg;
- if (parse_arg)
- {
- b->cond_string = NULL;
- b->extra_string = NULL;
- }
+ if (parse_extra)
+ b->cond_string = NULL;
else
{
/* Create a private copy of condition string. */
cond_string = xstrdup (cond_string);
make_cleanup (xfree, cond_string);
}
- /* Create a private copy of any extra string. */
- if (extra_string != NULL)
- {
- extra_string = xstrdup (extra_string);
- make_cleanup (xfree, extra_string);
- }
b->cond_string = cond_string;
- b->extra_string = extra_string;
b->thread = thread;
}
+
+ /* Create a private copy of any extra string. */
+ if (extra_string != NULL)
+ {
+ extra_string = xstrdup (extra_string);
+ make_cleanup (xfree, extra_string);
+ }
+ b->extra_string = extra_string;
b->ignore_count = ignore_count;
b->disposition = tempflag ? disp_del : disp_donttouch;
b->condition_not_parsed = 1;
? bp_hardware_breakpoint
: bp_breakpoint);
struct breakpoint_ops *ops;
- const char *arg_cp = arg;
+ struct event_location *location;
+ struct cleanup *cleanup;
+
+ location = string_to_event_location (&arg, current_language);
+ cleanup = make_cleanup_delete_event_location (location);
/* Matching breakpoints on probes. */
- if (arg && probe_linespec_to_ops (&arg_cp) != NULL)
+ if (location != NULL
+ && event_location_type (location) == PROBE_LOCATION)
ops = &bkpt_probe_breakpoint_ops;
else
ops = &bkpt_breakpoint_ops;
create_breakpoint (get_current_arch (),
- arg,
- NULL, 0, NULL, 1 /* parse arg */,
+ location,
+ NULL, 0, arg, 1 /* parse arg */,
tempflag, type_wanted,
0 /* Ignore count */,
pending_break_support,
1 /* enabled */,
0 /* internal */,
0);
+ do_cleanups (cleanup);
}
/* Helper function for break_command_1 and disassemble_command. */
static void
dprintf_command (char *arg, int from_tty)
{
+ struct event_location *location;
+ struct cleanup *cleanup;
+
+ location = string_to_event_location (&arg, current_language);
+ cleanup = make_cleanup_delete_event_location (location);
+
+ /* If non-NULL, ARG should have been advanced past the location;
+ the next character must be ','. */
+ if (arg != NULL)
+ {
+ if (arg[0] != ',' || arg[1] == '\0')
+ error (_("Format string required"));
+ else
+ {
+ /* Skip the comma. */
+ ++arg;
+ }
+ }
+
create_breakpoint (get_current_arch (),
- arg,
- NULL, 0, NULL, 1 /* parse arg */,
+ location,
+ NULL, 0, arg, 1 /* parse arg */,
0, bp_dprintf,
0 /* Ignore count */,
pending_break_support,
1 /* enabled */,
0 /* internal */,
0);
+ do_cleanups (cleanup);
}
static void
static void
print_recreate_ranged_breakpoint (struct breakpoint *b, struct ui_file *fp)
{
- fprintf_unfiltered (fp, "break-range %s, %s", b->addr_string,
- b->addr_string_range_end);
+ fprintf_unfiltered (fp, "break-range %s, %s",
+ event_location_to_string (b->location),
+ event_location_to_string (b->location_range_end));
print_recreate_thread (b, fp);
}
struct symtab_and_line sal_start, sal_end;
struct cleanup *cleanup_bkpt;
struct linespec_sals *lsal_start, *lsal_end;
+ struct event_location *start_location, *end_location;
/* We don't support software ranged breakpoints. */
if (target_ranged_break_num_registers () < 0)
init_linespec_result (&canonical_start);
arg_start = arg;
- parse_breakpoint_sals (&arg, &canonical_start);
-
- cleanup_bkpt = make_cleanup_destroy_linespec_result (&canonical_start);
+ start_location = string_to_event_location (&arg, current_language);
+ cleanup_bkpt = make_cleanup_delete_event_location (start_location);
+ parse_breakpoint_sals (start_location, &canonical_start);
+ make_cleanup_destroy_linespec_result (&canonical_start);
if (arg[0] != ',')
error (_("Too few arguments."));
symtab and line as the default symtab and line for the end of the
range. This makes it possible to have ranges like "foo.c:27, +14",
where +14 means 14 lines from the start location. */
- decode_line_full (&arg, DECODE_LINE_FUNFIRSTLINE,
+ end_location = string_to_event_location (&arg, current_language);
+ make_cleanup_delete_event_location (end_location);
+ decode_line_full (end_location, DECODE_LINE_FUNFIRSTLINE,
sal_start.symtab, sal_start.line,
&canonical_end, NULL, NULL);
error (_("Cannot create a ranged breakpoint with multiple locations."));
sal_end = lsal_end->sals.sals[0];
- addr_string_end = savestring (arg_start, arg - arg_start);
- make_cleanup (xfree, addr_string_end);
end = find_breakpoint_range_end (sal_end);
if (sal_start.pc > end)
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->disposition = disp_donttouch;
- b->addr_string = xstrdup (addr_string_start);
- b->addr_string_range_end = xstrdup (addr_string_end);
+ b->location = copy_event_location (start_location);
+ b->location_range_end = copy_event_location (end_location);
b->loc->length = length;
do_cleanups (cleanup_bkpt);
}
\f
-/* Helper routines for the until_command routine in infcmd.c. Here
- because it uses the mechanisms of breakpoints. */
+/* Data for the FSM that manages the until(location)/advance commands
+ in infcmd.c. Here because it uses the mechanisms of
+ breakpoints. */
+
+struct until_break_fsm
+{
+ /* The base class. */
+ struct thread_fsm thread_fsm;
+
+ /* The thread that as current when the command was executed. */
+ int thread;
-struct until_break_command_continuation_args
+ /* The breakpoint set at the destination location. */
+ struct breakpoint *location_breakpoint;
+
+ /* Breakpoint set at the return address in the caller frame. May be
+ NULL. */
+ struct breakpoint *caller_breakpoint;
+};
+
+static void until_break_fsm_clean_up (struct thread_fsm *self);
+static int until_break_fsm_should_stop (struct thread_fsm *self);
+static enum async_reply_reason
+ until_break_fsm_async_reply_reason (struct thread_fsm *self);
+
+/* until_break_fsm's vtable. */
+
+static struct thread_fsm_ops until_break_fsm_ops =
{
- struct breakpoint *breakpoint;
- struct breakpoint *breakpoint2;
- int thread_num;
+ NULL, /* dtor */
+ until_break_fsm_clean_up,
+ until_break_fsm_should_stop,
+ NULL, /* return_value */
+ until_break_fsm_async_reply_reason,
};
-/* This function is called by fetch_inferior_event via the
- cmd_continuation pointer, to complete the until command. It takes
- care of cleaning up the temporary breakpoints set up by the until
- command. */
+/* Allocate a new until_break_command_fsm. */
+
+static struct until_break_fsm *
+new_until_break_fsm (int thread,
+ struct breakpoint *location_breakpoint,
+ struct breakpoint *caller_breakpoint)
+{
+ struct until_break_fsm *sm;
+
+ sm = XCNEW (struct until_break_fsm);
+ thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops);
+
+ sm->thread = thread;
+ sm->location_breakpoint = location_breakpoint;
+ sm->caller_breakpoint = caller_breakpoint;
+
+ return sm;
+}
+
+/* Implementation of the 'should_stop' FSM method for the
+ until(location)/advance commands. */
+
+static int
+until_break_fsm_should_stop (struct thread_fsm *self)
+{
+ struct until_break_fsm *sm = (struct until_break_fsm *) self;
+ struct thread_info *tp = inferior_thread ();
+
+ if (bpstat_find_breakpoint (tp->control.stop_bpstat,
+ sm->location_breakpoint) != NULL
+ || (sm->caller_breakpoint != NULL
+ && bpstat_find_breakpoint (tp->control.stop_bpstat,
+ sm->caller_breakpoint) != NULL))
+ thread_fsm_set_finished (self);
+
+ return 1;
+}
+
+/* Implementation of the 'clean_up' FSM method for the
+ until(location)/advance commands. */
+
static void
-until_break_command_continuation (void *arg, int err)
+until_break_fsm_clean_up (struct thread_fsm *self)
{
- struct until_break_command_continuation_args *a = arg;
+ struct until_break_fsm *sm = (struct until_break_fsm *) self;
- delete_breakpoint (a->breakpoint);
- if (a->breakpoint2)
- delete_breakpoint (a->breakpoint2);
- delete_longjmp_breakpoint (a->thread_num);
+ /* Clean up our temporary breakpoints. */
+ if (sm->location_breakpoint != NULL)
+ {
+ delete_breakpoint (sm->location_breakpoint);
+ sm->location_breakpoint = NULL;
+ }
+ if (sm->caller_breakpoint != NULL)
+ {
+ delete_breakpoint (sm->caller_breakpoint);
+ sm->caller_breakpoint = NULL;
+ }
+ delete_longjmp_breakpoint (sm->thread);
+}
+
+/* Implementation of the 'async_reply_reason' FSM method for the
+ until(location)/advance commands. */
+
+static enum async_reply_reason
+until_break_fsm_async_reply_reason (struct thread_fsm *self)
+{
+ return EXEC_ASYNC_LOCATION_REACHED;
}
void
struct gdbarch *frame_gdbarch;
struct frame_id stack_frame_id;
struct frame_id caller_frame_id;
- struct breakpoint *breakpoint;
- struct breakpoint *breakpoint2 = NULL;
- struct cleanup *old_chain;
+ struct breakpoint *location_breakpoint;
+ struct breakpoint *caller_breakpoint = NULL;
+ struct cleanup *old_chain, *cleanup;
int thread;
struct thread_info *tp;
+ struct event_location *location;
+ struct until_break_fsm *sm;
clear_proceed_status (0);
/* Set a breakpoint where the user wants it and at return from
this function. */
+ location = string_to_event_location (&arg, current_language);
+ cleanup = make_cleanup_delete_event_location (location);
+
if (last_displayed_sal_is_valid ())
- sals = decode_line_1 (&arg, DECODE_LINE_FUNFIRSTLINE,
+ sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE,
get_last_displayed_symtab (),
get_last_displayed_line ());
else
- sals = decode_line_1 (&arg, DECODE_LINE_FUNFIRSTLINE,
+ sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE,
(struct symtab *) NULL, 0);
if (sals.nelts != 1)
if (frame_id_p (caller_frame_id))
{
struct symtab_and_line sal2;
+ struct gdbarch *caller_gdbarch;
sal2 = find_pc_line (frame_unwind_caller_pc (frame), 0);
sal2.pc = frame_unwind_caller_pc (frame);
- breakpoint2 = set_momentary_breakpoint (frame_unwind_caller_arch (frame),
- sal2,
- caller_frame_id,
- bp_until);
- make_cleanup_delete_breakpoint (breakpoint2);
+ caller_gdbarch = frame_unwind_caller_arch (frame);
+ caller_breakpoint = set_momentary_breakpoint (caller_gdbarch,
+ sal2,
+ caller_frame_id,
+ bp_until);
+ make_cleanup_delete_breakpoint (caller_breakpoint);
set_longjmp_breakpoint (tp, caller_frame_id);
make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
if (anywhere)
/* If the user told us to continue until a specified location,
we don't specify a frame at which we need to stop. */
- breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
- null_frame_id, bp_until);
+ location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
+ null_frame_id, bp_until);
else
/* Otherwise, specify the selected frame, because we want to stop
only at the very same frame. */
- breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
- stack_frame_id, bp_until);
- make_cleanup_delete_breakpoint (breakpoint);
-
- proceed (-1, GDB_SIGNAL_DEFAULT);
+ location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
+ stack_frame_id, bp_until);
+ make_cleanup_delete_breakpoint (location_breakpoint);
- /* If we are running asynchronously, and proceed call above has
- actually managed to start the target, arrange for breakpoints to
- be deleted when the target stops. Otherwise, we're already
- stopped and delete breakpoints via cleanup chain. */
+ sm = new_until_break_fsm (tp->num, location_breakpoint, caller_breakpoint);
+ tp->thread_fsm = &sm->thread_fsm;
- if (target_can_async_p () && is_running (inferior_ptid))
- {
- struct until_break_command_continuation_args *args;
- args = xmalloc (sizeof (*args));
+ discard_cleanups (old_chain);
- args->breakpoint = breakpoint;
- args->breakpoint2 = breakpoint2;
- args->thread_num = thread;
+ proceed (-1, GDB_SIGNAL_DEFAULT);
- discard_cleanups (old_chain);
- add_continuation (inferior_thread (),
- until_break_command_continuation, args,
- xfree);
- }
- else
- do_cleanups (old_chain);
+ do_cleanups (cleanup);
}
/* This function attempts to parse an optional "if <cond>" clause
b->enable_state = enabled ? bp_enabled : bp_disabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
- b->addr_string = addr_string;
+ b->location = string_to_event_location (&addr_string,
+ language_def (language_ada));
b->language = language_ada;
}
}
else
{
- sals.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line));
+ sals.sals = XNEW (struct symtab_and_line);
make_cleanup (xfree, sals.sals);
init_sal (&sal); /* Initialize to zeroes. */
{
struct breakpoint *b;
struct cleanup *old_chain;
-
- if (!target_can_download_tracepoint ())
- return;
+ enum tribool can_download_tracepoint = TRIBOOL_UNKNOWN;
old_chain = save_current_space_and_thread ();
: !may_insert_tracepoints))
continue;
+ if (can_download_tracepoint == TRIBOOL_UNKNOWN)
+ {
+ if (target_can_download_tracepoint ())
+ can_download_tracepoint = TRIBOOL_TRUE;
+ else
+ can_download_tracepoint = TRIBOOL_FALSE;
+ }
+
+ if (can_download_tracepoint == TRIBOOL_FALSE)
+ break;
+
for (bl = b->loc; bl; bl = bl->next)
{
/* In tracepoint, locations are _never_ duplicated, so
for (loc = b->loc; loc; loc = loc->next)
bp_location_count++;
- bp_location = xmalloc (sizeof (*bp_location) * bp_location_count);
+ bp_location = XNEWVEC (struct bp_location *, bp_location_count);
locp = bp_location;
ALL_BREAKPOINTS (b)
for (loc = b->loc; loc; loc = loc->next)
if (!found_object)
{
- if (removed && non_stop
+ if (removed && target_is_non_stop_p ()
&& need_moribund_for_location_type (old_loc))
{
/* This location was removed from the target. In
single string. */
if (b->loc == NULL)
{
- printf_filtered (_(" (%s) pending."), b->addr_string);
+ /* For pending locations, the output differs slightly based
+ on b->extra_string. If this is non-NULL, it contains either
+ a condition or dprintf arguments. */
+ if (b->extra_string == NULL)
+ {
+ printf_filtered (_(" (%s) pending."),
+ event_location_to_string (b->location));
+ }
+ else if (b->type == bp_dprintf)
+ {
+ printf_filtered (_(" (%s,%s) pending."),
+ event_location_to_string (b->location),
+ b->extra_string);
+ }
+ else
+ {
+ printf_filtered (_(" (%s %s) pending."),
+ event_location_to_string (b->location),
+ b->extra_string);
+ }
}
else
{
/* This is not ideal, but each location may have a
different file name, and this at least reflects the
real situation somewhat. */
- printf_filtered (": %s.", b->addr_string);
+ printf_filtered (": %s.",
+ event_location_to_string (b->location));
}
if (b->loc->next)
decref_counted_command_line (&self->commands);
xfree (self->cond_string);
xfree (self->extra_string);
- xfree (self->addr_string);
xfree (self->filter);
- xfree (self->addr_string_range_end);
+ delete_event_location (self->location);
+ delete_event_location (self->location_range_end);
}
static struct bp_location *
}
static void
-base_breakpoint_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start,
- char **copy_arg)
+base_breakpoint_create_sals_from_location
+ (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
internal_error_pure_virtual_called ();
}
}
static void
-base_breakpoint_decode_linespec (struct breakpoint *b, char **s,
+base_breakpoint_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
internal_error_pure_virtual_called ();
base_breakpoint_print_one_detail,
base_breakpoint_print_mention,
base_breakpoint_print_recreate,
- base_breakpoint_create_sals_from_address,
+ base_breakpoint_create_sals_from_location,
base_breakpoint_create_breakpoints_sal,
- base_breakpoint_decode_linespec,
+ base_breakpoint_decode_location,
base_breakpoint_explains_signal,
base_breakpoint_after_condition_true,
};
bkpt_re_set (struct breakpoint *b)
{
/* FIXME: is this still reachable? */
- if (b->addr_string == NULL)
+ if (event_location_empty_p (b->location))
{
- /* Anything without a string can't be re-set. */
+ /* Anything without a location can't be re-set. */
delete_breakpoint (b);
return;
}
internal_error (__FILE__, __LINE__,
_("unhandled breakpoint type %d"), (int) tp->type);
- fprintf_unfiltered (fp, " %s", tp->addr_string);
+ fprintf_unfiltered (fp, " %s",
+ event_location_to_string (tp->location));
+
+ /* Print out extra_string if this breakpoint is pending. It might
+ contain, for example, conditions that were set by the user. */
+ if (tp->loc == NULL && tp->extra_string != NULL)
+ fprintf_unfiltered (fp, " %s", tp->extra_string);
+
print_recreate_thread (tp, fp);
}
static void
-bkpt_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+bkpt_create_sals_from_location (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
- create_sals_from_address_default (arg, canonical, type_wanted,
- addr_start, copy_arg);
+ create_sals_from_location_default (location, canonical, type_wanted);
}
static void
}
static void
-bkpt_decode_linespec (struct breakpoint *b, char **s,
+bkpt_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
- decode_linespec_default (b, s, sals);
+ decode_location_default (b, location, sals);
}
/* Virtual table for internal breakpoints. */
static enum print_stop_action
momentary_bkpt_print_it (bpstat bs)
{
- struct ui_out *uiout = current_uiout;
-
- if (ui_out_is_mi_like_p (uiout))
- {
- struct breakpoint *b = bs->breakpoint_at;
-
- switch (b->type)
- {
- case bp_finish:
- ui_out_field_string
- (uiout, "reason",
- async_reason_lookup (EXEC_ASYNC_FUNCTION_FINISHED));
- break;
-
- case bp_until:
- ui_out_field_string
- (uiout, "reason",
- async_reason_lookup (EXEC_ASYNC_LOCATION_REACHED));
- break;
- }
- }
-
return PRINT_UNKNOWN;
}
}
static void
-bkpt_probe_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+bkpt_probe_create_sals_from_location (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
struct linespec_sals lsal;
- lsal.sals = parse_probes (arg, canonical);
-
- *copy_arg = xstrdup (canonical->addr_string);
- lsal.canonical = xstrdup (*copy_arg);
-
+ lsal.sals = parse_probes (location, canonical);
+ lsal.canonical = xstrdup (event_location_to_string (canonical->location));
VEC_safe_push (linespec_sals, canonical->sals, &lsal);
}
static void
-bkpt_probe_decode_linespec (struct breakpoint *b, char **s,
+bkpt_probe_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
- *sals = parse_probes (s, NULL);
+ *sals = parse_probes (location, NULL);
if (!sals->sals)
error (_("probe not found"));
}
internal_error (__FILE__, __LINE__,
_("unhandled tracepoint type %d"), (int) self->type);
- fprintf_unfiltered (fp, " %s", self->addr_string);
+ fprintf_unfiltered (fp, " %s",
+ event_location_to_string (self->location));
print_recreate_thread (self, fp);
if (tp->pass_count)
}
static void
-tracepoint_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+tracepoint_create_sals_from_location (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
- create_sals_from_address_default (arg, canonical, type_wanted,
- addr_start, copy_arg);
+ create_sals_from_location_default (location, canonical, type_wanted);
}
static void
}
static void
-tracepoint_decode_linespec (struct breakpoint *b, char **s,
+tracepoint_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
- decode_linespec_default (b, s, sals);
+ decode_location_default (b, location, sals);
}
struct breakpoint_ops tracepoint_breakpoint_ops;
static probe. */
static void
-tracepoint_probe_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+tracepoint_probe_create_sals_from_location
+ (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
/* We use the same method for breakpoint on probes. */
- bkpt_probe_create_sals_from_address (arg, canonical, type_wanted,
- addr_start, copy_arg);
+ bkpt_probe_create_sals_from_location (location, canonical, type_wanted);
}
static void
-tracepoint_probe_decode_linespec (struct breakpoint *b, char **s,
+tracepoint_probe_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
/* We use the same method for breakpoint on probes. */
- bkpt_probe_decode_linespec (b, s, sals);
+ bkpt_probe_decode_location (b, location, sals);
}
static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
{
breakpoint_re_set_default (b);
- /* This breakpoint could have been pending, and be resolved now, and
- if so, we should now have the extra string. If we don't, the
- dprintf was malformed when created, but we couldn't tell because
- we can't extract the extra string until the location is
- resolved. */
- if (b->loc != NULL && b->extra_string == NULL)
- error (_("Format string required"));
+ /* extra_string should never be non-NULL for dprintf. */
+ gdb_assert (b->extra_string != NULL);
/* 1 - connect to target 1, that can run breakpoint commands.
2 - create a dprintf, which resolves fine.
static void
dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
{
- fprintf_unfiltered (fp, "dprintf %s%s", tp->addr_string,
+ fprintf_unfiltered (fp, "dprintf %s,%s",
+ event_location_to_string (tp->location),
tp->extra_string);
print_recreate_thread (tp, fp);
}
markers (`-m'). */
static void
-strace_marker_create_sals_from_address (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+strace_marker_create_sals_from_location (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
struct linespec_sals lsal;
+ const char *arg_start, *arg;
+ char *str;
+ struct cleanup *cleanup;
- lsal.sals = decode_static_tracepoint_spec (arg);
+ arg = arg_start = get_linespec_location (location);
+ lsal.sals = decode_static_tracepoint_spec (&arg);
- *copy_arg = savestring (addr_start, *arg - addr_start);
+ str = savestring (arg_start, arg - arg_start);
+ cleanup = make_cleanup (xfree, str);
+ canonical->location = new_linespec_location (&str);
+ do_cleanups (cleanup);
- canonical->addr_string = xstrdup (*copy_arg);
- lsal.canonical = xstrdup (*copy_arg);
+ lsal.canonical = xstrdup (event_location_to_string (canonical->location));
VEC_safe_push (linespec_sals, canonical->sals, &lsal);
}
struct symtabs_and_lines expanded;
struct tracepoint *tp;
struct cleanup *old_chain;
- char *addr_string;
+ struct event_location *location;
expanded.nelts = 1;
expanded.sals = &lsal->sals.sals[i];
- addr_string = xstrdup (canonical->addr_string);
- old_chain = make_cleanup (xfree, addr_string);
+ location = copy_event_location (canonical->location);
+ old_chain = make_cleanup_delete_event_location (location);
tp = XCNEW (struct tracepoint);
init_breakpoint_sal (&tp->base, gdbarch, expanded,
- addr_string, NULL,
+ location, NULL,
cond_string, extra_string,
type_wanted, disposition,
thread, task, ignore_count, ops,
}
static void
-strace_marker_decode_linespec (struct breakpoint *b, char **s,
+strace_marker_decode_location (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
struct tracepoint *tp = (struct tracepoint *) b;
+ const char *s = get_linespec_location (location);
- *sals = decode_static_tracepoint_spec (s);
+ *sals = decode_static_tracepoint_spec (&s);
if (sals->nelts > tp->static_trace_marker_id_idx)
{
sals->sals[0] = sals->sals[tp->static_trace_marker_id_idx];
struct symbol *sym;
struct static_tracepoint_marker *tpmarker;
struct ui_out *uiout = current_uiout;
+ struct explicit_location explicit_loc;
tpmarker = VEC_index (static_tracepoint_marker_p, markers, 0);
b->loc->line_number = sal2.line;
b->loc->symtab = sym != NULL ? sal2.symtab : NULL;
- xfree (b->addr_string);
- b->addr_string = xstrprintf ("%s:%d",
- symtab_to_filename_for_display (sal2.symtab),
- b->loc->line_number);
+ delete_event_location (b->location);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.source_filename
+ = ASTRDUP (symtab_to_filename_for_display (sal2.symtab));
+ explicit_loc.line_offset.offset = b->loc->line_number;
+ explicit_loc.line_offset.sign = LINE_OFFSET_NONE;
+ b->location = new_explicit_location (&explicit_loc);
/* Might be nice to check if function changed, and warn if
so. */
update_global_location_list (UGLL_MAY_INSERT);
}
-/* Find the SaL locations corresponding to the given ADDR_STRING.
+/* Find the SaL locations corresponding to the given LOCATION.
On return, FOUND will be 1 if any SaL was found, zero otherwise. */
static struct symtabs_and_lines
-addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
+location_to_sals (struct breakpoint *b, struct event_location *location,
+ int *found)
{
- char *s;
struct symtabs_and_lines sals = {0};
struct gdb_exception exception = exception_none;
gdb_assert (b->ops != NULL);
- s = addr_string;
TRY
{
- b->ops->decode_linespec (b, &s, &sals);
+ b->ops->decode_location (b, location, &sals);
}
CATCH (e, RETURN_MASK_ERROR)
{
for (i = 0; i < sals.nelts; ++i)
resolve_sal_pc (&sals.sals[i]);
- if (b->condition_not_parsed && s && s[0])
+ if (b->condition_not_parsed && b->extra_string != NULL)
{
char *cond_string, *extra_string;
int thread, task;
- find_condition_and_thread (s, sals.sals[0].pc,
+ find_condition_and_thread (b->extra_string, sals.sals[0].pc,
&cond_string, &thread, &task,
&extra_string);
+ gdb_assert (b->cond_string == NULL);
if (cond_string)
b->cond_string = cond_string;
b->thread = thread;
b->task = task;
if (extra_string)
- b->extra_string = extra_string;
+ {
+ xfree (b->extra_string);
+ b->extra_string = extra_string;
+ }
b->condition_not_parsed = 0;
}
struct symtabs_and_lines expanded = {0};
struct symtabs_and_lines expanded_end = {0};
- sals = addr_string_to_sals (b, b->addr_string, &found);
+ sals = location_to_sals (b, b->location, &found);
if (found)
{
make_cleanup (xfree, sals.sals);
expanded = sals;
}
- if (b->addr_string_range_end)
+ if (b->location_range_end != NULL)
{
- sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found);
+ sals_end = location_to_sals (b, b->location_range_end, &found);
if (found)
{
make_cleanup (xfree, sals_end.sals);
calls parse_breakpoint_sals. Return 1 for success, zero for failure. */
static void
-create_sals_from_address_default (char **arg,
- struct linespec_result *canonical,
- enum bptype type_wanted,
- char *addr_start, char **copy_arg)
+create_sals_from_location_default (const struct event_location *location,
+ struct linespec_result *canonical,
+ enum bptype type_wanted)
{
- parse_breakpoint_sals (arg, canonical);
+ parse_breakpoint_sals (location, canonical);
}
/* Call create_breakpoints_sal for the given arguments. This is the default
}
/* Decode the line represented by S by calling decode_line_full. This is the
- default function for the `decode_linespec' method of breakpoint_ops. */
+ default function for the `decode_location' method of breakpoint_ops. */
static void
-decode_linespec_default (struct breakpoint *b, char **s,
+decode_location_default (struct breakpoint *b,
+ const struct event_location *location,
struct symtabs_and_lines *sals)
{
struct linespec_result canonical;
init_linespec_result (&canonical);
- decode_line_full (s, DECODE_LINE_FUNFIRSTLINE,
+ decode_line_full (location, DECODE_LINE_FUNFIRSTLINE,
(struct symtab *) NULL, 0,
&canonical, multiple_symbols_all,
b->filter);
trace_command (char *arg, int from_tty)
{
struct breakpoint_ops *ops;
- const char *arg_cp = arg;
+ struct event_location *location;
+ struct cleanup *back_to;
- if (arg && probe_linespec_to_ops (&arg_cp))
+ location = string_to_event_location (&arg, current_language);
+ back_to = make_cleanup_delete_event_location (location);
+ if (location != NULL
+ && event_location_type (location) == PROBE_LOCATION)
ops = &tracepoint_probe_breakpoint_ops;
else
ops = &tracepoint_breakpoint_ops;
create_breakpoint (get_current_arch (),
- arg,
- NULL, 0, NULL, 1 /* parse arg */,
+ location,
+ NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_tracepoint /* type_wanted */,
0 /* Ignore count */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
+ do_cleanups (back_to);
}
static void
ftrace_command (char *arg, int from_tty)
{
+ struct event_location *location;
+ struct cleanup *back_to;
+
+ location = string_to_event_location (&arg, current_language);
+ back_to = make_cleanup_delete_event_location (location);
create_breakpoint (get_current_arch (),
- arg,
- NULL, 0, NULL, 1 /* parse arg */,
+ location,
+ NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_fast_tracepoint /* type_wanted */,
0 /* Ignore count */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
+ do_cleanups (back_to);
}
/* strace command implementation. Creates a static tracepoint. */
strace_command (char *arg, int from_tty)
{
struct breakpoint_ops *ops;
+ struct event_location *location;
+ struct cleanup *back_to;
/* Decide if we are dealing with a static tracepoint marker (`-m'),
or with a normal static tracepoint. */
if (arg && startswith (arg, "-m") && isspace (arg[2]))
- ops = &strace_marker_breakpoint_ops;
+ {
+ ops = &strace_marker_breakpoint_ops;
+ location = new_linespec_location (&arg);
+ }
else
- ops = &tracepoint_breakpoint_ops;
+ {
+ ops = &tracepoint_breakpoint_ops;
+ location = string_to_event_location (&arg, current_language);
+ }
+ back_to = make_cleanup_delete_event_location (location);
create_breakpoint (get_current_arch (),
- arg,
- NULL, 0, NULL, 1 /* parse arg */,
+ location,
+ NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_static_tracepoint /* type_wanted */,
0 /* Ignore count */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
+ do_cleanups (back_to);
}
/* Set up a fake reader function that gets command lines from a linked
{
char *addr_str, small_buf[100];
struct tracepoint *tp;
+ struct event_location *location;
+ struct cleanup *cleanup;
if (utp->at_string)
addr_str = utp->at_string;
"has no source form, ignoring it"),
utp->number);
+ location = string_to_event_location (&addr_str, current_language);
+ cleanup = make_cleanup_delete_event_location (location);
if (!create_breakpoint (get_current_arch (),
- addr_str,
- utp->cond_string, -1, NULL,
+ location,
+ utp->cond_string, -1, addr_str,
0 /* parse cond/thread */,
0 /* tempflag */,
utp->type /* type_wanted */,
utp->enabled /* enabled */,
0 /* internal */,
CREATE_BREAKPOINT_FLAGS_INSERTED))
- return NULL;
+ {
+ do_cleanups (cleanup);
+ return NULL;
+ }
+
+ do_cleanups (cleanup);
/* Get the tracepoint we just created. */
tp = get_tracepoint (tracepoint_count);
}
\f
+/* This help string is used to consolidate all the help string for specifying
+ locations used by several commands. */
+
+#define LOCATION_HELP_STRING \
+"Linespecs are colon-separated lists of location parameters, such as\n\
+source filename, function name, label name, and line number.\n\
+Example: To specify the start of a label named \"the_top\" in the\n\
+function \"fact\" in the file \"factorial.c\", use\n\
+\"factorial.c:fact:the_top\".\n\
+\n\
+Address locations begin with \"*\" and specify an exact address in the\n\
+program. Example: To specify the fourth byte past the start function\n\
+\"main\", use \"*main + 4\".\n\
+\n\
+Explicit locations are similar to linespecs but use an option/argument\n\
+syntax to specify location parameters.\n\
+Example: To specify the start of the label named \"the_top\" in the\n\
+function \"fact\" in the file \"factorial.c\", use \"-source factorial.c\n\
+-function fact -label the_top\".\n"
+
/* This help string is used for the break, hbreak, tbreak and thbreak
commands. It is defined as a macro to prevent duplication.
COMMAND should be a string constant containing the name of the
command. */
+
#define BREAK_ARGS_HELP(command) \
command" [PROBE_MODIFIER] [LOCATION] [thread THREADNUM] [if CONDITION]\n\
PROBE_MODIFIER shall be present if the command is to be placed in a\n\
probe point. Accepted values are `-probe' (for a generic, automatically\n\
guessed probe type), `-probe-stap' (for a SystemTap probe) or \n\
`-probe-dtrace' (for a DTrace probe).\n\
-LOCATION may be a line number, function name, or \"*\" and an address.\n\
-If a line number is specified, break at start of code for that line.\n\
-If a function is specified, break at start of code for that function.\n\
-If an address is specified, break at that exact address.\n\
+LOCATION may be a linespec, address, or explicit location as described\n\
+below.\n\
+\n\
With no LOCATION, uses current execution address of the selected\n\
stack frame. This is useful for breaking on return to a stack frame.\n\
\n\
THREADNUM is the number from \"info threads\".\n\
CONDITION is a boolean expression.\n\
-\n\
+\n" LOCATION_HELP_STRING "\n\
Multiple breakpoints at one place are permitted, and useful if their\n\
conditions are different.\n\
\n\
ops->insert_location = bkpt_insert_location;
ops->remove_location = bkpt_remove_location;
ops->breakpoint_hit = bkpt_breakpoint_hit;
- ops->create_sals_from_address = bkpt_create_sals_from_address;
+ ops->create_sals_from_location = bkpt_create_sals_from_location;
ops->create_breakpoints_sal = bkpt_create_breakpoints_sal;
- ops->decode_linespec = bkpt_decode_linespec;
+ ops->decode_location = bkpt_decode_location;
/* The breakpoint_ops structure to be used in regular breakpoints. */
ops = &bkpt_breakpoint_ops;
*ops = bkpt_breakpoint_ops;
ops->insert_location = bkpt_probe_insert_location;
ops->remove_location = bkpt_probe_remove_location;
- ops->create_sals_from_address = bkpt_probe_create_sals_from_address;
- ops->decode_linespec = bkpt_probe_decode_linespec;
+ ops->create_sals_from_location = bkpt_probe_create_sals_from_location;
+ ops->decode_location = bkpt_probe_decode_location;
/* Watchpoints. */
ops = &watchpoint_breakpoint_ops;
ops->print_one_detail = tracepoint_print_one_detail;
ops->print_mention = tracepoint_print_mention;
ops->print_recreate = tracepoint_print_recreate;
- ops->create_sals_from_address = tracepoint_create_sals_from_address;
+ ops->create_sals_from_location = tracepoint_create_sals_from_location;
ops->create_breakpoints_sal = tracepoint_create_breakpoints_sal;
- ops->decode_linespec = tracepoint_decode_linespec;
+ ops->decode_location = tracepoint_decode_location;
/* Probe tracepoints. */
ops = &tracepoint_probe_breakpoint_ops;
*ops = tracepoint_breakpoint_ops;
- ops->create_sals_from_address = tracepoint_probe_create_sals_from_address;
- ops->decode_linespec = tracepoint_probe_decode_linespec;
+ ops->create_sals_from_location = tracepoint_probe_create_sals_from_location;
+ ops->decode_location = tracepoint_probe_decode_location;
/* Static tracepoints with marker (`-m'). */
ops = &strace_marker_breakpoint_ops;
*ops = tracepoint_breakpoint_ops;
- ops->create_sals_from_address = strace_marker_create_sals_from_address;
+ ops->create_sals_from_location = strace_marker_create_sals_from_location;
ops->create_breakpoints_sal = strace_marker_create_breakpoints_sal;
- ops->decode_linespec = strace_marker_decode_linespec;
+ ops->decode_location = strace_marker_decode_location;
/* Fork catchpoints. */
ops = &catch_fork_breakpoint_ops;
&deletelist);
add_com ("clear", class_breakpoint, clear_command, _("\
-Clear breakpoint at specified line or function.\n\
-Argument may be line number, function name, or \"*\" and an address.\n\
-If line number is specified, all breakpoints in that line are cleared.\n\
-If function is specified, breakpoints at beginning of function are cleared.\n\
-If an address is specified, breakpoints at that address are cleared.\n\
+Clear breakpoint at specified location.\n\
+Argument may be a linespec, explicit, or address location as described below.\n\
\n\
With no argument, clears all breakpoints in the line that the selected frame\n\
-is executing in.\n\
-\n\
+is executing in.\n"
+"\n" LOCATION_HELP_STRING "\n\
See also the \"delete\" command which clears breakpoints by number."));
add_com_alias ("cl", "clear", class_breakpoint, 1);
c = add_com ("break", class_breakpoint, break_command, _("\
-Set breakpoint at specified line or function.\n"
+Set breakpoint at specified location.\n"
BREAK_ARGS_HELP ("break")));
set_cmd_completer (c, location_completer);
/* Tracepoint manipulation commands. */
c = add_com ("trace", class_breakpoint, trace_command, _("\
-Set a tracepoint at specified line or function.\n\
+Set a tracepoint at specified location.\n\
\n"
BREAK_ARGS_HELP ("trace") "\n\
Do \"help tracepoints\" for info on other tracepoint commands."));
add_com_alias ("trac", "trace", class_alias, 1);
c = add_com ("ftrace", class_breakpoint, ftrace_command, _("\
-Set a fast tracepoint at specified line or function.\n\
+Set a fast tracepoint at specified location.\n\
\n"
BREAK_ARGS_HELP ("ftrace") "\n\
Do \"help tracepoints\" for info on other tracepoint commands."));
set_cmd_completer (c, location_completer);
c = add_com ("strace", class_breakpoint, strace_command, _("\
-Set a static tracepoint at specified line, function or marker.\n\
+Set a static tracepoint at location or marker.\n\
\n\
strace [LOCATION] [if CONDITION]\n\
-LOCATION may be a line number, function name, \"*\" and an address,\n\
-or -m MARKER_ID.\n\
-If a line number is specified, probe the marker at start of code\n\
-for that line. If a function is specified, probe the marker at start\n\
-of code for that function. If an address is specified, probe the marker\n\
-at that exact address. If a marker id is specified, probe the marker\n\
-with that name. With no LOCATION, uses current execution address of\n\
-the selected stack frame.\n\
+LOCATION may be a linespec, explicit, or address location (described below) \n\
+or -m MARKER_ID.\n\n\
+If a marker id is specified, probe the marker with that name. With\n\
+no LOCATION, uses current execution address of the selected stack frame.\n\
Static tracepoints accept an extra collect action -- ``collect $_sdata''.\n\
This collects arbitrary user data passed in the probe point call to the\n\
tracing library. You can inspect it when analyzing the trace buffer,\n\
by printing the $_sdata variable like any other convenience variable.\n\
\n\
CONDITION is a boolean expression.\n\
-\n\
+\n" LOCATION_HELP_STRING "\n\
Multiple tracepoints at one place are permitted, and useful if their\n\
conditions are different.\n\
\n\
range (including START-LOCATION and END-LOCATION)."));
c = add_com ("dprintf", class_breakpoint, dprintf_command, _("\
-Set a dynamic printf at specified line or function.\n\
+Set a dynamic printf at specified location.\n\
dprintf location,format string,arg1,arg2,...\n\
-location may be a line number, function name, or \"*\" and an address.\n\
-If a line number is specified, break at start of code for that line.\n\
-If a function is specified, break at start of code for that function."));
+location may be a linespec, explicit, or address location.\n"
+"\n" LOCATION_HELP_STRING));
set_cmd_completer (c, location_completer);
add_setshow_enum_cmd ("dprintf-style", class_support,