forked from OSchip/llvm-project
[llvm-dwp] Report the filename if it cannot be found
For now, we report nothing if the execution/dwo file is missing, which is confusing. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D133549
This commit is contained in:
parent
ecf327f154
commit
734843ebc7
|
@ -586,8 +586,12 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
||||||
|
|
||||||
for (const auto &Input : Inputs) {
|
for (const auto &Input : Inputs) {
|
||||||
auto ErrOrObj = object::ObjectFile::createObjectFile(Input);
|
auto ErrOrObj = object::ObjectFile::createObjectFile(Input);
|
||||||
if (!ErrOrObj)
|
if (!ErrOrObj) {
|
||||||
return ErrOrObj.takeError();
|
return handleErrors(ErrOrObj.takeError(),
|
||||||
|
[&](std::unique_ptr<ECError> EC) -> Error {
|
||||||
|
return createFileError(Input, Error(std::move(EC)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
auto &Obj = *ErrOrObj->getBinary();
|
auto &Obj = *ErrOrObj->getBinary();
|
||||||
Objects.push_back(std::move(*ErrOrObj));
|
Objects.push_back(std::move(*ErrOrObj));
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
RUN: rm -rf %t
|
||||||
|
RUN: mkdir %t
|
||||||
|
RUN: cd %t
|
||||||
|
RUN: cp %p/../Inputs/dwos_list_from_exec/b.dwo b.dwo
|
||||||
|
RUN: cp %p/../Inputs/dwos_list_from_exec/main main
|
||||||
|
RUN: not llvm-dwp -e binary -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-BIN
|
||||||
|
RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-1ST-DWO
|
||||||
|
RUN: cp %p/../Inputs/dwos_list_from_exec/a.dwo a.dwo
|
||||||
|
RUN: rm b.dwo
|
||||||
|
RUN: not llvm-dwp -e main -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-2ND-DWO
|
||||||
|
|
||||||
|
Build commands for the test binaries:
|
||||||
|
|
||||||
|
clang++ -Xclang -fdebug-compilation-dir -Xclang "./" -g -O0 -gsplit-dwarf a.cpp b.cpp -o main
|
||||||
|
|
||||||
|
sources:
|
||||||
|
a.cpp:
|
||||||
|
void a() {}
|
||||||
|
|
||||||
|
b.cpp:
|
||||||
|
void b() {}
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK-BIN: error: 'binary': {{[Nn]}}o such file or directory
|
||||||
|
CHECK-1ST-DWO: error: './a.dwo': {{[Nn]}}o such file or directory
|
||||||
|
CHECK-2ND-DWO: error: './b.dwo': {{[Nn]}}o such file or directory
|
|
@ -111,7 +111,13 @@ int main(int argc, char **argv) {
|
||||||
for (const auto &ExecFilename : ExecFilenames) {
|
for (const auto &ExecFilename : ExecFilenames) {
|
||||||
auto DWOs = getDWOFilenames(ExecFilename);
|
auto DWOs = getDWOFilenames(ExecFilename);
|
||||||
if (!DWOs) {
|
if (!DWOs) {
|
||||||
logAllUnhandledErrors(DWOs.takeError(), WithColor::error());
|
logAllUnhandledErrors(
|
||||||
|
handleErrors(DWOs.takeError(),
|
||||||
|
[&](std::unique_ptr<ECError> EC) -> Error {
|
||||||
|
return createFileError(ExecFilename,
|
||||||
|
Error(std::move(EC)));
|
||||||
|
}),
|
||||||
|
WithColor::error());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DWOFilenames.insert(DWOFilenames.end(),
|
DWOFilenames.insert(DWOFilenames.end(),
|
||||||
|
@ -127,7 +133,13 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
auto ErrOrTriple = readTargetTriple(DWOFilenames.front());
|
auto ErrOrTriple = readTargetTriple(DWOFilenames.front());
|
||||||
if (!ErrOrTriple) {
|
if (!ErrOrTriple) {
|
||||||
logAllUnhandledErrors(ErrOrTriple.takeError(), WithColor::error());
|
logAllUnhandledErrors(
|
||||||
|
handleErrors(ErrOrTriple.takeError(),
|
||||||
|
[&](std::unique_ptr<ECError> EC) -> Error {
|
||||||
|
return createFileError(DWOFilenames.front(),
|
||||||
|
Error(std::move(EC)));
|
||||||
|
}),
|
||||||
|
WithColor::error());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue