Skip to content

Commit e409f85

Browse files
authored
[DWP] Fix default for continue-on-cu-index-overflow (#75540)
This is follow up for #71902. The default option --continue-on-cu-index-overflow returned an error --continue-on-cu-index-overflow: missing argument. Changed it so that it is the same behavior as other flags like -gsplit-dwarf. Where --continue-on-cu-index-overflow will default to continue, and user can set mode with --continue-on-cu-index-overflow=\<value>.
1 parent 1821bc1 commit e409f85

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

llvm/test/tools/llvm-dwp/X86/simple.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ RUN: llvm-dwarfdump -v %t | FileCheck --check-prefixes=CHECK,NOTYP %s
33
RUN: llvm-objdump -h %t | FileCheck --check-prefix=NOTYPOBJ %s
44
RUN: llvm-dwp %p/../Inputs/simple/types/a.dwo %p/../Inputs/simple/types/b.dwo -o - \
55
RUN: | llvm-dwarfdump -v - | FileCheck --check-prefixes=CHECK,TYPES %s
6+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t --continue-on-cu-index-overflow
7+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t --continue-on-cu-index-overflow=continue
8+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t --continue-on-cu-index-overflow=soft-stop
9+
RUN: not llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t --continue-on-cu-index-overflow=foobar
10+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t -continue-on-cu-index-overflow
11+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t -continue-on-cu-index-overflow=continue
12+
RUN: llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t -continue-on-cu-index-overflow=soft-stop
13+
RUN: not llvm-dwp %p/../Inputs/simple/notypes/a.dwo %p/../Inputs/simple/notypes/b.dwo -o %t -continue-on-cu-index-overflow=foobar
614

715
DWP from non-type-unit debug info for these two translation units:
816
a.cpp:

llvm/tools/llvm-dwp/Opts.td

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def version : F<"version", "Display the version of this program">;
99

1010
def execFileNames : S<"e", "Specify the executable/library files to get the list of *.dwo from.">, MetaVarName<"<filename>">;
1111
def outputFileName : S<"o", "Specify the output file.">, MetaVarName<"<filename>">;
12-
def continueOnCuIndexOverflow : S<"continue-on-cu-index-overflow", "default = continue, This turns an error when offset "
13-
"for .debug_*.dwo sections overfolws into a warning. = soft-stop, This produces a "
14-
"truncated but valid DWP file, discarding any DWO files that would not fit within "
15-
"the 32 bit/4GB limits of the format.">, MetaVarName<"<filename>">;
12+
def continueOnCuIndexOverflow : Flag<["-", "--"], "continue-on-cu-index-overflow">;
13+
def continueOnCuIndexOverflow_EQ : Joined<["-", "--"], "continue-on-cu-index-overflow=">,
14+
HelpText<"default = continue, This turns an error when offset \n"
15+
"\t\tfor .debug_*.dwo sections overfolws into a warning. = soft-stop, This produces a \n"
16+
"\t\ttruncated but valid DWP file, discarding any DWO files that would not fit within \n"
17+
"\t\tthe 32 bit/4GB limits of the format.">,
18+
Values<"continue,soft-stop">;

llvm/tools/llvm-dwp/llvm-dwp.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,21 @@ int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
144144
}
145145

146146
OutputFilename = Args.getLastArgValue(OPT_outputFileName, "");
147-
if (Args.hasArg(OPT_continueOnCuIndexOverflow)) {
148-
ContinueOption =
149-
Args.getLastArgValue(OPT_continueOnCuIndexOverflow, "continue");
150-
if (ContinueOption == "soft-stop") {
151-
OverflowOptValue = OnCuIndexOverflow::SoftStop;
152-
} else {
147+
if (Arg *Arg = Args.getLastArg(OPT_continueOnCuIndexOverflow,
148+
OPT_continueOnCuIndexOverflow_EQ)) {
149+
if (Arg->getOption().matches(OPT_continueOnCuIndexOverflow)) {
153150
OverflowOptValue = OnCuIndexOverflow::Continue;
151+
} else {
152+
ContinueOption = Arg->getValue();
153+
if (ContinueOption == "soft-stop") {
154+
OverflowOptValue = OnCuIndexOverflow::SoftStop;
155+
} else if (ContinueOption == "continue") {
156+
OverflowOptValue = OnCuIndexOverflow::Continue;
157+
} else {
158+
llvm::errs() << "invalid value for --continue-on-cu-index-overflow"
159+
<< ContinueOption << '\n';
160+
exit(1);
161+
}
154162
}
155163
}
156164

0 commit comments

Comments
 (0)