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>
34 #include <libanjuta/interfaces/ianjuta-debugger.h>
35 #include <libanjuta/interfaces/ianjuta-debugger-breakpoint.h>
36 #include <libanjuta/interfaces/ianjuta-debugger-register.h>
37 #include <libanjuta/interfaces/ianjuta-debugger-memory.h>
38 #include <libanjuta/interfaces/ianjuta-debugger-instruction.h>
39 #include <libanjuta/interfaces/ianjuta-debugger-variable.h>
40 #include <libanjuta/interfaces/ianjuta-terminal.h>
41 #include <libanjuta/anjuta-plugin.h>
45 *---------------------------------------------------------------------------*/
54 /* Output callback data */
55 IAnjutaDebuggerOutputCallback output_callback
;
56 gpointer output_user_data
;
58 /* Log message window */
59 IAnjutaMessageView
*view
;
65 struct _GdbPluginClass
67 AnjutaPluginClass parent_class
;
71 *---------------------------------------------------------------------------*/
74 gdb_plugin_stop_terminal (GdbPlugin
* plugin
)
76 DEBUG_PRINT ("In function: gdb_plugin_stop_terminal()");
78 if (plugin
->term_pid
> 0) {
79 kill (plugin
->term_pid
, SIGTERM
);
80 plugin
->term_pid
= -1;
85 gdb_plugin_start_terminal (GdbPlugin
* plugin
)
89 IAnjutaTerminal
*term
;
91 DEBUG_PRINT ("In function: gdb_plugin_start_terminal() previous pid %d", plugin
->term_pid
);
93 /* Close previous terminal if needed */
94 gdb_plugin_stop_terminal (plugin
);
96 /* Get terminal plugin */
97 term
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
, IAnjutaTerminal
, NULL
);
101 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
102 _("Anjuta terminal plugin is not installed. The program will be run without a terminal."));
107 /* Check if anjuta launcher is here */
108 if (anjuta_util_prog_is_installed ("anjuta_launcher", TRUE
) == FALSE
)
113 file
= anjuta_util_get_a_tmp_file();
114 if (mkfifo (file
, 0664) < 0)
116 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
117 _("Failed to create fifo file named %s. The program will run without a terminal."), file
);
123 /* Launch terminal */
124 cmd
= g_strconcat ("anjuta_launcher --__debug_terminal ", file
, NULL
);
125 plugin
->term_pid
= ianjuta_terminal_execute_command (term
, NULL
, cmd
, NULL
, NULL
);
128 if (plugin
->term_pid
> 0)
131 * Warning: call to fopen() may be blocked if the terminal is
132 * not properly started. I don't know how to handle this. May
133 * be opening as non-blocking will solve this .
135 g_file_get_contents (file
, &tty
, NULL
, NULL
); /* Ok, take the risk. */
138 g_strchomp (tty
); /* anjuta_launcher add a end of line after the terminal name */
139 if (strcmp(tty
, "__ERROR__") == 0)
151 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (plugin
)->shell
),
152 _("Cannot start terminal for debugging."));
153 gdb_plugin_stop_terminal (plugin
);
160 *---------------------------------------------------------------------------*/
163 on_debugger_stopped (GdbPlugin
*self
, GError
*err
)
165 if (self
->debugger
!= NULL
)
167 g_signal_handlers_disconnect_by_func (self
, G_CALLBACK (on_debugger_stopped
), self
);
168 debugger_free (self
->debugger
);
169 self
->debugger
= NULL
;
170 gdb_plugin_stop_terminal (self
);
175 gdb_plugin_initialize (GdbPlugin
*this)
179 /* debugger can be not NULL, if initialize is called several times
180 * or if debugger_stopped signal has not been emitted */
181 if (this->debugger
!= NULL
)
183 on_debugger_stopped (this, NULL
);
186 parent
= GTK_WINDOW (ANJUTA_PLUGIN (this)->shell
);
187 this->debugger
= debugger_new (parent
, G_OBJECT (this));
188 g_signal_connect_swapped (this, "debugger-stopped", G_CALLBACK (on_debugger_stopped
), this);
189 debugger_set_output_callback (this->debugger
, this->output_callback
, this->output_user_data
);
190 if (this->view
) debugger_set_log (this->debugger
, this->view
);
193 /* AnjutaPlugin functions
194 *---------------------------------------------------------------------------*/
197 gdb_plugin_activate_plugin (AnjutaPlugin
* plugin
)
199 /* GdbPlugin *this = ANJUTA_PLUGIN_GDB (plugin); */
201 DEBUG_PRINT ("GDB: Activating Gdb plugin...");
207 gdb_plugin_deactivate_plugin (AnjutaPlugin
* plugin
)
209 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
211 DEBUG_PRINT ("GDB: Deactivating Gdb plugin...");
213 if (this->debugger
!= NULL
)
215 debugger_free (this->debugger
);
216 this->debugger
= NULL
;
223 *---------------------------------------------------------------------------*/
225 /* Used in dispose and finalize */
226 static gpointer parent_class
;
228 /* instance_init is the constructor. All functions should work after this
232 gdb_plugin_instance_init (GObject
* obj
)
234 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (obj
);
236 this->debugger
= NULL
;
237 this->output_callback
= NULL
;
241 /* dispose is the first destruction step. It is used to unref object created
242 * with instance_init in order to break reference counting cycles. This
243 * function could be called several times. All function should still work
244 * after this call. It has to called its parents.*/
247 gdb_plugin_dispose (GObject
* obj
)
249 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (obj
);
251 if (this->debugger
!= NULL
)
253 debugger_free (this->debugger
);
254 this->debugger
= NULL
;
256 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
259 /* finalize is the last destruction step. It must free all memory allocated
260 * with instance_init. It is called only one time just before releasing all
264 gdb_plugin_finalize (GObject
* obj
)
266 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
269 /* class_init intialize the class itself not the instance */
272 gdb_plugin_class_init (GObjectClass
* klass
)
274 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
276 parent_class
= g_type_class_peek_parent (klass
);
278 plugin_class
->activate
= gdb_plugin_activate_plugin
;
279 plugin_class
->deactivate
= gdb_plugin_deactivate_plugin
;
280 klass
->dispose
= gdb_plugin_dispose
;
281 klass
->finalize
= gdb_plugin_finalize
;
284 /* Implementation of IAnjutaDebugger interface
285 *---------------------------------------------------------------------------*/
287 static IAnjutaDebuggerState
288 idebugger_get_state (IAnjutaDebugger
*plugin
, GError
**err
)
290 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
292 if (this->debugger
== NULL
)
294 return IANJUTA_DEBUGGER_STOPPED
;
298 return debugger_get_state (this->debugger
);
304 idebugger_load (IAnjutaDebugger
*plugin
, const gchar
*file
, const gchar
* mime_type
,
305 const GList
*search_dirs
, GError
**err
)
307 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
308 gboolean is_libtool
= FALSE
;
310 /* Check allowed mime type */
311 if (mime_type
== NULL
)
313 /* Hope that the target is supported */
315 else if ((strcmp (mime_type
, "application/x-executable") == 0) ||
316 (strcmp (mime_type
, "application/octet-stream") == 0))
318 /* Supported target */
320 else if (strcmp (mime_type
, "application/x-shellscript") == 0)
322 /* FIXME: We should really do more checks to confirm that
323 * this target is indeed libtool target
327 else if (strcmp (mime_type
, "application/x-core") == 0)
329 /* Supported target */
333 /* Not supported target */
338 gdb_plugin_initialize (this);
340 return debugger_start (this->debugger
, search_dirs
, file
, is_libtool
);
344 idebugger_unload (IAnjutaDebugger
*plugin
, GError
**err
)
346 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
348 debugger_stop (this->debugger
);
354 idebugger_set_working_directory (IAnjutaDebugger
*plugin
, const gchar
*directory
, GError
**err
)
356 GdbPlugin
*self
= ANJUTA_PLUGIN_GDB (plugin
);
358 debugger_set_working_directory (self
->debugger
, directory
);
364 idebugger_set_environment (IAnjutaDebugger
*plugin
, gchar
**variables
, GError
**err
)
366 GdbPlugin
*self
= ANJUTA_PLUGIN_GDB (plugin
);
368 debugger_set_environment (self
->debugger
, variables
);
374 idebugger_attach (IAnjutaDebugger
*plugin
, pid_t pid
, const GList
*search_dirs
, GError
**err
)
376 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
379 gdb_plugin_initialize (this);
380 debugger_start (this->debugger
, search_dirs
, NULL
, FALSE
);
381 debugger_attach_process (this->debugger
, pid
);
387 idebugger_start (IAnjutaDebugger
*plugin
, const gchar
*argument
, gboolean terminal
, gboolean stop
, GError
**err
)
389 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
392 tty
= terminal
? gdb_plugin_start_terminal (this) : NULL
;
393 debugger_start_program (this->debugger
, argument
, tty
, stop
);
400 idebugger_quit (IAnjutaDebugger
*plugin
, GError
**err
)
402 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
404 if (!debugger_stop (this->debugger
))
406 DEBUG_PRINT ("set error");
407 g_set_error (err
, IANJUTA_DEBUGGER_ERROR
, IANJUTA_DEBUGGER_CANCEL
, "Command cancelled by user");
418 idebugger_abort (IAnjutaDebugger
*plugin
, GError
**err
)
420 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
422 DEBUG_PRINT ("idebugger abort\n");
423 if (!debugger_abort (this->debugger
))
425 g_set_error (err
, IANJUTA_DEBUGGER_ERROR
, IANJUTA_DEBUGGER_CANCEL
, "Command cancelled by user");
436 idebugger_run (IAnjutaDebugger
*plugin
, GError
**err
)
438 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
440 debugger_run (this->debugger
);
446 idebugger_step_in (IAnjutaDebugger
*plugin
, GError
**err
)
448 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
450 debugger_step_in (this->debugger
);
456 idebugger_step_over (IAnjutaDebugger
*plugin
, GError
**err
)
458 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
460 debugger_step_over (this->debugger
);
466 idebugger_run_to (IAnjutaDebugger
*plugin
, GFile
* file
,
467 gint line
, GError
**err
)
469 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
470 gchar
* path
= g_file_get_path (file
);
472 debugger_run_to_position (this->debugger
, path
, line
);
478 idebugger_step_out (IAnjutaDebugger
*plugin
, GError
**err
)
480 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
482 debugger_step_out (this->debugger
);
488 idebugger_exit (IAnjutaDebugger
*plugin
, GError
**err
)
490 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
492 debugger_stop_program (this->debugger
);
498 idebugger_interrupt (IAnjutaDebugger
*plugin
, GError
**err
)
500 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
502 debugger_interrupt (this->debugger
);
508 idebugger_inspect (IAnjutaDebugger
*plugin
, const gchar
*name
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
510 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
512 debugger_evaluate (this->debugger
, name
, callback
, user_data
);
518 idebugger_evaluate (IAnjutaDebugger
*plugin
, const gchar
*name
, const gchar
*value
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
520 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
523 buf
= g_strconcat ("\"", name
, " = ", value
, "\"", NULL
);
524 debugger_evaluate (this->debugger
, buf
, callback
, user_data
);
531 idebugger_send_command (IAnjutaDebugger
*plugin
, const gchar
* command
, GError
**err
)
533 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
535 debugger_command (this->debugger
, command
, FALSE
, NULL
, NULL
);
541 idebugger_print (IAnjutaDebugger
*plugin
, const gchar
* variable
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
543 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
545 debugger_print (this->debugger
, variable
, callback
, user_data
);
551 idebugger_list_local (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
553 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
555 debugger_list_local (this->debugger
, callback
, user_data
);
561 idebugger_list_argument (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
563 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
565 debugger_list_argument (this->debugger
, callback
, user_data
);
571 idebugger_info_signal (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
573 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
575 debugger_info_signal (this->debugger
, callback
, user_data
);
581 idebugger_info_sharedlib (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
583 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
585 debugger_info_sharedlib (this->debugger
, callback
, user_data
);
591 idebugger_handle_signal (IAnjutaDebugger
*plugin
, const gchar
* name
, gboolean stop
, gboolean print
, gboolean ignore
, GError
**err
)
594 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
596 cmd
= g_strdup_printf("handle %s %sstop %sprint %spass", name
, stop
? "" : "no", print
? "" : "no", ignore
? "" : "no");
597 debugger_command (this->debugger
, cmd
, FALSE
, NULL
, NULL
);
604 idebugger_info_frame (IAnjutaDebugger
*plugin
, guint frame
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
606 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
608 debugger_info_frame (this->debugger
, frame
, callback
, user_data
);
614 idebugger_info_args (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
616 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
618 debugger_info_args (this->debugger
, callback
, user_data
);
624 idebugger_info_target (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
626 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
628 debugger_info_target (this->debugger
, callback
, user_data
);
634 idebugger_info_program (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
636 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
638 debugger_info_program (this->debugger
, callback
, user_data
);
644 idebugger_info_udot (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
646 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
648 debugger_info_udot (this->debugger
, callback
, user_data
);
654 idebugger_info_variables (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
656 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
658 debugger_info_variables (this->debugger
, callback
, user_data
);
664 idebugger_set_frame (IAnjutaDebugger
*plugin
, guint frame
, GError
**err
)
666 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
668 debugger_set_frame (this->debugger
, frame
);
674 idebugger_list_frame (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
676 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
678 debugger_list_frame (this->debugger
, callback
, user_data
);
684 idebugger_set_thread (IAnjutaDebugger
*plugin
, gint thread
, GError
**err
)
686 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
688 debugger_set_thread (this->debugger
, thread
);
694 idebugger_list_thread (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
696 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
698 debugger_list_thread (this->debugger
, callback
, user_data
);
704 idebugger_info_thread (IAnjutaDebugger
*plugin
, gint thread
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
706 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
708 debugger_info_thread (this->debugger
, thread
, callback
, user_data
);
714 idebugger_list_register (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
716 //GdbPlugin *this = ANJUTA_PLUGIN_GDB (plugin);
718 //debugger_list_register (this->debugger, callback, user_data);
724 idebugger_callback (IAnjutaDebugger
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
727 callback (NULL
, user_data
, NULL
);
733 idebugger_enable_log (IAnjutaDebugger
*plugin
, IAnjutaMessageView
*log
, GError
**err
)
735 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
739 debugger_set_log (this->debugger
, log
);
743 idebugger_disable_log (IAnjutaDebugger
*plugin
, GError
**err
)
745 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
749 debugger_set_log (this->debugger
, NULL
);
753 idebugger_iface_init (IAnjutaDebuggerIface
*iface
)
755 iface
->get_state
= idebugger_get_state
;
756 iface
->attach
= idebugger_attach
;
757 iface
->load
= idebugger_load
;
758 iface
->set_working_directory
= idebugger_set_working_directory
;
759 iface
->set_environment
= idebugger_set_environment
;
760 iface
->start
= idebugger_start
;
761 iface
->unload
= idebugger_unload
;
762 iface
->quit
= idebugger_quit
;
763 iface
->abort
= idebugger_abort
;
764 iface
->run
= idebugger_run
;
765 iface
->step_in
= idebugger_step_in
;
766 iface
->step_over
= idebugger_step_over
;
767 iface
->step_out
= idebugger_step_out
;
768 iface
->run_to
= idebugger_run_to
;
769 iface
->exit
= idebugger_exit
;
770 iface
->interrupt
= idebugger_interrupt
;
772 iface
->inspect
= idebugger_inspect
;
773 iface
->evaluate
= idebugger_evaluate
;
775 iface
->print
= idebugger_print
;
776 iface
->list_local
= idebugger_list_local
;
777 iface
->list_argument
= idebugger_list_argument
;
778 iface
->info_frame
= idebugger_info_frame
;
779 iface
->info_signal
= idebugger_info_signal
;
780 iface
->info_sharedlib
= idebugger_info_sharedlib
;
781 iface
->info_args
= idebugger_info_args
;
782 iface
->info_target
= idebugger_info_target
;
783 iface
->info_program
= idebugger_info_program
;
784 iface
->info_udot
= idebugger_info_udot
;
785 iface
->info_variables
= idebugger_info_variables
;
786 iface
->handle_signal
= idebugger_handle_signal
;
787 iface
->list_frame
= idebugger_list_frame
;
788 iface
->set_frame
= idebugger_set_frame
;
789 iface
->list_thread
= idebugger_list_thread
;
790 iface
->set_thread
= idebugger_set_thread
;
791 iface
->info_thread
= idebugger_info_thread
;
792 iface
->list_register
= idebugger_list_register
;
794 iface
->send_command
= idebugger_send_command
;
796 iface
->callback
= idebugger_callback
;
798 iface
->enable_log
= idebugger_enable_log
;
799 iface
->disable_log
= idebugger_disable_log
;
803 /* Implementation of IAnjutaDebuggerBreakpoint interface
804 *---------------------------------------------------------------------------*/
807 idebugger_breakpoint_implement (IAnjutaDebuggerBreakpoint
*plugin
, GError
**err
)
809 /* gdb implement all interface methods */
810 return IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_ADDRESS
811 | IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_FUNCTION
812 | IANJUTA_DEBUGGER_BREAKPOINT_ENABLE
813 | IANJUTA_DEBUGGER_BREAKPOINT_IGNORE
814 | IANJUTA_DEBUGGER_BREAKPOINT_CONDITION
;
818 idebugger_breakpoint_add_at_line (IAnjutaDebuggerBreakpoint
*plugin
, const gchar
* file
, guint line
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
820 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
822 debugger_add_breakpoint_at_line (this->debugger
, file
, line
, callback
, user_data
);
828 idebugger_breakpoint_add_at_function (IAnjutaDebuggerBreakpoint
*plugin
, const gchar
* file
, const gchar
* function
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
830 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
832 debugger_add_breakpoint_at_function (this->debugger
, *file
== '\0' ? NULL
: file
, function
, callback
, user_data
);
838 idebugger_breakpoint_add_at_address (IAnjutaDebuggerBreakpoint
*plugin
, gulong address
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
840 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
842 debugger_add_breakpoint_at_address (this->debugger
, address
, callback
, user_data
);
848 idebugger_breakpoint_enable (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, gboolean enable
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
850 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
852 debugger_enable_breakpoint (this->debugger
, id
, enable
, callback
, user_data
);
858 idebugger_breakpoint_ignore (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, guint ignore
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
860 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
862 debugger_ignore_breakpoint (this->debugger
, id
, ignore
, callback
, user_data
);
868 idebugger_breakpoint_condition (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, const gchar
*condition
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
870 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
872 debugger_condition_breakpoint (this->debugger
, id
, condition
, callback
, user_data
);
878 idebugger_breakpoint_remove (IAnjutaDebuggerBreakpoint
*plugin
, guint id
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
880 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
882 debugger_remove_breakpoint (this->debugger
, id
, callback
, user_data
);
888 idebugger_breakpoint_list (IAnjutaDebuggerBreakpoint
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
890 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
892 debugger_list_breakpoint (this->debugger
, callback
, user_data
);
898 idebugger_breakpoint_iface_init (IAnjutaDebuggerBreakpointIface
*iface
)
900 iface
->implement
= idebugger_breakpoint_implement
;
901 iface
->set_at_line
= idebugger_breakpoint_add_at_line
;
902 iface
->clear
= idebugger_breakpoint_remove
;
903 iface
->list
= idebugger_breakpoint_list
;
904 iface
->set_at_address
= idebugger_breakpoint_add_at_address
;
905 iface
->set_at_function
= idebugger_breakpoint_add_at_function
;
906 iface
->enable
= idebugger_breakpoint_enable
;
907 iface
->ignore
= idebugger_breakpoint_ignore
;
908 iface
->condition
= idebugger_breakpoint_condition
;
911 /* Implementation of IAnjutaDebuggerRegister interface
912 *---------------------------------------------------------------------------*/
915 idebugger_register_list (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
917 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
919 debugger_list_register (this->debugger
, callback
, user_data
);
925 idebugger_register_update (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
927 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
929 debugger_update_register (this->debugger
, callback
, user_data
);
935 idebugger_register_write (IAnjutaDebuggerRegister
*plugin
, IAnjutaDebuggerRegisterData
*value
, GError
**err
)
937 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
939 debugger_write_register (this->debugger
, value
->name
, value
->value
);
945 idebugger_register_iface_init (IAnjutaDebuggerRegisterIface
*iface
)
947 iface
->list
= idebugger_register_list
;
948 iface
->update
= idebugger_register_update
;
949 iface
->write
= idebugger_register_write
;
952 /* Implementation of IAnjutaDebuggerMemory interface
953 *---------------------------------------------------------------------------*/
956 idebugger_memory_inspect (IAnjutaDebuggerMemory
*plugin
, gulong address
, guint length
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
958 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
960 debugger_inspect_memory (this->debugger
, address
, length
, callback
, user_data
);
966 idebugger_memory_iface_init (IAnjutaDebuggerMemoryIface
*iface
)
968 iface
->inspect
= idebugger_memory_inspect
;
971 /* Implementation of IAnjutaDebuggerInstruction interface
972 *---------------------------------------------------------------------------*/
975 idebugger_instruction_disassemble (IAnjutaDebuggerInstruction
*plugin
, gulong address
, guint length
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**err
)
977 GdbPlugin
*this = (GdbPlugin
*)plugin
;
979 debugger_disassemble (this->debugger
, address
, length
, callback
, user_data
);
985 idebugger_instruction_step_in (IAnjutaDebuggerInstruction
*plugin
, GError
**err
)
987 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
989 debugger_stepi_in (this->debugger
);
995 idebugger_instruction_step_over (IAnjutaDebuggerInstruction
*plugin
, GError
**err
)
997 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
999 debugger_stepi_over (this->debugger
);
1005 idebugger_instruction_run_to_address (IAnjutaDebuggerInstruction
*plugin
, gulong address
, GError
**err
)
1007 GdbPlugin
*this = ANJUTA_PLUGIN_GDB (plugin
);
1009 debugger_run_to_address (this->debugger
, address
);
1015 idebugger_instruction_iface_init (IAnjutaDebuggerInstructionIface
*iface
)
1017 iface
->disassemble
= idebugger_instruction_disassemble
;
1018 iface
->step_in
= idebugger_instruction_step_in
;
1019 iface
->step_over
= idebugger_instruction_step_over
;
1020 iface
->run_to_address
= idebugger_instruction_run_to_address
;
1023 /* Implementation of IAnjutaDebuggerVariable interface
1024 *---------------------------------------------------------------------------*/
1027 idebugger_variable_destroy (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, GError
**error
)
1029 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1031 debugger_delete_variable (gdb
->debugger
, name
);
1037 idebugger_variable_evaluate (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**error
)
1039 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1041 debugger_evaluate_variable (gdb
->debugger
, name
, callback
, user_data
);
1047 idebugger_variable_assign (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, const gchar
*value
, GError
**error
)
1049 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1051 debugger_assign_variable (gdb
->debugger
, name
, value
);
1057 idebugger_variable_list_children (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**error
)
1059 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1061 debugger_list_variable_children (gdb
->debugger
, name
, callback
, user_data
);
1067 idebugger_variable_create (IAnjutaDebuggerVariable
*plugin
, const gchar
*name
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**error
)
1069 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1071 debugger_create_variable (gdb
->debugger
, name
, callback
, user_data
);
1077 idebugger_variable_update (IAnjutaDebuggerVariable
*plugin
, IAnjutaDebuggerCallback callback
, gpointer user_data
, GError
**error
)
1079 GdbPlugin
*gdb
= ANJUTA_PLUGIN_GDB (plugin
);
1081 debugger_update_variable (gdb
->debugger
, callback
, user_data
);
1087 idebugger_variable_iface_init (IAnjutaDebuggerVariableIface
*iface
)
1089 iface
->destroy
= idebugger_variable_destroy
;
1090 iface
->evaluate
= idebugger_variable_evaluate
;
1091 iface
->assign
= idebugger_variable_assign
;
1092 iface
->list_children
= idebugger_variable_list_children
;
1093 iface
->create
= idebugger_variable_create
;
1094 iface
->update
= idebugger_variable_update
;
1097 ANJUTA_PLUGIN_BEGIN (GdbPlugin
, gdb_plugin
);
1098 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger
, IANJUTA_TYPE_DEBUGGER
);
1099 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_breakpoint
, IANJUTA_TYPE_DEBUGGER_BREAKPOINT
);
1100 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_register
, IANJUTA_TYPE_DEBUGGER_REGISTER
);
1101 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_memory
, IANJUTA_TYPE_DEBUGGER_MEMORY
);
1102 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_instruction
, IANJUTA_TYPE_DEBUGGER_INSTRUCTION
);
1103 ANJUTA_PLUGIN_ADD_INTERFACE(idebugger_variable
, IANJUTA_TYPE_DEBUGGER_VARIABLE
);
1106 ANJUTA_SIMPLE_PLUGIN (GdbPlugin
, gdb_plugin
);