X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=6fd18fd6b6236b587d3785a9a63afc16efb129f2;hb=112e8700a6fd2fed65ca70132c9cbed4132e8bd4;hp=9f9cb8af4144596fce37cc076f682e297610412c;hpb=53c3572a9f5b03a92292cb6d24bf69b52c95500e;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9f9cb8af41..6fd18fd6b6 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -102,8 +102,9 @@ static void disable_command (char *, int); static void enable_command (char *, int); -static void map_breakpoint_numbers (char *, void (*) (struct breakpoint *, - void *), +static void map_breakpoint_numbers (const char *, + void (*) (struct breakpoint *, + void *), void *); static void ignore_command (char *, int); @@ -980,8 +981,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, { struct watchpoint *w = (struct watchpoint *) b; - xfree (w->cond_exp); - w->cond_exp = NULL; + w->cond_exp.reset (); } else { @@ -989,8 +989,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, for (loc = b->loc; loc; loc = loc->next) { - xfree (loc->cond); - loc->cond = NULL; + loc->cond.reset (); /* No need to free the condition agent expression bytecode (if we have one). We will handle this @@ -1338,7 +1337,7 @@ struct commands_info int from_tty; /* The breakpoint range spec. */ - char *arg; + const char *arg; /* Non-NULL if the body of the commands are being read from this already-parsed command. */ @@ -1399,7 +1398,7 @@ do_map_commands_command (struct breakpoint *b, void *data) } static void -commands_command_1 (char *arg, int from_tty, +commands_command_1 (const char *arg, int from_tty, struct command_line *control) { struct cleanup *cleanups; @@ -1412,32 +1411,22 @@ commands_command_1 (char *arg, int from_tty, extra reference to the commands that we must clean up. */ cleanups = make_cleanup_decref_counted_command_line (&info.cmd); + std::string new_arg; + if (arg == NULL || !*arg) { if (breakpoint_count - prev_breakpoint_count > 1) - arg = xstrprintf ("%d-%d", prev_breakpoint_count + 1, - breakpoint_count); + new_arg = string_printf ("%d-%d", prev_breakpoint_count + 1, + breakpoint_count); else if (breakpoint_count > 0) - arg = xstrprintf ("%d", breakpoint_count); - else - { - /* So that we don't try to free the incoming non-NULL - argument in the cleanup below. Mapping breakpoint - numbers will fail in this case. */ - arg = NULL; - } + new_arg = string_printf ("%d", breakpoint_count); } else - /* The command loop has some static state, so we need to preserve - our argument. */ - arg = xstrdup (arg); - - if (arg != NULL) - make_cleanup (xfree, arg); + new_arg = arg; - info.arg = arg; + info.arg = new_arg.c_str (); - map_breakpoint_numbers (arg, do_map_commands_command, &info); + map_breakpoint_numbers (info.arg, do_map_commands_command, &info); if (info.cmd == NULL) error (_("No breakpoints specified.")); @@ -1457,7 +1446,7 @@ commands_command (char *arg, int from_tty) This is used by cli-script.c to DTRT with breakpoint commands that are part of if and while bodies. */ enum command_control_type -commands_from_control_command (char *arg, struct command_line *cmd) +commands_from_control_command (const char *arg, struct command_line *cmd) { commands_command_1 (arg, 0, cmd); return simple_control; @@ -1906,11 +1895,7 @@ update_watchpoint (struct watchpoint *b, int reparse) { const char *s; - if (b->exp) - { - xfree (b->exp); - b->exp = NULL; - } + b->exp.reset (); s = b->exp_string_reparse ? b->exp_string_reparse : b->exp_string; b->exp = parse_exp_1 (&s, 0, b->exp_valid_block, 0); /* If the meaning of expression itself changed, the old value is @@ -1926,11 +1911,7 @@ update_watchpoint (struct watchpoint *b, int reparse) locations (re)created below. */ if (b->base.cond_string != NULL) { - if (b->cond_exp != NULL) - { - xfree (b->cond_exp); - b->cond_exp = NULL; - } + b->cond_exp.reset (); s = b->base.cond_string; b->cond_exp = parse_exp_1 (&s, 0, b->cond_exp_valid_block, 0); @@ -1962,7 +1943,7 @@ update_watchpoint (struct watchpoint *b, int reparse) struct value *val_chain, *v, *result, *next; struct program_space *frame_pspace; - fetch_subexp_value (b->exp, &pc, &v, &result, &val_chain, 0); + fetch_subexp_value (b->exp.get (), &pc, &v, &result, &val_chain, 0); /* Avoid setting b->val if it's already set. The meaning of b->val is 'the last value' user saw, and we should update @@ -2275,14 +2256,14 @@ unduplicated_should_be_inserted (struct bp_location *bl) by the bytecode interpreter. Return NULL if there was any error during parsing. */ -static struct agent_expr * +static agent_expr_up parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) { - struct agent_expr *aexpr = NULL; - - if (!cond) + if (cond == NULL) return NULL; + agent_expr_up aexpr; + /* We don't want to stop processing, so catch any errors that may show up. */ TRY @@ -2295,7 +2276,6 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) /* If we got here, it means the condition could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the conditions. */ - return NULL; } END_CATCH @@ -2318,7 +2298,7 @@ build_target_condition_list (struct bp_location *bl) struct bp_location *loc; /* Release conditions left over from a previous insert. */ - VEC_free (agent_expr_p, bl->target_info.conditions); + bl->target_info.conditions.clear (); /* This is only meaningful if the target is evaluating conditions and if the user has @@ -2340,14 +2320,12 @@ build_target_condition_list (struct bp_location *bl) { if (modified) { - struct agent_expr *aexpr; - /* Re-parse the conditions since something changed. In that case we already freed the condition bytecodes (see force_breakpoint_reinsertion). We just need to parse the condition to bytecodes again. */ - aexpr = parse_cond_to_aexpr (bl->address, loc->cond); - loc->cond_bytecode = aexpr; + loc->cond_bytecode = parse_cond_to_aexpr (bl->address, + loc->cond.get ()); } /* If we have a NULL bytecode expression, it means something @@ -2378,8 +2356,7 @@ build_target_condition_list (struct bp_location *bl) if (!loc->cond_bytecode) return; - free_agent_expr (loc->cond_bytecode); - loc->cond_bytecode = NULL; + loc->cond_bytecode.reset (); } } } @@ -2394,10 +2371,11 @@ build_target_condition_list (struct bp_location *bl) && loc->pspace->num == bl->pspace->num && loc->owner->enable_state == bp_enabled && loc->enabled) - /* Add the condition to the vector. This will be used later to send the - conditions to the target. */ - VEC_safe_push (agent_expr_p, bl->target_info.conditions, - loc->cond_bytecode); + { + /* Add the condition to the vector. This will be used later + to send the conditions to the target. */ + bl->target_info.conditions.push_back (loc->cond_bytecode.get ()); + } } return; @@ -2407,19 +2385,18 @@ build_target_condition_list (struct bp_location *bl) bytecode suitable for evaluation by the bytecode interpreter. Return NULL if there was any error during parsing. */ -static struct agent_expr * +static agent_expr_up parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) { struct cleanup *old_cleanups = 0; - struct expression *expr, **argvec; - struct agent_expr *aexpr = NULL; + struct expression **argvec; const char *cmdrest; const char *format_start, *format_end; struct format_piece *fpieces; int nargs; struct gdbarch *gdbarch = get_current_arch (); - if (!cmd) + if (cmd == NULL) return NULL; cmdrest = cmd; @@ -2462,13 +2439,15 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) const char *cmd1; cmd1 = cmdrest; - expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope), 1); - argvec[nargs++] = expr; + expression_up expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope), 1); + argvec[nargs++] = expr.release (); cmdrest = cmd1; if (*cmdrest == ',') ++cmdrest; } + agent_expr_up aexpr; + /* We don't want to stop processing, so catch any errors that may show up. */ TRY @@ -2482,7 +2461,6 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) /* If we got here, it means the command could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the other commands. */ - aexpr = NULL; } END_CATCH @@ -2504,8 +2482,8 @@ build_target_command_list (struct bp_location *bl) int modified = bl->needs_update; struct bp_location *loc; - /* Release commands left over from a previous insert. */ - VEC_free (agent_expr_p, bl->target_info.tcommands); + /* Clear commands left over from a previous insert. */ + bl->target_info.tcommands.clear (); if (!target_can_run_breakpoint_commands ()) return; @@ -2539,15 +2517,13 @@ build_target_command_list (struct bp_location *bl) { if (modified) { - struct agent_expr *aexpr; - /* Re-parse the commands since something changed. In that case we already freed the command bytecodes (see force_breakpoint_reinsertion). We just need to parse the command to bytecodes again. */ - aexpr = parse_cmd_to_aexpr (bl->address, - loc->owner->extra_string); - loc->cmd_bytecode = aexpr; + loc->cmd_bytecode + = parse_cmd_to_aexpr (bl->address, + loc->owner->extra_string); } /* If we have a NULL bytecode expression, it means something @@ -2575,8 +2551,7 @@ build_target_command_list (struct bp_location *bl) if (loc->cmd_bytecode == NULL) return; - free_agent_expr (loc->cmd_bytecode); - loc->cmd_bytecode = NULL; + loc->cmd_bytecode.reset (); } } } @@ -2591,10 +2566,11 @@ build_target_command_list (struct bp_location *bl) && loc->pspace->num == bl->pspace->num && loc->owner->enable_state == bp_enabled && loc->enabled) - /* Add the command to the vector. This will be used later - to send the commands to the target. */ - VEC_safe_push (agent_expr_p, bl->target_info.tcommands, - loc->cmd_bytecode); + { + /* Add the command to the vector. This will be used later + to send the commands to the target. */ + bl->target_info.tcommands.push_back (loc->cmd_bytecode.get ()); + } } bl->target_info.persist = 0; @@ -4824,28 +4800,28 @@ watchpoint_value_print (struct value *val, struct ui_file *stream) void maybe_print_thread_hit_breakpoint (struct ui_out *uiout) { - if (ui_out_is_mi_like_p (uiout)) + if (uiout->is_mi_like_p ()) return; - ui_out_text (uiout, "\n"); + uiout->text ("\n"); if (show_thread_that_caused_stop ()) { const char *name; struct thread_info *thr = inferior_thread (); - ui_out_text (uiout, "Thread "); - ui_out_field_fmt (uiout, "thread-id", "%s", print_thread_id (thr)); + uiout->text ("Thread "); + uiout->field_fmt ("thread-id", "%s", print_thread_id (thr)); name = thr->name != NULL ? thr->name : target_thread_name (thr); if (name != NULL) { - ui_out_text (uiout, " \""); - ui_out_field_fmt (uiout, "name", "%s", name); - ui_out_text (uiout, "\""); + uiout->text (" \""); + uiout->field_fmt ("name", "%s", name); + uiout->text ("\""); } - ui_out_text (uiout, " hit "); + uiout->text (" hit "); } } @@ -4905,17 +4881,15 @@ print_solib_event (int is_catchpoint) if (!is_catchpoint) { if (any_added || any_deleted) - ui_out_text (current_uiout, - _("Stopped due to shared library event:\n")); + current_uiout->text (_("Stopped due to shared library event:\n")); else - ui_out_text (current_uiout, - _("Stopped due to shared library event (no " - "libraries added or removed)\n")); + current_uiout->text (_("Stopped due to shared library event (no " + "libraries added or removed)\n")); } - if (ui_out_is_mi_like_p (current_uiout)) - ui_out_field_string (current_uiout, "reason", - async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); + if (current_uiout->is_mi_like_p ()) + current_uiout->field_string ("reason", + async_reason_lookup (EXEC_ASYNC_SOLIB_EVENT)); if (any_deleted) { @@ -4923,7 +4897,7 @@ print_solib_event (int is_catchpoint) char *name; int ix; - ui_out_text (current_uiout, _(" Inferior unloaded ")); + current_uiout->text (_(" Inferior unloaded ")); cleanup = make_cleanup_ui_out_list_begin_end (current_uiout, "removed"); for (ix = 0; @@ -4932,9 +4906,9 @@ print_solib_event (int is_catchpoint) ++ix) { if (ix > 0) - ui_out_text (current_uiout, " "); - ui_out_field_string (current_uiout, "library", name); - ui_out_text (current_uiout, "\n"); + current_uiout->text (" "); + current_uiout->field_string ("library", name); + current_uiout->text ("\n"); } do_cleanups (cleanup); @@ -4946,7 +4920,7 @@ print_solib_event (int is_catchpoint) int ix; struct cleanup *cleanup; - ui_out_text (current_uiout, _(" Inferior loaded ")); + current_uiout->text (_(" Inferior loaded ")); cleanup = make_cleanup_ui_out_list_begin_end (current_uiout, "added"); for (ix = 0; @@ -4955,9 +4929,9 @@ print_solib_event (int is_catchpoint) ++ix) { if (ix > 0) - ui_out_text (current_uiout, " "); - ui_out_field_string (current_uiout, "library", iter->so_name); - ui_out_text (current_uiout, "\n"); + current_uiout->text (" "); + current_uiout->field_string ("library", iter->so_name); + current_uiout->text ("\n"); } do_cleanups (cleanup); @@ -5232,7 +5206,7 @@ watchpoint_check (void *p) return WP_VALUE_CHANGED; mark = value_mark (); - fetch_subexp_value (b->exp, &pc, &new_val, NULL, NULL, 0); + fetch_subexp_value (b->exp.get (), &pc, &new_val, NULL, NULL, 0); if (b->val_bitsize != 0) new_val = extract_bitfield_from_watchpoint_value (b, new_val); @@ -5281,13 +5255,12 @@ watchpoint_check (void *p) { struct ui_out *uiout = current_uiout; - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); - ui_out_text (uiout, "\nWatchpoint "); - ui_out_field_int (uiout, "wpnum", b->base.number); - ui_out_text (uiout, - " deleted because the program has left the block in\n" + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); + uiout->text ("\nWatchpoint "); + uiout->field_int ("wpnum", b->base.number); + uiout->text (" deleted because the program has left the block in\n" "which its expression is valid.\n"); } @@ -5533,10 +5506,10 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) { struct watchpoint *w = (struct watchpoint *) b; - cond = w->cond_exp; + cond = w->cond_exp.get (); } else - cond = bl->cond; + cond = bl->cond.get (); if (cond && b->disposition != disp_del_at_next_stop) { @@ -6086,10 +6059,10 @@ wrap_indent_at_field (struct ui_out *uiout, const char *col_name) { static char wrap_indent[80]; int i, total_width, width, align; - char *text; + const char *text; total_width = 0; - for (i = 1; ui_out_query_field (uiout, i, &width, &align, &text); i++) + for (i = 1; uiout->query_table_field (i, &width, &align, &text); i++) { if (strcmp (text, col_name) == 0) { @@ -6182,30 +6155,27 @@ print_breakpoint_location (struct breakpoint *b, set_current_program_space (loc->pspace); if (b->display_canonical) - ui_out_field_string (uiout, "what", - event_location_to_string (b->location)); + uiout->field_string ("what", event_location_to_string (b->location)); else if (loc && loc->symtab) { struct symbol *sym = find_pc_sect_function (loc->address, loc->section); if (sym) { - ui_out_text (uiout, "in "); - ui_out_field_string (uiout, "func", - SYMBOL_PRINT_NAME (sym)); - ui_out_text (uiout, " "); - ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what")); - ui_out_text (uiout, "at "); + uiout->text ("in "); + uiout->field_string ("func", SYMBOL_PRINT_NAME (sym)); + uiout->text (" "); + uiout->wrap_hint (wrap_indent_at_field (uiout, "what")); + uiout->text ("at "); } - ui_out_field_string (uiout, "file", + uiout->field_string ("file", symtab_to_filename_for_display (loc->symtab)); - ui_out_text (uiout, ":"); + uiout->text (":"); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "fullname", - symtab_to_fullname (loc->symtab)); + if (uiout->is_mi_like_p ()) + uiout->field_string ("fullname", symtab_to_fullname (loc->symtab)); - ui_out_field_int (uiout, "line", loc->line_number); + uiout->field_int ("line", loc->line_number); } else if (loc) { @@ -6214,24 +6184,23 @@ print_breakpoint_location (struct breakpoint *b, print_address_symbolic (loc->gdbarch, loc->address, stb, demangle, ""); - ui_out_field_stream (uiout, "at", stb); + uiout->field_stream ("at", stb); do_cleanups (stb_chain); } else { - ui_out_field_string (uiout, "pending", - event_location_to_string (b->location)); + uiout->field_string ("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 (!uiout->is_mi_like_p () && b->extra_string != NULL) { if (b->type == bp_dprintf) - ui_out_text (uiout, ","); + uiout->text (","); else - ui_out_text (uiout, " "); - ui_out_text (uiout, b->extra_string); + uiout->text (" "); + uiout->text (b->extra_string); } } @@ -6239,10 +6208,10 @@ print_breakpoint_location (struct breakpoint *b, && breakpoint_condition_evaluation_mode () == condition_evaluation_target && bp_condition_evaluator (b) == condition_evaluation_both) { - ui_out_text (uiout, " ("); - ui_out_field_string (uiout, "evaluated-by", + uiout->text (" ("); + uiout->field_string ("evaluated-by", bp_location_condition_evaluator (loc)); - ui_out_text (uiout, ")"); + uiout->text (")"); } do_cleanups (old_chain); @@ -6313,7 +6282,7 @@ output_thread_groups (struct ui_out *uiout, int mi_only) { struct cleanup *back_to; - int is_mi = ui_out_is_mi_like_p (uiout); + int is_mi = uiout->is_mi_like_p (); int inf; int i; @@ -6331,16 +6300,16 @@ output_thread_groups (struct ui_out *uiout, char mi_group[10]; xsnprintf (mi_group, sizeof (mi_group), "i%d", inf); - ui_out_field_string (uiout, NULL, mi_group); + uiout->field_string (NULL, mi_group); } else { if (i == 0) - ui_out_text (uiout, " inf "); + uiout->text (" inf "); else - ui_out_text (uiout, ", "); + uiout->text (", "); - ui_out_text (uiout, plongest (inf)); + uiout->text (plongest (inf)); } } @@ -6384,37 +6353,36 @@ print_one_breakpoint_location (struct breakpoint *b, { char *formatted; formatted = xstrprintf ("%d.%d", b->number, loc_number); - ui_out_field_string (uiout, "number", formatted); + uiout->field_string ("number", formatted); xfree (formatted); } else { - ui_out_field_int (uiout, "number", b->number); + uiout->field_int ("number", b->number); } /* 2 */ annotate_field (1); if (part_of_multiple) - ui_out_field_skip (uiout, "type"); + uiout->field_skip ("type"); else - ui_out_field_string (uiout, "type", bptype_string (b->type)); + uiout->field_string ("type", bptype_string (b->type)); /* 3 */ annotate_field (2); if (part_of_multiple) - ui_out_field_skip (uiout, "disp"); + uiout->field_skip ("disp"); else - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); /* 4 */ annotate_field (3); if (part_of_multiple) - ui_out_field_string (uiout, "enabled", loc->enabled ? "y" : "n"); + uiout->field_string ("enabled", loc->enabled ? "y" : "n"); else - ui_out_field_fmt (uiout, "enabled", "%c", - bpenables[(int) b->enable_state]); - ui_out_spaces (uiout, 2); + uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]); + uiout->spaces (2); /* 5 and 6 */ @@ -6445,9 +6413,9 @@ print_one_breakpoint_location (struct breakpoint *b, not line up too nicely with the headers, but the effect is relatively readable). */ if (opts.addressprint) - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); annotate_field (5); - ui_out_field_string (uiout, "what", w->exp_string); + uiout->field_string ("what", w->exp_string); } break; @@ -6483,11 +6451,11 @@ print_one_breakpoint_location (struct breakpoint *b, { annotate_field (4); if (header_of_multiple) - ui_out_field_string (uiout, "addr", ""); + uiout->field_string ("addr", ""); else if (b->loc == NULL || loc->shlib_disabled) - ui_out_field_string (uiout, "addr", ""); + uiout->field_string ("addr", ""); else - ui_out_field_core_addr (uiout, "addr", + uiout->field_core_addr ("addr", loc->gdbarch, loc->address); } annotate_field (5); @@ -6531,17 +6499,17 @@ print_one_breakpoint_location (struct breakpoint *b, { /* FIXME: This seems to be redundant and lost here; see the "stop only in" line a little further down. */ - ui_out_text (uiout, " thread "); - ui_out_field_int (uiout, "thread", b->thread); + uiout->text (" thread "); + uiout->field_int ("thread", b->thread); } else if (b->task != 0) { - ui_out_text (uiout, " task "); - ui_out_field_int (uiout, "task", b->task); + uiout->text (" task "); + uiout->field_int ("task", b->task); } } - ui_out_text (uiout, "\n"); + uiout->text ("\n"); if (!part_of_multiple) b->ops->print_one_detail (b, uiout); @@ -6549,22 +6517,22 @@ print_one_breakpoint_location (struct breakpoint *b, if (part_of_multiple && frame_id_p (b->frame_id)) { annotate_field (6); - ui_out_text (uiout, "\tstop only in stack frame at "); + uiout->text ("\tstop only in stack frame at "); /* FIXME: cagney/2002-12-01: Shouldn't be poking around inside the frame ID. */ - ui_out_field_core_addr (uiout, "frame", + uiout->field_core_addr ("frame", b->gdbarch, b->frame_id.stack_addr); - ui_out_text (uiout, "\n"); + uiout->text ("\n"); } if (!part_of_multiple && b->cond_string) { annotate_field (7); if (is_tracepoint (b)) - ui_out_text (uiout, "\ttrace only if "); + uiout->text ("\ttrace only if "); else - ui_out_text (uiout, "\tstop only if "); - ui_out_field_string (uiout, "cond", b->cond_string); + uiout->text ("\tstop only if "); + uiout->field_string ("cond", b->cond_string); /* Print whether the target is doing the breakpoint's condition evaluation. If GDB is doing the evaluation, don't print anything. */ @@ -6572,27 +6540,27 @@ print_one_breakpoint_location (struct breakpoint *b, && breakpoint_condition_evaluation_mode () == condition_evaluation_target) { - ui_out_text (uiout, " ("); - ui_out_field_string (uiout, "evaluated-by", + uiout->text (" ("); + uiout->field_string ("evaluated-by", bp_condition_evaluator (b)); - ui_out_text (uiout, " evals)"); + uiout->text (" evals)"); } - ui_out_text (uiout, "\n"); + uiout->text ("\n"); } if (!part_of_multiple && b->thread != -1) { /* FIXME should make an annotation for this. */ - ui_out_text (uiout, "\tstop only in thread "); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_int (uiout, "thread", b->thread); + uiout->text ("\tstop only in thread "); + if (uiout->is_mi_like_p ()) + uiout->field_int ("thread", b->thread); else { struct thread_info *thr = find_thread_global_id (b->thread); - ui_out_field_string (uiout, "thread", print_thread_id (thr)); + uiout->field_string ("thread", print_thread_id (thr)); } - ui_out_text (uiout, "\n"); + uiout->text ("\n"); } if (!part_of_multiple) @@ -6601,32 +6569,32 @@ print_one_breakpoint_location (struct breakpoint *b, { /* FIXME should make an annotation for this. */ if (is_catchpoint (b)) - ui_out_text (uiout, "\tcatchpoint"); + uiout->text ("\tcatchpoint"); else if (is_tracepoint (b)) - ui_out_text (uiout, "\ttracepoint"); + uiout->text ("\ttracepoint"); else - ui_out_text (uiout, "\tbreakpoint"); - ui_out_text (uiout, " already hit "); - ui_out_field_int (uiout, "times", b->hit_count); + uiout->text ("\tbreakpoint"); + uiout->text (" already hit "); + uiout->field_int ("times", b->hit_count); if (b->hit_count == 1) - ui_out_text (uiout, " time\n"); + uiout->text (" time\n"); else - ui_out_text (uiout, " times\n"); + uiout->text (" times\n"); } else { /* Output the count also if it is zero, but only if this is mi. */ - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_int (uiout, "times", b->hit_count); + if (uiout->is_mi_like_p ()) + uiout->field_int ("times", b->hit_count); } } if (!part_of_multiple && b->ignore_count) { annotate_field (8); - ui_out_text (uiout, "\tignore next "); - ui_out_field_int (uiout, "ignore", b->ignore_count); - ui_out_text (uiout, " hits\n"); + uiout->text ("\tignore next "); + uiout->field_int ("ignore", b->ignore_count); + uiout->text (" hits\n"); } /* Note that an enable count of 1 corresponds to "enable once" @@ -6635,15 +6603,15 @@ print_one_breakpoint_location (struct breakpoint *b, if (!part_of_multiple && b->enable_count > 1) { annotate_field (8); - ui_out_text (uiout, "\tdisable after "); + uiout->text ("\tdisable after "); /* Tweak the wording to clarify that ignore and enable counts are distinct, and have additive effect. */ if (b->ignore_count) - ui_out_text (uiout, "additional "); + uiout->text ("additional "); else - ui_out_text (uiout, "next "); - ui_out_field_int (uiout, "enable", b->enable_count); - ui_out_text (uiout, " hits\n"); + uiout->text ("next "); + uiout->field_int ("enable", b->enable_count); + uiout->text (" hits\n"); } if (!part_of_multiple && is_tracepoint (b)) @@ -6652,9 +6620,9 @@ print_one_breakpoint_location (struct breakpoint *b, if (tp->traceframe_usage) { - ui_out_text (uiout, "\ttrace buffer usage "); - ui_out_field_int (uiout, "traceframe-usage", tp->traceframe_usage); - ui_out_text (uiout, " bytes\n"); + uiout->text ("\ttrace buffer usage "); + uiout->field_int ("traceframe-usage", tp->traceframe_usage); + uiout->text (" bytes\n"); } } @@ -6676,9 +6644,9 @@ print_one_breakpoint_location (struct breakpoint *b, if (!part_of_multiple && t->pass_count) { annotate_field (10); - ui_out_text (uiout, "\tpass count "); - ui_out_field_int (uiout, "pass", t->pass_count); - ui_out_text (uiout, " \n"); + uiout->text ("\tpass count "); + uiout->field_int ("pass", t->pass_count); + uiout->text (" \n"); } /* Don't display it when tracepoint or tracepoint location is @@ -6687,31 +6655,31 @@ print_one_breakpoint_location (struct breakpoint *b, { annotate_field (11); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "installed", + if (uiout->is_mi_like_p ()) + uiout->field_string ("installed", loc->inserted ? "y" : "n"); else { if (loc->inserted) - ui_out_text (uiout, "\t"); + uiout->text ("\t"); else - ui_out_text (uiout, "\tnot "); - ui_out_text (uiout, "installed on target\n"); + uiout->text ("\tnot "); + uiout->text ("installed on target\n"); } } } - if (ui_out_is_mi_like_p (uiout) && !part_of_multiple) + if (uiout->is_mi_like_p () && !part_of_multiple) { if (is_watchpoint (b)) { struct watchpoint *w = (struct watchpoint *) b; - ui_out_field_string (uiout, "original-location", w->exp_string); + uiout->field_string ("original-location", w->exp_string); } else if (b->location != NULL && event_location_to_string (b->location) != NULL) - ui_out_field_string (uiout, "original-location", + uiout->field_string ("original-location", event_location_to_string (b->location)); } } @@ -6911,32 +6879,29 @@ breakpoint_1 (char *args, int allflag, annotate_breakpoints_headers (); if (nr_printable_breakpoints > 0) annotate_field (0); - ui_out_table_header (uiout, 7, ui_left, "number", "Num"); /* 1 */ + uiout->table_header (7, ui_left, "number", "Num"); /* 1 */ if (nr_printable_breakpoints > 0) annotate_field (1); - ui_out_table_header (uiout, print_type_col_width, ui_left, - "type", "Type"); /* 2 */ + uiout->table_header (print_type_col_width, ui_left, "type", "Type"); /* 2 */ if (nr_printable_breakpoints > 0) annotate_field (2); - ui_out_table_header (uiout, 4, ui_left, "disp", "Disp"); /* 3 */ + uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */ if (nr_printable_breakpoints > 0) annotate_field (3); - ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb"); /* 4 */ + uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */ if (opts.addressprint) { if (nr_printable_breakpoints > 0) annotate_field (4); if (print_address_bits <= 32) - ui_out_table_header (uiout, 10, ui_left, - "addr", "Address"); /* 5 */ + uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */ else - ui_out_table_header (uiout, 18, ui_left, - "addr", "Address"); /* 5 */ + uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */ } if (nr_printable_breakpoints > 0) annotate_field (5); - ui_out_table_header (uiout, 40, ui_noalign, "what", "What"); /* 6 */ - ui_out_table_body (uiout); + uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */ + uiout->table_body (); if (nr_printable_breakpoints > 0) annotate_breakpoints_table (); @@ -6978,10 +6943,9 @@ breakpoint_1 (char *args, int allflag, if (!filter) { if (args == NULL || *args == '\0') - ui_out_message (uiout, 0, "No breakpoints or watchpoints.\n"); + uiout->message ("No breakpoints or watchpoints.\n"); else - ui_out_message (uiout, 0, - "No breakpoint or watchpoint matching '%s'.\n", + uiout->message ("No breakpoint or watchpoint matching '%s'.\n", args); } } @@ -7014,9 +6978,9 @@ default_collect_info (void) /* The following phrase lines up nicely with per-tracepoint collect actions. */ - ui_out_text (uiout, "default collect "); - ui_out_field_string (uiout, "default-collect", default_collect); - ui_out_text (uiout, " \n"); + uiout->text ("default collect "); + uiout->field_string ("default-collect", default_collect); + uiout->text (" \n"); } static void @@ -7036,9 +7000,9 @@ watchpoints_info (char *args, int from_tty) if (num_printed == 0) { if (args == NULL || *args == '\0') - ui_out_message (uiout, 0, "No watchpoints.\n"); + uiout->message ("No watchpoints.\n"); else - ui_out_message (uiout, 0, "No watchpoint matching '%s'.\n", args); + uiout->message ("No watchpoint matching '%s'.\n", args); } } @@ -7159,12 +7123,12 @@ watchpoint_locations_match (struct bp_location *loc1, && target_can_accel_watchpoint_condition (loc1->address, loc1->length, loc1->watchpoint_type, - w1->cond_exp)) + w1->cond_exp.get ())) || (w2->cond_exp && target_can_accel_watchpoint_condition (loc2->address, loc2->length, loc2->watchpoint_type, - w2->cond_exp))) + w2->cond_exp.get ()))) return 0; /* Note that this checks the owner's type, not the location's. In @@ -7372,7 +7336,6 @@ init_bp_location (struct bp_location *loc, const struct bp_location_ops *ops, loc->ops = ops; loc->owner = owner; - loc->cond = NULL; loc->cond_bytecode = NULL; loc->shlib_disabled = 0; loc->enabled = 1; @@ -7441,7 +7404,7 @@ static void free_bp_location (struct bp_location *loc) { loc->ops->dtor (loc); - xfree (loc); + delete loc; } /* Increment reference count. */ @@ -7524,7 +7487,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, enum bptype bptype, const struct breakpoint_ops *ops) { - struct breakpoint *b = XNEW (struct breakpoint); + struct breakpoint *b = new breakpoint (); init_raw_breakpoint_without_location (b, gdbarch, bptype, ops); add_to_breakpoint_chain (b); @@ -7640,7 +7603,7 @@ set_raw_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal, enum bptype bptype, const struct breakpoint_ops *ops) { - struct breakpoint *b = XNEW (struct breakpoint); + struct breakpoint *b = new breakpoint (); init_raw_breakpoint (b, gdbarch, sal, bptype, ops); add_to_breakpoint_chain (b); @@ -7982,14 +7945,6 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) struct bp_location *loc, **locp_tmp; int disabled_shlib_breaks = 0; - /* SunOS a.out shared libraries are always mapped, so do not - disable breakpoints; they will only be reported as unloaded - through clear_solib when GDB discards its shared library - list. See clear_solib for more information. */ - if (exec_bfd != NULL - && bfd_get_flavour (exec_bfd) == bfd_target_aout_flavour) - return; - ALL_BP_LOCATIONS (loc, locp_tmp) { /* ALL_BP_LOCATIONS bp_location has LOC->OWNER always non-NULL. */ @@ -8166,19 +8121,18 @@ print_it_catch_fork (bpstat bs) annotate_catchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); if (b->disposition == disp_del) - ui_out_text (uiout, "Temporary catchpoint "); + uiout->text ("Temporary catchpoint "); else - ui_out_text (uiout, "Catchpoint "); - if (ui_out_is_mi_like_p (uiout)) + uiout->text ("Catchpoint "); + if (uiout->is_mi_like_p ()) { - ui_out_field_string (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_FORK)); - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_FORK)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); } - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, " (forked process "); - ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); - ui_out_text (uiout, "), "); + uiout->field_int ("bkptno", b->number); + uiout->text (" (forked process "); + uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid)); + uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -8198,19 +8152,18 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc) line up too nicely with the headers, but the effect is relatively readable). */ if (opts.addressprint) - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); annotate_field (5); - ui_out_text (uiout, "fork"); + uiout->text ("fork"); if (!ptid_equal (c->forked_inferior_pid, null_ptid)) { - ui_out_text (uiout, ", process "); - ui_out_field_int (uiout, "what", - ptid_get_pid (c->forked_inferior_pid)); - ui_out_spaces (uiout, 1); + uiout->text (", process "); + uiout->field_int ("what", ptid_get_pid (c->forked_inferior_pid)); + uiout->spaces (1); } - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "catch-type", "fork"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("catch-type", "fork"); } /* Implement the "print_mention" breakpoint_ops method for fork @@ -8284,19 +8237,18 @@ print_it_catch_vfork (bpstat bs) annotate_catchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); if (b->disposition == disp_del) - ui_out_text (uiout, "Temporary catchpoint "); + uiout->text ("Temporary catchpoint "); else - ui_out_text (uiout, "Catchpoint "); - if (ui_out_is_mi_like_p (uiout)) + uiout->text ("Catchpoint "); + if (uiout->is_mi_like_p ()) { - ui_out_field_string (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_VFORK)); - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_VFORK)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); } - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, " (vforked process "); - ui_out_field_int (uiout, "newpid", ptid_get_pid (c->forked_inferior_pid)); - ui_out_text (uiout, "), "); + uiout->field_int ("bkptno", b->number); + uiout->text (" (vforked process "); + uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid)); + uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -8315,19 +8267,18 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc) line up too nicely with the headers, but the effect is relatively readable). */ if (opts.addressprint) - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); annotate_field (5); - ui_out_text (uiout, "vfork"); + uiout->text ("vfork"); if (!ptid_equal (c->forked_inferior_pid, null_ptid)) { - ui_out_text (uiout, ", process "); - ui_out_field_int (uiout, "what", - ptid_get_pid (c->forked_inferior_pid)); - ui_out_spaces (uiout, 1); + uiout->text (", process "); + uiout->field_int ("what", ptid_get_pid (c->forked_inferior_pid)); + uiout->spaces (1); } - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "catch-type", "vfork"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("catch-type", "vfork"); } /* Implement the "print_mention" breakpoint_ops method for vfork @@ -8481,13 +8432,13 @@ print_it_catch_solib (bpstat bs) annotate_catchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); if (b->disposition == disp_del) - ui_out_text (uiout, "Temporary catchpoint "); + uiout->text ("Temporary catchpoint "); else - ui_out_text (uiout, "Catchpoint "); - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, "\n"); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->text ("Catchpoint "); + uiout->field_int ("bkptno", b->number); + uiout->text ("\n"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("disp", bpdisp_text (b->disposition)); print_solib_event (1); return PRINT_SRC_AND_LOC; } @@ -8507,7 +8458,7 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) if (opts.addressprint) { annotate_field (4); - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); } annotate_field (5); @@ -8525,12 +8476,11 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) else msg = xstrdup (_("unload of library")); } - ui_out_field_string (uiout, "what", msg); + uiout->field_string ("what", msg); xfree (msg); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "catch-type", - self->is_load ? "load" : "unload"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("catch-type", self->is_load ? "load" : "unload"); } static void @@ -8575,7 +8525,7 @@ add_solib_catchpoint (char *arg, int is_load, int is_temp, int enabled) arg = ""; arg = skip_spaces (arg); - c = XCNEW (struct solib_catchpoint); + c = new solib_catchpoint (); cleanup = make_cleanup (xfree, c); if (*arg != '\0') @@ -8674,7 +8624,7 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, int tempflag, char *cond_string, const struct breakpoint_ops *ops) { - struct fork_catchpoint *c = XNEW (struct fork_catchpoint); + struct fork_catchpoint *c = new fork_catchpoint (); init_catchpoint (&c->base, gdbarch, tempflag, cond_string, ops); @@ -8751,19 +8701,18 @@ print_it_catch_exec (bpstat bs) annotate_catchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); if (b->disposition == disp_del) - ui_out_text (uiout, "Temporary catchpoint "); + uiout->text ("Temporary catchpoint "); else - ui_out_text (uiout, "Catchpoint "); - if (ui_out_is_mi_like_p (uiout)) + uiout->text ("Catchpoint "); + if (uiout->is_mi_like_p ()) { - ui_out_field_string (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_EXEC)); - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXEC)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); } - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, " (exec'd "); - ui_out_field_string (uiout, "new-exec", c->exec_pathname); - ui_out_text (uiout, "), "); + uiout->field_int ("bkptno", b->number); + uiout->text (" (exec'd "); + uiout->field_string ("new-exec", c->exec_pathname); + uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -8781,18 +8730,18 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) not line up too nicely with the headers, but the effect is relatively readable). */ if (opts.addressprint) - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); annotate_field (5); - ui_out_text (uiout, "exec"); + uiout->text ("exec"); if (c->exec_pathname != NULL) { - ui_out_text (uiout, ", program \""); - ui_out_field_string (uiout, "what", c->exec_pathname); - ui_out_text (uiout, "\" "); + uiout->text (", program \""); + uiout->field_string ("what", c->exec_pathname); + uiout->text ("\" "); } - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string (uiout, "catch-type", "exec"); + if (uiout->is_mi_like_p ()) + uiout->field_string ("catch-type", "exec"); } static void @@ -8935,7 +8884,7 @@ enable_breakpoints_after_startup (void) static struct breakpoint * new_single_step_breakpoint (int thread, struct gdbarch *gdbarch) { - struct breakpoint *b = XNEW (struct breakpoint); + struct breakpoint *b = new breakpoint (); init_raw_breakpoint_without_location (b, gdbarch, bp_single_step, &momentary_breakpoint_ops); @@ -9052,7 +9001,7 @@ static void mention (struct breakpoint *b) { b->ops->print_mention (b); - if (ui_out_is_mi_like_p (current_uiout)) + if (current_uiout->is_mi_like_p ()) return; printf_filtered ("\n"); } @@ -9443,11 +9392,11 @@ create_breakpoint_sal (struct gdbarch *gdbarch, { struct tracepoint *t; - t = XCNEW (struct tracepoint); + t = new tracepoint (); b = &t->base; } else - b = XNEW (struct breakpoint); + b = new breakpoint (); old_chain = make_cleanup (xfree, b); @@ -9698,11 +9647,8 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) { - struct expression *expr; - tok = cond_start = end_tok + 1; - expr = parse_exp_1 (&tok, pc, block_for_pc (pc), 0); - xfree (expr); + parse_exp_1 (&tok, pc, block_for_pc (pc), 0); cond_end = tok; *cond_string = savestring (cond_start, cond_end - cond_start); } @@ -9947,11 +9893,11 @@ create_breakpoint (struct gdbarch *gdbarch, { struct tracepoint *t; - t = XCNEW (struct tracepoint); + t = new tracepoint (); b = &t->base; } else - b = XNEW (struct breakpoint); + b = new breakpoint (); init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops); b->location = copy_event_location (location); @@ -10298,17 +10244,17 @@ print_it_ranged_breakpoint (bpstat bs) maybe_print_thread_hit_breakpoint (uiout); if (b->disposition == disp_del) - ui_out_text (uiout, "Temporary ranged breakpoint "); + uiout->text ("Temporary ranged breakpoint "); else - ui_out_text (uiout, "Ranged breakpoint "); - if (ui_out_is_mi_like_p (uiout)) + uiout->text ("Ranged breakpoint "); + if (uiout->is_mi_like_p ()) { - ui_out_field_string (uiout, "reason", + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); } - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, ", "); + uiout->field_int ("bkptno", b->number); + uiout->text (", "); return PRINT_SRC_AND_LOC; } @@ -10332,7 +10278,7 @@ print_one_ranged_breakpoint (struct breakpoint *b, if (opts.addressprint) /* We don't print the address range here, it will be printed later by print_one_detail_ranged_breakpoint. */ - ui_out_field_skip (uiout, "addr"); + uiout->field_skip ("addr"); annotate_field (5); print_breakpoint_location (b, bl); *last_loc = bl; @@ -10355,12 +10301,12 @@ print_one_detail_ranged_breakpoint (const struct breakpoint *b, address_start = bl->address; address_end = address_start + bl->length - 1; - ui_out_text (uiout, "\taddress range: "); + uiout->text ("\taddress range: "); fprintf_unfiltered (stb, "[%s, %s]", print_core_address (bl->gdbarch, address_start), print_core_address (bl->gdbarch, address_end)); - ui_out_field_stream (uiout, "addr", stb); - ui_out_text (uiout, "\n"); + uiout->field_stream ("addr", stb); + uiout->text ("\n"); do_cleanups (cleanup); } @@ -10377,7 +10323,7 @@ print_mention_ranged_breakpoint (struct breakpoint *b) gdb_assert (bl); gdb_assert (b->type == bp_hardware_breakpoint); - if (ui_out_is_mi_like_p (uiout)) + if (uiout->is_mi_like_p ()) return; printf_filtered (_("Hardware assisted ranged breakpoint %d from %s to %s."), @@ -10672,8 +10618,6 @@ dtor_watchpoint (struct breakpoint *self) { struct watchpoint *w = (struct watchpoint *) self; - xfree (w->cond_exp); - xfree (w->exp); xfree (w->exp_string); xfree (w->exp_string_reparse); value_free (w->val); @@ -10725,7 +10669,7 @@ insert_watchpoint (struct bp_location *bl) int length = w->exact ? 1 : bl->length; return target_insert_watchpoint (bl->address, length, bl->watchpoint_type, - w->cond_exp); + w->cond_exp.get ()); } /* Implement the "remove" breakpoint_ops method for hardware watchpoints. */ @@ -10737,7 +10681,7 @@ remove_watchpoint (struct bp_location *bl, enum remove_bp_reason reason) int length = w->exact ? 1 : bl->length; return target_remove_watchpoint (bl->address, length, bl->watchpoint_type, - w->cond_exp); + w->cond_exp.get ()); } static int @@ -10816,64 +10760,62 @@ print_it_watchpoint (bpstat bs) { case bp_watchpoint: case bp_hardware_watchpoint: - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); mention (b); make_cleanup_ui_out_tuple_begin_end (uiout, "value"); - ui_out_text (uiout, "\nOld value = "); + uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, stb); - ui_out_field_stream (uiout, "old", stb); - ui_out_text (uiout, "\nNew value = "); + uiout->field_stream ("old", stb); + uiout->text ("\nNew value = "); watchpoint_value_print (w->val, stb); - ui_out_field_stream (uiout, "new", stb); - ui_out_text (uiout, "\n"); + uiout->field_stream ("new", stb); + uiout->text ("\n"); /* More than one watchpoint may have been triggered. */ result = PRINT_UNKNOWN; break; case bp_read_watchpoint: - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); mention (b); make_cleanup_ui_out_tuple_begin_end (uiout, "value"); - ui_out_text (uiout, "\nValue = "); + uiout->text ("\nValue = "); watchpoint_value_print (w->val, stb); - ui_out_field_stream (uiout, "value", stb); - ui_out_text (uiout, "\n"); + uiout->field_stream ("value", stb); + uiout->text ("\n"); result = PRINT_UNKNOWN; break; case bp_access_watchpoint: if (bs->old_val != NULL) { - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); mention (b); make_cleanup_ui_out_tuple_begin_end (uiout, "value"); - ui_out_text (uiout, "\nOld value = "); + uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, stb); - ui_out_field_stream (uiout, "old", stb); - ui_out_text (uiout, "\nNew value = "); + uiout->field_stream ("old", stb); + uiout->text ("\nNew value = "); } else { mention (b); - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); make_cleanup_ui_out_tuple_begin_end (uiout, "value"); - ui_out_text (uiout, "\nValue = "); + uiout->text ("\nValue = "); } watchpoint_value_print (w->val, stb); - ui_out_field_stream (uiout, "new", stb); - ui_out_text (uiout, "\n"); + uiout->field_stream ("new", stb); + uiout->text ("\n"); result = PRINT_UNKNOWN; break; default: @@ -10897,19 +10839,19 @@ print_mention_watchpoint (struct breakpoint *b) switch (b->type) { case bp_watchpoint: - ui_out_text (uiout, "Watchpoint "); + uiout->text ("Watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); break; case bp_hardware_watchpoint: - ui_out_text (uiout, "Hardware watchpoint "); + uiout->text ("Hardware watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); break; case bp_read_watchpoint: - ui_out_text (uiout, "Hardware read watchpoint "); + uiout->text ("Hardware read watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt"); break; case bp_access_watchpoint: - ui_out_text (uiout, "Hardware access (read/write) watchpoint "); + uiout->text ("Hardware access (read/write) watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt"); break; default: @@ -10917,9 +10859,9 @@ print_mention_watchpoint (struct breakpoint *b) _("Invalid hardware watchpoint type.")); } - ui_out_field_int (uiout, "number", b->number); - ui_out_text (uiout, ": "); - ui_out_field_string (uiout, "exp", w->exp_string); + uiout->field_int ("number", b->number); + uiout->text (": "); + uiout->field_string ("exp", w->exp_string); do_cleanups (ui_out_chain); } @@ -11032,23 +10974,21 @@ print_it_masked_watchpoint (bpstat bs) switch (b->type) { case bp_hardware_watchpoint: - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); break; case bp_read_watchpoint: - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", - async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); break; case bp_access_watchpoint: - if (ui_out_is_mi_like_p (uiout)) - ui_out_field_string - (uiout, "reason", + if (uiout->is_mi_like_p ()) + uiout->field_string + ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); break; default: @@ -11057,10 +10997,10 @@ print_it_masked_watchpoint (bpstat bs) } mention (b); - ui_out_text (uiout, _("\n\ + uiout->text (_("\n\ Check the underlying instruction at PC for the memory\n\ address and value which triggered this watchpoint.\n")); - ui_out_text (uiout, "\n"); + uiout->text ("\n"); /* More than one watchpoint may have been triggered. */ return PRINT_UNKNOWN; @@ -11078,9 +11018,9 @@ print_one_detail_masked_watchpoint (const struct breakpoint *b, /* Masked watchpoints have only one location. */ gdb_assert (b->loc && b->loc->next == NULL); - ui_out_text (uiout, "\tmask "); - ui_out_field_core_addr (uiout, "mask", b->loc->gdbarch, w->hw_wp_mask); - ui_out_text (uiout, "\n"); + uiout->text ("\tmask "); + uiout->field_core_addr ("mask", b->loc->gdbarch, w->hw_wp_mask); + uiout->text ("\n"); } /* Implement the "print_mention" breakpoint_ops method for @@ -11096,15 +11036,15 @@ print_mention_masked_watchpoint (struct breakpoint *b) switch (b->type) { case bp_hardware_watchpoint: - ui_out_text (uiout, "Masked hardware watchpoint "); + uiout->text ("Masked hardware watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt"); break; case bp_read_watchpoint: - ui_out_text (uiout, "Masked hardware read watchpoint "); + uiout->text ("Masked hardware read watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt"); break; case bp_access_watchpoint: - ui_out_text (uiout, "Masked hardware access (read/write) watchpoint "); + uiout->text ("Masked hardware access (read/write) watchpoint "); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt"); break; default: @@ -11112,9 +11052,9 @@ print_mention_masked_watchpoint (struct breakpoint *b) _("Invalid hardware watchpoint type.")); } - ui_out_field_int (uiout, "number", b->number); - ui_out_text (uiout, ": "); - ui_out_field_string (uiout, "exp", w->exp_string); + uiout->field_int ("number", b->number); + uiout->text (": "); + uiout->field_string ("exp", w->exp_string); do_cleanups (ui_out_chain); } @@ -11168,7 +11108,6 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, int just_location, int internal) { struct breakpoint *b, *scope_breakpoint = NULL; - struct expression *exp; const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL; struct value *val, *mark, *result; int saved_bitpos = 0, saved_bitsize = 0; @@ -11280,7 +11219,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, expression = savestring (arg, exp_end - arg); back_to = make_cleanup (xfree, expression); exp_start = arg = expression; - exp = parse_exp_1 (&arg, 0, 0, 0); + expression_up exp = parse_exp_1 (&arg, 0, 0, 0); exp_end = arg; /* Remove trailing whitespace from the expression before saving it. This makes the eventual display of the expression string a bit @@ -11289,7 +11228,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, --exp_end; /* Checking if the expression is not constant. */ - if (watchpoint_exp_is_const (exp)) + if (watchpoint_exp_is_const (exp.get ())) { int len; @@ -11301,7 +11240,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, exp_valid_block = innermost_block; mark = value_mark (); - fetch_subexp_value (exp, &pc, &val, &result, NULL, just_location); + fetch_subexp_value (exp.get (), &pc, &val, &result, NULL, just_location); if (val != NULL && just_location) { @@ -11337,17 +11276,14 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, toklen = end_tok - tok; if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) { - struct expression *cond; - innermost_block = NULL; tok = cond_start = end_tok + 1; - cond = parse_exp_1 (&tok, 0, 0, 0); + parse_exp_1 (&tok, 0, 0, 0); /* 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; - xfree (cond); cond_end = tok; } if (*tok) @@ -11401,7 +11337,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, else bp_type = bp_hardware_watchpoint; - w = XCNEW (struct watchpoint); + w = new watchpoint (); b = &w->base; if (use_mask) init_raw_breakpoint_without_location (b, NULL, bp_type, @@ -11412,21 +11348,20 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, b->thread = thread; b->disposition = disp_donttouch; b->pspace = current_program_space; - w->exp = exp; + w->exp = std::move (exp); w->exp_valid_block = exp_valid_block; w->cond_exp_valid_block = cond_exp_valid_block; if (just_location) { struct type *t = value_type (val); CORE_ADDR addr = value_as_address (val); - char *name; t = check_typedef (TYPE_TARGET_TYPE (check_typedef (t))); - name = type_to_string (t); - w->exp_string_reparse = xstrprintf ("* (%s *) %s", name, + std::string name = type_to_string (t); + + w->exp_string_reparse = xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)); - xfree (name); w->exp_string = xstrprintf ("-location %.*s", (int) (exp_end - exp_start), exp_start); @@ -11960,7 +11895,7 @@ catch_exec_command_1 (char *arg, int from_tty, if ((*arg != '\0') && !isspace (*arg)) error (_("Junk at end of arguments.")); - c = XNEW (struct exec_catchpoint); + c = new exec_catchpoint (); init_catchpoint (&c->base, gdbarch, tempflag, cond_string, &catch_exec_breakpoint_ops); c->exec_pathname = NULL; @@ -12438,11 +12373,7 @@ force_breakpoint_reinsertion (struct bp_location *bl) /* Free the agent expression bytecode as well. We will compute it later on. */ - if (loc->cond_bytecode) - { - free_agent_expr (loc->cond_bytecode); - loc->cond_bytecode = NULL; - } + loc->cond_bytecode.reset (); } } /* Called whether new breakpoints are created, or existing breakpoints @@ -12928,13 +12859,7 @@ say_where (struct breakpoint *b) static void bp_location_dtor (struct bp_location *self) { - xfree (self->cond); - if (self->cond_bytecode) - free_agent_expr (self->cond_bytecode); xfree (self->function_name); - - VEC_free (agent_expr_p, self->target_info.conditions); - VEC_free (agent_expr_p, self->target_info.tcommands); } static const struct bp_location_ops bp_location_ops = @@ -12961,7 +12886,7 @@ base_breakpoint_allocate_location (struct breakpoint *self) { struct bp_location *loc; - loc = XNEW (struct bp_location); + loc = new struct bp_location (); init_bp_location (loc, &bp_location_ops, self); return loc; } @@ -13226,17 +13151,17 @@ bkpt_print_it (bpstat bs) maybe_print_thread_hit_breakpoint (uiout); if (bp_temp) - ui_out_text (uiout, "Temporary breakpoint "); + uiout->text ("Temporary breakpoint "); else - ui_out_text (uiout, "Breakpoint "); - if (ui_out_is_mi_like_p (uiout)) + uiout->text ("Breakpoint "); + if (uiout->is_mi_like_p ()) { - ui_out_field_string (uiout, "reason", + uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); - ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (b->disposition)); } - ui_out_field_int (uiout, "bkptno", b->number); - ui_out_text (uiout, ", "); + uiout->field_int ("bkptno", b->number); + uiout->text (", "); return PRINT_SRC_AND_LOC; } @@ -13244,7 +13169,7 @@ bkpt_print_it (bpstat bs) static void bkpt_print_mention (struct breakpoint *b) { - if (ui_out_is_mi_like_p (current_uiout)) + if (current_uiout->is_mi_like_p ()) return; switch (b->type) @@ -13560,17 +13485,17 @@ tracepoint_print_one_detail (const struct breakpoint *self, { gdb_assert (self->type == bp_static_tracepoint); - ui_out_text (uiout, "\tmarker id is "); - ui_out_field_string (uiout, "static-tracepoint-marker-string-id", + uiout->text ("\tmarker id is "); + uiout->field_string ("static-tracepoint-marker-string-id", tp->static_trace_marker_id); - ui_out_text (uiout, "\n"); + uiout->text ("\n"); } } static void tracepoint_print_mention (struct breakpoint *b) { - if (ui_out_is_mi_like_p (current_uiout)) + if (current_uiout->is_mi_like_p ()) return; switch (b->type) @@ -13818,7 +13743,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, location = copy_event_location (canonical->location); old_chain = make_cleanup_delete_event_location (location); - tp = XCNEW (struct tracepoint); + tp = new tracepoint (); init_breakpoint_sal (&tp->base, gdbarch, expanded, location, NULL, cond_string, extra_string, @@ -13960,7 +13885,7 @@ delete_breakpoint (struct breakpoint *bpt) /* On the chance that someone will soon try again to delete this same bp, we mark it as deleted before freeing its storage. */ bpt->type = bp_none; - xfree (bpt); + delete bpt; } static void @@ -14210,26 +14135,25 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) sal2 = find_pc_line (tpmarker->address, 0); sym = find_pc_sect_function (tpmarker->address, NULL); - ui_out_text (uiout, "Now in "); + uiout->text ("Now in "); if (sym) { - ui_out_field_string (uiout, "func", - SYMBOL_PRINT_NAME (sym)); - ui_out_text (uiout, " at "); + uiout->field_string ("func", SYMBOL_PRINT_NAME (sym)); + uiout->text (" at "); } - ui_out_field_string (uiout, "file", + uiout->field_string ("file", symtab_to_filename_for_display (sal2.symtab)); - ui_out_text (uiout, ":"); + uiout->text (":"); - if (ui_out_is_mi_like_p (uiout)) + if (uiout->is_mi_like_p ()) { const char *fullname = symtab_to_fullname (sal2.symtab); - ui_out_field_string (uiout, "fullname", fullname); + uiout->field_string ("fullname", fullname); } - ui_out_field_int (uiout, "line", sal2.line); - ui_out_text (uiout, "\n"); + uiout->field_int ("line", sal2.line); + uiout->text ("\n"); b->loc->line_number = sal2.line; b->loc->symtab = sym != NULL ? sal2.symtab : NULL; @@ -14795,8 +14719,9 @@ ignore_command (char *args, int from_tty) whose numbers are given in ARGS. */ static void -map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *, - void *), +map_breakpoint_numbers (const char *args, + void (*function) (struct breakpoint *, + void *), void *data) { int num; @@ -15232,6 +15157,34 @@ insert_single_step_breakpoint (struct gdbarch *gdbarch, update_global_location_list (UGLL_INSERT); } +/* Insert single step breakpoints according to the current state. */ + +int +insert_single_step_breakpoints (struct gdbarch *gdbarch) +{ + struct regcache *regcache = get_current_regcache (); + VEC (CORE_ADDR) * next_pcs; + + next_pcs = gdbarch_software_single_step (gdbarch, regcache); + + if (next_pcs != NULL) + { + int i; + CORE_ADDR pc; + struct frame_info *frame = get_current_frame (); + struct address_space *aspace = get_frame_address_space (frame); + + for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++) + insert_single_step_breakpoint (gdbarch, aspace, pc); + + VEC_free (CORE_ADDR, next_pcs); + + return 1; + } + else + return 0; +} + /* See breakpoint.h. */ int @@ -15494,9 +15447,9 @@ tracepoints_info (char *args, int from_tty) if (num_printed == 0) { if (args == NULL || *args == '\0') - ui_out_message (uiout, 0, "No tracepoints.\n"); + uiout->message ("No tracepoints.\n"); else - ui_out_message (uiout, 0, "No tracepoint matching '%s'.\n", args); + uiout->message ("No tracepoint matching '%s'.\n", args); } default_collect_info (); @@ -15787,19 +15740,19 @@ save_breakpoints (char *filename, int from_tty, { fprintf_unfiltered (fp, " commands\n"); - ui_out_redirect (current_uiout, fp); + current_uiout->redirect (fp); TRY { print_command_lines (current_uiout, tp->commands->commands, 2); } CATCH (ex, RETURN_MASK_ALL) { - ui_out_redirect (current_uiout, NULL); + current_uiout->redirect (NULL); throw_exception (ex); } END_CATCH - ui_out_redirect (current_uiout, NULL); + current_uiout->redirect (NULL); fprintf_unfiltered (fp, " end\n"); }