aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-18 16:53:07 -0600
committerTom Tromey <tom@tromey.com>2018-05-04 15:58:08 -0600
commit60b3cef2e49ba72dea55181a8ad0cb8dbf3f8a5b (patch)
tree1fecc6fa000b666ff29bd42d66d80ff1901db6e5 /gdb/mi
parent7a2c85f25977ff9b11728ba85b1417538e22c246 (diff)
downloadgdb-60b3cef2e49ba72dea55181a8ad0cb8dbf3f8a5b.zip
gdb-60b3cef2e49ba72dea55181a8ad0cb8dbf3f8a5b.tar.gz
gdb-60b3cef2e49ba72dea55181a8ad0cb8dbf3f8a5b.tar.bz2
Use function_view in cli-script.c
This changes some functions in cli-script.c to use function_view rather than a function pointer and closure argument. This simplifies the code a bit and is useful in a subsequent patch. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * tracepoint.c (actions_command): Update. * mi/mi-cmd-break.c (mi_command_line_array) (mi_command_line_array_cnt, mi_command_line_array_ptr) (mi_read_next_line): Remove. (mi_cmd_break_commands): Update. * cli/cli-script.h (read_command_lines, read_command_lines_1): Use function_view. * cli/cli-script.c (get_command_line): Update. (process_next_line): Use function_view. Constify. (recurse_read_control_structure, read_command_lines) (read_command_lines_1): Change argument types to function_view. (do_define_command, document_command): Update. * breakpoint.h (check_tracepoint_command): Don't declare. * breakpoint.c (check_tracepoint_command): Remove. (commands_command_1, create_tracepoint_from_upload): Update.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-break.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 1772fad..8897117 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -32,6 +32,7 @@
#include "linespec.h"
#include "gdb_obstack.h"
#include <ctype.h>
+#include "tracepoint.h"
enum
{
@@ -468,24 +469,6 @@ mi_cmd_break_watch (const char *command, char **argv, int argc)
}
}
-/* The mi_read_next_line consults these variable to return successive
- command lines. While it would be clearer to use a closure pointer,
- it is not expected that any future code will use read_command_lines_1,
- therefore no point of overengineering. */
-
-static char **mi_command_line_array;
-static int mi_command_line_array_cnt;
-static int mi_command_line_array_ptr;
-
-static char *
-mi_read_next_line (void)
-{
- if (mi_command_line_array_ptr == mi_command_line_array_cnt)
- return NULL;
- else
- return mi_command_line_array[mi_command_line_array_ptr++];
-}
-
void
mi_cmd_break_commands (const char *command, char **argv, int argc)
{
@@ -509,15 +492,24 @@ mi_cmd_break_commands (const char *command, char **argv, int argc)
if (b == NULL)
error (_("breakpoint %d not found."), bnum);
- mi_command_line_array = argv;
- mi_command_line_array_ptr = 1;
- mi_command_line_array_cnt = argc;
+ int count = 1;
+ auto reader
+ = [&] ()
+ {
+ const char *result = nullptr;
+ if (count < argc)
+ result = argv[count++];
+ return result;
+ };
if (is_tracepoint (b))
- break_command = read_command_lines_1 (mi_read_next_line, 1,
- check_tracepoint_command, b);
+ break_command = read_command_lines_1 (reader, 1,
+ [=] (const char *line)
+ {
+ validate_actionline (line, b);
+ });
else
- break_command = read_command_lines_1 (mi_read_next_line, 1, 0, 0);
+ break_command = read_command_lines_1 (reader, 1, 0);
breakpoint_set_commands (b, std::move (break_command));
}