Skip to content

Commit 5c4071d

Browse files
committed
[lldb][Windows] Fix ZipFileResolver tests
D152759 introduced the Android .zip so file support, but it only considered POSIX path. The code also runs on Windows, so the path could be Windows path. Support both patterns on Windows. Differential Revision: https://reviews.llvm.org/D153390
1 parent bd4bf49 commit 5c4071d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lldb/source/Host/common/ZipFileResolver.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ bool ZipFileResolver::ResolveSharedLibraryPath(const FileSpec &file_spec,
2525
static constexpr llvm::StringLiteral k_zip_separator("!/");
2626
std::string path(file_spec.GetPath());
2727
size_t pos = path.find(k_zip_separator);
28+
29+
#if defined(_WIN32)
30+
// When the file_spec is resolved as a Windows path, the zip .so path will be
31+
// "zip_path!\so_path". Support both patterns on Windows.
32+
static constexpr llvm::StringLiteral k_zip_separator_win("!\\");
33+
if (pos == std::string::npos)
34+
pos = path.find(k_zip_separator_win);
35+
#endif
36+
2837
if (pos == std::string::npos) {
2938
// This file_spec does not contain the zip separator.
3039
// Treat this file_spec as a normal file.
@@ -40,6 +49,12 @@ bool ZipFileResolver::ResolveSharedLibraryPath(const FileSpec &file_spec,
4049
std::string zip_path(path.substr(0, pos));
4150
std::string so_path(path.substr(pos + k_zip_separator.size()));
4251

52+
#if defined(_WIN32)
53+
// Replace the .so path to use POSIX file separator for file searching inside
54+
// the zip file.
55+
std::replace(so_path.begin(), so_path.end(), '\\', '/');
56+
#endif
57+
4358
// Try to find the .so file from the zip file.
4459
FileSpec zip_file_spec(zip_path);
4560
uint64_t zip_file_size = FileSystem::Instance().GetByteSize(zip_file_spec);

0 commit comments

Comments
 (0)