aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-05 21:14:09 -0600
committerTom Tromey <tom@tromey.com>2017-04-12 11:16:17 -0600
commit93921405a46c0a58eae19fffb92e02416082801a (patch)
treec3a9c2a4407cb09bc571d5af47dce812a68169b0 /gdb/breakpoint.c
parentffc2605c41d026cf5710704848b7c3b1cdbdcf49 (diff)
downloadgdb-93921405a46c0a58eae19fffb92e02416082801a.zip
gdb-93921405a46c0a58eae19fffb92e02416082801a.tar.gz
gdb-93921405a46c0a58eae19fffb92e02416082801a.tar.bz2
Introduce command_line_up
This introduces command_line_up, a unique_ptr for command_line objects, and changes many places to use it. This removes a number of cleanups. Command lines are funny in that sometimes they are reference counted. Once there is more C++-ification of some of the users, perhaps all of these can be changed to use shared_ptr instead. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * tracepoint.c (actions_command): Update. * python/python.c (python_command, python_interactive_command): Update. * mi/mi-cmd-break.c (mi_cmd_break_commands): Update. * guile/guile.c (guile_command): Update. * defs.h (read_command_lines, read_command_lines_1): Return command_line_up. (command_lines_deleter): New struct. (command_line_up): New typedef. * compile/compile.c (compile_code_command) (compile_print_command): Update. * cli/cli-script.h (get_command_line, copy_command_lines): Return command_line_up. (make_cleanup_free_command_lines): Remove. * cli/cli-script.c (get_command_line, read_command_lines_1) (copy_command_lines): Return command_line_up. (while_command, if_command, read_command_lines, define_command) (document_command): Update. (do_free_command_lines_cleanup, make_cleanup_free_command_lines): Remove. * breakpoint.h (breakpoint_set_commands): Change type of "commands". * breakpoint.c (breakpoint_set_commands): Change type of "commands". Update. (do_map_commands_command, update_dprintf_command_list) (create_tracepoint_from_upload): Update.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9f7db91..3a3cd80 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1271,12 +1271,12 @@ static_tracepoints_here (CORE_ADDR addr)
void
breakpoint_set_commands (struct breakpoint *b,
- struct command_line *commands)
+ command_line_up &&commands)
{
- validate_commands_for_breakpoint (b, commands);
+ validate_commands_for_breakpoint (b, commands.get ());
decref_counted_command_line (&b->commands);
- b->commands = alloc_counted_command_line (commands);
+ b->commands = alloc_counted_command_line (commands.release ());
observer_notify_breakpoint_modified (b);
}
@@ -1358,7 +1358,7 @@ do_map_commands_command (struct breakpoint *b, void *data)
if (info->cmd == NULL)
{
- struct command_line *l;
+ command_line_up l;
if (info->control != NULL)
l = copy_command_lines (info->control->body_list[0]);
@@ -1382,7 +1382,7 @@ do_map_commands_command (struct breakpoint *b, void *data)
do_cleanups (old_chain);
}
- info->cmd = alloc_counted_command_line (l);
+ info->cmd = alloc_counted_command_line (l.release ());
}
/* If a breakpoint was on the list more than once, we don't need to
@@ -9191,7 +9191,7 @@ update_dprintf_command_list (struct breakpoint *b)
printf_cmd_line->next = NULL;
printf_cmd_line->line = printf_line;
- breakpoint_set_commands (b, printf_cmd_line);
+ breakpoint_set_commands (b, command_line_up (printf_cmd_line));
}
}
@@ -15356,14 +15356,14 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
function. */
if (!VEC_empty (char_ptr, utp->cmd_strings))
{
- struct command_line *cmd_list;
+ command_line_up cmd_list;
this_utp = utp;
next_cmd = 0;
cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL, NULL);
- breakpoint_set_commands (&tp->base, cmd_list);
+ breakpoint_set_commands (&tp->base, std::move (cmd_list));
}
else if (!VEC_empty (char_ptr, utp->actions)
|| !VEC_empty (char_ptr, utp->step_actions))