aboutsummaryrefslogtreecommitdiff
path: root/source/Core/Disassembler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Core/Disassembler.cpp')
-rw-r--r--source/Core/Disassembler.cpp333
1 files changed, 131 insertions, 202 deletions
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index bb5f106ca611..1e6a245261bb 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -11,18 +11,21 @@
// C Includes
// C++ Includes
+#include <cstdio>
+#include <cstring>
+
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/EmulateInstruction.h"
+#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/OptionValueArray.h"
#include "lldb/Interpreter/OptionValueDictionary.h"
@@ -35,13 +38,13 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/lldb-private.h"
#define DEFAULT_DISASM_BYTE_SIZE 32
using namespace lldb;
using namespace lldb_private;
-
DisassemblerSP
Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name)
{
@@ -50,7 +53,7 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *
arch.GetArchitectureName(),
plugin_name);
- DisassemblerCreateInstance create_callback = NULL;
+ DisassemblerCreateInstance create_callback = nullptr;
if (plugin_name)
{
@@ -60,17 +63,17 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *
{
DisassemblerSP disassembler_sp(create_callback(arch, flavor));
- if (disassembler_sp.get())
+ if (disassembler_sp)
return disassembler_sp;
}
}
else
{
- for (uint32_t idx = 0; (create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(idx)) != NULL; ++idx)
+ for (uint32_t idx = 0; (create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(idx)) != nullptr; ++idx)
{
DisassemblerSP disassembler_sp(create_callback(arch, flavor));
- if (disassembler_sp.get())
+ if (disassembler_sp)
return disassembler_sp;
}
}
@@ -80,7 +83,7 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *
DisassemblerSP
Disassembler::FindPluginForTarget(const TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name)
{
- if (target_sp && flavor == NULL)
+ if (target_sp && flavor == nullptr)
{
// FIXME - we don't have the mechanism in place to do per-architecture settings. But since we know that for now
// we only support flavors on x86 & x86_64,
@@ -91,7 +94,6 @@ Disassembler::FindPluginForTarget(const TargetSP target_sp, const ArchSpec &arch
return FindPlugin(arch, flavor, plugin_name);
}
-
static void
ResolveAddress (const ExecutionContext &exe_ctx,
const Address &addr,
@@ -122,19 +124,16 @@ ResolveAddress (const ExecutionContext &exe_ctx,
}
size_t
-Disassembler::Disassemble
-(
- Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- SymbolContextList &sc_list,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+Disassembler::Disassemble(Debugger &debugger,
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ SymbolContextList &sc_list,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options,
+ Stream &strm)
{
size_t success_count = 0;
const size_t count = sc_list.GetSize();
@@ -142,9 +141,9 @@ Disassembler::Disassemble
AddressRange range;
const uint32_t scope = eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = true;
- for (size_t i=0; i<count; ++i)
+ for (size_t i = 0; i < count; ++i)
{
- if (sc_list.GetContextAtIndex(i, sc) == false)
+ if (!sc_list.GetContextAtIndex(i, sc))
break;
for (uint32_t range_idx = 0; sc.GetAddressRange(scope, range_idx, use_inline_block_range, range); ++range_idx)
{
@@ -168,20 +167,17 @@ Disassembler::Disassemble
}
bool
-Disassembler::Disassemble
-(
- Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const ConstString &name,
- Module *module,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+Disassembler::Disassemble(Debugger &debugger,
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const ConstString &name,
+ Module *module,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options,
+ Stream &strm)
{
SymbolContextList sc_list;
if (name)
@@ -190,13 +186,13 @@ Disassembler::Disassemble
const bool include_inlines = true;
if (module)
{
- module->FindFunctions (name,
- NULL,
- eFunctionNameTypeAuto,
- include_symbols,
- include_inlines,
- true,
- sc_list);
+ module->FindFunctions(name,
+ nullptr,
+ eFunctionNameTypeAuto,
+ include_symbols,
+ include_inlines,
+ true,
+ sc_list);
}
else if (exe_ctx.GetTargetPtr())
{
@@ -225,17 +221,13 @@ Disassembler::Disassemble
return false;
}
-
lldb::DisassemblerSP
-Disassembler::DisassembleRange
-(
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &range,
- bool prefer_file_cache
-)
+Disassembler::DisassembleRange(const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const AddressRange &range,
+ bool prefer_file_cache)
{
lldb::DisassemblerSP disasm_sp;
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
@@ -244,7 +236,7 @@ Disassembler::DisassembleRange
if (disasm_sp)
{
- size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache);
+ size_t bytes_disassembled = disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
if (bytes_disassembled == 0)
disasm_sp.reset();
}
@@ -284,27 +276,23 @@ Disassembler::DisassembleBytes (const ArchSpec &arch,
return disasm_sp;
}
-
bool
-Disassembler::Disassemble
-(
- Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &disasm_range,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+Disassembler::Disassemble(Debugger &debugger,
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const AddressRange &disasm_range,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options,
+ Stream &strm)
{
if (disasm_range.GetByteSize())
{
lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
- if (disasm_sp.get())
+ if (disasm_sp)
{
AddressRange range;
ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
@@ -314,38 +302,24 @@ Disassembler::Disassemble
if (bytes_disassembled == 0)
return false;
- bool result = PrintInstructions (disasm_sp.get(),
- debugger,
- arch,
- exe_ctx,
- num_instructions,
- num_mixed_context_lines,
- options,
- strm);
-
- // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
- // I'll fix that but for now, just clear the list and it will go away nicely.
- disasm_sp->GetInstructionList().Clear();
- return result;
+ return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx, num_instructions,
+ num_mixed_context_lines, options, strm);
}
}
return false;
}
bool
-Disassembler::Disassemble
-(
- Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- const Address &start_address,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+Disassembler::Disassemble(Debugger &debugger,
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ const Address &start_address,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options,
+ Stream &strm)
{
if (num_instructions > 0)
{
@@ -353,7 +327,7 @@ Disassembler::Disassemble
arch,
flavor,
plugin_name));
- if (disasm_sp.get())
+ if (disasm_sp)
{
Address addr;
ResolveAddress (exe_ctx, start_address, addr);
@@ -364,36 +338,17 @@ Disassembler::Disassemble
prefer_file_cache);
if (bytes_disassembled == 0)
return false;
- bool result = PrintInstructions (disasm_sp.get(),
- debugger,
- arch,
- exe_ctx,
- num_instructions,
- num_mixed_context_lines,
- options,
- strm);
-
- // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
- // I'll fix that but for now, just clear the list and it will go away nicely.
- disasm_sp->GetInstructionList().Clear();
- return result;
+ return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx, num_instructions,
+ num_mixed_context_lines, options, strm);
}
}
return false;
}
-
-bool
-Disassembler::PrintInstructions
-(
- Disassembler *disasm_ptr,
- Debugger &debugger,
- const ArchSpec &arch,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+
+bool
+Disassembler::PrintInstructions(Disassembler *disasm_ptr, Debugger &debugger, const ArchSpec &arch,
+ const ExecutionContext &exe_ctx, uint32_t num_instructions,
+ uint32_t num_mixed_context_lines, uint32_t options, Stream &strm)
{
// We got some things disassembled...
size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
@@ -406,7 +361,7 @@ Disassembler::PrintInstructions
SymbolContext sc;
SymbolContext prev_sc;
AddressRange sc_range;
- const Address *pc_addr_ptr = NULL;
+ const Address *pc_addr_ptr = nullptr;
StackFrame *frame = exe_ctx.GetFramePtr();
TargetSP target_sp (exe_ctx.GetTargetSP());
@@ -419,7 +374,7 @@ Disassembler::PrintInstructions
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
- const FormatEntity::Entry *disassembly_format = NULL;
+ const FormatEntity::Entry *disassembly_format = nullptr;
FormatEntity::Entry format;
if (exe_ctx.HasTargetScope())
{
@@ -449,7 +404,7 @@ Disassembler::PrintInstructions
if (resolved_mask)
{
StreamString strmstr;
- Debugger::FormatDisassemblerAddress (disassembly_format, &sc, NULL, &exe_ctx, &addr, strmstr);
+ Debugger::FormatDisassemblerAddress(disassembly_format, &sc, nullptr, &exe_ctx, &addr, strmstr);
size_t cur_line = strmstr.GetSizeOfLastLine();
if (cur_line > address_text_size)
address_text_size = cur_line;
@@ -509,7 +464,7 @@ Disassembler::PrintInstructions
}
const bool show_bytes = (options & eOptionShowBytes) != 0;
- inst->Dump (&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx, &sc, &prev_sc, NULL, address_text_size);
+ inst->Dump(&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx, &sc, &prev_sc, nullptr, address_text_size);
strm.EOL();
}
else
@@ -521,20 +476,16 @@ Disassembler::PrintInstructions
return true;
}
-
bool
-Disassembler::Disassemble
-(
- Debugger &debugger,
- const ArchSpec &arch,
- const char *plugin_name,
- const char *flavor,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- uint32_t num_mixed_context_lines,
- uint32_t options,
- Stream &strm
-)
+Disassembler::Disassemble(Debugger &debugger,
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const ExecutionContext &exe_ctx,
+ uint32_t num_instructions,
+ uint32_t num_mixed_context_lines,
+ uint32_t options,
+ Stream &strm)
{
AddressRange range;
StackFrame *frame = exe_ctx.GetFramePtr();
@@ -579,9 +530,7 @@ Instruction::Instruction(const Address &address, AddressClass addr_class) :
{
}
-Instruction::~Instruction()
-{
-}
+Instruction::~Instruction() = default;
AddressClass
Instruction::GetAddressClass ()
@@ -664,12 +613,12 @@ Instruction::Dump (lldb_private::Stream *s,
bool
Instruction::DumpEmulation (const ArchSpec &arch)
{
- std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
- if (insn_emulator_ap.get())
- {
- insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL);
+ std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
+ if (insn_emulator_ap)
+ {
+ insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
return insn_emulator_ap->EvaluateInstruction (0);
- }
+ }
return false;
}
@@ -714,7 +663,7 @@ Instruction::ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type dat
line.clear();
}
- if (line.size() > 0)
+ if (!line.empty())
{
std::string value;
static RegularExpression g_reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
@@ -784,7 +733,7 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
}
// Try to find a key-value pair in the current line and add it to the dictionary.
- if (line.size() > 0)
+ if (!line.empty())
{
static RegularExpression g_reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
RegularExpression::Match regex_match(2);
@@ -816,7 +765,7 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
assert (value.size() == 1);
// value is a dictionary
value_sp = ReadDictionary (in_file, out_stream);
- if (value_sp.get() == NULL)
+ if (!value_sp)
{
option_value_sp.reset ();
return option_value_sp;
@@ -827,7 +776,7 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
assert (value.size() == 1);
// value is an array
value_sp = ReadArray (in_file, out_stream, data_type);
- if (value_sp.get() == NULL)
+ if (!value_sp)
{
option_value_sp.reset ();
return option_value_sp;
@@ -848,8 +797,6 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
value_sp.reset (new OptionValueString (value.c_str(), ""));
}
-
-
if (const_key == encoding_key)
{
// A 'data_encoding=..." is NOT a normal key-value pair; it is meta-data indicating the
@@ -876,8 +823,7 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
out_stream->Printf ("Instruction::TestEmulation: Missing file_name.");
return false;
}
-
- FILE *test_file = fopen (file_name, "r");
+ FILE *test_file = FileSystem::Fopen(file_name, "r");
if (!test_file)
{
out_stream->Printf ("Instruction::TestEmulation: Attempt to open test file failed.");
@@ -902,7 +848,7 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
// Read all the test information from the test file into an OptionValueDictionary.
OptionValueSP data_dictionary_sp (ReadDictionary (test_file, out_stream));
- if (data_dictionary_sp.get() == NULL)
+ if (!data_dictionary_sp)
{
out_stream->Printf ("Instruction::TestEmulation: Error reading Dictionary Object.\n");
fclose (test_file);
@@ -917,17 +863,16 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
OptionValueSP value_sp = data_dictionary->GetValueForKey (description_key);
- if (value_sp.get() == NULL)
+ if (!value_sp)
{
out_stream->Printf ("Instruction::TestEmulation: Test file does not contain description string.\n");
return false;
}
SetDescription (value_sp->GetStringValue());
-
-
+
value_sp = data_dictionary->GetValueForKey (triple_key);
- if (value_sp.get() == NULL)
+ if (!value_sp)
{
out_stream->Printf ("Instruction::TestEmulation: Test file does not contain triple.\n");
return false;
@@ -937,8 +882,8 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
arch.SetTriple (llvm::Triple (value_sp->GetStringValue()));
bool success = false;
- std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
- if (insn_emulator_ap.get())
+ std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
+ if (insn_emulator_ap)
success = insn_emulator_ap->TestEmulation (out_stream, arch, data_dictionary);
if (success)
@@ -958,19 +903,18 @@ Instruction::Emulate (const ArchSpec &arch,
EmulateInstruction::ReadRegisterCallback read_reg_callback,
EmulateInstruction::WriteRegisterCallback write_reg_callback)
{
- std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
- if (insn_emulator_ap.get())
- {
- insn_emulator_ap->SetBaton (baton);
- insn_emulator_ap->SetCallbacks (read_mem_callback, write_mem_callback, read_reg_callback, write_reg_callback);
- insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL);
- return insn_emulator_ap->EvaluateInstruction (evaluate_options);
- }
+ std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
+ if (insn_emulator_ap)
+ {
+ insn_emulator_ap->SetBaton(baton);
+ insn_emulator_ap->SetCallbacks(read_mem_callback, write_mem_callback, read_reg_callback, write_reg_callback);
+ insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
+ return insn_emulator_ap->EvaluateInstruction(evaluate_options);
+ }
return false;
}
-
uint32_t
Instruction::GetData (DataExtractor &data)
{
@@ -982,9 +926,7 @@ InstructionList::InstructionList() :
{
}
-InstructionList::~InstructionList()
-{
-}
+InstructionList::~InstructionList() = default;
size_t
InstructionList::GetSize() const
@@ -1008,8 +950,6 @@ InstructionList::GetMaxOpcocdeByteSize () const
return max_inst_size;
}
-
-
InstructionSP
InstructionList::GetInstructionAtIndex (size_t idx) const
{
@@ -1028,7 +968,7 @@ InstructionList::Dump (Stream *s,
const uint32_t max_opcode_byte_size = GetMaxOpcocdeByteSize();
collection::const_iterator pos, begin, end;
- const FormatEntity::Entry *disassembly_format = NULL;
+ const FormatEntity::Entry *disassembly_format = nullptr;
FormatEntity::Entry format;
if (exe_ctx && exe_ctx->HasTargetScope())
{
@@ -1046,15 +986,14 @@ InstructionList::Dump (Stream *s,
{
if (pos != begin)
s->EOL();
- (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx, NULL, NULL, disassembly_format, 0);
+ (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx, nullptr, nullptr, disassembly_format, 0);
}
}
-
void
InstructionList::Clear()
{
- m_instructions.clear();
+ m_instructions.clear();
}
void
@@ -1144,7 +1083,6 @@ InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
return index;
}
-
uint32_t
InstructionList::GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target)
{
@@ -1163,7 +1101,7 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
{
Target *target = exe_ctx->GetTargetPtr();
const addr_t byte_size = range.GetByteSize();
- if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid())
+ if (target == nullptr || byte_size == 0 || !range.GetBaseAddress().IsValid())
return 0;
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
@@ -1186,7 +1124,8 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
m_arch.GetByteOrder(),
m_arch.GetAddressByteSize());
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
- return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false, data_from_file);
+ return DecodeInstructions(range.GetBaseAddress(), data, 0, UINT32_MAX, false,
+ data_from_file);
}
else if (error_strm_ptr)
{
@@ -1212,14 +1151,14 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
{
m_instruction_list.Clear();
- if (exe_ctx == NULL || num_instructions == 0 || !start.IsValid())
+ if (exe_ctx == nullptr || num_instructions == 0 || !start.IsValid())
return 0;
Target *target = exe_ctx->GetTargetPtr();
// Calculate the max buffer size we will need in order to disassemble
const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
- if (target == NULL || byte_size == 0)
+ if (target == nullptr || byte_size == 0)
return 0;
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
@@ -1262,7 +1201,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
m_base_addr(LLDB_INVALID_ADDRESS),
m_flavor ()
{
- if (flavor == NULL)
+ if (flavor == nullptr)
m_flavor.assign("default");
else
m_flavor.assign(flavor);
@@ -1270,10 +1209,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
// If this is an arm variant that can only include thumb (T16, T32)
// instructions, force the arch triple to be "thumbv.." instead of
// "armv..."
- if ((arch.GetTriple().getArch() == llvm::Triple::arm || arch.GetTriple().getArch() == llvm::Triple::thumb)
- && (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
- || arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
- || arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
+ if (arch.IsAlwaysThumbInstructions())
{
std::string thumb_arch_name (arch.GetTriple().getArchName().str());
// Replace "arm" with "thumb" so we get all thumb variants correct
@@ -1286,12 +1222,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
}
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-Disassembler::~Disassembler()
-{
-}
+Disassembler::~Disassembler() = default;
InstructionList &
Disassembler::GetInstructionList ()
@@ -1308,15 +1239,14 @@ Disassembler::GetInstructionList () const
//----------------------------------------------------------------------
// Class PseudoInstruction
//----------------------------------------------------------------------
+
PseudoInstruction::PseudoInstruction () :
Instruction (Address(), eAddressClassUnknown),
m_description ()
{
}
-PseudoInstruction::~PseudoInstruction ()
-{
-}
+PseudoInstruction::~PseudoInstruction() = default;
bool
PseudoInstruction::DoesBranch ()
@@ -1340,7 +1270,6 @@ PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
return m_opcode.GetByteSize();
}
-
void
PseudoInstruction::SetOpcode (size_t opcode_size, void *opcode_data)
{