Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.

gdb/
2013-09-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
	* cli/cli-cmds.c (find_and_open_script): Add OPF_RETURN_REALPATH to
	variable search_flags.
	* defs.h (OPF_DISABLE_REALPATH): Rename to ...
	(OPF_RETURN_REALPATH): ... here.
	* dwarf2read.c (try_open_dwop_file): Set OPF_RETURN_REALPATH for flags.
	* exec.c (exec_file_attach): Remove OPF_DISABLE_REALPATH from openp
	call.  Twice.
	* nto-tdep.c (nto_find_and_open_solib): Add OPF_RETURN_REALPATH for
	openp call.
	* solib.c (solib_find): Likewise.  Four times.
	* source.c (openp): Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH
	in the function comment and for the realpath_fptr variable.
	(source_full_path_of): Add OPF_RETURN_REALPATH for openp call.
	(find_and_open_source): Likewise.  Twice.
	* symfile.c (symfile_bfd_open): Likewise, also twice.
This commit is contained in:
Jan Kratochvil 2013-09-04 20:09:39 +00:00
parent 23a44de810
commit 492c0ab72a
9 changed files with 50 additions and 28 deletions

View File

@ -1,3 +1,22 @@
2013-09-04 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
* cli/cli-cmds.c (find_and_open_script): Add OPF_RETURN_REALPATH to
variable search_flags.
* defs.h (OPF_DISABLE_REALPATH): Rename to ...
(OPF_RETURN_REALPATH): ... here.
* dwarf2read.c (try_open_dwop_file): Set OPF_RETURN_REALPATH for flags.
* exec.c (exec_file_attach): Remove OPF_DISABLE_REALPATH from openp
call. Twice.
* nto-tdep.c (nto_find_and_open_solib): Add OPF_RETURN_REALPATH for
openp call.
* solib.c (solib_find): Likewise. Four times.
* source.c (openp): Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH
in the function comment and for the realpath_fptr variable.
(source_full_path_of): Add OPF_RETURN_REALPATH for openp call.
(find_and_open_source): Likewise. Twice.
* symfile.c (symfile_bfd_open): Likewise, also twice.
2013-09-04 Doug Evans <dje@google.com>
* progspace.c (save_current_space_and_thread): Remove unnecessary

View File

