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"
|
#include "lldb/Core/DataBufferHeap.h"
|
||||||
|
|
||||||
|
// C Includes
|
||||||
|
// C++ Includes
|
||||||
|
// Other libraries and framework includes
|
||||||
|
// Project includes
|
||||||
|
|
||||||
using namespace lldb_private;
|
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
|
// Virtual destructor since this class inherits from a pure virtual
|
||||||
// base class.
|
// 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.
|
// the object contains no bytes.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uint8_t *
|
uint8_t *
|
||||||
DataBufferHeap::GetBytes ()
|
DataBufferHeap::GetBytes ()
|
||||||
{
|
{
|
||||||
if (m_data.empty())
|
return (m_data.empty() ? nullptr : m_data.data());
|
||||||
return NULL;
|
|
||||||
return &m_data[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// 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.
|
// if the object contains no bytes.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const uint8_t *
|
const uint8_t *
|
||||||
DataBufferHeap::GetBytes () const
|
DataBufferHeap::GetBytes () const
|
||||||
{
|
{
|
||||||
if (m_data.empty())
|
return (m_data.empty() ? nullptr : m_data.data());
|
||||||
return NULL;
|
|
||||||
return &m_data[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -81,7 +80,6 @@ DataBufferHeap::GetByteSize () const
|
||||||
return m_data.size();
|
return m_data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Sets the number of bytes that this object should be able to
|
// Sets the number of bytes that this object should be able to
|
||||||
// contain. This can be used prior to copying data into the buffer.
|
// contain. This can be used prior to copying data into the buffer.
|
||||||
|
|
|
@ -7,10 +7,8 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// C Includes
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "lldb/Host/windows/windows.h"
|
#include "lldb/Host/windows/windows.h"
|
||||||
|
@ -18,8 +16,14 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C++ Includes
|
||||||
|
#include <cerrno>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
|
||||||
|
// Project includes
|
||||||
#include "lldb/Core/DataBufferMemoryMap.h"
|
#include "lldb/Core/DataBufferMemoryMap.h"
|
||||||
#include "lldb/Core/Error.h"
|
#include "lldb/Core/Error.h"
|
||||||
#include "lldb/Host/File.h"
|
#include "lldb/Host/File.h"
|
||||||
|
@ -34,9 +38,9 @@ using namespace lldb_private;
|
||||||
// Default Constructor
|
// Default Constructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
DataBufferMemoryMap::DataBufferMemoryMap() :
|
DataBufferMemoryMap::DataBufferMemoryMap() :
|
||||||
m_mmap_addr(NULL),
|
m_mmap_addr(nullptr),
|
||||||
m_mmap_size(0),
|
m_mmap_size(0),
|
||||||
m_data(NULL),
|
m_data(nullptr),
|
||||||
m_size(0)
|
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.
|
// the object contains no bytes.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
uint8_t *
|
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.
|
// if the object contains no bytes.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const uint8_t *
|
const uint8_t *
|
||||||
|
@ -86,7 +90,7 @@ DataBufferMemoryMap::GetByteSize() const
|
||||||
void
|
void
|
||||||
DataBufferMemoryMap::Clear()
|
DataBufferMemoryMap::Clear()
|
||||||
{
|
{
|
||||||
if (m_mmap_addr != NULL)
|
if (m_mmap_addr != nullptr)
|
||||||
{
|
{
|
||||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
||||||
if (log)
|
if (log)
|
||||||
|
@ -97,9 +101,9 @@ DataBufferMemoryMap::Clear()
|
||||||
#else
|
#else
|
||||||
::munmap((void *)m_mmap_addr, m_mmap_size);
|
::munmap((void *)m_mmap_addr, m_mmap_size);
|
||||||
#endif
|
#endif
|
||||||
m_mmap_addr = NULL;
|
m_mmap_addr = nullptr;
|
||||||
m_mmap_size = 0;
|
m_mmap_size = 0;
|
||||||
m_data = NULL;
|
m_data = nullptr;
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +122,7 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
|
||||||
size_t length,
|
size_t length,
|
||||||
bool writeable)
|
bool writeable)
|
||||||
{
|
{
|
||||||
if (filespec != NULL)
|
if (filespec != nullptr)
|
||||||
{
|
{
|
||||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
|
||||||
if (log)
|
if (log)
|
||||||
|
@ -150,7 +154,6 @@ DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static size_t win32memmapalignment = 0;
|
static size_t win32memmapalignment = 0;
|
||||||
void LoadWin32MemMapAlignment ()
|
void LoadWin32MemMapAlignment ()
|
||||||
|
@ -208,8 +211,8 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
||||||
|
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL);
|
HANDLE fileMapping = CreateFileMapping(handle, nullptr, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, nullptr);
|
||||||
if (fileMapping != NULL)
|
if (fileMapping != nullptr)
|
||||||
{
|
{
|
||||||
if (win32memmapalignment == 0) LoadWin32MemMapAlignment();
|
if (win32memmapalignment == 0) LoadWin32MemMapAlignment();
|
||||||
lldb::offset_t realoffset = offset;
|
lldb::offset_t realoffset = offset;
|
||||||
|
@ -259,7 +262,7 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
||||||
if (fd_is_file)
|
if (fd_is_file)
|
||||||
flags |= MAP_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;
|
Error error;
|
||||||
|
|
||||||
if (m_mmap_addr == (void*)-1)
|
if (m_mmap_addr == (void*)-1)
|
||||||
|
@ -271,13 +274,13 @@ DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
|
||||||
size_t page_offset = offset % HostInfo::GetPageSize();
|
size_t page_offset = offset % HostInfo::GetPageSize();
|
||||||
if (page_offset != 0)
|
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)
|
if (m_mmap_addr == (void*)-1)
|
||||||
{
|
{
|
||||||
// Failed to map file
|
// 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
|
// We recovered and were able to memory map
|
||||||
// after we aligned things to page boundaries
|
// after we aligned things to page boundaries
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
// C Includes
|
// C Includes
|
||||||
// C++ Includes
|
// C++ Includes
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
// Other libraries and framework includes
|
// Other libraries and framework includes
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "lldb/lldb-private.h"
|
#include "lldb/lldb-private.h"
|
||||||
|
@ -41,7 +45,6 @@
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
|
|
||||||
DisassemblerSP
|
DisassemblerSP
|
||||||
Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name)
|
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(),
|
arch.GetArchitectureName(),
|
||||||
plugin_name);
|
plugin_name);
|
||||||
|
|
||||||
DisassemblerCreateInstance create_callback = NULL;
|
DisassemblerCreateInstance create_callback = nullptr;
|
||||||
|
|
||||||
if (plugin_name)
|
if (plugin_name)
|
||||||
{
|
{
|
||||||
|
@ -60,17 +63,17 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *
|
||||||
{
|
{
|
||||||
DisassemblerSP disassembler_sp(create_callback(arch, flavor));
|
DisassemblerSP disassembler_sp(create_callback(arch, flavor));
|
||||||
|
|
||||||
if (disassembler_sp.get())
|
if (disassembler_sp)
|
||||||
return disassembler_sp;
|
return disassembler_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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));
|
DisassemblerSP disassembler_sp(create_callback(arch, flavor));
|
||||||
|
|
||||||
if (disassembler_sp.get())
|
if (disassembler_sp)
|
||||||
return disassembler_sp;
|
return disassembler_sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +83,7 @@ Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *
|
||||||
DisassemblerSP
|
DisassemblerSP
|
||||||
Disassembler::FindPluginForTarget(const TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name)
|
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
|
// 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,
|
// 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);
|
return FindPlugin(arch, flavor, plugin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ResolveAddress (const ExecutionContext &exe_ctx,
|
ResolveAddress (const ExecutionContext &exe_ctx,
|
||||||
const Address &addr,
|
const Address &addr,
|
||||||
|
@ -122,19 +124,16 @@ ResolveAddress (const ExecutionContext &exe_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
Disassembler::Disassemble
|
Disassembler::Disassemble(Debugger &debugger,
|
||||||
(
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
SymbolContextList &sc_list,
|
||||||
const ExecutionContext &exe_ctx,
|
uint32_t num_instructions,
|
||||||
SymbolContextList &sc_list,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
size_t success_count = 0;
|
size_t success_count = 0;
|
||||||
const size_t count = sc_list.GetSize();
|
const size_t count = sc_list.GetSize();
|
||||||
|
@ -142,9 +141,9 @@ Disassembler::Disassemble
|
||||||
AddressRange range;
|
AddressRange range;
|
||||||
const uint32_t scope = eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
|
const uint32_t scope = eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
|
||||||
const bool use_inline_block_range = true;
|
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;
|
break;
|
||||||
for (uint32_t range_idx = 0; sc.GetAddressRange(scope, range_idx, use_inline_block_range, range); ++range_idx)
|
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
|
bool
|
||||||
Disassembler::Disassemble
|
Disassembler::Disassemble(Debugger &debugger,
|
||||||
(
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
const ConstString &name,
|
||||||
const ExecutionContext &exe_ctx,
|
Module *module,
|
||||||
const ConstString &name,
|
uint32_t num_instructions,
|
||||||
Module *module,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
SymbolContextList sc_list;
|
SymbolContextList sc_list;
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -190,13 +186,13 @@ Disassembler::Disassemble
|
||||||
const bool include_inlines = true;
|
const bool include_inlines = true;
|
||||||
if (module)
|
if (module)
|
||||||
{
|
{
|
||||||
module->FindFunctions (name,
|
module->FindFunctions(name,
|
||||||
NULL,
|
nullptr,
|
||||||
eFunctionNameTypeAuto,
|
eFunctionNameTypeAuto,
|
||||||
include_symbols,
|
include_symbols,
|
||||||
include_inlines,
|
include_inlines,
|
||||||
true,
|
true,
|
||||||
sc_list);
|
sc_list);
|
||||||
}
|
}
|
||||||
else if (exe_ctx.GetTargetPtr())
|
else if (exe_ctx.GetTargetPtr())
|
||||||
{
|
{
|
||||||
|
@ -225,17 +221,13 @@ Disassembler::Disassemble
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lldb::DisassemblerSP
|
lldb::DisassemblerSP
|
||||||
Disassembler::DisassembleRange
|
Disassembler::DisassembleRange(const ArchSpec &arch,
|
||||||
(
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
const AddressRange &range,
|
||||||
const ExecutionContext &exe_ctx,
|
bool prefer_file_cache)
|
||||||
const AddressRange &range,
|
|
||||||
bool prefer_file_cache
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
lldb::DisassemblerSP disasm_sp;
|
lldb::DisassemblerSP disasm_sp;
|
||||||
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
|
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
|
||||||
|
@ -244,7 +236,7 @@ Disassembler::DisassembleRange
|
||||||
|
|
||||||
if (disasm_sp)
|
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)
|
if (bytes_disassembled == 0)
|
||||||
disasm_sp.reset();
|
disasm_sp.reset();
|
||||||
}
|
}
|
||||||
|
@ -284,27 +276,23 @@ Disassembler::DisassembleBytes (const ArchSpec &arch,
|
||||||
return disasm_sp;
|
return disasm_sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Disassembler::Disassemble
|
Disassembler::Disassemble(Debugger &debugger,
|
||||||
(
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
const AddressRange &disasm_range,
|
||||||
const ExecutionContext &exe_ctx,
|
uint32_t num_instructions,
|
||||||
const AddressRange &disasm_range,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (disasm_range.GetByteSize())
|
if (disasm_range.GetByteSize())
|
||||||
{
|
{
|
||||||
lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
|
lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
|
||||||
|
|
||||||
if (disasm_sp.get())
|
if (disasm_sp)
|
||||||
{
|
{
|
||||||
AddressRange range;
|
AddressRange range;
|
||||||
ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
|
ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
|
||||||
|
@ -333,19 +321,16 @@ Disassembler::Disassemble
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Disassembler::Disassemble
|
Disassembler::Disassemble(Debugger &debugger,
|
||||||
(
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
const Address &start_address,
|
||||||
const ExecutionContext &exe_ctx,
|
uint32_t num_instructions,
|
||||||
const Address &start_address,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (num_instructions > 0)
|
if (num_instructions > 0)
|
||||||
{
|
{
|
||||||
|
@ -353,7 +338,7 @@ Disassembler::Disassemble
|
||||||
arch,
|
arch,
|
||||||
flavor,
|
flavor,
|
||||||
plugin_name));
|
plugin_name));
|
||||||
if (disasm_sp.get())
|
if (disasm_sp)
|
||||||
{
|
{
|
||||||
Address addr;
|
Address addr;
|
||||||
ResolveAddress (exe_ctx, start_address, addr);
|
ResolveAddress (exe_ctx, start_address, addr);
|
||||||
|
@ -383,17 +368,14 @@ Disassembler::Disassemble
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Disassembler::PrintInstructions
|
Disassembler::PrintInstructions(Disassembler *disasm_ptr,
|
||||||
(
|
Debugger &debugger,
|
||||||
Disassembler *disasm_ptr,
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const ExecutionContext &exe_ctx,
|
||||||
const ArchSpec &arch,
|
uint32_t num_instructions,
|
||||||
const ExecutionContext &exe_ctx,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// We got some things disassembled...
|
// We got some things disassembled...
|
||||||
size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
|
size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
|
||||||
|
@ -406,7 +388,7 @@ Disassembler::PrintInstructions
|
||||||
SymbolContext sc;
|
SymbolContext sc;
|
||||||
SymbolContext prev_sc;
|
SymbolContext prev_sc;
|
||||||
AddressRange sc_range;
|
AddressRange sc_range;
|
||||||
const Address *pc_addr_ptr = NULL;
|
const Address *pc_addr_ptr = nullptr;
|
||||||
StackFrame *frame = exe_ctx.GetFramePtr();
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
||||||
|
|
||||||
TargetSP target_sp (exe_ctx.GetTargetSP());
|
TargetSP target_sp (exe_ctx.GetTargetSP());
|
||||||
|
@ -419,7 +401,7 @@ Disassembler::PrintInstructions
|
||||||
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
|
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
|
||||||
const bool use_inline_block_range = false;
|
const bool use_inline_block_range = false;
|
||||||
|
|
||||||
const FormatEntity::Entry *disassembly_format = NULL;
|
const FormatEntity::Entry *disassembly_format = nullptr;
|
||||||
FormatEntity::Entry format;
|
FormatEntity::Entry format;
|
||||||
if (exe_ctx.HasTargetScope())
|
if (exe_ctx.HasTargetScope())
|
||||||
{
|
{
|
||||||
|
@ -449,7 +431,7 @@ Disassembler::PrintInstructions
|
||||||
if (resolved_mask)
|
if (resolved_mask)
|
||||||
{
|
{
|
||||||
StreamString strmstr;
|
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();
|
size_t cur_line = strmstr.GetSizeOfLastLine();
|
||||||
if (cur_line > address_text_size)
|
if (cur_line > address_text_size)
|
||||||
address_text_size = cur_line;
|
address_text_size = cur_line;
|
||||||
|
@ -509,7 +491,7 @@ Disassembler::PrintInstructions
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool show_bytes = (options & eOptionShowBytes) != 0;
|
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();
|
strm.EOL();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -521,20 +503,16 @@ Disassembler::PrintInstructions
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Disassembler::Disassemble
|
Disassembler::Disassemble(Debugger &debugger,
|
||||||
(
|
const ArchSpec &arch,
|
||||||
Debugger &debugger,
|
const char *plugin_name,
|
||||||
const ArchSpec &arch,
|
const char *flavor,
|
||||||
const char *plugin_name,
|
const ExecutionContext &exe_ctx,
|
||||||
const char *flavor,
|
uint32_t num_instructions,
|
||||||
const ExecutionContext &exe_ctx,
|
uint32_t num_mixed_context_lines,
|
||||||
uint32_t num_instructions,
|
uint32_t options,
|
||||||
uint32_t num_mixed_context_lines,
|
Stream &strm)
|
||||||
uint32_t options,
|
|
||||||
Stream &strm
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
AddressRange range;
|
AddressRange range;
|
||||||
StackFrame *frame = exe_ctx.GetFramePtr();
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
||||||
|
@ -579,9 +557,7 @@ Instruction::Instruction(const Address &address, AddressClass addr_class) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction::~Instruction()
|
Instruction::~Instruction() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
AddressClass
|
AddressClass
|
||||||
Instruction::GetAddressClass ()
|
Instruction::GetAddressClass ()
|
||||||
|
@ -664,12 +640,12 @@ Instruction::Dump (lldb_private::Stream *s,
|
||||||
bool
|
bool
|
||||||
Instruction::DumpEmulation (const ArchSpec &arch)
|
Instruction::DumpEmulation (const ArchSpec &arch)
|
||||||
{
|
{
|
||||||
std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
|
std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
|
||||||
if (insn_emulator_ap.get())
|
if (insn_emulator_ap)
|
||||||
{
|
{
|
||||||
insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL);
|
insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
|
||||||
return insn_emulator_ap->EvaluateInstruction (0);
|
return insn_emulator_ap->EvaluateInstruction (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +690,7 @@ Instruction::ReadArray (FILE *in_file, Stream *out_stream, OptionValue::Type dat
|
||||||
line.clear();
|
line.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.size() > 0)
|
if (!line.empty())
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value;
|
||||||
static RegularExpression g_reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
|
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.
|
// 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]*$");
|
static RegularExpression g_reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
|
||||||
RegularExpression::Match regex_match(2);
|
RegularExpression::Match regex_match(2);
|
||||||
|
@ -816,7 +792,7 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
|
||||||
assert (value.size() == 1);
|
assert (value.size() == 1);
|
||||||
// value is a dictionary
|
// value is a dictionary
|
||||||
value_sp = ReadDictionary (in_file, out_stream);
|
value_sp = ReadDictionary (in_file, out_stream);
|
||||||
if (value_sp.get() == NULL)
|
if (!value_sp)
|
||||||
{
|
{
|
||||||
option_value_sp.reset ();
|
option_value_sp.reset ();
|
||||||
return option_value_sp;
|
return option_value_sp;
|
||||||
|
@ -827,7 +803,7 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
|
||||||
assert (value.size() == 1);
|
assert (value.size() == 1);
|
||||||
// value is an array
|
// value is an array
|
||||||
value_sp = ReadArray (in_file, out_stream, data_type);
|
value_sp = ReadArray (in_file, out_stream, data_type);
|
||||||
if (value_sp.get() == NULL)
|
if (!value_sp)
|
||||||
{
|
{
|
||||||
option_value_sp.reset ();
|
option_value_sp.reset ();
|
||||||
return option_value_sp;
|
return option_value_sp;
|
||||||
|
@ -848,8 +824,6 @@ Instruction::ReadDictionary (FILE *in_file, Stream *out_stream)
|
||||||
value_sp.reset (new OptionValueString (value.c_str(), ""));
|
value_sp.reset (new OptionValueString (value.c_str(), ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (const_key == encoding_key)
|
if (const_key == encoding_key)
|
||||||
{
|
{
|
||||||
// A 'data_encoding=..." is NOT a normal key-value pair; it is meta-data indicating the
|
// 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.
|
// Read all the test information from the test file into an OptionValueDictionary.
|
||||||
|
|
||||||
OptionValueSP data_dictionary_sp (ReadDictionary (test_file, out_stream));
|
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");
|
out_stream->Printf ("Instruction::TestEmulation: Error reading Dictionary Object.\n");
|
||||||
fclose (test_file);
|
fclose (test_file);
|
||||||
|
@ -917,17 +891,16 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
|
||||||
|
|
||||||
OptionValueSP value_sp = data_dictionary->GetValueForKey (description_key);
|
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");
|
out_stream->Printf ("Instruction::TestEmulation: Test file does not contain description string.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDescription (value_sp->GetStringValue());
|
SetDescription (value_sp->GetStringValue());
|
||||||
|
|
||||||
|
|
||||||
value_sp = data_dictionary->GetValueForKey (triple_key);
|
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");
|
out_stream->Printf ("Instruction::TestEmulation: Test file does not contain triple.\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -937,8 +910,8 @@ Instruction::TestEmulation (Stream *out_stream, const char *file_name)
|
||||||
arch.SetTriple (llvm::Triple (value_sp->GetStringValue()));
|
arch.SetTriple (llvm::Triple (value_sp->GetStringValue()));
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
|
std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
|
||||||
if (insn_emulator_ap.get())
|
if (insn_emulator_ap)
|
||||||
success = insn_emulator_ap->TestEmulation (out_stream, arch, data_dictionary);
|
success = insn_emulator_ap->TestEmulation (out_stream, arch, data_dictionary);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
|
@ -958,19 +931,18 @@ Instruction::Emulate (const ArchSpec &arch,
|
||||||
EmulateInstruction::ReadRegisterCallback read_reg_callback,
|
EmulateInstruction::ReadRegisterCallback read_reg_callback,
|
||||||
EmulateInstruction::WriteRegisterCallback write_reg_callback)
|
EmulateInstruction::WriteRegisterCallback write_reg_callback)
|
||||||
{
|
{
|
||||||
std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
|
std::unique_ptr<EmulateInstruction> insn_emulator_ap(EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
|
||||||
if (insn_emulator_ap.get())
|
if (insn_emulator_ap)
|
||||||
{
|
{
|
||||||
insn_emulator_ap->SetBaton (baton);
|
insn_emulator_ap->SetBaton(baton);
|
||||||
insn_emulator_ap->SetCallbacks (read_mem_callback, write_mem_callback, read_reg_callback, write_reg_callback);
|
insn_emulator_ap->SetCallbacks(read_mem_callback, write_mem_callback, read_reg_callback, write_reg_callback);
|
||||||
insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL);
|
insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
|
||||||
return insn_emulator_ap->EvaluateInstruction (evaluate_options);
|
return insn_emulator_ap->EvaluateInstruction(evaluate_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
Instruction::GetData (DataExtractor &data)
|
Instruction::GetData (DataExtractor &data)
|
||||||
{
|
{
|
||||||
|
@ -982,9 +954,7 @@ InstructionList::InstructionList() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionList::~InstructionList()
|
InstructionList::~InstructionList() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
InstructionList::GetSize() const
|
InstructionList::GetSize() const
|
||||||
|
@ -1008,8 +978,6 @@ InstructionList::GetMaxOpcocdeByteSize () const
|
||||||
return max_inst_size;
|
return max_inst_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
InstructionSP
|
InstructionSP
|
||||||
InstructionList::GetInstructionAtIndex (size_t idx) const
|
InstructionList::GetInstructionAtIndex (size_t idx) const
|
||||||
{
|
{
|
||||||
|
@ -1028,7 +996,7 @@ InstructionList::Dump (Stream *s,
|
||||||
const uint32_t max_opcode_byte_size = GetMaxOpcocdeByteSize();
|
const uint32_t max_opcode_byte_size = GetMaxOpcocdeByteSize();
|
||||||
collection::const_iterator pos, begin, end;
|
collection::const_iterator pos, begin, end;
|
||||||
|
|
||||||
const FormatEntity::Entry *disassembly_format = NULL;
|
const FormatEntity::Entry *disassembly_format = nullptr;
|
||||||
FormatEntity::Entry format;
|
FormatEntity::Entry format;
|
||||||
if (exe_ctx && exe_ctx->HasTargetScope())
|
if (exe_ctx && exe_ctx->HasTargetScope())
|
||||||
{
|
{
|
||||||
|
@ -1046,15 +1014,14 @@ InstructionList::Dump (Stream *s,
|
||||||
{
|
{
|
||||||
if (pos != begin)
|
if (pos != begin)
|
||||||
s->EOL();
|
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
|
void
|
||||||
InstructionList::Clear()
|
InstructionList::Clear()
|
||||||
{
|
{
|
||||||
m_instructions.clear();
|
m_instructions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1069,7 +1036,7 @@ InstructionList::GetIndexOfNextBranchInstruction(uint32_t start, Target &target)
|
||||||
{
|
{
|
||||||
size_t num_instructions = m_instructions.size();
|
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;
|
size_t i;
|
||||||
for (i = start; i < num_instructions; 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 (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon)
|
||||||
{
|
{
|
||||||
// If we didn't find a branch, find the last packet start.
|
// 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;
|
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
|
// We couldn't find the previous packet, so return start
|
||||||
next_branch = start;
|
next_branch = start;
|
||||||
|
@ -1132,7 +1099,7 @@ uint32_t
|
||||||
InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
|
InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
|
||||||
{
|
{
|
||||||
size_t num_instructions = m_instructions.size();
|
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++)
|
for (size_t i = 0; i < num_instructions; i++)
|
||||||
{
|
{
|
||||||
if (m_instructions[i]->GetAddress() == address)
|
if (m_instructions[i]->GetAddress() == address)
|
||||||
|
@ -1144,7 +1111,6 @@ InstructionList::GetIndexOfInstructionAtAddress (const Address &address)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
InstructionList::GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target)
|
InstructionList::GetIndexOfInstructionAtLoadAddress (lldb::addr_t load_addr, Target &target)
|
||||||
{
|
{
|
||||||
|
@ -1163,7 +1129,7 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
|
||||||
{
|
{
|
||||||
Target *target = exe_ctx->GetTargetPtr();
|
Target *target = exe_ctx->GetTargetPtr();
|
||||||
const addr_t byte_size = range.GetByteSize();
|
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;
|
return 0;
|
||||||
|
|
||||||
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
|
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
|
||||||
|
@ -1186,7 +1152,8 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
|
||||||
m_arch.GetByteOrder(),
|
m_arch.GetByteOrder(),
|
||||||
m_arch.GetAddressByteSize());
|
m_arch.GetAddressByteSize());
|
||||||
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
|
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)
|
else if (error_strm_ptr)
|
||||||
{
|
{
|
||||||
|
@ -1212,14 +1179,14 @@ Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
|
||||||
{
|
{
|
||||||
m_instruction_list.Clear();
|
m_instruction_list.Clear();
|
||||||
|
|
||||||
if (exe_ctx == NULL || num_instructions == 0 || !start.IsValid())
|
if (exe_ctx == nullptr || num_instructions == 0 || !start.IsValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Target *target = exe_ctx->GetTargetPtr();
|
Target *target = exe_ctx->GetTargetPtr();
|
||||||
// Calculate the max buffer size we will need in order to disassemble
|
// Calculate the max buffer size we will need in order to disassemble
|
||||||
const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
|
const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
|
||||||
|
|
||||||
if (target == NULL || byte_size == 0)
|
if (target == nullptr || byte_size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\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_base_addr(LLDB_INVALID_ADDRESS),
|
||||||
m_flavor ()
|
m_flavor ()
|
||||||
{
|
{
|
||||||
if (flavor == NULL)
|
if (flavor == nullptr)
|
||||||
m_flavor.assign("default");
|
m_flavor.assign("default");
|
||||||
else
|
else
|
||||||
m_flavor.assign(flavor);
|
m_flavor.assign(flavor);
|
||||||
|
@ -1286,12 +1253,7 @@ Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
Disassembler::~Disassembler() = default;
|
||||||
// Destructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
Disassembler::~Disassembler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
InstructionList &
|
InstructionList &
|
||||||
Disassembler::GetInstructionList ()
|
Disassembler::GetInstructionList ()
|
||||||
|
@ -1308,15 +1270,14 @@ Disassembler::GetInstructionList () const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Class PseudoInstruction
|
// Class PseudoInstruction
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
PseudoInstruction::PseudoInstruction () :
|
PseudoInstruction::PseudoInstruction () :
|
||||||
Instruction (Address(), eAddressClassUnknown),
|
Instruction (Address(), eAddressClassUnknown),
|
||||||
m_description ()
|
m_description ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PseudoInstruction::~PseudoInstruction ()
|
PseudoInstruction::~PseudoInstruction() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PseudoInstruction::DoesBranch ()
|
PseudoInstruction::DoesBranch ()
|
||||||
|
@ -1340,7 +1301,6 @@ PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
|
||||||
return m_opcode.GetByteSize();
|
return m_opcode.GetByteSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PseudoInstruction::SetOpcode (size_t opcode_size, void *opcode_data)
|
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/lldb-private.h"
|
||||||
#include "lldb/Target/DynamicLoader.h"
|
#include "lldb/Target/DynamicLoader.h"
|
||||||
#include "lldb/Target/Process.h"
|
#include "lldb/Target/Process.h"
|
||||||
|
@ -22,7 +26,7 @@ using namespace lldb_private;
|
||||||
DynamicLoader*
|
DynamicLoader*
|
||||||
DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
|
DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
|
||||||
{
|
{
|
||||||
DynamicLoaderCreateInstance create_callback = NULL;
|
DynamicLoaderCreateInstance create_callback = nullptr;
|
||||||
if (plugin_name)
|
if (plugin_name)
|
||||||
{
|
{
|
||||||
ConstString const_plugin_name(plugin_name);
|
ConstString const_plugin_name(plugin_name);
|
||||||
|
@ -30,42 +34,34 @@ DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
|
||||||
if (create_callback)
|
if (create_callback)
|
||||||
{
|
{
|
||||||
std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, true));
|
std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, true));
|
||||||
if (instance_ap.get())
|
if (instance_ap)
|
||||||
return instance_ap.release();
|
return instance_ap.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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));
|
std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, false));
|
||||||
if (instance_ap.get())
|
if (instance_ap)
|
||||||
return instance_ap.release();
|
return instance_ap.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// DynamicLoader constructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
DynamicLoader::DynamicLoader(Process *process) :
|
DynamicLoader::DynamicLoader(Process *process) :
|
||||||
m_process (process)
|
m_process (process)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
DynamicLoader::~DynamicLoader() = default;
|
||||||
// Destructor
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
DynamicLoader::~DynamicLoader()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Accessosors to the global setting as to whether to stop at image
|
// Accessosors to the global setting as to whether to stop at image
|
||||||
// (shared library) loading/unloading.
|
// (shared library) loading/unloading.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DynamicLoader::GetStopWhenImagesChange () const
|
DynamicLoader::GetStopWhenImagesChange () const
|
||||||
{
|
{
|
||||||
|
@ -84,7 +80,7 @@ DynamicLoader::GetTargetExecutable()
|
||||||
Target &target = m_process->GetTarget();
|
Target &target = m_process->GetTarget();
|
||||||
ModuleSP executable = target.GetExecutableModule();
|
ModuleSP executable = target.GetExecutableModule();
|
||||||
|
|
||||||
if (executable.get())
|
if (executable)
|
||||||
{
|
{
|
||||||
if (executable->GetFileSpec().Exists())
|
if (executable->GetFileSpec().Exists())
|
||||||
{
|
{
|
||||||
|
@ -92,7 +88,7 @@ DynamicLoader::GetTargetExecutable()
|
||||||
ModuleSP module_sp (new Module (module_spec));
|
ModuleSP module_sp (new Module (module_spec));
|
||||||
|
|
||||||
// Check if the executable has changed and set it to the target executable if they differ.
|
// 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())
|
if (module_sp->GetUUID() != executable->GetUUID())
|
||||||
executable.reset();
|
executable.reset();
|
||||||
|
@ -102,7 +98,7 @@ DynamicLoader::GetTargetExecutable()
|
||||||
executable.reset();
|
executable.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!executable.get())
|
if (!executable)
|
||||||
{
|
{
|
||||||
executable = target.GetSharedModule(module_spec);
|
executable = target.GetSharedModule(module_spec);
|
||||||
if (executable.get() != target.GetExecutableModulePointer())
|
if (executable.get() != target.GetExecutableModulePointer())
|
||||||
|
@ -158,15 +154,14 @@ DynamicLoader::UnloadSectionsCommon(const ModuleSP module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SectionList *
|
const SectionList *
|
||||||
DynamicLoader::GetSectionListFromModule(const ModuleSP module) const
|
DynamicLoader::GetSectionListFromModule(const ModuleSP module) const
|
||||||
{
|
{
|
||||||
SectionList *sections = nullptr;
|
SectionList *sections = nullptr;
|
||||||
if (module.get())
|
if (module)
|
||||||
{
|
{
|
||||||
ObjectFile *obj_file = module->GetObjectFile();
|
ObjectFile *obj_file = module->GetObjectFile();
|
||||||
if (obj_file)
|
if (obj_file != nullptr)
|
||||||
{
|
{
|
||||||
sections = obj_file->GetSectionList();
|
sections = obj_file->GetSectionList();
|
||||||
}
|
}
|
||||||
|
@ -220,7 +215,6 @@ int64_t
|
||||||
DynamicLoader::ReadUnsignedIntWithSizeInBytes(addr_t addr, int size_in_bytes)
|
DynamicLoader::ReadUnsignedIntWithSizeInBytes(addr_t addr, int size_in_bytes)
|
||||||
{
|
{
|
||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
uint64_t value = m_process->ReadUnsignedIntegerFromMemory(addr, size_in_bytes, 0, error);
|
uint64_t value = m_process->ReadUnsignedIntegerFromMemory(addr, size_in_bytes, 0, error);
|
||||||
if (error.Fail())
|
if (error.Fail())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
|
|
||||||
#include "lldb/Core/EmulateInstruction.h"
|
#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/Address.h"
|
||||||
#include "lldb/Core/DataExtractor.h"
|
#include "lldb/Core/DataExtractor.h"
|
||||||
#include "lldb/Core/Error.h"
|
#include "lldb/Core/Error.h"
|
||||||
|
@ -29,7 +35,7 @@ using namespace lldb_private;
|
||||||
EmulateInstruction*
|
EmulateInstruction*
|
||||||
EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
|
EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
|
||||||
{
|
{
|
||||||
EmulateInstructionCreateInstance create_callback = NULL;
|
EmulateInstructionCreateInstance create_callback = nullptr;
|
||||||
if (plugin_name)
|
if (plugin_name)
|
||||||
{
|
{
|
||||||
ConstString const_plugin_name (plugin_name);
|
ConstString const_plugin_name (plugin_name);
|
||||||
|
@ -43,33 +49,32 @@ EmulateInstruction::FindPlugin (const ArchSpec &arch, InstructionType supported_
|
||||||
}
|
}
|
||||||
else
|
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);
|
EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type);
|
||||||
if (emulate_insn_ptr)
|
if (emulate_insn_ptr)
|
||||||
return emulate_insn_ptr;
|
return emulate_insn_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmulateInstruction::EmulateInstruction (const ArchSpec &arch) :
|
EmulateInstruction::EmulateInstruction (const ArchSpec &arch) :
|
||||||
m_arch (arch),
|
m_arch(arch),
|
||||||
m_baton (NULL),
|
m_baton(nullptr),
|
||||||
m_read_mem_callback (&ReadMemoryDefault),
|
m_read_mem_callback(&ReadMemoryDefault),
|
||||||
m_write_mem_callback (&WriteMemoryDefault),
|
m_write_mem_callback(&WriteMemoryDefault),
|
||||||
m_read_reg_callback (&ReadRegisterDefault),
|
m_read_reg_callback(&ReadRegisterDefault),
|
||||||
m_write_reg_callback (&WriteRegisterDefault),
|
m_write_reg_callback(&WriteRegisterDefault),
|
||||||
m_addr (LLDB_INVALID_ADDRESS)
|
m_addr(LLDB_INVALID_ADDRESS)
|
||||||
{
|
{
|
||||||
::memset (&m_opcode, 0, sizeof (m_opcode));
|
::memset (&m_opcode, 0, sizeof (m_opcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EmulateInstruction::ReadRegister (const RegisterInfo *reg_info, RegisterValue& reg_value)
|
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 m_read_reg_callback (this, m_baton, reg_info, reg_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +120,7 @@ EmulateInstruction::WriteRegister (const Context &context,
|
||||||
const RegisterInfo *reg_info,
|
const RegisterInfo *reg_info,
|
||||||
const RegisterValue& reg_value)
|
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 m_write_reg_callback (this, m_baton, context, reg_info, reg_value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -132,14 +137,12 @@ EmulateInstruction::WriteRegister (const Context &context,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EmulateInstruction::WriteRegisterUnsigned (const Context &context,
|
EmulateInstruction::WriteRegisterUnsigned (const Context &context,
|
||||||
lldb::RegisterKind reg_kind,
|
lldb::RegisterKind reg_kind,
|
||||||
uint32_t reg_num,
|
uint32_t reg_num,
|
||||||
uint64_t uint_value)
|
uint64_t uint_value)
|
||||||
{
|
{
|
||||||
|
|
||||||
RegisterInfo reg_info;
|
RegisterInfo reg_info;
|
||||||
if (GetRegisterInfo(reg_kind, reg_num, reg_info))
|
if (GetRegisterInfo(reg_kind, reg_num, reg_info))
|
||||||
{
|
{
|
||||||
|
@ -155,8 +158,7 @@ EmulateInstruction::WriteRegisterUnsigned (const Context &context,
|
||||||
const RegisterInfo *reg_info,
|
const RegisterInfo *reg_info,
|
||||||
uint64_t uint_value)
|
uint64_t uint_value)
|
||||||
{
|
{
|
||||||
|
if (reg_info != nullptr)
|
||||||
if (reg_info)
|
|
||||||
{
|
{
|
||||||
RegisterValue reg_value;
|
RegisterValue reg_value;
|
||||||
if (reg_value.SetUInt(uint_value, reg_info->byte_size))
|
if (reg_value.SetUInt(uint_value, reg_info->byte_size))
|
||||||
|
@ -171,7 +173,7 @@ EmulateInstruction::ReadMemory (const Context &context,
|
||||||
void *dst,
|
void *dst,
|
||||||
size_t dst_len)
|
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 m_read_mem_callback (this, m_baton, context, addr, dst, dst_len) == dst_len;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,6 @@ EmulateInstruction::ReadMemoryUnsigned (const Context &context, lldb::addr_t add
|
||||||
return uval64;
|
return uval64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EmulateInstruction::WriteMemoryUnsigned (const Context &context,
|
EmulateInstruction::WriteMemoryUnsigned (const Context &context,
|
||||||
lldb::addr_t addr,
|
lldb::addr_t addr,
|
||||||
|
@ -213,9 +214,7 @@ EmulateInstruction::WriteMemoryUnsigned (const Context &context,
|
||||||
strm.PutMaxHex64 (uval, uval_byte_size);
|
strm.PutMaxHex64 (uval, uval_byte_size);
|
||||||
|
|
||||||
size_t bytes_written = m_write_mem_callback (this, m_baton, context, addr, strm.GetData(), 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 (bytes_written == uval_byte_size);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -224,12 +223,11 @@ EmulateInstruction::WriteMemory (const Context &context,
|
||||||
const void *src,
|
const void *src,
|
||||||
size_t src_len)
|
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 m_write_mem_callback (this, m_baton, context, addr, src, src_len) == src_len;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EmulateInstruction::SetBaton (void *baton)
|
EmulateInstruction::SetBaton (void *baton)
|
||||||
{
|
{
|
||||||
|
@ -254,29 +252,24 @@ EmulateInstruction::SetReadMemCallback (ReadMemoryCallback read_mem_callback)
|
||||||
m_read_mem_callback = read_mem_callback;
|
m_read_mem_callback = read_mem_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EmulateInstruction::SetWriteMemCallback (WriteMemoryCallback write_mem_callback)
|
EmulateInstruction::SetWriteMemCallback (WriteMemoryCallback write_mem_callback)
|
||||||
{
|
{
|
||||||
m_write_mem_callback = write_mem_callback;
|
m_write_mem_callback = write_mem_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EmulateInstruction::SetReadRegCallback (ReadRegisterCallback read_reg_callback)
|
EmulateInstruction::SetReadRegCallback (ReadRegisterCallback read_reg_callback)
|
||||||
{
|
{
|
||||||
m_read_reg_callback = read_reg_callback;
|
m_read_reg_callback = read_reg_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EmulateInstruction::SetWriteRegCallback (WriteRegisterCallback write_reg_callback)
|
EmulateInstruction::SetWriteRegCallback (WriteRegisterCallback write_reg_callback)
|
||||||
{
|
{
|
||||||
m_write_reg_callback = write_reg_callback;
|
m_write_reg_callback = write_reg_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read & Write Memory and Registers callback functions.
|
// Read & Write Memory and Registers callback functions.
|
||||||
//
|
//
|
||||||
|
@ -289,7 +282,7 @@ EmulateInstruction::ReadMemoryFrame (EmulateInstruction *instruction,
|
||||||
void *dst,
|
void *dst,
|
||||||
size_t dst_len)
|
size_t dst_len)
|
||||||
{
|
{
|
||||||
if (!baton || dst == NULL || dst_len == 0)
|
if (baton == nullptr || dst == nullptr || dst_len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
StackFrame *frame = (StackFrame *) baton;
|
StackFrame *frame = (StackFrame *) baton;
|
||||||
|
@ -311,7 +304,7 @@ EmulateInstruction::WriteMemoryFrame (EmulateInstruction *instruction,
|
||||||
const void *src,
|
const void *src,
|
||||||
size_t src_len)
|
size_t src_len)
|
||||||
{
|
{
|
||||||
if (!baton || src == NULL || src_len == 0)
|
if (baton == nullptr || src == nullptr || src_len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
StackFrame *frame = (StackFrame *) baton;
|
StackFrame *frame = (StackFrame *) baton;
|
||||||
|
@ -332,7 +325,7 @@ EmulateInstruction::ReadRegisterFrame (EmulateInstruction *instruction,
|
||||||
const RegisterInfo *reg_info,
|
const RegisterInfo *reg_info,
|
||||||
RegisterValue ®_value)
|
RegisterValue ®_value)
|
||||||
{
|
{
|
||||||
if (!baton)
|
if (baton == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StackFrame *frame = (StackFrame *) baton;
|
StackFrame *frame = (StackFrame *) baton;
|
||||||
|
@ -346,7 +339,7 @@ EmulateInstruction::WriteRegisterFrame (EmulateInstruction *instruction,
|
||||||
const RegisterInfo *reg_info,
|
const RegisterInfo *reg_info,
|
||||||
const RegisterValue ®_value)
|
const RegisterValue ®_value)
|
||||||
{
|
{
|
||||||
if (!baton)
|
if (baton == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StackFrame *frame = (StackFrame *) baton;
|
StackFrame *frame = (StackFrame *) baton;
|
||||||
|
@ -504,45 +497,35 @@ EmulateInstruction::Context::Dump (Stream &strm,
|
||||||
switch (info_type)
|
switch (info_type)
|
||||||
{
|
{
|
||||||
case eInfoTypeRegisterPlusOffset:
|
case eInfoTypeRegisterPlusOffset:
|
||||||
{
|
strm.Printf(" (reg_plus_offset = %s%+" PRId64 ")",
|
||||||
strm.Printf (" (reg_plus_offset = %s%+" PRId64 ")",
|
info.RegisterPlusOffset.reg.name,
|
||||||
info.RegisterPlusOffset.reg.name,
|
info.RegisterPlusOffset.signed_offset);
|
||||||
info.RegisterPlusOffset.signed_offset);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInfoTypeRegisterPlusIndirectOffset:
|
case eInfoTypeRegisterPlusIndirectOffset:
|
||||||
{
|
strm.Printf(" (reg_plus_reg = %s + %s)",
|
||||||
strm.Printf (" (reg_plus_reg = %s + %s)",
|
info.RegisterPlusIndirectOffset.base_reg.name,
|
||||||
info.RegisterPlusIndirectOffset.base_reg.name,
|
info.RegisterPlusIndirectOffset.offset_reg.name);
|
||||||
info.RegisterPlusIndirectOffset.offset_reg.name);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInfoTypeRegisterToRegisterPlusOffset:
|
case eInfoTypeRegisterToRegisterPlusOffset:
|
||||||
{
|
strm.Printf(" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
|
||||||
strm.Printf (" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
|
info.RegisterToRegisterPlusOffset.base_reg.name,
|
||||||
info.RegisterToRegisterPlusOffset.base_reg.name,
|
info.RegisterToRegisterPlusOffset.offset,
|
||||||
info.RegisterToRegisterPlusOffset.offset,
|
info.RegisterToRegisterPlusOffset.data_reg.name);
|
||||||
info.RegisterToRegisterPlusOffset.data_reg.name);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInfoTypeRegisterToRegisterPlusIndirectOffset:
|
case eInfoTypeRegisterToRegisterPlusIndirectOffset:
|
||||||
{
|
strm.Printf(" (base_and_reg_offset = %s + %s, data_reg = %s)",
|
||||||
strm.Printf (" (base_and_reg_offset = %s + %s, data_reg = %s)",
|
info.RegisterToRegisterPlusIndirectOffset.base_reg.name,
|
||||||
info.RegisterToRegisterPlusIndirectOffset.base_reg.name,
|
info.RegisterToRegisterPlusIndirectOffset.offset_reg.name,
|
||||||
info.RegisterToRegisterPlusIndirectOffset.offset_reg.name,
|
info.RegisterToRegisterPlusIndirectOffset.data_reg.name);
|
||||||
info.RegisterToRegisterPlusIndirectOffset.data_reg.name);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInfoTypeRegisterRegisterOperands:
|
case eInfoTypeRegisterRegisterOperands:
|
||||||
{
|
strm.Printf(" (register to register binary op: %s and %s)",
|
||||||
strm.Printf (" (register to register binary op: %s and %s)",
|
info.RegisterRegisterOperands.operand1.name,
|
||||||
info.RegisterRegisterOperands.operand1.name,
|
info.RegisterRegisterOperands.operand2.name);
|
||||||
info.RegisterRegisterOperands.operand2.name);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInfoTypeOffset:
|
case eInfoTypeOffset:
|
||||||
|
@ -599,7 +582,7 @@ EmulateInstruction::SetInstruction (const Opcode &opcode, const Address &inst_ad
|
||||||
m_addr = LLDB_INVALID_ADDRESS;
|
m_addr = LLDB_INVALID_ADDRESS;
|
||||||
if (inst_addr.IsValid())
|
if (inst_addr.IsValid())
|
||||||
{
|
{
|
||||||
if (target)
|
if (target != nullptr)
|
||||||
m_addr = inst_addr.GetLoadAddress (target);
|
m_addr = inst_addr.GetLoadAddress (target);
|
||||||
if (m_addr == LLDB_INVALID_ADDRESS)
|
if (m_addr == LLDB_INVALID_ADDRESS)
|
||||||
m_addr = inst_addr.GetFileAddress ();
|
m_addr = inst_addr.GetFileAddress ();
|
||||||
|
@ -661,12 +644,9 @@ EmulateInstruction::GetInternalRegisterNumber (RegisterContext *reg_ctx, const R
|
||||||
return LLDB_INVALID_REGNUM;
|
return LLDB_INVALID_REGNUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EmulateInstruction::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
|
EmulateInstruction::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
|
||||||
{
|
{
|
||||||
unwind_plan.Clear();
|
unwind_plan.Clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,35 +6,29 @@
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "lldb/Core/FileSpecList.h"
|
#include "lldb/Core/FileSpecList.h"
|
||||||
#include "lldb/Core/Stream.h"
|
|
||||||
|
// C Includes
|
||||||
|
// C++ Includes
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
|
// Project includes
|
||||||
|
#include "lldb/Core/Stream.h"
|
||||||
|
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// Default constructor
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
FileSpecList::FileSpecList() :
|
FileSpecList::FileSpecList() :
|
||||||
m_files()
|
m_files()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
FileSpecList::FileSpecList(const FileSpecList& rhs) = default;
|
||||||
// Copy constructor
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
FileSpecList::FileSpecList(const FileSpecList& rhs) :
|
|
||||||
m_files(rhs.m_files)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
FileSpecList::~FileSpecList() = default;
|
||||||
// Destructor
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
FileSpecList::~FileSpecList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Assignment operator
|
// 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.
|
// "file_spec" starting "start_idx" entries into the file spec list.
|
||||||
//
|
//
|
||||||
// Returns the valid index of the file that matches "file_spec" if
|
// 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
|
size_t
|
||||||
FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool full, bool remove_dots) const
|
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
|
// 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 &
|
const FileSpec &
|
||||||
FileSpecList::GetFileSpecAtIndex(size_t idx) const
|
FileSpecList::GetFileSpecAtIndex(size_t idx) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (idx < m_files.size())
|
if (idx < m_files.size())
|
||||||
return m_files[idx];
|
return m_files[idx];
|
||||||
static FileSpec g_empty_file_spec;
|
static FileSpec g_empty_file_spec;
|
||||||
|
@ -153,7 +146,7 @@ FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const
|
||||||
{
|
{
|
||||||
if (idx < m_files.size())
|
if (idx < m_files.size())
|
||||||
return &m_files[idx];
|
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)
|
else if (type == FileSpec::eFileTypeDirectory)
|
||||||
{
|
{
|
||||||
// Fill the match list with all the files in the directory:
|
// Fill the match list with all the files in the directory:
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConstString dir_name = path_spec.GetDirectory();
|
ConstString dir_name = path_spec.GetDirectory();
|
||||||
Constring file_name = GetFilename();
|
ConstString file_name = GetFilename();
|
||||||
if (dir_name == NULL)
|
if (dir_name == nullptr)
|
||||||
{
|
{
|
||||||
// Match files in the CWD.
|
// Match files in the CWD.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Match files in the given directory:
|
// Match files in the given directory:
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue