1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Naba Kumar 2005 <naba@gnome.org>
6 * gdbmi-test.c is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2, or (at your option) any later version.
12 * main.c is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with main.c. See the file "COPYING". If not,
19 * write to: The Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
32 static gchar
*gdb_test_line
=
33 "^done,BreakpointTable={nr_rows=\"2\",nr_cols=\"6\",hdr=[{width=\"3\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"10\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x08050f5d\",func=\"main\",file=\"main.c\",line=\"122\",times=\"1\"},bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x0096fbae\",func=\"anjuta_plugin_activate\",file=\"anjuta-plugin.c\",line=\"395\",times=\"1\"}]}";
37 output_callback (Debugger
*debugger
, DebuggerOutputType type
,
38 const gchar
*data
, gpointer user_data
)
44 output_parser (Debugger
* debugger
, const GDBMIValue
*mi_result
,
45 const GList
* cli_result
, gpointer data
, gpointer extra_data
)
47 gdbmi_value_dump (mi_result
, 0);
51 on_location_changed (Debugger
* debugger
, const gchar
*file
, gint line
,
52 gchar
*addr
, gpointer data
)
54 printf ("Location changed %s:%d\n", file
, line
);
58 on_program_running (Debugger
* debugger
, gpointer data
)
63 on_program_exited (Debugger
* debugger
, const GDBMIValue
*value
,
69 on_program_stopped (Debugger
* debugger
, const GDBMIValue
*value
,
75 on_entry_activate (GtkEntry
*entry
, Debugger
*debugger
)
77 debugger_command (debugger
, gtk_entry_get_text (entry
),
78 FALSE
, output_parser
, NULL
);
83 main(int argc
, char **argv
)
87 /* Debugger *debugger; */
88 /* GtkWidget *win, *entry; */
90 printf("Test GDB MI interface.\n");
92 val
= gdbmi_value_parse (ptr
);
95 printf ("GDB MI parse test successful:\n");
96 printf ("Data ==>\n");
97 gdbmi_value_dump (val
, 0);
101 printf ("GDB MI parse test failed\n");
103 printf ("Testing debugger\n");
104 gtk_init (&argc
, &argv
);
107 debugger
= debugger_new_with_program (NULL
, NULL
, output_callback
, NULL
,
108 "./gdbmi-test", TRUE
);
110 g_signal_connect (debugger
, "location-changed",
111 G_CALLBACK (on_location_changed
), NULL
);
112 g_signal_connect (debugger
, "program-running",
113 G_CALLBACK (on_program_running
), NULL
);
114 g_signal_connect (debugger
, "program-exited",
115 G_CALLBACK (on_program_exited
), NULL
);
116 g_signal_connect (debugger
, "program-stopped",
117 G_CALLBACK (on_program_stopped
), NULL
);
119 win
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
120 entry
= gtk_entry_new ();
121 gtk_container_add (GTK_CONTAINER (win
), entry
);
122 g_signal_connect (entry
, "activate",
123 G_CALLBACK (on_entry_activate
),
125 gtk_widget_show_all (win
);