Extend the llvm-dwp to support searching the DWOs that from relative path for the
case that build from remote building system(different comp_dir).
Reviewd By: dblaikie
Differential Revision: https://reviews.llvm.org/D133480
--- /dev/null
+RUN: rm -rf %t
+RUN: mkdir %t
+RUN: cd %t
+RUN: cp %p/../Inputs/search_dwos/a.dwo a.dwo
+RUN: cp %p/../Inputs/search_dwos/b.dwo b.dwo
+RUN: cp %p/../Inputs/search_dwos/main main
+RUN: llvm-dwp -e main -o %t.dwp
+
+Search the DWO from relative path if absolute path is not valid.
+Build commands for the test binaries:
+
+clang++ -Xclang -fdebug-compilation-dir -Xclang "path-not-exists" -g -O0 -gsplit-dwarf a.cpp b.cpp -o main
+
+sources:
+a.cpp:
+ void a() {}
+
+b.cpp:
+ void b() {}
+ int main() {
+ return 0;
+ }
if (!DWOCompDir.empty()) {
SmallString<16> DWOPath(std::move(DWOName));
sys::fs::make_absolute(DWOCompDir, DWOPath);
- DWOPaths.emplace_back(DWOPath.data(), DWOPath.size());
+ if (!sys::fs::exists(DWOPath) && sys::fs::exists(DWOName))
+ DWOPaths.push_back(std::move(DWOName));
+ else
+ DWOPaths.emplace_back(DWOPath.data(), DWOPath.size());
} else {
DWOPaths.push_back(std::move(DWOName));
}