GNOME Bugzilla – Bug 172394
display "/usr/libexec" as path even if the file is not in this directory
Last modified: 2008-10-02 14:15:35 UTC
* crash an app usually using /usr/libexec on a Debian system which doesn't use /usr/libexec (ie: /usr/lib/netspeed/netspeed_applet2) * look on the bug-buddy text: "Backtrace was generated from '/usr/libexec/netspeed_applet2'" It should display the real path: "/usr/lib/netspeed/netspeed_applet2" and not "/usr/libexec/netspeed_applet2"
Why not use the target of the symlink /proc/$pid/exe instead of semi-hardcoding the path?
Good point. Do you want to cook a patch? :)
Hm, why do we need to know the path at all? 'gdp -p $pid' works fine for me.
Created attachment 79010 [details] [review] don't hardcode process name Anyway, here's a first stab at this. The approach I took was to try each method of getting the process' executable file in turn until one succeeds. IMO grovelling through PATH if none of the methods work is not useful since we have already seen how it gives the wrong result--especially unwanted if the path is being fed to gdb (GDB gets run on /usr/bin/gnome-terminal when I ran /home/sam/src/g-t/gnome-terminal...)
Is this bug still relevant since the bug-buddy rewrite & associated interface changes?
Yes, this is still relevant I guess. I'll have a look at this patch after branching for gnome-2-24.
Indeed, when my own applications crash, bug-buddy prints messages like this to the console: /usr/lib/bug-buddy/nitromap: No such file or directory.
Marking the patch as "needs-work", as it isn't ready to be committed. I want to work on this, but don't know how it works on Solaris, CC-ing Matt.
For Solaris the addendum to the patch attached here would be : + + /* Solaris - Similar to above just different location of symlink */ + { + gchar *link = g_strdup_printf ("/proc/%d/path/a.out", pid); + g_assert (link); + + GError *err = NULL; + gchar *exe = g_file_read_link (link, &err); + if (err == NULL) { + g_free (link); + return (exe); + } + g_message ("Could not read %s: %s\n", link, err->message); + g_clear_error (&err); + }
Thanks Matt and Sam, I committed a modified patch to trunk for this. I didn't commit the BSD snippet, as I am not sure recent BSD builds support /proc. If someone is interested, please write a patch. Also, I kept the old code so that unsupported platforms will still be able use that as a fallback and won't fail. 2008-09-25 Cosimo Cecchi <cosimoc@gnome.org> * src/gdb-buddy.c: (get_process_executable), (gdb_get_trace): Take the real path of the process from /proc, on supported platforms (Linux and Solaris). Thanks to Sam Morris and Matt Keenan (#172394).
*** Bug 490586 has been marked as a duplicate of this bug. ***