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> 2013-09-04 Doug Evans <dje@google.com>
* progspace.c (save_current_space_and_thread): Remove unnecessary * 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; char *file;
int fd; int fd;
struct cleanup *old_cleanups; 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); file = tilde_expand (script_file);
old_cleanups = make_cleanup (xfree, 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. */ /* See openp function definition for their description. */
#define OPF_TRY_CWD_FIRST 0x01 #define OPF_TRY_CWD_FIRST 0x01
#define OPF_SEARCH_IN_PATH 0x02 #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 **); 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 else
search_path = xstrdup (debug_file_directory); search_path = xstrdup (debug_file_directory);
flags = 0; flags = OPF_RETURN_REALPATH;
if (is_dwp) if (is_dwp)
flags |= OPF_SEARCH_IN_PATH; flags |= OPF_SEARCH_IN_PATH;
desc = openp (search_path, flags, file_name, 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; struct target_section *sections = NULL, *sections_end = NULL;
char **matching; char **matching;
scratch_chan = openp (getenv ("PATH"), scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname); &scratch_pathname);
#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__) #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); char *exename = alloca (strlen (filename) + 5);
strcat (strcpy (exename, filename), ".exe"); strcat (strcpy (exename, filename), ".exe");
scratch_chan = openp (getenv ("PATH"), scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH,
exename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname); &scratch_pathname);
} }

View File

@ -128,7 +128,8 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
arch_path); arch_path);
base = lbasename (solib); 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) if (ret < 0 && base != solib)
{ {
xsnprintf (arch_path, arch_len, "/%s", 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 not found, search the solib_search_path (if any). */
if (found_file < 0 && solib_search_path != NULL) 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); in_pathname, O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, next search the solib_search_path (if any) for the basename /* 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 only (ignoring the path). This is to allow reading solibs from a path
that differs from the opened path. */ that differs from the opened path. */
if (found_file < 0 && solib_search_path != NULL) 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), target_lbasename (fskind, in_pathname),
O_RDONLY | O_BINARY, &temp_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) if (found_file < 0 && gdb_sysroot_is_empty)
found_file = openp (get_in_environ (current_inferior ()->environment, found_file = openp (get_in_environ (current_inferior ()->environment,
"PATH"), "PATH"),
OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
&temp_pathname); O_RDONLY | O_BINARY, &temp_pathname);
/* If not found, next search the inferior's $LD_LIBRARY_PATH /* If not found, next search the inferior's $LD_LIBRARY_PATH
environment variable. */ environment variable. */
if (found_file < 0 && gdb_sysroot_is_empty) if (found_file < 0 && gdb_sysroot_is_empty)
found_file = openp (get_in_environ (current_inferior ()->environment, found_file = openp (get_in_environ (current_inferior ()->environment,
"LD_LIBRARY_PATH"), "LD_LIBRARY_PATH"),
OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, in_pathname,
&temp_pathname); O_RDONLY | O_BINARY, &temp_pathname);
*fd = found_file; *fd = found_file;
return temp_pathname; 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 and the file, sigh! Emacs gets confuzzed by this when we print the
source file name!!! source file name!!!
If OPTS does not have OPF_DISABLE_REALPATH set return FILENAME_OPENED If OPTS has OPF_RETURN_REALPATH set return FILENAME_OPENED resolved by
resolved by gdb_realpath. Even with OPF_DISABLE_REALPATH this function gdb_realpath. Even without OPF_RETURN_REALPATH this function still returns
still returns filename starting with "/". If FILENAME_OPENED is NULL filename starting with "/". If FILENAME_OPENED is NULL this option has no
this option has no effect. effect.
If a file is found, return the descriptor. If a file is found, return the descriptor.
Otherwise, return -1, with errno set for the last name we tried to open. */ Otherwise, return -1, with errno set for the last name we tried to open. */
@ -857,8 +857,8 @@ done:
{ {
char *(*realpath_fptr) (const char *); char *(*realpath_fptr) (const char *);
realpath_fptr = ((opts & OPF_DISABLE_REALPATH) != 0 realpath_fptr = ((opts & OPF_RETURN_REALPATH) != 0
? xstrdup : gdb_realpath); ? gdb_realpath : xstrdup);
if (IS_ABSOLUTE_PATH (filename)) if (IS_ABSOLUTE_PATH (filename))
*filename_opened = realpath_fptr (filename); *filename_opened = realpath_fptr (filename);
@ -897,8 +897,9 @@ source_full_path_of (const char *filename, char **full_pathname)
{ {
int fd; int fd;
fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, filename, fd = openp (source_path,
O_RDONLY, full_pathname); OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
filename, O_RDONLY, full_pathname);
if (fd < 0) if (fd < 0)
{ {
*full_pathname = NULL; *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) if (result < 0)
{ {
/* Didn't work. Try using just the basename. */ /* Didn't work. Try using just the basename. */
p = lbasename (filename); p = lbasename (filename);
if (p != 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); do_cleanups (cleanup);

View File

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