[Lldb-commits] [lldb] f2e1027 - [lldb] Support discontinuous functions in another Disasembler overload (#130987)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 14 00:24:49 PDT 2025
Author: Pavel Labath
Date: 2025-03-14T08:24:46+01:00
New Revision: f2e10278efe7a54544bf1a1d34cf55fe80d92316
URL: https://github.com/llvm/llvm-project/commit/f2e10278efe7a54544bf1a1d34cf55fe80d92316
DIFF: https://github.com/llvm/llvm-project/commit/f2e10278efe7a54544bf1a1d34cf55fe80d92316.diff
LOG: [lldb] Support discontinuous functions in another Disasembler overload (#130987)
This overload is taking a StackFrame, so we just need to change how we
obtain the ranges out of it. A slightly fiddly aspect is the code which
tries to provide a default dissassembly range for the case where we
don't have a real one. I believe this case is only relevant for
symbol-based stack frames as debug info always has size/range for the
functions (if it didn't we wouldn't even resolve the stack frame to a
function), which is why I've split the handling of the two cases.
We already have a test case for disassembly of discontinuous functions
(in test/Shell/Commands/command-disassemble.s), so I'm not creating
another one as this is just a slightly different entry point into the
same code.
Added:
Modified:
lldb/source/Core/Disassembler.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index b05be7e1a46d7..dce3d59457c0e 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -552,28 +552,46 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
StackFrame &frame, Stream &strm) {
- AddressRange range;
+ constexpr const char *plugin_name = nullptr;
+ constexpr const char *flavor = nullptr;
+ constexpr const char *cpu = nullptr;
+ constexpr const char *features = nullptr;
+ constexpr bool mixed_source_and_assembly = false;
+ constexpr uint32_t num_mixed_context_lines = 0;
+ constexpr uint32_t options = 0;
+
SymbolContext sc(
frame.GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function) {
- range = sc.function->GetAddressRange();
- } else if (sc.symbol && sc.symbol->ValueIsAddress()) {
+ if (DisassemblerSP disasm_sp = DisassembleRange(
+ arch, plugin_name, flavor, cpu, features, *frame.CalculateTarget(),
+ sc.function->GetAddressRanges())) {
+ disasm_sp->PrintInstructions(debugger, arch, frame,
+ mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
+ return true;
+ }
+ return false;
+ }
+
+ AddressRange range;
+ if (sc.symbol && sc.symbol->ValueIsAddress()) {
range.GetBaseAddress() = sc.symbol->GetAddressRef();
range.SetByteSize(sc.symbol->GetByteSize());
} else {
range.GetBaseAddress() = frame.GetFrameCodeAddress();
}
- if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0)
- range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
+ if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0)
+ range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
- Disassembler::Limit limit = {Disassembler::Limit::Bytes,
- range.GetByteSize()};
- if (limit.value == 0)
- limit.value = DEFAULT_DISASM_BYTE_SIZE;
+ Disassembler::Limit limit = {Disassembler::Limit::Bytes, range.GetByteSize()};
+ if (limit.value == 0)
+ limit.value = DEFAULT_DISASM_BYTE_SIZE;
- return Disassemble(debugger, arch, nullptr, nullptr, nullptr, nullptr,
- frame, range.GetBaseAddress(), limit, false, 0, 0, strm);
+ return Disassemble(debugger, arch, plugin_name, flavor, cpu, features, frame,
+ range.GetBaseAddress(), limit, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
}
Instruction::Instruction(const Address &address, AddressClass addr_class)
More information about the lldb-commits
mailing list