diff options
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 162 |
1 files changed, 78 insertions, 84 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 053ccef..3dc9112 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1042,8 +1042,9 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, /* Completion for the "condition" command. */ -static VEC (char_ptr) * +static void condition_completer (struct cmd_list_element *cmd, + completion_tracker &tracker, const char *text, const char *word) { const char *space; @@ -1059,9 +1060,9 @@ condition_completer (struct cmd_list_element *cmd, if (text[0] == '$') { /* We don't support completion of history indices. */ - if (isdigit (text[1])) - return NULL; - return complete_internalvar (&text[1]); + if (!isdigit (text[1])) + complete_internalvar (tracker, &text[1]); + return; } /* We're completing the breakpoint number. */ @@ -1074,15 +1075,18 @@ condition_completer (struct cmd_list_element *cmd, xsnprintf (number, sizeof (number), "%d", b->number); if (strncmp (number, text, len) == 0) - VEC_safe_push (char_ptr, result, xstrdup (number)); + { + gdb::unique_xmalloc_ptr<char> copy (xstrdup (number)); + tracker.add_completion (std::move (copy)); + } } - return result; + return; } /* We're completing the expression part. */ text = skip_spaces_const (space); - return expression_completer (cmd, text, word); + expression_completer (cmd, tracker, text, word); } /* condition N EXP -- set break condition of breakpoint N to EXP. */ @@ -6804,7 +6808,6 @@ breakpoint_1 (char *args, int allflag, struct breakpoint *b; struct bp_location *last_loc = NULL; int nr_printable_breakpoints; - struct cleanup *bkpttbl_chain; struct value_print_options opts; int print_address_bits = 0; int print_type_col_width = 14; @@ -6847,77 +6850,71 @@ breakpoint_1 (char *args, int allflag, } } - if (opts.addressprint) - bkpttbl_chain - = make_cleanup_ui_out_table_begin_end (uiout, 6, - nr_printable_breakpoints, - "BreakpointTable"); - else - bkpttbl_chain - = make_cleanup_ui_out_table_begin_end (uiout, 5, - nr_printable_breakpoints, - "BreakpointTable"); - - if (nr_printable_breakpoints > 0) - annotate_breakpoints_headers (); - if (nr_printable_breakpoints > 0) - annotate_field (0); - uiout->table_header (7, ui_left, "number", "Num"); /* 1 */ - if (nr_printable_breakpoints > 0) - annotate_field (1); - uiout->table_header (print_type_col_width, ui_left, "type", "Type"); /* 2 */ - if (nr_printable_breakpoints > 0) - annotate_field (2); - uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */ - if (nr_printable_breakpoints > 0) - annotate_field (3); - uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */ - if (opts.addressprint) - { - if (nr_printable_breakpoints > 0) - annotate_field (4); - if (print_address_bits <= 32) - uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */ - else - uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */ - } - if (nr_printable_breakpoints > 0) - annotate_field (5); - uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */ - uiout->table_body (); - if (nr_printable_breakpoints > 0) - annotate_breakpoints_table (); - - ALL_BREAKPOINTS (b) - { - QUIT; - /* If we have a filter, only list the breakpoints it accepts. */ - if (filter && !filter (b)) - continue; - - /* If we have an "args" string, it is a list of breakpoints to - accept. Skip the others. */ + { + ui_out_emit_table table_emitter (uiout, + opts.addressprint ? 6 : 5, + nr_printable_breakpoints, + "BreakpointTable"); + + if (nr_printable_breakpoints > 0) + annotate_breakpoints_headers (); + if (nr_printable_breakpoints > 0) + annotate_field (0); + uiout->table_header (7, ui_left, "number", "Num"); /* 1 */ + if (nr_printable_breakpoints > 0) + annotate_field (1); + uiout->table_header (print_type_col_width, ui_left, "type", "Type"); /* 2 */ + if (nr_printable_breakpoints > 0) + annotate_field (2); + uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */ + if (nr_printable_breakpoints > 0) + annotate_field (3); + uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */ + if (opts.addressprint) + { + if (nr_printable_breakpoints > 0) + annotate_field (4); + if (print_address_bits <= 32) + uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */ + else + uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */ + } + if (nr_printable_breakpoints > 0) + annotate_field (5); + uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */ + uiout->table_body (); + if (nr_printable_breakpoints > 0) + annotate_breakpoints_table (); + + ALL_BREAKPOINTS (b) + { + QUIT; + /* If we have a filter, only list the breakpoints it accepts. */ + if (filter && !filter (b)) + continue; - if (args != NULL && *args != '\0') - { - if (allflag) /* maintenance info breakpoint */ - { - if (parse_and_eval_long (args) != b->number) - continue; - } - else /* all others */ - { - if (!number_is_in_list (args, b->number)) - continue; - } - } - /* We only print out user settable breakpoints unless the - allflag is set. */ - if (allflag || user_breakpoint_p (b)) - print_one_breakpoint (b, &last_loc, allflag); - } + /* If we have an "args" string, it is a list of breakpoints to + accept. Skip the others. */ - do_cleanups (bkpttbl_chain); + if (args != NULL && *args != '\0') + { + if (allflag) /* maintenance info breakpoint */ + { + if (parse_and_eval_long (args) != b->number) + continue; + } + else /* all others */ + { + if (!number_is_in_list (args, b->number)) + continue; + } + } + /* We only print out user settable breakpoints unless the + allflag is set. */ + if (allflag || user_breakpoint_p (b)) + print_one_breakpoint (b, &last_loc, allflag); + } + } if (nr_printable_breakpoints == 0) { @@ -15481,7 +15478,6 @@ save_breakpoints (char *filename, int from_tty, { struct breakpoint *tp; int any = 0; - struct cleanup *cleanup; int extra_trace_bits = 0; if (filename == 0 || *filename == 0) @@ -15515,14 +15511,13 @@ save_breakpoints (char *filename, int from_tty, return; } - filename = tilde_expand (filename); - cleanup = make_cleanup (xfree, filename); + gdb::unique_xmalloc_ptr<char> expanded_filename (tilde_expand (filename)); stdio_file fp; - if (!fp.open (filename, "w")) + if (!fp.open (expanded_filename.get (), "w")) error (_("Unable to open file '%s' for saving (%s)"), - filename, safe_strerror (errno)); + expanded_filename.get (), safe_strerror (errno)); if (extra_trace_bits) save_trace_state_variables (&fp); @@ -15590,8 +15585,7 @@ save_breakpoints (char *filename, int from_tty, fp.printf ("set default-collect %s\n", default_collect); if (from_tty) - printf_filtered (_("Saved to file '%s'.\n"), filename); - do_cleanups (cleanup); + printf_filtered (_("Saved to file '%s'.\n"), expanded_filename.get ()); } /* The `save breakpoints' command. */ |