#include "thread-fsm.h"
#include "tid-parse.h"
#include "cli/cli-style.h"
+#include "mi/mi-main.h"
/* readline include files */
#include "readline/readline.h"
{
struct watchpoint *w = (struct watchpoint *) b;
- innermost_block.reset ();
+ innermost_block_tracker tracker;
arg = exp;
- w->cond_exp = parse_exp_1 (&arg, 0, 0, 0);
+ w->cond_exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
if (*arg)
error (_("Junk at end of expression"));
- w->cond_exp_valid_block = innermost_block.block ();
+ w->cond_exp_valid_block = tracker.block ();
}
else
{
int allflag)
{
struct ui_out *uiout = current_uiout;
+ bool use_fixed_output = mi_multi_location_breakpoint_output_fixed (uiout);
- {
- ui_out_emit_tuple tuple_emitter (uiout, "bkpt");
+ gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
+ print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
- print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
- }
+ /* The mi2 broken format: the main breakpoint tuple ends here, the locations
+ are outside. */
+ if (!use_fixed_output)
+ bkpt_tuple_emitter.reset ();
/* If this breakpoint has custom print function,
it's already printed. Otherwise, print individual
&& !is_hardware_watchpoint (b)
&& (b->loc->next || !b->loc->enabled))
{
- struct bp_location *loc;
- int n = 1;
+ gdb::optional<ui_out_emit_list> locations_list;
- for (loc = b->loc; loc; loc = loc->next, ++n)
+ /* For MI version <= 2, keep the behavior where GDB outputs an invalid
+ MI record. For later versions, place breakpoint locations in a
+ list. */
+ if (uiout->is_mi_like_p () && use_fixed_output)
+ locations_list.emplace (uiout, "locations");
+
+ int n = 1;
+ for (bp_location *loc = b->loc; loc != NULL; loc = loc->next, ++n)
{
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ ui_out_emit_tuple loc_tuple_emitter (uiout, NULL);
print_one_breakpoint_location (b, loc, n, last_loc, allflag);
}
}
}
}
-bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner)
+bp_location::bp_location (breakpoint *owner)
{
bp_location *loc = this;
- gdb_assert (ops != NULL);
-
- loc->ops = ops;
loc->owner = owner;
loc->cond_bytecode = NULL;
loc->shlib_disabled = 0;
static void
free_bp_location (struct bp_location *loc)
{
- loc->ops->dtor (loc);
delete loc;
}
/* Parse the rest of the arguments. From here on out, everything
is in terms of a newly allocated string instead of the original
ARG. */
- innermost_block.reset ();
std::string expression (arg, exp_end - arg);
exp_start = arg = expression.c_str ();
- expression_up exp = parse_exp_1 (&arg, 0, 0, 0);
+ innermost_block_tracker tracker;
+ expression_up exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
exp_end = arg;
/* Remove trailing whitespace from the expression before saving it.
This makes the eventual display of the expression string a bit
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
- exp_valid_block = innermost_block.block ();
+ exp_valid_block = tracker.block ();
struct value *mark = value_mark ();
struct value *val_as_value = nullptr;
fetch_subexp_value (exp.get (), &pc, &val_as_value, &result, NULL,
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
- innermost_block.reset ();
tok = cond_start = end_tok + 1;
- parse_exp_1 (&tok, 0, 0, 0);
+ innermost_block_tracker if_tracker;
+ parse_exp_1 (&tok, 0, 0, 0, &if_tracker);
/* The watchpoint expression may not be local, but the condition
may still be. E.g.: `watch global if local > 0'. */
- cond_exp_valid_block = innermost_block.block ();
+ cond_exp_valid_block = if_tracker.block ();
cond_end = tok;
}
}
}
-/* Default bp_location_ops methods. */
-
-static void
-bp_location_dtor (struct bp_location *self)
+bp_location::~bp_location ()
{
- xfree (self->function_name);
+ xfree (function_name);
}
-static const struct bp_location_ops bp_location_ops =
-{
- bp_location_dtor
-};
-
/* Destructor for the breakpoint base class. */
breakpoint::~breakpoint ()
static struct bp_location *
base_breakpoint_allocate_location (struct breakpoint *self)
{
- return new bp_location (&bp_location_ops, self);
+ return new bp_location (self);
}
static void