[Xfce4-commits] <midori:master> Add --debug/ -g switch to run Midori in gdb
Christian Dywan
noreply at xfce.org
Thu Feb 21 02:14:03 CET 2013
Updating branch refs/heads/master
to f94fb69664749d3ae463dd0dfc2a4745fd8a69e3 (commit)
from 5c6d70db33a1c5eaabfae6399cff8dd0e2b1d113 (commit)
commit f94fb69664749d3ae463dd0dfc2a4745fd8a69e3
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Feb 21 02:08:03 2013 +0100
Add --debug/ -g switch to run Midori in gdb
extensions/addons.c | 2 +-
katze/midori-paths.vala | 8 +++++---
midori/main.c | 17 +++++++++++++++++
midori/midori-browser.c | 6 +++---
midori/midori-view.c | 2 +-
midori/sokoke.c | 20 ++++++++++++++------
midori/sokoke.h | 3 ++-
7 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/extensions/addons.c b/extensions/addons.c
index 08c14b1..1ce19c4 100644
--- a/extensions/addons.c
+++ b/extensions/addons.c
@@ -482,7 +482,7 @@ addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
g_object_get (settings, "text-editor", &text_editor, NULL);
if (text_editor && *text_editor)
- sokoke_spawn_program (text_editor, TRUE, element->fullpath, TRUE);
+ sokoke_spawn_program (text_editor, TRUE, element->fullpath, TRUE, FALSE);
else
{
gchar* element_uri = g_filename_to_uri (element->fullpath, NULL, NULL);
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 50de349..05d2b05 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -276,7 +276,7 @@ namespace Midori {
#endif
if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
stdout.printf ("command_line: %s\nexec_path: %s\nres: %s\nlib: %s\n",
- get_command_line_str (), exec_path,
+ get_command_line_str (true), exec_path,
get_res_filename (""), get_lib_path (PACKAGE_NAME));
}
}
@@ -286,9 +286,11 @@ namespace Midori {
return command_line;
}
- public static string get_command_line_str () {
+ public static string get_command_line_str (bool for_display) {
assert (command_line != null);
- return string.joinv (" ", command_line).replace (Environment.get_home_dir (), "~");
+ if (for_display)
+ return string.joinv (" ", command_line).replace (Environment.get_home_dir (), "~");
+ return string.joinv (" ", command_line).replace ("--debug", "").replace ("-g", "");
}
public static string get_lib_path (string package) {
diff --git a/midori/main.c b/midori/main.c
index 9037abd..9c5463f 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -73,6 +73,7 @@ main (int argc,
gboolean portable;
gboolean plain;
gboolean diagnostic_dialog = FALSE;
+ gboolean debug = FALSE;
gboolean run;
gchar* snapshot;
gboolean execute;
@@ -97,6 +98,8 @@ main (int argc,
N_("Plain GTK+ window with WebKit, akin to GtkLauncher"), NULL },
{ "diagnostic-dialog", 'd', 0, G_OPTION_ARG_NONE, &diagnostic_dialog,
N_("Show a diagnostic dialog"), NULL },
+ { "debug", 'g', 0, G_OPTION_ARG_NONE, &debug,
+ N_("Run within gdb and save a backtrace on crash"), NULL },
{ "run", 'r', 0, G_OPTION_ARG_NONE, &run,
N_("Run the specified filename as javascript"), NULL },
{ "snapshot", 's', 0, G_OPTION_ARG_STRING, &snapshot,
@@ -135,6 +138,20 @@ main (int argc,
inactivity_reset = 0;
midori_app_setup (&argc, &argv, entries);
+ if (debug)
+ {
+ gchar* args = midori_paths_get_command_line_str (FALSE);
+ gchar* cmd = g_strdup_printf (
+ "--batch -ex 'set print thread-events off' -ex run "
+ "-ex bt -ex 'set logging on %s' --return-child-result "
+ "--args %s",
+ "/tmp/midori-gdb.bt", args);
+ sokoke_spawn_program ("gdb", TRUE, cmd, FALSE, TRUE);
+ g_free (cmd);
+ g_free (args);
+ return 0;
+ }
+
g_set_application_name (_("Midori"));
/* Versioned prgname to override menuproxy blacklist */
g_set_prgname (PACKAGE_NAME "4");
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 6580533..cc30ae4 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2450,9 +2450,9 @@ midori_browser_subscribe_to_news_feed (MidoriBrowser* browser,
/* Special-case Liferea because a helper script may be required */
if (g_str_equal (browser->news_aggregator, "liferea")
&& g_find_program_in_path ("liferea-add-feed"))
- sokoke_spawn_program ("liferea-add-feed", FALSE, feed, TRUE);
+ sokoke_spawn_program ("liferea-add-feed", FALSE, feed, TRUE, FALSE);
else
- sokoke_spawn_program (browser->news_aggregator, TRUE, feed, TRUE);
+ sokoke_spawn_program (browser->news_aggregator, TRUE, feed, TRUE, FALSE);
g_free (feed);
}
else
@@ -3397,7 +3397,7 @@ _action_source_view_activate (GtkAction* action,
}
else
{
- sokoke_spawn_program (text_editor, TRUE, filename, TRUE);
+ sokoke_spawn_program (text_editor, TRUE, filename, TRUE, FALSE);
g_free (filename);
}
g_free (text_editor);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 6aae10b..a465768 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3998,7 +3998,7 @@ midori_view_set_uri (MidoriView* view,
}
else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version"))
{
- gchar* command_line = midori_paths_get_command_line_str ();
+ gchar* command_line = midori_paths_get_command_line_str (TRUE);
gchar* architecture, *platform;
const gchar* sys_name = midori_web_settings_get_system_name (
&architecture, &platform);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 90cddc8..5da6cb3 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -131,7 +131,7 @@ sokoke_open_with_response_cb (GtkWidget* dialog,
{
const gchar* command = gtk_entry_get_text (entry);
const gchar* uri = g_object_get_data (G_OBJECT (dialog), "uri");
- sokoke_spawn_program (command, FALSE, uri, TRUE);
+ sokoke_spawn_program (command, FALSE, uri, TRUE, FALSE);
}
gtk_widget_destroy (dialog);
}
@@ -337,6 +337,7 @@ sokoke_prepare_command (const gchar* command,
* @argument: any arguments, properly quoted
* @quote_command: if %TRUE, @command will be quoted
* @quote_argument: if %TRUE, @argument will be quoted, ie. a URI or filename
+ * @sync: spawn synchronously and wait for command to exit
*
* If @command contains %s, @argument will be quoted and inserted into
* @command, which is left unquoted regardless of @quote_command.
@@ -347,7 +348,8 @@ gboolean
sokoke_spawn_program (const gchar* command,
gboolean quote_command,
const gchar* argument,
- gboolean quote_argument)
+ gboolean quote_argument,
+ gboolean sync)
{
GError* error;
gchar* command_ready;
@@ -372,9 +374,15 @@ sokoke_spawn_program (const gchar* command,
g_free (command_ready);
error = NULL;
- if (!g_spawn_async (NULL, argv, NULL,
- (GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &error))
+ if (sync)
+ g_spawn_sync (NULL, argv, NULL,
+ (GSpawnFlags)G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, NULL, NULL, &error);
+ else
+ g_spawn_async (NULL, argv, NULL,
+ (GSpawnFlags)G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, NULL, NULL, &error);
+ if (error != NULL)
{
sokoke_message_dialog (GTK_MESSAGE_ERROR,
_("Could not run external program."),
@@ -402,7 +410,7 @@ sokoke_spawn_app (const gchar* uri,
else
argument = g_strconcat ("-a ", uri_quoted, NULL);
g_free (uri_quoted);
- sokoke_spawn_program (executable, TRUE, argument, FALSE);
+ sokoke_spawn_program (executable, TRUE, argument, FALSE, FALSE);
g_free (argument);
}
diff --git a/midori/sokoke.h b/midori/sokoke.h
index 2019321..e076c5c 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -52,7 +52,8 @@ gboolean
sokoke_spawn_program (const gchar* command,
gboolean quote_command,
const gchar* argument,
- gboolean quote_argument);
+ gboolean quote_argument,
+ gboolean sync);
void
sokoke_spawn_app (const gchar* uri,
More information about the Xfce4-commits
mailing list