#include "cli/cli-script.h"
#include "gdb_assert.h"
+#include "python/python.h"
+
/* Prototypes for local functions */
static enum command_control_type
/* Build and return a new command structure for the control commands
such as "if" and "while". */
-static struct command_line *
+struct command_line *
get_command_line (enum command_control_type type, char *arg)
{
struct command_line *cmd;
continue;
}
+ if (list->control_type == python_control)
+ {
+ ui_out_field_string (uiout, NULL, "python");
+ ui_out_text (uiout, "\n");
+ /* Don't indent python code at all. */
+ print_command_lines (uiout, *list->body_list, 0);
+ if (depth)
+ ui_out_spaces (uiout, 2 * depth);
+ ui_out_field_string (uiout, NULL, "end");
+ ui_out_text (uiout, "\n");
+ list = list->next;
+ continue;
+ }
+
/* ignore illegal command type and try next */
list = list->next;
} /* while (list) */
ret = commands_from_control_command (new_line, cmd);
break;
}
+ case python_control:
+ {
+ eval_python_from_control_command (cmd);
+ ret = simple_control;
+ break;
+ }
default:
warning (_("Invalid control type in canned commands structure."));
return ret;
}
+/* Like execute_control_command, but first set
+ suppress_next_print_command_trace. */
+
+enum command_control_type
+execute_control_command_untraced (struct command_line *cmd)
+{
+ suppress_next_print_command_trace = 1;
+ return execute_control_command (cmd);
+}
+
+
/* "while" command support. Executes a body of statements while the
loop condition is nonzero. */
if (command == NULL)
return;
- suppress_next_print_command_trace = 1;
- execute_control_command (command);
+ execute_control_command_untraced (command);
free_command_lines (&command);
}
if (command == NULL)
return;
- suppress_next_print_command_trace = 1;
- execute_control_command (command);
+ execute_control_command_untraced (command);
free_command_lines (&command);
}
first_arg++;
*command = build_command_line (commands_control, first_arg);
}
+ else if (p1 - p == 6 && !strncmp (p, "python", 6))
+ {
+ /* Note that we ignore the inline "python command" form
+ here. */
+ *command = build_command_line (python_control, "");
+ }
else if (p1 - p == 10 && !strncmp (p, "loop_break", 10))
{
*command = (struct command_line *)
{
if (current_cmd->control_type == while_control
|| current_cmd->control_type == if_control
+ || current_cmd->control_type == python_control
|| current_cmd->control_type == commands_control)
{
/* Success reading an entire canned sequence of commands. */
on it. */
if (next->control_type == while_control
|| next->control_type == if_control
+ || next->control_type == python_control
|| next->control_type == commands_control)
{
control_level++;
if (next->control_type == while_control
|| next->control_type == if_control
+ || next->control_type == python_control
|| next->control_type == commands_control)
{
control_level++;