[Lldb-commits] [PATCH] D75730: [lldb] Reduce duplication in the Disassembler class
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 6 02:46:25 PST 2020
labath created this revision.
labath added a reviewer: JDevlieghere.
Herald added subscribers: atanasyan, jrtc27, sdardis.
Herald added a project: LLDB.
labath marked an inline comment as done.
labath added inline comments.
================
Comment at: lldb/source/Commands/CommandObjectDisassemble.cpp:462-469
+ 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 {
+ limit = {Disassembler::Limit::Instructions, m_options.num_instructions};
----------------
The idea is that further refactorings will change `ranges` from a `vector<AddressRange>` to a `vector<pair<Address, Limit>>` and this will become a simple ranged for loop.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75730
Files:
lldb/include/lldb/Core/Disassembler.h
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
lldb/source/Target/StackFrame.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75730.248676.patch
Type: text/x-patch
Size: 14852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200306/735ee004/attachment-0001.bin>
More information about the lldb-commits
mailing list