GNOME Bugzilla – Bug 791188
Setting breakpoints for c code build under flatpak fails
Last modified: 2017-12-05 02:46:39 UTC
Running a debug session for any c project compiled with flatpak the only breakpoint that works is the initial one (stop on main function). Using host it works correctly Does this reproduce for you? It doesn't make a difference, but as I will post code references I show here the source code used https://github.com/albfan/gtask-example/ Seing log for debug session, main function is located in a main.c file which path is like: Temporary breakpoint 1, main (argc=1, argv=0x7ffd97005c08) at ../../../../../../../../../Projects/gtask-example/src/main.c:61 Asking for relative and full path for source files to gdb: -file-list-exec-source-files you get a long list (shortened here to interesting file): files=[ {file="../../../../../../../../../Projects/gtask-example/src/main.c" ,fullname="/home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589ae573-local-flatpak-org.gnome.Platform-x86_64-master/../../../../../../../../../Projects/gtask-example/src/main.c"} ... It seems that gdb operates from a reference to builddir: /home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589a e573-local-flatpak-org.gnome.Platform-x86_64-master I do ask gdb about its current working directory: -environment-pwd And says it is /home/alberto Looking at path Builder pass to gdb /home/alberto/Projects/gtask-example/src/main.c it should be the same path (as applying ../ all the builddir dirs disappears) But for whatever reason it doesn't. This patch makes it work: translating replacing /home/alberto/ into buildir + (several ../) I really don't know how to do this cleanly, so this is only a WIP. To convert Builder file /home/alberto/Projects/gtask-example/src/main.c into gdb known file path: /home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589ae573-local-flatpak-org.gnome.Platform-x86_64-master/../../../../../../../../../Projects/gtask-example/src/main.c I guess we should: 1. Remove cwd from builddir .var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589ae573-local-flatpak-org.gnome.Platform-x86_64-master/ 2 turn all that paths into .. ../../../../../../../../../ 3. concat that with builddir /home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589ae573-local-flatpak-org.gnome.Platform-x86_64-master/ + ../../../../../../../../../ 4. Remove cwd from Builder path Projects/gtask-example/src/main.c 5. concat /home/alberto/.var/app/org.gnome.Builder/cache/gnome-builder/projects/gtask-example/builds/org.gnome.Gtask-Example.json-0601fcfb2fbf01231dd228e0b218301c589ae573-local-flatpak-org.gnome.Platform-x86_64-master/../../../../../../../../../ + Projects/gtask-example/src/main.c I think I can implement that if the algorithm is correct, but maybe there's something better that will fix this
Created attachment 364883 [details] [review] translate Builder source file breakpoint into a path understandable by gdb Just a WIP about the algorithm exposed
Created attachment 364961 [details] [review] gdb resolve source paths relative to builddir
Created attachment 364963 [details] [review] non-canonical path helper This adds a helper we can use for non-canonical paths (along with tests to prove the implementation).
Created attachment 364984 [details] [review] Use glib helper to uncanonicalize paths
Pushed with some cleanups.