Summary: | gdb resolves symbolic links when passing argv[0] | ||
---|---|---|---|
Product: | gdb | Reporter: | Pedro Alves <pedro> |
Component: | gdb | Assignee: | Jan Kratochvil <jan> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | dak, dje, florian.baumert, ian, jan, janerikdahlin, lakkurvarun, sam |
Priority: | P2 | ||
Version: | 7.6 | ||
Target Milestone: | 7.6.1 | ||
See Also: | https://sourceware.org/bugzilla/show_bug.cgi?id=24143 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | Patch for following symlinks |
Description
Pedro Alves
2013-04-29 10:42:22 UTC
This is really flakey and has cost me several days effort on my project establishing that this is a gdb bug. Here are the gdb versions I have found this on and a short terminal session transcript: ian@nanny-ogg ~/src/lilypond/build (T3154)$ gdb --command ../.gdbinit GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Breakpoint 1 at 0x834b744: file /home/ian/src/lilypond/flower/warn.cc, line 191. Breakpoint 2 at 0x8147057: file /home/ian/src/lilypond/lily/grob.cc, line 729. (gdb) run Starting program: /home/ian/src/lilypond/build/lily/out/lilypond [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". GNU LilyPond 2.17.19 warning: not relocating, no 2.17.19/ or current/ found under /home/ian/src/lilypond/build/lily/share/lilypond/ ERROR: In procedure primitive-load-path: ERROR: Unable to find file "lily.scm" in load path [Inferior 1 (process 11595) exited with code 01] (gdb) ======================================================================= Replacing xfullpath with gdb_realname seems to have triggered this. http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/source.c.diff?r1=1.153.2.3&r2=1.136&cvsroot=src&f=h We use symbolic links to executables a lot, so this breaks our ability to debug programs at the moment. Sorry, gdb_realpath instead of gdb_realname. (In reply to Florian Baumert from comment #2) > Replacing xfullpath with gdb_realname seems to have triggered this. > > http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/source.c.diff?r1=1.153.2. > 3&r2=1.136&cvsroot=src&f=h > > We use symbolic links to executables a lot, so this breaks our ability to > debug programs at the moment. Created attachment 7108 [details]
Patch for following symlinks
Fix which works for me (at least in the cases we tried, not thoroughly tested)
Another thing to consider is auxiliary file names based on the name of the binary. e.g. ${foo}-gdb.py, ${foo}.dwp. I can imagine some situations wanting gdb to xfullpath $foo and I can imagine some situations wanting gdb to realpath $foo. gdb needs to either try both (maybe fullpath first, then realpath) or give the user a way to specify which one. [It would be simplest to do the former if that works in a sufficient number of cases.] Given that a realpath operation cannot be undone (one can't get back the original path), I suggest for now we go back to using xfullpath, and then start working on support for realpath. [patch] [7.6.1] Fix argv[0] symlink regression (PR 15415) https://sourceware.org/ml/gdb-patches/2013-08/msg00764.html Message-ID: <20130826182111.GA19509@host2.jankratochvil.net> CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2013-08-28 17:52:03 Modified files: gdb : ChangeLog corefile.c defs.h exec.c exec.h inferior.c progspace.c progspace.h source.c gdb/mi : mi-main.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.base: argv0-symlink.c argv0-symlink.exp Log message: PR gdb/15415 gdb/ 2013-08-27 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/15415 * corefile.c (get_exec_file): Use exec_filename. * defs.h (OPF_DISABLE_REALPATH): New definition. Add new comment. * exec.c (exec_close): Free EXEC_FILENAME. (exec_file_attach): New variable canonical_pathname. Use OPF_DISABLE_REALPATH. Call gdb_realpath explicitly. Set EXEC_FILENAME. * exec.h (exec_filename): New. * inferior.c (print_inferior, inferior_command): Use PSPACE_EXEC_FILENAME. * mi/mi-main.c (print_one_inferior): Likewise. * progspace.c (clone_program_space, print_program_space): Likewise. * progspace.h (struct program_space): New field pspace_exec_filename. * source.c (openp): Describe OPF_DISABLE_REALPATH. New variable realpath_fptr, initialize it from OPF_DISABLE_REALPATH, use it. gdb/testsuite/ 2013-08-27 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/15415 * gdb.base/argv0-symlink.c: New file. * gdb.base/argv0-symlink.exp: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15939&r2=1.15940 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/corefile.c.diff?cvsroot=src&r1=1.74&r2=1.75 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/defs.h.diff?cvsroot=src&r1=1.332&r2=1.333 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/exec.c.diff?cvsroot=src&r1=1.127&r2=1.128 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/exec.h.diff?cvsroot=src&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/inferior.c.diff?cvsroot=src&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/progspace.c.diff?cvsroot=src&r1=1.17&r2=1.18 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/progspace.h.diff?cvsroot=src&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/source.c.diff?cvsroot=src&r1=1.163&r2=1.164 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/mi/mi-main.c.diff?cvsroot=src&r1=1.238&r2=1.239 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3789&r2=1.3790 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/argv0-symlink.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/argv0-symlink.exp.diff?cvsroot=src&r1=NONE&r2=1.1 CVSROOT: /cvs/src Module name: src Branch: gdb_7_6-branch Changes by: jkratoch@sourceware.org 2013-08-28 17:55:56 Modified files: gdb : ChangeLog corefile.c defs.h exec.c exec.h inferior.c progspace.c progspace.h source.c gdb/mi : mi-main.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.base: argv0-symlink.c argv0-symlink.exp Log message: PR gdb/15415 gdb/ 2013-08-27 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/15415 * corefile.c (get_exec_file): Use exec_filename. * defs.h (OPF_DISABLE_REALPATH): New definition. Add new comment. * exec.c (exec_close): Free EXEC_FILENAME. (exec_file_attach): New variable canonical_pathname. Use OPF_DISABLE_REALPATH. Call gdb_realpath explicitly. Set EXEC_FILENAME. * exec.h (exec_filename): New. * inferior.c (print_inferior, inferior_command): Use PSPACE_EXEC_FILENAME. * mi/mi-main.c (print_one_inferior): Likewise. * progspace.c (clone_program_space, print_program_space): Likewise. * progspace.h (struct program_space): New field pspace_exec_filename. * source.c (openp): Describe OPF_DISABLE_REALPATH. New variable realpath_fptr, initialize it from OPF_DISABLE_REALPATH, use it. gdb/testsuite/ 2013-08-27 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/15415 * gdb.base/argv0-symlink.c: New file. * gdb.base/argv0-symlink.exp: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.15260.2.58&r2=1.15260.2.59 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/corefile.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.72&r2=1.72.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/defs.h.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.329&r2=1.329.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/exec.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.122&r2=1.122.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/exec.h.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.20&r2=1.20.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/inferior.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.41&r2=1.41.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/progspace.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.17&r2=1.17.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/progspace.h.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.12&r2=1.12.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/source.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.153.2.3&r2=1.153.2.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/mi/mi-main.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.228&r2=1.228.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=1.3580.2.23&r2=1.3580.2.24 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/argv0-symlink.c.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=NONE&r2=1.1.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/argv0-symlink.exp.diff?cvsroot=src&only_with_tag=gdb_7_6-branch&r1=NONE&r2=1.1.2.2 Fixed in trunk and for 7.6.1. CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2013-10-13 16:11:08 Modified files: gdb : ChangeLog exec.c utils.c utils.h gdb/testsuite : ChangeLog gdb/testsuite/gdb.base: argv0-symlink.exp Log message: Improve Executable displayed path (PR 15415 regression kind #2) gdb/ 2013-10-13 Jan Kratochvil <jan.kratochvil@redhat.com> Canonicalize directories for EXEC_FILENAME. * exec.c (exec_file_attach): Use gdb_realpath_keepfile for exec_filename. * utils.c (gdb_realpath_keepfile): New function. * utils.h (gdb_realpath_keepfile): New declaration. gdb/testsuite/ 2013-10-13 Jan Kratochvil <jan.kratochvil@redhat.com> Canonicalize directories for EXEC_FILENAME. * gdb.base/argv0-symlink.exp (kept file symbolic link name for info inferiors): New. (kept directory symbolic link name): Setup kfail. (kept directory symbolic link name for info inferiors): New. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.16100&r2=1.16101 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/exec.c.diff?cvsroot=src&r1=1.129&r2=1.130 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/utils.c.diff?cvsroot=src&r1=1.309&r2=1.310 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/utils.h.diff?cvsroot=src&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3835&r2=1.3836 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/argv0-symlink.exp.diff?cvsroot=src&r1=1.1&r2=1.2 The master branch has been updated by Sandra Loosemore <sandra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2ea1a07a0a6a15a55df28eeefddf71a4ac47e17d commit 2ea1a07a0a6a15a55df28eeefddf71a4ac47e17d Author: Sandra Loosemore <sandra@codesourcery.com> Date: Thu Aug 29 14:48:05 2019 -0700 Run argv0-symlink.exp only on native target and local host. This testcase was originally for PR gdb/15415, a problem with the "run" command expanding symlinks in the name of the program being run. It does not correctly distinguish between files on build, host, and target, and it is not clear if it would be testing anything useful in configurations where "run" is not being used. 2019-08-29 Sandra Loosemore <sandra@codesourcery.com> * gdb.base/argv0-symlink.exp: Run only on native target and local host. *** Bug 16079 has been marked as a duplicate of this bug. *** *** Bug 15652 has been marked as a duplicate of this bug. *** *** Bug 24143 has been marked as a duplicate of this bug. *** |