aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Bradford <rob@o-hand.com>2008-04-04 14:39:58 +0000
committerrob <rob@aea7fca7-3721-49c4-ace3-ac8c44b998bb>2008-04-04 14:39:58 +0000
commit33fad004217f963c437005cc3f28b1759de06464 (patch)
tree4fd75e16c09ee2c4e7d47de24820631c43d94c11
parente0b1dd2f2162c8172e0559376362651e61a3145a (diff)
downloadanjuta-poky-33fad004217f963c437005cc3f28b1759de06464.tar.gz
anjuta-poky-33fad004217f963c437005cc3f28b1759de06464.tar.bz2
anjuta-poky-33fad004217f963c437005cc3f28b1759de06464.zip
2008-04-04 Rob Bradford <rob@openedhand.com>
* src/beaver-target.c: (beaver_target_dispose), (beaver_target_class_init), (beaver_target_init), (beaver_target_remote_debug), (_beaver_target_run_remote), (_beaver_target_run_remote_v), (_beaver_target_remote_debug), (debug_launcher_data_cb): * src/beaver-target.h: Refactor some of the remote debugging infrastructure into the target. Also specify the PATH environment variable so that we can find the versions installed into the the /usr/local directories.
-rw-r--r--ChangeLog12
-rw-r--r--src/beaver-target.c142
-rw-r--r--src/beaver-target.h6
3 files changed, 154 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b37d60..e99d4be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2008-04-04 Rob Bradford <rob@openedhand.com>
+ * src/beaver-target.c: (beaver_target_dispose),
+ (beaver_target_class_init), (beaver_target_init),
+ (beaver_target_remote_debug), (_beaver_target_run_remote),
+ (_beaver_target_run_remote_v), (_beaver_target_remote_debug),
+ (debug_launcher_data_cb):
+ * src/beaver-target.h:
+ Refactor some of the remote debugging infrastructure into the target.
+ Also specify the PATH environment variable so that we can find the
+ versions installed into the the /usr/local directories.
+
+2008-04-04 Rob Bradford <rob@openedhand.com>
+
* src/beaver-target.c: (beaver_target_init),
(_beaver_target_run_remote_v):
Move initialisation of launcher from just-in-time to on object
diff --git a/src/beaver-target.c b/src/beaver-target.c
index a8a0677..d0b9ba1 100644
--- a/src/beaver-target.c
+++ b/src/beaver-target.c
@@ -25,14 +25,19 @@ G_DEFINE_TYPE (BeaverTarget, beaver_target, G_TYPE_OBJECT)
#define ICON_FILE "anjuta-plugin-sdk.png"
+#define LAUNCH_COMMAND "PATH=/usr/local/bin:/usr/local/sbin:$PATH DISPLAY=:0 dbus-launch"
+
typedef struct _BeaverTargetPrivate BeaverTargetPrivate;
struct _BeaverTargetPrivate
{
AnjutaShell *shell;
+
IAnjutaMessageView *msg_view;
+ IAnjutaMessageView *debug_msg_view;
AnjutaLauncher *launcher;
+ AnjutaLauncher *debug_launcher;
};
/* for signals */
@@ -61,10 +66,14 @@ static void launcher_child_exited_cb (AnjutaLauncher *launcher, gint child_pid,
gint status, gulong time, gpointer userdata);
static void launcher_data_cb (AnjutaLauncher *launcher,
AnjutaLauncherOutputType type, const gchar *chars, gpointer userdata);
+static void debug_launcher_data_cb (AnjutaLauncher *launcher,
+ AnjutaLauncherOutputType type, const gchar *chars, gpointer userdata);
static gboolean _beaver_target_run_remote_v (BeaverTarget *target, gchar **in_args,
GError **error);
static gboolean _beaver_target_run_remote (BeaverTarget *target, gchar *cmd,
GError **out_err);
+static gboolean _beaver_target_remote_debug (BeaverTarget *target, gchar *cmd,
+ gchar *cmd_args, GError **out_err);
static void
beaver_target_get_property (GObject *object, guint property_id,
@@ -107,6 +116,12 @@ beaver_target_dispose (GObject *object)
priv->launcher = NULL;
}
+ if (priv->debug_launcher)
+ {
+ g_object_unref (priv->debug_launcher);
+ priv->debug_launcher = NULL;
+ }
+
if (G_OBJECT_CLASS (beaver_target_parent_class)->dispose)
G_OBJECT_CLASS (beaver_target_parent_class)->dispose (object);
}
@@ -132,6 +147,7 @@ beaver_target_class_init (BeaverTargetClass *klass)
klass->run_remote_v = _beaver_target_run_remote_v;
klass->run_remote = _beaver_target_run_remote;
+ klass->remote_debug = _beaver_target_remote_debug;
signals[STATE_CHANGED] = g_signal_new ("state-changed",
G_OBJECT_CLASS_TYPE (object_class),
@@ -155,6 +171,10 @@ beaver_target_init (BeaverTarget *self)
priv->launcher = anjuta_launcher_new ();
g_signal_connect (priv->launcher, "child-exited",
(GCallback)launcher_child_exited_cb, self);
+
+ priv->debug_launcher = anjuta_launcher_new ();
+ g_signal_connect (priv->debug_launcher, "child-exited",
+ (GCallback)launcher_child_exited_cb, self);
}
BeaverTargetState
@@ -209,16 +229,23 @@ beaver_target_run_remote (BeaverTarget *target, gchar *cmd, GError **error)
return BEAVER_TARGET_GET_CLASS (target)->run_remote (target, cmd, error);
}
+gboolean
+beaver_target_remote_debug (BeaverTarget *target, gchar *cmd, gchar *cmd_args,
+ GError **error)
+{
+ return BEAVER_TARGET_GET_CLASS (target)->remote_debug (target, cmd, cmd_args, error);
+}
+
/* default implementations */
static gboolean
_beaver_target_run_remote (BeaverTarget *target, gchar *cmd, GError **out_err)
{
GError *error = NULL;
- gchar *args[2] = { 0 };
+ gchar *args[2] = {NULL, NULL};
gchar *cmdline = NULL;
gboolean res = FALSE;
- cmdline = g_strdup_printf ("DISPLAY=:0 dbus-launch %s", cmd);
+ cmdline = g_strdup_printf (LAUNCH_COMMAND " " "%s", cmd);
args[0] = cmdline;
args[1] = NULL;
@@ -235,7 +262,7 @@ _beaver_target_run_remote_v (BeaverTarget *target, gchar **in_args,
{
BeaverTargetPrivate *priv = TARGET_PRIVATE (target);
gchar **args = NULL;
- gchar *ip_args[] = { (gchar *)beaver_target_get_ip_address (target), NULL };
+ gchar *ip_args[] = {(gchar *)beaver_target_get_ip_address (target), NULL};
GError *error = NULL;
IAnjutaMessageManager *msg_manager = NULL;
@@ -271,7 +298,6 @@ _beaver_target_run_remote_v (BeaverTarget *target, gchar **in_args,
}
}
-
if (anjuta_launcher_execute_v (priv->launcher, args, launcher_data_cb, target))
{
beaver_target_set_state (target, TARGET_STATE_BUSY);
@@ -288,6 +314,92 @@ _beaver_target_run_remote_v (BeaverTarget *target, gchar **in_args,
}
}
+/*
+ * Used for starting remote gdb server on the target. cmd is the program name
+ * and args are the args. We check to see if cmd is a full path and if not put
+ * through backticks with which to find it.
+ */
+static gboolean
+_beaver_target_remote_debug (BeaverTarget *target, gchar *cmd, gchar *cmd_args,
+ GError **out_err)
+{
+ BeaverTargetPrivate *priv = TARGET_PRIVATE (target);
+
+ IAnjutaMessageManager *msg_manager = NULL;
+ GError *error = NULL;
+
+ gchar **args = NULL;
+ gchar *gdb_args[2] = {NULL, NULL};
+ gchar *ip_args[] = {(gchar *)beaver_target_get_ip_address (target), NULL};
+ gchar *real_cmd = NULL;
+
+ /* Don't think this should ever happen since the text of the widget is "" */
+ if (cmd_args == NULL)
+ cmd_args = "";
+
+ /* We need to this because gdbserver is pretty rubbish. */
+ if (g_str_has_prefix (cmd, "/"))
+ {
+ real_cmd = g_strdup (cmd);
+ } else {
+ real_cmd = g_strdup_printf ("`which %s`", cmd);
+ }
+
+ gdb_args[0] = g_strdup_printf (LAUNCH_COMMAND " " "gdbserver 0.0.0.0:2345 %s %s",
+ real_cmd, cmd_args);
+ g_free (real_cmd);
+
+ gdb_args[1] = NULL;
+
+ args = beaver_util_strv_joinv ((gchar **)ssh_options, ip_args, gdb_args, NULL);
+
+ if (!priv->debug_msg_view)
+ {
+ /* Create a new view */
+ msg_manager = beaver_target_get_message_manager (target);
+ priv->debug_msg_view = ianjuta_message_manager_add_view (msg_manager,
+ _("Remote Debug"), ICON_FILE, &error);
+
+ if (!priv->debug_msg_view)
+ {
+ g_warning ("Error getting view: %s", error->message);
+ g_propagate_error (out_err, error);
+ return FALSE;
+ } else {
+ g_signal_connect (priv->debug_msg_view, "buffer-flushed",
+ (GCallback)beaver_util_message_view_buffer_flushed_cb, NULL);
+
+ /* When the view is destroyed make the pointer to it null */
+ g_object_add_weak_pointer (G_OBJECT (priv->debug_msg_view),
+ (gpointer *)&priv->debug_msg_view);
+
+ ianjuta_message_manager_set_current_view (msg_manager, priv->debug_msg_view,
+ &error);
+
+ if (error != NULL)
+ {
+ g_warning ("Error setting current message view: %s", error->message);
+ g_clear_error (&error);
+ }
+ }
+ }
+
+ if (anjuta_launcher_execute_v (priv->debug_launcher, args, debug_launcher_data_cb, target))
+ {
+ beaver_target_set_state (target, TARGET_STATE_BUSY);
+ return TRUE;
+ } else {
+ gchar *debug_str = NULL;
+
+ debug_str = g_strjoinv (" ", args);
+ g_warning ("Error whilst launching command: %s", debug_str);
+ g_free (debug_str);
+ g_free (args);
+
+ return FALSE;
+ }
+}
+
static void
launcher_child_exited_cb (AnjutaLauncher *launcher, gint child_pid,
gint status, gulong time, gpointer userdata)
@@ -319,3 +431,25 @@ launcher_data_cb (AnjutaLauncher *launcher,
}
}
+static void
+debug_launcher_data_cb (AnjutaLauncher *launcher,
+ AnjutaLauncherOutputType type, const gchar *chars, gpointer userdata)
+{
+ BeaverTargetPrivate *priv = TARGET_PRIVATE (userdata);
+ GError *error = NULL;
+
+ if (priv->debug_msg_view)
+ {
+ /* Append to the buffer for the message view to deal with the newlines */
+ ianjuta_message_view_buffer_append (priv->debug_msg_view, chars, &error);
+
+ if (error != NULL)
+ {
+ g_warning ("Error appending to message view: %s", error->message);
+ g_clear_error (&error);
+ }
+ } else {
+ g_warning ("No message view to append to.");
+ }
+}
+
diff --git a/src/beaver-target.h b/src/beaver-target.h
index 0b3bf7f..6fa8ab2 100644
--- a/src/beaver-target.h
+++ b/src/beaver-target.h
@@ -75,6 +75,8 @@ typedef struct {
GError **error);
gboolean (* run_remote) (BeaverTarget *target, gchar *cmd,
GError **error);
+ gboolean (* remote_debug) (BeaverTarget *target, gchar *cmd, gchar *args,
+ GError **error);
} BeaverTargetClass;
GType beaver_target_get_type (void);
@@ -85,8 +87,8 @@ const gchar *beaver_target_get_ip_address (BeaverTarget *target);
IAnjutaMessageManager *beaver_target_get_message_manager (BeaverTarget *target);
gboolean beaver_target_run_remote_v (BeaverTarget *target, gchar **in_args,
GError **error);
-gboolean beaver_target_run_remote (BeaverTarget *target, gchar *cmd,
- GError **error);
+gboolean beaver_target_remote_debug (BeaverTarget *target, gchar *cmd,
+ gchar *args, GError **error);
G_END_DECLS