This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[PATCH] get_breakpoint_commands
- To: Insight Maling List <insight at sources dot redhat dot com>
- Subject: [PATCH] get_breakpoint_commands
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Fri, 5 Oct 2001 18:42:34 -0700 (PDT)
Hi,
I've committed the following patch, which updates the gdb_breakpoint_info
command so that it can properly communicate command lists on breakpoints.
Keith
ChangeLog
2001-10-05 Keith Seitz <keiths@redhat.com>
* generic/gdbtk-bp.c (get_breakpoint_commands): New function.
(gdb_get_breakpoint_info): Use gdb_breakpoint_commands to
assemble breakpoint commands information.
Patch
Index: generic/gdbtk-bp.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-bp.c,v
retrieving revision 1.9
diff -u -p -r1.9 gdbtk-bp.c
--- gdbtk-bp.c 2001/08/03 03:37:40 1.9
+++ gdbtk-bp.c 2001/10/06 01:33:18
@@ -116,6 +116,8 @@ static int gdb_trace_status (ClientData,
Tcl_Obj * CONST[]);
static int gdb_tracepoint_exists_command (ClientData, Tcl_Interp *,
int, Tcl_Obj * CONST objv[]);
+static Tcl_Obj *get_breakpoint_commands (struct command_line *cmd);
+
static int tracepoint_exists (char *args);
/* Breakpoint/tracepoint events and related functions */
@@ -349,11 +351,8 @@ gdb_get_breakpoint_info (ClientData clie
Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
Tcl_NewIntObj (b->ignore_count));
- new_obj = Tcl_NewObj ();
- for (cmd = b->commands; cmd; cmd = cmd->next)
- Tcl_ListObjAppendElement (NULL, new_obj,
- Tcl_NewStringObj (cmd->line, -1));
- Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, new_obj);
+ Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
+ get_breakpoint_commands (b->commands));
Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr,
Tcl_NewStringObj (b->cond_string, -1));
@@ -371,6 +370,75 @@ gdb_get_breakpoint_info (ClientData clie
return TCL_OK;
}
+/* Helper function for gdb_get_breakpoint_info, this function is
+ responsible for figuring out what to type at the "commands" command
+ in gdb's cli in order to get at the same command list passed here.
+
+ NOTE: cannot use sprintf_append_element_to_obj with anything from
+ gdb, since those things could contain unescaped sequences. */
+static Tcl_Obj *
+get_breakpoint_commands (struct command_line *cmd)
+{
+ Tcl_Obj *obj, *tmp;
+
+ obj = Tcl_NewObj ();
+ while (cmd != NULL)
+ {
+ switch (cmd->control_type)
+ {
+ case simple_control:
+ /* A simple command. Just append it. */
+ Tcl_ListObjAppendElement (NULL, obj,
+ Tcl_NewStringObj (cmd->line, -1));
+ break;
+
+ case break_control:
+ /* A loop_break */
+ sprintf_append_element_to_obj (obj, "loop_break");
+ break;
+
+ case continue_control:
+ /* A loop_continue */
+ sprintf_append_element_to_obj (obj, "loop_continue");
+ break;
+
+ case while_control:
+ /* A while loop. Must append "end" to the end of it. */
+ tmp = Tcl_NewStringObj ("while ", -1);
+ Tcl_AppendToObj (tmp, cmd->line, -1);
+ Tcl_ListObjAppendElement (NULL, obj, tmp);
+ Tcl_ListObjAppendList (NULL, obj,
+ get_breakpoint_commands (*cmd->body_list));
+ sprintf_append_element_to_obj (obj, "end");
+ break;
+
+ case if_control:
+ /* An if statement. cmd->body_list[0] is the true part,
+ cmd->body_list[1] contains the "else" (false) part. */
+ tmp = Tcl_NewStringObj ("if ", -1);
+ Tcl_AppendToObj (tmp, cmd->line, -1);
+ Tcl_ListObjAppendElement (NULL, obj, tmp);
+ Tcl_ListObjAppendList (NULL, obj,
+ get_breakpoint_commands (cmd->body_list[0]));
+ if (cmd->body_count == 2)
+ {
+ sprintf_append_element_to_obj (obj, "else");
+ Tcl_ListObjAppendList (NULL, obj,
+ get_breakpoint_commands(cmd->body_list[1]));
+ }
+ sprintf_append_element_to_obj (obj, "end");
+ break;
+
+ case invalid_control:
+ /* Something invalid. Just skip it. */
+ break;
+ }
+
+ cmd = cmd->next;
+ }
+
+ return obj;
+}
/* This implements the tcl command gdb_get_breakpoint_list
* It builds up a list of the current breakpoints.