X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=ada72e04237a41adb27218de2265aac4522846dd;hb=bd5225139c83a80aad542e46efb66fabf51bff91;hp=ae09da4bca330524f1e63a81f5b0b8dd3d636875;hpb=11db943032396e1fee31440b0a331511dc0f4c00;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ae09da4bca..ada72e0423 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -44,7 +44,6 @@ #include "source.h" #include "linespec.h" #include "completer.h" -#include "gdb.h" #include "ui-out.h" #include "cli/cli-script.h" #include "block.h" @@ -81,6 +80,8 @@ #include "extension.h" #include #include "progspace-and-thread.h" +#include "common/array-view.h" +#include "common/gdb_optional.h" /* Enums for exception-handling support. */ enum exception_event_kind @@ -92,25 +93,11 @@ enum exception_event_kind /* Prototypes for local functions. */ -static void enable_delete_command (char *, int); - -static void enable_once_command (char *, int); - -static void enable_count_command (char *, int); - -static void disable_command (char *, int); - -static void enable_command (char *, int); - static void map_breakpoint_numbers (const char *, - void (*) (struct breakpoint *, - void *), - void *); + gdb::function_view); static void ignore_command (char *, int); -static int breakpoint_re_set_one (void *); - static void breakpoint_re_set_default (struct breakpoint *); static void @@ -128,19 +115,14 @@ static void create_breakpoints_sal_default (struct gdbarch *, const struct breakpoint_ops *, int, int, int, unsigned); -static void decode_location_default (struct breakpoint *b, - const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals); +static std::vector decode_location_default + (struct breakpoint *b, const struct event_location *location, + struct program_space *search_pspace); static void clear_command (char *, int); -static void catch_command (char *, int); - static int can_use_hardware_watchpoint (struct value *); -static void break_command_1 (char *, int, int); - static void mention (struct breakpoint *); static struct breakpoint *set_raw_breakpoint_without_location (struct gdbarch *, @@ -176,24 +158,17 @@ static int watchpoint_locations_match (struct bp_location *loc1, struct bp_location *loc2); static int breakpoint_location_address_match (struct bp_location *bl, - struct address_space *aspace, + const struct address_space *aspace, CORE_ADDR addr); static int breakpoint_location_address_range_overlap (struct bp_location *, - struct address_space *, + const address_space *, CORE_ADDR, int); static void info_breakpoints_command (char *, int); static void info_watchpoints_command (char *, int); -static int breakpoint_1 (char *, int, - int (*) (const struct breakpoint *)); - -static int breakpoint_cond_eval (void *); - -static void cleanup_executing_breakpoints (void *); - static void commands_command (char *, int); static void condition_command (char *, int); @@ -203,10 +178,6 @@ static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason); static enum print_stop_action print_bp_stop_message (bpstat bs); -static int watchpoint_check (void *); - -static void maintenance_info_breakpoints (char *, int); - static int hw_breakpoint_used_count (void); static int hw_watchpoint_use_count (struct breakpoint *); @@ -224,12 +195,6 @@ static void enable_breakpoint_disp (struct breakpoint *, enum bpdisp, static void stop_command (char *arg, int from_tty); -static void stopin_command (char *arg, int from_tty); - -static void stopat_command (char *arg, int from_tty); - -static void tcatch_command (char *arg, int from_tty); - static void free_bp_location (struct bp_location *loc); static void incref_bp_location (struct bp_location *loc); static void decref_bp_location (struct bp_location **loc); @@ -281,8 +246,6 @@ static void insert_breakpoint_locations (void); static void info_tracepoints_command (char *, int); -static void delete_trace_command (char *, int); - static void enable_trace_command (char *, int); static void disable_trace_command (char *, int); @@ -360,21 +323,10 @@ static char *dprintf_channel; has disconnected. */ static int disconnected_dprintf = 1; -/* A reference-counted struct command_line. This lets multiple - breakpoints share a single command list. */ -struct counted_command_line -{ - /* The reference count. */ - int refc; - - /* The command list. */ - struct command_line *commands; -}; - struct command_line * breakpoint_commands (struct breakpoint *b) { - return b->commands ? b->commands->commands : NULL; + return b->commands ? b->commands.get () : NULL; } /* Flag indicating that a command has proceeded the inferior past the @@ -551,8 +503,6 @@ gdb_evaluates_breakpoint_condition_p (void) return (mode == condition_evaluation_host); } -void _initialize_breakpoint (void); - /* Are we executing breakpoint commands? */ static int executing_breakpoint_commands; @@ -720,64 +670,6 @@ clear_breakpoint_hit_counts (void) b->hit_count = 0; } -/* Allocate a new counted_command_line with reference count of 1. - The new structure owns COMMANDS. */ - -static struct counted_command_line * -alloc_counted_command_line (struct command_line *commands) -{ - struct counted_command_line *result = XNEW (struct counted_command_line); - - result->refc = 1; - result->commands = commands; - - return result; -} - -/* Increment reference count. This does nothing if CMD is NULL. */ - -static void -incref_counted_command_line (struct counted_command_line *cmd) -{ - if (cmd) - ++cmd->refc; -} - -/* Decrement reference count. If the reference count reaches 0, - destroy the counted_command_line. Sets *CMDP to NULL. This does - nothing if *CMDP is NULL. */ - -static void -decref_counted_command_line (struct counted_command_line **cmdp) -{ - if (*cmdp) - { - if (--(*cmdp)->refc == 0) - { - free_command_lines (&(*cmdp)->commands); - xfree (*cmdp); - } - *cmdp = NULL; - } -} - -/* A cleanup function that calls decref_counted_command_line. */ - -static void -do_cleanup_counted_command_line (void *arg) -{ - decref_counted_command_line ((struct counted_command_line **) arg); -} - -/* Create a cleanup that calls decref_counted_command_line on the - argument. */ - -static struct cleanup * -make_cleanup_decref_counted_command_line (struct counted_command_line **cmdp) -{ - return make_cleanup (do_cleanup_counted_command_line, cmdp); -} - /* Return the breakpoint with the specified number, or NULL if the number does not refer to an existing breakpoint. */ @@ -1049,8 +941,8 @@ condition_completer (struct cmd_list_element *cmd, { const char *space; - text = skip_spaces_const (text); - space = skip_to_space_const (text); + text = skip_spaces (text); + space = skip_to_space (text); if (*space == '\0') { int len; @@ -1085,7 +977,7 @@ condition_completer (struct cmd_list_element *cmd, } /* We're completing the expression part. */ - text = skip_spaces_const (space); + text = skip_spaces (space); expression_completer (cmd, tracker, text, word); } @@ -1306,8 +1198,7 @@ breakpoint_set_commands (struct breakpoint *b, { validate_commands_for_breakpoint (b, commands.get ()); - decref_counted_command_line (&b->commands); - b->commands = alloc_counted_command_line (commands.release ()); + b->commands = std::move (commands); observer_notify_breakpoint_modified (b); } @@ -1359,88 +1250,11 @@ check_tracepoint_command (char *line, void *closure) validate_actionline (line, b); } -/* A structure used to pass information through - map_breakpoint_numbers. */ - -struct commands_info -{ - /* True if the command was typed at a tty. */ - int from_tty; - - /* The breakpoint range spec. */ - const char *arg; - - /* Non-NULL if the body of the commands are being read from this - already-parsed command. */ - struct command_line *control; - - /* The command lines read from the user, or NULL if they have not - yet been read. */ - struct counted_command_line *cmd; -}; - -/* A callback for map_breakpoint_numbers that sets the commands for - commands_command. */ - -static void -do_map_commands_command (struct breakpoint *b, void *data) -{ - struct commands_info *info = (struct commands_info *) data; - - if (info->cmd == NULL) - { - command_line_up l; - - if (info->control != NULL) - l = copy_command_lines (info->control->body_list[0]); - else - { - struct cleanup *old_chain; - char *str; - - str = xstrprintf (_("Type commands for breakpoint(s) " - "%s, one per line."), - info->arg); - - old_chain = make_cleanup (xfree, str); - - l = read_command_lines (str, - info->from_tty, 1, - (is_tracepoint (b) - ? check_tracepoint_command : 0), - b); - - do_cleanups (old_chain); - } - - info->cmd = alloc_counted_command_line (l.release ()); - } - - /* If a breakpoint was on the list more than once, we don't need to - do anything. */ - if (b->commands != info->cmd) - { - validate_commands_for_breakpoint (b, info->cmd->commands); - incref_counted_command_line (info->cmd); - decref_counted_command_line (&b->commands); - b->commands = info->cmd; - observer_notify_breakpoint_modified (b); - } -} - static void commands_command_1 (const char *arg, int from_tty, struct command_line *control) { - struct cleanup *cleanups; - struct commands_info info; - - info.from_tty = from_tty; - info.control = control; - info.cmd = NULL; - /* If we read command lines from the user, then `info' will hold an - extra reference to the commands that we must clean up. */ - cleanups = make_cleanup_decref_counted_command_line (&info.cmd); + counted_command_line cmd; std::string new_arg; @@ -1451,18 +1265,43 @@ commands_command_1 (const char *arg, int from_tty, breakpoint_count); else if (breakpoint_count > 0) new_arg = string_printf ("%d", breakpoint_count); - } - else - new_arg = arg; - - info.arg = new_arg.c_str (); - - map_breakpoint_numbers (info.arg, do_map_commands_command, &info); + arg = new_arg.c_str (); + } + + map_breakpoint_numbers + (arg, [&] (breakpoint *b) + { + if (cmd == NULL) + { + if (control != NULL) + cmd = copy_command_lines (control->body_list[0]); + else + { + std::string str + = string_printf (_("Type commands for breakpoint(s) " + "%s, one per line."), + arg); + + cmd = read_command_lines (&str[0], + from_tty, 1, + (is_tracepoint (b) + ? check_tracepoint_command : 0), + b); + } + } + + /* If a breakpoint was on the list more than once, we don't need to + do anything. */ + if (b->commands != cmd) + { + validate_commands_for_breakpoint (b, cmd.get ()); + b->commands = cmd; + observer_notify_breakpoint_modified (b); + } + }); - if (info.cmd == NULL) + if (cmd == NULL) error (_("No breakpoints specified.")); - - do_cleanups (cleanups); } static void @@ -2432,7 +2271,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) if (*cmdrest == ',') ++cmdrest; - cmdrest = skip_spaces_const (cmdrest); + cmdrest = skip_spaces (cmdrest); if (*cmdrest++ != '"') error (_("No format string following the location")); @@ -2448,14 +2287,14 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) if (*cmdrest++ != '"') error (_("Bad format string, non-terminated '\"'.")); - cmdrest = skip_spaces_const (cmdrest); + cmdrest = skip_spaces (cmdrest); if (!(*cmdrest == ',' || *cmdrest == '\0')) error (_("Invalid argument syntax")); if (*cmdrest == ',') cmdrest++; - cmdrest = skip_spaces_const (cmdrest); + cmdrest = skip_spaces (cmdrest); /* For each argument, make an expression. */ @@ -2889,16 +2728,14 @@ insert_bp_location (struct bp_location *bl, { if (bp_err_message == NULL) { - char *message + std::string message = memory_error_message (TARGET_XFER_E_IO, bl->gdbarch, bl->address); - struct cleanup *old_chain = make_cleanup (xfree, message); fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n" "%s\n", - bl->owner->number, message); - do_cleanups (old_chain); + bl->owner->number, message.c_str ()); } else { @@ -3129,7 +2966,7 @@ update_inserted_breakpoint_locations (void) if (error_flag) { - target_terminal_ours_for_output (); + target_terminal::ours_for_output (); error_stream (tmp_error_stream); } } @@ -3228,7 +3065,7 @@ insert_breakpoint_locations (void) tmp_error_stream.printf ("Could not insert hardware breakpoints:\n\ You may have requested too many hardware breakpoints/watchpoints.\n"); } - target_terminal_ours_for_output (); + target_terminal::ours_for_output (); error_stream (tmp_error_stream); } } @@ -3299,42 +3136,6 @@ remove_breakpoints_pid (int pid) return 0; } -int -reattach_breakpoints (int pid) -{ - struct bp_location *bl, **blp_tmp; - int val; - int dummy1 = 0, dummy2 = 0, dummy3 = 0; - struct inferior *inf; - struct thread_info *tp; - - tp = any_live_thread_of_process (pid); - if (tp == NULL) - return 1; - - inf = find_inferior_pid (pid); - - scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = tp->ptid; - - string_file tmp_error_stream; - - ALL_BP_LOCATIONS (bl, blp_tmp) - { - if (bl->pspace != inf->pspace) - continue; - - if (bl->inserted) - { - bl->inserted = 0; - val = insert_bp_location (bl, &tmp_error_stream, &dummy1, &dummy2, &dummy3); - if (val != 0) - return val; - } - } - return 0; -} - static int internal_breakpoint_number = -1; /* Set the breakpoint number of B, depending on the value of INTERNAL. @@ -3360,16 +3161,12 @@ create_internal_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address, enum bptype type, const struct breakpoint_ops *ops) { - struct symtab_and_line sal; - struct breakpoint *b; - - init_sal (&sal); /* Initialize to zeroes. */ - + symtab_and_line sal; sal.pc = address; sal.section = find_pc_overlay (sal.pc); sal.pspace = current_program_space; - b = set_raw_breakpoint (gdbarch, sal, type, ops); + breakpoint *b = set_raw_breakpoint (gdbarch, sal, type, ops); b->number = internal_breakpoint_number--; b->disposition = disp_donttouch; @@ -4248,7 +4045,7 @@ breakpoint_init_inferior (enum inf_context context) the target, to advance the PC past the breakpoint. */ enum breakpoint_here -breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc) +breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) { struct bp_location *bl, **blp_tmp; int any_breakpoint_here = 0; @@ -4281,7 +4078,7 @@ breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc) /* See breakpoint.h. */ int -breakpoint_in_range_p (struct address_space *aspace, +breakpoint_in_range_p (const address_space *aspace, CORE_ADDR addr, ULONGEST len) { struct bp_location *bl, **blp_tmp; @@ -4315,7 +4112,7 @@ breakpoint_in_range_p (struct address_space *aspace, /* Return true if there's a moribund breakpoint at PC. */ int -moribund_breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc) +moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) { struct bp_location *loc; int ix; @@ -4332,7 +4129,7 @@ moribund_breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc) static int bp_location_inserted_here_p (struct bp_location *bl, - struct address_space *aspace, CORE_ADDR pc) + const address_space *aspace, CORE_ADDR pc) { if (bl->inserted && breakpoint_address_match (bl->pspace->aspace, bl->address, @@ -4351,7 +4148,7 @@ bp_location_inserted_here_p (struct bp_location *bl, /* Returns non-zero iff there's a breakpoint inserted at PC. */ int -breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc) +breakpoint_inserted_here_p (const address_space *aspace, CORE_ADDR pc) { struct bp_location **blp, **blp_tmp = NULL; @@ -4373,7 +4170,7 @@ breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc) inserted at PC. */ int -software_breakpoint_inserted_here_p (struct address_space *aspace, +software_breakpoint_inserted_here_p (const address_space *aspace, CORE_ADDR pc) { struct bp_location **blp, **blp_tmp = NULL; @@ -4395,7 +4192,7 @@ software_breakpoint_inserted_here_p (struct address_space *aspace, /* See breakpoint.h. */ int -hardware_breakpoint_inserted_here_p (struct address_space *aspace, +hardware_breakpoint_inserted_here_p (const address_space *aspace, CORE_ADDR pc) { struct bp_location **blp, **blp_tmp = NULL; @@ -4415,7 +4212,7 @@ hardware_breakpoint_inserted_here_p (struct address_space *aspace, } int -hardware_watchpoint_inserted_in_range (struct address_space *aspace, +hardware_watchpoint_inserted_in_range (const address_space *aspace, CORE_ADDR addr, ULONGEST len) { struct breakpoint *bpt; @@ -4459,14 +4256,12 @@ is_catchpoint (struct breakpoint *ep) /* Frees any storage that is part of a bpstat. Does not walk the 'next' chain. */ -static void -bpstat_free (bpstat bs) +bpstats::~bpstats () { - if (bs->old_val != NULL) - value_free (bs->old_val); - decref_counted_command_line (&bs->commands); - decref_bp_location (&bs->bp_location_at); - xfree (bs); + if (old_val != NULL) + value_free (old_val); + if (bp_location_at != NULL) + decref_bp_location (&bp_location_at); } /* Clear a bpstat so that it says we are not at any breakpoint. @@ -4484,12 +4279,30 @@ bpstat_clear (bpstat *bsp) while (p != NULL) { q = p->next; - bpstat_free (p); + delete p; p = q; } *bsp = NULL; } +bpstats::bpstats (const bpstats &other) + : next (NULL), + bp_location_at (other.bp_location_at), + breakpoint_at (other.breakpoint_at), + commands (other.commands), + old_val (other.old_val), + print (other.print), + stop (other.stop), + print_it (other.print_it) +{ + if (old_val != NULL) + { + old_val = value_copy (old_val); + release_value (old_val); + } + incref_bp_location (bp_location_at); +} + /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that is part of the bpstat is copied as well. */ @@ -4505,15 +4318,7 @@ bpstat_copy (bpstat bs) for (; bs != NULL; bs = bs->next) { - tmp = (bpstat) xmalloc (sizeof (*tmp)); - memcpy (tmp, bs, sizeof (*tmp)); - incref_counted_command_line (tmp->commands); - incref_bp_location (tmp->bp_location_at); - if (bs->old_val != NULL) - { - tmp->old_val = value_copy (bs->old_val); - release_value (tmp->old_val); - } + tmp = new bpstats (*bs); if (p == NULL) /* This is the first thing in the chain. */ @@ -4614,7 +4419,7 @@ bpstat_clear_actions (void) for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next) { - decref_counted_command_line (&bs->commands); + bs->commands = NULL; if (bs->old_val != NULL) { @@ -4644,14 +4449,6 @@ breakpoint_about_to_proceed (void) breakpoint_proceeded = 1; } -/* Stub for cleaning up our state if we error-out of a breakpoint - command. */ -static void -cleanup_executing_breakpoints (void *ignore) -{ - executing_breakpoint_commands = 0; -} - /* Return non-zero iff CMD as the first line of a command sequence is `silent' or its equivalent. */ @@ -4674,7 +4471,6 @@ static int bpstat_do_actions_1 (bpstat *bsp) { bpstat bs; - struct cleanup *old_chain; int again = 0; /* Avoid endless recursion if a `source' command is contained @@ -4682,8 +4478,8 @@ bpstat_do_actions_1 (bpstat *bsp) if (executing_breakpoint_commands) return 0; - executing_breakpoint_commands = 1; - old_chain = make_cleanup (cleanup_executing_breakpoints, 0); + scoped_restore save_executing + = make_scoped_restore (&executing_breakpoint_commands, 1); scoped_restore preventer = prevent_dont_repeat (); @@ -4693,9 +4489,7 @@ bpstat_do_actions_1 (bpstat *bsp) breakpoint_proceeded = 0; for (; bs != NULL; bs = bs->next) { - struct counted_command_line *ccmd; - struct command_line *cmd; - struct cleanup *this_cmd_tree_chain; + struct command_line *cmd = NULL; /* Take ownership of the BSP's command tree, if it has one. @@ -4707,10 +4501,10 @@ bpstat_do_actions_1 (bpstat *bsp) commands are only executed once, we don't need to copy it; we can clear the pointer in the bpstat, and make sure we free the tree when we're done. */ - ccmd = bs->commands; + counted_command_line ccmd = bs->commands; bs->commands = NULL; - this_cmd_tree_chain = make_cleanup_decref_counted_command_line (&ccmd); - cmd = ccmd ? ccmd->commands : NULL; + if (ccmd != NULL) + cmd = ccmd.get (); if (command_line_is_silent (cmd)) { /* The action has been already done by bpstat_stop_status. */ @@ -4727,9 +4521,6 @@ bpstat_do_actions_1 (bpstat *bsp) cmd = cmd->next; } - /* We can free this command tree now. */ - do_cleanups (this_cmd_tree_chain); - if (breakpoint_proceeded) { if (current_ui->async) @@ -4755,7 +4546,6 @@ bpstat_do_actions_1 (bpstat *bsp) break; } } - do_cleanups (old_chain); return again; } @@ -4983,42 +4773,45 @@ bpstat_print (bpstat bs, int kind) return PRINT_UNKNOWN; } -/* Evaluate the expression EXP and return 1 if value is zero. - This returns the inverse of the condition because it is called - from catch_errors which returns 0 if an exception happened, and if an - exception happens we want execution to stop. - The argument is a "struct expression *" that has been cast to a - "void *" to make it pass through catch_errors. */ +/* Evaluate the boolean expression EXP and return the result. */ -static int -breakpoint_cond_eval (void *exp) +static bool +breakpoint_cond_eval (expression *exp) { struct value *mark = value_mark (); - int i = !value_true (evaluate_expression ((struct expression *) exp)); + bool res = value_true (evaluate_expression (exp)); value_free_to_mark (mark); - return i; + return res; } /* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */ -static bpstat -bpstat_alloc (struct bp_location *bl, bpstat **bs_link_pointer) +bpstats::bpstats (struct bp_location *bl, bpstat **bs_link_pointer) + : next (NULL), + bp_location_at (bl), + breakpoint_at (bl->owner), + commands (NULL), + old_val (NULL), + print (0), + stop (0), + print_it (print_it_normal) { - bpstat bs; - - bs = (bpstat) xmalloc (sizeof (*bs)); - bs->next = NULL; - **bs_link_pointer = bs; - *bs_link_pointer = &bs->next; - bs->breakpoint_at = bl->owner; - bs->bp_location_at = bl; incref_bp_location (bl); - /* If the condition is false, etc., don't do the commands. */ - bs->commands = NULL; - bs->old_val = NULL; - bs->print_it = print_it_normal; - return bs; + **bs_link_pointer = this; + *bs_link_pointer = &next; +} + +bpstats::bpstats () + : next (NULL), + bp_location_at (NULL), + breakpoint_at (NULL), + commands (NULL), + old_val (NULL), + print (0), + stop (0), + print_it (print_it_normal) +{ } /* The target has stopped with waitstatus WS. Check if any hardware @@ -5099,30 +4892,31 @@ watchpoints_triggered (struct target_waitstatus *ws) return 1; } -/* Possible return values for watchpoint_check (this can't be an enum - because of check_errors). */ -/* The watchpoint has been deleted. */ -#define WP_DELETED 1 -/* The value has changed. */ -#define WP_VALUE_CHANGED 2 -/* The value has not changed. */ -#define WP_VALUE_NOT_CHANGED 3 -/* Ignore this watchpoint, no matter if the value changed or not. */ -#define WP_IGNORE 4 +/* Possible return values for watchpoint_check. */ +enum wp_check_result + { + /* The watchpoint has been deleted. */ + WP_DELETED = 1, + + /* The value has changed. */ + WP_VALUE_CHANGED = 2, + + /* The value has not changed. */ + WP_VALUE_NOT_CHANGED = 3, + + /* Ignore this watchpoint, no matter if the value changed or not. */ + WP_IGNORE = 4, + }; #define BP_TEMPFLAG 1 #define BP_HARDWAREFLAG 2 /* Evaluate watchpoint condition expression and check if its value - changed. - - P should be a pointer to struct bpstat, but is defined as a void * - in order for this function to be usable with catch_errors. */ + changed. */ -static int -watchpoint_check (void *p) +static wp_check_result +watchpoint_check (bpstat bs) { - bpstat bs = (bpstat) p; struct watchpoint *b; struct frame_info *fr; int within_current_scope; @@ -5257,7 +5051,7 @@ watchpoint_check (void *p) } /* Make sure the watchpoint's commands aren't executed. */ - decref_counted_command_line (&b->commands); + b->commands = NULL; watchpoint_del_at_next_stop (b); return WP_DELETED; @@ -5270,7 +5064,7 @@ watchpoint_check (void *p) static int bpstat_check_location (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { struct breakpoint *b = bl->owner; @@ -5318,13 +5112,29 @@ bpstat_check_watchpoint (bpstat bs) if (must_check_value) { - char *message - = xstrprintf ("Error evaluating expression for watchpoint %d\n", - b->number); - struct cleanup *cleanups = make_cleanup (xfree, message); - int e = catch_errors (watchpoint_check, bs, message, - RETURN_MASK_ALL); - do_cleanups (cleanups); + wp_check_result e; + + TRY + { + e = watchpoint_check (bs); + } + CATCH (ex, RETURN_MASK_ALL) + { + exception_fprintf (gdb_stderr, ex, + "Error evaluating expression " + "for watchpoint %d\n", + b->number); + + SWITCH_THRU_ALL_UIS () + { + printf_filtered (_("Watchpoint %d deleted.\n"), + b->number); + } + watchpoint_del_at_next_stop (b); + e = WP_DELETED; + } + END_CATCH + switch (e) { case WP_DELETED: @@ -5420,18 +5230,6 @@ bpstat_check_watchpoint (bpstat bs) break; default: /* Can't happen. */ - case 0: - /* Error from catch_errors. */ - { - SWITCH_THRU_ALL_UIS () - { - printf_filtered (_("Watchpoint %d deleted.\n"), - b->number); - } - watchpoint_del_at_next_stop (b); - /* We've already printed what needs to be printed. */ - bs->print_it = print_it_done; - } break; } } @@ -5457,7 +5255,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) { const struct bp_location *bl; struct breakpoint *b; - int value_is_zero = 0; + /* Assume stop. */ + bool condition_result = true; struct expression *cond; gdb_assert (bs->stop); @@ -5553,23 +5352,30 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) within_current_scope = 0; } if (within_current_scope) - value_is_zero - = catch_errors (breakpoint_cond_eval, cond, - "Error in testing breakpoint condition:\n", - RETURN_MASK_ALL); + { + TRY + { + condition_result = breakpoint_cond_eval (cond); + } + CATCH (ex, RETURN_MASK_ALL) + { + exception_fprintf (gdb_stderr, ex, + "Error in testing breakpoint condition:\n"); + } + END_CATCH + } else { warning (_("Watchpoint condition cannot be tested " "in the current scope")); /* If we failed to set the right context for this watchpoint, unconditionally report it. */ - value_is_zero = 0; } /* FIXME-someday, should give breakpoint #. */ value_free_to_mark (mark); } - if (cond && value_is_zero) + if (cond && !condition_result) { bs->stop = 0; } @@ -5615,7 +5421,7 @@ need_moribund_for_location_type (struct bp_location *loc) commands, FIXME??? fields. */ bpstat -bpstat_stop_status (struct address_space *aspace, +bpstat_stop_status (const address_space *aspace, CORE_ADDR bp_addr, ptid_t ptid, const struct target_waitstatus *ws) { @@ -5661,7 +5467,7 @@ bpstat_stop_status (struct address_space *aspace, /* Come here if it's a watchpoint, or if the break address matches. */ - bs = bpstat_alloc (bl, &bs_link); /* Alloc a bpstat to + bs = new bpstats (bl, &bs_link); /* Alloc a bpstat to explain stop. */ /* Assume we stop. Should we find a watchpoint that is not @@ -5692,7 +5498,7 @@ bpstat_stop_status (struct address_space *aspace, if (breakpoint_location_address_match (loc, aspace, bp_addr) && need_moribund_for_location_type (loc)) { - bs = bpstat_alloc (loc, &bs_link); + bs = new bpstats (loc, &bs_link); /* For hits of moribund locations, we should just proceed. */ bs->stop = 0; bs->print = 0; @@ -5747,9 +5553,8 @@ bpstat_stop_status (struct address_space *aspace, if (b->silent) bs->print = 0; bs->commands = b->commands; - incref_counted_command_line (bs->commands); if (command_line_is_silent (bs->commands - ? bs->commands->commands : NULL)) + ? bs->commands.get () : NULL)) bs->print = 0; b->ops->after_condition_true (bs); @@ -5799,14 +5604,14 @@ handle_jit_event (void) /* Switch terminal for any messages produced by breakpoint_re_set. */ - target_terminal_ours_for_output (); + target_terminal::ours_for_output (); frame = get_current_frame (); gdbarch = get_frame_arch (frame); jit_event_handler (gdbarch); - target_terminal_inferior (); + target_terminal::inferior (); } /* Prepare WHAT final decision for infrun. */ @@ -6612,7 +6417,7 @@ print_one_breakpoint_location (struct breakpoint *b, } } - l = b->commands ? b->commands->commands : NULL; + l = b->commands ? b->commands.get () : NULL; if (!part_of_multiple && l) { annotate_field (9); @@ -6731,44 +6536,13 @@ breakpoint_address_bits (struct breakpoint *b) return print_address_bits; } -struct captured_breakpoint_query_args - { - int bnum; - }; +/* See breakpoint.h. */ -static int -do_captured_breakpoint_query (struct ui_out *uiout, void *data) +void +print_breakpoint (breakpoint *b) { - struct captured_breakpoint_query_args *args - = (struct captured_breakpoint_query_args *) data; - struct breakpoint *b; struct bp_location *dummy_loc = NULL; - - ALL_BREAKPOINTS (b) - { - if (args->bnum == b->number) - { - print_one_breakpoint (b, &dummy_loc, 0); - return GDB_RC_OK; - } - } - return GDB_RC_NONE; -} - -enum gdb_rc -gdb_breakpoint_query (struct ui_out *uiout, int bnum, - char **error_message) -{ - struct captured_breakpoint_query_args args; - - args.bnum = bnum; - /* For the moment we don't trust print_one_breakpoint() to not throw - an error. */ - if (catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args, - error_message, RETURN_MASK_ALL) < 0) - return GDB_RC_FAIL; - else - return GDB_RC_OK; + print_one_breakpoint (b, &dummy_loc, 0); } /* Return true if this breakpoint was set by the user, false if it is @@ -6796,7 +6570,7 @@ pending_breakpoint_p (struct breakpoint *b) breakpoints listed. */ static int -breakpoint_1 (char *args, int allflag, +breakpoint_1 (const char *args, int allflag, int (*filter) (const struct breakpoint *)) { struct breakpoint *b; @@ -6981,7 +6755,7 @@ info_watchpoints_command (char *args, int from_tty) } static void -maintenance_info_breakpoints (char *args, int from_tty) +maintenance_info_breakpoints (const char *args, int from_tty) { breakpoint_1 (args, 1, NULL); @@ -7120,8 +6894,8 @@ watchpoint_locations_match (struct bp_location *loc1, /* See breakpoint.h. */ int -breakpoint_address_match (struct address_space *aspace1, CORE_ADDR addr1, - struct address_space *aspace2, CORE_ADDR addr2) +breakpoint_address_match (const address_space *aspace1, CORE_ADDR addr1, + const address_space *aspace2, CORE_ADDR addr2) { return ((gdbarch_has_global_breakpoints (target_gdbarch ()) || aspace1 == aspace2) @@ -7134,8 +6908,9 @@ breakpoint_address_match (struct address_space *aspace1, CORE_ADDR addr1, space doesn't really matter. */ static int -breakpoint_address_match_range (struct address_space *aspace1, CORE_ADDR addr1, - int len1, struct address_space *aspace2, +breakpoint_address_match_range (const address_space *aspace1, + CORE_ADDR addr1, + int len1, const address_space *aspace2, CORE_ADDR addr2) { return ((gdbarch_has_global_breakpoints (target_gdbarch ()) @@ -7150,7 +6925,7 @@ breakpoint_address_match_range (struct address_space *aspace1, CORE_ADDR addr1, static int breakpoint_location_address_match (struct bp_location *bl, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR addr) { return (breakpoint_address_match (bl->pspace->aspace, bl->address, @@ -7169,7 +6944,7 @@ breakpoint_location_address_match (struct bp_location *bl, static int breakpoint_location_address_range_overlap (struct bp_location *bl, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR addr, int len) { if (gdbarch_has_global_breakpoints (target_gdbarch ()) @@ -7932,7 +7707,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) if (!disabled_shlib_breaks) { - target_terminal_ours_for_output (); + target_terminal::ours_for_output (); warning (_("Temporarily disabling breakpoints " "for unloaded shared library \"%s\""), solib->so_name); @@ -8052,7 +7827,7 @@ remove_catch_fork (struct bp_location *bl, enum remove_bp_reason reason) static int breakpoint_hit_catch_fork (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner; @@ -8168,7 +7943,7 @@ remove_catch_vfork (struct bp_location *bl, enum remove_bp_reason reason) static int breakpoint_hit_catch_vfork (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner; @@ -8296,7 +8071,7 @@ remove_catch_solib (struct bp_location *ignore, enum remove_bp_reason reason) static int breakpoint_hit_catch_solib (const struct bp_location *bl, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { @@ -8467,7 +8242,7 @@ add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled) if (!arg) arg = ""; - arg = skip_spaces_const (arg); + arg = skip_spaces (arg); std::unique_ptr c (new solib_catchpoint ()); @@ -8527,9 +8302,7 @@ init_catchpoint (struct breakpoint *b, const char *cond_string, const struct breakpoint_ops *ops) { - struct symtab_and_line sal; - - init_sal (&sal); + symtab_and_line sal; sal.pspace = current_program_space; init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops); @@ -8604,7 +8377,7 @@ remove_catch_exec (struct bp_location *bl, enum remove_bp_reason reason) static int breakpoint_hit_catch_exec (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { struct exec_catchpoint *c = (struct exec_catchpoint *) bl->owner; @@ -9003,8 +8776,6 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address) CORE_ADDR addr; const gdb_byte *bpoint; gdb_byte *target_mem; - struct cleanup *cleanup; - int retval = 0; addr = address; bpoint = gdbarch_breakpoint_from_pc (gdbarch, &addr, &len); @@ -9018,15 +8789,14 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address) /* Enable the automatic memory restoration from breakpoints while we read the memory. Otherwise we could say about our temporary breakpoints they are permanent. */ - cleanup = make_show_memory_breakpoints_cleanup (0); + scoped_restore restore_memory + = make_scoped_restore_show_memory_breakpoints (0); if (target_read_memory (address, target_mem, len) == 0 && memcmp (target_mem, bpoint, len) == 0) - retval = 1; - - do_cleanups (cleanup); + return 1; - return retval; + return 0; } /* Return 1 if LOC is pointing to a permanent breakpoint, @@ -9141,7 +8911,7 @@ update_dprintf_commands (char *args, int from_tty, static void init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, - struct symtabs_and_lines sals, + gdb::array_view sals, event_location_up &&location, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, @@ -9168,11 +8938,10 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, error (_("Hardware breakpoints used exceeds limit.")); } - gdb_assert (sals.nelts > 0); + gdb_assert (!sals.empty ()); - for (i = 0; i < sals.nelts; ++i) + for (const auto &sal : sals) { - struct symtab_and_line sal = sals.sals[i]; struct bp_location *loc; if (from_tty) @@ -9185,7 +8954,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, sal.pspace, sal.pc, sal.section, thread); } - if (i == 0) + if (&sal == &sals[0]) { init_raw_breakpoint (b, gdbarch, sal, type, ops); b->thread = thread; @@ -9214,9 +8983,9 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, const char *endp; char *marker_str; - p = skip_spaces_const (p); + p = skip_spaces (p); - endp = skip_to_space_const (p); + endp = skip_to_space (p); marker_str = savestring (p, endp - p); t->static_trace_marker_id = marker_str; @@ -9281,7 +9050,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, static void create_breakpoint_sal (struct gdbarch *gdbarch, - struct symtabs_and_lines sals, + gdb::array_view sals, event_location_up &&location, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, @@ -9333,13 +9102,10 @@ create_breakpoints_sal (struct gdbarch *gdbarch, const struct breakpoint_ops *ops, int from_tty, int enabled, int internal, unsigned flags) { - int i; - struct linespec_sals *lsal; - if (canonical->pre_expanded) - gdb_assert (VEC_length (linespec_sals, canonical->sals) == 1); + gdb_assert (canonical->lsals.size () == 1); - for (i = 0; VEC_iterate (linespec_sals, canonical->sals, i, lsal); ++i) + for (const auto &lsal : canonical->lsals) { /* Note that 'location' can be NULL in the case of a plain 'break', without arguments. */ @@ -9347,9 +9113,9 @@ create_breakpoints_sal (struct gdbarch *gdbarch, = (canonical->location != NULL ? copy_event_location (canonical->location.get ()) : NULL); gdb::unique_xmalloc_ptr filter_string - (lsal->canonical != NULL ? xstrdup (lsal->canonical) : NULL); + (lsal.canonical != NULL ? xstrdup (lsal.canonical) : NULL); - create_breakpoint_sal (gdbarch, lsal->sals, + create_breakpoint_sal (gdbarch, lsal.sals, std::move (location), std::move (filter_string), std::move (cond_string), @@ -9385,20 +9151,14 @@ parse_breakpoint_sals (const struct event_location *location, 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; + symtab_and_line sal = get_last_displayed_sal (); + CORE_ADDR pc = sal.pc; + sal = find_pc_line (pc, 0); /* "break" without arguments is equivalent to "break *PC" @@ -9409,11 +9169,11 @@ parse_breakpoint_sals (const struct event_location *location, sal.pc = pc; sal.explicit_pc = 1; - lsal.sals.sals[0] = sal; - lsal.sals.nelts = 1; + struct linespec_sals lsal; + lsal.sals = {sal}; lsal.canonical = NULL; - VEC_safe_push (linespec_sals, canonical->sals, &lsal); + canonical->lsals.push_back (std::move (lsal)); return; } else @@ -9458,12 +9218,10 @@ parse_breakpoint_sals (const struct event_location *location, inserted as a breakpoint. If it can't throw an error. */ static void -breakpoint_sals_to_pc (struct symtabs_and_lines *sals) +breakpoint_sals_to_pc (std::vector &sals) { - int i; - - for (i = 0; i < sals->nelts; i++) - resolve_sal_pc (&sals->sals[i]); + for (auto &sal : sals) + resolve_sal_pc (&sal); } /* Fast tracepoints may have restrictions on valid locations. For @@ -9475,30 +9233,27 @@ breakpoint_sals_to_pc (struct symtabs_and_lines *sals) static void check_fast_tracepoint_sals (struct gdbarch *gdbarch, - struct symtabs_and_lines *sals) + gdb::array_view sals) { - int i, rslt; - struct symtab_and_line *sal; + int rslt; char *msg; struct cleanup *old_chain; - for (i = 0; i < sals->nelts; i++) + for (const auto &sal : sals) { struct gdbarch *sarch; - sal = &sals->sals[i]; - - sarch = get_sal_arch (*sal); + sarch = get_sal_arch (sal); /* We fall back to GDBARCH if there is no architecture associated with SAL. */ if (sarch == NULL) sarch = gdbarch; - rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal->pc, &msg); + rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg); old_chain = make_cleanup (xfree, msg); if (!rslt) error (_("May not have a fast tracepoint at %s%s"), - paddress (sarch, sal->pc), (msg ? msg : "")); + paddress (sarch, sal.pc), (msg ? msg : "")); do_cleanups (old_chain); } @@ -9528,7 +9283,7 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, const char *cond_start = NULL; const char *cond_end = NULL; - tok = skip_spaces_const (tok); + tok = skip_spaces (tok); if ((*tok == '"' || *tok == ',') && rest) { @@ -9536,7 +9291,7 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, return; } - end_tok = skip_to_space_const (tok); + end_tok = skip_to_space (tok); toklen = end_tok - tok; @@ -9583,47 +9338,41 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, /* Decode a static tracepoint marker spec. */ -static struct symtabs_and_lines +static std::vector decode_static_tracepoint_spec (const char **arg_p) { VEC(static_tracepoint_marker_p) *markers = NULL; - struct symtabs_and_lines sals; - struct cleanup *old_chain; const char *p = &(*arg_p)[3]; const char *endp; - char *marker_str; int i; - p = skip_spaces_const (p); + p = skip_spaces (p); - endp = skip_to_space_const (p); + endp = skip_to_space (p); - marker_str = savestring (p, endp - p); - old_chain = make_cleanup (xfree, marker_str); + std::string marker_str (p, endp - p); - markers = target_static_tracepoint_markers_by_strid (marker_str); + markers = target_static_tracepoint_markers_by_strid (marker_str.c_str ()); if (VEC_empty(static_tracepoint_marker_p, markers)) - error (_("No known static tracepoint marker named %s"), marker_str); + error (_("No known static tracepoint marker named %s"), + marker_str.c_str ()); - sals.nelts = VEC_length(static_tracepoint_marker_p, markers); - sals.sals = XNEWVEC (struct symtab_and_line, sals.nelts); + std::vector sals; + sals.reserve (VEC_length(static_tracepoint_marker_p, markers)); - for (i = 0; i < sals.nelts; i++) + for (i = 0; i < VEC_length(static_tracepoint_marker_p, markers); i++) { struct static_tracepoint_marker *marker; marker = VEC_index (static_tracepoint_marker_p, markers, i); - init_sal (&sals.sals[i]); - - sals.sals[i] = find_pc_line (marker->address, 0); - sals.sals[i].pc = marker->address; + symtab_and_line sal = find_pc_line (marker->address, 0); + sal.pc = marker->address; + sals.push_back (sal); release_static_tracepoint_marker (marker); } - do_cleanups (old_chain); - *arg_p = endp; return sals; } @@ -9691,7 +9440,7 @@ create_breakpoint (struct gdbarch *gdbarch, } END_CATCH - if (!pending && VEC_empty (linespec_sals, canonical.sals)) + if (!pending && canonical.lsals.empty ()) return 0; /* ----------------------------- SNIP ----------------------------- @@ -9704,21 +9453,15 @@ create_breakpoint (struct gdbarch *gdbarch, are ok for the target. */ if (!pending) { - int ix; - struct linespec_sals *iter; - - for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix) - breakpoint_sals_to_pc (&iter->sals); + for (auto &lsal : canonical.lsals) + breakpoint_sals_to_pc (lsal.sals); } /* Fast tracepoints may have additional restrictions on location. */ if (!pending && type_wanted == bp_fast_tracepoint) { - int ix; - struct linespec_sals *iter; - - for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix) - check_fast_tracepoint_sals (gdbarch, &iter->sals); + for (const auto &lsal : canonical.lsals) + check_fast_tracepoint_sals (gdbarch, lsal.sals); } /* Verify that condition can be parsed, before setting any @@ -9733,16 +9476,15 @@ create_breakpoint (struct gdbarch *gdbarch, { char *rest; char *cond; - struct linespec_sals *lsal; - lsal = VEC_index (linespec_sals, canonical.sals, 0); + const linespec_sals &lsal = canonical.lsals[0]; /* Here we only parse 'arg' to separate condition from thread number, so parsing in context of first sal is OK. When setting the breakpoint we'll re-parse it in context of each sal. */ - find_condition_and_thread (extra_string, lsal->sals.sals[0].pc, + find_condition_and_thread (extra_string, lsal.sals[0].pc, &cond, &thread, &task, &rest); cond_string_copy.reset (cond); extra_string_copy.reset (rest); @@ -9798,7 +9540,7 @@ create_breakpoint (struct gdbarch *gdbarch, install_breakpoint (internal, std::move (b), 0); } - if (VEC_length (linespec_sals, canonical.sals) > 1) + if (canonical.lsals.size () > 1) { warning (_("Multiple breakpoints were set.\nUse the " "\"delete\" command to delete unwanted breakpoints.")); @@ -9823,7 +9565,7 @@ create_breakpoint (struct gdbarch *gdbarch, and BP_TEMPFLAG. */ static void -break_command_1 (char *arg, int flag, int from_tty) +break_command_1 (const char *arg, int flag, int from_tty) { int tempflag = flag & BP_TEMPFLAG; enum bptype type_wanted = (flag & BP_HARDWAREFLAG @@ -9941,7 +9683,7 @@ Usage: stop in \n\ } static void -stopin_command (char *arg, int from_tty) +stopin_command (const char *arg, int from_tty) { int badInput = 0; @@ -9949,7 +9691,7 @@ stopin_command (char *arg, int from_tty) badInput = 1; else if (*arg != '*') { - char *argptr = arg; + const char *argptr = arg; int hasColon = 0; /* Look for a ':'. If this is a line number specification, then @@ -9974,7 +9716,7 @@ stopin_command (char *arg, int from_tty) } static void -stopat_command (char *arg, int from_tty) +stopat_command (const char *arg, int from_tty) { int badInput = 0; @@ -9982,7 +9724,7 @@ stopat_command (char *arg, int from_tty) badInput = 1; else { - char *argptr = arg; + const char *argptr = arg; int hasColon = 0; /* Look for a ':'. If there is a '::' then get out, otherwise @@ -10011,8 +9753,9 @@ stopat_command (char *arg, int from_tty) line. */ static void -dprintf_command (char *arg, int from_tty) +dprintf_command (char *arg_in, int from_tty) { + const char *arg = arg_in; event_location_up location = string_to_event_location (&arg, current_language); /* If non-NULL, ARG should have been advanced past the location; @@ -10052,7 +9795,7 @@ agent_printf_command (char *arg, int from_tty) static int breakpoint_hit_ranged_breakpoint (const struct bp_location *bl, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { @@ -10226,16 +9969,14 @@ find_breakpoint_range_end (struct symtab_and_line sal) /* Implement the "break-range" CLI command. */ static void -break_range_command (char *arg, int from_tty) +break_range_command (char *arg_in, int from_tty) { - char *arg_start, *addr_string_start; + const char *arg = arg_in; + const char *arg_start; struct linespec_result canonical_start, canonical_end; int bp_count, can_use_bp, length; CORE_ADDR end; struct breakpoint *b; - struct symtab_and_line sal_start, sal_end; - struct cleanup *cleanup_bkpt; - struct linespec_sals *lsal_start, *lsal_end; /* We don't support software ranged breakpoints. */ if (target_ranged_break_num_registers () < 0) @@ -10259,18 +10000,17 @@ break_range_command (char *arg, int from_tty) if (arg[0] != ',') error (_("Too few arguments.")); - else if (VEC_empty (linespec_sals, canonical_start.sals)) + else if (canonical_start.lsals.empty ()) error (_("Could not find location of the beginning of the range.")); - lsal_start = VEC_index (linespec_sals, canonical_start.sals, 0); + const linespec_sals &lsal_start = canonical_start.lsals[0]; - if (VEC_length (linespec_sals, canonical_start.sals) > 1 - || lsal_start->sals.nelts != 1) + if (canonical_start.lsals.size () > 1 + || lsal_start.sals.size () != 1) error (_("Cannot create a ranged breakpoint with multiple locations.")); - sal_start = lsal_start->sals.sals[0]; - addr_string_start = savestring (arg_start, arg - arg_start); - cleanup_bkpt = make_cleanup (xfree, addr_string_start); + const symtab_and_line &sal_start = lsal_start.sals[0]; + std::string addr_string_start (arg_start, arg - arg_start); arg++; /* Skip the comma. */ arg = skip_spaces (arg); @@ -10290,15 +10030,15 @@ break_range_command (char *arg, int from_tty) sal_start.symtab, sal_start.line, &canonical_end, NULL, NULL); - if (VEC_empty (linespec_sals, canonical_end.sals)) + if (canonical_end.lsals.empty ()) error (_("Could not find location of the end of the range.")); - lsal_end = VEC_index (linespec_sals, canonical_end.sals, 0); - if (VEC_length (linespec_sals, canonical_end.sals) > 1 - || lsal_end->sals.nelts != 1) + const linespec_sals &lsal_end = canonical_end.lsals[0]; + if (canonical_end.lsals.size () > 1 + || lsal_end.sals.size () != 1) error (_("Cannot create a ranged breakpoint with multiple locations.")); - sal_end = lsal_end->sals.sals[0]; + const symtab_and_line &sal_end = lsal_end.sals[0]; end = find_breakpoint_range_end (sal_end); if (sal_start.pc > end) @@ -10312,9 +10052,7 @@ break_range_command (char *arg, int from_tty) { /* This range is simple enough to be handled by the `hbreak' command. */ - hbreak_command (addr_string_start, 1); - - do_cleanups (cleanup_bkpt); + hbreak_command (&addr_string_start[0], 1); return; } @@ -10329,8 +10067,6 @@ break_range_command (char *arg, int from_tty) b->location_range_end = std::move (end_location); b->loc->length = length; - do_cleanups (cleanup_bkpt); - mention (b); observer_notify_breakpoint_created (b); update_global_location_list (UGLL_MAY_INSERT); @@ -10386,8 +10122,7 @@ watchpoint_exp_is_const (const struct expression *exp) case TERNOP_SLICE: case OP_LONG: - case OP_DOUBLE: - case OP_DECFLOAT: + case OP_FLOAT: case OP_LAST: case OP_COMPLEX: case OP_STRING: @@ -10520,7 +10255,7 @@ remove_watchpoint (struct bp_location *bl, enum remove_bp_reason reason) static int breakpoint_hit_watchpoint (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { struct breakpoint *b = bl->owner; @@ -10572,7 +10307,6 @@ works_in_software_mode_watchpoint (const struct breakpoint *b) static enum print_stop_action print_it_watchpoint (bpstat bs) { - struct cleanup *old_chain; struct breakpoint *b; enum print_stop_action result; struct watchpoint *w; @@ -10583,13 +10317,12 @@ print_it_watchpoint (bpstat bs) b = bs->breakpoint_at; w = (struct watchpoint *) b; - old_chain = make_cleanup (null_cleanup, NULL); - annotate_watchpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); string_file stb; + gdb::optional tuple_emitter; switch (b->type) { case bp_watchpoint: @@ -10598,7 +10331,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, &stb); uiout->field_stream ("old", stb); @@ -10615,7 +10348,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nValue = "); watchpoint_value_print (w->val, &stb); uiout->field_stream ("value", stb); @@ -10631,7 +10364,7 @@ print_it_watchpoint (bpstat bs) ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); mention (b); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nOld value = "); watchpoint_value_print (bs->old_val, &stb); uiout->field_stream ("old", stb); @@ -10644,7 +10377,7 @@ print_it_watchpoint (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER)); - make_cleanup_ui_out_tuple_begin_end (uiout, "value"); + tuple_emitter.emplace (uiout, "value"); uiout->text ("\nValue = "); } watchpoint_value_print (w->val, &stb); @@ -10656,7 +10389,6 @@ print_it_watchpoint (bpstat bs) result = PRINT_UNKNOWN; } - do_cleanups (old_chain); return result; } @@ -10958,8 +10690,6 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, the hardware watchpoint. */ int use_mask = 0; CORE_ADDR mask = 0; - char *expression; - struct cleanup *back_to; /* Make sure that we actually have parameters to parse. */ if (arg != NULL && arg[0] != '\0') @@ -11048,9 +10778,8 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, is in terms of a newly allocated string instead of the original ARG. */ innermost_block = NULL; - expression = savestring (arg, exp_end - arg); - back_to = make_cleanup (xfree, expression); - exp_start = arg = expression; + std::string expression (arg, exp_end - arg); + exp_start = arg = expression.c_str (); expression_up exp = parse_exp_1 (&arg, 0, 0, 0); exp_end = arg; /* Remove trailing whitespace from the expression before saving it. @@ -11102,8 +10831,8 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, else if (val != NULL) release_value (val); - tok = skip_spaces_const (arg); - end_tok = skip_to_space_const (tok); + tok = skip_spaces (arg); + end_tok = skip_to_space (tok); toklen = end_tok - tok; if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) @@ -11250,7 +10979,6 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, update_watchpoint (w.get (), 1); install_breakpoint (internal, std::move (w), 1); - do_cleanups (back_to); } /* Return count of debug registers needed to watch the given expression. @@ -11338,7 +11066,7 @@ can_use_hardware_watchpoint (struct value *v) } void -watch_command_wrapper (char *arg, int from_tty, int internal) +watch_command_wrapper (const char *arg, int from_tty, int internal) { watch_command_1 (arg, hw_write, from_tty, 0, internal); } @@ -11369,7 +11097,7 @@ watch_command (char *arg, int from_tty) } void -rwatch_command_wrapper (char *arg, int from_tty, int internal) +rwatch_command_wrapper (const char *arg, int from_tty, int internal) { watch_command_1 (arg, hw_read, from_tty, 0, internal); } @@ -11381,7 +11109,7 @@ rwatch_command (char *arg, int from_tty) } void -awatch_command_wrapper (char *arg, int from_tty, int internal) +awatch_command_wrapper (const char *arg, int from_tty, int internal) { watch_command_1 (arg, hw_access, from_tty, 0, internal); } @@ -11502,10 +11230,8 @@ until_break_fsm_async_reply_reason (struct thread_fsm *self) } void -until_break_command (char *arg, int from_tty, int anywhere) +until_break_command (const char *arg, int from_tty, int anywhere) { - struct symtabs_and_lines sals; - struct symtab_and_line sal; struct frame_info *frame; struct gdbarch *frame_gdbarch; struct frame_id stack_frame_id; @@ -11524,19 +11250,18 @@ until_break_command (char *arg, int from_tty, int anywhere) event_location_up location = string_to_event_location (&arg, current_language); - if (last_displayed_sal_is_valid ()) - sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, - get_last_displayed_symtab (), - get_last_displayed_line ()); - else - sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, - NULL, (struct symtab *) NULL, 0); + std::vector sals + = (last_displayed_sal_is_valid () + ? decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, + get_last_displayed_symtab (), + get_last_displayed_line ()) + : decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, + NULL, (struct symtab *) NULL, 0)); - if (sals.nelts != 1) + if (sals.size () != 1) error (_("Couldn't get information on specified line.")); - sal = sals.sals[0]; - xfree (sals.sals); /* malloc'd, so freed. */ + symtab_and_line &sal = sals[0]; if (*arg) error (_("Junk at end of arguments.")); @@ -11624,7 +11349,7 @@ ep_parse_optional_if_clause (const char **arg) /* Skip any extra leading whitespace, and record the start of the condition string. */ - *arg = skip_spaces_const (*arg); + *arg = skip_spaces (*arg); cond_string = *arg; /* Assume that the condition occupies the remainder of the arg @@ -11660,7 +11385,7 @@ catch_fork_command_1 (char *arg_entry, int from_tty, if (!arg) arg = ""; - arg = skip_spaces_const (arg); + arg = skip_spaces (arg); /* The allowed syntax is: catch [v]fork @@ -11705,7 +11430,7 @@ catch_exec_command_1 (char *arg_entry, int from_tty, if (!arg) arg = ""; - arg = skip_spaces_const (arg); + arg = skip_spaces (arg); /* The allowed syntax is: catch exec @@ -11729,7 +11454,7 @@ void init_ada_exception_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch, struct symtab_and_line sal, - char *addr_string, + const char *addr_string, const struct breakpoint_ops *ops, int tempflag, int enabled, @@ -11763,31 +11488,29 @@ init_ada_exception_breakpoint (struct breakpoint *b, } static void -catch_command (char *arg, int from_tty) +catch_command (const char *arg, int from_tty) { error (_("Catch requires an event name.")); } static void -tcatch_command (char *arg, int from_tty) +tcatch_command (const char *arg, int from_tty) { error (_("Catch requires an event name.")); } -/* A qsort comparison function that sorts breakpoints in order. */ +/* Compare two breakpoints and return a strcmp-like result. */ static int -compare_breakpoints (const void *a, const void *b) +compare_breakpoints (const breakpoint *a, const breakpoint *b) { - const breakpoint_p *ba = (const breakpoint_p *) a; - uintptr_t ua = (uintptr_t) *ba; - const breakpoint_p *bb = (const breakpoint_p *) b; - uintptr_t ub = (uintptr_t) *bb; + uintptr_t ua = (uintptr_t) a; + uintptr_t ub = (uintptr_t) b; - if ((*ba)->number < (*bb)->number) + if (a->number < b->number) return -1; - else if ((*ba)->number > (*bb)->number) + else if (a->number > b->number) return 1; /* Now sort by address, in case we see, e..g, two breakpoints with @@ -11802,40 +11525,33 @@ compare_breakpoints (const void *a, const void *b) static void clear_command (char *arg, int from_tty) { - struct breakpoint *b, *prev; - VEC(breakpoint_p) *found = 0; - int ix; + struct breakpoint *b; int default_match; - struct symtabs_and_lines sals; - struct symtab_and_line sal; int i; - struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); + std::vector decoded_sals; + symtab_and_line last_sal; + gdb::array_view sals; if (arg) { - sals = decode_line_with_current_source (arg, - (DECODE_LINE_FUNFIRSTLINE - | DECODE_LINE_LIST_MODE)); - make_cleanup (xfree, sals.sals); + decoded_sals + = decode_line_with_current_source (arg, + (DECODE_LINE_FUNFIRSTLINE + | DECODE_LINE_LIST_MODE)); default_match = 0; + sals = decoded_sals; } else { - sals.sals = XNEW (struct symtab_and_line); - make_cleanup (xfree, sals.sals); - init_sal (&sal); /* Initialize to zeroes. */ - /* Set sal's line, symtab, pc, and pspace to the values corresponding to the last call to print_frame_info. If the codepoint is not valid, this will set all the fields to 0. */ - get_last_displayed_sal (&sal); - if (sal.symtab == 0) + last_sal = get_last_displayed_sal (); + if (last_sal.symtab == 0) error (_("No source file specified.")); - sals.sals[0] = sal; - sals.nelts = 1; - default_match = 1; + sals = last_sal; } /* We don't call resolve_sal_pc here. That's not as bad as it @@ -11860,9 +11576,8 @@ clear_command (char *arg, int from_tty) from_tty is forced true if we delete more than one breakpoint. */ - found = NULL; - make_cleanup (VEC_cleanup (breakpoint_p), &found); - for (i = 0; i < sals.nelts; i++) + std::vector found; + for (const auto &sal : sals) { const char *sal_fullname; @@ -11878,7 +11593,6 @@ clear_command (char *arg, int from_tty) 0 0 line 1 0 */ - sal = sals.sals[i]; sal_fullname = (sal.symtab == NULL ? NULL : symtab_to_fullname (sal.symtab)); @@ -11920,12 +11634,12 @@ clear_command (char *arg, int from_tty) } if (match) - VEC_safe_push(breakpoint_p, found, b); + found.push_back (b); } } /* Now go thru the 'found' chain and delete them. */ - if (VEC_empty(breakpoint_p, found)) + if (found.empty ()) { if (arg) error (_("No breakpoint at %s."), arg); @@ -11934,40 +11648,36 @@ clear_command (char *arg, int from_tty) } /* Remove duplicates from the vec. */ - qsort (VEC_address (breakpoint_p, found), - VEC_length (breakpoint_p, found), - sizeof (breakpoint_p), - compare_breakpoints); - prev = VEC_index (breakpoint_p, found, 0); - for (ix = 1; VEC_iterate (breakpoint_p, found, ix, b); ++ix) - { - if (b == prev) - { - VEC_ordered_remove (breakpoint_p, found, ix); - --ix; - } - } + std::sort (found.begin (), found.end (), + [] (const breakpoint *a, const breakpoint *b) + { + return compare_breakpoints (a, b) < 0; + }); + found.erase (std::unique (found.begin (), found.end (), + [] (const breakpoint *a, const breakpoint *b) + { + return compare_breakpoints (a, b) == 0; + }), + found.end ()); - if (VEC_length(breakpoint_p, found) > 1) + if (found.size () > 1) from_tty = 1; /* Always report if deleted more than one. */ if (from_tty) { - if (VEC_length(breakpoint_p, found) == 1) + if (found.size () == 1) printf_unfiltered (_("Deleted breakpoint ")); else printf_unfiltered (_("Deleted breakpoints ")); } - for (ix = 0; VEC_iterate(breakpoint_p, found, ix, b); ix++) + for (breakpoint *iter : found) { if (from_tty) - printf_unfiltered ("%d ", b->number); - delete_breakpoint (b); + printf_unfiltered ("%d ", iter->number); + delete_breakpoint (iter); } if (from_tty) putchar_unfiltered ('\n'); - - do_cleanups (cleanups); } /* Delete breakpoint in BS if they are `delete' breakpoints and @@ -12208,7 +11918,6 @@ update_global_location_list (enum ugll_insert_mode insert_mode) { struct breakpoint *b; struct bp_location **locp, *loc; - struct cleanup *cleanups; /* Last breakpoint location address that was marked for update. */ CORE_ADDR last_addr = 0; /* Last breakpoint location program space that was marked for update. */ @@ -12227,14 +11936,13 @@ update_global_location_list (enum ugll_insert_mode insert_mode) /* Saved former bp_locations array which we compare against the newly built bp_locations from the current state of ALL_BREAKPOINTS. */ - struct bp_location **old_locations, **old_locp; + struct bp_location **old_locp; unsigned old_locations_count; + gdb::unique_xmalloc_ptr old_locations (bp_locations); - old_locations = bp_locations; old_locations_count = bp_locations_count; bp_locations = NULL; bp_locations_count = 0; - cleanups = make_cleanup (xfree, old_locations); ALL_BREAKPOINTS (b) for (loc = b->loc; loc; loc = loc->next) @@ -12261,8 +11969,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) and former bp_location array state respectively. */ locp = bp_locations; - for (old_locp = old_locations; - old_locp < old_locations + old_locations_count; + for (old_locp = old_locations.get (); + old_locp < old_locations.get () + old_locations_count; old_locp++) { struct bp_location *old_loc = *old_locp; @@ -12545,8 +12253,6 @@ update_global_location_list (enum ugll_insert_mode insert_mode) if (insert_mode != UGLL_DONT_INSERT) download_tracepoint_locations (); - - do_cleanups (cleanups); } void @@ -12691,7 +12397,6 @@ static const struct bp_location_ops bp_location_ops = breakpoint::~breakpoint () { - decref_counted_command_line (&this->commands); xfree (this->cond_string); xfree (this->extra_string); xfree (this->filter); @@ -12727,7 +12432,7 @@ base_breakpoint_remove_location (struct bp_location *bl, static int base_breakpoint_breakpoint_hit (const struct bp_location *bl, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { @@ -12808,11 +12513,10 @@ base_breakpoint_create_breakpoints_sal (struct gdbarch *gdbarch, internal_error_pure_virtual_called (); } -static void +static std::vector base_breakpoint_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { internal_error_pure_virtual_called (); } @@ -12896,7 +12600,7 @@ bkpt_remove_location (struct bp_location *bl, enum remove_bp_reason reason) static int bkpt_breakpoint_hit (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { if (ws->kind != TARGET_WAITKIND_STOPPED @@ -12917,7 +12621,7 @@ bkpt_breakpoint_hit (const struct bp_location *bl, static int dprintf_breakpoint_hit (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { if (dprintf_style == dprintf_style_agent @@ -13063,13 +12767,12 @@ bkpt_create_breakpoints_sal (struct gdbarch *gdbarch, enabled, internal, flags); } -static void +static std::vector bkpt_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { - decode_location_default (b, location, search_pspace, sals); + return decode_location_default (b, location, search_pspace); } /* Virtual table for internal breakpoints. */ @@ -13254,18 +12957,18 @@ bkpt_probe_create_sals_from_location (const struct event_location *location, lsal.sals = parse_probes (location, NULL, canonical); lsal.canonical = xstrdup (event_location_to_string (canonical->location.get ())); - VEC_safe_push (linespec_sals, canonical->sals, &lsal); + canonical->lsals.push_back (std::move (lsal)); } -static void +static std::vector bkpt_probe_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { - *sals = parse_probes (location, search_pspace, NULL); - if (!sals->sals) + std::vector sals = parse_probes (location, search_pspace, NULL); + if (sals.empty ()) error (_("probe not found")); + return sals; } /* The breakpoint_ops structure to be used in tracepoints. */ @@ -13278,7 +12981,7 @@ tracepoint_re_set (struct breakpoint *b) static int tracepoint_breakpoint_hit (const struct bp_location *bl, - struct address_space *aspace, CORE_ADDR bp_addr, + const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { /* By definition, the inferior does not report stops at @@ -13383,13 +13086,12 @@ tracepoint_create_breakpoints_sal (struct gdbarch *gdbarch, enabled, internal, flags); } -static void +static std::vector tracepoint_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { - decode_location_default (b, location, search_pspace, sals); + return decode_location_default (b, location, search_pspace); } struct breakpoint_ops tracepoint_breakpoint_ops; @@ -13407,14 +13109,13 @@ tracepoint_probe_create_sals_from_location bkpt_probe_create_sals_from_location (location, canonical, type_wanted); } -static void +static std::vector tracepoint_probe_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { /* We use the same method for breakpoint on probes. */ - bkpt_probe_decode_location (b, location, search_pspace, sals); + return bkpt_probe_decode_location (b, location, search_pspace); } static struct breakpoint_ops tracepoint_probe_breakpoint_ops; @@ -13466,8 +13167,7 @@ dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp) static void dprintf_after_condition_true (struct bpstats *bs) { - struct cleanup *old_chain; - struct bpstats tmp_bs = { NULL }; + struct bpstats tmp_bs; struct bpstats *tmp_bs_p = &tmp_bs; /* dprintf's never cause a stop. This wasn't set in the @@ -13482,14 +13182,12 @@ dprintf_after_condition_true (struct bpstats *bs) commands here throws. */ tmp_bs.commands = bs->commands; bs->commands = NULL; - old_chain = make_cleanup_decref_counted_command_line (&tmp_bs.commands); bpstat_do_actions_1 (&tmp_bs_p); /* 'tmp_bs.commands' will usually be NULL by now, but bpstat_do_actions_1 may return early without processing the whole list. */ - do_cleanups (old_chain); } /* The breakpoint_ops structure to be used on static tracepoints with @@ -13502,20 +13200,17 @@ strace_marker_create_sals_from_location (const struct event_location *location, { struct linespec_sals lsal; const char *arg_start, *arg; - char *str; - struct cleanup *cleanup; arg = arg_start = get_linespec_location (location); lsal.sals = decode_static_tracepoint_spec (&arg); - str = savestring (arg_start, arg - arg_start); - cleanup = make_cleanup (xfree, str); - canonical->location = new_linespec_location (&str); - do_cleanups (cleanup); + std::string str (arg_start, arg - arg_start); + const char *ptr = str.c_str (); + canonical->location = new_linespec_location (&ptr); lsal.canonical = xstrdup (event_location_to_string (canonical->location.get ())); - VEC_safe_push (linespec_sals, canonical->sals, &lsal); + canonical->lsals.push_back (std::move (lsal)); } static void @@ -13531,9 +13226,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, int from_tty, int enabled, int internal, unsigned flags) { - int i; - struct linespec_sals *lsal = VEC_index (linespec_sals, - canonical->sals, 0); + const linespec_sals &lsal = canonical->lsals[0]; /* If the user is creating a static tracepoint by marker id (strace -m MARKER_ID), then store the sals index, so that @@ -13542,18 +13235,13 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, expand multiple locations for each sal, given than SALS already should contain all sals for MARKER_ID. */ - for (i = 0; i < lsal->sals.nelts; ++i) + for (size_t i = 0; i < lsal.sals.size (); i++) { - struct symtabs_and_lines expanded; - event_location_up location; - - expanded.nelts = 1; - expanded.sals = &lsal->sals.sals[i]; - - location = copy_event_location (canonical->location.get ()); + event_location_up location + = copy_event_location (canonical->location.get ()); std::unique_ptr tp (new tracepoint ()); - init_breakpoint_sal (tp.get (), gdbarch, expanded, + init_breakpoint_sal (tp.get (), gdbarch, lsal.sals[i], std::move (location), NULL, std::move (cond_string), std::move (extra_string), @@ -13573,20 +13261,20 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, } } -static void +static std::vector strace_marker_decode_location (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { struct tracepoint *tp = (struct tracepoint *) b; const char *s = get_linespec_location (location); - *sals = decode_static_tracepoint_spec (&s); - if (sals->nelts > tp->static_trace_marker_id_idx) + std::vector sals = decode_static_tracepoint_spec (&s); + if (sals.size () > tp->static_trace_marker_id_idx) { - sals->sals[0] = sals->sals[tp->static_trace_marker_id_idx]; - sals->nelts = 1; + sals[0] = sals[tp->static_trace_marker_id_idx]; + sals.resize (1); + return sals; } else error (_("marker %s not found"), tp->static_trace_marker_id); @@ -13712,9 +13400,7 @@ make_cleanup_delete_breakpoint (struct breakpoint *b) static void iterate_over_related_breakpoints (struct breakpoint *b, - void (*function) (struct breakpoint *, - void *), - void *data) + gdb::function_view function) { struct breakpoint *related; @@ -13729,7 +13415,7 @@ iterate_over_related_breakpoints (struct breakpoint *b, if (next == related) { /* RELATED is the last ring entry. */ - function (related, data); + function (related); /* FUNCTION may have deleted it, so we'd never reach back to B. There's nothing left to do anyway, so just break @@ -13737,7 +13423,7 @@ iterate_over_related_breakpoints (struct breakpoint *b, break; } else - function (related, data); + function (related); related = next; } @@ -13745,22 +13431,7 @@ iterate_over_related_breakpoints (struct breakpoint *b, } static void -do_delete_breakpoint (struct breakpoint *b, void *ignore) -{ - delete_breakpoint (b); -} - -/* A callback for map_breakpoint_numbers that calls - delete_breakpoint. */ - -static void -do_map_delete_breakpoint (struct breakpoint *b, void *ignore) -{ - iterate_over_related_breakpoints (b, do_delete_breakpoint, NULL); -} - -void -delete_command (char *arg, int from_tty) +delete_command (const char *arg, int from_tty) { struct breakpoint *b, *b_tmp; @@ -13790,7 +13461,11 @@ delete_command (char *arg, int from_tty) } } else - map_breakpoint_numbers (arg, do_map_delete_breakpoint, NULL); + map_breakpoint_numbers + (arg, [&] (breakpoint *b) + { + iterate_over_related_breakpoints (b, delete_breakpoint); + }); } /* Return true if all locations of B bound to PSPACE are pending. If @@ -13921,7 +13596,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) if (!VEC_empty(static_tracepoint_marker_p, markers)) { - struct symtab_and_line sal2; struct symbol *sym; struct static_tracepoint_marker *tpmarker; struct ui_out *uiout = current_uiout; @@ -13936,11 +13610,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) "found at previous line number"), b->number, tp->static_trace_marker_id); - init_sal (&sal2); - - sal2.pc = tpmarker->address; - - sal2 = find_pc_line (tpmarker->address, 0); + symtab_and_line sal2 = find_pc_line (tpmarker->address, 0); sym = find_pc_sect_function (tpmarker->address, NULL); uiout->text ("Now in "); if (sym) @@ -14056,13 +13726,13 @@ hoist_existing_locations (struct breakpoint *b, struct program_space *pspace) void update_breakpoint_locations (struct breakpoint *b, struct program_space *filter_pspace, - struct symtabs_and_lines sals, - struct symtabs_and_lines sals_end) + gdb::array_view sals, + gdb::array_view sals_end) { int i; struct bp_location *existing_locations; - if (sals_end.nelts != 0 && (sals.nelts != 1 || sals_end.nelts != 1)) + if (!sals_end.empty () && (sals.size () != 1 || sals_end.size () != 1)) { /* Ranged breakpoints have only one start location and one end location. */ @@ -14079,18 +13749,18 @@ update_breakpoint_locations (struct breakpoint *b, We'd like to retain the location, so that when the library is loaded again, we don't loose the enabled/disabled status of the individual locations. */ - if (all_locations_are_pending (b, filter_pspace) && sals.nelts == 0) + if (all_locations_are_pending (b, filter_pspace) && sals.empty ()) return; existing_locations = hoist_existing_locations (b, filter_pspace); - for (i = 0; i < sals.nelts; ++i) + for (const auto &sal : sals) { struct bp_location *new_loc; - switch_to_program_space_and_thread (sals.sals[i].pspace); + switch_to_program_space_and_thread (sal.pspace); - new_loc = add_location_to_breakpoint (b, &(sals.sals[i])); + new_loc = add_location_to_breakpoint (b, &sal); /* Reparse conditions, they might contain references to the old symtab. */ @@ -14101,8 +13771,8 @@ update_breakpoint_locations (struct breakpoint *b, s = b->cond_string; TRY { - new_loc->cond = parse_exp_1 (&s, sals.sals[i].pc, - block_for_pc (sals.sals[i].pc), + new_loc->cond = parse_exp_1 (&s, sal.pc, + block_for_pc (sal.pc), 0); } CATCH (e, RETURN_MASK_ERROR) @@ -14115,11 +13785,11 @@ update_breakpoint_locations (struct breakpoint *b, END_CATCH } - if (sals_end.nelts) + if (!sals_end.empty ()) { - CORE_ADDR end = find_breakpoint_range_end (sals_end.sals[0]); + CORE_ADDR end = find_breakpoint_range_end (sals_end[0]); - new_loc->length = end - sals.sals[0].pc + 1; + new_loc->length = end - sals[0].pc + 1; } } @@ -14169,18 +13839,19 @@ update_breakpoint_locations (struct breakpoint *b, /* 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 +static std::vector location_to_sals (struct breakpoint *b, struct event_location *location, struct program_space *search_pspace, int *found) { - struct symtabs_and_lines sals = {0}; struct gdb_exception exception = exception_none; gdb_assert (b->ops != NULL); + std::vector sals; + TRY { - b->ops->decode_location (b, location, search_pspace, &sals); + sals = b->ops->decode_location (b, location, search_pspace); } CATCH (e, RETURN_MASK_ERROR) { @@ -14221,16 +13892,14 @@ location_to_sals (struct breakpoint *b, struct event_location *location, if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR) { - int i; - - for (i = 0; i < sals.nelts; ++i) - resolve_sal_pc (&sals.sals[i]); + for (auto &sal : sals) + resolve_sal_pc (&sal); if (b->condition_not_parsed && b->extra_string != NULL) { char *cond_string, *extra_string; int thread, task; - find_condition_and_thread (b->extra_string, sals.sals[0].pc, + find_condition_and_thread (b->extra_string, sals[0].pc, &cond_string, &thread, &task, &extra_string); gdb_assert (b->cond_string == NULL); @@ -14247,7 +13916,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location, } if (b->type == bp_static_tracepoint && !strace_marker_p (b)) - sals.sals[0] = update_static_tracepoint (b, sals.sals[0]); + sals[0] = update_static_tracepoint (b, sals[0]); *found = 1; } @@ -14264,28 +13933,22 @@ location_to_sals (struct breakpoint *b, struct event_location *location, static void breakpoint_re_set_default (struct breakpoint *b) { - int found; - struct symtabs_and_lines sals, sals_end; - struct symtabs_and_lines expanded = {0}; - struct symtabs_and_lines expanded_end = {0}; struct program_space *filter_pspace = current_program_space; + std::vector expanded, expanded_end; - sals = location_to_sals (b, b->location.get (), filter_pspace, &found); + int found; + std::vector sals = location_to_sals (b, b->location.get (), + filter_pspace, &found); if (found) - { - make_cleanup (xfree, sals.sals); - expanded = sals; - } + expanded = std::move (sals); if (b->location_range_end != NULL) { - sals_end = location_to_sals (b, b->location_range_end.get (), - filter_pspace, &found); + std::vector sals_end + = location_to_sals (b, b->location_range_end.get (), + filter_pspace, &found); if (found) - { - make_cleanup (xfree, sals_end.sals); - expanded_end = sals_end; - } + expanded_end = std::move (sals_end); } update_breakpoint_locations (b, filter_pspace, expanded, expanded_end); @@ -14330,11 +13993,10 @@ create_breakpoints_sal_default (struct gdbarch *gdbarch, /* Decode the line represented by S by calling decode_line_full. This is the default function for the `decode_location' method of breakpoint_ops. */ -static void +static std::vector decode_location_default (struct breakpoint *b, const struct event_location *location, - struct program_space *search_pspace, - struct symtabs_and_lines *sals) + struct program_space *search_pspace) { struct linespec_result canonical; @@ -14344,46 +14006,25 @@ decode_location_default (struct breakpoint *b, b->filter); /* We should get 0 or 1 resulting SALs. */ - gdb_assert (VEC_length (linespec_sals, canonical.sals) < 2); + gdb_assert (canonical.lsals.size () < 2); - if (VEC_length (linespec_sals, canonical.sals) > 0) + if (!canonical.lsals.empty ()) { - struct linespec_sals *lsal; - - lsal = VEC_index (linespec_sals, canonical.sals, 0); - *sals = lsal->sals; - /* Arrange it so the destructor does not free the - contents. */ - lsal->sals.sals = NULL; + const linespec_sals &lsal = canonical.lsals[0]; + return std::move (lsal.sals); } + return {}; } -/* Prepare the global context for a re-set of breakpoint B. */ +/* Reset a breakpoint. */ -static struct cleanup * -prepare_re_set_context (struct breakpoint *b) +static void +breakpoint_re_set_one (breakpoint *b) { input_radix = b->input_radix; set_language (b->language); - return make_cleanup (null_cleanup, NULL); -} - -/* Reset a breakpoint given it's struct breakpoint * BINT. - The value we return ends up being the return value from catch_errors. - Unused in this case. */ - -static int -breakpoint_re_set_one (void *bint) -{ - /* Get past catch_errs. */ - struct breakpoint *b = (struct breakpoint *) bint; - struct cleanup *cleanups; - - cleanups = prepare_re_set_context (b); b->ops->re_set (b); - do_cleanups (cleanups); - return 0; } /* Re-set breakpoint locations for the current program space. @@ -14393,13 +14034,10 @@ void breakpoint_re_set (void) { struct breakpoint *b, *b_tmp; - enum language save_language; - int save_input_radix; - - save_language = current_language->la_language; - save_input_radix = input_radix; { + scoped_restore_current_language save_language; + scoped_restore save_input_radix = make_scoped_restore (&input_radix); scoped_restore_current_pspace_and_thread restore_pspace_thread; /* Note: we must not try to insert locations until after all @@ -14409,15 +14047,18 @@ breakpoint_re_set (void) ALL_BREAKPOINTS_SAFE (b, b_tmp) { - /* Format possible error msg. */ - char *message = xstrprintf ("Error in re-setting breakpoint %d: ", - b->number); - struct cleanup *cleanups = make_cleanup (xfree, message); - catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL); - do_cleanups (cleanups); + TRY + { + breakpoint_re_set_one (b); + } + CATCH (ex, RETURN_MASK_ALL) + { + exception_fprintf (gdb_stderr, ex, + "Error in re-setting breakpoint %d: ", + b->number); + } + END_CATCH } - set_language (save_language); - input_radix = save_input_radix; jit_breakpoint_re_set (); } @@ -14525,9 +14166,7 @@ ignore_command (char *args, int from_tty) static void map_breakpoint_numbers (const char *args, - void (*function) (struct breakpoint *, - void *), - void *data) + gdb::function_view function) { int num; struct breakpoint *b, *tmp; @@ -14553,7 +14192,7 @@ map_breakpoint_numbers (const char *args, if (b->number == num) { match = true; - function (b, data); + function (b); break; } if (!match) @@ -14563,20 +14202,17 @@ map_breakpoint_numbers (const char *args, } static struct bp_location * -find_location_by_number (char *number) +find_location_by_number (const char *number) { - char *dot = strchr (number, '.'); - char *p1; + const char *p1; int bp_num; int loc_num; struct breakpoint *b; struct bp_location *loc; - *dot = '\0'; - p1 = number; - bp_num = get_number (&p1); - if (bp_num == 0) + bp_num = get_number_trailer (&p1, '.'); + if (bp_num == 0 || p1[0] != '.') error (_("Bad breakpoint number '%s'"), number); ALL_BREAKPOINTS (b) @@ -14588,7 +14224,9 @@ find_location_by_number (char *number) if (!b || b->number != bp_num) error (_("Bad breakpoint number '%s'"), number); - p1 = dot+1; + /* Skip the dot. */ + ++p1; + const char *save = p1; loc_num = get_number (&p1); if (loc_num == 0) error (_("Bad breakpoint location number '%s'"), number); @@ -14598,7 +14236,7 @@ find_location_by_number (char *number) for (;loc_num && loc; --loc_num, loc = loc->next) ; if (!loc) - error (_("Bad breakpoint location number '%s'"), dot+1); + error (_("Bad breakpoint location number '%s'"), save); return loc; } @@ -14636,25 +14274,8 @@ disable_breakpoint (struct breakpoint *bpt) observer_notify_breakpoint_modified (bpt); } -/* A callback for iterate_over_related_breakpoints. */ - -static void -do_disable_breakpoint (struct breakpoint *b, void *ignore) -{ - disable_breakpoint (b); -} - -/* A callback for map_breakpoint_numbers that calls - disable_breakpoint. */ - static void -do_map_disable_breakpoint (struct breakpoint *b, void *ignore) -{ - iterate_over_related_breakpoints (b, do_disable_breakpoint, NULL); -} - -static void -disable_command (char *args, int from_tty) +disable_command (const char *args, int from_tty) { if (args == 0) { @@ -14666,13 +14287,13 @@ disable_command (char *args, int from_tty) } else { - char *num = extract_arg (&args); + std::string num = extract_arg (&args); - while (num) + while (!num.empty ()) { - if (strchr (num, '.')) + if (num.find ('.') != std::string::npos) { - struct bp_location *loc = find_location_by_number (num); + struct bp_location *loc = find_location_by_number (num.c_str ()); if (loc) { @@ -14689,7 +14310,11 @@ disable_command (char *args, int from_tty) update_global_location_list (UGLL_DONT_INSERT); } else - map_breakpoint_numbers (num, do_map_disable_breakpoint, NULL); + map_breakpoint_numbers + (num.c_str (), [&] (breakpoint *b) + { + iterate_over_related_breakpoints (b, disable_breakpoint); + }); num = extract_arg (&args); } } @@ -14765,27 +14390,12 @@ enable_breakpoint (struct breakpoint *bpt) enable_breakpoint_disp (bpt, bpt->disposition, 0); } -static void -do_enable_breakpoint (struct breakpoint *bpt, void *arg) -{ - enable_breakpoint (bpt); -} - -/* A callback for map_breakpoint_numbers that calls - enable_breakpoint. */ - -static void -do_map_enable_breakpoint (struct breakpoint *b, void *ignore) -{ - iterate_over_related_breakpoints (b, do_enable_breakpoint, NULL); -} - /* The enable command enables the specified breakpoints (or all defined breakpoints) so they once again become (or continue to be) effective in stopping the inferior. */ static void -enable_command (char *args, int from_tty) +enable_command (const char *args, int from_tty) { if (args == 0) { @@ -14797,13 +14407,13 @@ enable_command (char *args, int from_tty) } else { - char *num = extract_arg (&args); + std::string num = extract_arg (&args); - while (num) + while (!num.empty ()) { - if (strchr (num, '.')) + if (num.find ('.') != std::string::npos) { - struct bp_location *loc = find_location_by_number (num); + struct bp_location *loc = find_location_by_number (num.c_str ()); if (loc) { @@ -14820,53 +14430,32 @@ enable_command (char *args, int from_tty) update_global_location_list (UGLL_MAY_INSERT); } else - map_breakpoint_numbers (num, do_map_enable_breakpoint, NULL); + map_breakpoint_numbers + (num.c_str (), [&] (breakpoint *b) + { + iterate_over_related_breakpoints (b, enable_breakpoint); + }); num = extract_arg (&args); } } } -/* This struct packages up disposition data for application to multiple - breakpoints. */ - -struct disp_data -{ - enum bpdisp disp; - int count; -}; - -static void -do_enable_breakpoint_disp (struct breakpoint *bpt, void *arg) -{ - struct disp_data disp_data = *(struct disp_data *) arg; - - enable_breakpoint_disp (bpt, disp_data.disp, disp_data.count); -} - -static void -do_map_enable_once_breakpoint (struct breakpoint *bpt, void *ignore) -{ - struct disp_data disp = { disp_disable, 1 }; - - iterate_over_related_breakpoints (bpt, do_enable_breakpoint_disp, &disp); -} - -static void -enable_once_command (char *args, int from_tty) -{ - map_breakpoint_numbers (args, do_map_enable_once_breakpoint, NULL); -} - static void -do_map_enable_count_breakpoint (struct breakpoint *bpt, void *countptr) +enable_once_command (const char *args, int from_tty) { - struct disp_data disp = { disp_disable, *(int *) countptr }; - - iterate_over_related_breakpoints (bpt, do_enable_breakpoint_disp, &disp); + map_breakpoint_numbers + (args, [&] (breakpoint *b) + { + iterate_over_related_breakpoints + (b, [&] (breakpoint *bpt) + { + enable_breakpoint_disp (bpt, disp_disable, 1); + }); + }); } static void -enable_count_command (char *args, int from_tty) +enable_count_command (const char *args, int from_tty) { int count; @@ -14875,30 +14464,38 @@ enable_count_command (char *args, int from_tty) count = get_number (&args); - map_breakpoint_numbers (args, do_map_enable_count_breakpoint, &count); -} - -static void -do_map_enable_delete_breakpoint (struct breakpoint *bpt, void *ignore) -{ - struct disp_data disp = { disp_del, 1 }; - - iterate_over_related_breakpoints (bpt, do_enable_breakpoint_disp, &disp); + map_breakpoint_numbers + (args, [&] (breakpoint *b) + { + iterate_over_related_breakpoints + (b, [&] (breakpoint *bpt) + { + enable_breakpoint_disp (bpt, disp_disable, count); + }); + }); } static void -enable_delete_command (char *args, int from_tty) +enable_delete_command (const char *args, int from_tty) { - map_breakpoint_numbers (args, do_map_enable_delete_breakpoint, NULL); + map_breakpoint_numbers + (args, [&] (breakpoint *b) + { + iterate_over_related_breakpoints + (b, [&] (breakpoint *bpt) + { + enable_breakpoint_disp (bpt, disp_del, 1); + }); + }); } static void -set_breakpoint_cmd (char *args, int from_tty) +set_breakpoint_cmd (const char *args, int from_tty) { } static void -show_breakpoint_cmd (char *args, int from_tty) +show_breakpoint_cmd (const char *args, int from_tty) { } @@ -14940,7 +14537,7 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior, void insert_single_step_breakpoint (struct gdbarch *gdbarch, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR next_pc) { struct thread_info *tp = inferior_thread (); @@ -14990,7 +14587,7 @@ insert_single_step_breakpoints (struct gdbarch *gdbarch) int breakpoint_has_location_inserted_here (struct breakpoint *bp, - struct address_space *aspace, + const address_space *aspace, CORE_ADDR pc) { struct bp_location *loc; @@ -15007,7 +14604,7 @@ breakpoint_has_location_inserted_here (struct breakpoint *bp, PC. */ int -single_step_breakpoint_inserted_here_p (struct address_space *aspace, +single_step_breakpoint_inserted_here_p (const address_space *aspace, CORE_ADDR pc) { struct breakpoint *bpt; @@ -15032,8 +14629,9 @@ set_tracepoint_count (int num) } static void -trace_command (char *arg, int from_tty) +trace_command (char *arg_in, int from_tty) { + const char *arg = arg_in; struct breakpoint_ops *ops; event_location_up location = string_to_event_location (&arg, @@ -15058,8 +14656,9 @@ trace_command (char *arg, int from_tty) } static void -ftrace_command (char *arg, int from_tty) +ftrace_command (char *arg_in, int from_tty) { + const char *arg = arg_in; event_location_up location = string_to_event_location (&arg, current_language); create_breakpoint (get_current_arch (), @@ -15078,11 +14677,11 @@ ftrace_command (char *arg, int from_tty) /* strace command implementation. Creates a static tracepoint. */ static void -strace_command (char *arg, int from_tty) +strace_command (char *arg_in, int from_tty) { + const char *arg = arg_in; struct breakpoint_ops *ops; event_location_up location; - struct cleanup *back_to; /* Decide if we are dealing with a static tracepoint marker (`-m'), or with a normal static tracepoint. */ @@ -15137,7 +14736,8 @@ read_uploaded_action (void) struct tracepoint * create_tracepoint_from_upload (struct uploaded_tp *utp) { - char *addr_str, small_buf[100]; + const char *addr_str; + char small_buf[100]; struct tracepoint *tp; if (utp->at_string) @@ -15258,7 +14858,7 @@ disable_trace_command (char *args, int from_tty) /* Remove a tracepoint (or all if no argument). */ static void -delete_trace_command (char *arg, int from_tty) +delete_trace_command (const char *arg, int from_tty) { struct breakpoint *b, *b_tmp; @@ -15289,7 +14889,11 @@ delete_trace_command (char *arg, int from_tty) } } else - map_breakpoint_numbers (arg, do_map_delete_breakpoint, NULL); + map_breakpoint_numbers + (arg, [&] (breakpoint *b) + { + iterate_over_related_breakpoints (b, delete_breakpoint); + }); } /* Helper function for trace_pass_command. */ @@ -15448,7 +15052,7 @@ print_recreate_thread (struct breakpoint *b, struct ui_file *fp) non-zero. */ static void -save_breakpoints (char *filename, int from_tty, +save_breakpoints (const char *filename, int from_tty, int (*filter) (const struct breakpoint *)) { struct breakpoint *tp; @@ -15526,7 +15130,7 @@ save_breakpoints (char *filename, int from_tty, current_uiout->redirect (&fp); TRY { - print_command_lines (current_uiout, tp->commands->commands, 2); + print_command_lines (current_uiout, tp->commands.get (), 2); } CATCH (ex, RETURN_MASK_ALL) { @@ -15566,7 +15170,7 @@ save_breakpoints (char *filename, int from_tty, /* The `save breakpoints' command. */ static void -save_breakpoints_command (char *args, int from_tty) +save_breakpoints_command (const char *args, int from_tty) { save_breakpoints (args, from_tty, NULL); } @@ -15574,7 +15178,7 @@ save_breakpoints_command (char *args, int from_tty) /* The `save tracepoints' command. */ static void -save_tracepoints_command (char *args, int from_tty) +save_tracepoints_command (const char *args, int from_tty) { save_breakpoints (args, from_tty, is_tracepoint); } @@ -15656,13 +15260,13 @@ add_catch_command (const char *name, const char *docstring, { struct cmd_list_element *command; - command = add_cmd (name, class_breakpoint, NULL, docstring, + command = add_cmd (name, class_breakpoint, docstring, &catch_cmdlist); set_cmd_sfunc (command, sfunc); set_cmd_context (command, user_data_catch); set_cmd_completer (command, completer); - command = add_cmd (name, class_breakpoint, NULL, docstring, + command = add_cmd (name, class_breakpoint, docstring, &tcatch_cmdlist); set_cmd_sfunc (command, sfunc); set_cmd_context (command, user_data_tcatch); @@ -15670,7 +15274,7 @@ add_catch_command (const char *name, const char *docstring, } static void -save_command (char *arg, int from_tty) +save_command (const char *arg, int from_tty) { printf_unfiltered (_("\"save\" must be followed by " "the name of a save subcommand.\n")); @@ -15710,7 +15314,7 @@ is_non_inline_function (struct breakpoint *b) have been inlined. */ int -pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc, +pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc, const struct target_waitstatus *ws) { struct breakpoint *b;