[gnome-builder] gdb: resolve source paths relative to builddir



commit 63d4a45221dcc8fc257fb425a72ddf54512cb862
Author: albfan <albertofanjul gmail com>
Date:   Tue Dec 5 00:40:52 2017 +0100

    gdb: resolve source paths relative to builddir
    
    This uses the ide_g_file_get_uncanonical_relative_path() helper to get
    a file path that is more likely to match what gdb expects for the
    --source argument when adding a breakpoint.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791188

 src/plugins/gdb/gbp-gdb-debugger.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gdb/gbp-gdb-debugger.c b/src/plugins/gdb/gbp-gdb-debugger.c
index 8c60c3b..812483d 100644
--- a/src/plugins/gdb/gbp-gdb-debugger.c
+++ b/src/plugins/gdb/gbp-gdb-debugger.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "gbp-gdb-debugger.h"
+#include "util/ide-glib.h"
 
 #define READ_BUFFER_LEN 4096
 
@@ -1195,8 +1196,10 @@ gbp_gdb_debugger_insert_breakpoint_async (IdeDebugger           *debugger,
                                           gpointer               user_data)
 {
   GbpGdbDebugger *self = (GbpGdbDebugger *)debugger;
+  g_autofree gchar *translated_file = NULL;
   g_autoptr(GString) command = NULL;
   g_autoptr(GTask) task = NULL;
+  g_autoptr(GFile) gfile = NULL;
   IdeDebuggerAddress addr;
   const gchar *func;
   const gchar *file;
@@ -1224,6 +1227,16 @@ gbp_gdb_debugger_insert_breakpoint_async (IdeDebugger           *debugger,
   line = ide_debugger_breakpoint_get_line (breakpoint);
   addr = ide_debugger_breakpoint_get_address (breakpoint);
 
+  /* Possibly translate the file to be relative to builddir, as that is
+   * what gdb seems to want from us. That is possibly going to be specific
+   * to the build system, and we may need some more massaging here in the
+   * future to get the right thing.
+   */
+  gfile = g_file_new_for_path (file);
+  translated_file = ide_g_file_get_uncanonical_relative_path (self->builddir, gfile);
+  if (translated_file != NULL)
+    file = translated_file;
+
   if (file != NULL && line > 0)
     {
       g_string_append_printf (command, " --source %s", file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]