https://github.com/labath created https://github.com/llvm/llvm-project/pull/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. >From 1f79d61274bb04aa37e043a7b33a1711dc66361d Mon Sep 17 00:00:00 2001 From: Pavel Labath <pa...@labath.sk> Date: Wed, 12 Mar 2025 13:35:46 +0100 Subject: [PATCH] [lldb] Support discontinuous functions in another Disasembler overload 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. --- lldb/source/Core/Disassembler.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index b05be7e1a46d7..9b1d4e9316cb0 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -552,28 +552,35 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch, bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch, StackFrame &frame, Stream &strm) { - AddressRange range; 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, nullptr, nullptr, nullptr, nullptr, *frame.CalculateTarget(), + sc.function->GetAddressRanges())) { + disasm_sp->PrintInstructions(debugger, arch, frame, false, 0, 0, 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, nullptr, nullptr, nullptr, nullptr, frame, + range.GetBaseAddress(), limit, false, 0, 0, strm); } Instruction::Instruction(const Address &address, AddressClass addr_class) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits