forked from OSchip/llvm-project
Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes.
llvm-svn: 262570
This commit is contained in:
parent
6b500dc5f9
commit
34ede34acd
|
@ -9,6 +9,11 @@
|
|||
|
||||
#include "lldb/Core/DataBufferHeap.h"
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -44,32 +49,26 @@ DataBufferHeap::DataBufferHeap (const void *src, lldb::offset_t src_len) :
|
|||
// Virtual destructor since this class inherits from a pure virtual
|
||||
// base class.
|
||||
//----------------------------------------------------------------------
|
||||
DataBufferHeap::~DataBufferHeap ()
|
||||
{
|
||||
}
|
||||
DataBufferHeap::~DataBufferHeap() = default;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Return a pointer to the bytes owned by this object, or NULL if
|
||||
// Return a pointer to the bytes owned by this object, or nullptr if
|
||||
// the object contains no bytes.
|
||||
//----------------------------------------------------------------------
|
||||
uint8_t *
|
||||
DataBufferHeap::GetBytes ()
|
||||
{
|
||||
if (m_data.empty())
|
||||
return NULL;
|
||||
return &m_data[0];
|
||||
return (m_data.empty() ? nullptr : m_data.data());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Return a const pointer to the bytes owned by this object, or NULL
|
||||
// Return a const pointer to the bytes owned by this object, or nullptr
|
||||
// if the object contains no bytes.
|
||||
//----------------------------------------------------------------------
|
||||
const uint8_t *
|
||||
DataBufferHeap::GetBytes () const
|
||||
{
|
||||
if (m_data.empty())
|
||||
return NULL;
|
||||
return &m_data[0];
|
||||
return (m_data.empty() ? nullptr : m_data.data());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -81,7 +80,6 @@ DataBufferHeap::GetByteSize () const
|
|||
return m_data.size();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Sets the number of bytes that this object should be able to
|
||||
// contain. This can be used prior to copying data into the buffer.
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
// C Includes
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef _WIN32
|
||||
#include "lldb/Host/windows/windows.h"
|
||||
|
@ -18,8 +16,14 @@
|
|||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
// C++ Includes
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
|
||||
// Other libraries and framework includes
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
// Project includes
|
||||
#include "lldb/Core/DataBufferMemoryMap.h"
|
||||
#include "lldb/Core/Error.h"
|
||||
#include "lldb/Host/File.h"
|
||||
|
@ -34,9 +38,9 @@ using namespace lldb_private;
|
|||
// Default Constructor
|
||||
//----------------------------------------------------------------------
|
||||
DataBufferMemoryMap::DataBufferMemoryMap() :
|
||||
m_mmap_addr(NULL),
|
||||
m_mmap_addr(nullptr),
|
||||
m_mmap_size(0),
|
||||
m_data(NULL),
|
||||
m_data(nullptr),
|
||||
m_size(0)
|
||||
{
|
||||
}
|
||||
|
@ -51,7 +55,7 @@ DataBufferMemoryMap::~DataBufferMemoryMap()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Return a pointer to the bytes owned by this object, or NULL if
|
||||
// Return a pointer to the bytes owned by this object, or nullptr if
|
||||
// the object contains no bytes.
|
||||
//----------------------------------------------------------------------
|
||||
uint8_t *
|
||||
|
@ -61,7 +65,7 @@ DataBufferMemoryMap::GetBytes()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Return a const pointer to the bytes owned by this object, or NULL
|
||||
// Return a const pointer to the bytes owned by this object, or nullptr
|
||||
// if the object contains no bytes.
|
||||
//----------------------------------------------------------------------
|
||||
const uint8_t *
|
||||
|
@ -86,7 +90,7 @@ DataBufferMemoryMap::GetByteSize() const
|
|||
void
|
||||
DataBufferMemoryMap::Clear()
|
||||
{
|
||||
if (m_mmap_addr != NULL)
|
||||
if (m_mmap_addr != nullptr)
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
||||
if (log)
|
||||
|
@ -97,9 +101,9 @@ DataBufferMemoryMap::Clear()
|
|||
#else
|
||||
::munmap((void *)m_mmap_addr, m_mmap_size);
|
||||
#endif
|
||||
m_mmap_addr = NULL;
|
||||
m_mmap_addr = nullptr;
|
||||
m_mmap_size = 0;
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
m_size = 0;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +122,7 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
|
|||
size_t length,
|
||||
bool writeable)
|
||||
{
|
||||
if (filespec != NULL)
|
||||
if (filespec != nullptr)
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
||||
if (log)
|
||||
|
@ -150,7 +154,6 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
static size_t win32memmapalignment = 0;
|
||||
void LoadWin32MemMapAlignment ()
|
||||
|
@ -208,8 +211,8 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
|||
|
||||
if (length > 0)
|
||||
{
|
||||
HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL);
|
||||
if (fileMapping != NULL)
|
||||
HANDLE fileMapping = CreateFileMapping(handle, nullptr, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, nullptr);
|
||||
if (fileMapping != nullptr)
|
||||
{
|
||||
if (win32memmapalignment == 0) LoadWin32MemMapAlignment();
|
||||
lldb::offset_t realoffset = offset;
|
||||
|
@ -259,7 +262,7 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
|||
if (fd_is_file)
|
||||
flags |= MAP_FILE;
|
||||
|
||||
m_mmap_addr = (uint8_t *)::mmap(NULL, length, prot, flags, fd, offset);
|
||||
m_mmap_addr = (uint8_t *)::mmap(nullptr, length, prot, flags, fd, offset);
|
||||
Error error;
|
||||
|
||||
if (m_mmap_addr == (void*)-1)
|
||||
|
@ -271,13 +274,13 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
|||
size_t page_offset = offset % HostInfo::GetPageSize();
|
||||
if (page_offset != 0)
|
||||
{
|
||||
m_mmap_addr = (uint8_t *)::mmap(NULL, length + page_offset, prot, flags, fd, offset - page_offset);
|
||||
m_mmap_addr = (uint8_t *)::mmap(nullptr, length + page_offset, prot, flags, fd, offset - page_offset);
|
||||
if (m_mmap_addr == (void*)-1)
|
||||
{
|
||||
// Failed to map file
|
||||
m_mmap_addr = NULL;
|
||||
m_mmap_addr = nullptr;
|
||||
}
|
||||
else if (m_mmap_addr != NULL)
|
||||
else if (m_mmap_addr != nullptr)
|
||||
{
|
||||
// We recovered and were able to memory map
|
||||
// after we aligned things to page boundaries
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/lldb-private.h"
|
||||
|
@ -41,7 +45,6 @@
|
|||
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());
|
||||
|
@ -333,19 +321,16 @@ Disassembler::Disassemble
|
|||
}
|
||||
|
||||
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 +338,7 @@ Disassembler::Disassemble
|
|||
arch,
|
||||
flavor,
|
||||
plugin_name));
|
||||
if (disasm_sp.get())
|
||||
if (disasm_sp)
|
||||
{
|
||||
Address addr;
|
||||
ResolveAddress (exe_ctx, start_address, addr);
|
||||
|
@ -383,17 +368,14 @@ Disassembler::Disassemble
|
|||
}
|
||||
|
||||
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
|
||||
)
|
||||
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 +388,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 +401,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 +431,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 +491,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 +503,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 +557,7 @@ Instruction::Instruction(const Address &address, AddressClass addr_class) :
|
|||
{
|
||||
}
|
||||
|
||||
Instruction::~Instruction()
|
||||
{
|
||||
}
|
||||
Instruction::~Instruction() = default;
|
||||
|
||||
AddressClass
|
||||
Instruction::GetAddressClass ()
|
||||
|
@ -664,12 +640,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 +690,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 +760,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 +792,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 +803,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 +824,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
|
||||
|
@ -902,7 +876,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 +891,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 +910,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 +931,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 +954,7 @@ InstructionList::InstructionList() :
|
|||
{
|
||||
}
|
||||
|
||||
InstructionList::~InstructionList()
|
||||
{
|
||||
}
|
||||
InstructionList::~InstructionList() = default;
|
||||
|
||||
size_t
|
||||
InstructionList::GetSize() const
|
||||
|
@ -1008,8 +978,6 @@ InstructionList::GetMaxOpcocdeByteSize () const
|
|||
return max_inst_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
InstructionSP
|
||||
InstructionList::GetInstructionAtIndex (size_t idx) const
|
||||
{
|
||||
|
@ -1028,7 +996,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 +1014,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
|
||||
|
@ -1069,7 +1036,7 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start, Target &target)
|
|||
{
|
||||
size_t num_instructions = m_instructions.size();
|
||||
|
||||
uint32_t next_branch = UINT32_MAX;
|
||||
uint32_t next_branch = std::numeric_limits<uint32_t>::max();
|
||||
size_t i;
|
||||
for (i = start; i < num_instructions; i++)
|
||||
{
|
||||
|
@ -1086,7 +1053,7 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start, Target &target)
|
|||
if (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon)
|
||||
{
|
||||
// If we didn't find a branch, find the last packet start.
|
||||
if (next_branch == UINT32_MAX)
|
||||
if (next_branch == std::numeric_limits<uint32_t>::max())
|
||||
{
|
||||
i = num_instructions - 1;
|
||||
}
|
||||
|
@ -1119,7 +1086,7 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start, Target &target)
|
|||
}
|
||||
}
|
||||
|
||||
if (next_branch == UINT32_MAX)
|
||||
if (next_branch == std::numeric_limits<uint32_t>::max())
|
||||
{
|
||||
// We couldn't find the previous packet, so return start
|
||||
next_branch = start;
|
||||
|
@ -1132,7 +1099,7 @@ uint32_t
|
|||
InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
|
||||
{
|
||||
size_t num_instructions = m_instructions.size();
|
||||
uint32_t index = UINT32_MAX;
|
||||
uint32_t index = std::numeric_limits<uint32_t>::max();
|
||||
for (size_t i = 0; i < num_instructions; i++)
|
||||
{
|
||||
if (m_instructions[i]->GetAddress() == address)
|
||||
|
@ -1144,7 +1111,6 @@ InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
|
|||
return index;
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
InstructionList::GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target)
|
||||
{
|
||||
|
@ -1163,7 +1129,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 +1152,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, std::numeric_limits<uint32_t>::max(), false,
|
||||
data_from_file);
|
||||
}
|
||||
else if (error_strm_ptr)
|
||||
{
|
||||
|
@ -1212,14 +1179,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 +1229,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);
|
||||
|
@ -1286,12 +1253,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Destructor
|
||||
//----------------------------------------------------------------------
|
||||
Disassembler::~Disassembler()
|
||||
{
|
||||
}
|
||||
Disassembler::~Disassembler() = default;
|
||||
|
||||
InstructionList &
|
||||
Disassembler::GetInstructionList ()
|
||||
|
@ -1308,15 +1270,14 @@ Disassembler::GetInstructionList () const
|
|||
//----------------------------------------------------------------------
|
||||
// Class PseudoInstruction
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
PseudoInstruction::PseudoInstruction () :
|
||||
Instruction (Address(), eAddressClassUnknown),
|
||||
m_description ()
|
||||
{
|
||||
}
|
||||
|
||||
PseudoInstruction::~PseudoInstruction ()
|
||||
{
|
||||
}
|
||||
PseudoInstruction::~PseudoInstruction() = default;
|
||||
|
||||
bool
|
||||
PseudoInstruction::DoesBranch ()
|
||||
|
@ -1340,7 +1301,6 @@ PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
|
|||
return m_opcode.GetByteSize();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PseudoInstruction::SetOpcode (size_t opcode_size, void *opcode_data)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/lldb-private.h"
|
||||
#include "lldb/Target/DynamicLoader.h"
|
||||
#include "lldb/Target/Process.h"
|
||||
|
@ -22,7 +26,7 @@ using namespace lldb_private;
|
|||
DynamicLoader*
|
||||
DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
|
||||
{
|
||||
DynamicLoaderCreateInstance create_callback = NULL;
|
||||
DynamicLoaderCreateInstance create_callback = nullptr;
|
||||
if (plugin_name)
|
||||
{
|
||||
ConstString const_plugin_name(plugin_name);
|
||||
|
@ -30,42 +34,34 @@ DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
|
|||
if (create_callback)
|
||||
{
|
||||
std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, true));
|
||||
if (instance_ap.get())
|
||||
if (instance_ap)
|
||||
return instance_ap.release();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
|
||||
for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
||||
{
|
||||
std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, false));
|
||||
if (instance_ap.get())
|
||||
if (instance_ap)
|
||||
return instance_ap.release();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// DynamicLoader constructor
|
||||
//----------------------------------------------------------------------
|
||||
DynamicLoader::DynamicLoader(Process *process) :
|
||||
m_process (process)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Destructor
|
||||
//----------------------------------------------------------------------
|
||||
DynamicLoader::~DynamicLoader()
|
||||
{
|
||||
}
|
||||
DynamicLoader::~DynamicLoader() = default;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Accessosors to the global setting as to whether to stop at image
|
||||
// (shared library) loading/unloading.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
DynamicLoader::GetStopWhenImagesChange () const
|
||||
{
|
||||
|
@ -84,7 +80,7 @@ DynamicLoader::GetTargetExecutable()
|
|||
Target &target = m_process->GetTarget();
|
||||
ModuleSP executable = target.GetExecutableModule();
|
||||
|
||||
if (executable.get())
|
||||
if (executable)
|
||||
{
|
||||
if (executable->GetFileSpec().Exists())
|
||||
{
|
||||
|
@ -92,7 +88,7 @@ DynamicLoader::GetTargetExecutable()
|
|||
ModuleSP module_sp (new Module (module_spec));
|
||||
|
||||
// Check if the executable has changed and set it to the target executable if they differ.
|
||||
if (module_sp.get() && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid())
|
||||
if (module_sp && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid())
|
||||
{
|
||||
if (module_sp->GetUUID() != executable->GetUUID())
|
||||
executable.reset();
|
||||
|
@ -102,7 +98,7 @@ DynamicLoader::GetTargetExecutable()
|
|||
executable.reset();
|
||||
}
|
||||
|
||||
if (!executable.get())
|
||||
if (!executable)
|
||||
{
|
||||
executable = target.GetSharedModule(module_spec);
|
||||
if (executable.get() != target.GetExecutableModulePointer())
|
||||
|
@ -158,15 +154,14 @@ DynamicLoader::UnloadSectionsCommon(const ModuleSP module)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const SectionList *
|
||||
DynamicLoader::GetSectionListFromModule(const ModuleSP module) const
|
||||
{
|
||||
SectionList *sections = nullptr;
|
||||
if (module.get())
|
||||
if (module)
|
||||
{
|
||||
ObjectFile *obj_file = module->GetObjectFile();
|
||||
if (obj_file)
|
||||
if (obj_file != nullptr)
|
||||
{
|
||||
sections = obj_file->GetSectionList();
|
||||
}
|
||||
|
@ -220,7 +215,6 @@ int64_t
|
|||
DynamicLoader::ReadUnsignedIntWithSizeInBytes(addr_t addr, int size_in_bytes)
|
||||
{
|
||||
Error error;
|
||||
|
||||
uint64_t value = m_process->ReadUnsignedIntegerFromMemory(addr, size_in_bytes, 0, error);
|
||||
if (error.Fail())
|
||||
return -1;
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
|
||||
#include "lldb/Core/EmulateInstruction.h"
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
#include <cstring>
|
||||
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Core/Address.h"
|
||||
#include "lldb/Core/DataExtractor.h"
|
||||
#include "lldb/Core/Error.h"
|
||||
|
@ -29,7 +35,7 @@ using namespace lldb_private;
|
|||
EmulateInstruction*
|
||||
EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
|
||||
{
|
||||
EmulateInstructionCreateInstance create_callback = NULL;
|
||||
EmulateInstructionCreateInstance create_callback = nullptr;
|
||||
if (plugin_name)
|
||||
{
|
||||
ConstString const_plugin_name (plugin_name);
|
||||
|
@ -43,33 +49,32 @@ EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_
|
|||
}
|
||||
else
|
||||
{
|
||||
for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != NULL; ++idx)
|
||||
for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
||||
{
|
||||
EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type);
|
||||
if (emulate_insn_ptr)
|
||||
return emulate_insn_ptr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EmulateInstruction::EmulateInstruction (const ArchSpec &arch) :
|
||||
m_arch (arch),
|
||||
m_baton (NULL),
|
||||
m_read_mem_callback (&ReadMemoryDefault),
|
||||
m_write_mem_callback (&WriteMemoryDefault),
|
||||
m_read_reg_callback (&ReadRegisterDefault),
|
||||
m_write_reg_callback (&WriteRegisterDefault),
|
||||
m_addr (LLDB_INVALID_ADDRESS)
|
||||
m_arch(arch),
|
||||
m_baton(nullptr),
|
||||
m_read_mem_callback(&ReadMemoryDefault),
|
||||
m_write_mem_callback(&WriteMemoryDefault),
|
||||
m_read_reg_callback(&ReadRegisterDefault),
|
||||
m_write_reg_callback(&WriteRegisterDefault),
|
||||
m_addr(LLDB_INVALID_ADDRESS)
|
||||
{
|
||||
::memset (&m_opcode, 0, sizeof (m_opcode));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
EmulateInstruction::ReadRegister (const RegisterInfo *reg_info, RegisterValue& reg_value)
|
||||
{
|
||||
if (m_read_reg_callback)
|
||||
if (m_read_reg_callback != nullptr)
|
||||
return m_read_reg_callback (this, m_baton, reg_info, reg_value);
|
||||
return false;
|
||||
}
|
||||
|
@ -115,7 +120,7 @@ EmulateInstruction::WriteRegister (const Context &context,
|
|||
const RegisterInfo *reg_info,
|
||||
const RegisterValue& reg_value)
|
||||
{
|
||||
if (m_write_reg_callback)
|
||||
if (m_write_reg_callback != nullptr)
|
||||
return m_write_reg_callback (this, m_baton, context, reg_info, reg_value);
|
||||
return false;
|
||||
}
|
||||
|
@ -132,14 +137,12 @@ EmulateInstruction::WriteRegister (const Context &context,
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
EmulateInstruction::WriteRegisterUnsigned (const Context &context,
|
||||
lldb::RegisterKind reg_kind,
|
||||
uint32_t reg_num,
|
||||
uint64_t uint_value)
|
||||
{
|
||||
|
||||
RegisterInfo reg_info;
|
||||
if (GetRegisterInfo(reg_kind, reg_num, reg_info))
|
||||
{
|
||||
|
@ -155,8 +158,7 @@ EmulateInstruction::WriteRegisterUnsigned (const Context &context,
|
|||
const RegisterInfo *reg_info,
|
||||
uint64_t uint_value)
|
||||
{
|
||||
|
||||
if (reg_info)
|
||||
if (reg_info != nullptr)
|
||||
{
|
||||
RegisterValue reg_value;
|
||||
if (reg_value.SetUInt(uint_value, reg_info->byte_size))
|
||||
|
@ -171,7 +173,7 @@ EmulateInstruction::ReadMemory (const Context &context,
|
|||
void *dst,
|
||||
size_t dst_len)
|
||||
{
|
||||
if (m_read_mem_callback)
|
||||
if (m_read_mem_callback != nullptr)
|
||||
return m_read_mem_callback (this, m_baton, context, addr, dst, dst_len) == dst_len;
|
||||
return false;
|
||||
}
|
||||
|
@ -202,7 +204,6 @@ EmulateInstruction::ReadMemoryUnsigned (const Context &context, lldb::addr_t add
|
|||
return uval64;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
EmulateInstruction::WriteMemoryUnsigned (const Context &context,
|
||||
lldb::addr_t addr,
|
||||
|
@ -213,9 +214,7 @@ EmulateInstruction::WriteMemoryUnsigned (const Context &context,
|
|||
strm.PutMaxHex64 (uval, uval_byte_size);
|
||||
|
||||
size_t bytes_written = m_write_mem_callback (this, m_baton, context, addr, strm.GetData(), uval_byte_size);
|
||||
if (bytes_written == uval_byte_size)
|
||||
return true;
|
||||
return false;
|
||||
return (bytes_written == uval_byte_size);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -224,12 +223,11 @@ EmulateInstruction::WriteMemory (const Context &context,
|
|||
const void *src,
|
||||
size_t src_len)
|
||||
{
|
||||
if (m_write_mem_callback)
|
||||
if (m_write_mem_callback != nullptr)
|
||||
return m_write_mem_callback (this, m_baton, context, addr, src, src_len) == src_len;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmulateInstruction::SetBaton (void *baton)
|
||||
{
|
||||
|
@ -254,29 +252,24 @@ EmulateInstruction::SetReadMemCallback (ReadMemoryCallback read_mem_callback)
|
|||
m_read_mem_callback = read_mem_callback;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmulateInstruction::SetWriteMemCallback (WriteMemoryCallback write_mem_callback)
|
||||
{
|
||||
m_write_mem_callback = write_mem_callback;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmulateInstruction::SetReadRegCallback (ReadRegisterCallback read_reg_callback)
|
||||
{
|
||||
m_read_reg_callback = read_reg_callback;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmulateInstruction::SetWriteRegCallback (WriteRegisterCallback write_reg_callback)
|
||||
{
|
||||
m_write_reg_callback = write_reg_callback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Read & Write Memory and Registers callback functions.
|
||||
//
|
||||
|
@ -289,7 +282,7 @@ EmulateInstruction::ReadMemoryFrame (EmulateInstruction *instruction,
|
|||
void *dst,
|
||||
size_t dst_len)
|
||||
{
|
||||
if (!baton || dst == NULL || dst_len == 0)
|
||||
if (baton == nullptr || dst == nullptr || dst_len == 0)
|
||||
return 0;
|
||||
|
||||
StackFrame *frame = (StackFrame *) baton;
|
||||
|
@ -311,7 +304,7 @@ EmulateInstruction::WriteMemoryFrame (EmulateInstruction *instruction,
|
|||
const void *src,
|
||||
size_t src_len)
|
||||
{
|
||||
if (!baton || src == NULL || src_len == 0)
|
||||
if (baton == nullptr || src == nullptr || src_len == 0)
|
||||
return 0;
|
||||
|
||||
StackFrame *frame = (StackFrame *) baton;
|
||||
|
@ -332,7 +325,7 @@ EmulateInstruction::ReadRegisterFrame (EmulateInstruction *instruction,
|
|||
const RegisterInfo *reg_info,
|
||||
RegisterValue ®_value)
|
||||
{
|
||||
if (!baton)
|
||||
if (baton == nullptr)
|
||||
return false;
|
||||
|
||||
StackFrame *frame = (StackFrame *) baton;
|
||||
|
@ -346,7 +339,7 @@ EmulateInstruction::WriteRegisterFrame (EmulateInstruction *instruction,
|
|||
const RegisterInfo *reg_info,
|
||||
const RegisterValue ®_value)
|
||||
{
|
||||
if (!baton)
|
||||
if (baton == nullptr)
|
||||
return false;
|
||||
|
||||
StackFrame *frame = (StackFrame *) baton;
|
||||
|
@ -504,45 +497,35 @@ EmulateInstruction::Context::Dump (Stream &strm,
|
|||
switch (info_type)
|
||||
{
|
||||
case eInfoTypeRegisterPlusOffset:
|
||||
{
|
||||
strm.Printf (" (reg_plus_offset = %s%+" PRId64 ")",
|
||||
info.RegisterPlusOffset.reg.name,
|
||||
info.RegisterPlusOffset.signed_offset);
|
||||
}
|
||||
strm.Printf(" (reg_plus_offset = %s%+" PRId64 ")",
|
||||
info.RegisterPlusOffset.reg.name,
|
||||
info.RegisterPlusOffset.signed_offset);
|
||||
break;
|
||||
|
||||
case eInfoTypeRegisterPlusIndirectOffset:
|
||||
{
|
||||
strm.Printf (" (reg_plus_reg = %s + %s)",
|
||||
info.RegisterPlusIndirectOffset.base_reg.name,
|
||||
info.RegisterPlusIndirectOffset.offset_reg.name);
|
||||
}
|
||||
strm.Printf(" (reg_plus_reg = %s + %s)",
|
||||
info.RegisterPlusIndirectOffset.base_reg.name,
|
||||
info.RegisterPlusIndirectOffset.offset_reg.name);
|
||||
break;
|
||||
|
||||
case eInfoTypeRegisterToRegisterPlusOffset:
|
||||
{
|
||||
strm.Printf (" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
|
||||
info.RegisterToRegisterPlusOffset.base_reg.name,
|
||||
info.RegisterToRegisterPlusOffset.offset,
|
||||
info.RegisterToRegisterPlusOffset.data_reg.name);
|
||||
}
|
||||
strm.Printf(" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
|
||||
info.RegisterToRegisterPlusOffset.base_reg.name,
|
||||
info.RegisterToRegisterPlusOffset.offset,
|
||||
info.RegisterToRegisterPlusOffset.data_reg.name);
|
||||
break;
|
||||
|
||||
case eInfoTypeRegisterToRegisterPlusIndirectOffset:
|
||||
{
|
||||
strm.Printf (" (base_and_reg_offset = %s + %s, data_reg = %s)",
|
||||
info.RegisterToRegisterPlusIndirectOffset.base_reg.name,
|
||||
info.RegisterToRegisterPlusIndirectOffset.offset_reg.name,
|
||||
info.RegisterToRegisterPlusIndirectOffset.data_reg.name);
|
||||
}
|
||||
strm.Printf(" (base_and_reg_offset = %s + %s, data_reg = %s)",
|
||||
info.RegisterToRegisterPlusIndirectOffset.base_reg.name,
|
||||
info.RegisterToRegisterPlusIndirectOffset.offset_reg.name,
|
||||
info.RegisterToRegisterPlusIndirectOffset.data_reg.name);
|
||||
break;
|
||||
|
||||
case eInfoTypeRegisterRegisterOperands:
|
||||
{
|
||||
strm.Printf (" (register to register binary op: %s and %s)",
|
||||
info.RegisterRegisterOperands.operand1.name,
|
||||
info.RegisterRegisterOperands.operand2.name);
|
||||
}
|
||||
strm.Printf(" (register to register binary op: %s and %s)",
|
||||
info.RegisterRegisterOperands.operand1.name,
|
||||
info.RegisterRegisterOperands.operand2.name);
|
||||
break;
|
||||
|
||||
case eInfoTypeOffset:
|
||||
|
@ -599,7 +582,7 @@ EmulateInstruction::SetInstruction (const Opcode &opcode, const Address &inst_ad
|
|||
m_addr = LLDB_INVALID_ADDRESS;
|
||||
if (inst_addr.IsValid())
|
||||
{
|
||||
if (target)
|
||||
if (target != nullptr)
|
||||
m_addr = inst_addr.GetLoadAddress (target);
|
||||
if (m_addr == LLDB_INVALID_ADDRESS)
|
||||
m_addr = inst_addr.GetFileAddress ();
|
||||
|
@ -661,12 +644,9 @@ EmulateInstruction::GetInternalRegisterNumber (RegisterContext *reg_ctx, const R
|
|||
return LLDB_INVALID_REGNUM;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
EmulateInstruction::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
|
||||
{
|
||||
unwind_plan.Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,35 +6,29 @@
|
|||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/Core/FileSpecList.h"
|
||||
#include "lldb/Core/Stream.h"
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Core/Stream.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Default constructor
|
||||
//------------------------------------------------------------------
|
||||
FileSpecList::FileSpecList() :
|
||||
m_files()
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Copy constructor
|
||||
//------------------------------------------------------------------
|
||||
FileSpecList::FileSpecList(const FileSpecList& rhs) :
|
||||
m_files(rhs.m_files)
|
||||
{
|
||||
}
|
||||
FileSpecList::FileSpecList(const FileSpecList& rhs) = default;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Destructor
|
||||
//------------------------------------------------------------------
|
||||
FileSpecList::~FileSpecList()
|
||||
{
|
||||
}
|
||||
FileSpecList::~FileSpecList() = default;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Assignment operator
|
||||
|
@ -104,7 +98,7 @@ FileSpecList::Dump(Stream *s, const char *separator_cstr) const
|
|||
// "file_spec" starting "start_idx" entries into the file spec list.
|
||||
//
|
||||
// Returns the valid index of the file that matches "file_spec" if
|
||||
// it is found, else UINT32_MAX is returned.
|
||||
// it is found, else std::numeric_limits<uint32_t>::max() is returned.
|
||||
//------------------------------------------------------------------
|
||||
size_t
|
||||
FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool full, bool remove_dots) const
|
||||
|
@ -131,7 +125,7 @@ FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool f
|
|||
}
|
||||
|
||||
// We didn't find the file, return an invalid index
|
||||
return UINT32_MAX;
|
||||
return std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -141,7 +135,6 @@ FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool f
|
|||
const FileSpec &
|
||||
FileSpecList::GetFileSpecAtIndex(size_t idx) const
|
||||
{
|
||||
|
||||
if (idx < m_files.size())
|
||||
return m_files[idx];
|
||||
static FileSpec g_empty_file_spec;
|
||||
|
@ -153,7 +146,7 @@ FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const
|
|||
{
|
||||
if (idx < m_files.size())
|
||||
return &m_files[idx];
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -208,26 +201,23 @@ FileSpecList::GetFilesMatchingPartialPath (const char *path, bool dir_okay, File
|
|||
else if (type == FileSpec::eFileTypeDirectory)
|
||||
{
|
||||
// Fill the match list with all the files in the directory:
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ConstString dir_name = path_spec.GetDirectory();
|
||||
Constring file_name = GetFilename();
|
||||
if (dir_name == NULL)
|
||||
ConstString file_name = GetFilename();
|
||||
if (dir_name == nullptr)
|
||||
{
|
||||
// Match files in the CWD.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Match files in the given directory:
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue