-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Support discontinuous functions in another Disasembler overload #130987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-lldb Author: Pavel Labath (labath) ChangesThis 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. Full diff: https://github.com/llvm/llvm-project/pull/130987.diff 1 Files Affected:
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)
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
llvm#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.
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.