1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2005 Sebastien Granjoux
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program as distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * Implement the IAnjutaDebugger interface.
28 #include <libanjuta/anjuta-debug.h>
32 #include <glib/gi18n.h>
33 #include <sys/types.h>
37 #include "preferences.h"
39 #include <libanjuta/interfaces/ianjuta-debugger.h>
40 #include <libanjuta/interfaces/ianjuta-debugger-breakpoint.h>
41 #include <libanjuta/interfaces/ianjuta-debugger-register.h>
42 #include <libanjuta/interfaces/ianjuta-debugger-memory.h>
43 #include <libanjuta/interfaces/ianjuta-debugger-instruction.h>
44 #include <libanjuta/interfaces/ianjuta-debugger-variable.h>
45 #include <libanjuta/interfaces/ianjuta-terminal.h>
46 #include <libanjuta/interfaces/ianjuta-preferences.h>
47 #include <libanjuta/anjuta-plugin.h>
51 *---------------------------------------------------------------------------*/
60 /* Output callback data */
61 IAnjutaDebuggerOutputCallback output_callback
;
62 gpointer output_user_data
;
64 /* Log message window */
65 IAnjutaMessageView
*view
;
70 /* Pretty printer list */
71 GList
*pretty_printers
;
74 struct _GdbPluginClass
76 AnjutaPluginClass parent_class
;
79 #define UNIMPLEMENTED G_STMT_START { g_warning (G_STRLOC": unimplemented"); } G_STMT_END
82 *---------------------------------------------------------------------------*/
84 #define PREF_SCHEMA "org.gnome.anjuta.plugins.run"
85 #define PREF_TERMINAL_COMMAND "terminal-command"
88 gdb_plugin_stop_terminal (GdbPlugin
* plugin
)
90 DEBUG_PRINT ("%s", "In function: gdb_plugin_stop_terminal()");
92 if (plugin
->term_pid
> 0) {
93 kill (plugin
->term_pid
, SIGTERM
);
94 plugin
->term_pid
= -1;
99 gdb_plugin_start_terminal (GdbPlugin
* plugin
)
103 IAnjutaTerminal
*term
;
105 DEBUG_PRINT ("In function: gdb_plugin_start_terminal() previous pid %d", plugin
->term_pid
);
107 /* Close previous terminal if needed */
108 gdb_plugin_stop_terminal (plugin
);
110 /* Check if anjuta launcher is here */
111 if (anjuta_util_prog_is_installed ("anjuta-launcher", TRUE
) == FALSE
)
116 file
= anjuta_util_get_a_tmp_file();
117 if (mkfifo (file
, 0664) < 0)
119 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
120 _("Failed to create FIFO file named %s. The program will run without a terminal."), file
);
126 /* Launch terminal */
127 cmd
= g_strconcat ("anjuta-launcher --__debug_terminal ", file
, NULL
);
129 /* Get terminal plugin */
130 term
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
, IAnjutaTerminal
, NULL
);
133 /* Use gnome terminal or another user defined one */
138 settings
= g_settings_new (PREF_SCHEMA
);
140 term_cmd
= g_settings_get_string (settings
, PREF_TERMINAL_COMMAND
);
141 g_object_unref (settings
);
142 if (g_shell_parse_argv (term_cmd
, NULL
, &argv
, NULL
))
147 /* Replace %s by command */
148 for (arg
= argv
; *arg
!= NULL
; arg
++)
150 if (strcmp(*arg
, "%s") == 0)
157 if (g_spawn_async (NULL
, argv
, NULL
, G_SPAWN_SEARCH_PATH
, NULL
, NULL
, &gpid
, NULL
))
159 plugin
->term_pid
= gpid
;
163 plugin
->term_pid
= -1;
169 plugin
->term_pid
= -1;
175 /* Use Anjuta terminal plugin */
176 plugin
->term_pid
= ianjuta_terminal_execute_command (term
, NULL
, cmd
, NULL
, NULL
);
180 if (plugin
->term_pid
> 0)
183 * Warning: call to fopen() may be blocked if the terminal is
184 * not properly started. I don't know how to handle this. May
185 * be opening as non-blocking will solve this .
187 g_file_get_contents (file
, &tty
, NULL
, NULL
); /* Ok, take the risk. */
190 g_strchomp (tty
); /* anjuta_launcher add a end of line after the terminal name */
191 if (strcmp(tty
, "__ERROR__") == 0)
203 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
204 _("Cannot start terminal for debugging."));
205 gdb_plugin_stop_terminal (plugin
);
212 *---------------------------------------------------------------------------*/
215 on_debugger_stopped (GdbPlugin
*self
, GError
*err
)
217 if (self
->debugger
!= NULL
)
219 g_signal_handlers_disconnect_by_func (self
, G_CALLBACK (on_debugger_stopped
), self
);
220 debugger_free (self
->debugger
);
221 self
->debugger
= NULL
;
222 gdb_plugin_stop_terminal (self
);
227 gdb_plugin_initialize (GdbPlugin
*this)
231 /* debugger can be not NULL, if initialize is called several times
232 * or if debugger_stopped signal has not been emitted */
233 if (this->debugger
!= NULL
)
235 on_debugger_stopped (this, NULL
);
238 parent
= GTK_WINDOW (ANJUTA_PLUGIN (this)->shell
);
239 this->debugger
= debugger_new (parent
, G_OBJECT (this));
240 g_signal_connect_swapped (this, "debugger-stopped", G_CALLBACK (on_debugger_stopped
), this);
241 debugger_set_output_callback (this->debugger
, this->output_callback
, this->output_user_data
);
242 if (this->view
) debugger_set_log (this->debugger
, this->view
);
244 debugger_set_pretty_printers (this->debugger
, this->pretty_printers
);
248 *---------------------------------------------------------------------------*/
251 quote_expression (const gchar
*expression
) {
256 /* This part is for expressions with an actual \" inside */
257 regex
= g_regex_new ("\\\\\"", G_REGEX_MULTILINE
, 0, NULL
);
258 aux
= g_regex_replace_literal (regex
, expression
, -1, 0, "\\\\\\\"", 0, NULL
);
259 g_regex_unref (regex
);
261 /* This part is for expressions with an " inside */
262 regex
= g_regex_new ("(?<!\\\\)\"", G_REGEX_MULTILINE
, 0, NULL
);
263 aux2
= g_regex_replace_literal (regex
, aux
, -1, 0, "\\\"", 0, NULL
);
264 g_regex_unref (regex
);
267 /* Converts newlines in spaces */
268 g_strdelimit (aux2
, "\n", ' ');
269 quoted
= g_strconcat ("\"",aux2
, "\"", NULL
);
275 /* Callback for saving session
276 *---------------------------------------------------------------------------*/
279 on_session_save (AnjutaShell
*shell
, AnjutaSessionPhase phase
, AnjutaSession
*session
, GdbPlugin
*this)
281 if (phase
!= ANJUTA_SESSION_PHASE_NORMAL
)
284 gdb_save_pretty_printers (session
, this->pretty_printers
);
287 static void on_session_load (AnjutaShell
*shell
, AnjutaSessionPhase phase
, AnjutaSession
*session
, GdbPlugin
*this)
289 if (phase
!= ANJUTA_SESSION_PHASE_NORMAL
)
292 g_list_foreach (this->pretty_printers
, (GFunc
)gdb_pretty_printer_free
, NULL
);
293 g_list_free (this->pretty_printers
);
294 this->pretty_printers
= gdb_load_pretty_printers (session
);
297 /* AnjutaPlugin functions
298 *---------------------------------------------------------------------------*/
301 gdb_plugin_activate_plugin (AnjutaPlugin
* plugin
)
303 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
305 DEBUG_PRINT ("%s", "GDB: Activating Gdb plugin...");
306 this->pretty_printers
= NULL
;
308 /* Connect to session signal */
309 g_signal_connect (plugin
->shell
, "save-session",
310 G_CALLBACK (on_session_save
), this);
311 g_signal_connect (plugin
->shell
, "load-session",
312 G_CALLBACK (on_session_load
), this);
319 gdb_plugin_deactivate_plugin (AnjutaPlugin
* plugin
)
321 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
323 DEBUG_PRINT ("%s", "GDB: Deactivating Gdb plugin...");
325 if (this->debugger
!= NULL
)
327 debugger_free (this->debugger
);
328 this->debugger
= NULL
;
331 g_list_foreach (this->pretty_printers
, (GFunc
)gdb_pretty_printer_free
, NULL
);
332 g_list_free (this->pretty_printers
);
333 this->pretty_printers
= NULL
;
339 *---------------------------------------------------------------------------*/
341 /* Used in dispose and finalize */
342 static gpointer parent_class
;
344 /* instance_init is the constructor. All functions should work after this
348 gdb_plugin_instance_init (GObject
* obj
)
350 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (obj
);
352 this->debugger
= NULL
;
353 this->output_callback
= NULL
;
357 /* dispose is the first destruction step. It is used to unref object created
358 * with instance_init in order to break reference counting cycles. This
359 * function could be called several times. All function should still work
360 * after this call. It has to called its parents.*/
363 gdb_plugin_dispose (GObject
* obj
)
365 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (obj
);
367 if (this->debugger
!= NULL
)
369 debugger_free (this->debugger
);
370 this->debugger
= NULL
;
372 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
375 /* finalize is the last destruction step. It must free all memory allocated
376 * with instance_init. It is called only one time just before releasing all
380 gdb_plugin_finalize (GObject
* obj
)
382 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
385 /* class_init intialize the class itself not the instance */
388 gdb_plugin_class_init (GObjectClass
* klass
)
390 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
392 parent_class
= g_type_class_peek_parent (klass
);
394 plugin_class
->activate
= gdb_plugin_activate_plugin
;
395 plugin_class
->deactivate
= gdb_plugin_deactivate_plugin
;
396 klass
->dispose
= gdb_plugin_dispose
;
397 klass
->finalize
= gdb_plugin_finalize
;
400 /* Implementation of IAnjutaDebugger interface
401 *---------------------------------------------------------------------------*/
403 static IAnjutaDebuggerState
404 idebugger_get_state (IAnjutaDebugger
*plugin
, GError
**err
)
406 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
408 if (this->debugger
== NULL
)
410 return IANJUTA_DEBUGGER_STOPPED
;
414 return debugger_get_state (this->debugger
);
420 idebugger_load (IAnjutaDebugger
*plugin
, const gchar
*file
, const gchar
* mime_type
,
421 const GList
*search_dirs
, GError
**err
)
423 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
424 gboolean is_libtool
= FALSE
;
426 /* Check allowed mime type */
427 if (mime_type
== NULL
)
429 /* Hope that the target is supported */
431 else if ((strcmp (mime_type
, "application/x-executable") == 0) ||
432 (strcmp (mime_type
, "application/octet-stream") == 0))
434 /* Supported target */
436 else if (strcmp (mime_type
, "application/x-shellscript") == 0)
438 /* FIXME: We should really do more checks to confirm that
439 * this target is indeed libtool target
443 else if (strcmp (mime_type
, "application/x-core") == 0)
445 /* Supported target */
449 /* Not supported target */
454 gdb_plugin_initialize (this);
456 return debugger_start (this->debugger
, search_dirs
, file
, is_libtool
);
460 idebugger_unload (IAnjutaDebugger
*plugin
, GError
**err
)
462 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
464 debugger_stop (this->debugger
);
470 idebugger_set_working_directory (IAnjutaDebugger
*plugin
, const gchar
*directory
, GError
**err
)
472 GdbPlugin
*self
= ANJUTA_PLUGIN_GDB (plugin
);
474 debugger_set_working_directory (self
->debugger
, directory
);
480 idebugger_set_environment (IAnjutaDebugger
*plugin
, gchar
**variables
, GError
**err
)
482 GdbPlugin
*self
= ANJUTA_PLUGIN_GDB (plugin
);
484 debugger_set_environment (self
->debugger
, variables
);
490 idebugger_attach (IAnjutaDebugger
*plugin
, pid_t pid
, const GList
*search_dirs
, GError
**err
)
492 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
495 gdb_plugin_initialize (this);
496 debugger_start (this->debugger
, search_dirs
, NULL
, FALSE
);
497 debugger_attach_process (this->debugger
, pid
);
503 idebugger_start (IAnjutaDebugger
*plugin
, const gchar
*argument
, gboolean terminal
, gboolean stop
, GError
**err
)
505 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
508 tty
= terminal
? gdb_plugin_start_terminal (this) : NULL
;
509 debugger_start_program (this->debugger
, NULL
, argument
, tty
, stop
);
516 idebugger_connect (IAnjutaDebugger
*plugin
, const gchar
*server
, const gchar
*argument
, gboolean terminal
, gboolean stop
, GError
**err
)
518 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
521 tty
= terminal
? gdb_plugin_start_terminal (this) : NULL
;
522 debugger_start_program (this->debugger
, server
, argument
, tty
, stop
);
529 idebugger_quit (IAnjutaDebugger
*plugin
, GError
**err
)
531 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
533 if (!debugger_stop (this->debugger
))
535 DEBUG_PRINT ("%s", "set error");
536 g_set_error (err
, IANJUTA_DEBUGGER_ERROR
, IANJUTA_DEBUGGER_CANCEL
, "Command cancelled by user");
547 idebugger_abort (IAnjutaDebugger
*plugin
, GError
**err
)
549 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
551 DEBUG_PRINT ("%s", "idebugger abort\n");
552 if (!debugger_abort (this->debugger
))
554 g_set_error (err
, IANJUTA_DEBUGGER_ERROR
, IANJUTA_DEBUGGER_CANCEL
, "Command cancelled by user");
565 idebugger_run (IAnjutaDebugger
*plugin
, GError
**err
)
567 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
569 debugger_run (this->debugger
);
575 idebugger_step_in (IAnjutaDebugger
*plugin
, GError
**err
)
577 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
579 debugger_step_in (this->debugger
);
585 idebugger_step_over (IAnjutaDebugger
*plugin
, GError
**err
)
587 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
589 debugger_step_over (this->debugger
);
595 idebugger_run_to (IAnjutaDebugger
*plugin
, const gchar
* file
,
596 gint line
, GError
**err
)
598 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
600 debugger_run_to_position (this->debugger
, file
, line
);
606 idebugger_step_out (IAnjutaDebugger
*plugin
, GError
**err
)
608 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
610 debugger_step_out (this->debugger
);
616 idebugger_exit (IAnjutaDebugger
*plugin
, GError
**err
)
618 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
620 debugger_stop_program (this->debugger
);
626 idebugger_interrupt (IAnjutaDebugger
*plugin
, GError
**err
)
628 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
630 debugger_interrupt (this->debugger
);
636 idebugger_inspect (IAnjutaDebugger
*plugin
, const gchar
*name
, IAnjutaDebuggerGCharCallback callback
, gpointer user_data
, GError
**err
)
638 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
640 debugger_evaluate (this->debugger
, name
, callback
, user_data
);
646 idebugger_evaluate (IAnjutaDebugger
*plugin
, const gchar
*name
, const gchar
*value
, IAnjutaDebuggerGCharCallback callback
, gpointer user_data
, GError
**err
)
648 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
651 buf
= g_strconcat ("\"", name
, " = ", value
, "\"", NULL
);
652 debugger_evaluate (this->debugger
, buf
, callback
, user_data
);
659 idebugger_send_command (IAnjutaDebugger
*plugin
, const gchar
* command
, GError
**err
)
661 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
663 debugger_command (this->debugger
, command
, FALSE
, NULL
, NULL
);
669 idebugger_print (IAnjutaDebugger
*plugin
, const gchar
* variable
, IAnjutaDebuggerGCharCallback callback
, gpointer user_data
, GError
**err
)
671 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
673 debugger_print (this->debugger
, variable
, callback
, user_data
);
679 idebugger_list_local (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
681 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
683 debugger_list_local (this->debugger
, callback
, user_data
);
689 idebugger_list_argument (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
691 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
693 debugger_list_argument (this->debugger
, callback
, user_data
);
699 idebugger_info_signal (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
701 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
703 debugger_info_signal (this->debugger
, callback
, user_data
);
709 idebugger_info_sharedlib (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
711 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
713 debugger_info_sharedlib (this->debugger
, callback
, user_data
);
719 idebugger_handle_signal (IAnjutaDebugger
*plugin
, const gchar
* name
, gboolean stop
, gboolean print
, gboolean ignore
, GError
**err
)
722 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
724 cmd
= g_strdup_printf("handle %s %sstop %sprint %spass", name
, stop
? "" : "no", print
? "" : "no", ignore
? "" : "no");
725 debugger_command (this->debugger
, cmd
, FALSE
, NULL
, NULL
);
732 idebugger_info_frame (IAnjutaDebugger
*plugin
, guint frame
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
740 idebugger_info_args (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
748 idebugger_info_target (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
756 idebugger_info_program (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
764 idebugger_info_udot (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
772 idebugger_info_variables (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
780 idebugger_set_frame (IAnjutaDebugger
*plugin
, guint frame
, GError
**err
)
782 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
784 debugger_set_frame (this->debugger
, frame
);
790 idebugger_list_frame (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
792 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
794 debugger_list_frame (this->debugger
, callback
, user_data
);
800 idebugger_set_thread (IAnjutaDebugger
*plugin
, gint thread
, GError
**err
)
802 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
804 debugger_set_thread (this->debugger
, thread
);
810 idebugger_list_thread (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
812 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
814 debugger_list_thread (this->debugger
, callback
, user_data
);
820 idebugger_info_thread (IAnjutaDebugger
*plugin
, gint thread
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
822 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
824 debugger_info_thread (this->debugger
, thread
, callback
, user_data
);
830 idebugger_run_from (IAnjutaDebugger
*plugin
, const gchar
*file
, gint line
, GError
**err
)
832 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
834 debugger_run_from_position (this->debugger
, file
, line
);
840 idebugger_dump_stack_trace (IAnjutaDebugger
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
842 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
844 debugger_dump_stack_trace (this->debugger
, callback
, user_data
);
850 idebugger_callback (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
853 callback (NULL
, user_data
, NULL
);
859 idebugger_enable_log (IAnjutaDebugger
*plugin
, IAnjutaMessageView
*log
, GError
**err
)
861 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
865 debugger_set_log (this->debugger
, log
);
869 idebugger_disable_log (IAnjutaDebugger
*plugin
, GError
**err
)
871 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
875 debugger_set_log (this->debugger
, NULL
);
879 idebugger_iface_init (IAnjutaDebuggerIface
*iface
)
881 iface
->get_state
= idebugger_get_state
;
882 iface
->attach
= idebugger_attach
;
883 iface
->load
= idebugger_load
;
884 iface
->set_working_directory
= idebugger_set_working_directory
;
885 iface
->set_environment
= idebugger_set_environment
;
886 iface
->start
= idebugger_start
;
887 iface
->connect
= idebugger_connect
;
888 iface
->unload
= idebugger_unload
;
889 iface
->quit
= idebugger_quit
;
890 iface
->abort
= idebugger_abort
;
891 iface
->run
= idebugger_run
;
892 iface
->step_in
= idebugger_step_in
;
893 iface
->step_over
= idebugger_step_over
;
894 iface
->step_out
= idebugger_step_out
;
895 iface
->run_to
= idebugger_run_to
;
896 iface
->run_from
= idebugger_run_from
;
897 iface
->exit
= idebugger_exit
;
898 iface
->interrupt
= idebugger_interrupt
;
900 iface
->inspect
= idebugger_inspect
;
901 iface
->evaluate
= idebugger_evaluate
;
903 iface
->print
= idebugger_print
;
904 iface
->list_local
= idebugger_list_local
;
905 iface
->list_argument
= idebugger_list_argument
;
906 iface
->info_frame
= idebugger_info_frame
;
907 iface
->info_signal
= idebugger_info_signal
;
908 iface
->info_sharedlib
= idebugger_info_sharedlib
;
909 iface
->info_args
= idebugger_info_args
;
910 iface
->info_target
= idebugger_info_target
;
911 iface
->info_program
= idebugger_info_program
;
912 iface
->info_udot
= idebugger_info_udot
;
913 iface
->info_variables
= idebugger_info_variables
;
914 iface
->handle_signal
= idebugger_handle_signal
;
915 iface
->list_frame
= idebugger_list_frame
;
916 iface
->set_frame
= idebugger_set_frame
;
917 iface
->list_thread
= idebugger_list_thread
;
918 iface
->set_thread
= idebugger_set_thread
;
919 iface
->info_thread
= idebugger_info_thread
;
920 iface
->dump_stack_trace
= idebugger_dump_stack_trace
;
922 iface
->send_command
= idebugger_send_command
;
924 iface
->callback
= idebugger_callback
;
926 iface
->enable_log
= idebugger_enable_log
;
927 iface
->disable_log
= idebugger_disable_log
;
931 /* Implementation of IAnjutaDebuggerBreakpoint interface
932 *---------------------------------------------------------------------------*/
935 idebugger_breakpoint_implement (IAnjutaDebuggerBreakpoint
*plugin
, GError
**err
)
937 /* gdb implement all interface methods */
938 return IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_ADDRESS
939 | IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_FUNCTION
940 | IANJUTA_DEBUGGER_BREAKPOINT_ENABLE
941 | IANJUTA_DEBUGGER_BREAKPOINT_IGNORE
942 | IANJUTA_DEBUGGER_BREAKPOINT_CONDITION
;
946 idebugger_breakpoint_add_at_line (IAnjutaDebuggerBreakpoint
*plugin
, const gchar
* file
, guint line
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
948 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
950 debugger_add_breakpoint_at_line (this->debugger
, file
, line
, callback
, user_data
);
956 idebugger_breakpoint_add_at_function (IAnjutaDebuggerBreakpoint
*plugin
, const gchar
* file
, const gchar
* function
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
958 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
960 debugger_add_breakpoint_at_function (this->debugger
, *file
== '\0' ? NULL
: file
, function
, callback
, user_data
);
966 idebugger_breakpoint_add_at_address (IAnjutaDebuggerBreakpoint
*plugin
, gulong address
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
968 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
970 debugger_add_breakpoint_at_address (this->debugger
, address
, callback
, user_data
);
976 idebugger_breakpoint_enable (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, gboolean enable
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
978 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
980 debugger_enable_breakpoint (this->debugger
, id
, enable
, callback
, user_data
);
986 idebugger_breakpoint_ignore (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, guint ignore
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
988 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
990 debugger_ignore_breakpoint (this->debugger
, id
, ignore
, callback
, user_data
);
996 idebugger_breakpoint_condition (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, const gchar
*condition
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
998 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1000 debugger_condition_breakpoint (this->debugger
, id
, condition
, callback
, user_data
);
1006 idebugger_breakpoint_remove (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, IAnjutaDebuggerBreakpointCallback callback
, gpointer user_data
, GError
**err
)
1008 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1010 debugger_remove_breakpoint (this->debugger
, id
, callback
, user_data
);
1016 idebugger_breakpoint_list (IAnjutaDebuggerBreakpoint
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
1018 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1020 debugger_list_breakpoint (this->debugger
, callback
, user_data
);
1026 idebugger_breakpoint_iface_init (IAnjutaDebuggerBreakpointIface
*iface
)
1028 iface
->implement_breakpoint
= idebugger_breakpoint_implement
;
1029 iface
->set_breakpoint_at_line
= idebugger_breakpoint_add_at_line
;
1030 iface
->clear_breakpoint
= idebugger_breakpoint_remove
;
1031 iface
->list_breakpoint
= idebugger_breakpoint_list
;
1032 iface
->set_breakpoint_at_address
= idebugger_breakpoint_add_at_address
;
1033 iface
->set_breakpoint_at_function
= idebugger_breakpoint_add_at_function
;
1034 iface
->enable_breakpoint
= idebugger_breakpoint_enable
;
1035 iface
->ignore_breakpoint
= idebugger_breakpoint_ignore
;
1036 iface
->condition_breakpoint
= idebugger_breakpoint_condition
;
1039 /* Implementation of IAnjutaDebuggerRegister interface
1040 *---------------------------------------------------------------------------*/
1043 idebugger_register_list (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
1045 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1047 debugger_list_register (this->debugger
, callback
, user_data
);
1053 idebugger_register_update (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**err
)
1055 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1057 debugger_update_register (this->debugger
, callback
, user_data
);
1063 idebugger_register_write (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerRegisterData
*value
, GError
**err
)
1065 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1067 debugger_write_register (this->debugger
, value
->name
, value
->value
);
1073 idebugger_register_iface_init (IAnjutaDebuggerRegisterIface
*iface
)
1075 iface
->list_register
= idebugger_register_list
;
1076 iface
->update_register
= idebugger_register_update
;
1077 iface
->write_register
= idebugger_register_write
;
1080 /* Implementation of IAnjutaDebuggerMemory interface
1081 *---------------------------------------------------------------------------*/
1084 idebugger_memory_inspect (IAnjutaDebuggerMemory
*plugin
, gulong address
, guint length
, IAnjutaDebuggerMemoryCallback callback
, gpointer user_data
, GError
**err
)
1086 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1088 debugger_inspect_memory (this->debugger
, address
, length
, callback
, user_data
);
1094 idebugger_memory_iface_init (IAnjutaDebuggerMemoryIface
*iface
)
1096 iface
->inspect
= idebugger_memory_inspect
;
1099 /* Implementation of IAnjutaDebuggerInstruction interface
1100 *---------------------------------------------------------------------------*/
1103 idebugger_instruction_disassemble (IAnjutaDebuggerInstruction
*plugin
, gulong address
, guint length
, IAnjutaDebuggerInstructionCallback callback
, gpointer user_data
, GError
**err
)
1105 GdbPlugin
*this = (GdbPlugin
*)plugin
;
1107 debugger_disassemble (this->debugger
, address
, length
, callback
, user_data
);
1113 idebugger_instruction_step_in (IAnjutaDebuggerInstruction
*plugin
, GError
**err
)
1115 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1117 debugger_stepi_in (this->debugger
);
1123 idebugger_instruction_step_over (IAnjutaDebuggerInstruction
*plugin
, GError
**err
)
1125 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1127 debugger_stepi_over (this->debugger
);
1133 idebugger_instruction_run_to_address (IAnjutaDebuggerInstruction
*plugin
, gulong address
, GError
**err
)
1135 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1137 debugger_run_to_address (this->debugger
, address
);
1143 idebugger_instruction_run_from_address (IAnjutaDebuggerInstruction
*plugin
, gulong address
, GError
**err
)
1145 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1147 debugger_run_from_address (this->debugger
, address
);
1153 idebugger_instruction_iface_init (IAnjutaDebuggerInstructionIface
*iface
)
1155 iface
->disassemble
= idebugger_instruction_disassemble
;
1156 iface
->step_in_instruction
= idebugger_instruction_step_in
;
1157 iface
->step_over_instruction
= idebugger_instruction_step_over
;
1158 iface
->run_to_address
= idebugger_instruction_run_to_address
;
1159 iface
->run_from_address
= idebugger_instruction_run_from_address
;
1162 /* Implementation of IAnjutaDebuggerVariable interface
1163 *---------------------------------------------------------------------------*/
1166 idebugger_variable_destroy (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, GError
**error
)
1168 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1171 quoted
= quote_expression (name
);
1172 debugger_delete_variable (gdb
->debugger
, quoted
);
1179 idebugger_variable_evaluate (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, IAnjutaDebuggerGCharCallback callback
, gpointer user_data
, GError
**error
)
1181 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1183 debugger_evaluate_variable (gdb
->debugger
, name
, callback
, user_data
);
1189 idebugger_variable_assign (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, const gchar
*value
, GError
**error
)
1191 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1194 quoted
= quote_expression (name
);
1195 debugger_assign_variable (gdb
->debugger
, quoted
, value
);
1202 idebugger_variable_list_children (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, guint from
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**error
)
1204 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1207 quoted
= quote_expression (name
);
1208 debugger_list_variable_children (gdb
->debugger
, quoted
, from
, callback
, user_data
);
1215 idebugger_variable_create (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, IAnjutaDebuggerVariableCallback callback
, gpointer user_data
, GError
**error
)
1217 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1220 quoted
= quote_expression (name
);
1221 debugger_create_variable (gdb
->debugger
, quoted
, callback
, user_data
);
1228 idebugger_variable_update (IAnjutaDebuggerVariable
*plugin
, IAnjutaDebuggerGListCallback callback
, gpointer user_data
, GError
**error
)
1230 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1232 debugger_update_variable (gdb
->debugger
, callback
, user_data
);
1238 idebugger_variable_iface_init (IAnjutaDebuggerVariableIface
*iface
)
1240 iface
->destroy
= idebugger_variable_destroy
;
1241 iface
->evaluate
= idebugger_variable_evaluate
;
1242 iface
->assign
= idebugger_variable_assign
;
1243 iface
->list_children
= idebugger_variable_list_children
;
1244 iface
->create
= idebugger_variable_create
;
1245 iface
->update
= idebugger_variable_update
;
1248 /* Implementation of IAnjutaPreference interface
1249 *---------------------------------------------------------------------------*/
1252 ipreferences_merge(IAnjutaPreferences
* ipref
, AnjutaPreferences
* prefs
, GError
** error
)
1254 gdb_merge_preferences (prefs
, &(ANJUTA_PLUGIN_GDB (ipref
)->pretty_printers
));
1258 ipreferences_unmerge(IAnjutaPreferences
* ipref
, AnjutaPreferences
* prefs
, GError
** error
)
1260 gdb_unmerge_preferences (prefs
);
1264 ipreferences_iface_init(IAnjutaPreferencesIface
* iface
)
1266 iface
->merge
= ipreferences_merge
;
1267 iface
->unmerge
= ipreferences_unmerge
;
1270 ANJUTA_PLUGIN_BEGIN (GdbPlugin
, gdb_plugin
);
1271 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger
, IANJUTA_TYPE_DEBUGGER
);
1272 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_breakpoint
, IANJUTA_TYPE_DEBUGGER_BREAKPOINT
);
1273 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_register
, IANJUTA_TYPE_DEBUGGER_REGISTER
);
1274 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_memory
, IANJUTA_TYPE_DEBUGGER_MEMORY
);
1275 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_instruction
, IANJUTA_TYPE_DEBUGGER_INSTRUCTION
);
1276 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_variable
, IANJUTA_TYPE_DEBUGGER_VARIABLE
);
1277 ANJUTA_PLUGIN_ADD_INTERFACE (ipreferences
, IANJUTA_TYPE_PREFERENCES
);
1280 ANJUTA_SIMPLE_PLUGIN (GdbPlugin
, gdb_plugin
);