diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/beaver-target.c | 59 | ||||
-rw-r--r-- | src/beaver-target.h | 3 |
3 files changed, 69 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2008-04-07 Rob Bradford <rob@openedhand.com> + + * src/beaver-target.c: (beaver_target_finalize), + (_beaver_target_remote_debug), (debug_launcher_data_cb): + * src/beaver-target.h: + Add an extra DEBUGGER_READY state which we can use to find out if the + gdbserver is ready to start the client side. + 2008-04-04 Rob Bradford <rob@openedhand.com> * src/beaver-target.c: (beaver_target_class_init), diff --git a/src/beaver-target.c b/src/beaver-target.c index dac84f8..acf78c2 100644 --- a/src/beaver-target.c +++ b/src/beaver-target.c @@ -38,6 +38,8 @@ struct _BeaverTargetPrivate AnjutaLauncher *launcher; AnjutaLauncher *debug_launcher; + + gchar *debug_output; /* we need this for tracking if debugger is up and happy */ }; /* for signals */ @@ -131,6 +133,10 @@ beaver_target_dispose (GObject *object) static void beaver_target_finalize (GObject *object) { + BeaverTargetPrivate *priv = TARGET_PRIVATE (object); + + g_free (priv->debug_output); + G_OBJECT_CLASS (beaver_target_parent_class)->finalize (object); } @@ -342,6 +348,10 @@ _beaver_target_remote_debug (BeaverTarget *target, gchar *cmd, gchar *cmd_args, gchar *ip_args[] = {(gchar *)beaver_target_get_ip_address (target), NULL}; gchar *real_cmd = NULL; + /* clear out the old 'log' */ + g_free (priv->debug_output); + priv->debug_output = NULL; + /* Don't think this should ever happen since the text of the widget is "" */ if (cmd_args == NULL) cmd_args = ""; @@ -452,8 +462,11 @@ static void debug_launcher_data_cb (AnjutaLauncher *launcher, AnjutaLauncherOutputType type, const gchar *chars, gpointer userdata) { + BeaverTarget *target = BEAVER_TARGET (userdata); BeaverTargetPrivate *priv = TARGET_PRIVATE (userdata); GError *error = NULL; + gchar *old_debug_output = NULL; + gchar *chars_copy = NULL; if (priv->debug_msg_view) { @@ -468,5 +481,51 @@ debug_launcher_data_cb (AnjutaLauncher *launcher, } else { g_warning ("No message view to append to."); } + + /* + * Keep tabs on the output, we need to search this to find out whether our + * attempts to start the gdbserver have failed or whether the world is a + * happy place. + */ + chars_copy = g_strdup (chars); + g_strstrip (chars_copy); + + if (priv->debug_output) + { + old_debug_output = priv->debug_output; + priv->debug_output = g_strconcat (priv->debug_output, chars_copy, NULL); + g_free (old_debug_output); + g_free (chars_copy); + } else { + priv->debug_output = chars_copy; + } + + if (strstr (priv->debug_output, "Listening on port") && + strstr (priv->debug_output, "Child exited with retcode")) + { + if (!strstr (priv->debug_output, "retcode = 0")) + { + beaver_target_remote_debug_stop (target, NULL); + } + + anjuta_launcher_reset (priv->debug_launcher); + beaver_target_set_state (target, TARGET_STATE_READY); + + /* tidy up */ + g_free (priv->debug_output); + priv->debug_output = NULL; + } else if (strstr (priv->debug_output, "Listening on port")) { + + if (!strstr (priv->debug_output, "Terminated")) + { + /* FIXME: Should filter this out in the get/set state implementation */ + if (beaver_target_get_state (target) != TARGET_STATE_DEBUGGER_READY) + { + beaver_target_set_state (target, TARGET_STATE_DEBUGGER_READY); + } + } + } else { + /* do nothing */ + } } diff --git a/src/beaver-target.h b/src/beaver-target.h index 9e549e9..89ea4fe 100644 --- a/src/beaver-target.h +++ b/src/beaver-target.h @@ -53,7 +53,8 @@ typedef enum TARGET_STATE_UNKNOWN, TARGET_STATE_STOPPED, TARGET_STATE_READY, - TARGET_STATE_BUSY + TARGET_STATE_BUSY, + TARGET_STATE_DEBUGGER_READY } BeaverTargetState; typedef struct { |