@ -479,7 +479,7 @@ find_and_open_script (const char *script_file, int search_path,
char *file;
int fd;
struct cleanup *old_cleanups;
int search_flags = OPF_TRY_CWD_FIRST;
int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
file = tilde_expand (script_file);
old_cleanups = make_cleanup (xfree, file);

View File

@ -349,7 +349,7 @@ extern const char *pc_prefix (CORE_ADDR);
/* See openp function definition for their description. */
#define OPF_TRY_CWD_FIRST 0x01
#define OPF_SEARCH_IN_PATH 0x02
#define OPF_DISABLE_REALPATH 0x04
#define OPF_RETURN_REALPATH 0x04
extern int openp (const char *, int, const char *, int, char **);

View File

@ -9349,7 +9349,7 @@ try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
else
search_path = xstrdup (debug_file_directory);
flags = 0;
flags = OPF_RETURN_REALPATH;
if (is_dwp)
flags |= OPF_SEARCH_IN_PATH;
desc = openp (search_path, flags, file_name,

View File

@ -187,8 +187,7 @@ exec_file_attach (char *filename, int from_tty)
struct target_section *sections = NULL, *sections_end = NULL;
char **matching;
scratch_chan = openp (getenv ("PATH"),
OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
@ -197,9 +196,7 @@ 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 | OPF_DISABLE_REALPATH,
exename,
scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
}

View File

@ -128,7 +128,8 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
arch_path);
base = lbasename (solib);
ret = openp (buf, OPF_TRY_CWD_FIRST, base, o_flags, temp_pathname);
ret = openp (buf, OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, base, o_flags,
temp_pathname);
if (ret < 0 && base != solib)
{
xsnprintf (arch_path, arch_len, "/%s", solib);

View File

@ -319,14 +319,16 @@ solib_find (char *in_pathname, int *fd)
/* If not found, search the solib_search_path (if any). */
if (found_file < 0 && solib_search_path != NULL)
found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
found_file = openp (solib_search_path,
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
in_pathname, O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, next search the solib_search_path (if any) for the basename
only (ignoring the path). This is to allow reading solibs from a path
that differs from the opened path. */
if (found_file < 0 && solib_search_path != NULL)
found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
found_file = openp (solib_search_path,
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
target_lbasename (fskind, in_pathname),
O_RDONLY | O_BINARY, &temp_pathname);
@ -339,16 +341,16 @@ solib_find (char *in_pathname, int *fd)
if (found_file < 0 && gdb_sysroot_is_empty)
found_file = openp (get_in_environ (current_inferior ()->environment,
"PATH"),
OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY,
&temp_pathname);
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, next search the inferior's $LD_LIBRARY_PATH
environment variable. */
if (found_file < 0 && gdb_sysroot_is_empty)
found_file = openp (get_in_environ (current_inferior ()->environment,
"LD_LIBRARY_PATH"),
OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY,
&temp_pathname);
OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
O_RDONLY | O_BINARY, &temp_pathname);
*fd = found_file;
return temp_pathname;

View File

@ -689,10 +689,10 @@ is_regular_file (const char *name)
and the file, sigh! Emacs gets confuzzed by this when we print the
source file name!!!
If OPTS does not have OPF_DISABLE_REALPATH set return FILENAME_OPENED
resolved by gdb_realpath. Even with OPF_DISABLE_REALPATH this function
still returns filename starting with "/". If FILENAME_OPENED is NULL
this option has no effect.
If OPTS has OPF_RETURN_REALPATH set return FILENAME_OPENED resolved by
gdb_realpath. Even without OPF_RETURN_REALPATH this function still returns
filename starting with "/". If FILENAME_OPENED is NULL this option has no
effect.
If a file is found, return the descriptor.
Otherwise, return -1, with errno set for the last name we tried to open. */
@ -857,8 +857,8 @@ done:
{
char *(*realpath_fptr) (const char *);
realpath_fptr = ((opts & OPF_DISABLE_REALPATH) != 0
? xstrdup : gdb_realpath);
realpath_fptr = ((opts & OPF_RETURN_REALPATH) != 0
? gdb_realpath : xstrdup);
if (IS_ABSOLUTE_PATH (filename))
*filename_opened = realpath_fptr (filename);
@ -897,8 +897,9 @@ source_full_path_of (const char *filename, char **full_pathname)
{
int fd;
fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, filename,
O_RDONLY, full_pathname);
fd = openp (source_path,
OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
filename, O_RDONLY, full_pathname);
if (fd < 0)
{
*full_pathname = NULL;
@ -1077,13 +1078,15 @@ find_and_open_source (const char *filename,
}
}
result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, fullname);
result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
OPEN_MODE, fullname);
if (result < 0)
{
/* Didn't work. Try using just the basename. */
p = lbasename (filename);
if (p != filename)
result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, fullname);
result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, p,
OPEN_MODE, fullname);
}
do_cleanups (cleanup);

View File

@ -1679,7 +1679,7 @@ symfile_bfd_open (char *name)
name = tilde_expand (name); /* Returns 1st new malloc'd copy. */
/* Look down path for it, allocate 2nd new malloc'd copy. */
desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, name,
desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
O_RDONLY | O_BINARY, &absolute_name);
#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
if (desc < 0)
@ -1687,8 +1687,8 @@ symfile_bfd_open (char *name)
char *exename = alloca (strlen (name) + 5);
strcat (strcpy (exename, name), ".exe");
desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
O_RDONLY | O_BINARY, &absolute_name);
desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH,
exename, O_RDONLY | O_BINARY, &absolute_name);
}
#endif
if (desc < 0)