Skip to content

Commit fdd4c39

Browse files
committed
fixup! SymbolContextList -> SymbolContext
1 parent b136560 commit fdd4c39

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,12 @@ class SymbolFile : public PluginInterface {
332332
/// Resolves the function corresponding to the specified LLDB function
333333
/// call \c label.
334334
///
335-
/// \param[in,out] sc_list The resolved functions will be appended to this
336-
/// list.
337-
///
338335
/// \param[in] label The FunctionCallLabel to be resolved.
339336
///
340337
/// \returns An llvm::Error if the specified \c label couldn't be resolved.
341-
/// Returns \c llvm::ErrorSuccess otherwise.
342-
virtual llvm::Error ResolveFunctionCallLabel(SymbolContextList &sc_list,
343-
const FunctionCallLabel &label) {
338+
/// Returns the resolved function (as a SymbolContext) otherwise.
339+
virtual llvm::Expected<SymbolContext>
340+
ResolveFunctionCallLabel(const FunctionCallLabel &label) {
344341
return llvm::createStringError("Not implemented");
345342
}
346343

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,14 @@ ResolveFunctionCallLabel(const FunctionCallLabel &label,
825825
return llvm::createStringError(
826826
llvm::formatv("no SymbolFile found on module {0:x}.", module_sp.get()));
827827

828-
SymbolContextList sc_list;
829-
if (auto err = symbol_file->ResolveFunctionCallLabel(sc_list, label))
828+
auto sc_or_err = symbol_file->ResolveFunctionCallLabel(label);
829+
if (!sc_or_err)
830830
return llvm::joinErrors(
831831
llvm::createStringError("failed to resolve function by UID"),
832-
std::move(err));
832+
sc_or_err.takeError());
833+
834+
SymbolContextList sc_list;
835+
sc_list.Append(*sc_or_err);
833836

834837
LoadAddressResolver resolver(*sc.target_sp, symbol_was_missing_weak);
835838
return resolver.Resolve(sc_list).value_or(LLDB_INVALID_ADDRESS);

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,9 +2471,8 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
24712471
return false;
24722472
}
24732473

2474-
llvm::Error
2475-
SymbolFileDWARF::ResolveFunctionCallLabel(SymbolContextList &sc_list,
2476-
const FunctionCallLabel &label) {
2474+
llvm::Expected<SymbolContext>
2475+
SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
24772476
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
24782477

24792478
DWARFDIE die = GetDIE(label.symbol_id);
@@ -2507,6 +2506,7 @@ SymbolFileDWARF::ResolveFunctionCallLabel(SymbolContextList &sc_list,
25072506
llvm::formatv("failed to find definition DIE for {0}", label));
25082507
}
25092508

2509+
SymbolContextList sc_list;
25102510
if (!ResolveFunction(die, /*include_inlines=*/false, sc_list))
25112511
return llvm::createStringError(
25122512
llvm::formatv("failed to resolve function for {0}", label));
@@ -2515,12 +2515,9 @@ SymbolFileDWARF::ResolveFunctionCallLabel(SymbolContextList &sc_list,
25152515
return llvm::createStringError(
25162516
llvm::formatv("failed to find function for {0}", label));
25172517

2518-
if (sc_list.GetSize() > 1)
2519-
return llvm::createStringError(
2520-
llvm::formatv("found {0} functions for {1} but expected only 1",
2521-
sc_list.GetSize(), label));
2518+
assert(sc_list.GetSize() == 1);
25222519

2523-
return llvm::Error::success();
2520+
return sc_list[0];
25242521
}
25252522

25262523
bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext &decl_ctx,

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ class SymbolFileDWARF : public SymbolFileCommon {
434434
DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die,
435435
DIEArray &&variable_dies);
436436

437-
llvm::Error ResolveFunctionCallLabel(SymbolContextList &sc_list,
438-
const FunctionCallLabel &label) override;
437+
llvm::Expected<SymbolContext>
438+
ResolveFunctionCallLabel(const FunctionCallLabel &label) override;
439439

440440
// Given a die_offset, figure out the symbol context representing that die.
441441
bool ResolveFunction(const DWARFDIE &die, bool include_inlines,

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,13 +1603,13 @@ void SymbolFileDWARFDebugMap::GetCompileOptions(
16031603
});
16041604
}
16051605

1606-
llvm::Error SymbolFileDWARFDebugMap::ResolveFunctionCallLabel(
1607-
SymbolContextList &sc_list, const FunctionCallLabel &label) {
1606+
llvm::Expected<SymbolContext> SymbolFileDWARFDebugMap::ResolveFunctionCallLabel(
1607+
const FunctionCallLabel &label) {
16081608
const uint64_t oso_idx = GetOSOIndexFromUserID(label.symbol_id);
16091609
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
16101610
if (!oso_dwarf)
16111611
return llvm::createStringError(llvm::formatv(
16121612
"couldn't find symbol file for {0} in debug-map.", label));
16131613

1614-
return oso_dwarf->ResolveFunctionCallLabel(sc_list, label);
1614+
return oso_dwarf->ResolveFunctionCallLabel(label);
16151615
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon {
144144
void
145145
GetCompileOptions(std::unordered_map<lldb::CompUnitSP, Args> &args) override;
146146

147-
llvm::Error ResolveFunctionCallLabel(SymbolContextList &sc_list,
148-
const FunctionCallLabel &label) override;
147+
llvm::Expected<SymbolContext>
148+
ResolveFunctionCallLabel(const FunctionCallLabel &label) override;
149149

150150
protected:
151151
enum { kHaveInitializedOSOs = (1 << 0), kNumFlags };

0 commit comments

Comments
 (0)