1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
3 * debugger.c Copyright (C) 2000 Kh. Naba Kumar Singh
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc., 59
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <sys/types.h>
39 #include <libanjuta/anjuta-launcher.h>
40 #include <libanjuta/anjuta-debug.h>
41 #include <libanjuta/anjuta-marshal.h>
42 #include <libanjuta/interfaces/ianjuta-debugger-breakpoint.h>
43 #include <libanjuta/interfaces/ianjuta-debugger-register.h>
44 #include <libanjuta/interfaces/ianjuta-debugger-memory.h>
45 #include <libanjuta/interfaces/ianjuta-debugger-instruction.h>
46 #include <libanjuta/interfaces/ianjuta-debugger-variable.h>
49 #include "utilities.h"
51 #define ANJUTA_LOG_ENV "ANJUTA_LOG"
52 #define DEBUGGER_LOG_LEVEL 1
54 #define GDB_PROMPT "(gdb)"
55 #define FILE_BUFFER_SIZE 1024
56 #define GDB_PATH "gdb"
57 #define SUMMARY_MAX_LENGTH 90 /* Should be smaller than 4K to be displayed
58 * in GtkCellRendererCell */
63 DEBUGGER_RERUN_PROGRAM
68 PROGRAM_LOADED_SIGNAL
,
69 PROGRAM_RUNNING_SIGNAL
,
70 PROGRAM_EXITED_SIGNAL
,
71 PROGRAM_STOPPED_SIGNAL
,
72 RESULTS_ARRIVED_SIGNAL
,
73 LOCATION_CHANGED_SIGNAL
,
74 BREAKPOINT_CHANGED_SIGNAL
,
75 VARIABLE_CHANGED_SIGNAL
,
81 GtkWindow
*parent_win
;
83 IAnjutaDebuggerOutputCallback output_callback
;
84 gpointer output_user_data
;
88 gboolean prog_is_running
;
89 gboolean prog_is_attached
;
90 gboolean prog_is_loaded
;
91 gboolean debugger_is_started
;
92 guint debugger_is_busy
;
93 gint post_execution_flag
;
95 AnjutaLauncher
*launcher
;
103 gboolean solib_event
;
107 gboolean terminating
;
110 /* GDB command queue */
112 DebuggerCommand current_cmd
;
113 gboolean skip_next_prompt
;
114 gboolean command_output_sent
;
122 IAnjutaMessageView
*log
;
126 static gpointer parent_class
;
128 static void debugger_queue_clear (Debugger
*debugger
);
129 static void debugger_queue_execute_command (Debugger
*debugger
);
131 static void gdb_stdout_line_arrived (Debugger
*debugger
, const gchar
* line
);
132 static void gdb_stderr_line_arrived (Debugger
*debugger
, const gchar
* line
);
133 static void debugger_stdo_flush (Debugger
*debugger
);
134 static void debugger_stde_flush (Debugger
*debugger
);
135 static void on_gdb_output_arrived (AnjutaLauncher
*launcher
,
136 AnjutaLauncherOutputType output_type
,
137 const gchar
*chars
, gpointer data
);
138 static void on_gdb_terminated (AnjutaLauncher
*launcher
,
139 gint child_pid
, gint status
,
140 gulong t
, gpointer data
);
142 static void debugger_class_init (DebuggerClass
*klass
);
143 static void debugger_instance_init (Debugger
*debugger
);
145 typedef struct _GdbGListPacket
152 *---------------------------------------------------------------------------*/
154 static gchar
* gdb_quote (const gchar
*unquoted_string
)
157 g_return_val_if_fail (unquoted_string
!= NULL
, NULL
);
160 p
= strpbrk (unquoted_string
, "\"\\");
163 /* No need to quote anything */
164 return g_strdup (unquoted_string
);
170 dest
= g_string_new_len (unquoted_string
, p
- unquoted_string
);
173 g_string_append_c (dest
, '\\');
175 p
= strpbrk (unquoted_string
+ 1, "\"\\");
178 g_string_append (dest
, unquoted_string
);
183 g_string_append_len (dest
, unquoted_string
, p
- unquoted_string
);
186 return g_string_free (dest
, FALSE
);
190 typedef struct _GdbMessageCode GdbMessageCode
;
192 struct _GdbMessageCode
198 const static GdbMessageCode GdbErrorMessage
[] =
199 {{"mi_cmd_var_create: unable to create variable object",
200 IANJUTA_DEBUGGER_UNABLE_TO_CREATE_VARIABLE
},
201 {"Cannot access memory at address ",
202 IANJUTA_DEBUGGER_UNABLE_TO_ACCESS_MEMORY
},
203 {"No source file named ",
204 IANJUTA_DEBUGGER_UNABLE_TO_OPEN_FILE
},
208 gdb_match_error(const gchar
*message
)
210 const GdbMessageCode
* msg
;
212 for (msg
= GdbErrorMessage
; msg
->msg
!= NULL
; msg
++)
214 gsize len
= strlen (msg
->msg
);
216 if (!isspace (msg
->msg
[len
- 1]))
218 /* Match the whole string */
222 if (memcmp (msg
->msg
, message
, len
) == 0)
228 return IANJUTA_DEBUGGER_UNKNOWN_ERROR
;
232 debugger_message_view_append (Debugger
*debugger
, IAnjutaMessageViewType type
, const char *message
)
234 guint len
= strlen(message
);
235 gchar buf
[SUMMARY_MAX_LENGTH
];
236 const gchar
* summary
= message
;
237 const gchar
* detail
= "";
240 if (len
> SUMMARY_MAX_LENGTH
)
243 memcpy(buf
, message
, SUMMARY_MAX_LENGTH
- 4);
244 memcpy(buf
+ SUMMARY_MAX_LENGTH
- 4, "...", 4);
249 ianjuta_message_view_append (debugger
->priv
->log
, type
, summary
, detail
, NULL
);
253 debugger_initialize (Debugger
*debugger
)
255 const gchar
* anjuta_log
;
257 DEBUG_PRINT ("In function: debugger_init()");
259 debugger
->priv
= g_new0 (DebuggerPriv
, 1);
261 debugger
->priv
->output_callback
= NULL
;
262 debugger
->priv
->parent_win
= NULL
;
263 debugger
->priv
->search_dirs
= NULL
;
264 debugger
->priv
->launcher
= anjuta_launcher_new ();
266 debugger
->priv
->debugger_is_started
= FALSE
;
267 debugger
->priv
->prog_is_running
= FALSE
;
268 debugger
->priv
->debugger_is_busy
= 0;
269 debugger
->priv
->starting
= FALSE
;
270 debugger
->priv
->terminating
= FALSE
;
271 debugger
->priv
->skip_next_prompt
= FALSE
;
272 debugger
->priv
->command_output_sent
= FALSE
;
274 debugger
->priv
->current_cmd
.cmd
= NULL
;
275 debugger
->priv
->current_cmd
.parser
= NULL
;
277 debugger
->priv
->cmd_queqe
= NULL
;
278 debugger
->priv
->cli_lines
= NULL
;
279 debugger
->priv
->solib_event
= FALSE
;
281 debugger
->priv
->stdo_line
= g_string_sized_new (FILE_BUFFER_SIZE
);
282 g_string_assign (debugger
->priv
->stdo_line
, "");
283 debugger
->priv
->stdo_acc
= g_string_new ("");
285 debugger
->priv
->stde_line
= g_string_sized_new (FILE_BUFFER_SIZE
);
286 g_string_assign (debugger
->priv
->stde_line
, "");
288 debugger
->priv
->post_execution_flag
= DEBUGGER_NONE
;
290 anjuta_log
= g_getenv (ANJUTA_LOG_ENV
);
291 debugger
->priv
->gdb_log
= anjuta_log
&& (atoi(anjuta_log
) > DEBUGGER_LOG_LEVEL
);
295 debugger_instance_init (Debugger
*debugger
)
297 debugger_initialize (debugger
);
301 debugger_new (GtkWindow
*parent_win
, GObject
* instance
)
305 debugger
= g_object_new (DEBUGGER_TYPE
, NULL
);
306 debugger
->priv
->parent_win
= parent_win
;
307 debugger
->priv
->instance
= instance
;
313 debugger_free (Debugger
*debugger
)
315 g_return_if_fail (IS_DEBUGGER (debugger
));
317 g_object_unref (debugger
);
321 debugger_is_ready (Debugger
*debugger
)
323 g_return_val_if_fail (IS_DEBUGGER (debugger
), FALSE
);
324 return !debugger
->priv
->debugger_is_busy
;
328 debugger_program_is_running (Debugger
*debugger
)
330 g_return_val_if_fail (IS_DEBUGGER (debugger
), FALSE
);
331 return debugger
->priv
->prog_is_running
;
335 debugger_program_is_attached (Debugger
*debugger
)
337 g_return_val_if_fail (IS_DEBUGGER (debugger
), FALSE
);
338 return debugger
->priv
->prog_is_attached
;
342 debugger_program_is_loaded (Debugger
*debugger
)
344 g_return_val_if_fail (IS_DEBUGGER (debugger
), FALSE
);
345 return debugger
->priv
->prog_is_loaded
;
349 debugger_log_command (Debugger
*debugger
, const gchar
*command
)
354 if (debugger
->priv
->log
== NULL
) return;
358 str
= g_strdup (command
);
359 len
= strlen (command
);
361 /* Remove trailing carriage return */
362 if (str
[len
- 1] == '\n') str
[len
- 1] = '\0';
364 /* Log only MI command as other are echo */
366 DEBUG_PRINT ("GDB:> %s", str
);
368 if (debugger
->priv
->gdb_log
) g_message ("GDB:> %s", str
);
370 debugger_message_view_append (debugger
, IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
, str
);
376 debugger_log_output (Debugger
*debugger
, const gchar
*line
)
380 IAnjutaMessageViewType type
;
383 if (debugger
->priv
->log
== NULL
) return;
385 type
= IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
;
389 type
= IANJUTA_MESSAGE_VIEW_TYPE_INFO
;
395 /* Remove double quote if necessary */
396 if ((line
[1] == '\"') && (line
[len
- 1] == '\"')) start
++;
397 str
= g_strcompress (line
+ 2);
399 if (start
== line
+ 2)
405 /* Remove trailing carriage return */
406 if (str
[len
- 1] == '\n') str
[len
- 1] = '\0';
408 debugger_message_view_append (debugger
, type
, str
);
412 if (strncmp(line
+ 1, "error", 5) == 0)
414 debugger_message_view_append (debugger
, IANJUTA_MESSAGE_VIEW_TYPE_ERROR
, line
+ 1);
418 debugger_message_view_append (debugger
, IANJUTA_MESSAGE_VIEW_TYPE_WARNING
, line
+ 1);
422 debugger_message_view_append (debugger
, IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
, line
+ 1);
425 debugger_message_view_append (debugger
, IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
, line
);
431 debugger_emit_ready (Debugger
*debugger
)
433 if (!debugger
->priv
->debugger_is_busy
)
435 if (debugger
->priv
->loading
)
437 debugger
->priv
->starting
= FALSE
;
438 debugger
->priv
->loading
= FALSE
;
439 debugger
->priv
->exiting
= FALSE
;
440 debugger
->priv
->stopping
= FALSE
;
441 debugger
->priv
->solib_event
= FALSE
;
442 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_PROGRAM_LOADED
);
444 else if (debugger
->priv
->starting
)
446 debugger
->priv
->starting
= FALSE
;
447 debugger
->priv
->loading
= FALSE
;
448 debugger
->priv
->exiting
= FALSE
;
449 debugger
->priv
->stopping
= FALSE
;
450 debugger
->priv
->solib_event
= FALSE
;
451 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_STARTED
);
453 else if (debugger
->priv
->exiting
)
455 debugger
->priv
->exiting
= FALSE
;
456 debugger
->priv
->stopping
= FALSE
;
457 debugger
->priv
->solib_event
= FALSE
;
458 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_PROGRAM_LOADED
);
460 else if (debugger
->priv
->solib_event
)
462 debugger
->priv
->exiting
= FALSE
;
463 debugger
->priv
->stopping
= FALSE
;
464 debugger
->priv
->solib_event
= FALSE
;
465 g_signal_emit_by_name (debugger
->priv
->instance
, "sharedlib-event");
467 else if (debugger
->priv
->stopping
)
469 debugger
->priv
->exiting
= FALSE
;
470 debugger
->priv
->stopping
= FALSE
;
471 debugger
->priv
->solib_event
= FALSE
;
472 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_PROGRAM_STOPPED
);
476 if (debugger
->priv
->prog_is_running
|| debugger
->priv
->prog_is_attached
)
478 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_PROGRAM_STOPPED
);
480 else if (debugger
->priv
->prog_is_loaded
)
482 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_PROGRAM_LOADED
);
486 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-ready", IANJUTA_DEBUGGER_STARTED
);
493 debugger_get_state (Debugger
*debugger
)
495 if (debugger
->priv
->debugger_is_busy
)
497 return IANJUTA_DEBUGGER_BUSY
;
501 if (debugger
->priv
->prog_is_running
|| debugger
->priv
->prog_is_attached
)
503 return IANJUTA_DEBUGGER_PROGRAM_STOPPED
;
505 else if (debugger
->priv
->prog_is_loaded
)
507 return IANJUTA_DEBUGGER_PROGRAM_LOADED
;
509 else if (debugger
->priv
->debugger_is_started
)
511 return IANJUTA_DEBUGGER_STARTED
;
515 return IANJUTA_DEBUGGER_STOPPED
;
521 debugger_clear_buffers (Debugger
*debugger
)
523 DEBUG_PRINT ("In function: debugger_clear_buffers()");
525 /* Clear the output line buffer */
526 g_string_assign (debugger
->priv
->stdo_line
, "");
527 if (!debugger
->priv
->current_cmd
.keep_result
)
528 g_string_assign (debugger
->priv
->stdo_acc
, "");
530 /* Clear the error line buffer */
531 g_string_assign (debugger
->priv
->stde_line
, "");
533 /* Clear CLI output lines */
534 g_list_foreach (debugger
->priv
->cli_lines
, (GFunc
)g_free
, NULL
);
535 g_list_free (debugger
->priv
->cli_lines
);
536 debugger
->priv
->cli_lines
= NULL
;
539 static DebuggerCommand
*
540 debugger_queue_get_next_command (Debugger
*debugger
)
544 DEBUG_PRINT ("In function: debugger_get_next_command()");
546 if (debugger
->priv
->cmd_queqe
)
548 dc
= g_list_nth_data (debugger
->priv
->cmd_queqe
, 0);
549 debugger
->priv
->cmd_queqe
= g_list_remove (debugger
->priv
->cmd_queqe
, dc
);
557 debugger_queue_set_next_command (Debugger
*debugger
)
561 DEBUG_PRINT ("In function: debugger_set_next_command()");
563 dc
= debugger_queue_get_next_command (debugger
);
566 debugger
->priv
->current_cmd
.cmd
= NULL
;
567 debugger
->priv
->current_cmd
.parser
= NULL
;
568 debugger
->priv
->current_cmd
.callback
= NULL
;
569 debugger
->priv
->current_cmd
.user_data
= NULL
;
570 debugger
->priv
->current_cmd
.suppress_error
= FALSE
;
571 debugger
->priv
->current_cmd
.keep_result
= FALSE
;
575 g_free (debugger
->priv
->current_cmd
.cmd
);
576 debugger
->priv
->current_cmd
.cmd
= dc
->cmd
;
577 debugger
->priv
->current_cmd
.parser
= dc
->parser
;
578 debugger
->priv
->current_cmd
.callback
= dc
->callback
;
579 debugger
->priv
->current_cmd
.user_data
= dc
->user_data
;
580 debugger
->priv
->current_cmd
.suppress_error
= dc
->suppress_error
;
581 debugger
->priv
->current_cmd
.keep_result
= dc
->keep_result
;
588 debugger_queue_command (Debugger
*debugger
, const gchar
*cmd
,
589 gboolean suppress_error
, gboolean keep_result
,
590 DebuggerParserFunc parser
,
591 IAnjutaDebuggerCallback callback
, gpointer user_data
)
596 DEBUG_PRINT ("In function: debugger_queue_command (%s)", cmd
);
598 dc
= g_malloc (sizeof (DebuggerCommand
));
601 dc
->cmd
= g_strdup(cmd
);
603 dc
->callback
= callback
;
604 dc
->user_data
= user_data
;
605 dc
->suppress_error
= suppress_error
;
606 dc
->keep_result
= keep_result
;
608 debugger
->priv
->cmd_queqe
= g_list_append (debugger
->priv
->cmd_queqe
, dc
);
609 debugger_queue_execute_command (debugger
);
613 debugger_queue_clear (Debugger
*debugger
)
617 DEBUG_PRINT ("In function: debugger_queue_clear()");
619 node
= debugger
->priv
->cmd_queqe
;
622 g_free (((DebuggerCommand
*)node
->data
)->cmd
);
624 node
= g_list_next (node
);
626 g_list_free (debugger
->priv
->cmd_queqe
);
627 debugger
->priv
->cmd_queqe
= NULL
;
628 g_free (debugger
->priv
->current_cmd
.cmd
);
629 debugger
->priv
->current_cmd
.cmd
= NULL
;
630 debugger
->priv
->current_cmd
.parser
= NULL
;
631 debugger
->priv
->current_cmd
.callback
= NULL
;
632 debugger
->priv
->current_cmd
.user_data
= NULL
;
633 debugger
->priv
->current_cmd
.suppress_error
= FALSE
;
634 debugger
->priv
->current_cmd
.keep_result
= FALSE
;
635 debugger_clear_buffers (debugger
);
639 debugger_execute_command (Debugger
*debugger
, const gchar
*command
)
643 DEBUG_PRINT ("In function: debugger_execute_command(%s) %d\n",command
, debugger
->priv
->debugger_is_busy
);
644 debugger
->priv
->debugger_is_busy
++;
645 debugger
->priv
->command_output_sent
= FALSE
;
646 cmd
= g_strconcat (command
, "\n", NULL
);
647 debugger_log_command (debugger
, cmd
);
648 anjuta_launcher_send_stdin (debugger
->priv
->launcher
, cmd
);
653 debugger_queue_execute_command (Debugger
*debugger
)
655 DEBUG_PRINT ("In function: debugger_queue_execute_command()");
657 if (!debugger
->priv
->debugger_is_busy
&&
658 !debugger
->priv
->starting
&&
659 g_list_length (debugger
->priv
->cmd_queqe
) >= 1)
661 debugger_clear_buffers (debugger
);
662 if (debugger_queue_set_next_command (debugger
))
663 debugger_execute_command (debugger
, debugger
->priv
->current_cmd
.cmd
);
668 debugger_load_executable_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
,
669 const GList
*cli_results
, GError
*error
)
671 DEBUG_PRINT ("Program loaded");
672 debugger
->priv
->prog_is_loaded
= TRUE
;
674 g_signal_emit_by_name (debugger
->priv
->instance
, "program-loaded");
678 debugger_load_executable (Debugger
*debugger
, const gchar
*prog
)
680 gchar
*command
, *dir
, *msg
;
682 g_return_if_fail (IS_DEBUGGER (debugger
));
683 g_return_if_fail (prog
!= NULL
);
685 DEBUG_PRINT ("In function: debugger_load_executable(%s)", prog
);
687 if (debugger
->priv
->output_callback
)
689 msg
= g_strconcat (_("Loading Executable: "), prog
, "\n", NULL
);
690 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
, msg
,
691 debugger
->priv
->output_user_data
);
695 command
= g_strconcat ("-file-exec-and-symbols ", prog
, NULL
);
696 dir
= g_path_get_dirname (prog
);
698 anjuta_set_execution_dir(dir);
701 debugger_queue_command (debugger
, command
, FALSE
, FALSE
, debugger_load_executable_finish
, NULL
, NULL
);
703 debugger
->priv
->starting
= TRUE
;
704 debugger
->priv
->terminating
= FALSE
;
708 debugger_load_core (Debugger
*debugger
, const gchar
*core
)
710 gchar
*command
, *dir
, *msg
;
712 g_return_if_fail (IS_DEBUGGER (debugger
));
713 g_return_if_fail (core
!= NULL
);
715 DEBUG_PRINT ("In function: debugger_load_core(%s)", core
);
717 if (debugger
->priv
->output_callback
)
719 msg
= g_strconcat (_("Loading Core: "), core
, "\n", NULL
);
720 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
, msg
,
721 debugger
->priv
->output_user_data
);
725 command
= g_strconcat ("core ", core
, NULL
);
726 dir
= g_path_get_dirname (core
);
727 debugger
->priv
->search_dirs
=
728 g_list_prepend (debugger
->priv
->search_dirs
, dir
);
729 debugger_queue_command (debugger
, command
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
734 debugger_start (Debugger
*debugger
, const GList
*search_dirs
,
735 const gchar
*prog
, gboolean is_libtool_prog
)
737 gchar
*command_str
, *dir
, *tmp
, *text
, *msg
;
741 AnjutaLauncher
*launcher
;
742 GList
*dir_list
= NULL
;
745 DEBUG_PRINT ("In function: debugger_start(%s) libtool %d", prog
== NULL
? "(null)" : prog
, is_libtool_prog
);
747 if (anjuta_util_prog_is_installed ("gdb", TRUE
) == FALSE
)
750 debugger_queue_clear (debugger
);
752 tmp
= g_strconcat (PACKAGE_DATA_DIR
, "/", "gdb.init", NULL
);
753 if (g_file_test (tmp
, G_FILE_TEST_IS_REGULAR
) == FALSE
)
755 anjuta_util_dialog_error (debugger
->priv
->parent_win
,
756 _("Unable to find: %s.\n"
757 "Unable to initialize debugger.\n"
758 "Make sure Anjuta is installed correctly."),
765 /* Prepare source search directories */
768 exec_dir
= g_path_get_dirname (prog
);
772 gchar
*quoted_exec_dir
= gdb_quote (exec_dir
);
773 dir
= g_strconcat (" -directory=\"", quoted_exec_dir
, "\"", NULL
);
774 g_free (quoted_exec_dir
);
775 dir_list
= g_list_prepend (dir_list
, exec_dir
);
779 dir
= g_strdup (" ");
786 if (strncmp (text
, "file://", 7) == 0)
792 g_warning ("Debugger source search uri '%s' is not a local uri", text
);
797 tmp
= g_strconcat (dir
, " -directory=", text
, NULL
);
801 dir_list
= g_list_prepend (dir_list
, g_strdup (text
));
805 g_warning ("Debugger source search dir '%s' is not absolute",
808 node
= g_list_next (node
);
811 /* Now save the dir list. Order is automatically revesed */
815 debugger
->priv
->search_dirs
=
816 g_list_prepend (debugger
->priv
->search_dirs
, node
->data
);
817 node
= g_list_next (node
);
819 g_list_free (dir_list
);
821 if (prog
&& strlen(prog
) > 0)
823 gchar
*quoted_prog
= gdb_quote (prog
);
826 if (is_libtool_prog
== FALSE
)
828 command_str
= g_strdup_printf (GDB_PATH
" -f -n -i=mi2 %s %s "
829 "-x %s/gdb.init \"%s\"", dir
, term
== NULL
? "" : term
,
830 PACKAGE_DATA_DIR
, quoted_prog
);
834 command_str
= g_strdup_printf ("libtool --mode=execute " GDB_PATH
835 " -f -n -i=mi2 %s %s "
836 "-x %s/gdb.init \"%s\"", dir
, term
== NULL
? "" : term
,
837 PACKAGE_DATA_DIR
, quoted_prog
);
839 g_free (quoted_prog
);
843 if (is_libtool_prog
== FALSE
)
845 command_str
= g_strdup_printf (GDB_PATH
" -f -n -i=mi2 %s %s "
846 "-x %s/gdb.init ", term
== NULL
? "" : term
,
847 dir
, PACKAGE_DATA_DIR
);
851 command_str
= g_strdup_printf ("libtool --mode=execute " GDB_PATH
852 " -f -n -i=mi2 %s %s -x "
854 dir
, term
== NULL
? "" : term
, PACKAGE_DATA_DIR
);
859 debugger
->priv
->starting
= TRUE
;
860 debugger
->priv
->terminating
= FALSE
;
861 debugger
->priv
->loading
= prog
!= NULL
? TRUE
: FALSE
;
862 debugger
->priv
->debugger_is_busy
= 1;
864 /* Prepare for launch. */
865 launcher
= debugger
->priv
->launcher
;
866 anjuta_launcher_set_terminate_on_exit (launcher
, TRUE
);
867 g_signal_connect (G_OBJECT (launcher
), "child-exited",
868 G_CALLBACK (on_gdb_terminated
), debugger
);
869 ret
= anjuta_launcher_execute (launcher
, command_str
,
870 on_gdb_output_arrived
, debugger
);
874 debugger
->priv
->debugger_is_started
= TRUE
;
875 debugger
->priv
->prog_is_loaded
= prog
!= NULL
;
877 anjuta_launcher_set_encoding (launcher
, "ISO-8859-1");
879 if (debugger
->priv
->output_callback
!= NULL
)
883 /* TODO anjuta_update_app_status (TRUE, _("Debugger")); */
884 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
885 _("Getting ready to start debugging "
887 debugger
->priv
->output_user_data
);
891 msg
= g_strconcat (_("Loading Executable: "), prog
, "\n", NULL
);
892 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
894 debugger
->priv
->output_user_data
);
899 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
900 _("No executable specified.\n"),
901 debugger
->priv
->output_user_data
);
902 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
903 _("Open an executable or attach "
904 "to a process to start "
906 debugger
->priv
->output_user_data
);
911 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
912 _("There was an error whilst "
913 "launching the debugger.\n"),
914 debugger
->priv
->output_user_data
);
915 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
916 _("Make sure 'gdb' is installed "
918 debugger
->priv
->output_user_data
);
921 g_free (command_str
);
927 gdb_stdout_line_arrived (Debugger
*debugger
, const gchar
* chars
)
933 if (chars
[i
] == '\n')
935 debugger_stdo_flush (debugger
);
939 g_string_append_c (debugger
->priv
->stdo_line
, chars
[i
]);
946 gdb_stderr_line_arrived (Debugger
*debugger
, const gchar
* chars
)
950 for (i
= 0; i
< strlen (chars
); i
++)
952 if (chars
[i
] == '\n')
953 debugger_stde_flush (debugger
);
955 g_string_append_c (debugger
->priv
->stde_line
, chars
[i
]);
960 on_gdb_output_arrived (AnjutaLauncher
*launcher
,
961 AnjutaLauncherOutputType output_type
,
962 const gchar
*chars
, gpointer data
)
964 Debugger
*debugger
= DEBUGGER (data
);
965 DEBUG_PRINT ("on gdb output arrived");
967 /* Do not emit signal when the debugger is destroyed */
968 if (debugger
->priv
->instance
== NULL
) return;
972 case ANJUTA_LAUNCHER_OUTPUT_STDERR
:
973 gdb_stderr_line_arrived (debugger
, chars
);
975 case ANJUTA_LAUNCHER_OUTPUT_STDOUT
:
976 gdb_stdout_line_arrived (debugger
, chars
);
984 debugger_handle_post_execution (Debugger
*debugger
)
986 switch (debugger
->priv
->post_execution_flag
)
991 DEBUG_PRINT ("debugger stop in handle post execution\n");
992 debugger_stop (debugger
);
994 case DEBUGGER_RERUN_PROGRAM
:
995 DEBUG_PRINT ("debugger run in handle post execution\n");
996 debugger_run (debugger
);
999 g_warning ("Execution should not reach here");
1004 debugger_process_frame (Debugger
*debugger
, const GDBMIValue
*val
)
1006 const GDBMIValue
*file
, *line
, *frame
, *addr
, *fullname
, *thread
;
1007 const gchar
*file_str
= NULL
;
1009 gulong addr_num
= 0;
1011 g_return_if_fail (val
!= NULL
);
1013 thread
= gdbmi_value_hash_lookup (val
, "thread-id");
1016 debugger
->priv
->current_thread
= strtoul (gdbmi_value_literal_get (thread
), NULL
, 0);
1018 debugger
->priv
->current_frame
= 0;
1020 frame
= gdbmi_value_hash_lookup (val
, "frame");
1023 fullname
= gdbmi_value_hash_lookup (frame
, "fullname");
1026 file_str
= gdbmi_value_literal_get (fullname
);
1027 if (*file_str
== '\0') file_str
= NULL
;
1031 file
= gdbmi_value_hash_lookup (frame
, "file");
1034 file_str
= gdbmi_value_literal_get (file
);
1035 if (*file_str
== '\0') file_str
= NULL
;
1039 if (file_str
!= NULL
)
1041 line
= gdbmi_value_hash_lookup (frame
, "line");
1044 line_num
= strtoul (gdbmi_value_literal_get (line
), NULL
, 0);
1048 addr
= gdbmi_value_hash_lookup (frame
, "addr");
1051 addr_num
= strtoul (gdbmi_value_literal_get (addr
), NULL
, 0);
1053 debugger_program_moved (debugger
, file_str
, line_num
, addr_num
);
1058 gdb_parse_error (Debugger
*debugger
, const GDBMIValue
*mi_results
)
1060 const GDBMIValue
*message
;
1061 const gchar
*literal
;
1062 guint code
= IANJUTA_DEBUGGER_UNKNOWN_ERROR
;
1064 message
= gdbmi_value_hash_lookup (mi_results
, "msg");
1065 literal
= gdbmi_value_literal_get (message
);
1067 if ((mi_results
!= NULL
)
1068 && ((message
= gdbmi_value_hash_lookup (mi_results
, "msg")) != NULL
)
1069 && ((literal
= gdbmi_value_literal_get (message
)) != NULL
)
1070 && (*literal
!= '\0'))
1072 code
= gdb_match_error (literal
);
1073 DEBUG_PRINT ("error code %d", code
);
1077 /* No error message */
1078 literal
= "Error without a message";
1081 return g_error_new_literal (IANJUTA_DEBUGGER_ERROR
, code
, literal
);
1086 *---------------------------------------------------------------------------*/
1089 debugger_parse_output (Debugger
*debugger
)
1093 line
= debugger
->priv
->stdo_line
->str
;
1095 if (line
[0] == '\032' && line
[1] == '\032')
1100 gdb_util_parse_error_line (&(line
[2]), &filename
, &lineno
);
1103 debugger_program_moved (debugger
, filename
, lineno
, 0);
1112 len
= strlen (line
);
1113 if (line
[1] == '\"' && line
[strlen(line
) - 1] == '\"')
1116 /* Reserve space for an additional carriage return */
1117 line
[strlen(line
) - 1] = ' ';
1118 proper_msg
= g_strcompress (line
+ 1);
1119 len
= strlen (proper_msg
) - 1;
1120 proper_msg
[len
] = '\0';
1124 /* Reserve space for an additional carriage return */
1125 proper_msg
= g_strndup (line
, len
+ 1);
1128 if (strcmp(proper_msg
, "~Stopped due to shared library event\n") == 0)
1130 /* Recognize a solib event */
1131 debugger
->priv
->solib_event
= TRUE
;
1132 g_free (proper_msg
);
1134 else if (debugger
->priv
->current_cmd
.parser
)
1136 /* Save GDB CLI output */
1137 debugger
->priv
->cli_lines
= g_list_prepend (debugger
->priv
->cli_lines
,
1142 /* Discard CLI output */
1143 g_free (proper_msg
);
1149 debugger_parse_stopped (Debugger
*debugger
)
1151 gchar
*line
= debugger
->priv
->stdo_line
->str
;
1154 if (!debugger
->priv
->solib_event
)
1156 gboolean program_exited
= FALSE
;
1159 /* Check if program has exited */
1160 val
= gdbmi_value_parse (line
);
1163 const GDBMIValue
*reason
;
1164 const gchar
*str
= NULL
;
1166 debugger_process_frame (debugger
, val
);
1168 reason
= gdbmi_value_hash_lookup (val
, "reason");
1170 str
= gdbmi_value_literal_get (reason
);
1172 if (str
&& (strncmp (str
, "exited", 6) == 0))
1174 program_exited
= TRUE
;
1177 /* Emit signal received if necessary */
1178 if (str
&& strcmp (str
, "exited-signalled") == 0)
1180 const GDBMIValue
*signal_name
, *signal_meaning
;
1181 const gchar
*signal_str
, *signal_meaning_str
;
1183 signal_name
= gdbmi_value_hash_lookup (val
, "signal-name");
1184 signal_str
= gdbmi_value_literal_get (signal_name
);
1185 signal_meaning
= gdbmi_value_hash_lookup (val
, "signal-meaning");
1186 signal_meaning_str
= gdbmi_value_literal_get (signal_meaning
);
1187 g_signal_emit_by_name (debugger
->priv
->instance
, "signal-received", signal_str
, signal_meaning_str
);
1189 else if (str
&& strcmp (str
, "signal-received") == 0)
1191 const GDBMIValue
*signal_name
, *signal_meaning
;
1192 const gchar
*signal_str
, *signal_meaning_str
;
1194 signal_name
= gdbmi_value_hash_lookup (val
, "signal-name");
1195 signal_str
= gdbmi_value_literal_get (signal_name
);
1196 signal_meaning
= gdbmi_value_hash_lookup (val
, "signal-meaning");
1197 signal_meaning_str
= gdbmi_value_literal_get (signal_meaning
);
1199 g_signal_emit_by_name (debugger
->priv
->instance
, "signal-received", signal_str
, signal_meaning_str
);
1202 if (debugger
->priv
->output_callback
)
1204 if (str
&& strcmp (str
, "exited-normally") == 0)
1206 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1207 _("Program exited normally\n"),
1208 debugger
->priv
->output_user_data
);
1210 else if (str
&& strcmp (str
, "exited") == 0)
1212 const GDBMIValue
*errcode
;
1213 const gchar
*errcode_str
;
1216 errcode
= gdbmi_value_hash_lookup (val
, "exit-code");
1217 errcode_str
= gdbmi_value_literal_get (errcode
);
1218 msg
= g_strdup_printf (_("Program exited with error code %s\n"),
1220 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1221 msg
, debugger
->priv
->output_user_data
);
1224 else if (str
&& strcmp (str
, "breakpoint-hit") == 0)
1226 const GDBMIValue
*bkptno
;
1227 const gchar
*bkptno_str
;
1230 bkptno
= gdbmi_value_hash_lookup (val
, "bkptno");
1231 bkptno_str
= gdbmi_value_literal_get (bkptno
);
1232 /* The program has reached one breakpoint and will stop */
1233 msg
= g_strdup_printf (_("Breakpoint number %s hit\n"),
1235 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1236 msg
, debugger
->priv
->output_user_data
);
1239 else if (str
&& strcmp (str
, "function-finished") == 0)
1241 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1242 _("Function finished\n"),
1243 debugger
->priv
->output_user_data
);
1245 else if (str
&& strcmp (str
, "end-stepping-range") == 0)
1247 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1248 _("Stepping finished\n"),
1249 debugger
->priv
->output_user_data
);
1251 else if (str
&& strcmp (str
, "location-reached") == 0)
1253 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1254 _("Location reached\n"),
1255 debugger
->priv
->output_user_data
);
1262 debugger
->priv
->prog_is_running
= FALSE
;
1263 debugger
->priv
->prog_is_attached
= FALSE
;
1264 debugger_handle_post_execution (debugger
);
1265 debugger
->priv
->exiting
= TRUE
;
1269 // g_signal_emit_by_name (debugger->priv->instance, "program-stopped");
1270 debugger
->priv
->stopping
= TRUE
;
1273 debugger
->priv
->cli_lines
= g_list_reverse (debugger
->priv
->cli_lines
);
1274 if ((debugger
->priv
->current_cmd
.cmd
!= NULL
) &&
1275 (debugger
->priv
->current_cmd
.parser
!= NULL
))
1277 debugger
->priv
->current_cmd
.parser (debugger
, val
,
1278 debugger
->priv
->cli_lines
, FALSE
);
1279 debugger
->priv
->command_output_sent
= TRUE
;
1280 DEBUG_PRINT ("In function: Sending output...");
1284 gdbmi_value_free (val
);
1289 debugger_parse_prompt (Debugger
*debugger
)
1291 /* If the parser has not yet been called, call it now. */
1292 if (debugger
->priv
->command_output_sent
== FALSE
&&
1293 debugger
->priv
->current_cmd
.parser
)
1295 debugger
->priv
->current_cmd
.parser (debugger
, NULL
,
1296 debugger
->priv
->cli_lines
, FALSE
);
1297 debugger
->priv
->command_output_sent
= TRUE
;
1300 debugger
->priv
->debugger_is_busy
--;
1301 debugger_queue_execute_command (debugger
); /* Next command. Go. */
1302 debugger_emit_ready (debugger
);
1306 parse_breakpoint (IAnjutaDebuggerBreakpointItem
* bp
, const GDBMIValue
*brkpnt
)
1308 const GDBMIValue
*literal
;
1311 memset (bp
, 0, sizeof (*bp
));
1313 literal
= gdbmi_value_hash_lookup (brkpnt
, "number");
1316 value
= gdbmi_value_literal_get (literal
);
1317 bp
->id
= strtoul (value
, NULL
, 10);
1320 literal
= gdbmi_value_hash_lookup (brkpnt
, "fullname");
1321 if (literal
== NULL
) literal
= gdbmi_value_hash_lookup (brkpnt
, "file");
1324 value
= gdbmi_value_literal_get (literal
);
1325 bp
->file
= (gchar
*)value
;
1328 literal
= gdbmi_value_hash_lookup (brkpnt
, "line");
1331 value
= gdbmi_value_literal_get (literal
);
1332 bp
->line
= strtoul (value
, NULL
, 10);
1333 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_ON_LINE
;
1336 literal
= gdbmi_value_hash_lookup (brkpnt
, "type");
1339 value
= gdbmi_value_literal_get (literal
);
1342 literal
= gdbmi_value_hash_lookup (brkpnt
, "disp");
1345 value
= gdbmi_value_literal_get (literal
);
1346 if (strcmp (value
, "keep") == 0)
1348 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_TEMPORARY
;
1349 bp
->temporary
= FALSE
;
1351 else if ((strcmp (value
, "nokeep") == 0) || (strcmp (value
, "del") == 0))
1353 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_TEMPORARY
;
1354 bp
->temporary
= TRUE
;
1358 literal
= gdbmi_value_hash_lookup (brkpnt
, "enabled");
1361 value
= gdbmi_value_literal_get (literal
);
1362 if (strcmp (value
, "n") == 0)
1364 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_ENABLE
;
1367 else if (strcmp (value
, "y") == 0)
1369 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_ENABLE
;
1374 literal
= gdbmi_value_hash_lookup (brkpnt
, "addr");
1377 value
= gdbmi_value_literal_get (literal
);
1378 bp
->address
= strtoul (value
, NULL
, 16);
1379 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_ON_ADDRESS
;
1382 literal
= gdbmi_value_hash_lookup (brkpnt
, "func");
1385 value
= gdbmi_value_literal_get (literal
);
1386 bp
->function
= (gchar
*)value
;
1387 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_ON_FUNCTION
;
1390 literal
= gdbmi_value_hash_lookup (brkpnt
, "times");
1393 value
= gdbmi_value_literal_get (literal
);
1394 bp
->times
= strtoul (value
, NULL
, 10);
1395 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_TIME
;
1397 DEBUG_PRINT("parse time %d", bp
->times
);
1399 literal
= gdbmi_value_hash_lookup (brkpnt
, "ignore");
1402 value
= gdbmi_value_literal_get (literal
);
1403 bp
->ignore
= strtoul (value
, NULL
, 10);
1404 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_IGNORE
;
1407 literal
= gdbmi_value_hash_lookup (brkpnt
, "cond");
1410 value
= gdbmi_value_literal_get (literal
);
1411 bp
->condition
= (gchar
*)value
;
1412 bp
->type
|= IANJUTA_DEBUGGER_BREAKPOINT_WITH_CONDITION
;
1419 debugger_stdo_flush (Debugger
*debugger
)
1423 line
= debugger
->priv
->stdo_line
->str
;
1426 DEBUG_PRINT ("GDB:< %s", line
);
1428 if (debugger
->priv
->gdb_log
) g_message ("GDB:< %s", line
);
1430 debugger_log_output (debugger
, line
);
1431 if (strlen (line
) == 0)
1435 if (strncasecmp (line
, "^error", 6) == 0)
1437 /* GDB reported error */
1438 if ((debugger
->priv
->current_cmd
.keep_result
) || (debugger
->priv
->stdo_acc
->len
!= 0))
1440 /* Keep result for next command */
1442 if (debugger
->priv
->stdo_acc
->len
== 0)
1444 g_string_append (debugger
->priv
->stdo_acc
, line
);
1448 line
= strchr (line
, ',');
1451 g_string_append (debugger
->priv
->stdo_acc
, line
);
1454 line
= debugger
->priv
->stdo_acc
->str
;
1457 GDBMIValue
*val
= gdbmi_value_parse (line
);
1460 error
= gdb_parse_error (debugger
, val
);
1462 if (debugger
->priv
->current_cmd
.parser
!= NULL
)
1464 debugger
->priv
->current_cmd
.parser (debugger
, val
, debugger
->priv
->cli_lines
, error
);
1465 debugger
->priv
->command_output_sent
= TRUE
; }
1466 DEBUG_PRINT("GDB: error %s", error
->message
);
1469 anjuta_util_dialog_error (debugger->priv->parent_win, "%s", error->message);
1471 g_error_free (error
);
1472 gdbmi_value_free (val
);
1474 else if (strncasecmp(line
, "^running", 8) == 0)
1476 /* Program started running */
1477 debugger
->priv
->prog_is_running
= TRUE
;
1478 /* debugger->priv->skip_next_prompt = TRUE; Replaced by debugger_is_busy++ */
1479 debugger
->priv
->debugger_is_busy
++;
1480 g_signal_emit_by_name (debugger
->priv
->instance
, "program-running");
1482 else if (strncasecmp (line
, "*stopped", 8) == 0)
1484 /* Process has stopped */
1485 debugger_parse_stopped (debugger
);
1487 else if (strncasecmp (line
, "^done", 5) == 0)
1489 if ((debugger
->priv
->current_cmd
.keep_result
) || (debugger
->priv
->stdo_acc
->len
!= 0))
1491 /* Keep result for next command */
1493 if (debugger
->priv
->stdo_acc
->len
== 0)
1495 g_string_append (debugger
->priv
->stdo_acc
, line
);
1499 line
= strchr (line
, ',');
1502 g_string_append (debugger
->priv
->stdo_acc
, line
);
1505 line
= debugger
->priv
->stdo_acc
->str
;
1508 if (!debugger
->priv
->current_cmd
.keep_result
)
1510 /* GDB command has reported output */
1511 GDBMIValue
*val
= gdbmi_value_parse (line
);
1513 debugger
->priv
->cli_lines
= g_list_reverse (debugger
->priv
->cli_lines
);
1514 if ((debugger
->priv
->current_cmd
.cmd
!= NULL
) &&
1515 (debugger
->priv
->current_cmd
.parser
!= NULL
))
1517 debugger
->priv
->current_cmd
.parser (debugger
, val
,
1518 debugger
->priv
->cli_lines
, FALSE
);
1519 debugger
->priv
->command_output_sent
= TRUE
;
1520 DEBUG_PRINT ("In function: Sending output...");
1524 /*g_signal_emit_by_name (debugger, "results-arrived",
1525 debugger->priv->current_cmd.cmd, val);*/
1530 /*debugger_process_frame (debugger, val);*/
1531 gdbmi_value_free (val
);
1535 if (!debugger
->priv
->current_cmd
.keep_result
)
1537 g_string_assign (debugger
->priv
->stdo_acc
, "");
1540 else if (strncasecmp (line
, GDB_PROMPT
, strlen (GDB_PROMPT
)) == 0)
1542 debugger_parse_prompt (debugger
);
1546 debugger_parse_output (debugger
);
1549 /* Clear the line buffer */
1550 g_string_assign (debugger
->priv
->stdo_line
, "");
1554 debugger_stde_flush (Debugger
*debugger
)
1556 if ((debugger
->priv
->output_callback
) && (strlen (debugger
->priv
->stde_line
->str
) > 0))
1558 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_ERROR_OUTPUT
,
1559 debugger
->priv
->stde_line
->str
,
1560 debugger
->priv
->output_user_data
);
1562 /* Clear the line buffer */
1563 g_string_assign (debugger
->priv
->stde_line
, "");
1567 on_gdb_terminated (AnjutaLauncher
*launcher
,
1568 gint child_pid
, gint status
, gulong t
,
1571 Debugger
*debugger
= DEBUGGER (data
);
1574 g_signal_handlers_disconnect_by_func (G_OBJECT (launcher
),
1575 G_CALLBACK (on_gdb_terminated
),
1578 DEBUG_PRINT ("In function: gdb_terminated()");
1580 /* Clear the command queue & Buffer */
1581 debugger_clear_buffers (debugger
);
1583 /* Good Bye message */
1584 /*if (!debugger->priv->terminating)
1586 anjuta_util_dialog_error (debugger->priv->parent_win,
1587 _("gdb terminated unexpectedly with status %d\n"), status);
1589 debugger
->priv
->prog_is_running
= FALSE
;
1590 debugger
->priv
->prog_is_attached
= FALSE
;
1591 debugger
->priv
->prog_is_loaded
= FALSE
;
1592 debugger
->priv
->debugger_is_busy
= 0;
1593 debugger
->priv
->skip_next_prompt
= FALSE
;
1594 if (!debugger
->priv
->terminating
)
1596 err
= g_error_new (IANJUTA_DEBUGGER_ERROR
,
1597 IANJUTA_DEBUGGER_OTHER_ERROR
,
1598 "gdb terminated with status %d", status
);
1600 debugger
->priv
->terminating
= FALSE
;
1601 debugger
->priv
->debugger_is_started
= FALSE
;
1602 if (debugger
->priv
->instance
)
1604 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-stopped", err
);
1606 if (err
!= NULL
) g_error_free (err
);
1610 debugger_stop_real (Debugger
*debugger
)
1612 DEBUG_PRINT ("In function: debugger_stop_real()");
1614 /* if program is attached - detach from it before quiting */
1615 if (debugger
->priv
->prog_is_attached
== TRUE
)
1617 debugger_detach_process(debugger
);
1620 debugger
->priv
->terminating
= TRUE
;
1621 debugger_queue_command (debugger
, "-gdb-exit", FALSE
, FALSE
, NULL
, NULL
, NULL
);
1625 debugger_stop (Debugger
*debugger
)
1628 gboolean ret
= TRUE
;
1630 if (debugger
->priv
->prog_is_running
== TRUE
)
1635 if (debugger
->priv
->prog_is_attached
== TRUE
)
1636 mesg
= _("The program is attached.\n"
1637 "Do you still want to stop the debugger?");
1639 mesg
= _("The program is running.\n"
1640 "Do you still want to stop the debugger?");
1641 dialog
= gtk_message_dialog_new (debugger
->priv
->parent_win
,
1642 GTK_DIALOG_DESTROY_WITH_PARENT
,
1643 GTK_MESSAGE_QUESTION
,
1644 GTK_BUTTONS_NONE
, mesg
);
1645 gtk_dialog_add_buttons (GTK_DIALOG (dialog
),
1646 GTK_STOCK_CANCEL
, GTK_RESPONSE_NO
,
1647 GTK_STOCK_STOP
, GTK_RESPONSE_YES
,
1649 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_YES
)
1650 debugger_stop_real (debugger
);
1653 gtk_widget_destroy (dialog
);
1656 debugger_stop_real (debugger
);
1659 debugger_stop_real (debugger
);
1665 debugger_abort (Debugger
*debugger
)
1667 DEBUG_PRINT ("In function: debugger_abort()");
1670 if ((debugger
->priv
->prog_is_attached
== FALSE
) && (debugger
->priv
->inferior_pid
!= 0))
1672 kill (debugger
->priv
->inferior_pid
, SIGTERM
);
1673 debugger
->priv
->inferior_pid
= 0;
1677 debugger
->priv
->terminating
= TRUE
;
1678 g_signal_handlers_disconnect_by_func (G_OBJECT (debugger
->priv
->launcher
), G_CALLBACK (on_gdb_terminated
), debugger
);
1679 anjuta_launcher_reset (debugger
->priv
->launcher
);
1682 debugger_queue_clear (debugger
);
1683 g_list_foreach (debugger
->priv
->search_dirs
, (GFunc
)g_free
, NULL
);
1684 g_list_free (debugger
->priv
->search_dirs
);
1685 debugger
->priv
->search_dirs
= NULL
;
1687 /* Emit signal, state of the debugger must be DEBUGGER_STOPPED */
1688 debugger
->priv
->prog_is_running
= FALSE
;
1689 debugger
->priv
->prog_is_attached
= FALSE
;
1690 debugger
->priv
->inferior_pid
= 0;
1691 debugger
->priv
->prog_is_loaded
= FALSE
;
1692 debugger
->priv
->debugger_is_busy
= 0;
1693 debugger
->priv
->debugger_is_started
= FALSE
;
1694 if (debugger
->priv
->instance
!= NULL
)
1696 g_signal_emit_by_name (debugger
->priv
->instance
, "debugger-stopped", NULL
);
1697 debugger
->priv
->instance
= NULL
;
1704 debugger_get_source_path (Debugger
*debugger
, const gchar
*file
)
1709 if (g_path_is_absolute (file
))
1710 return g_strdup (file
);
1712 node
= debugger
->priv
->search_dirs
;
1715 path
= g_build_filename (node
->data
, file
, NULL
);
1716 if (g_file_test (path
, G_FILE_TEST_EXISTS
))
1720 node
= g_list_next (node
);
1725 /* The file could be found nowhere. Use current directory */
1727 cwd
= g_get_current_dir ();
1728 path
= g_build_filename (cwd
, file
, NULL
);
1735 debugger_set_output_callback (Debugger
*debugger
, IAnjutaDebuggerOutputCallback callback
, gpointer user_data
)
1737 debugger
->priv
->output_callback
= callback
;
1738 debugger
->priv
->output_user_data
= user_data
;
1742 debugger_program_moved (Debugger
*debugger
, const gchar
*file
,
1743 gint line
, gulong address
)
1747 if ((file
!= NULL
) && (*file
!= G_DIR_SEPARATOR
))
1749 src_path
= debugger_get_source_path (debugger
, file
);
1750 g_signal_emit_by_name (debugger
->priv
->instance
, "program-moved", debugger
->priv
->inferior_pid
, debugger
->priv
->current_thread
, address
, src_path
, line
);
1755 g_signal_emit_by_name (debugger
->priv
->instance
, "program-moved", debugger
->priv
->inferior_pid
, debugger
->priv
->current_thread
, address
, file
, line
);
1760 debugger_info_program_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
,
1761 const GList
*cli_results
, GError
*error
)
1763 DEBUG_PRINT ("In function: debugger_info_program()");
1765 /* Hack: find message string giving inferior pid */
1766 while (cli_results
!= NULL
)
1770 child_proc
= strstr(cli_results
->data
, " child process ");
1771 if (child_proc
!= NULL
)
1773 debugger
->priv
->inferior_pid
= strtoul (child_proc
+ 15, NULL
, 10);
1776 cli_results
= g_list_next (cli_results
);
1781 debugger_start_program (Debugger
*debugger
, const gchar
* args
, const gchar
* tty
, gboolean stop
)
1785 DEBUG_PRINT ("In function: debugger_start_program()");
1787 g_return_if_fail (IS_DEBUGGER (debugger
));
1788 g_return_if_fail (debugger
->priv
->prog_is_running
== FALSE
);
1790 /* Without a terminal, the output of the debugged program
1794 cmd
= g_strdup_printf ("-inferior-tty-set %s", tty
);
1795 debugger_queue_command (debugger
, cmd
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
1799 debugger
->priv
->inferior_pid
= 0;
1802 debugger_queue_command (debugger
, "-break-insert -t main", FALSE
, FALSE
, NULL
, NULL
, NULL
);
1804 if (args
&& (*args
))
1806 cmd
= g_strconcat ("-exec-arguments ", args
, NULL
);
1807 debugger_queue_command (debugger
, cmd
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
1811 debugger_queue_command (debugger
, "-exec-run", FALSE
, FALSE
, NULL
, NULL
, NULL
);
1813 /* Get pid of program on next stop */
1814 debugger_queue_command (debugger
, "info program", FALSE
, FALSE
, debugger_info_program_finish
, NULL
, NULL
);
1815 debugger
->priv
->post_execution_flag
= DEBUGGER_NONE
;
1819 debugger_attach_process_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
,
1820 const GList
*cli_results
, GError
*error
)
1822 DEBUG_PRINT ("Program attach finished");
1823 if (debugger
->priv
->output_callback
)
1825 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1826 _("Program attached\n"),
1827 debugger
->priv
->output_user_data
);
1829 debugger
->priv
->prog_is_attached
= TRUE
;
1830 debugger
->priv
->prog_is_running
= TRUE
;
1831 /* It is not really a shared lib event, but it allows to restart
1832 * the program after setting breakpoints. It is better to restart
1833 * it because we don't have the normal stop frame that tell where
1834 * the program is stopped */
1835 debugger
->priv
->solib_event
= TRUE
;
1839 debugger_attach_process_real (Debugger
*debugger
, pid_t pid
)
1843 DEBUG_PRINT ("In function: debugger_attach_process_real()");
1845 if (debugger
->priv
->output_callback
)
1847 buff
= g_strdup_printf (_("Attaching to process: %d...\n"), pid
);
1848 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1849 buff
, debugger
->priv
->output_user_data
);
1853 debugger
->priv
->inferior_pid
= pid
;
1854 buff
= g_strdup_printf ("attach %d", pid
);
1855 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
,
1856 debugger_attach_process_finish
, NULL
, NULL
);
1861 debugger_attach_process (Debugger
*debugger
, pid_t pid
)
1863 DEBUG_PRINT ("In function: debugger_attach_process()");
1865 g_return_if_fail (IS_DEBUGGER (debugger
));
1867 if (debugger
->priv
->prog_is_running
== TRUE
)
1869 // TODO: Dialog to be made HIG compliant.
1873 mesg
= _("A process is already running.\n"
1874 "Would you like to terminate it and attach the new process?"),
1875 dialog
= gtk_message_dialog_new (debugger
->priv
->parent_win
,
1876 GTK_DIALOG_DESTROY_WITH_PARENT
,
1877 GTK_MESSAGE_QUESTION
,
1878 GTK_BUTTONS_YES_NO
, mesg
);
1879 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_YES
)
1881 debugger_stop_program (debugger
);
1882 debugger_attach_process_real (debugger
, pid
);
1884 gtk_widget_destroy (dialog
);
1886 else if (getpid () == pid
||
1887 anjuta_launcher_get_child_pid (debugger
->priv
->launcher
) == pid
)
1889 anjuta_util_dialog_error (debugger
->priv
->parent_win
,
1890 _("Anjuta is unable to attach to itself."));
1894 debugger_attach_process_real (debugger
, pid
);
1898 debugger_restart_program (Debugger
*debugger
)
1900 DEBUG_PRINT ("In function: debugger_restart_program()");
1902 g_return_if_fail (debugger
->priv
->prog_is_attached
== FALSE
);
1905 debugger->priv->post_execution_flag = DEBUGGER_RERUN_PROGRAM;
1906 debugger_stop_program (debugger);
1908 debugger_put_cmd_in_queqe ("tbreak main", DB_CMD_NONE, NULL, NULL);
1909 debugger_put_cmd_in_queqe ("run >/dev/null 2>/dev/null", DB_CMD_ALL,
1911 debugger_put_cmd_in_queqe ("info program", DB_CMD_NONE,
1912 on_debugger_update_prog_status, NULL);
1913 debugger_put_cmd_in_queqe ("continue", DB_CMD_NONE, NULL, NULL);
1914 debugger_execute_cmd_in_queqe ();
1919 debugger_stop_program (Debugger
*debugger
)
1921 DEBUG_PRINT ("In function: debugger_stop_program()");
1923 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
1925 if (debugger
->priv
->prog_is_attached
== TRUE
)
1927 debugger_detach_process (debugger
);
1931 /* FIXME: Why doesn't -exec-abort work??? */
1932 /* debugger_queue_command (debugger, "-exec-abort", NULL, NULL); */
1933 debugger_queue_command (debugger
, "kill", FALSE
, FALSE
, NULL
, NULL
, NULL
);
1934 debugger
->priv
->prog_is_running
= FALSE
;
1935 debugger
->priv
->prog_is_attached
= FALSE
;
1936 g_signal_emit_by_name (debugger
->priv
->instance
, "program-exited");
1937 if (debugger
->priv
->output_callback
)
1939 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1940 _("Program terminated\n"),
1941 debugger
->priv
->output_user_data
);
1943 debugger_handle_post_execution (debugger
);
1948 debugger_detach_process_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
,
1949 const GList
*cli_results
, GError
*error
)
1951 DEBUG_PRINT ("Program detach finished");
1952 if (debugger
->priv
->output_callback
)
1954 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1955 _("Program detached\n"),
1956 debugger
->priv
->output_user_data
);
1958 debugger
->priv
->inferior_pid
= 0;
1959 debugger
->priv
->prog_is_attached
= FALSE
;
1960 debugger
->priv
->prog_is_running
= FALSE
;
1961 g_signal_emit_by_name (debugger
->priv
->instance
, "program-exited");
1965 debugger_detach_process (Debugger
*debugger
)
1969 DEBUG_PRINT ("In function: debugger_detach_process()");
1971 g_return_if_fail (debugger
->priv
->prog_is_attached
== TRUE
);
1973 if (debugger
->priv
->output_callback
)
1975 buff
= g_strdup_printf (_("Detaching the process...\n"));
1976 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1977 buff
, debugger
->priv
->output_user_data
);
1981 debugger_queue_command (debugger
, "detach", FALSE
, FALSE
,
1982 debugger_detach_process_finish
, NULL
, NULL
);
1986 debugger_interrupt (Debugger
*debugger
)
1988 DEBUG_PRINT ("In function: debugger_interrupt()");
1990 g_return_if_fail (IS_DEBUGGER (debugger
));
1991 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
1993 if (debugger
->priv
->output_callback
)
1995 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
1996 _("Interrupting the process\n"),
1997 debugger
->priv
->output_user_data
);
2000 if (debugger
->priv
->inferior_pid
== 0)
2002 /* In case we do not have the inferior pid, send signal to gdb */
2003 anjuta_launcher_signal (debugger
->priv
->launcher
, SIGINT
);
2007 /* Send signal directly to inferior */
2008 kill (debugger
->priv
->inferior_pid
, SIGINT
);
2010 //g_signal_emit_by_name (debugger->priv->instance, "program-running");
2014 debugger_run (Debugger
*debugger
)
2016 DEBUG_PRINT ("In function: debugger_run()");
2018 g_return_if_fail (IS_DEBUGGER (debugger
));
2019 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2021 /* Program running - continue */
2022 debugger_queue_command (debugger
, "-exec-continue", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2026 debugger_step_in (Debugger
*debugger
)
2028 DEBUG_PRINT ("In function: debugger_step_in()");
2030 g_return_if_fail (IS_DEBUGGER (debugger
));
2031 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2033 debugger_queue_command (debugger
, "-exec-step", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2037 debugger_step_over (Debugger
*debugger
)
2039 DEBUG_PRINT ("In function: debugger_step_over()");
2041 g_return_if_fail (IS_DEBUGGER (debugger
));
2042 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2044 debugger_queue_command (debugger
, "-exec-next", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2048 debugger_step_out (Debugger
*debugger
)
2050 DEBUG_PRINT ("In function: debugger_step_out()");
2052 g_return_if_fail (IS_DEBUGGER (debugger
));
2053 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2055 debugger_queue_command (debugger
, "-exec-finish", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2059 debugger_stepi_in (Debugger
*debugger
)
2061 DEBUG_PRINT ("In function: debugger_step_in()");
2063 g_return_if_fail (IS_DEBUGGER (debugger
));
2064 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2066 debugger_queue_command (debugger
, "-exec-step-instruction", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2070 debugger_stepi_over (Debugger
*debugger
)
2072 DEBUG_PRINT ("In function: debugger_step_over()");
2074 g_return_if_fail (IS_DEBUGGER (debugger
));
2075 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2077 debugger_queue_command (debugger
, "-exec-next-instruction", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2081 debugger_run_to_location (Debugger
*debugger
, const gchar
*loc
)
2085 DEBUG_PRINT ("In function: debugger_run_to_location()");
2087 g_return_if_fail (IS_DEBUGGER (debugger
));
2088 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2090 buff
= g_strdup_printf ("-exec-until %s", loc
);
2091 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
2096 debugger_run_to_position (Debugger
*debugger
, const gchar
*file
, guint line
)
2101 DEBUG_PRINT ("In function: debugger_run_to_position()");
2103 g_return_if_fail (IS_DEBUGGER (debugger
));
2104 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2106 quoted_file
= gdb_quote (file
);
2107 buff
= g_strdup_printf ("-break-insert -t \"\\\"%s\\\":%u\"", quoted_file
, line
);
2108 g_free (quoted_file
);
2109 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
2111 debugger_queue_command (debugger
, "-exec-continue", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2115 debugger_run_to_address (Debugger
*debugger
, gulong address
)
2119 DEBUG_PRINT ("In function: debugger_run_to_address()");
2121 g_return_if_fail (IS_DEBUGGER (debugger
));
2122 g_return_if_fail (debugger
->priv
->prog_is_running
== TRUE
);
2124 buff
= g_strdup_printf ("-break-insert -t *0x%lx", address
);
2125 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
2127 debugger_queue_command (debugger
, "-exec-continue", FALSE
, FALSE
, NULL
, NULL
, NULL
);
2131 debugger_command (Debugger
*debugger
, const gchar
*command
,
2132 gboolean suppress_error
, DebuggerParserFunc parser
,
2135 if (strncasecmp (command
, "-exec-run",
2136 strlen ("-exec-run")) == 0 ||
2137 strncasecmp (command
, "run", strlen ("run")) == 0)
2139 /* FIXME: The user might have passed args to the command */
2140 debugger_run (debugger
);
2142 else if (strncasecmp (command
, "-exec-step",
2143 strlen ("-exec-step")) == 0 ||
2144 strncasecmp (command
, "step", strlen ("step")) == 0)
2146 debugger_step_in (debugger
);
2148 else if (strncasecmp (command
, "-exec-next",
2149 strlen ("-exec-next")) == 0 ||
2150 strncasecmp (command
, "next", strlen ("next")) == 0)
2152 debugger_step_over (debugger
);
2154 else if (strncasecmp (command
, "-exec-finish",
2155 strlen ("-exec-finish")) == 0 ||
2156 strncasecmp (command
, "finish", strlen ("finish")) == 0)
2158 debugger_step_out (debugger
);
2160 else if (strncasecmp (command
, "-exec-continue",
2161 strlen ("-exec-continue")) == 0 ||
2162 strncasecmp (command
, "continue", strlen ("continue")) == 0)
2164 debugger_run (debugger
);
2166 else if (strncasecmp (command
, "-exec-until",
2167 strlen ("-exec-until")) == 0 ||
2168 strncasecmp (command
, "until", strlen ("until")) == 0)
2170 debugger_run_to_location (debugger
, strchr (command
, ' '));
2172 else if (strncasecmp (command
, "-exec-abort",
2173 strlen ("-exec-abort")) == 0 ||
2174 strncasecmp (command
, "kill", strlen ("kill")) == 0)
2176 debugger_stop_program (debugger
);
2178 else if (strncasecmp (command
, "-target-attach",
2179 strlen ("-target-attach")) == 0 ||
2180 strncasecmp (command
, "attach", strlen ("attach")) == 0)
2183 gchar
*pid_str
= strchr (command
, ' ');
2185 pid
= atoi (pid_str
);
2186 debugger_attach_process (debugger
, pid
);
2188 else if (strncasecmp (command
, "-target-detach",
2189 strlen ("-target-detach")) == 0 ||
2190 strncasecmp (command
, "detach", strlen ("detach")) == 0)
2192 debugger_detach_process (debugger
);
2194 else if (strncasecmp (command
, "-file-exec-and-symbols",
2195 strlen ("-file-exec-and-symbols")) == 0 ||
2196 strncasecmp (command
, "file", strlen ("file")) == 0)
2198 debugger_load_executable (debugger
, strchr (command
, ' '));
2200 else if (strncasecmp (command
, "core", strlen ("core")) == 0)
2202 debugger_load_core (debugger
, strchr (command
, ' '));
2206 debugger_queue_command (debugger
, command
, suppress_error
, FALSE
,
2207 parser
, user_data
, NULL
);
2212 debugger_add_breakpoint_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2214 IAnjutaDebuggerBreakpointItem bp
;
2215 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2216 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2218 if ((error
!= NULL
) || (mi_results
== NULL
))
2220 /* Call callback in all case (useful for enable that doesn't return
2222 if (callback
!= NULL
)
2223 callback (NULL
, user_data
, error
);
2225 else if (callback
!= NULL
)
2227 const GDBMIValue
*brkpnt
;
2229 brkpnt
= gdbmi_value_hash_lookup (mi_results
, "bkpt");
2230 parse_breakpoint (&bp
, brkpnt
);
2232 /* Call callback in all case (useful for enable that doesn't return
2234 callback (&bp
, user_data
, error
);
2240 debugger_add_breakpoint_at_line (Debugger
*debugger
, const gchar
*file
, guint line
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2245 DEBUG_PRINT ("In function: debugger_add_breakpoint()");
2247 g_return_if_fail (IS_DEBUGGER (debugger
));
2249 quoted_file
= gdb_quote (file
);
2251 buff
= g_strdup_printf ("-break-insert \"\\\"%s\\\":%u\"", quoted_file
, line
);
2252 g_free (quoted_file
);
2253 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2258 debugger_add_breakpoint_at_function (Debugger
*debugger
, const gchar
*file
, const gchar
*function
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2262 DEBUG_PRINT ("In function: debugger_add_breakpoint()");
2264 g_return_if_fail (IS_DEBUGGER (debugger
));
2266 buff
= g_strdup_printf ("-break-insert %s%s%s", file
== NULL
? "" : file
, file
== NULL
? "" : ":" , function
);
2267 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2272 debugger_add_breakpoint_at_address (Debugger
*debugger
, gulong address
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2276 DEBUG_PRINT ("In function: debugger_add_breakpoint()");
2278 g_return_if_fail (IS_DEBUGGER (debugger
));
2280 buff
= g_strdup_printf ("-break-insert *0x%lx", address
);
2281 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2286 debugger_enable_breakpoint (Debugger
*debugger
, guint id
, gboolean enable
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2291 DEBUG_PRINT ("In function: debugger_enable_breakpoint()");
2293 g_return_if_fail (IS_DEBUGGER (debugger
));
2295 buff
= g_strdup_printf (enable
? "-break-enable %d" : "-break-disable %d",id
);
2296 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2301 debugger_ignore_breakpoint (Debugger
*debugger
, guint id
, guint ignore
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2305 DEBUG_PRINT ("In function: debugger_ignore_breakpoint()");
2307 g_return_if_fail (IS_DEBUGGER (debugger
));
2309 buff
= g_strdup_printf ("-break-after %d %d", id
, ignore
);
2310 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2315 debugger_condition_breakpoint (Debugger
*debugger
, guint id
, const gchar
*condition
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2319 DEBUG_PRINT ("In function: debugger_ignore_breakpoint()");
2321 g_return_if_fail (IS_DEBUGGER (debugger
));
2323 buff
= g_strdup_printf ("-break-condition %d %s", id
, condition
== NULL
? "" : condition
);
2324 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_add_breakpoint_finish
, callback
, user_data
);
2329 debugger_remove_breakpoint_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2331 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2332 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2333 IAnjutaDebuggerBreakpointItem bp
;
2335 bp
.type
= IANJUTA_DEBUGGER_BREAKPOINT_REMOVED
;
2336 bp
.id
= atoi (debugger
->priv
->current_cmd
.cmd
+ 14);
2337 if (callback
!= NULL
)
2338 callback (&bp
, user_data
, NULL
);
2342 debugger_remove_breakpoint (Debugger
*debugger
, guint id
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2346 DEBUG_PRINT ("In function: debugger_delete_breakpoint()");
2348 g_return_if_fail (IS_DEBUGGER (debugger
));
2350 buff
= g_strdup_printf ("-break-delete %d", id
);
2351 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_remove_breakpoint_finish
, callback
, user_data
);
2356 debugger_list_breakpoint_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2358 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2359 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2360 IAnjutaDebuggerBreakpointItem
* bp
;
2361 const GDBMIValue
*table
;
2364 if ((error
!= NULL
) || (mi_results
== NULL
))
2366 /* Call callback in all case (useful for enable that doesn't return
2368 if (callback
!= NULL
)
2369 callback (NULL
, user_data
, error
);
2372 table
= gdbmi_value_hash_lookup (mi_results
, "BreakpointTable");
2375 table
= gdbmi_value_hash_lookup (table
, "body");
2381 for (i
= 0; i
< gdbmi_value_get_size (table
); i
++)
2383 const GDBMIValue
*brkpnt
;
2385 bp
= g_new0 (IAnjutaDebuggerBreakpointItem
, 1);
2387 brkpnt
= gdbmi_value_list_get_nth (table
, i
);
2388 parse_breakpoint(bp
, brkpnt
);
2389 list
= g_list_prepend (list
, bp
);
2394 /* Call callback in all case (useful for enable that doesn't return
2396 if (callback
!= NULL
)
2398 list
= g_list_reverse (list
);
2399 callback (list
, user_data
, error
);
2402 g_list_foreach (list
, (GFunc
)g_free
, NULL
);
2407 debugger_list_breakpoint (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2409 DEBUG_PRINT ("In function: debugger_list_breakpoint()");
2411 g_return_if_fail (IS_DEBUGGER (debugger
));
2413 debugger_queue_command (debugger
, "-break-list", FALSE
, FALSE
, debugger_list_breakpoint_finish
, callback
, user_data
);
2417 debugger_print_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2422 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2423 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2426 list
= gdb_util_remove_blank_lines (cli_results
);
2427 if (g_list_length (list
) < 1)
2433 tmp
= strchr ((gchar
*) list
->data
, '=');
2437 ptr
= g_strdup (tmp
);
2438 for (node
= list
? list
->next
: NULL
; node
!= NULL
; node
= node
->next
)
2441 ptr
= g_strconcat (tmp
, (gchar
*) node
->data
, NULL
);
2446 callback (ptr
, user_data
, NULL
);
2451 debugger_print (Debugger
*debugger
, const gchar
* variable
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2455 DEBUG_PRINT ("In function: debugger_print()");
2457 g_return_if_fail (IS_DEBUGGER (debugger
));
2459 buff
= g_strdup_printf ("print %s", variable
);
2460 debugger_queue_command (debugger
, buff
, TRUE
, FALSE
, debugger_print_finish
, callback
, user_data
);
2465 debugger_evaluate_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2468 const GDBMIValue
*value
= NULL
;
2469 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2470 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2473 value
= gdbmi_value_hash_lookup (mi_results
, "value");
2475 /* Call user function */
2476 if (callback
!= NULL
)
2477 callback (value
== NULL
? "?" : (char *)gdbmi_value_literal_get (value
), user_data
, NULL
);
2481 debugger_evaluate (Debugger
*debugger
, const gchar
* name
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2484 DEBUG_PRINT ("In function: debugger_add_watch()");
2486 g_return_if_fail (IS_DEBUGGER (debugger
));
2488 buff
= g_strdup_printf ("-data-evaluate-expression %s", name
);
2489 debugger_queue_command (debugger
, buff
, TRUE
, FALSE
, debugger_evaluate_finish
, callback
, user_data
);
2494 debugger_list_local_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2497 const GDBMIValue
*local
, *var
, *frame
, *args
, *stack
;
2501 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2502 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2507 stack
= gdbmi_value_hash_lookup (mi_results
, "stack-args");
2510 frame
= gdbmi_value_list_get_nth (stack
, 0);
2513 args
= gdbmi_value_hash_lookup (frame
, "args");
2516 for (i
= 0; i
< gdbmi_value_get_size (args
); i
++)
2518 var
= gdbmi_value_list_get_nth (args
, i
);
2521 name
= gdbmi_value_literal_get (var
);
2522 list
= g_list_prepend (list
, (gchar
*)name
);
2530 /* List local variables */
2531 local
= gdbmi_value_hash_lookup (mi_results
, "locals");
2534 for (i
= 0; i
< gdbmi_value_get_size (local
); i
++)
2536 var
= gdbmi_value_list_get_nth (local
, i
);
2539 name
= gdbmi_value_literal_get (var
);
2540 list
= g_list_prepend (list
, (gchar
*)name
);
2544 list
= g_list_reverse (list
);
2545 callback (list
, user_data
, NULL
);
2550 debugger_list_local (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2553 DEBUG_PRINT ("In function: debugger_list_local()");
2555 g_return_if_fail (IS_DEBUGGER (debugger
));
2557 buff
= g_strdup_printf("-stack-list-arguments 0 %d %d", debugger
->priv
->current_frame
, debugger
->priv
->current_frame
);
2558 debugger_queue_command (debugger
, buff
, TRUE
, TRUE
, NULL
, NULL
, NULL
);
2560 debugger_queue_command (debugger
, "-stack-list-locals 0", TRUE
, FALSE
, debugger_list_local_finish
, callback
, user_data
);
2564 debugger_list_argument_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2567 const GDBMIValue
*frame
, *var
, *args
, *stack
;
2571 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2572 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2577 stack
= gdbmi_value_hash_lookup (mi_results
, "stack-args");
2580 frame
= gdbmi_value_list_get_nth (stack
, 0);
2583 args
= gdbmi_value_hash_lookup (frame
, "args");
2589 for (i
= 0; i
< gdbmi_value_get_size (args
); i
++)
2591 var
= gdbmi_value_list_get_nth (args
, i
);
2594 name
= gdbmi_value_literal_get (var
);
2595 list
= g_list_prepend (list
, (gchar
*)name
);
2599 list
= g_list_reverse (list
);
2600 callback (list
, user_data
, NULL
);
2605 debugger_list_argument (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2609 DEBUG_PRINT ("In function: debugger_list_argument()");
2611 g_return_if_fail (IS_DEBUGGER (debugger
));
2613 buff
= g_strdup_printf("-stack-list-arguments 0 %d %d", debugger
->priv
->current_frame
, debugger
->priv
->current_frame
);
2614 debugger_queue_command (debugger
, buff
, TRUE
, FALSE
, debugger_list_argument_finish
, callback
, user_data
);
2619 debugger_info_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2622 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2623 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2625 if (callback
!= NULL
)
2626 callback ((GList
*)cli_results
, user_data
, NULL
);
2630 debugger_info_frame (Debugger
*debugger
, guint frame
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2634 DEBUG_PRINT ("In function: debugger_info_frame()");
2636 g_return_if_fail (IS_DEBUGGER (debugger
));
2640 buff
= g_strdup_printf("info frame");
2644 buff
= g_strdup_printf ("info frame %d", frame
);
2646 debugger_queue_command (debugger
, buff
, TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2651 debugger_info_signal (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2653 DEBUG_PRINT ("In function: debugger_info_signal()");
2655 g_return_if_fail (IS_DEBUGGER (debugger
));
2657 debugger_queue_command (debugger
, "info signals", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2661 debugger_info_sharedlib (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2665 DEBUG_PRINT ("In function: debugger_info_sharedlib()");
2667 g_return_if_fail (IS_DEBUGGER (debugger
));
2669 buff
= g_strdup_printf ("info sharedlib");
2670 debugger_queue_command (debugger
, buff
, TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
); g_free (buff
);
2674 debugger_info_args (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2676 DEBUG_PRINT ("In function: debugger_info_args()");
2678 g_return_if_fail (IS_DEBUGGER (debugger
));
2680 debugger_queue_command (debugger
, "info args", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2684 debugger_info_target (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2686 DEBUG_PRINT ("In function: debugger_info_target()");
2688 g_return_if_fail (IS_DEBUGGER (debugger
));
2690 debugger_queue_command (debugger
, "info target", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2694 debugger_info_program (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2696 DEBUG_PRINT ("In function: debugger_info_program()");
2698 g_return_if_fail (IS_DEBUGGER (debugger
));
2700 debugger_queue_command (debugger
, "info program", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2704 debugger_info_udot (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2706 DEBUG_PRINT ("In function: debugger_info_udot()");
2708 g_return_if_fail (IS_DEBUGGER (debugger
));
2710 debugger_queue_command (debugger
, "info udot", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2714 debugger_info_variables (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2716 DEBUG_PRINT ("In function: debugger_info_variables()");
2718 g_return_if_fail (IS_DEBUGGER (debugger
));
2720 debugger_queue_command (debugger
, "info variables", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_info_finish
, callback
, user_data
);
2724 debugger_read_memory_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2727 const GDBMIValue
*literal
;
2728 const GDBMIValue
*mem
;
2735 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2736 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2737 IAnjutaDebuggerMemoryBlock read
= {0,};
2739 literal
= gdbmi_value_hash_lookup (mi_results
, "total-bytes");
2744 len
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 10);
2745 data
= g_new (gchar
, len
* 2);
2746 memset (data
+ len
, 0, len
);
2748 literal
= gdbmi_value_hash_lookup (mi_results
, "addr");
2749 address
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 0);
2753 mem
= gdbmi_value_hash_lookup (mi_results
, "memory");
2756 mem
= gdbmi_value_list_get_nth (mem
, 0);
2759 mem
= gdbmi_value_hash_lookup (mem
, "data");
2762 size
= gdbmi_value_get_size (mem
);
2767 if (size
< len
) len
= size
;
2768 for (i
= 0; i
< len
; i
++)
2770 literal
= gdbmi_value_list_get_nth (mem
, i
);
2774 value
= gdbmi_value_literal_get (literal
);
2775 *ptr
= strtoul (value
, &endptr
, 16);
2776 if ((*value
!= '\0') && (*endptr
== '\0'))
2784 read
.address
= address
;
2787 callback (&read
, user_data
, NULL
);
2793 callback (NULL
, user_data
, NULL
);
2798 debugger_inspect_memory (Debugger
*debugger
, gulong address
, guint length
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2802 DEBUG_PRINT ("In function: debugger_inspect_memory()");
2804 g_return_if_fail (IS_DEBUGGER (debugger
));
2806 buff
= g_strdup_printf ("-data-read-memory 0x%lx x 1 1 %d", address
, length
);
2807 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_read_memory_finish
, callback
, user_data
);
2812 debugger_disassemble_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
2815 const GDBMIValue
*literal
;
2816 const GDBMIValue
*line
;
2817 const GDBMIValue
*mem
;
2820 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
2821 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
2822 IAnjutaDebuggerInstructionDisassembly
*read
= NULL
;
2827 callback (NULL
, user_data
, error
);
2833 mem
= gdbmi_value_hash_lookup (mi_results
, "asm_insns");
2838 size
= gdbmi_value_get_size (mem
);
2839 read
= (IAnjutaDebuggerInstructionDisassembly
*)g_malloc0(sizeof (IAnjutaDebuggerInstructionDisassembly
) + sizeof(IAnjutaDebuggerInstructionALine
) * size
);
2842 for (i
= 0; i
< size
; i
++)
2844 line
= gdbmi_value_list_get_nth (mem
, i
);
2848 literal
= gdbmi_value_hash_lookup (line
, "address");
2851 value
= gdbmi_value_literal_get (literal
);
2852 read
->data
[i
].address
= strtoul (value
, NULL
, 0);
2855 /* Get label if one exist */
2856 literal
= gdbmi_value_hash_lookup (line
, "offset");
2859 value
= gdbmi_value_literal_get (literal
);
2860 if ((value
!= NULL
) && (strtoul (value
, NULL
, 0) == 0))
2862 literal
= gdbmi_value_hash_lookup (line
, "func-name");
2865 read
->data
[i
].label
= gdbmi_value_literal_get (literal
);
2872 /* Get disassembly line */
2873 literal
= gdbmi_value_hash_lookup (line
, "inst");
2876 read
->data
[i
].text
= gdbmi_value_literal_get (literal
);
2881 /* Remove last line to mark end */
2882 read
->data
[i
- 1].text
= NULL
;
2884 callback (read
, user_data
, NULL
);
2890 callback (NULL
, user_data
, NULL
);
2895 debugger_disassemble (Debugger
*debugger
, gulong address
, guint length
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
2900 DEBUG_PRINT ("In function: debugger_disassemble()");
2902 g_return_if_fail (IS_DEBUGGER (debugger
));
2905 /* Handle overflow */
2906 end
= (address
+ length
< address
) ? G_MAXULONG
: address
+ length
;
2907 buff
= g_strdup_printf ("-data-disassemble -s 0x%lx -e 0x%lx -- 0", address
, end
);
2908 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, debugger_disassemble_finish
, callback
, user_data
);
2913 parse_frame (IAnjutaDebuggerFrame
*frame
, const GDBMIValue
*frame_hash
)
2915 const GDBMIValue
*literal
;
2917 literal
= gdbmi_value_hash_lookup (frame_hash
, "level");
2919 frame
->level
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 10);
2923 literal
= gdbmi_value_hash_lookup (frame_hash
, "fullname");
2924 if (literal
== NULL
)
2925 literal
= gdbmi_value_hash_lookup (frame_hash
, "file");
2927 frame
->file
= (gchar
*)gdbmi_value_literal_get (literal
);
2931 literal
= gdbmi_value_hash_lookup (frame_hash
, "line");
2933 frame
->line
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 10);
2937 literal
= gdbmi_value_hash_lookup (frame_hash
, "func");
2939 frame
->function
= (gchar
*)gdbmi_value_literal_get (literal
);
2941 frame
->function
= NULL
;
2943 literal
= gdbmi_value_hash_lookup (frame_hash
, "from");
2945 frame
->library
= (gchar
*)gdbmi_value_literal_get (literal
);
2947 frame
->library
= NULL
;
2949 literal
= gdbmi_value_hash_lookup (frame_hash
, "addr");
2951 frame
->address
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 16);
2959 add_frame (const GDBMIValue
*frame_hash
, GdbGListPacket
* pack
)
2961 IAnjutaDebuggerFrame
* frame
;
2963 frame
= g_new0 (IAnjutaDebuggerFrame
, 1);
2964 pack
->list
= g_list_prepend (pack
->list
, frame
);
2966 frame
->thread
= pack
->tag
;
2967 parse_frame (frame
, frame_hash
);
2971 set_func_args (const GDBMIValue
*frame_hash
, GList
** node
)
2974 const GDBMIValue
*literal
, *args_list
, *arg_hash
;
2977 IAnjutaDebuggerFrame
* frame
;
2979 literal
= gdbmi_value_hash_lookup (frame_hash
, "level");
2983 level
= gdbmi_value_literal_get (literal
);
2987 frame
= (IAnjutaDebuggerFrame
*)(*node
)->data
;
2989 args_list
= gdbmi_value_hash_lookup (frame_hash
, "args");
2992 args_str
= g_string_new ("(");
2993 for (i
= 0; i
< gdbmi_value_get_size (args_list
); i
++)
2995 const gchar
*name
, *value
;
2997 arg_hash
= gdbmi_value_list_get_nth (args_list
, i
);
3001 literal
= gdbmi_value_hash_lookup (arg_hash
, "name");
3004 name
= gdbmi_value_literal_get (literal
);
3008 literal
= gdbmi_value_hash_lookup (arg_hash
, "value");
3011 value
= gdbmi_value_literal_get (literal
);
3014 args_str
= g_string_append (args_str
, name
);
3015 args_str
= g_string_append (args_str
, "=");
3016 args_str
= g_string_append (args_str
, value
);
3017 if (i
< (gdbmi_value_get_size (args_list
) - 1))
3018 args_str
= g_string_append (args_str
, ", ");
3020 args_str
= g_string_append (args_str
, ")");
3021 frame
->args
= args_str
->str
;
3022 g_string_free (args_str
, FALSE
);
3024 *node
= g_list_next (*node
);
3028 debugger_stack_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3031 GdbGListPacket pack
= {NULL
, 0};
3033 const GDBMIValue
*stack_list
;
3034 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3035 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3040 stack_list
= gdbmi_value_hash_lookup (mi_results
, "stack");
3043 pack
.tag
= debugger
->priv
->current_thread
;
3044 gdbmi_value_foreach (stack_list
, (GFunc
)add_frame
, &pack
);
3049 pack
.list
= g_list_reverse (pack
.list
);
3050 node
= g_list_first (pack
.list
);
3051 stack_list
= gdbmi_value_hash_lookup (mi_results
, "stack-args");
3053 gdbmi_value_foreach (stack_list
, (GFunc
)set_func_args
, &node
);
3055 // Call call back function
3056 if (callback
!= NULL
)
3057 callback (pack
.list
, user_data
, NULL
);
3060 for (node
= g_list_first (pack
.list
); node
!= NULL
; node
= g_list_next (node
))
3062 g_free ((gchar
*)((IAnjutaDebuggerFrame
*)node
->data
)->args
);
3063 g_free (node
->data
);
3066 g_list_free (pack
.list
);
3070 // Call call back function
3071 if (callback
!= NULL
)
3072 callback (NULL
, user_data
, NULL
);
3077 debugger_list_frame (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3079 DEBUG_PRINT ("In function: debugger_list_frame()");
3081 g_return_if_fail (IS_DEBUGGER (debugger
));
3083 debugger_queue_command (debugger
, "-stack-list-frames", TRUE
, TRUE
, NULL
, NULL
, NULL
);
3084 debugger_queue_command (debugger
, "-stack-list-arguments 1", TRUE
, FALSE
, debugger_stack_finish
, callback
, user_data
);
3088 *---------------------------------------------------------------------------*/
3091 debugger_set_thread_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3093 const GDBMIValue
*literal
;
3096 if (mi_results
== NULL
) return;
3098 literal
= gdbmi_value_hash_lookup (mi_results
, "new-thread-id");
3099 if (literal
== NULL
) return;
3101 id
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 10);
3102 if (id
== 0) return;
3104 debugger
->priv
->current_thread
= id
;
3105 g_signal_emit_by_name (debugger
->priv
->instance
, "frame-changed", 0, debugger
->priv
->current_thread
);
3111 debugger_set_thread (Debugger
*debugger
, gint thread
)
3115 DEBUG_PRINT ("In function: debugger_set_thread()");
3117 g_return_if_fail (IS_DEBUGGER (debugger
));
3119 buff
= g_strdup_printf ("-thread-select %d", thread
);
3121 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, (DebuggerParserFunc
)debugger_set_thread_finish
, NULL
, NULL
);
3126 add_thread_id (const GDBMIValue
*thread_hash
, GList
** list
)
3128 IAnjutaDebuggerFrame
* frame
;
3131 thread
= strtoul (gdbmi_value_literal_get (thread_hash
), NULL
, 10);
3132 if (thread
== 0) return;
3134 frame
= g_new0 (IAnjutaDebuggerFrame
, 1);
3135 *list
= g_list_prepend (*list
, frame
);
3137 frame
->thread
= thread
;
3141 debugger_list_thread_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3144 const GDBMIValue
*id_list
;
3145 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3146 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3147 GList
* thread_list
= NULL
;
3151 if (mi_results
== NULL
) break;
3153 id_list
= gdbmi_value_hash_lookup (mi_results
, "thread-ids");
3154 if (id_list
== NULL
) break;
3156 gdbmi_value_foreach (id_list
, (GFunc
)add_thread_id
, &thread_list
);
3157 thread_list
= g_list_reverse (thread_list
);
3161 if (callback
!= NULL
)
3162 callback (thread_list
, user_data
, error
);
3164 if (thread_list
!= NULL
)
3166 g_list_foreach (thread_list
, (GFunc
)g_free
, NULL
);
3167 g_list_free (thread_list
);
3172 debugger_list_thread (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3174 DEBUG_PRINT ("In function: debugger_list_thread()");
3176 g_return_if_fail (IS_DEBUGGER (debugger
));
3178 debugger_queue_command (debugger
, "-thread-list-ids", TRUE
, FALSE
, debugger_list_thread_finish
, callback
, user_data
);
3182 debugger_info_set_thread_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3184 const GDBMIValue
*literal
;
3187 if (mi_results
== NULL
) return;
3189 literal
= gdbmi_value_hash_lookup (mi_results
, "new-thread-id");
3190 if (literal
== NULL
) return;
3192 id
= strtoul (gdbmi_value_literal_get (literal
), NULL
, 10);
3193 if (id
== 0) return;
3195 debugger
->priv
->current_thread
= id
;
3196 /* Do not emit a signal notification as the current thread will
3197 * be restored when needed */
3203 debugger_info_thread_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3205 const GDBMIValue
*frame
;
3206 IAnjutaDebuggerFrame top_frame
;
3207 IAnjutaDebuggerFrame
*top
;
3208 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3209 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3213 DEBUG_PRINT("look for stack %p", mi_results
);
3214 if (mi_results
== NULL
) break;
3216 frame
= gdbmi_value_hash_lookup (mi_results
, "stack");
3217 if (frame
== NULL
) break;
3219 DEBUG_PRINT("get stack");
3221 frame
= gdbmi_value_list_get_nth (frame
, 0);
3222 if (frame
== NULL
) break;
3224 DEBUG_PRINT("get nth element");
3226 /*frame = gdbmi_value_hash_lookup (frame, "frame");
3227 DEBUG_PRINT("get frame %p", frame);
3228 if (frame == NULL) break;*/
3230 DEBUG_PRINT("get frame");
3233 top
->thread
= debugger
->priv
->current_thread
;
3235 parse_frame (top
, frame
);
3239 if (callback
!= NULL
)
3240 callback (top
, user_data
, error
);
3246 debugger_info_thread (Debugger
*debugger
, gint thread
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3251 DEBUG_PRINT ("In function: debugger_info_thread()");
3253 g_return_if_fail (IS_DEBUGGER (debugger
));
3255 orig_thread
= debugger
->priv
->current_thread
;
3256 buff
= g_strdup_printf ("-thread-select %d", thread
);
3257 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, (DebuggerParserFunc
)debugger_info_set_thread_finish
, NULL
, NULL
);
3259 debugger_queue_command (debugger
, "-stack-list-frames 0 0", FALSE
, FALSE
, (DebuggerParserFunc
)debugger_info_thread_finish
, callback
, user_data
);
3261 buff
= g_strdup_printf ("-thread-select %d", orig_thread
);
3262 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, (DebuggerParserFunc
)debugger_info_set_thread_finish
, NULL
, NULL
);
3267 add_register_name (const GDBMIValue
*reg_literal
, GList
** list
)
3269 IAnjutaDebuggerRegisterData
* reg
;
3270 GList
*prev
= *list
;
3272 reg
= g_new0 (IAnjutaDebuggerRegisterData
, 1);
3273 *list
= g_list_prepend (prev
, reg
);
3274 reg
->name
= (gchar
*)gdbmi_value_literal_get (reg_literal
);
3275 reg
->num
= prev
== NULL
? 0 : ((IAnjutaDebuggerRegisterData
*)prev
->data
)->num
+ 1;
3279 add_register_value (const GDBMIValue
*reg_hash
, GList
** list
)
3281 const GDBMIValue
*literal
;
3283 IAnjutaDebuggerRegisterData
* reg
;
3285 GList
* prev
= *list
;
3287 literal
= gdbmi_value_hash_lookup (reg_hash
, "number");
3290 val
= gdbmi_value_literal_get (literal
);
3291 num
= strtoul (val
, NULL
, 10);
3293 literal
= gdbmi_value_hash_lookup (reg_hash
, "value");
3297 reg
= g_new0 (IAnjutaDebuggerRegisterData
, 1);
3298 *list
= g_list_prepend (prev
, reg
);
3300 reg
->value
= (gchar
*)gdbmi_value_literal_get (literal
);
3304 debugger_register_name_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3309 const GDBMIValue
*reg_list
;
3310 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3311 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3316 reg_list
= gdbmi_value_hash_lookup (mi_results
, "register-names");
3318 gdbmi_value_foreach (reg_list
, (GFunc
)add_register_name
, &list
);
3319 list
= g_list_reverse (list
);
3321 // Call call back function
3322 if (callback
!= NULL
)
3323 callback (list
, user_data
, NULL
);
3326 for (node
= g_list_first (list
); node
!= NULL
; node
= g_list_next (node
))
3328 g_free (node
->data
);
3334 debugger_register_value_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3339 const GDBMIValue
*reg_list
;
3340 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3341 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3346 reg_list
= gdbmi_value_hash_lookup (mi_results
, "register-values");
3348 gdbmi_value_foreach (reg_list
, (GFunc
)add_register_value
, &list
);
3349 list
= g_list_reverse (list
);
3351 // Call call back function
3352 if (callback
!= NULL
)
3353 callback (list
, user_data
, NULL
);
3356 for (node
= g_list_first (list
); node
!= NULL
; node
= g_list_next (node
))
3358 g_free (node
->data
);
3364 debugger_list_register (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3366 DEBUG_PRINT ("In function: debugger_list_register()");
3368 g_return_if_fail (IS_DEBUGGER (debugger
));
3370 debugger_queue_command (debugger
, "-data-list-register-names", TRUE
, FALSE
, debugger_register_name_finish
, callback
, user_data
);
3374 debugger_update_register (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3376 DEBUG_PRINT ("In function: debugger_update_register()");
3378 g_return_if_fail (IS_DEBUGGER (debugger
));
3380 debugger_queue_command (debugger
, "-data-list-register-values r", TRUE
, FALSE
, (DebuggerParserFunc
)debugger_register_value_finish
, callback
, user_data
);
3384 debugger_write_register (Debugger
*debugger
, const gchar
*name
, const gchar
*value
)
3388 DEBUG_PRINT ("In function: debugger_write_register()");
3390 g_return_if_fail (IS_DEBUGGER (debugger
));
3392 buf
= g_strdup_printf ("-data-evaluate-expression \"$%s=%s\"", name
, value
);
3393 debugger_queue_command (debugger
, buf
, TRUE
, FALSE
, NULL
, NULL
, NULL
);
3398 debugger_set_frame_finish (Debugger
*debugger
, const GDBMIValue
*mi_results
, const GList
*cli_results
, GError
*error
)
3401 guint frame
= (guint
)debugger
->priv
->current_cmd
.user_data
;
3402 debugger
->priv
->current_frame
= frame
;
3404 g_signal_emit_by_name (debugger
->priv
->instance
, "frame-changed", frame
, debugger
->priv
->current_thread
);
3408 debugger_set_frame (Debugger
*debugger
, guint frame
)
3412 DEBUG_PRINT ("In function: debugger_set_frame()");
3414 g_return_if_fail (IS_DEBUGGER (debugger
));
3416 buff
= g_strdup_printf ("-stack-select-frame %d", frame
);
3418 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, (DebuggerParserFunc
)debugger_set_frame_finish
, NULL
, (gpointer
)frame
);
3423 debugger_set_log (Debugger
*debugger
, IAnjutaMessageView
*log
)
3425 debugger
->priv
->log
= log
;
3428 /* Variable objects functions
3429 *---------------------------------------------------------------------------*/
3432 debugger_delete_variable (Debugger
*debugger
, const gchar
* name
)
3436 DEBUG_PRINT ("In function: delete_variable()");
3438 g_return_if_fail (IS_DEBUGGER (debugger
));
3440 buff
= g_strdup_printf ("-var-delete %s", name
);
3441 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
3446 gdb_var_evaluate_expression (Debugger
*debugger
,
3447 const GDBMIValue
*mi_results
, const GList
*cli_results
,
3450 const gchar
*value
= NULL
;
3451 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3452 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3454 if (mi_results
!= NULL
)
3456 const GDBMIValue
*const gdbmi_value
=
3457 gdbmi_value_hash_lookup (mi_results
, "value");
3459 if (gdbmi_value
!= NULL
)
3460 value
= gdbmi_value_literal_get (gdbmi_value
);
3462 callback ((const gpointer
)value
, user_data
, NULL
);
3466 debugger_evaluate_variable (Debugger
*debugger
, const gchar
* name
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3470 DEBUG_PRINT ("In function: evaluate_variable()");
3472 g_return_if_fail (IS_DEBUGGER (debugger
));
3474 buff
= g_strdup_printf ("-var-evaluate-expression %s", name
);
3475 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, gdb_var_evaluate_expression
, callback
, user_data
);
3480 debugger_assign_variable (Debugger
*debugger
, const gchar
* name
, const gchar
*value
)
3484 DEBUG_PRINT ("In function: assign_variable()");
3486 g_return_if_fail (IS_DEBUGGER (debugger
));
3488 buff
= g_strdup_printf ("-var-assign %s %s", name
, value
);
3489 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, NULL
, NULL
, NULL
);
3494 gdb_var_list_children (Debugger
*debugger
,
3495 const GDBMIValue
*mi_results
, const GList
*cli_results
,
3499 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3500 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3502 if (mi_results
!= NULL
)
3504 const GDBMIValue
*literal
;
3505 const GDBMIValue
*children
;
3509 literal
= gdbmi_value_hash_lookup (mi_results
, "numchild");
3512 numchild
= strtoul(gdbmi_value_literal_get (literal
), NULL
, 0);
3513 children
= gdbmi_value_hash_lookup (mi_results
, "children");
3515 for(i
= 0 ; i
< numchild
; ++i
)
3517 const GDBMIValue
*const gdbmi_chl
=
3518 gdbmi_value_list_get_nth (children
, i
);
3519 IAnjutaDebuggerVariableObject
*var
;
3521 var
= g_new0 (IAnjutaDebuggerVariableObject
, 1);
3523 literal
= gdbmi_value_hash_lookup (gdbmi_chl
, "name");
3525 var
->name
= (gchar
*)gdbmi_value_literal_get (literal
);
3527 literal
= gdbmi_value_hash_lookup (gdbmi_chl
, "exp");
3529 var
->expression
= (gchar
*)gdbmi_value_literal_get(literal
);
3531 literal
= gdbmi_value_hash_lookup (gdbmi_chl
, "type");
3533 var
->type
= (gchar
*)gdbmi_value_literal_get(literal
);
3535 literal
= gdbmi_value_hash_lookup (gdbmi_chl
, "value");
3537 var
->value
= (gchar
*)gdbmi_value_literal_get(literal
);
3539 literal
= gdbmi_value_hash_lookup (gdbmi_chl
, "numchild");
3541 var
->children
= strtoul(gdbmi_value_literal_get(literal
), NULL
, 10);
3543 list
= g_list_prepend (list
, var
);
3545 list
= g_list_reverse (list
);
3548 callback (list
, user_data
, NULL
);
3549 g_list_foreach (list
, (GFunc
)g_free
, NULL
);
3553 void debugger_list_variable_children (Debugger
*debugger
, const gchar
* name
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3557 DEBUG_PRINT ("In function: list_variable_children()");
3559 g_return_if_fail (IS_DEBUGGER (debugger
));
3561 buff
= g_strdup_printf ("-var-list-children --all-values %s", name
);
3562 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, gdb_var_list_children
, callback
, user_data
);
3567 gdb_var_create (Debugger
*debugger
,
3568 const GDBMIValue
*mi_results
, const GList
*cli_results
,
3571 const GDBMIValue
* result
;
3572 IAnjutaDebuggerVariableObject var
= {0,};
3573 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3574 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3576 if ((error
== NULL
) && (mi_results
!= NULL
))
3578 result
= gdbmi_value_hash_lookup (mi_results
, "name");
3579 var
.name
= (gchar
*)gdbmi_value_literal_get(result
);
3581 result
= gdbmi_value_hash_lookup (mi_results
, "type");
3582 var
.type
= (gchar
*)gdbmi_value_literal_get (result
);
3584 result
= gdbmi_value_hash_lookup (mi_results
, "numchild");
3585 var
.children
= strtoul (gdbmi_value_literal_get(result
), NULL
, 10);
3587 callback (&var
, user_data
, error
);
3591 void debugger_create_variable (Debugger
*debugger
, const gchar
* name
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3595 DEBUG_PRINT ("In function: create_variable()");
3597 g_return_if_fail (IS_DEBUGGER (debugger
));
3599 buff
= g_strdup_printf ("-var-create - * %s", name
);
3600 debugger_queue_command (debugger
, buff
, FALSE
, FALSE
, gdb_var_create
, callback
, user_data
);
3605 gdb_var_update (Debugger
*debugger
,
3606 const GDBMIValue
*mi_results
, const GList
*cli_results
,
3610 glong idx
= 0, changed_count
= 0;
3611 const GDBMIValue
*const gdbmi_changelist
=
3612 gdbmi_value_hash_lookup (mi_results
, "changelist");
3613 IAnjutaDebuggerCallback callback
= debugger
->priv
->current_cmd
.callback
;
3614 gpointer user_data
= debugger
->priv
->current_cmd
.user_data
;
3617 changed_count
= gdbmi_value_get_size (gdbmi_changelist
);
3618 for(; idx
<changed_count
; ++idx
)
3620 const GDBMIValue
*const gdbmi_change
=
3621 gdbmi_value_list_get_nth (gdbmi_changelist
, idx
);
3622 const GDBMIValue
* value
;
3625 value
= gdbmi_value_hash_lookup (gdbmi_change
, "name");
3628 IAnjutaDebuggerVariableObject
*var
= g_new0 (IAnjutaDebuggerVariableObject
, 1);
3629 var
->changed
= TRUE
;
3630 var
->name
= (gchar
*)gdbmi_value_literal_get(value
);
3631 list
= g_list_prepend (list
, var
);
3633 value
= gdbmi_value_hash_lookup (gdbmi_change
, "type_changed");
3636 const gchar
*type_changed
= gdbmi_value_literal_get (value
);
3638 if (strcmp (type_changed
, "true"))
3640 var
->deleted
= TRUE
;
3644 value
= gdbmi_value_hash_lookup (gdbmi_change
, "in_scope");
3647 const gchar
*in_scope
= gdbmi_value_literal_get(value
);
3649 if (strcmp (in_scope
, "false") == 0)
3653 else if (strcmp (in_scope
, "invalid") == 0)
3655 var
->deleted
= TRUE
;
3660 list
= g_list_reverse (list
);
3661 callback (list
, user_data
, NULL
);
3662 g_list_foreach (list
, (GFunc
)g_free
, NULL
);
3666 void debugger_update_variable (Debugger
*debugger
, IAnjutaDebuggerCallback callback
, gpointer user_data
)
3668 DEBUG_PRINT ("In function: update_variable()");
3670 g_return_if_fail (IS_DEBUGGER (debugger
));
3672 debugger_queue_command (debugger
, "-var-update *", FALSE
, FALSE
, gdb_var_update
, callback
, user_data
);
3676 debugger_get_type (void)
3678 static GType obj_type
= 0;
3682 static const GTypeInfo obj_info
=
3684 sizeof (DebuggerClass
),
3685 (GBaseInitFunc
) NULL
,
3686 (GBaseFinalizeFunc
) NULL
,
3687 (GClassInitFunc
) debugger_class_init
,
3688 (GClassFinalizeFunc
) NULL
,
3689 NULL
, /* class_data */
3691 0, /* n_preallocs */
3692 (GInstanceInitFunc
) debugger_instance_init
,
3693 NULL
/* value_table */
3695 obj_type
= g_type_register_static (G_TYPE_OBJECT
,
3696 "Debugger", &obj_info
, 0);
3702 debugger_dispose (GObject
*obj
)
3704 Debugger
*debugger
= DEBUGGER (obj
);
3706 DEBUG_PRINT ("In function: debugger_shutdown()");
3708 /* Do not emit signal when the debugger is destroyed */
3709 debugger
->priv
->instance
= NULL
;
3710 debugger_abort (debugger
);
3712 /* Good Bye message */
3713 if (debugger
->priv
->output_callback
)
3715 debugger
->priv
->output_callback (IANJUTA_DEBUGGER_OUTPUT
,
3716 "Debugging session completed.\n",
3717 debugger
->priv
->output_user_data
);
3720 if (debugger
->priv
->launcher
)
3722 anjuta_launcher_reset (debugger
->priv
->launcher
);
3723 g_object_unref (debugger
->priv
->launcher
);
3724 debugger
->priv
->launcher
= NULL
;
3727 GNOME_CALL_PARENT (G_OBJECT_CLASS
, dispose
, (obj
));
3731 debugger_finalize (GObject
*obj
)
3733 Debugger
*debugger
= DEBUGGER (obj
);
3734 g_string_free (debugger
->priv
->stdo_line
, TRUE
);
3735 g_string_free (debugger
->priv
->stdo_acc
, TRUE
);
3736 g_string_free (debugger
->priv
->stde_line
, TRUE
);
3737 g_free (debugger
->priv
);
3738 GNOME_CALL_PARENT (G_OBJECT_CLASS
, finalize
, (obj
));
3742 debugger_class_init (DebuggerClass
* klass
)
3744 GObjectClass
*object_class
;
3746 g_return_if_fail (klass
!= NULL
);
3747 object_class
= G_OBJECT_CLASS (klass
);
3749 DEBUG_PRINT ("Initializing debugger class");
3751 parent_class
= g_type_class_peek_parent (klass
);
3752 object_class
->dispose
= debugger_dispose
;
3753 object_class
->finalize
= debugger_finalize
;
3759 debugger_signal (const gchar
*sig
, gboolean show_msg
)
3761 /* eg:- "SIGTERM" */
3765 DEBUG_PRINT ("In function: debugger_signal()");
3767 if (debugger_is_active () == FALSE
)
3769 if (debugger
.prog_is_running
== FALSE
)
3771 if (debugger
.child_pid
< 1)
3773 DEBUG_PRINT ("Not sending signal - pid not known\n");
3779 buff
= g_strdup_printf (_("Sending signal %s to the process: %d"),
3780 sig
, (int) debugger
.child_pid
);
3781 gdb_util_append_message (ANJUTA_PLUGIN (debugger
.plugin
), buff
);
3785 if (debugger_is_ready ())
3787 cmd
= g_strconcat ("signal ", sig
, NULL
);
3788 stack_trace_set_frame (debugger
.stack
, 0);
3789 debugger_put_cmd_in_queqe (cmd
, DB_CMD_ALL
, NULL
, NULL
);
3790 debugger_put_cmd_in_queqe ("info program", DB_CMD_NONE
,
3791 on_debugger_update_prog_status
,
3794 debugger_execute_cmd_in_queqe ();
3801 parent
= GTK_WINDOW (ANJUTA_PLUGIN (debugger
.plugin
)->shell
);
3802 status
= gdb_util_kill_process (debugger
.child_pid
, sig
);
3803 if (status
!= 0 && show_msg
)
3804 anjuta_util_dialog_error (parent
,
3805 _("Error whilst signaling the process."));
3810 query_set_cmd (const gchar
*cmd
, gboolean state
)
3813 gchar
*tmp
= g_stpcpy (buffer
, cmd
);
3814 strcpy (tmp
, state
? "on" : "off");
3815 debugger_put_cmd_in_queqe (buffer
, DB_CMD_NONE
, NULL
, NULL
);
3819 query_set_verbose (gboolean state
)
3821 query_set_cmd ("set verbose ", state
);
3825 query_set_print_staticmembers (gboolean state
)
3827 query_set_cmd ("set print static-members ", state
);
3831 query_set_print_pretty (gboolean state
)
3833 query_set_cmd ("set print pretty ", state
);
3836 void debugger_query_evaluate_expr_tip (const gchar
*expr
,
3837 DebuggerCLIFunc parser
, gpointer data
)
3839 query_set_verbose (FALSE
);
3840 query_set_print_staticmembers (FALSE
);
3841 gchar
*printcmd
= g_strconcat ("print ", expr
, NULL
);
3842 debugger_put_cmd_in_queqe (printcmd
, DB_CMD_NONE
, parser
, data
);
3843 query_set_verbose (TRUE
);
3844 query_set_print_staticmembers (TRUE
);
3849 debugger_query_evaluate_expression (const gchar
*expr
, DebuggerFunc parser
,
3852 query_set_print_pretty (TRUE
);
3853 query_set_verbose (FALSE
);
3854 gchar
*printcmd
= g_strconcat ("print ", expr
, NULL
);
3855 debugger_put_cmd_in_queqe (printcmd
, DB_CMD_SE_MESG
| DB_CMD_SE_DIALOG
,
3857 query_set_print_pretty (FALSE
);
3858 query_set_verbose (TRUE
);