gdb_realpath: Rework comment about handling on Windows.
Rework the comment to explain why we're still relying on GetFullPathName even though gnulib ensures that canonicalize_file_name is now available on all platforms, including Windows. gdb/ChangeLog: * utils.c (gdb_realpath): Rework comment about handling on Windows.
This commit is contained in:
parent
6a29c58ef8
commit
0fa9473ff0
|
@ -1,3 +1,8 @@
|
||||||
|
2014-11-28 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* utils.c (gdb_realpath): Rework comment about handling on
|
||||||
|
Windows.
|
||||||
|
|
||||||
2014-11-28 Yao Qi <yao@codesourcery.com>
|
2014-11-28 Yao Qi <yao@codesourcery.com>
|
||||||
|
|
||||||
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
|
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
|
||||||
|
|
36
gdb/utils.c
36
gdb/utils.c
|
@ -2868,20 +2868,38 @@ string_to_core_addr (const char *my_string)
|
||||||
char *
|
char *
|
||||||
gdb_realpath (const char *filename)
|
gdb_realpath (const char *filename)
|
||||||
{
|
{
|
||||||
/* The MS Windows method. If we don't have realpath, we assume we
|
/* On most hosts, we rely on canonicalize_file_name to compute
|
||||||
don't have symlinks and just canonicalize to a Windows absolute
|
the FILENAME's realpath.
|
||||||
path. GetFullPath converts ../ and ./ in relative paths to
|
|
||||||
absolute paths, filling in current drive if one is not given
|
But the situation is slightly more complex on Windows, due to some
|
||||||
or using the current directory of a specified drive (eg, "E:foo").
|
versions of GCC which were reported to generate paths where
|
||||||
It also converts all forward slashes to back slashes. */
|
backlashes (the directory separator) were doubled. For instance:
|
||||||
/* The file system is case-insensitive but case-preserving.
|
c:\\some\\double\\slashes\\dir
|
||||||
So we do not lowercase the path. Otherwise, we might not
|
... instead of ...
|
||||||
be able to display the original casing in a given path. */
|
c:\some\double\slashes\dir
|
||||||
|
Those double-slashes were getting in the way when comparing paths,
|
||||||
|
for instance when trying to insert a breakpoint as follow:
|
||||||
|
(gdb) b c:/some/double/slashes/dir/foo.c:4
|
||||||
|
No source file named c:/some/double/slashes/dir/foo.c:4.
|
||||||
|
(gdb) b c:\some\double\slashes\dir\foo.c:4
|
||||||
|
No source file named c:\some\double\slashes\dir\foo.c:4.
|
||||||
|
To prevent this from happening, we need this function to always
|
||||||
|
strip those extra backslashes. While canonicalize_file_name does
|
||||||
|
perform this simplification, it only works when the path is valid.
|
||||||
|
Since the simplification would be useful even if the path is not
|
||||||
|
valid (one can always set a breakpoint on a file, even if the file
|
||||||
|
does not exist locally), we rely instead on GetFullPathName to
|
||||||
|
perform the canonicalization. */
|
||||||
|
|
||||||
#if defined (_WIN32)
|
#if defined (_WIN32)
|
||||||
{
|
{
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
|
DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
|
||||||
|
|
||||||
|
/* The file system is case-insensitive but case-preserving.
|
||||||
|
So it is important we do not lowercase the path. Otherwise,
|
||||||
|
we might not be able to display the original casing in a given
|
||||||
|
path. */
|
||||||
if (len > 0 && len < MAX_PATH)
|
if (len > 0 && len < MAX_PATH)
|
||||||
return xstrdup (buf);
|
return xstrdup (buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue