aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@br.ibm.com>2008-08-06 19:41:33 +0000
committerThiago Jung Bauermann <bauerman@br.ibm.com>2008-08-06 19:41:33 +0000
commitd57a3c85f6eee87b04852e98cce75af080969951 (patch)
tree6758be339bdf45930c2d61e4d447ce308bb82ec5 /gdb/cli
parent5141027dd033490b4866bea973206985b8a0cab4 (diff)
downloadfsf-binutils-gdb-d57a3c85f6eee87b04852e98cce75af080969951.zip
fsf-binutils-gdb-d57a3c85f6eee87b04852e98cce75af080969951.tar.gz
fsf-binutils-gdb-d57a3c85f6eee87b04852e98cce75af080969951.tar.bz2
Initial python support.
gdb/ 2008-08-06 Vladimir Prus <vladimir@codesourcery.com> Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> Doug Evans <dje@google.com> * Makefile.in (SUBDIR_PYTHON_OBS, SUBDIR_PYTHON_SRCS, SUBDIR_PYTHON_DEPS, SUBDIR_PYTHON_LDFLAGS, SUBDIR_PYTHON_CFLAGS, PYTHON_CFLAGS): New. (python_h, python_internal_h): New. (cli-script.o): Depend on python.h (python.o, python-utils.o): New. * cli/cli-script.c (print_command_lines): Handle python_control. (execute_control_command): Handle python_control. (execute_control_command_untraced): New function. (while_command): Call execute_control_command_untraced. (if_command): Likewise. (get_command_line): Remove static attribute. (read_next_line): Handle "python". (recurse_read_control_structure): Handle python_control. (read_command_lines): Handle python_control. Include python.h. * cli/cli-script.h (get_command_line): Add prototype. (execute_control_command_untraced): Likewise. * configure.ac: Add --with-python. * defs.h (enum command_control_type) <python_control>: New constant. * python/python-internal.h: New file. * python/python.c: New file. * python/python.h: New file. * python/python-utils.c: New file. * NEWS: Mention Python scripting support and its new commands. gdb/doc/ 2008-08-06 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Extending GDB): New chapter. (Sequences): Demoted chapter, now a section under the new Extending GDB chapter. (Python): New section. gdb/testsuite/ 2008-08-06 Tom Tromey <tromey@redhat.com> * gdb.python/python.exp: New file.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-script.c50
-rw-r--r--gdb/cli/cli-script.h6
2 files changed, 51 insertions, 5 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index e6fbe3f..5aafc75 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -34,6 +34,8 @@
#include "cli/cli-script.h"
#include "gdb_assert.h"
+#include "python/python.h"
+
/* Prototypes for local functions */
static enum command_control_type
@@ -102,7 +104,7 @@ build_command_line (enum command_control_type type, char *args)
/* 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;
@@ -225,6 +227,20 @@ print_command_lines (struct ui_out *uiout, 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) */
@@ -527,6 +543,12 @@ execute_control_command (struct command_line *cmd)
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."));
@@ -538,6 +560,17 @@ execute_control_command (struct command_line *cmd)
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. */
@@ -552,8 +585,7 @@ while_command (char *arg, int from_tty)
if (command == NULL)
return;
- suppress_next_print_command_trace = 1;
- execute_control_command (command);
+ execute_control_command_untraced (command);
free_command_lines (&command);
}
@@ -571,8 +603,7 @@ if_command (char *arg, int from_tty)
if (command == NULL)
return;
- suppress_next_print_command_trace = 1;
- execute_control_command (command);
+ execute_control_command_untraced (command);
free_command_lines (&command);
}
@@ -886,6 +917,12 @@ read_next_line (struct command_line **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 *)
@@ -962,6 +999,7 @@ recurse_read_control_structure (struct command_line *current_cmd)
{
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. */
@@ -1013,6 +1051,7 @@ recurse_read_control_structure (struct command_line *current_cmd)
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++;
@@ -1086,6 +1125,7 @@ read_command_lines (char *prompt_arg, int from_tty)
if (next->control_type == while_control
|| next->control_type == if_control
+ || next->control_type == python_control
|| next->control_type == commands_control)
{
control_level++;
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index 42663dd..50ec1e1 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -40,6 +40,12 @@ extern void show_user_1 (struct cmd_list_element *c, struct ui_file *stream);
extern enum command_control_type
execute_control_command (struct command_line *cmd);
+extern enum command_control_type
+ execute_control_command_untraced (struct command_line *cmd);
+
+extern struct command_line *get_command_line (enum command_control_type,
+ char *);
+
extern void print_command_lines (struct ui_out *,
struct command_line *, unsigned int);