Skip to content

Commit ae391a2

Browse files
author
Alex B
committed
Address Feedback Nr.6
1 parent fda812c commit ae391a2

File tree

9 files changed

+25
-22
lines changed

9 files changed

+25
-22
lines changed

llvm/include/llvm/DebugInfo/GSYM/CallSiteInfo.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class CallSiteInfoLoader {
8686
/// structures.
8787
///
8888
/// \param GCreator A reference to the GsymCreator.
89-
CallSiteInfoLoader(GsymCreator &GCreator) : GCreator(GCreator) {}
89+
CallSiteInfoLoader(GsymCreator &GCreator, std::vector<FunctionInfo> &Funcs)
90+
: GCreator(GCreator), Funcs(Funcs) {}
9091

9192
/// This method reads the specified YAML file, parses its content, and updates
9293
/// the `Funcs` vector with call site information based on the YAML data.
@@ -97,7 +98,7 @@ class CallSiteInfoLoader {
9798
/// file to be loaded.
9899
/// \returns An `llvm::Error` indicating success or describing any issues
99100
/// encountered during the loading process.
100-
llvm::Error loadYAML(std::vector<FunctionInfo> &Funcs, StringRef YAMLFile);
101+
llvm::Error loadYAML(StringRef YAMLFile);
101102

102103
private:
103104
/// Builds a map from function names to FunctionInfo pointers based on the
@@ -106,7 +107,7 @@ class CallSiteInfoLoader {
106107
/// \param Funcs A reference to a vector of FunctionInfo objects.
107108
/// \returns A StringMap mapping function names (StringRef) to their
108109
/// corresponding FunctionInfo pointers.
109-
StringMap<FunctionInfo *> buildFunctionMap(std::vector<FunctionInfo> &Funcs);
110+
StringMap<FunctionInfo *> buildFunctionMap();
110111

111112
/// Processes the parsed YAML functions and updates the `FuncMap` accordingly.
112113
///
@@ -121,6 +122,9 @@ class CallSiteInfoLoader {
121122

122123
/// Reference to the parent Gsym Creator object.
123124
GsymCreator &GCreator;
125+
126+
/// Reference to the vector of FunctionInfo objects to be populated.
127+
std::vector<FunctionInfo> &Funcs;
124128
};
125129

126130
raw_ostream &operator<<(raw_ostream &OS, const CallSiteInfo &CSI);

llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,15 @@ class GsymCreator {
329329
/// \returns The unique 32 bit offset into the string table.
330330
uint32_t insertString(StringRef S, bool Copy = true);
331331

332-
/// Retrieve a string fromt he GSYM string table given its offset.
332+
/// Retrieve a string from the GSYM string table given its offset.
333333
///
334334
/// The offset is assumed to be a valid offset into the string table.
335335
/// otherwise an assert will be triggered.
336336
///
337-
/// \param offset The offset of the string to retrieve, previously returned by
338-
/// insertString. \returns The string at the given offset in the string table.
339-
StringRef getString(uint32_t offset);
337+
/// \param Offset The offset of the string to retrieve, previously returned by
338+
/// insertString.
339+
/// \returns The string at the given offset in the string table.
340+
StringRef getString(uint32_t Offset);
340341

341342
/// Insert a file into this GSYM creator.
342343
///

llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ template <> struct MappingTraits<FunctionsYAML> {
149149
LLVM_YAML_IS_SEQUENCE_VECTOR(CallSiteYAML)
150150
LLVM_YAML_IS_SEQUENCE_VECTOR(FunctionYAML)
151151

152-
Error CallSiteInfoLoader::loadYAML(std::vector<FunctionInfo> &Funcs,
153-
StringRef YAMLFile) {
152+
Error CallSiteInfoLoader::loadYAML(StringRef YAMLFile) {
154153
// Step 1: Read YAML file
155154
auto BufferOrError = MemoryBuffer::getFile(YAMLFile);
156155
if (!BufferOrError)
@@ -167,14 +166,13 @@ Error CallSiteInfoLoader::loadYAML(std::vector<FunctionInfo> &Funcs,
167166
Buffer->getBufferIdentifier().str().c_str());
168167

169168
// Step 3: Build function map from Funcs
170-
auto FuncMap = buildFunctionMap(Funcs);
169+
auto FuncMap = buildFunctionMap();
171170

172171
// Step 4: Process parsed YAML functions and update FuncMap
173172
return processYAMLFunctions(FuncsYAML, FuncMap);
174173
}
175174

176-
StringMap<FunctionInfo *>
177-
CallSiteInfoLoader::buildFunctionMap(std::vector<FunctionInfo> &Funcs) {
175+
StringMap<FunctionInfo *> CallSiteInfoLoader::buildFunctionMap() {
178176
// If the function name is already in the map, don't update it. This way we
179177
// preferentially use the first encountered function. Since symbols are
180178
// loaded from dSYM first, we end up preferring keeping track of symbols

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ llvm::Error GsymCreator::encode(FileWriter &O) const {
191191

192192
llvm::Error GsymCreator::loadCallSitesFromYAML(StringRef YAMLFile) {
193193
// Use the loader to load call site information from the YAML file.
194-
CallSiteInfoLoader Loader(*this);
195-
return Loader.loadYAML(Funcs, YAMLFile);
194+
CallSiteInfoLoader Loader(*this, Funcs);
195+
return Loader.loadYAML(YAMLFile);
196196
}
197197

198198
void GsymCreator::prepareMergedFunctions(OutputAggregator &Out) {

llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-callsite-info-dsym.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: split-file %s %t
55
# RUN: yaml2obj %t/call_sites.dSYM.yaml -o %t/call_sites.dSYM
66

7-
# RUN: llvm-gsymutil --convert=%t/call_sites.dSYM --callsites-from-yaml=%t/callsites.yaml -o %t/call_sites_dSYM.gsym
7+
# RUN: llvm-gsymutil --convert=%t/call_sites.dSYM --callsites-yaml-file=%t/callsites.yaml -o %t/call_sites_dSYM.gsym
88

99
# Dump the GSYM file and check the output for callsite information
1010
# RUN: llvm-gsymutil %t/call_sites_dSYM.gsym | FileCheck --check-prefix=CHECK-GSYM %s

llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-callsite-info-exe.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: split-file %s %t
55
# RUN: yaml2obj %t/call_sites.exe.yaml -o %t/call_sites.exe
66

7-
# RUN: llvm-gsymutil --convert=%t/call_sites.exe --callsites-from-yaml=%t/callsites.yaml -o %t/call_sites_exe.gsym
7+
# RUN: llvm-gsymutil --convert=%t/call_sites.exe --callsites-yaml-file=%t/callsites.yaml -o %t/call_sites_exe.gsym
88

99
# Dump the GSYM file and check the output for callsite information
1010
# RUN: llvm-gsymutil %t/call_sites_exe.gsym | FileCheck --check-prefix=CHECK-GSYM %s

llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-callsite-info-obj.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Assemble the input assembly code into an object file
44
// RUN: llc -enable-machine-outliner=never -mtriple arm64-apple-darwin -filetype=obj %t/call_sites.ll -o %t/call_sites.o
5-
// RUN: llvm-gsymutil --convert=%t/call_sites.o --callsites-from-yaml=%t/callsites.yaml -o %t/call_sites_obj.gsym
5+
// RUN: llvm-gsymutil --convert=%t/call_sites.o --callsites-yaml-file=%t/callsites.yaml -o %t/call_sites_obj.gsym
66

77
// Dump the GSYM file and check the output for callsite information
88
// RUN: llvm-gsymutil %t/call_sites_obj.gsym | FileCheck --check-prefix=CHECK-GSYM %s

llvm/tools/llvm-gsymutil/Opts.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ defm convert :
1818
"Convert the specified file to the GSYM format.\nSupported files include ELF and mach-o files that will have their debug info (DWARF) and symbol table converted">;
1919
def merged_functions :
2020
FF<"merged-functions", "Encode merged function information for functions in debug info that have matching address ranges.\nWithout this option one function per unique address range will be emitted.">;
21-
defm callsites_from_yaml :
22-
Eq<"callsites-from-yaml", "Load call site info from YAML file.">;
21+
defm callsites_yaml_file :
22+
Eq<"callsites-yaml-file", "Load call site info from YAML file.">;
2323
defm arch :
2424
Eq<"arch",
2525
"Process debug information for the specified CPU architecture only.\nArchitectures may be specified by name or by number.\nThis option can be specified multiple times, once for each desired architecture">;

llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ static void parseArgs(int argc, char **argv) {
180180
LookupAddressesFromStdin = Args.hasArg(OPT_addresses_from_stdin);
181181
StoreMergedFunctionInfo = Args.hasArg(OPT_merged_functions);
182182

183-
if (Args.hasArg(OPT_callsites_from_yaml_EQ)) {
184-
CallSiteYamlPath = Args.getLastArgValue(OPT_callsites_from_yaml_EQ);
183+
if (Args.hasArg(OPT_callsites_yaml_file_EQ)) {
184+
CallSiteYamlPath = Args.getLastArgValue(OPT_callsites_yaml_file_EQ);
185185
if (CallSiteYamlPath.empty()) {
186186
llvm::errs()
187187
<< ToolName
188-
<< ": --callsites-from-yaml option requires a non-empty argument.\n";
188+
<< ": --callsites-yaml-file option requires a non-empty argument.\n";
189189
std::exit(1);
190190
}
191191
}

0 commit comments

Comments
 (0)