aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwp/llvm-dwp.cpp
diff options
context:
space:
mode:
authorJinjie Huang <huangjinjie@bytedance.com>2023-12-02 04:01:22 +0800
committerGitHub <noreply@github.com>2023-12-01 12:01:22 -0800
commit4c44dcffd5f1557bde2c21773221081437308895 (patch)
tree49ed0e0bf7b345d2278da204286362f1faa63b2c /llvm/tools/llvm-dwp/llvm-dwp.cpp
parent481e9b3e0b9c0a6843261f060822c7a41387e28c (diff)
downloadllvm-4c44dcffd5f1557bde2c21773221081437308895.zip
llvm-4c44dcffd5f1557bde2c21773221081437308895.tar.gz
llvm-4c44dcffd5f1557bde2c21773221081437308895.tar.bz2
Support soft failure on DWP section overflow, producing a truncated but valid DWP(#71902)
When 'ContinueOnCuIndexOverflow' enables without this modification, the forcibly generated '.dwp' won't be recognized by Debugger(gdb 10.1) correctly. <img width="657" alt="image" src="https://github.com/llvm/llvm-project/assets/150100070/31732775-2548-453a-a47a-fa04c6d05fe9"> it looks like there's a problem with processing the dwarf header, which makes debugging completely impossible. (unless the consumer walks the debug_info section to rebuild that column (if that's the only section that overflowed - if it's another section, there's no recovery)) **About patch:** When llvm-dwp enables option '--continue-on-cu-index-overflow=soft-stop' and recognizes the overflow problem , it will stop packing and generate the '.dwp' file at once, discarding any DWO files that would not fit within the 32 bit/4GB limits of the format. <img width="625" alt="image" src="https://github.com/llvm/llvm-project/assets/150100070/77d6be24-262b-4f4c-afc0-9a6c49e133c7">
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
-rw-r--r--llvm/tools/llvm-dwp/llvm-dwp.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index f976298..5cd4c00 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -71,7 +71,7 @@ public:
// Options
static std::vector<std::string> ExecFilenames;
static std::string OutputFilename;
-static bool ContinueOnCuIndexOverflow;
+static std::string ContinueOption;
static Expected<SmallVector<std::string, 16>>
getDWOFilenames(StringRef ExecFilename) {
@@ -125,6 +125,7 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
DwpOptTable Tbl;
llvm::BumpPtrAllocator A;
llvm::StringSaver Saver{A};
+ OnCuIndexOverflow OverflowOptValue = OnCuIndexOverflow::HardStop;
opt::InputArgList Args =
Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
llvm::errs() << Msg << '\n';
@@ -143,7 +144,15 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
}
OutputFilename = Args.getLastArgValue(OPT_outputFileName, "");
- ContinueOnCuIndexOverflow = Args.hasArg(OPT_continueOnCuIndexOverflow);
+ if (Args.hasArg(OPT_continueOnCuIndexOverflow)) {
+ ContinueOption =
+ Args.getLastArgValue(OPT_continueOnCuIndexOverflow, "continue");
+ if (ContinueOption == "soft-stop") {
+ OverflowOptValue = OnCuIndexOverflow::SoftStop;
+ } else {
+ OverflowOptValue = OnCuIndexOverflow::Continue;
+ }
+ }
for (const llvm::opt::Arg *A : Args.filtered(OPT_execFileNames))
ExecFilenames.emplace_back(A->getValue());
@@ -255,7 +264,7 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
if (!MS)
return error("no object streamer for target " + TripleName, Context);
- if (auto Err = write(*MS, DWOFilenames, ContinueOnCuIndexOverflow)) {
+ if (auto Err = write(*MS, DWOFilenames, OverflowOptValue)) {
logAllUnhandledErrors(std::move(Err), WithColor::error());
return 1;
}