splhack created this revision. Herald added a project: All. splhack requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
D152759 <https://reviews.llvm.org/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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D153390 Files: lldb/source/Host/common/ZipFileResolver.cpp Index: lldb/source/Host/common/ZipFileResolver.cpp =================================================================== --- lldb/source/Host/common/ZipFileResolver.cpp +++ lldb/source/Host/common/ZipFileResolver.cpp @@ -25,6 +25,15 @@ static constexpr llvm::StringLiteral k_zip_separator("!/"); std::string path(file_spec.GetPath()); size_t pos = path.find(k_zip_separator); + +#if defined(_WIN32) + // When the file_spec is resolved as a Windows path, the zip .so path will be + // "zip_path!\so_path". Support both patterns on Windows. + static constexpr llvm::StringLiteral k_zip_separator_win("!\\"); + if (pos == std::string::npos) + pos = path.find(k_zip_separator_win); +#endif + if (pos == std::string::npos) { // This file_spec does not contain the zip separator. // Treat this file_spec as a normal file. @@ -40,6 +49,12 @@ std::string zip_path(path.substr(0, pos)); std::string so_path(path.substr(pos + k_zip_separator.size())); +#if defined(_WIN32) + // Replace the .so path to use POSIX file separator for file searching inside + // the zip file. + std::replace(so_path.begin(), so_path.end(), '\\', '/'); +#endif + // Try to find the .so file from the zip file. FileSpec zip_file_spec(zip_path); uint64_t zip_file_size = FileSystem::Instance().GetByteSize(zip_file_spec);
Index: lldb/source/Host/common/ZipFileResolver.cpp =================================================================== --- lldb/source/Host/common/ZipFileResolver.cpp +++ lldb/source/Host/common/ZipFileResolver.cpp @@ -25,6 +25,15 @@ static constexpr llvm::StringLiteral k_zip_separator("!/"); std::string path(file_spec.GetPath()); size_t pos = path.find(k_zip_separator); + +#if defined(_WIN32) + // When the file_spec is resolved as a Windows path, the zip .so path will be + // "zip_path!\so_path". Support both patterns on Windows. + static constexpr llvm::StringLiteral k_zip_separator_win("!\\"); + if (pos == std::string::npos) + pos = path.find(k_zip_separator_win); +#endif + if (pos == std::string::npos) { // This file_spec does not contain the zip separator. // Treat this file_spec as a normal file. @@ -40,6 +49,12 @@ std::string zip_path(path.substr(0, pos)); std::string so_path(path.substr(pos + k_zip_separator.size())); +#if defined(_WIN32) + // Replace the .so path to use POSIX file separator for file searching inside + // the zip file. + std::replace(so_path.begin(), so_path.end(), '\\', '/'); +#endif + // Try to find the .so file from the zip file. FileSpec zip_file_spec(zip_path); uint64_t zip_file_size = FileSystem::Instance().GetByteSize(zip_file_spec);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits