2010-06-09 00:52:24 +08:00
|
|
|
//===-- DataExtractor.cpp ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include <bitset>
|
2012-10-20 14:08:09 +08:00
|
|
|
#include <limits>
|
|
|
|
#include <sstream>
|
2010-06-09 00:52:24 +08:00
|
|
|
#include <string>
|
|
|
|
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
#include "llvm/ADT/APFloat.h"
|
2011-08-15 10:24:40 +08:00
|
|
|
#include "llvm/ADT/APInt.h"
|
2011-08-15 15:23:47 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2010-06-11 07:56:16 +08:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
#include "lldb/Core/DataBufferHeap.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/DataExtractor.h"
|
|
|
|
#include "lldb/Core/DataBuffer.h"
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
#include "lldb/Core/Disassembler.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
|
|
|
#include "lldb/Core/UUID.h"
|
|
|
|
#include "lldb/Core/dwarf.h"
|
2011-02-01 09:31:41 +08:00
|
|
|
#include "lldb/Host/Endian.h"
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/ExecutionContextScope.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2010-06-12 09:03:17 +08:00
|
|
|
static inline uint16_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadInt16(const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return *(uint16_t *)(ptr + offset);
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
2010-06-12 09:03:17 +08:00
|
|
|
static inline uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadInt32 (const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return *(uint32_t *)(ptr + offset);
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
2010-06-12 09:03:17 +08:00
|
|
|
|
|
|
|
static inline uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadInt64(const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return *(uint64_t *)(ptr + offset);
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
2010-06-12 09:03:17 +08:00
|
|
|
|
2013-02-09 06:02:02 +08:00
|
|
|
static inline uint16_t
|
|
|
|
ReadInt16(const void* ptr)
|
|
|
|
{
|
|
|
|
return *(uint16_t *)(ptr);
|
|
|
|
}
|
|
|
|
static inline uint32_t
|
|
|
|
ReadInt32 (const void* ptr)
|
|
|
|
{
|
|
|
|
return *(uint32_t *)(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
ReadInt64(const void* ptr)
|
|
|
|
{
|
|
|
|
return *(uint64_t *)(ptr);
|
|
|
|
}
|
|
|
|
|
2010-06-12 09:03:17 +08:00
|
|
|
static inline uint16_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadSwapInt16(const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return llvm::ByteSwap_16(*(uint16_t *)(ptr + offset));
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
2010-06-12 09:03:17 +08:00
|
|
|
|
|
|
|
static inline uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadSwapInt32 (const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return llvm::ByteSwap_32(*(uint32_t *)(ptr + offset));
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
2010-06-12 09:03:17 +08:00
|
|
|
static inline uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
ReadSwapInt64(const unsigned char* ptr, offset_t offset)
|
2010-06-12 09:03:17 +08:00
|
|
|
{
|
|
|
|
return llvm::ByteSwap_64(*(uint64_t *)(ptr + offset));
|
2010-06-11 07:56:16 +08:00
|
|
|
}
|
|
|
|
|
2013-02-09 06:02:02 +08:00
|
|
|
static inline uint16_t
|
|
|
|
ReadSwapInt16(const void* ptr)
|
|
|
|
{
|
|
|
|
return llvm::ByteSwap_16(*(uint16_t *)(ptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
ReadSwapInt32 (const void* ptr)
|
|
|
|
{
|
|
|
|
return llvm::ByteSwap_32(*(uint32_t *)(ptr));
|
|
|
|
}
|
|
|
|
static inline uint64_t
|
|
|
|
ReadSwapInt64(const void* ptr)
|
|
|
|
{
|
|
|
|
return llvm::ByteSwap_64(*(uint64_t *)(ptr));
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#define NON_PRINTABLE_CHAR '.'
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Default constructor.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
DataExtractor::DataExtractor () :
|
|
|
|
m_start (NULL),
|
|
|
|
m_end (NULL),
|
2011-02-01 09:31:41 +08:00
|
|
|
m_byte_order(lldb::endian::InlHostByteOrder()),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_addr_size (4),
|
|
|
|
m_data_sp ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This constructor allows us to use data that is owned by someone else.
|
|
|
|
// The data must stay around as long as this object is valid.
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endian, uint32_t addr_size) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_start ((uint8_t*)data),
|
|
|
|
m_end ((uint8_t*)data + length),
|
|
|
|
m_byte_order(endian),
|
|
|
|
m_addr_size (addr_size),
|
|
|
|
m_data_sp ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Make a shared pointer reference to the shared data in "data_sp" and
|
|
|
|
// set the endian swapping setting to "swap", and the address size to
|
|
|
|
// "addr_size". The shared data reference will ensure the data lives
|
|
|
|
// as long as any DataExtractor objects exist that have a reference to
|
|
|
|
// this data.
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint32_t addr_size) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_start (NULL),
|
|
|
|
m_end (NULL),
|
|
|
|
m_byte_order(endian),
|
|
|
|
m_addr_size (addr_size),
|
|
|
|
m_data_sp ()
|
|
|
|
{
|
|
|
|
SetData (data_sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Initialize this object with a subset of the data bytes in "data".
|
|
|
|
// If "data" contains shared data, then a reference to this shared
|
|
|
|
// data will added and the shared data will stay around as long
|
|
|
|
// as any object contains a reference to that data. The endian
|
|
|
|
// swap and address size settings are copied from "data".
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset_t length) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_start(NULL),
|
|
|
|
m_end(NULL),
|
|
|
|
m_byte_order(data.m_byte_order),
|
|
|
|
m_addr_size(data.m_addr_size),
|
|
|
|
m_data_sp()
|
|
|
|
{
|
|
|
|
if (data.ValidOffset(offset))
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t bytes_available = data.GetByteSize() - offset;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (length > bytes_available)
|
|
|
|
length = bytes_available;
|
|
|
|
SetData(data, offset, length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
DataExtractor::DataExtractor (const DataExtractor& rhs) :
|
|
|
|
m_start (rhs.m_start),
|
|
|
|
m_end (rhs.m_end),
|
|
|
|
m_byte_order (rhs.m_byte_order),
|
|
|
|
m_addr_size (rhs.m_addr_size),
|
|
|
|
m_data_sp (rhs.m_data_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Assignment operator
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const DataExtractor&
|
|
|
|
DataExtractor::operator= (const DataExtractor& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
m_start = rhs.m_start;
|
|
|
|
m_end = rhs.m_end;
|
|
|
|
m_byte_order = rhs.m_byte_order;
|
2010-06-09 00:52:24 +08:00
|
|
|
m_addr_size = rhs.m_addr_size;
|
2011-05-30 08:49:24 +08:00
|
|
|
m_data_sp = rhs.m_data_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
DataExtractor::~DataExtractor ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Clears the object contents back to a default invalid state, and
|
|
|
|
// release any references to shared data that this object may
|
|
|
|
// contain.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
DataExtractor::Clear ()
|
|
|
|
{
|
|
|
|
m_start = NULL;
|
|
|
|
m_end = NULL;
|
2011-02-01 09:31:41 +08:00
|
|
|
m_byte_order = lldb::endian::InlHostByteOrder();
|
2010-06-09 00:52:24 +08:00
|
|
|
m_addr_size = 4;
|
|
|
|
m_data_sp.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// If this object contains shared data, this function returns the
|
|
|
|
// offset into that shared data. Else zero is returned.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
size_t
|
|
|
|
DataExtractor::GetSharedDataOffset () const
|
|
|
|
{
|
|
|
|
if (m_start != NULL)
|
|
|
|
{
|
|
|
|
const DataBuffer * data = m_data_sp.get();
|
|
|
|
if (data != NULL)
|
|
|
|
{
|
|
|
|
const uint8_t * data_bytes = data->GetBytes();
|
|
|
|
if (data_bytes != NULL)
|
|
|
|
{
|
|
|
|
assert(m_start >= data_bytes);
|
|
|
|
return m_start - data_bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Set the data with which this object will extract from to data
|
|
|
|
// starting at BYTES and set the length of the data to LENGTH bytes
|
|
|
|
// long. The data is externally owned must be around at least as
|
|
|
|
// long as this object points to the data. No copy of the data is
|
|
|
|
// made, this object just refers to this data and can extract from
|
|
|
|
// it. If this object refers to any shared data upon entry, the
|
|
|
|
// reference to that data will be released. Is SWAP is set to true,
|
|
|
|
// any data extracted will be endian swapped.
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
|
|
|
DataExtractor::SetData (const void *bytes, offset_t length, ByteOrder endian)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
m_byte_order = endian;
|
|
|
|
m_data_sp.reset();
|
|
|
|
if (bytes == NULL || length == 0)
|
|
|
|
{
|
|
|
|
m_start = NULL;
|
|
|
|
m_end = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_start = (uint8_t *)bytes;
|
|
|
|
m_end = m_start + length;
|
|
|
|
}
|
|
|
|
return GetByteSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Assign the data for this object to be a subrange in "data"
|
|
|
|
// starting "data_offset" bytes into "data" and ending "data_length"
|
|
|
|
// bytes later. If "data_offset" is not a valid offset into "data",
|
|
|
|
// then this object will contain no bytes. If "data_offset" is
|
|
|
|
// within "data" yet "data_length" is too large, the length will be
|
|
|
|
// capped at the number of bytes remaining in "data". If "data"
|
|
|
|
// contains a shared pointer to other data, then a ref counted
|
|
|
|
// pointer to that data will be made in this object. If "data"
|
|
|
|
// doesn't contain a shared pointer to data, then the bytes referred
|
|
|
|
// to in "data" will need to exist at least as long as this object
|
|
|
|
// refers to those bytes. The address size and endian swap settings
|
|
|
|
// are copied from the current values in "data".
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
|
|
|
DataExtractor::SetData (const DataExtractor& data, offset_t data_offset, offset_t data_length)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
m_addr_size = data.m_addr_size;
|
|
|
|
// If "data" contains shared pointer to data, then we can use that
|
|
|
|
if (data.m_data_sp.get())
|
|
|
|
{
|
|
|
|
m_byte_order = data.m_byte_order;
|
|
|
|
return SetData(data.m_data_sp, data.GetSharedDataOffset() + data_offset, data_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have a DataExtractor object that just has a pointer to bytes
|
|
|
|
if (data.ValidOffset(data_offset))
|
|
|
|
{
|
|
|
|
if (data_length > data.GetByteSize() - data_offset)
|
|
|
|
data_length = data.GetByteSize() - data_offset;
|
|
|
|
return SetData (data.GetDataStart() + data_offset, data_length, data.GetByteOrder());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Assign the data for this object to be a subrange of the shared
|
|
|
|
// data in "data_sp" starting "data_offset" bytes into "data_sp"
|
|
|
|
// and ending "data_length" bytes later. If "data_offset" is not
|
|
|
|
// a valid offset into "data_sp", then this object will contain no
|
|
|
|
// bytes. If "data_offset" is within "data_sp" yet "data_length" is
|
|
|
|
// too large, the length will be capped at the number of bytes
|
|
|
|
// remaining in "data_sp". A ref counted pointer to the data in
|
|
|
|
// "data_sp" will be made in this object IF the number of bytes this
|
|
|
|
// object refers to in greater than zero (if at least one byte was
|
|
|
|
// available starting at "data_offset") to ensure the data stays
|
|
|
|
// around as long as it is needed. The address size and endian swap
|
|
|
|
// settings will remain unchanged from their current settings.
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
|
|
|
DataExtractor::SetData (const DataBufferSP& data_sp, offset_t data_offset, offset_t data_length)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
m_start = m_end = NULL;
|
|
|
|
|
|
|
|
if (data_length > 0)
|
|
|
|
{
|
|
|
|
m_data_sp = data_sp;
|
|
|
|
if (data_sp.get())
|
|
|
|
{
|
|
|
|
const size_t data_size = data_sp->GetByteSize();
|
|
|
|
if (data_offset < data_size)
|
|
|
|
{
|
|
|
|
m_start = data_sp->GetBytes() + data_offset;
|
|
|
|
const size_t bytes_left = data_size - data_offset;
|
|
|
|
// Cap the length of we asked for too many
|
|
|
|
if (data_length <= bytes_left)
|
|
|
|
m_end = m_start + data_length; // We got all the bytes we wanted
|
|
|
|
else
|
|
|
|
m_end = m_start + bytes_left; // Not all the bytes requested were available in the shared data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t new_size = GetByteSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Don't hold a shared pointer to the data buffer if we don't share
|
|
|
|
// any valid bytes in the shared buffer.
|
|
|
|
if (new_size == 0)
|
|
|
|
m_data_sp.reset();
|
|
|
|
|
|
|
|
return new_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single unsigned char from the binary data and update
|
|
|
|
// the offset pointed to by "offset_ptr".
|
|
|
|
//
|
|
|
|
// RETURNS the byte that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint8_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU8 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, 1);
|
|
|
|
if (data)
|
|
|
|
return *data;
|
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract "count" unsigned chars from the binary data and update the
|
|
|
|
// offset pointed to by "offset_ptr". The extracted data is copied into
|
|
|
|
// "dst".
|
|
|
|
//
|
|
|
|
// RETURNS the non-NULL buffer pointer upon successful extraction of
|
|
|
|
// all the requested bytes, or NULL when the data is not available in
|
|
|
|
// the buffer due to being out of bounds, or unsufficient data.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void *
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU8 (offset_t *offset_ptr, void *dst, uint32_t count) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, count);
|
|
|
|
if (data)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// Copy the data into the buffer
|
2013-02-09 06:02:02 +08:00
|
|
|
memcpy (dst, data, count);
|
2010-06-09 00:52:24 +08:00
|
|
|
// Return a non-NULL pointer to the converted data as an indicator of success
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single uint16_t from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr".
|
|
|
|
//
|
|
|
|
// RETURNS the uint16_t that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint16_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU16 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint16_t val = 0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
|
|
|
|
if (data)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2013-02-09 06:02:02 +08:00
|
|
|
val = ReadSwapInt16(data);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2013-02-09 06:02:02 +08:00
|
|
|
val = ReadInt16 (data);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:33:30 +08:00
|
|
|
uint16_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU16_unchecked (offset_t *offset_ptr) const
|
2010-09-15 16:33:30 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint16_t val;
|
|
|
|
if (m_byte_order == lldb::endian::InlHostByteOrder())
|
|
|
|
val = ReadInt16 (m_start, *offset_ptr);
|
|
|
|
else
|
|
|
|
val = ReadSwapInt16(m_start, *offset_ptr);
|
2010-09-15 16:33:30 +08:00
|
|
|
*offset_ptr += sizeof(val);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU32_unchecked (offset_t *offset_ptr) const
|
2010-09-15 16:33:30 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint32_t val;
|
|
|
|
if (m_byte_order == lldb::endian::InlHostByteOrder())
|
|
|
|
val = ReadInt32 (m_start, *offset_ptr);
|
|
|
|
else
|
|
|
|
val = ReadSwapInt32 (m_start, *offset_ptr);
|
2010-09-15 16:33:30 +08:00
|
|
|
*offset_ptr += sizeof(val);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU64_unchecked (offset_t *offset_ptr) const
|
2010-09-15 16:33:30 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint64_t val;
|
|
|
|
if (m_byte_order == lldb::endian::InlHostByteOrder())
|
|
|
|
val = ReadInt64 (m_start, *offset_ptr);
|
|
|
|
else
|
|
|
|
val = ReadSwapInt64 (m_start, *offset_ptr);
|
2010-09-15 16:33:30 +08:00
|
|
|
*offset_ptr += sizeof(val);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract "count" uint16_t values from the binary data and update
|
|
|
|
// the offset pointed to by "offset_ptr". The extracted data is
|
|
|
|
// copied into "dst".
|
|
|
|
//
|
|
|
|
// RETURNS the non-NULL buffer pointer upon successful extraction of
|
|
|
|
// all the requested bytes, or NULL when the data is not available
|
|
|
|
// in the buffer due to being out of bounds, or unsufficient data.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void *
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU16 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(uint16_t) * count;
|
|
|
|
const uint16_t *src = (const uint16_t *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint16_t *dst_pos = (uint16_t *)void_dst;
|
|
|
|
uint16_t *dst_end = dst_pos + count;
|
|
|
|
const uint16_t *src_pos = src;
|
|
|
|
while (dst_pos < dst_end)
|
|
|
|
{
|
|
|
|
*dst_pos = ReadSwapInt16 (src_pos);
|
|
|
|
++dst_pos;
|
|
|
|
++src_pos;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
memcpy (void_dst, src, src_size);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// Return a non-NULL pointer to the converted data as an indicator of success
|
2013-02-09 06:02:02 +08:00
|
|
|
return void_dst;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single uint32_t from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr".
|
|
|
|
//
|
|
|
|
// RETURNS the uint32_t that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU32 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint32_t val = 0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint32_t *data = (const uint32_t *)GetData (offset_ptr, sizeof(val));
|
|
|
|
if (data)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2013-02-09 06:02:02 +08:00
|
|
|
val = ReadSwapInt32 (data);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2013-02-09 06:02:02 +08:00
|
|
|
val = *data;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract "count" uint32_t values from the binary data and update
|
|
|
|
// the offset pointed to by "offset_ptr". The extracted data is
|
|
|
|
// copied into "dst".
|
|
|
|
//
|
|
|
|
// RETURNS the non-NULL buffer pointer upon successful extraction of
|
|
|
|
// all the requested bytes, or NULL when the data is not available
|
|
|
|
// in the buffer due to being out of bounds, or unsufficient data.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void *
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU32 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(uint32_t) * count;
|
|
|
|
const uint32_t *src = (const uint32_t *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint32_t *dst_pos = (uint32_t *)void_dst;
|
|
|
|
uint32_t *dst_end = dst_pos + count;
|
|
|
|
const uint32_t *src_pos = src;
|
|
|
|
while (dst_pos < dst_end)
|
|
|
|
{
|
|
|
|
*dst_pos = ReadSwapInt32 (src_pos);
|
|
|
|
++dst_pos;
|
|
|
|
++src_pos;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
memcpy (void_dst, src, src_size);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// Return a non-NULL pointer to the converted data as an indicator of success
|
2013-02-09 06:02:02 +08:00
|
|
|
return void_dst;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single uint64_t from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr".
|
|
|
|
//
|
|
|
|
// RETURNS the uint64_t that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU64 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint64_t val = 0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint64_t *data = (const uint64_t *)GetData (offset_ptr, sizeof(val));
|
|
|
|
if (data)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2013-02-09 06:02:02 +08:00
|
|
|
val = ReadSwapInt64 (data);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2013-02-09 06:02:02 +08:00
|
|
|
val = *data;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// GetU64
|
|
|
|
//
|
|
|
|
// Get multiple consecutive 64 bit values. Return true if the entire
|
|
|
|
// read succeeds and increment the offset pointed to by offset_ptr, else
|
|
|
|
// return false and leave the offset pointed to by offset_ptr unchanged.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void *
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetU64 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(uint64_t) * count;
|
|
|
|
const uint64_t *src = (const uint64_t *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
uint64_t *dst_pos = (uint64_t *)void_dst;
|
|
|
|
uint64_t *dst_end = dst_pos + count;
|
|
|
|
const uint64_t *src_pos = src;
|
|
|
|
while (dst_pos < dst_end)
|
|
|
|
{
|
|
|
|
*dst_pos = ReadSwapInt64 (src_pos);
|
|
|
|
++dst_pos;
|
|
|
|
++src_pos;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
memcpy (void_dst, src, src_size);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// Return a non-NULL pointer to the converted data as an indicator of success
|
2013-02-09 06:02:02 +08:00
|
|
|
return void_dst;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single integer value from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr". The size of the extracted integer
|
|
|
|
// is specified by the "byte_size" argument. "byte_size" should have
|
|
|
|
// a value between 1 and 4 since the return value is only 32 bits
|
|
|
|
// wide. Any "byte_size" values less than 1 or greater than 4 will
|
|
|
|
// result in nothing being extracted, and zero being returned.
|
|
|
|
//
|
|
|
|
// RETURNS the integer value that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxU32 (offset_t *offset_ptr, size_t byte_size) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
switch (byte_size)
|
|
|
|
{
|
|
|
|
case 1: return GetU8 (offset_ptr); break;
|
|
|
|
case 2: return GetU16(offset_ptr); break;
|
|
|
|
case 4: return GetU32(offset_ptr); break;
|
|
|
|
default:
|
2013-01-26 02:06:21 +08:00
|
|
|
assert("GetMaxU32 unhandled case!" == NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extract a single integer value from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr". The size of the extracted integer
|
|
|
|
// is specified by the "byte_size" argument. "byte_size" should have
|
|
|
|
// a value >= 1 and <= 8 since the return value is only 64 bits
|
|
|
|
// wide. Any "byte_size" values less than 1 or greater than 8 will
|
|
|
|
// result in nothing being extracted, and zero being returned.
|
|
|
|
//
|
|
|
|
// RETURNS the integer value that was extracted, or zero on failure.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxU64 (offset_t *offset_ptr, size_t size) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 1: return GetU8 (offset_ptr); break;
|
|
|
|
case 2: return GetU16(offset_ptr); break;
|
|
|
|
case 4: return GetU32(offset_ptr); break;
|
|
|
|
case 8: return GetU64(offset_ptr); break;
|
|
|
|
default:
|
2013-01-26 02:06:21 +08:00
|
|
|
assert("GetMax64 unhandled case!" == NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-30 08:32:24 +08:00
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxU64_unchecked (offset_t *offset_ptr, size_t size) const
|
2011-12-30 08:32:24 +08:00
|
|
|
{
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 1: return GetU8_unchecked (offset_ptr); break;
|
|
|
|
case 2: return GetU16_unchecked (offset_ptr); break;
|
|
|
|
case 4: return GetU32_unchecked (offset_ptr); break;
|
|
|
|
case 8: return GetU64_unchecked (offset_ptr); break;
|
|
|
|
default:
|
2013-01-26 02:06:21 +08:00
|
|
|
assert("GetMax64 unhandled case!" == NULL);
|
2011-12-30 08:32:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
int64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxS64 (offset_t *offset_ptr, size_t size) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 1: return (int8_t)GetU8 (offset_ptr); break;
|
|
|
|
case 2: return (int16_t)GetU16(offset_ptr); break;
|
|
|
|
case 4: return (int32_t)GetU32(offset_ptr); break;
|
|
|
|
case 8: return (int64_t)GetU64(offset_ptr); break;
|
|
|
|
default:
|
2013-01-26 02:06:21 +08:00
|
|
|
assert("GetMax64 unhandled case!" == NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxU64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint64_t uval64 = GetMaxU64 (offset_ptr, size);
|
|
|
|
if (bitfield_bit_size > 0)
|
|
|
|
{
|
|
|
|
if (bitfield_bit_offset > 0)
|
|
|
|
uval64 >>= bitfield_bit_offset;
|
2011-07-06 10:13:41 +08:00
|
|
|
uint64_t bitfield_mask = ((1ul << bitfield_bit_size) - 1);
|
The implementation of categories is now synchronization safe
Code cleanup:
- The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
are contained. The wrapper code always remains in Debugger.{h|cpp}
- Several leftover fields, methods and comments from previous design choices have been removed
type category subcommands (enable, disable, delete) now can take a list of category names as input
- for type category enable, saying "enable A B C" is the same as saying
enable C
enable B
enable A
(the ordering is relevant in enabling categories, and it is expected that a user typing
enable A B C wants to look into category A, then into B, then into C and not the other
way round)
- for the other two commands, the order is not really relevant (however, the same inverted ordering
is used for consistency)
llvm-svn: 135494
2011-07-20 02:03:25 +08:00
|
|
|
if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64)
|
2011-07-06 10:13:41 +08:00
|
|
|
return uval64;
|
2010-06-09 00:52:24 +08:00
|
|
|
uval64 &= bitfield_mask;
|
|
|
|
}
|
|
|
|
return uval64;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetMaxS64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
int64_t sval64 = GetMaxS64 (offset_ptr, size);
|
|
|
|
if (bitfield_bit_size > 0)
|
|
|
|
{
|
|
|
|
if (bitfield_bit_offset > 0)
|
|
|
|
sval64 >>= bitfield_bit_offset;
|
2012-11-01 04:56:43 +08:00
|
|
|
uint64_t bitfield_mask = (((uint64_t)1) << bitfield_bit_size) - 1;
|
2010-06-09 00:52:24 +08:00
|
|
|
sval64 &= bitfield_mask;
|
|
|
|
// sign extend if needed
|
2012-11-01 04:56:43 +08:00
|
|
|
if (sval64 & (((uint64_t)1) << (bitfield_bit_size - 1)))
|
2010-06-09 00:52:24 +08:00
|
|
|
sval64 |= ~bitfield_mask;
|
|
|
|
}
|
|
|
|
return sval64;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetFloat (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-14 12:09:57 +08:00
|
|
|
typedef float float_type;
|
|
|
|
float_type val = 0.0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(float_type);
|
|
|
|
const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-09-14 12:09:57 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src_data = (const uint8_t *)src;
|
2010-09-14 12:09:57 +08:00
|
|
|
uint8_t *dst_data = (uint8_t *)&val;
|
|
|
|
for (int i=0; i<sizeof(float_type); ++i)
|
|
|
|
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2010-09-14 12:09:57 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
val = *src;
|
2010-09-14 12:09:57 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-14 12:09:57 +08:00
|
|
|
return val;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetDouble (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-14 12:09:57 +08:00
|
|
|
typedef double float_type;
|
|
|
|
float_type val = 0.0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(float_type);
|
|
|
|
const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-09-14 12:09:57 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src_data = (const uint8_t *)src;
|
2010-09-14 12:09:57 +08:00
|
|
|
uint8_t *dst_data = (uint8_t *)&val;
|
|
|
|
for (int i=0; i<sizeof(float_type); ++i)
|
|
|
|
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2010-09-14 12:09:57 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
val = *src;
|
2010-09-14 12:09:57 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-14 12:09:57 +08:00
|
|
|
return val;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long double
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetLongDouble (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-14 12:09:57 +08:00
|
|
|
typedef long double float_type;
|
|
|
|
float_type val = 0.0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const size_t src_size = sizeof(float_type);
|
|
|
|
const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
|
|
|
|
if (src)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-02-01 09:31:41 +08:00
|
|
|
if (m_byte_order != lldb::endian::InlHostByteOrder())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src_data = (const uint8_t *)src;
|
2010-09-14 12:09:57 +08:00
|
|
|
uint8_t *dst_data = (uint8_t *)&val;
|
|
|
|
for (int i=0; i<sizeof(float_type); ++i)
|
|
|
|
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-14 12:09:57 +08:00
|
|
|
else
|
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
val = *src;
|
2010-09-14 12:09:57 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-09-14 12:09:57 +08:00
|
|
|
return val;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Extract a single address from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr". The size of the extracted address
|
|
|
|
// comes from the "this->m_addr_size" member variable and should be
|
|
|
|
// set correctly prior to extracting any address values.
|
|
|
|
//
|
|
|
|
// RETURNS the address that was extracted, or zero on failure.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetAddress (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return GetMaxU64 (offset_ptr, m_addr_size);
|
|
|
|
}
|
|
|
|
|
2011-12-30 08:32:24 +08:00
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetAddress_unchecked (offset_t *offset_ptr) const
|
2011-12-30 08:32:24 +08:00
|
|
|
{
|
|
|
|
return GetMaxU64_unchecked (offset_ptr, m_addr_size);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Extract a single pointer from the data and update the offset
|
|
|
|
// pointed to by "offset_ptr". The size of the extracted pointer
|
|
|
|
// comes from the "this->m_addr_size" member variable and should be
|
|
|
|
// set correctly prior to extracting any pointer values.
|
|
|
|
//
|
|
|
|
// RETURNS the pointer that was extracted, or zero on failure.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetPointer (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return GetMaxU64 (offset_ptr, m_addr_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// GetDwarfEHPtr
|
|
|
|
//
|
|
|
|
// Used for calls when the value type is specified by a DWARF EH Frame
|
|
|
|
// pointer encoding.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetGNUEHPointer (offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, lldb::addr_t data_addr)//, BSDRelocs *data_relocs) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-07 06:38:03 +08:00
|
|
|
if (eh_ptr_enc == DW_EH_PE_omit)
|
2011-04-02 02:14:08 +08:00
|
|
|
return ULLONG_MAX; // Value isn't in the buffer...
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
uint64_t baseAddress = 0;
|
|
|
|
uint64_t addressValue = 0;
|
|
|
|
const uint32_t addr_size = GetAddressByteSize();
|
|
|
|
|
|
|
|
bool signExtendValue = false;
|
|
|
|
// Decode the base part or adjust our offset
|
|
|
|
switch (eh_ptr_enc & 0x70)
|
|
|
|
{
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_pcrel:
|
2010-06-09 00:52:24 +08:00
|
|
|
signExtendValue = true;
|
|
|
|
baseAddress = *offset_ptr;
|
|
|
|
if (pc_rel_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
baseAddress += pc_rel_addr;
|
|
|
|
// else
|
|
|
|
// Log::GlobalWarning ("PC relative pointer encoding found with invalid pc relative address.");
|
|
|
|
break;
|
|
|
|
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_textrel:
|
2010-06-09 00:52:24 +08:00
|
|
|
signExtendValue = true;
|
|
|
|
if (text_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
baseAddress = text_addr;
|
|
|
|
// else
|
|
|
|
// Log::GlobalWarning ("text relative pointer encoding being decoded with invalid text section address, setting base address to zero.");
|
|
|
|
break;
|
|
|
|
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_datarel:
|
2010-06-09 00:52:24 +08:00
|
|
|
signExtendValue = true;
|
|
|
|
if (data_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
baseAddress = data_addr;
|
|
|
|
// else
|
|
|
|
// Log::GlobalWarning ("data relative pointer encoding being decoded with invalid data section address, setting base address to zero.");
|
|
|
|
break;
|
|
|
|
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_funcrel:
|
2010-06-09 00:52:24 +08:00
|
|
|
signExtendValue = true;
|
|
|
|
break;
|
|
|
|
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_aligned:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// SetPointerSize should be called prior to extracting these so the
|
|
|
|
// pointer size is cached
|
|
|
|
assert(addr_size != 0);
|
|
|
|
if (addr_size)
|
|
|
|
{
|
|
|
|
// Align to a address size boundary first
|
|
|
|
uint32_t alignOffset = *offset_ptr % addr_size;
|
|
|
|
if (alignOffset)
|
|
|
|
offset_ptr += addr_size - alignOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decode the value part
|
2010-07-07 06:38:03 +08:00
|
|
|
switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_absptr :
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
addressValue = GetAddress (offset_ptr);
|
|
|
|
// if (data_relocs)
|
|
|
|
// addressValue = data_relocs->Relocate(*offset_ptr - addr_size, *this, addressValue);
|
|
|
|
}
|
|
|
|
break;
|
2010-07-07 06:38:03 +08:00
|
|
|
case DW_EH_PE_uleb128 : addressValue = GetULEB128(offset_ptr); break;
|
|
|
|
case DW_EH_PE_udata2 : addressValue = GetU16(offset_ptr); break;
|
|
|
|
case DW_EH_PE_udata4 : addressValue = GetU32(offset_ptr); break;
|
|
|
|
case DW_EH_PE_udata8 : addressValue = GetU64(offset_ptr); break;
|
|
|
|
case DW_EH_PE_sleb128 : addressValue = GetSLEB128(offset_ptr); break;
|
|
|
|
case DW_EH_PE_sdata2 : addressValue = (int16_t)GetU16(offset_ptr); break;
|
|
|
|
case DW_EH_PE_sdata4 : addressValue = (int32_t)GetU32(offset_ptr); break;
|
|
|
|
case DW_EH_PE_sdata8 : addressValue = (int64_t)GetU64(offset_ptr); break;
|
2010-06-09 00:52:24 +08:00
|
|
|
default:
|
|
|
|
// Unhandled encoding type
|
|
|
|
assert(eh_ptr_enc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Since we promote everything to 64 bit, we may need to sign extend
|
|
|
|
if (signExtendValue && addr_size < sizeof(baseAddress))
|
|
|
|
{
|
|
|
|
uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull);
|
|
|
|
if (sign_bit & addressValue)
|
|
|
|
{
|
|
|
|
uint64_t mask = ~sign_bit + 1;
|
|
|
|
addressValue |= mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return baseAddress + addressValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::ExtractBytes (offset_t offset, offset_t length, ByteOrder dst_byte_order, void *dst) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const uint8_t *src = PeekData (offset, length);
|
|
|
|
if (src)
|
|
|
|
{
|
|
|
|
if (dst_byte_order != GetByteOrder())
|
|
|
|
{
|
|
|
|
for (uint32_t i=0; i<length; ++i)
|
|
|
|
((uint8_t*)dst)[i] = src[length - i - 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
::memcpy (dst, src, length);
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
// Extract data and swap if needed when doing the copy
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
|
|
|
DataExtractor::CopyByteOrderedData (offset_t src_offset,
|
|
|
|
offset_t src_len,
|
2011-05-10 04:18:18 +08:00
|
|
|
void *dst_void_ptr,
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t dst_len,
|
2011-05-10 04:18:18 +08:00
|
|
|
ByteOrder dst_byte_order) const
|
|
|
|
{
|
|
|
|
// Validate the source info
|
2013-01-26 02:06:21 +08:00
|
|
|
if (!ValidOffsetForDataOfSize(src_offset, src_len))
|
|
|
|
assert (ValidOffsetForDataOfSize(src_offset, src_len));
|
2011-05-10 04:18:18 +08:00
|
|
|
assert (src_len > 0);
|
|
|
|
assert (m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle);
|
|
|
|
|
|
|
|
// Validate the destination info
|
|
|
|
assert (dst_void_ptr != NULL);
|
|
|
|
assert (dst_len > 0);
|
|
|
|
assert (dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle);
|
|
|
|
|
|
|
|
// Must have valid byte orders set in this object and for destination
|
|
|
|
if (!(dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle) ||
|
|
|
|
!(m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t i;
|
|
|
|
uint8_t* dst = (uint8_t*)dst_void_ptr;
|
|
|
|
const uint8_t* src = (const uint8_t *)PeekData (src_offset, src_len);
|
|
|
|
if (src)
|
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
if (dst_len >= src_len)
|
2011-05-10 04:18:18 +08:00
|
|
|
{
|
|
|
|
// We are copying the entire value from src into dst.
|
|
|
|
// Calculate how many, if any, zeroes we need for the most
|
|
|
|
// significant bytes if "dst_len" is greater than "src_len"...
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t num_zeroes = dst_len - src_len;
|
2011-05-10 04:18:18 +08:00
|
|
|
if (dst_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
// Big endian, so we lead with zeroes...
|
|
|
|
if (num_zeroes > 0)
|
|
|
|
::memset (dst, 0, num_zeroes);
|
|
|
|
// Then either copy or swap the rest
|
|
|
|
if (m_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
::memcpy (dst + num_zeroes, src, src_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i=0; i<src_len; ++i)
|
|
|
|
dst[i+num_zeroes] = src[src_len - 1 - i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Little endian destination, so we lead the value bytes
|
|
|
|
if (m_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
for (i=0; i<src_len; ++i)
|
|
|
|
dst[i] = src[src_len - 1 - i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::memcpy (dst, src, src_len);
|
|
|
|
}
|
|
|
|
// And zero the rest...
|
|
|
|
if (num_zeroes > 0)
|
|
|
|
::memset (dst + src_len, 0, num_zeroes);
|
|
|
|
}
|
|
|
|
return src_len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We are only copying some of the value from src into dst..
|
|
|
|
|
|
|
|
if (dst_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
// Big endian dst
|
|
|
|
if (m_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
// Big endian dst, with big endian src
|
|
|
|
::memcpy (dst, src + (src_len - dst_len), dst_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Big endian dst, with little endian src
|
|
|
|
for (i=0; i<dst_len; ++i)
|
|
|
|
dst[i] = src[dst_len - 1 - i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Little endian dst
|
|
|
|
if (m_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
// Little endian dst, with big endian src
|
|
|
|
for (i=0; i<dst_len; ++i)
|
|
|
|
dst[i] = src[src_len - 1 - i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Little endian dst, with big endian src
|
|
|
|
::memcpy (dst, src, dst_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dst_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extracts a AsCString (fixed length, or variable length) from
|
|
|
|
// the data at the offset pointed to by "offset_ptr". If
|
|
|
|
// "length" is zero, then a variable length NULL terminated C
|
|
|
|
// string will be extracted from the data the "offset_ptr" will be
|
|
|
|
// updated with the offset of the byte that follows the NULL
|
|
|
|
// terminator byte. If "length" is greater than zero, then
|
|
|
|
// the function will make sure there are "length" bytes
|
|
|
|
// available in the current data and if so, return a valid pointer.
|
|
|
|
//
|
|
|
|
// If the offset pointed to by "offset_ptr" is out of bounds, or if
|
|
|
|
// "length" is non-zero and there aren't enough avaialable
|
|
|
|
// bytes, NULL will be returned and "offset_ptr" will not be
|
|
|
|
// updated.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const char*
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetCStr (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const char *cstr = (const char *)PeekData (*offset_ptr, 1);
|
|
|
|
if (cstr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const char *cstr_end = cstr;
|
|
|
|
const char *end = (const char *)m_end;
|
|
|
|
while (cstr_end < end && *cstr_end)
|
|
|
|
++cstr_end;
|
|
|
|
|
|
|
|
// Now we are either at the end of the data or we point to the
|
|
|
|
// NULL C string terminator with cstr_end...
|
|
|
|
if (*cstr_end == '\0')
|
|
|
|
{
|
|
|
|
// Advance the offset with one extra byte for the NULL terminator
|
|
|
|
*offset_ptr += (cstr_end - cstr + 1);
|
|
|
|
return cstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We reached the end of the data without finding a NULL C string
|
|
|
|
// terminator. Fall through and return NULL otherwise anyone that
|
|
|
|
// would have used the result as a C string can wonder into
|
|
|
|
// unknown memory...
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-02-09 06:02:02 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Peeks at a string in the contained data. No verification is done
|
|
|
|
// to make sure the entire string lies within the bounds of this
|
|
|
|
// object's data, only "offset" is verified to be a valid offset.
|
|
|
|
//
|
|
|
|
// Returns a valid C string pointer if "offset" is a valid offset in
|
|
|
|
// this object's data, else NULL is returned.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
const char *
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::PeekCStr (offset_t offset) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
return (const char *)PeekData (offset, 1);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extracts an unsigned LEB128 number from this object's data
|
|
|
|
// starting at the offset pointed to by "offset_ptr". The offset
|
|
|
|
// pointed to by "offset_ptr" will be updated with the offset of the
|
|
|
|
// byte following the last extracted byte.
|
|
|
|
//
|
|
|
|
// Returned the extracted integer value.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetULEB128 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
|
2011-11-15 06:56:58 +08:00
|
|
|
const uint8_t *end = m_end;
|
|
|
|
|
|
|
|
if (src < end)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-11-15 06:56:58 +08:00
|
|
|
uint64_t result = *src++;
|
|
|
|
if (result >= 0x80)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-11-15 06:56:58 +08:00
|
|
|
result &= 0x7f;
|
|
|
|
int shift = 7;
|
|
|
|
while (src < end)
|
|
|
|
{
|
|
|
|
uint8_t byte = *src++;
|
|
|
|
result |= (byte & 0x7f) << shift;
|
|
|
|
if ((byte & 0x80) == 0)
|
|
|
|
break;
|
|
|
|
shift += 7;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-02-09 06:02:02 +08:00
|
|
|
*offset_ptr = src - m_start;
|
2011-11-15 06:56:58 +08:00
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-11-15 06:56:58 +08:00
|
|
|
|
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Extracts an signed LEB128 number from this object's data
|
|
|
|
// starting at the offset pointed to by "offset_ptr". The offset
|
|
|
|
// pointed to by "offset_ptr" will be updated with the offset of the
|
|
|
|
// byte following the last extracted byte.
|
|
|
|
//
|
|
|
|
// Returned the extracted integer value.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int64_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::GetSLEB128 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
|
|
|
|
const uint8_t *end = m_end;
|
|
|
|
|
|
|
|
if (src < end)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
int64_t result = 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
int shift = 0;
|
2013-02-09 06:02:02 +08:00
|
|
|
int size = sizeof (int64_t) * 8;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-10 04:39:50 +08:00
|
|
|
uint8_t byte = 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
int bytecount = 0;
|
|
|
|
|
2013-02-09 06:02:02 +08:00
|
|
|
while (src < end)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bytecount++;
|
|
|
|
byte = *src++;
|
|
|
|
result |= (byte & 0x7f) << shift;
|
|
|
|
shift += 7;
|
|
|
|
if ((byte & 0x80) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sign bit of byte is 2nd high order bit (0x40)
|
|
|
|
if (shift < size && (byte & 0x40))
|
|
|
|
result |= - (1 << shift);
|
|
|
|
|
|
|
|
*offset_ptr += bytecount;
|
2013-02-09 06:02:02 +08:00
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-02-09 06:02:02 +08:00
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Skips a ULEB128 number (signed or unsigned) from this object's
|
|
|
|
// data starting at the offset pointed to by "offset_ptr". The
|
|
|
|
// offset pointed to by "offset_ptr" will be updated with the offset
|
|
|
|
// of the byte following the last extracted byte.
|
|
|
|
//
|
|
|
|
// Returns the number of bytes consumed during the extraction.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
uint32_t
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::Skip_LEB128 (offset_t *offset_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint32_t bytes_consumed = 0;
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
|
|
|
|
const uint8_t *end = m_end;
|
|
|
|
|
|
|
|
if (src < end)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-09 06:02:02 +08:00
|
|
|
const uint8_t *src_pos = src;
|
|
|
|
while ((src_pos < end) && (*src_pos++ & 0x80))
|
2010-06-09 00:52:24 +08:00
|
|
|
++bytes_consumed;
|
2013-02-09 06:02:02 +08:00
|
|
|
*offset_ptr += src_pos - src;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return bytes_consumed;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
static lldb::offset_t
|
|
|
|
DumpAPInt (Stream *s, const DataExtractor &data, lldb::offset_t offset, lldb::offset_t byte_size, bool is_signed, unsigned radix)
|
2011-08-15 10:24:40 +08:00
|
|
|
{
|
|
|
|
llvm::SmallVector<uint64_t, 2> uint64_array;
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t bytes_left = byte_size;
|
2011-08-15 10:24:40 +08:00
|
|
|
uint64_t u64;
|
|
|
|
const lldb::ByteOrder byte_order = data.GetByteOrder();
|
|
|
|
if (byte_order == lldb::eByteOrderLittle)
|
|
|
|
{
|
|
|
|
while (bytes_left > 0)
|
|
|
|
{
|
|
|
|
if (bytes_left >= 8)
|
|
|
|
{
|
|
|
|
u64 = data.GetU64(&offset);
|
|
|
|
bytes_left -= 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
u64 = data.GetMaxU64(&offset, (uint32_t)bytes_left);
|
2011-08-15 10:24:40 +08:00
|
|
|
bytes_left = 0;
|
|
|
|
}
|
|
|
|
uint64_array.push_back(u64);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (byte_order == lldb::eByteOrderBig)
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t be_offset = offset + byte_size;
|
|
|
|
lldb::offset_t temp_offset;
|
2011-08-15 10:24:40 +08:00
|
|
|
while (bytes_left > 0)
|
|
|
|
{
|
|
|
|
if (bytes_left >= 8)
|
|
|
|
{
|
|
|
|
be_offset -= 8;
|
|
|
|
temp_offset = be_offset;
|
|
|
|
u64 = data.GetU64(&temp_offset);
|
|
|
|
bytes_left -= 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
be_offset -= bytes_left;
|
|
|
|
temp_offset = be_offset;
|
2013-01-26 02:06:21 +08:00
|
|
|
u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
|
2011-08-15 10:24:40 +08:00
|
|
|
bytes_left = 0;
|
|
|
|
}
|
|
|
|
uint64_array.push_back(u64);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return offset;
|
|
|
|
|
2011-08-15 15:23:47 +08:00
|
|
|
llvm::APInt apint (byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
|
2011-08-15 10:24:40 +08:00
|
|
|
|
|
|
|
std::string apint_str(apint.toString(radix, is_signed));
|
|
|
|
switch (radix)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
s->Write ("0b", 2);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
s->Write ("0", 1);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s->Write(apint_str.c_str(), apint_str.size());
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
DataExtractor::Dump (Stream *s,
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t start_offset,
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
lldb::Format item_format,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t item_byte_size,
|
|
|
|
size_t item_count,
|
|
|
|
size_t num_per_line,
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
uint64_t base_addr,
|
|
|
|
uint32_t item_bit_size, // If zero, this is not a bitfield value, if non-zero, the value is a bitfield
|
|
|
|
uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the shift amount to apply to a bitfield
|
|
|
|
ExecutionContextScope *exe_scope) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (s == NULL)
|
|
|
|
return start_offset;
|
|
|
|
|
|
|
|
if (item_format == eFormatPointer)
|
|
|
|
{
|
|
|
|
if (item_byte_size != 4 && item_byte_size != 8)
|
|
|
|
item_byte_size = s->GetAddressByteSize();
|
|
|
|
}
|
2011-01-06 02:43:15 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t offset = start_offset;
|
2011-10-29 07:44:55 +08:00
|
|
|
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
if (item_format == eFormatInstruction)
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
TargetSP target_sp;
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
if (exe_scope)
|
2012-02-18 13:35:26 +08:00
|
|
|
target_sp = exe_scope->CalculateTarget();
|
|
|
|
if (target_sp)
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
{
|
2013-03-02 08:26:47 +08:00
|
|
|
DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL, NULL));
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
if (disassembler_sp)
|
|
|
|
{
|
|
|
|
lldb::addr_t addr = base_addr + start_offset;
|
|
|
|
lldb_private::Address so_addr;
|
2013-03-29 07:42:53 +08:00
|
|
|
bool data_from_file = true;
|
|
|
|
if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
|
|
|
|
{
|
|
|
|
data_from_file = false;
|
|
|
|
}
|
|
|
|
else
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
{
|
2013-02-14 11:26:35 +08:00
|
|
|
if (target_sp->GetSectionLoadList().IsEmpty() || !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
|
|
|
|
so_addr.SetRawAddress(addr);
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
}
|
|
|
|
|
2013-03-29 07:42:53 +08:00
|
|
|
size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false, data_from_file);
|
2011-10-29 07:44:55 +08:00
|
|
|
|
|
|
|
if (bytes_consumed)
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
{
|
2011-10-29 07:44:55 +08:00
|
|
|
offset += bytes_consumed;
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
const bool show_address = base_addr != LLDB_INVALID_ADDRESS;
|
|
|
|
const bool show_bytes = true;
|
|
|
|
ExecutionContext exe_ctx;
|
|
|
|
exe_scope->CalculateExecutionContext(exe_ctx);
|
|
|
|
disassembler_sp->GetInstructionList().Dump (s, show_address, show_bytes, &exe_ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s->Printf ("invalid target");
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) && item_byte_size > 8)
|
2011-01-06 02:43:15 +08:00
|
|
|
item_format = eFormatHex;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t line_start_offset = start_offset;
|
2011-10-29 07:44:55 +08:00
|
|
|
for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if ((count % num_per_line) == 0)
|
|
|
|
{
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
|
|
|
|
Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
s->EOL();
|
|
|
|
}
|
|
|
|
if (base_addr != LLDB_INVALID_ADDRESS)
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("0x%8.8" PRIx64 ": ", (uint64_t)(base_addr + (offset - start_offset)));
|
2010-06-09 00:52:24 +08:00
|
|
|
line_start_offset = offset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (item_format != eFormatChar &&
|
|
|
|
item_format != eFormatCharPrintable &&
|
2011-06-18 07:50:44 +08:00
|
|
|
item_format != eFormatCharArray &&
|
2010-06-09 00:52:24 +08:00
|
|
|
count > 0)
|
|
|
|
{
|
|
|
|
s->PutChar(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t i;
|
|
|
|
switch (item_format)
|
|
|
|
{
|
|
|
|
case eFormatBoolean:
|
2012-02-28 07:00:14 +08:00
|
|
|
if (item_byte_size <= 8)
|
|
|
|
s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false");
|
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("error: unsupported byte size (%zu) for boolean format", item_byte_size);
|
2012-02-28 07:00:14 +08:00
|
|
|
return offset;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatBinary:
|
2011-08-15 10:24:40 +08:00
|
|
|
if (item_byte_size <= 8)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
|
2010-07-21 09:08:41 +08:00
|
|
|
// Avoid std::bitset<64>::to_string() since it is missing in
|
|
|
|
// earlier C++ libraries
|
|
|
|
std::string binary_value(64, '0');
|
|
|
|
std::bitset<64> bits(uval64);
|
2011-01-26 07:55:37 +08:00
|
|
|
for (i = 0; i < 64; ++i)
|
2010-07-21 09:08:41 +08:00
|
|
|
if (bits[i])
|
|
|
|
binary_value[64 - 1 - i] = '1';
|
2010-06-09 00:52:24 +08:00
|
|
|
if (item_bit_size > 0)
|
|
|
|
s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size);
|
|
|
|
else if (item_byte_size > 0 && item_byte_size <= 8)
|
|
|
|
s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
|
|
|
|
}
|
2011-08-15 10:24:40 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool is_signed = false;
|
|
|
|
const unsigned radix = 2;
|
|
|
|
offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatBytes:
|
|
|
|
case eFormatBytesWithASCII:
|
|
|
|
for (i=0; i<item_byte_size; ++i)
|
|
|
|
{
|
|
|
|
s->Printf ("%2.2x", GetU8(&offset));
|
|
|
|
}
|
|
|
|
// Put an extra space between the groups of bytes if more than one
|
|
|
|
// is being dumped in a group (item_byte_size is more than 1).
|
|
|
|
if (item_byte_size > 1)
|
|
|
|
s->PutChar(' ');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatChar:
|
|
|
|
case eFormatCharPrintable:
|
2011-06-18 07:50:44 +08:00
|
|
|
case eFormatCharArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// If we are only printing one character surround it with single
|
|
|
|
// quotes
|
|
|
|
if (item_count == 1 && item_format == eFormatChar)
|
|
|
|
s->PutChar('\'');
|
|
|
|
|
2011-11-10 11:38:56 +08:00
|
|
|
const uint64_t ch = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (isprint(ch))
|
2011-11-10 11:38:56 +08:00
|
|
|
s->Printf ("%c", (char)ch);
|
2011-06-18 07:50:44 +08:00
|
|
|
else if (item_format != eFormatCharPrintable)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
switch (ch)
|
|
|
|
{
|
2011-11-01 06:51:00 +08:00
|
|
|
case '\033': s->Printf ("\\e"); break;
|
2011-09-21 05:44:10 +08:00
|
|
|
case '\a': s->Printf ("\\a"); break;
|
|
|
|
case '\b': s->Printf ("\\b"); break;
|
|
|
|
case '\f': s->Printf ("\\f"); break;
|
|
|
|
case '\n': s->Printf ("\\n"); break;
|
|
|
|
case '\r': s->Printf ("\\r"); break;
|
|
|
|
case '\t': s->Printf ("\\t"); break;
|
|
|
|
case '\v': s->Printf ("\\v"); break;
|
|
|
|
case '\0': s->Printf ("\\0"); break;
|
2011-01-06 02:43:15 +08:00
|
|
|
default:
|
|
|
|
if (item_byte_size == 1)
|
2011-11-10 11:38:56 +08:00
|
|
|
s->Printf ("\\x%2.2x", (uint8_t)ch);
|
2011-01-06 02:43:15 +08:00
|
|
|
else
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("%" PRIu64, ch);
|
2011-01-06 02:43:15 +08:00
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->PutChar(NON_PRINTABLE_CHAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we are only printing one character surround it with single quotes
|
|
|
|
if (item_count == 1 && item_format == eFormatChar)
|
|
|
|
s->PutChar('\'');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-02-28 07:00:14 +08:00
|
|
|
case eFormatEnum: // Print enum value as a signed integer when we don't get the enum type
|
2010-06-09 00:52:24 +08:00
|
|
|
case eFormatDecimal:
|
2010-07-07 04:30:35 +08:00
|
|
|
if (item_byte_size <= 8)
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("%" PRId64, GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
|
2011-08-15 10:24:40 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool is_signed = true;
|
|
|
|
const unsigned radix = 10;
|
|
|
|
offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatUnsigned:
|
2010-07-07 04:30:35 +08:00
|
|
|
if (item_byte_size <= 8)
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("%" PRIu64, GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
|
2011-08-15 10:24:40 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool is_signed = false;
|
|
|
|
const unsigned radix = 10;
|
|
|
|
offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatOctal:
|
2010-07-07 04:30:35 +08:00
|
|
|
if (item_byte_size <= 8)
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf ("0%" PRIo64, GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
|
2011-08-15 10:24:40 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool is_signed = false;
|
|
|
|
const unsigned radix = 8;
|
|
|
|
offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2011-01-06 02:43:15 +08:00
|
|
|
case eFormatOSType:
|
|
|
|
{
|
|
|
|
uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
|
|
|
|
s->PutChar('\'');
|
|
|
|
for (i=0; i<item_byte_size; ++i)
|
|
|
|
{
|
2011-10-27 05:01:16 +08:00
|
|
|
uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
|
2011-01-06 02:43:15 +08:00
|
|
|
if (isprint(ch))
|
|
|
|
s->Printf ("%c", ch);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (ch)
|
|
|
|
{
|
2011-11-01 06:51:02 +08:00
|
|
|
case '\033': s->Printf ("\\e"); break;
|
2011-09-21 05:44:10 +08:00
|
|
|
case '\a': s->Printf ("\\a"); break;
|
|
|
|
case '\b': s->Printf ("\\b"); break;
|
|
|
|
case '\f': s->Printf ("\\f"); break;
|
|
|
|
case '\n': s->Printf ("\\n"); break;
|
|
|
|
case '\r': s->Printf ("\\r"); break;
|
|
|
|
case '\t': s->Printf ("\\t"); break;
|
|
|
|
case '\v': s->Printf ("\\v"); break;
|
|
|
|
case '\0': s->Printf ("\\0"); break;
|
2011-01-06 02:43:15 +08:00
|
|
|
default: s->Printf ("\\x%2.2x", ch); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->PutChar('\'');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
case eFormatCString:
|
|
|
|
{
|
|
|
|
const char *cstr = GetCStr(&offset);
|
2012-01-05 01:36:30 +08:00
|
|
|
|
|
|
|
if (!cstr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-09-21 05:44:10 +08:00
|
|
|
s->Printf("NULL");
|
2013-01-26 02:06:21 +08:00
|
|
|
offset = LLDB_INVALID_OFFSET;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2012-01-05 01:36:30 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
s->PutChar('\"');
|
|
|
|
|
|
|
|
while (const char c = *cstr)
|
|
|
|
{
|
|
|
|
if (isprint(c))
|
|
|
|
{
|
|
|
|
s->PutChar(c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '\033': s->Printf ("\\e"); break;
|
|
|
|
case '\a': s->Printf ("\\a"); break;
|
|
|
|
case '\b': s->Printf ("\\b"); break;
|
|
|
|
case '\f': s->Printf ("\\f"); break;
|
|
|
|
case '\n': s->Printf ("\\n"); break;
|
|
|
|
case '\r': s->Printf ("\\r"); break;
|
|
|
|
case '\t': s->Printf ("\\t"); break;
|
|
|
|
case '\v': s->Printf ("\\v"); break;
|
|
|
|
default: s->Printf ("\\x%2.2x", c); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++cstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->PutChar('\"');
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case eFormatPointer:
|
|
|
|
s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset), sizeof (addr_t));
|
|
|
|
break;
|
|
|
|
|
2011-01-15 10:52:14 +08:00
|
|
|
|
|
|
|
case eFormatComplexInteger:
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t complex_int_byte_size = item_byte_size / 2;
|
2011-01-15 10:52:14 +08:00
|
|
|
|
|
|
|
if (complex_int_byte_size <= 8)
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf("%" PRIu64, GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
|
|
|
|
s->Printf(" + %" PRIu64 "i", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
|
2011-01-15 10:52:14 +08:00
|
|
|
}
|
2012-02-28 07:00:14 +08:00
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("error: unsupported byte size (%zu) for complex integer format", item_byte_size);
|
2012-02-28 07:00:14 +08:00
|
|
|
return offset;
|
|
|
|
}
|
2011-01-15 10:52:14 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-01-06 02:43:15 +08:00
|
|
|
case eFormatComplex:
|
|
|
|
if (sizeof(float) * 2 == item_byte_size)
|
|
|
|
{
|
|
|
|
float f32_1 = GetFloat (&offset);
|
|
|
|
float f32_2 = GetFloat (&offset);
|
|
|
|
|
|
|
|
s->Printf ("%g + %gi", f32_1, f32_2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (sizeof(double) * 2 == item_byte_size)
|
|
|
|
{
|
|
|
|
double d64_1 = GetDouble (&offset);
|
|
|
|
double d64_2 = GetDouble (&offset);
|
|
|
|
|
|
|
|
s->Printf ("%lg + %lgi", d64_1, d64_2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (sizeof(long double) * 2 == item_byte_size)
|
|
|
|
{
|
|
|
|
long double ld64_1 = GetLongDouble (&offset);
|
|
|
|
long double ld64_2 = GetLongDouble (&offset);
|
|
|
|
s->Printf ("%Lg + %Lgi", ld64_1, ld64_2);
|
|
|
|
break;
|
|
|
|
}
|
2011-01-15 10:52:14 +08:00
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("error: unsupported byte size (%zu) for complex float format", item_byte_size);
|
2012-02-28 07:00:14 +08:00
|
|
|
return offset;
|
2011-01-15 10:52:14 +08:00
|
|
|
}
|
|
|
|
break;
|
2011-01-06 02:43:15 +08:00
|
|
|
|
2010-07-10 04:39:50 +08:00
|
|
|
default:
|
|
|
|
case eFormatDefault:
|
2010-06-09 00:52:24 +08:00
|
|
|
case eFormatHex:
|
2012-08-10 03:33:34 +08:00
|
|
|
case eFormatHexUppercase:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-08-10 03:33:34 +08:00
|
|
|
bool wantsuppercase = (item_format == eFormatHexUppercase);
|
|
|
|
if (item_byte_size <= 8)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
|
2012-08-10 03:33:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert (item_bit_size == 0 && item_bit_offset == 0);
|
|
|
|
s->PutCString("0x");
|
|
|
|
const uint8_t *bytes = (const uint8_t* )GetData(&offset, item_byte_size);
|
|
|
|
if (bytes)
|
2011-04-29 04:55:26 +08:00
|
|
|
{
|
2012-08-10 03:33:34 +08:00
|
|
|
uint32_t idx;
|
|
|
|
if (m_byte_order == eByteOrderBig)
|
|
|
|
{
|
|
|
|
for (idx = 0; idx < item_byte_size; ++idx)
|
|
|
|
s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (idx = 0; idx < item_byte_size; ++idx)
|
|
|
|
s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[item_byte_size - 1 - idx]);
|
|
|
|
}
|
2011-04-29 04:55:26 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatFloat:
|
|
|
|
{
|
2012-10-20 14:08:09 +08:00
|
|
|
std::ostringstream ss;
|
2012-11-02 07:35:19 +08:00
|
|
|
if (item_byte_size == sizeof(float))
|
2012-10-20 14:08:09 +08:00
|
|
|
{
|
|
|
|
ss.precision(std::numeric_limits<float>::digits10);
|
|
|
|
ss << GetFloat(&offset);
|
2012-11-02 07:35:19 +08:00
|
|
|
}
|
|
|
|
else if (item_byte_size == sizeof(double))
|
|
|
|
{
|
2012-10-20 14:08:09 +08:00
|
|
|
ss.precision(std::numeric_limits<double>::digits10);
|
|
|
|
ss << GetDouble(&offset);
|
2012-11-02 07:35:19 +08:00
|
|
|
}
|
|
|
|
else if (item_byte_size == sizeof(long double))
|
|
|
|
{
|
2012-10-20 14:08:09 +08:00
|
|
|
ss.precision(std::numeric_limits<long double>::digits10);
|
|
|
|
ss << GetLongDouble(&offset);
|
2012-11-02 07:35:19 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("error: unsupported byte size (%zu) for float format", item_byte_size);
|
2012-11-02 07:35:19 +08:00
|
|
|
return offset;
|
2012-10-20 14:08:09 +08:00
|
|
|
}
|
|
|
|
ss.flush();
|
|
|
|
s->Printf("%s", ss.str().c_str());
|
2012-02-28 07:00:14 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatUnicode16:
|
2012-02-28 07:00:14 +08:00
|
|
|
s->Printf("U+%4.4x", GetU16 (&offset));
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatUnicode32:
|
2012-02-28 07:00:14 +08:00
|
|
|
s->Printf("U+0x%8.8x", GetU32 (&offset));
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
case eFormatAddressInfo:
|
|
|
|
{
|
|
|
|
addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), addr);
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
if (exe_scope)
|
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
TargetSP target_sp (exe_scope->CalculateTarget());
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
lldb_private::Address so_addr;
|
2012-07-12 06:18:24 +08:00
|
|
|
if (target_sp)
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
{
|
2012-07-12 06:18:24 +08:00
|
|
|
if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
|
|
|
|
{
|
|
|
|
s->PutChar(' ');
|
|
|
|
so_addr.Dump (s,
|
|
|
|
exe_scope,
|
|
|
|
Address::DumpStyleResolvedDescription,
|
|
|
|
Address::DumpStyleModuleWithFileAddress);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
so_addr.SetOffset(addr);
|
|
|
|
so_addr.Dump (s, exe_scope, Address::DumpStyleResolvedPointerDescription);
|
|
|
|
}
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatHexFloat:
|
|
|
|
if (sizeof(float) == item_byte_size)
|
|
|
|
{
|
|
|
|
char float_cstr[256];
|
|
|
|
llvm::APFloat ap_float (GetFloat (&offset));
|
|
|
|
ap_float.convertToHexString (float_cstr, 0, false, llvm::APFloat::rmNearestTiesToEven);
|
|
|
|
s->Printf ("%s", float_cstr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (sizeof(double) == item_byte_size)
|
|
|
|
{
|
|
|
|
char float_cstr[256];
|
|
|
|
llvm::APFloat ap_float (GetDouble (&offset));
|
|
|
|
ap_float.convertToHexString (float_cstr, 0, false, llvm::APFloat::rmNearestTiesToEven);
|
|
|
|
s->Printf ("%s", float_cstr);
|
|
|
|
break;
|
|
|
|
}
|
2012-02-17 07:09:08 +08:00
|
|
|
else
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("error: unsupported byte size (%zu) for hex float format", item_byte_size);
|
2012-02-28 07:00:14 +08:00
|
|
|
return offset;
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-07-13 06:56:10 +08:00
|
|
|
// please keep the single-item formats below in sync with FormatManager::GetSingleItemFormat
|
|
|
|
// if you fail to do so, users will start getting different outputs depending on internal
|
|
|
|
// implementation details they should not care about ||
|
|
|
|
case eFormatVectorOfChar: // ||
|
|
|
|
s->PutChar('{'); // \/
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatCharArray, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfSInt8:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatDecimal, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfUInt8:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatHex, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfSInt16:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatDecimal, sizeof(uint16_t), item_byte_size / sizeof(uint16_t), item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfUInt16:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatHex, sizeof(uint16_t), item_byte_size / sizeof(uint16_t), item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfSInt32:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatDecimal, sizeof(uint32_t), item_byte_size / sizeof(uint32_t), item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfUInt32:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatHex, sizeof(uint32_t), item_byte_size / sizeof(uint32_t), item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfSInt64:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatDecimal, sizeof(uint64_t), item_byte_size / sizeof(uint64_t), item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfUInt64:
|
|
|
|
s->PutChar('{');
|
2013-03-27 05:13:57 +08:00
|
|
|
offset = Dump (s, offset, eFormatHex, sizeof(uint64_t), item_byte_size / sizeof(uint64_t), item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfFloat32:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatFloat, 4, item_byte_size / 4, item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfFloat64:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatFloat, 8, item_byte_size / 8, item_byte_size / 8, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFormatVectorOfUInt128:
|
|
|
|
s->PutChar('{');
|
2012-02-17 06:06:47 +08:00
|
|
|
offset = Dump (s, offset, eFormatHex, 16, item_byte_size / 16, item_byte_size / 16, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutChar('}');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
|
|
|
|
Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return offset; // Return the offset at which we ended up
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Dumps bytes from this object's data to the stream "s" starting
|
|
|
|
// "start_offset" bytes into this data, and ending with the byte
|
|
|
|
// before "end_offset". "base_addr" will be added to the offset
|
|
|
|
// into the dumped data when showing the offset into the data in the
|
|
|
|
// output information. "num_per_line" objects of type "type" will
|
|
|
|
// be dumped with the option to override the format for each object
|
|
|
|
// with "type_format". "type_format" is a printf style formatting
|
|
|
|
// string. If "type_format" is NULL, then an appropriate format
|
|
|
|
// string will be used for the supplied "type". If the stream "s"
|
|
|
|
// is NULL, then the output will be send to Log().
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t
|
2010-06-09 00:52:24 +08:00
|
|
|
DataExtractor::PutToLog
|
|
|
|
(
|
|
|
|
Log *log,
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t start_offset,
|
|
|
|
offset_t length,
|
2010-06-09 00:52:24 +08:00
|
|
|
uint64_t base_addr,
|
|
|
|
uint32_t num_per_line,
|
|
|
|
DataExtractor::Type type,
|
|
|
|
const char *format
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
if (log == NULL)
|
|
|
|
return start_offset;
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
offset_t offset;
|
|
|
|
offset_t end_offset;
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t count;
|
|
|
|
StreamString sstr;
|
2010-07-10 07:04:08 +08:00
|
|
|
for (offset = start_offset, end_offset = offset + length, count = 0; ValidOffset(offset) && offset < end_offset; ++count)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if ((count % num_per_line) == 0)
|
|
|
|
{
|
|
|
|
// Print out any previous string
|
|
|
|
if (sstr.GetSize() > 0)
|
|
|
|
{
|
|
|
|
log->Printf("%s", sstr.GetData());
|
|
|
|
sstr.Clear();
|
|
|
|
}
|
|
|
|
// Reset string offset and fill the current line string with address:
|
|
|
|
if (base_addr != LLDB_INVALID_ADDRESS)
|
2012-11-30 05:49:15 +08:00
|
|
|
sstr.Printf("0x%8.8" PRIx64 ":", (uint64_t)(base_addr + (offset - start_offset)));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case TypeUInt8: sstr.Printf (format ? format : " %2.2x", GetU8(&offset)); break;
|
|
|
|
case TypeChar:
|
|
|
|
{
|
|
|
|
char ch = GetU8(&offset);
|
|
|
|
sstr.Printf (format ? format : " %c", isprint(ch) ? ch : ' ');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TypeUInt16: sstr.Printf (format ? format : " %4.4x", GetU16(&offset)); break;
|
|
|
|
case TypeUInt32: sstr.Printf (format ? format : " %8.8x", GetU32(&offset)); break;
|
2012-11-30 05:49:15 +08:00
|
|
|
case TypeUInt64: sstr.Printf (format ? format : " %16.16" PRIx64, GetU64(&offset)); break;
|
|
|
|
case TypePointer: sstr.Printf (format ? format : " 0x%" PRIx64, GetAddress(&offset)); break;
|
|
|
|
case TypeULEB128: sstr.Printf (format ? format : " 0x%" PRIx64, GetULEB128(&offset)); break;
|
|
|
|
case TypeSLEB128: sstr.Printf (format ? format : " %" PRId64, GetSLEB128(&offset)); break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sstr.GetSize() > 0)
|
|
|
|
log->Printf("%s", sstr.GetData());
|
|
|
|
|
|
|
|
return offset; // Return the offset at which we ended up
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// DumpUUID
|
|
|
|
//
|
|
|
|
// Dump out a UUID starting at 'offset' bytes into the buffer
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::DumpUUID (Stream *s, offset_t offset) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
const uint8_t *uuid_data = PeekData(offset, 16);
|
|
|
|
if ( uuid_data )
|
|
|
|
{
|
2011-02-05 02:53:10 +08:00
|
|
|
lldb_private::UUID uuid(uuid_data, 16);
|
2010-06-09 00:52:24 +08:00
|
|
|
uuid.Dump(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
s->Printf("<not enough data for UUID at offset 0x%8.8" PRIx64 ">", offset);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-16 11:19:08 +08:00
|
|
|
void
|
|
|
|
DataExtractor::DumpHexBytes (Stream *s,
|
|
|
|
const void *src,
|
|
|
|
size_t src_len,
|
2011-07-18 04:36:25 +08:00
|
|
|
uint32_t bytes_per_line,
|
2011-07-16 11:19:08 +08:00
|
|
|
addr_t base_addr)
|
|
|
|
{
|
|
|
|
DataExtractor data (src, src_len, eByteOrderLittle, 4);
|
|
|
|
data.Dump (s,
|
|
|
|
0, // Offset into "src"
|
|
|
|
eFormatBytes, // Dump as hex bytes
|
|
|
|
1, // Size of each item is 1 for single bytes
|
|
|
|
src_len, // Number of bytes
|
2011-07-18 04:36:25 +08:00
|
|
|
bytes_per_line, // Num bytes per line
|
2011-07-16 11:19:08 +08:00
|
|
|
base_addr, // Base address
|
|
|
|
0, 0); // Bitfield info
|
|
|
|
}
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
|
|
|
|
size_t
|
|
|
|
DataExtractor::Copy (DataExtractor &dest_data) const
|
|
|
|
{
|
|
|
|
if (m_data_sp.get())
|
|
|
|
{
|
|
|
|
// we can pass along the SP to the data
|
|
|
|
dest_data.SetData(m_data_sp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const uint8_t *base_ptr = m_start;
|
|
|
|
size_t data_size = GetByteSize();
|
|
|
|
dest_data.SetData(DataBufferSP(new DataBufferHeap(base_ptr, data_size)));
|
|
|
|
}
|
|
|
|
return GetByteSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DataExtractor::Append(DataExtractor& rhs)
|
|
|
|
{
|
|
|
|
if (rhs.GetByteOrder() != GetByteOrder())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (rhs.GetByteSize() == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (GetByteSize() == 0)
|
|
|
|
return (rhs.Copy(*this) > 0);
|
|
|
|
|
|
|
|
size_t bytes = GetByteSize() + rhs.GetByteSize();
|
|
|
|
|
|
|
|
DataBufferHeap *buffer_heap_ptr = NULL;
|
|
|
|
DataBufferSP buffer_sp(buffer_heap_ptr = new DataBufferHeap(bytes, 0));
|
|
|
|
|
|
|
|
if (buffer_sp.get() == NULL || buffer_heap_ptr == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uint8_t* bytes_ptr = buffer_heap_ptr->GetBytes();
|
|
|
|
|
|
|
|
memcpy(bytes_ptr, GetDataStart(), GetByteSize());
|
|
|
|
memcpy(bytes_ptr + GetByteSize(), rhs.GetDataStart(), rhs.GetByteSize());
|
|
|
|
|
|
|
|
SetData(buffer_sp);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-26 02:06:21 +08:00
|
|
|
DataExtractor::Append(void* buf, offset_t length)
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
size_t bytes = GetByteSize() + length;
|
|
|
|
|
|
|
|
DataBufferHeap *buffer_heap_ptr = NULL;
|
|
|
|
DataBufferSP buffer_sp(buffer_heap_ptr = new DataBufferHeap(bytes, 0));
|
|
|
|
|
|
|
|
if (buffer_sp.get() == NULL || buffer_heap_ptr == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uint8_t* bytes_ptr = buffer_heap_ptr->GetBytes();
|
|
|
|
|
|
|
|
if (GetByteSize() > 0)
|
|
|
|
memcpy(bytes_ptr, GetDataStart(), GetByteSize());
|
|
|
|
|
|
|
|
memcpy(bytes_ptr + GetByteSize(), buf, length);
|
|
|
|
|
|
|
|
SetData(buffer_sp);
|
|
|
|
|
|
|
|
return true;
|
2011-10-12 08:53:29 +08:00
|
|
|
}
|