aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectDisassemble.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2020-03-05 14:42:03 +0100
committerPavel Labath <pavel@labath.sk>2020-03-09 13:41:43 +0100
commitaf3db4e9aa8fbe7e43f89cdde780c6acc35368be (patch)
treec1743e0477dd5604ed4c5dd4a100d702db6c28bc /lldb/source/Commands/CommandObjectDisassemble.cpp
parent62af02e76fe808134b06b75c8108a98c079ac8bc (diff)
downloadllvm-af3db4e9aa8fbe7e43f89cdde780c6acc35368be.zip
llvm-af3db4e9aa8fbe7e43f89cdde780c6acc35368be.tar.gz
llvm-af3db4e9aa8fbe7e43f89cdde780c6acc35368be.tar.bz2
[lldb] Reduce duplication in the Disassembler class
Summary: The class has two pairs of functions whose functionalities differ in only how one specifies how much he wants to disasseble. One limits the process by the size of the input memory region. The other based on the total amount of instructions disassembled. They also differ in various features (like error reporting) that were only added to one of the versions. There are various ways in which this could be addressed. This patch does it by introducing a helper struct called "Limit", which is effectively a pair specifying the value that you want to limit, and the actual limit itself. Reviewers: JDevlieghere Subscribers: sdardis, jrtc27, atanasyan, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D75730
Diffstat (limited to 'lldb/source/Commands/CommandObjectDisassemble.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index a11af68..bd1c7a4 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -459,25 +459,19 @@ bool CommandObjectDisassemble::DoExecute(Args &command,
bool print_sc_header = ranges.size() > 1;
for (AddressRange cur_range : ranges) {
- bool success;
- if (m_options.num_instructions != 0) {
- success = Disassembler::Disassemble(
- GetDebugger(), m_options.arch, plugin_name, flavor_string, m_exe_ctx,
- cur_range.GetBaseAddress(), m_options.num_instructions,
- m_options.show_mixed,
- m_options.show_mixed ? m_options.num_lines_context : 0, options,
- result.GetOutputStream());
+ Disassembler::Limit limit;
+ if (m_options.num_instructions == 0) {
+ limit = {Disassembler::Limit::Bytes, cur_range.GetByteSize()};
+ if (limit.value == 0)
+ limit.value = DEFAULT_DISASM_BYTE_SIZE;
} else {
- if (cur_range.GetByteSize() == 0)
- cur_range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
-
- success = Disassembler::Disassemble(
- GetDebugger(), m_options.arch, plugin_name, flavor_string, m_exe_ctx,
- cur_range, m_options.num_instructions, m_options.show_mixed,
- m_options.show_mixed ? m_options.num_lines_context : 0, options,
- result.GetOutputStream());
+ limit = {Disassembler::Limit::Instructions, m_options.num_instructions};
}
- if (success) {
+ if (Disassembler::Disassemble(
+ GetDebugger(), m_options.arch, plugin_name, flavor_string,
+ m_exe_ctx, cur_range.GetBaseAddress(), limit, m_options.show_mixed,
+ m_options.show_mixed ? m_options.num_lines_context : 0, options,
+ result.GetOutputStream())) {
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS) {