forked from qt-creator/qt-creator
Debugger: Fix Utils::FilePath dumper for "remote" windows paths
A path was considered relative (only) when it started with a slash, not e.g. "C:/...". This led to display of the "./" "relative path marker" in these cases. "remote" windows paths regularly occur for baremetal executables on a Windows host. Change-Id: I082ae1cfb473ce2009d830fa98759d65a45735b5 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -202,6 +202,46 @@ def qdump__CPlusPlus__Internal__Value(d, value):
|
||||
d.putPlainChildren(value)
|
||||
|
||||
|
||||
def is_windows_drive_letter(ch):
|
||||
return (ch >= ord('A') and ch <= ord('Z')) or (ch >= ord('a') and ch <= ord('z'))
|
||||
|
||||
def is_relative_filepath_enc(path_enc):
|
||||
# Note: path is hex-encoded UTF-16 here, i.e. 4 byte per original QChar
|
||||
"""
|
||||
This needs to stay in sync with the implementation on the C++ side
|
||||
in filepath.cpp.
|
||||
|
||||
bool isWindowsDriveLetter(QChar ch)
|
||||
{
|
||||
return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
|
||||
}
|
||||
bool startsWithWindowsDriveLetterAndSlash(QStringView path)
|
||||
{
|
||||
return path.size() > 2 && path[1] == ':' && path[2] == '/
|
||||
&& isWindowsDriveLetter(path[0]);
|
||||
}
|
||||
bool FilePath::isRelativePath() const
|
||||
{
|
||||
const QStringView p = pathView();
|
||||
if (p.startsWith('/'))
|
||||
return false;
|
||||
if (startsWithWindowsDriveLetterAndSlash(p))
|
||||
return false;
|
||||
if (p.startsWith(u":/")) // QRC
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
"""
|
||||
colon = "3A00"
|
||||
slash = "2F00"
|
||||
if path_enc.startswith(slash):
|
||||
return False
|
||||
if path_enc[4:12] == colon + slash and is_windows_drive_letter(int(path_enc[0:2], 16)):
|
||||
return False
|
||||
if path_enc.startswith(colon + slash):
|
||||
return False
|
||||
return True
|
||||
|
||||
def qdump__Utils__FilePath(d, value):
|
||||
data, path_len, scheme_len, host_len = d.split("{@QString}IHH", value)
|
||||
length, enc = d.encodeStringHelper(data, d.displayStringLimit)
|
||||
@@ -216,8 +256,10 @@ def qdump__Utils__FilePath(d, value):
|
||||
dot = "2E00"
|
||||
colon = "3A00"
|
||||
val = scheme_enc + colon + slash + slash + host_enc
|
||||
if not path_enc.startswith(slash):
|
||||
if is_relative_filepath_enc(path_enc):
|
||||
val += slash + dot + slash
|
||||
elif is_windows_drive_letter(int(path_enc[0:2], 16)):
|
||||
val += slash
|
||||
val += path_enc
|
||||
else:
|
||||
val = enc
|
||||
|
Reference in New Issue
Block a user