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.
This commit is contained in:
Jan Kratochvil 2013-08-28 17:52:03 +00:00
parent 602e3198bc
commit 1f0c498857
13 changed files with 168 additions and 28 deletions

View file

@ -102,6 +102,9 @@ exec_close (void)
exec_bfd_mtime = 0;
remove_target_sections (&exec_bfd);
xfree (exec_filename);
exec_filename = NULL;
}
}
@ -179,12 +182,13 @@ exec_file_attach (char *filename, int from_tty)
else
{
struct cleanup *cleanups;
char *scratch_pathname;
char *scratch_pathname, *canonical_pathname;
int scratch_chan;
struct target_section *sections = NULL, *sections_end = NULL;
char **matching;
scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
scratch_chan = openp (getenv ("PATH"),
OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
@ -193,7 +197,9 @@ exec_file_attach (char *filename, int from_tty)
char *exename = alloca (strlen (filename) + 5);
strcat (strcpy (exename, filename), ".exe");
scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
scratch_chan = openp (getenv ("PATH"),
OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH,
exename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
}
@ -203,11 +209,16 @@ exec_file_attach (char *filename, int from_tty)
cleanups = make_cleanup (xfree, scratch_pathname);
/* gdb_bfd_open (and its variants) prefers canonicalized pathname for
better BFD caching. */
canonical_pathname = gdb_realpath (scratch_pathname);
make_cleanup (xfree, canonical_pathname);
if (write_files)
exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget,
exec_bfd = gdb_bfd_fopen (canonical_pathname, gnutarget,
FOPEN_RUB, scratch_chan);
else
exec_bfd = gdb_bfd_open (scratch_pathname, gnutarget, scratch_chan);
exec_bfd = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
if (!exec_bfd)
{
@ -215,6 +226,9 @@ exec_file_attach (char *filename, int from_tty)
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
gdb_assert (exec_filename == NULL);
exec_filename = xstrdup (scratch_pathname);
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
/* Make sure to close exec_bfd, or else "run" might try to use