Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 917287
Collapse All | Expand All

(-)a/gdb/exec.c (-10 / +4 lines)
Lines 386-392 exec_file_attach (const char *filename, int from_tty) Link Here
386
  else
386
  else
387
    {
387
    {
388
      int load_via_target = 0;
388
      int load_via_target = 0;
389
      const char *scratch_pathname, *canonical_pathname;
389
      const char *scratch_pathname;
390
      int scratch_chan;
390
      int scratch_chan;
391
      char **matching;
391
      char **matching;
392
392
Lines 398-404 exec_file_attach (const char *filename, int from_tty) Link Here
398
	    load_via_target = 1;
398
	    load_via_target = 1;
399
	}
399
	}
400
400
401
      gdb::unique_xmalloc_ptr<char> canonical_storage, scratch_storage;
401
      gdb::unique_xmalloc_ptr<char> scratch_storage;
402
      if (load_via_target)
402
      if (load_via_target)
403
	{
403
	{
404
	  /* gdb_bfd_fopen does not support "target:" filenames.  */
404
	  /* gdb_bfd_fopen does not support "target:" filenames.  */
Lines 409-415 exec_file_attach (const char *filename, int from_tty) Link Here
409
409
410
	  scratch_pathname = filename;
410
	  scratch_pathname = filename;
411
	  scratch_chan = -1;
411
	  scratch_chan = -1;
412
	  canonical_pathname = scratch_pathname;
413
	}
412
	}
414
      else
413
      else
415
	{
414
	{
Lines 437-455 exec_file_attach (const char *filename, int from_tty) Link Here
437
	    perror_with_name (filename);
436
	    perror_with_name (filename);
438
437
439
	  scratch_pathname = scratch_storage.get ();
438
	  scratch_pathname = scratch_storage.get ();
440
441
	  /* gdb_bfd_open (and its variants) prefers canonicalized
442
	     pathname for better BFD caching.  */
443
	  canonical_storage = gdb_realpath (scratch_pathname);
444
	  canonical_pathname = canonical_storage.get ();
445
	}
439
	}
446
440
447
      gdb_bfd_ref_ptr temp;
441
      gdb_bfd_ref_ptr temp;
448
      if (write_files && !load_via_target)
442
      if (write_files && !load_via_target)
449
	temp = gdb_bfd_fopen (canonical_pathname, gnutarget,
443
	temp = gdb_bfd_fopen (scratch_pathname, gnutarget,
450
			      FOPEN_RUB, scratch_chan);
444
			      FOPEN_RUB, scratch_chan);
451
      else
445
      else
452
	temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
446
	temp = gdb_bfd_open (scratch_pathname, gnutarget, scratch_chan);
453
      current_program_space->set_exec_bfd (std::move (temp));
447
      current_program_space->set_exec_bfd (std::move (temp));
454
448
455
      if (!current_program_space->exec_bfd ())
449
      if (!current_program_space->exec_bfd ())
(-)a/gdb/symfile.c (-1 / +1 lines)
Lines 1707-1713 symfile_bfd_open (const char *name) Link Here
1707
1707
1708
      /* Look down path for it, allocate 2nd new malloc'd copy.  */
1708
      /* Look down path for it, allocate 2nd new malloc'd copy.  */
1709
      desc = openp (getenv ("PATH"),
1709
      desc = openp (getenv ("PATH"),
1710
		    OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
1710
		    OPF_TRY_CWD_FIRST,
1711
		    expanded_name.get (), O_RDONLY | O_BINARY, &absolute_name);
1711
		    expanded_name.get (), O_RDONLY | O_BINARY, &absolute_name);
1712
#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
1712
#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
1713
      if (desc < 0)
1713
      if (desc < 0)
(-)a/gdb/testsuite/gdb.base/symlink-exe.exp (-1 / +57 lines)
Line 0 Link Here
0
- 
1
# Copyright 2022 Free Software Foundation, Inc.
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
16
if {![isnative]} {
17
    unsupported "symlink-exe.exp not supported on non-native target"
18
    return -1
19
}
20
21
if {[is_remote host]} {
22
    unsupported "symlink-exe.exp not supported on remote host"
23
    return -1
24
}
25
26
# We don't really care about the contents, but we're going to build
27
# two executables here and they need different source file names.
28
standard_testfile main.c argv0-symlink.c
29
30
if {[build_executable ${testfile}.exp ${testfile}1 ${srcfile}] == -1} {
31
    return -1
32
}
33
34
set status [remote_exec host \
35
		"ln -sf ${testfile}1 [standard_output_file ${testfile}]"]
36
if {[lindex $status 0] != 0} {
37
    unsupported "symlink-exe.exp - host does not support symbolic links"
38
    return -1
39
}
40
41
clean_restart $testfile
42
gdb_test "run" ".*"
43
44
# Ensure the new file has a newer mtime.
45
sleep 1
46
if {[build_executable ${testfile}.exp ${testfile}2 ${srcfile2}] == -1} {
47
    return -1
48
}
49
set status [remote_exec host \
50
		"ln -sf ${testfile}2 [standard_output_file ${testfile}]"]
51
if {[lindex $status 0] != 0} {
52
    unsupported "symlink-exe.exp - host does not support symbolic links"
53
    return -1
54
}
55
56
gdb_test "run" ".*${testfile}.* has changed; re-reading symbols.*" \
57
    "run and re-read symbols"

Return to bug 917287