llvm.org GIT mirror llvm / d353c91
[dsymutil] Support multiple input files on the command line git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243777 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
3 changed file(s) with 44 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
0 REQUIRES: shell
1 RUN: cat %p/../Inputs/basic.macho.x86_64 > %t1
2 RUN: cat %p/../Inputs/basic-archive.macho.x86_64 > %t2
3 RUN: cat %p/../Inputs/basic-lto.macho.x86_64 > %t3
4 RUN: cat %p/../Inputs/basic-lto-dw4.macho.x86_64 > %t4
5 RUN: llvm-dsymutil -oso-prepend-path=%p/.. %t1 %t2 %t3 %t4
6 RUN: llvm-dwarfdump %t1.dwarf \
7 | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=BASIC
8 RUN: llvm-dwarfdump %t2.dwarf \
9 | FileCheck %S/basic-linking-x86.test --check-prefix=CHECK --check-prefix=ARCHIVE
10 RUN: llvm-dwarfdump %t3.dwarf | FileCheck %S/basic-lto-linking-x86.test
11 RUN: llvm-dwarfdump %t4.dwarf | FileCheck %S/basic-lto-dw4-linking-x86.test
0 RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
11 RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
22 RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK-ARCHIVE
3 RUN: llvm-dsymutil -no-output -verbose -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 %p/Inputs/basic-lto.macho.x86_64 %p/Inputs/basic-archive.macho.x86_64 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LTO --check-prefix=CHECK-ARCHIVE
34
45 This test check the basic Dwarf linking process through the debug dumps.
56
3030 static opt Help("h", desc("Alias for -help"), Hidden);
3131 static opt Version("v", desc("Alias for -version"), Hidden);
3232
33 static opt InputFile(Positional, desc(""),
34 init("a.out"), cat(DsymCategory));
33 static list InputFiles(Positional, OneOrMore,
34 desc(""), cat(DsymCategory));
3535
3636 static opt
3737 OutputFileOpt("o",
8989 return 0;
9090 }
9191
92 auto DebugMapPtrOrErr =
93 parseDebugMap(InputFile, OsoPrependPath, Verbose, InputIsYAMLDebugMap);
94
9592 Options.Verbose = Verbose;
9693 Options.NoOutput = NoOutput;
9794 Options.NoODR = NoODR;
10198 llvm::InitializeAllTargets();
10299 llvm::InitializeAllAsmPrinters();
103100
104 if (auto EC = DebugMapPtrOrErr.getError()) {
105 llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
106 << "\": " << EC.message() << '\n';
101 if (InputFiles.size() > 1 && !OutputFileOpt.empty()) {
102 llvm::errs() << "error: cannot use -o with multiple inputs\n";
107103 return 1;
108104 }
109105
110 if (Verbose || DumpDebugMap)
111 (*DebugMapPtrOrErr)->print(llvm::outs());
106 for (auto &InputFile : InputFiles) {
107 auto DebugMapPtrOrErr =
108 parseDebugMap(InputFile, OsoPrependPath, Verbose, InputIsYAMLDebugMap);
112109
113 if (DumpDebugMap)
114 return 0;
110 if (auto EC = DebugMapPtrOrErr.getError()) {
111 llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
112 << "\": " << EC.message() << '\n';
113 return 1;
114 }
115115
116 std::string OutputFile;
117 if (OutputFileOpt.empty()) {
118 if (InputFile == "-")
119 OutputFile = "a.out.dwarf";
120 else
121 OutputFile = InputFile + ".dwarf";
122 } else {
123 OutputFile = OutputFileOpt;
116 if (Verbose || DumpDebugMap)
117 (*DebugMapPtrOrErr)->print(llvm::outs());
118
119 if (DumpDebugMap)
120 continue;
121
122 std::string OutputFile;
123 if (OutputFileOpt.empty()) {
124 if (InputFile == "-")
125 OutputFile = "a.out.dwarf";
126 else
127 OutputFile = InputFile + ".dwarf";
128 } else {
129 OutputFile = OutputFileOpt;
130 }
131
132 if (!linkDwarf(OutputFile, **DebugMapPtrOrErr, Options))
133 return 1;
124134 }
125135
126 return !linkDwarf(OutputFile, **DebugMapPtrOrErr, Options);
136 return 0;
127137 }