[gnome-builder] sysprof: add more debug directories based on runtime
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] sysprof: add more debug directories based on runtime
- Date: Sun, 26 Feb 2017 06:39:23 +0000 (UTC)
commit 7d400e529ee5201618395bbdb822accbdffaa1ec
Author: Christian Hergert <chergert redhat com>
Date: Sat Feb 25 22:02:02 2017 -0800
sysprof: add more debug directories based on runtime
We might need to access debug files from inside a runtime, so sysprof
needs to be told about those locations.
We will still need more than this to get things working properly. For
example, we will want to ensure we have the Debug overlay available
which contains the symbols.
plugins/sysprof/configure.ac | 2 +-
plugins/sysprof/gbp-sysprof-workbench-addin.c | 59 +++++++++++++++++++++++++
2 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/plugins/sysprof/configure.ac b/plugins/sysprof/configure.ac
index b708f63..bbbf5b0 100644
--- a/plugins/sysprof/configure.ac
+++ b/plugins/sysprof/configure.ac
@@ -1,4 +1,4 @@
-m4_define(sysprof_required_version, [3.22.2])
+m4_define(sysprof_required_version, [3.23.91])
PKG_CHECK_MODULES(SYSPROF,
[sysprof-ui-2 >= sysprof_required_version],
diff --git a/plugins/sysprof/gbp-sysprof-workbench-addin.c b/plugins/sysprof/gbp-sysprof-workbench-addin.c
index 7606bd7..62fbefa 100644
--- a/plugins/sysprof/gbp-sysprof-workbench-addin.c
+++ b/plugins/sysprof/gbp-sysprof-workbench-addin.c
@@ -123,6 +123,32 @@ profiler_child_spawned (GbpSysprofWorkbenchAddin *self,
sp_profiler_start (self->profiler);
}
+static gchar *
+get_runtime_sysroot (IdeContext *context,
+ const gchar *path)
+{
+ IdeConfigurationManager *config_manager;
+ IdeConfiguration *config;
+ IdeRuntime *runtime;
+
+ g_assert (IDE_IS_CONTEXT (context));
+
+ config_manager = ide_context_get_configuration_manager (context);
+ config = ide_configuration_manager_get_current (config_manager);
+ runtime = ide_configuration_get_runtime (config);
+
+ if (runtime != NULL)
+ {
+ g_autoptr(GFile) base = g_file_new_for_path (path);
+ g_autoptr(GFile) translated = ide_runtime_translate_file (runtime, base);
+
+ if (translated != NULL)
+ return g_file_get_path (translated);
+ }
+
+ return NULL;
+}
+
static void
profiler_run_handler (IdeRunManager *run_manager,
IdeRunner *runner,
@@ -132,6 +158,8 @@ profiler_run_handler (IdeRunManager *run_manager,
g_autoptr(SpSource) proc_source = NULL;
g_autoptr(SpSource) perf_source = NULL;
g_autoptr(SpSource) hostinfo_source = NULL;
+ g_autofree gchar *sysroot = NULL;
+ IdeContext *context;
g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
g_assert (IDE_IS_RUNNER (runner));
@@ -144,6 +172,37 @@ profiler_run_handler (IdeRunManager *run_manager,
g_clear_object (&self->profiler);
}
+ /*
+ * First get a copy of the active runtime and find the root of it's
+ * translation path. That way we can adjust for the sysroot when
+ * resolving symbols.
+ *
+ * TODO: Hardcoding /usr and /app here sucks, we need a way to have
+ * this in the flatpak plugin instead (and associated plumbing
+ * to abstract it). We probably should just have a "get_debug_paths"
+ * type helper from the runtime.
+ */
+ {
+ static const gchar *dirs[] = {
+ "/usr/lib/debug",
+ "/app/lib",
+ "/app/lib/debug",
+ "/app/lib/debug/lib",
+ NULL
+ };
+
+ context = ide_object_get_context (IDE_OBJECT (run_manager));
+
+ for (guint i = 0; dirs[i]; i++)
+ {
+ gchar *path;
+
+ path = get_runtime_sysroot (context, dirs[i]);
+ sp_symbol_dirs_add (path);
+ g_free (path);
+ }
+ }
+
self->profiler = sp_local_profiler_new ();
g_signal_connect_object (self->profiler,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]