Index: lldb/trunk/include/lldb/Core/RegisterValue.h =================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h +++ lldb/trunk/include/lldb/Core/RegisterValue.h @@ -1,279 +0,0 @@ -//===-- RegisterValue.h -----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_RegisterValue_h -#define lldb_RegisterValue_h - -#include "lldb/Core/Scalar.h" -#include "lldb/Utility/Endian.h" -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for ByteOrder, Format -#include "lldb/lldb-types.h" // for offset_t - -#include "llvm/ADT/APInt.h" -#include "llvm/ADT/StringRef.h" // for StringRef - -#include // for uint32_t, uint8_t, uint64_t, uin... -#include - -namespace lldb_private { -class DataExtractor; -} -namespace lldb_private { -class Stream; -} -namespace lldb_private { -struct RegisterInfo; -} -namespace lldb_private { - -class RegisterValue { -public: - enum { kMaxRegisterByteSize = 64u }; - - enum Type { - eTypeInvalid, - eTypeUInt8, - eTypeUInt16, - eTypeUInt32, - eTypeUInt64, - eTypeUInt128, - eTypeFloat, - eTypeDouble, - eTypeLongDouble, - eTypeBytes - }; - - RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {} - - explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; } - - explicit RegisterValue(uint16_t inst) : m_type(eTypeUInt16) { - m_scalar = inst; - } - - explicit RegisterValue(uint32_t inst) : m_type(eTypeUInt32) { - m_scalar = inst; - } - - explicit RegisterValue(uint64_t inst) : m_type(eTypeUInt64) { - m_scalar = inst; - } - - explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) { - m_scalar = llvm::APInt(inst); - } - - explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; } - - explicit RegisterValue(double value) : m_type(eTypeDouble) { - m_scalar = value; - } - - explicit RegisterValue(long double value) : m_type(eTypeLongDouble) { - m_scalar = value; - } - - explicit RegisterValue(uint8_t *bytes, size_t length, - lldb::ByteOrder byte_order) { - SetBytes(bytes, length, byte_order); - } - - RegisterValue::Type GetType() const { return m_type; } - - bool CopyValue(const RegisterValue &rhs); - - void SetType(RegisterValue::Type type) { m_type = type; } - - RegisterValue::Type SetType(const RegisterInfo *reg_info); - - bool GetData(DataExtractor &data) const; - - // Copy the register value from this object into a buffer in "dst" and obey - // the "dst_byte_order" when copying the data. Also watch out in case - // "dst_len" is longer or shorter than the register value described by - // "reg_info" and only copy the least significant bytes of the register - // value, or pad the destination with zeroes if the register byte size is - // shorter that "dst_len" (all while correctly abiding the "dst_byte_order"). - // Returns the number of bytes copied into "dst". - uint32_t GetAsMemoryData(const RegisterInfo *reg_info, void *dst, - uint32_t dst_len, lldb::ByteOrder dst_byte_order, - Status &error) const; - - uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src, - uint32_t src_len, lldb::ByteOrder src_byte_order, - Status &error); - - bool GetScalarValue(Scalar &scalar) const; - - uint8_t GetAsUInt8(uint8_t fail_value = UINT8_MAX, - bool *success_ptr = nullptr) const { - if (m_type == eTypeUInt8) { - if (success_ptr) - *success_ptr = true; - return m_scalar.UChar(fail_value); - } - if (success_ptr) - *success_ptr = true; - return fail_value; - } - - uint16_t GetAsUInt16(uint16_t fail_value = UINT16_MAX, - bool *success_ptr = nullptr) const; - - uint32_t GetAsUInt32(uint32_t fail_value = UINT32_MAX, - bool *success_ptr = nullptr) const; - - uint64_t GetAsUInt64(uint64_t fail_value = UINT64_MAX, - bool *success_ptr = nullptr) const; - - llvm::APInt GetAsUInt128(const llvm::APInt &fail_value, - bool *success_ptr = nullptr) const; - - float GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const; - - double GetAsDouble(double fail_value = 0.0, - bool *success_ptr = nullptr) const; - - long double GetAsLongDouble(long double fail_value = 0.0, - bool *success_ptr = nullptr) const; - - void SetValueToInvalid() { m_type = eTypeInvalid; } - - bool ClearBit(uint32_t bit); - - bool SetBit(uint32_t bit); - - bool operator==(const RegisterValue &rhs) const; - - bool operator!=(const RegisterValue &rhs) const; - - void operator=(uint8_t uint) { - m_type = eTypeUInt8; - m_scalar = uint; - } - - void operator=(uint16_t uint) { - m_type = eTypeUInt16; - m_scalar = uint; - } - - void operator=(uint32_t uint) { - m_type = eTypeUInt32; - m_scalar = uint; - } - - void operator=(uint64_t uint) { - m_type = eTypeUInt64; - m_scalar = uint; - } - - void operator=(llvm::APInt uint) { - m_type = eTypeUInt128; - m_scalar = llvm::APInt(uint); - } - - void operator=(float f) { - m_type = eTypeFloat; - m_scalar = f; - } - - void operator=(double f) { - m_type = eTypeDouble; - m_scalar = f; - } - - void operator=(long double f) { - m_type = eTypeLongDouble; - m_scalar = f; - } - - void SetUInt8(uint8_t uint) { - m_type = eTypeUInt8; - m_scalar = uint; - } - - void SetUInt16(uint16_t uint) { - m_type = eTypeUInt16; - m_scalar = uint; - } - - void SetUInt32(uint32_t uint, Type t = eTypeUInt32) { - m_type = t; - m_scalar = uint; - } - - void SetUInt64(uint64_t uint, Type t = eTypeUInt64) { - m_type = t; - m_scalar = uint; - } - - void SetUInt128(llvm::APInt uint) { - m_type = eTypeUInt128; - m_scalar = uint; - } - - bool SetUInt(uint64_t uint, uint32_t byte_size); - - void SetFloat(float f) { - m_type = eTypeFloat; - m_scalar = f; - } - - void SetDouble(double f) { - m_type = eTypeDouble; - m_scalar = f; - } - - void SetLongDouble(long double f) { - m_type = eTypeLongDouble; - m_scalar = f; - } - - void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order); - - bool SignExtend(uint32_t sign_bitpos); - - Status SetValueFromString(const RegisterInfo *reg_info, - llvm::StringRef value_str); - Status SetValueFromString(const RegisterInfo *reg_info, - const char *value_str) = delete; - - Status SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data, - lldb::offset_t offset, bool partial_data_ok); - - const void *GetBytes() const; - - lldb::ByteOrder GetByteOrder() const { - if (m_type == eTypeBytes) - return buffer.byte_order; - return endian::InlHostByteOrder(); - } - - uint32_t GetByteSize() const; - - static uint32_t GetMaxByteSize() { return kMaxRegisterByteSize; } - - void Clear(); - -protected: - RegisterValue::Type m_type; - Scalar m_scalar; - - struct { - uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any - // register for any supported target. - uint8_t length; - lldb::ByteOrder byte_order; - } buffer; -}; - -} // namespace lldb_private - -#endif // lldb_RegisterValue_h Index: lldb/trunk/include/lldb/Core/Scalar.h =================================================================== --- lldb/trunk/include/lldb/Core/Scalar.h +++ lldb/trunk/include/lldb/Core/Scalar.h @@ -1,378 +0,0 @@ -//===-- Scalar.h ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_Scalar_h_ -#define liblldb_Scalar_h_ - -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for Encoding, ByteOrder -#include "lldb/lldb-private-types.h" // for type128 - -#include "llvm/ADT/APFloat.h" -#include "llvm/ADT/APInt.h" - -#include // for size_t -#include // for uint32_t, uint64_t, int64_t - -namespace lldb_private { -class DataExtractor; -} -namespace lldb_private { -class Stream; -} - -#define NUM_OF_WORDS_INT128 2 -#define BITWIDTH_INT128 128 -#define NUM_OF_WORDS_INT256 4 -#define BITWIDTH_INT256 256 - -namespace lldb_private { - -//---------------------------------------------------------------------- -// A class designed to hold onto values and their corresponding types. -// Operators are defined and Scalar objects will correctly promote their types -// and values before performing these operations. Type promotion currently -// follows the ANSI C type promotion rules. -//---------------------------------------------------------------------- -class Scalar { -public: - enum Type { - e_void = 0, - e_sint, - e_uint, - e_slong, - e_ulong, - e_slonglong, - e_ulonglong, - e_sint128, - e_uint128, - e_sint256, - e_uint256, - e_float, - e_double, - e_long_double - }; - - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - Scalar(); - Scalar(int v) : m_type(e_sint), m_float((float)0) { - m_integer = llvm::APInt(sizeof(int) * 8, v, true); - } - Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { - m_integer = llvm::APInt(sizeof(int) * 8, v); - } - Scalar(long v) : m_type(e_slong), m_float((float)0) { - m_integer = llvm::APInt(sizeof(long) * 8, v, true); - } - Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { - m_integer = llvm::APInt(sizeof(long) * 8, v); - } - Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { - m_integer = llvm::APInt(sizeof(long long) * 8, v, true); - } - Scalar(unsigned long long v) : m_type(e_ulonglong), m_float((float)0) { - m_integer = llvm::APInt(sizeof(long long) * 8, v); - } - Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); } - Scalar(double v) : m_type(e_double), m_float(v) { - m_float = llvm::APFloat(v); - } - Scalar(long double v, bool ieee_quad) - : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) { - if (ieee_quad) - m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((type128 *)&v)->x)); - else - m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((type128 *)&v)->x)); - } - Scalar(llvm::APInt v) : m_type(), m_float((float)0) { - m_integer = llvm::APInt(v); - switch (m_integer.getBitWidth()) { - case 8: - case 16: - case 32: - if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) - m_type = e_sint; - else - m_type = e_uint; - break; - case 64: - if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) - m_type = e_slonglong; - else - m_type = e_ulonglong; - break; - case 128: - if (m_integer.isSignedIntN(BITWIDTH_INT128)) - m_type = e_sint128; - else - m_type = e_uint128; - break; - case 256: - if (m_integer.isSignedIntN(BITWIDTH_INT256)) - m_type = e_sint256; - else - m_type = e_uint256; - break; - } - } - Scalar(const Scalar &rhs); - // Scalar(const RegisterValue& reg_value); - virtual ~Scalar(); - - bool SignExtend(uint32_t bit_pos); - - bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset); - - bool SetBit(uint32_t bit); - - bool ClearBit(uint32_t bit); - - const void *GetBytes() const; - - size_t GetByteSize() const; - - bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; - - size_t GetAsMemoryData(void *dst, size_t dst_len, - lldb::ByteOrder dst_byte_order, Status &error) const; - - bool IsZero() const; - - void Clear() { - m_type = e_void; - m_integer.clearAllBits(); - } - - const char *GetTypeAsCString() const; - - void GetValue(Stream *s, bool show_type) const; - - bool IsValid() const { - return (m_type >= e_sint) && (m_type <= e_long_double); - } - - bool Promote(Scalar::Type type); - - bool MakeSigned(); - - bool MakeUnsigned(); - - static const char *GetValueTypeAsCString(Scalar::Type value_type); - - static Scalar::Type - GetValueTypeForSignedIntegerWithByteSize(size_t byte_size); - - static Scalar::Type - GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size); - - static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size); - - //---------------------------------------------------------------------- - // All operators can benefits from the implicit conversions that will happen - // automagically by the compiler, so no temporary objects will need to be - // created. As a result, we currently don't need a variety of overloaded set - // value accessors. - //---------------------------------------------------------------------- - Scalar &operator=(const int i); - Scalar &operator=(unsigned int v); - Scalar &operator=(long v); - Scalar &operator=(unsigned long v); - Scalar &operator=(long long v); - Scalar &operator=(unsigned long long v); - Scalar &operator=(float v); - Scalar &operator=(double v); - Scalar &operator=(long double v); - Scalar &operator=(llvm::APInt v); - Scalar &operator=(const Scalar &rhs); // Assignment operator - Scalar &operator+=(const Scalar &rhs); - Scalar &operator<<=(const Scalar &rhs); // Shift left - Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic) - Scalar &operator&=(const Scalar &rhs); - - //---------------------------------------------------------------------- - // Shifts the current value to the right without maintaining the current sign - // of the value (if it is signed). - //---------------------------------------------------------------------- - bool ShiftRightLogical(const Scalar &rhs); // Returns true on success - - //---------------------------------------------------------------------- - // Takes the absolute value of the current value if it is signed, else the - // value remains unchanged. Returns false if the contained value has a void - // type. - //---------------------------------------------------------------------- - bool AbsoluteValue(); // Returns true on success - //---------------------------------------------------------------------- - // Negates the current value (even for unsigned values). Returns false if the - // contained value has a void type. - //---------------------------------------------------------------------- - bool UnaryNegate(); // Returns true on success - //---------------------------------------------------------------------- - // Inverts all bits in the current value as long as it isn't void or a - // float/double/long double type. Returns false if the contained value has a - // void/float/double/long double type, else the value is inverted and true is - // returned. - //---------------------------------------------------------------------- - bool OnesComplement(); // Returns true on success - - //---------------------------------------------------------------------- - // Access the type of the current value. - //---------------------------------------------------------------------- - Scalar::Type GetType() const { return m_type; } - - //---------------------------------------------------------------------- - // Returns a casted value of the current contained data without modifying the - // current value. FAIL_VALUE will be returned if the type of the value is - // void or invalid. - //---------------------------------------------------------------------- - int SInt(int fail_value = 0) const; - - unsigned char UChar(unsigned char fail_value = 0) const; - - signed char SChar(char fail_value = 0) const; - - unsigned short UShort(unsigned short fail_value = 0) const; - - short SShort(short fail_value = 0) const; - - unsigned int UInt(unsigned int fail_value = 0) const; - - long SLong(long fail_value = 0) const; - - unsigned long ULong(unsigned long fail_value = 0) const; - - long long SLongLong(long long fail_value = 0) const; - - unsigned long long ULongLong(unsigned long long fail_value = 0) const; - - llvm::APInt SInt128(llvm::APInt &fail_value) const; - - llvm::APInt UInt128(const llvm::APInt &fail_value) const; - - llvm::APInt SInt256(llvm::APInt &fail_value) const; - - llvm::APInt UInt256(const llvm::APInt &fail_value) const; - - float Float(float fail_value = 0.0f) const; - - double Double(double fail_value = 0.0) const; - - long double LongDouble(long double fail_value = 0.0) const; - - Status SetValueFromCString(const char *s, lldb::Encoding encoding, - size_t byte_size); - - Status SetValueFromData(DataExtractor &data, lldb::Encoding encoding, - size_t byte_size); - - static bool UIntValueIsValidForSize(uint64_t uval64, size_t total_byte_size) { - if (total_byte_size > 8) - return false; - - if (total_byte_size == 8) - return true; - - const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1; - return uval64 <= max; - } - - static bool SIntValueIsValidForSize(int64_t sval64, size_t total_byte_size) { - if (total_byte_size > 8) - return false; - - if (total_byte_size == 8) - return true; - - const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1; - const int64_t min = ~(max); - return min <= sval64 && sval64 <= max; - } - -protected: - typedef char schar_t; - typedef unsigned char uchar_t; - typedef short sshort_t; - typedef unsigned short ushort_t; - typedef int sint_t; - typedef unsigned int uint_t; - typedef long slong_t; - typedef unsigned long ulong_t; - typedef long long slonglong_t; - typedef unsigned long long ulonglong_t; - typedef float float_t; - typedef double double_t; - typedef long double long_double_t; - - //------------------------------------------------------------------ - // Classes that inherit from Scalar can see and modify these - //------------------------------------------------------------------ - Scalar::Type m_type; - llvm::APInt m_integer; - llvm::APFloat m_float; - bool m_ieee_quad = false; - -private: - friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator-(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator/(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator*(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator&(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator|(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator%(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator^(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs); - friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs); - friend bool operator==(const Scalar &lhs, const Scalar &rhs); - friend bool operator!=(const Scalar &lhs, const Scalar &rhs); - friend bool operator<(const Scalar &lhs, const Scalar &rhs); - friend bool operator<=(const Scalar &lhs, const Scalar &rhs); - friend bool operator>(const Scalar &lhs, const Scalar &rhs); - friend bool operator>=(const Scalar &lhs, const Scalar &rhs); -}; - -//---------------------------------------------------------------------- -// Split out the operators into a format where the compiler will be able to -// implicitly convert numbers into Scalar objects. -// -// This allows code like: -// Scalar two(2); -// Scalar four = two * 2; -// Scalar eight = 2 * four; // This would cause an error if the -// // operator* was implemented as a -// // member function. -// SEE: -// Item 19 of "Effective C++ Second Edition" by Scott Meyers -// Differentiate among members functions, non-member functions, and -// friend functions -//---------------------------------------------------------------------- -const Scalar operator+(const Scalar &lhs, const Scalar &rhs); -const Scalar operator-(const Scalar &lhs, const Scalar &rhs); -const Scalar operator/(const Scalar &lhs, const Scalar &rhs); -const Scalar operator*(const Scalar &lhs, const Scalar &rhs); -const Scalar operator&(const Scalar &lhs, const Scalar &rhs); -const Scalar operator|(const Scalar &lhs, const Scalar &rhs); -const Scalar operator%(const Scalar &lhs, const Scalar &rhs); -const Scalar operator^(const Scalar &lhs, const Scalar &rhs); -const Scalar operator<<(const Scalar &lhs, const Scalar &rhs); -const Scalar operator>>(const Scalar &lhs, const Scalar &rhs); -bool operator==(const Scalar &lhs, const Scalar &rhs); -bool operator!=(const Scalar &lhs, const Scalar &rhs); -bool operator<(const Scalar &lhs, const Scalar &rhs); -bool operator<=(const Scalar &lhs, const Scalar &rhs); -bool operator>(const Scalar &lhs, const Scalar &rhs); -bool operator>=(const Scalar &lhs, const Scalar &rhs); - -} // namespace lldb_private - -#endif // liblldb_Scalar_h_ Index: lldb/trunk/include/lldb/Core/State.h =================================================================== --- lldb/trunk/include/lldb/Core/State.h +++ lldb/trunk/include/lldb/Core/State.h @@ -1,85 +0,0 @@ -//===-- State.h -------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_State_h_ -#define liblldb_State_h_ - -#include "llvm/Support/FormatProviders.h" - -#include "lldb/lldb-enumerations.h" // for StateType -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/raw_ostream.h" // for raw_ostream - -#include // for uint32_t - -namespace lldb_private { - -//------------------------------------------------------------------ -/// Converts a StateType to a C string. -/// -/// @param[in] state -/// The StateType object to convert. -/// -/// @return -/// A NULL terminated C string that describes \a state. The -/// returned string comes from constant string buffers and does -/// not need to be freed. -//------------------------------------------------------------------ -const char *StateAsCString(lldb::StateType state); - -//------------------------------------------------------------------ -/// Check if a state represents a state where the process or thread -/// is running. -/// -/// @param[in] state -/// The StateType enumeration value -/// -/// @return -/// \b true if the state represents a process or thread state -/// where the process or thread is running, \b false otherwise. -//------------------------------------------------------------------ -bool StateIsRunningState(lldb::StateType state); - -//------------------------------------------------------------------ -/// Check if a state represents a state where the process or thread -/// is stopped. Stopped can mean stopped when the process is still -/// around, or stopped when the process has exited or doesn't exist -/// yet. The \a must_exist argument tells us which of these cases is -/// desired. -/// -/// @param[in] state -/// The StateType enumeration value -/// -/// @param[in] must_exist -/// A boolean that indicates the thread must also be alive -/// so states like unloaded or exited won't return true. -/// -/// @return -/// \b true if the state represents a process or thread state -/// where the process or thread is stopped. If \a must_exist is -/// \b true, then the process can't be exited or unloaded, -/// otherwise exited and unloaded or other states where the -/// process no longer exists are considered to be stopped. -//------------------------------------------------------------------ -bool StateIsStoppedState(lldb::StateType state, bool must_exist); - -const char *GetPermissionsAsCString(uint32_t permissions); - -} // namespace lldb_private - -namespace llvm { -template <> struct format_provider { - static void format(const lldb::StateType &state, raw_ostream &Stream, - StringRef Style) { - Stream << lldb_private::StateAsCString(state); - } -}; -} - -#endif // liblldb_State_h_ Index: lldb/trunk/include/lldb/Core/Value.h =================================================================== --- lldb/trunk/include/lldb/Core/Value.h +++ lldb/trunk/include/lldb/Core/Value.h @@ -10,9 +10,9 @@ #ifndef liblldb_Value_h_ #define liblldb_Value_h_ -#include "lldb/Core/Scalar.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eB... #include "lldb/lldb-private-enumerations.h" // for AddressType Index: lldb/trunk/include/lldb/Core/ValueObjectRegister.h =================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectRegister.h +++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h @@ -10,14 +10,14 @@ #ifndef liblldb_ValueObjectRegister_h_ #define liblldb_ValueObjectRegister_h_ -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" // for CompilerType #include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType, ValueType::eValueTy... -#include "lldb/lldb-forward.h" // for RegisterContextSP, ValueObjectSP -#include "lldb/lldb-private-types.h" // for RegisterInfo, RegisterSet (ptr... +#include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-enumerations.h" // for ValueType, ValueType::eValueTy... +#include "lldb/lldb-forward.h" // for RegisterContextSP, ValueObjectSP +#include "lldb/lldb-private-types.h" // for RegisterInfo, RegisterSet (ptr... #include // for size_t #include // for uint32_t, uint64_t, int32_t Index: lldb/trunk/include/lldb/Expression/DWARFExpression.h =================================================================== --- lldb/trunk/include/lldb/Expression/DWARFExpression.h +++ lldb/trunk/include/lldb/Expression/DWARFExpression.h @@ -12,8 +12,8 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include Index: lldb/trunk/include/lldb/Target/StackFrame.h =================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h +++ lldb/trunk/include/lldb/Target/StackFrame.h @@ -19,11 +19,11 @@ // Project includes #include "lldb/Utility/Flags.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackID.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UserID.h" Index: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h =================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h @@ -15,9 +15,9 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" namespace lldb_private { Index: lldb/trunk/include/lldb/Utility/RegisterValue.h =================================================================== --- lldb/trunk/include/lldb/Utility/RegisterValue.h +++ lldb/trunk/include/lldb/Utility/RegisterValue.h @@ -0,0 +1,271 @@ +//===-- RegisterValue.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_REGISTERVALUE_H +#define LLDB_UTILITY_REGISTERVALUE_H + +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" // for Status +#include "lldb/lldb-enumerations.h" // for ByteOrder, Format +#include "lldb/lldb-types.h" // for offset_t +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/StringRef.h" // for StringRef +#include // for uint32_t, uint8_t, uint64_t, uin... +#include + +namespace lldb_private { +class DataExtractor; +class Stream; +struct RegisterInfo; + +class RegisterValue { +public: + enum { kMaxRegisterByteSize = 64u }; + + enum Type { + eTypeInvalid, + eTypeUInt8, + eTypeUInt16, + eTypeUInt32, + eTypeUInt64, + eTypeUInt128, + eTypeFloat, + eTypeDouble, + eTypeLongDouble, + eTypeBytes + }; + + RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {} + + explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; } + + explicit RegisterValue(uint16_t inst) : m_type(eTypeUInt16) { + m_scalar = inst; + } + + explicit RegisterValue(uint32_t inst) : m_type(eTypeUInt32) { + m_scalar = inst; + } + + explicit RegisterValue(uint64_t inst) : m_type(eTypeUInt64) { + m_scalar = inst; + } + + explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) { + m_scalar = llvm::APInt(inst); + } + + explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; } + + explicit RegisterValue(double value) : m_type(eTypeDouble) { + m_scalar = value; + } + + explicit RegisterValue(long double value) : m_type(eTypeLongDouble) { + m_scalar = value; + } + + explicit RegisterValue(uint8_t *bytes, size_t length, + lldb::ByteOrder byte_order) { + SetBytes(bytes, length, byte_order); + } + + RegisterValue::Type GetType() const { return m_type; } + + bool CopyValue(const RegisterValue &rhs); + + void SetType(RegisterValue::Type type) { m_type = type; } + + RegisterValue::Type SetType(const RegisterInfo *reg_info); + + bool GetData(DataExtractor &data) const; + + // Copy the register value from this object into a buffer in "dst" and obey + // the "dst_byte_order" when copying the data. Also watch out in case + // "dst_len" is longer or shorter than the register value described by + // "reg_info" and only copy the least significant bytes of the register + // value, or pad the destination with zeroes if the register byte size is + // shorter that "dst_len" (all while correctly abiding the "dst_byte_order"). + // Returns the number of bytes copied into "dst". + uint32_t GetAsMemoryData(const RegisterInfo *reg_info, void *dst, + uint32_t dst_len, lldb::ByteOrder dst_byte_order, + Status &error) const; + + uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src, + uint32_t src_len, lldb::ByteOrder src_byte_order, + Status &error); + + bool GetScalarValue(Scalar &scalar) const; + + uint8_t GetAsUInt8(uint8_t fail_value = UINT8_MAX, + bool *success_ptr = nullptr) const { + if (m_type == eTypeUInt8) { + if (success_ptr) + *success_ptr = true; + return m_scalar.UChar(fail_value); + } + if (success_ptr) + *success_ptr = true; + return fail_value; + } + + uint16_t GetAsUInt16(uint16_t fail_value = UINT16_MAX, + bool *success_ptr = nullptr) const; + + uint32_t GetAsUInt32(uint32_t fail_value = UINT32_MAX, + bool *success_ptr = nullptr) const; + + uint64_t GetAsUInt64(uint64_t fail_value = UINT64_MAX, + bool *success_ptr = nullptr) const; + + llvm::APInt GetAsUInt128(const llvm::APInt &fail_value, + bool *success_ptr = nullptr) const; + + float GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const; + + double GetAsDouble(double fail_value = 0.0, + bool *success_ptr = nullptr) const; + + long double GetAsLongDouble(long double fail_value = 0.0, + bool *success_ptr = nullptr) const; + + void SetValueToInvalid() { m_type = eTypeInvalid; } + + bool ClearBit(uint32_t bit); + + bool SetBit(uint32_t bit); + + bool operator==(const RegisterValue &rhs) const; + + bool operator!=(const RegisterValue &rhs) const; + + void operator=(uint8_t uint) { + m_type = eTypeUInt8; + m_scalar = uint; + } + + void operator=(uint16_t uint) { + m_type = eTypeUInt16; + m_scalar = uint; + } + + void operator=(uint32_t uint) { + m_type = eTypeUInt32; + m_scalar = uint; + } + + void operator=(uint64_t uint) { + m_type = eTypeUInt64; + m_scalar = uint; + } + + void operator=(llvm::APInt uint) { + m_type = eTypeUInt128; + m_scalar = llvm::APInt(uint); + } + + void operator=(float f) { + m_type = eTypeFloat; + m_scalar = f; + } + + void operator=(double f) { + m_type = eTypeDouble; + m_scalar = f; + } + + void operator=(long double f) { + m_type = eTypeLongDouble; + m_scalar = f; + } + + void SetUInt8(uint8_t uint) { + m_type = eTypeUInt8; + m_scalar = uint; + } + + void SetUInt16(uint16_t uint) { + m_type = eTypeUInt16; + m_scalar = uint; + } + + void SetUInt32(uint32_t uint, Type t = eTypeUInt32) { + m_type = t; + m_scalar = uint; + } + + void SetUInt64(uint64_t uint, Type t = eTypeUInt64) { + m_type = t; + m_scalar = uint; + } + + void SetUInt128(llvm::APInt uint) { + m_type = eTypeUInt128; + m_scalar = uint; + } + + bool SetUInt(uint64_t uint, uint32_t byte_size); + + void SetFloat(float f) { + m_type = eTypeFloat; + m_scalar = f; + } + + void SetDouble(double f) { + m_type = eTypeDouble; + m_scalar = f; + } + + void SetLongDouble(long double f) { + m_type = eTypeLongDouble; + m_scalar = f; + } + + void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order); + + bool SignExtend(uint32_t sign_bitpos); + + Status SetValueFromString(const RegisterInfo *reg_info, + llvm::StringRef value_str); + Status SetValueFromString(const RegisterInfo *reg_info, + const char *value_str) = delete; + + Status SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data, + lldb::offset_t offset, bool partial_data_ok); + + const void *GetBytes() const; + + lldb::ByteOrder GetByteOrder() const { + if (m_type == eTypeBytes) + return buffer.byte_order; + return endian::InlHostByteOrder(); + } + + uint32_t GetByteSize() const; + + static uint32_t GetMaxByteSize() { return kMaxRegisterByteSize; } + + void Clear(); + +protected: + RegisterValue::Type m_type; + Scalar m_scalar; + + struct { + uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any + // register for any supported target. + uint8_t length; + lldb::ByteOrder byte_order; + } buffer; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_REGISTERVALUE_H Index: lldb/trunk/include/lldb/Utility/Scalar.h =================================================================== --- lldb/trunk/include/lldb/Utility/Scalar.h +++ lldb/trunk/include/lldb/Utility/Scalar.h @@ -0,0 +1,374 @@ +//===-- Scalar.h ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_SCALAR_H +#define LLDB_UTILITY_SCALAR_H + +#include "lldb/Utility/Status.h" // for Status +#include "lldb/lldb-enumerations.h" // for Encoding, ByteOrder +#include "lldb/lldb-private-types.h" // for type128 +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include // for size_t +#include // for uint32_t, uint64_t, int64_t + +namespace lldb_private { +class DataExtractor; +class Stream; +} // namespace lldb_private + +#define NUM_OF_WORDS_INT128 2 +#define BITWIDTH_INT128 128 +#define NUM_OF_WORDS_INT256 4 +#define BITWIDTH_INT256 256 + +namespace lldb_private { + +//---------------------------------------------------------------------- +// A class designed to hold onto values and their corresponding types. +// Operators are defined and Scalar objects will correctly promote their types +// and values before performing these operations. Type promotion currently +// follows the ANSI C type promotion rules. +//---------------------------------------------------------------------- +class Scalar { +public: + enum Type { + e_void = 0, + e_sint, + e_uint, + e_slong, + e_ulong, + e_slonglong, + e_ulonglong, + e_sint128, + e_uint128, + e_sint256, + e_uint256, + e_float, + e_double, + e_long_double + }; + + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + Scalar(); + Scalar(int v) : m_type(e_sint), m_float((float)0) { + m_integer = llvm::APInt(sizeof(int) * 8, v, true); + } + Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { + m_integer = llvm::APInt(sizeof(int) * 8, v); + } + Scalar(long v) : m_type(e_slong), m_float((float)0) { + m_integer = llvm::APInt(sizeof(long) * 8, v, true); + } + Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { + m_integer = llvm::APInt(sizeof(long) * 8, v); + } + Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { + m_integer = llvm::APInt(sizeof(long long) * 8, v, true); + } + Scalar(unsigned long long v) : m_type(e_ulonglong), m_float((float)0) { + m_integer = llvm::APInt(sizeof(long long) * 8, v); + } + Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); } + Scalar(double v) : m_type(e_double), m_float(v) { + m_float = llvm::APFloat(v); + } + Scalar(long double v, bool ieee_quad) + : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) { + if (ieee_quad) + m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + ((type128 *)&v)->x)); + else + m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + ((type128 *)&v)->x)); + } + Scalar(llvm::APInt v) : m_type(), m_float((float)0) { + m_integer = llvm::APInt(v); + switch (m_integer.getBitWidth()) { + case 8: + case 16: + case 32: + if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) + m_type = e_sint; + else + m_type = e_uint; + break; + case 64: + if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) + m_type = e_slonglong; + else + m_type = e_ulonglong; + break; + case 128: + if (m_integer.isSignedIntN(BITWIDTH_INT128)) + m_type = e_sint128; + else + m_type = e_uint128; + break; + case 256: + if (m_integer.isSignedIntN(BITWIDTH_INT256)) + m_type = e_sint256; + else + m_type = e_uint256; + break; + } + } + Scalar(const Scalar &rhs); + // Scalar(const RegisterValue& reg_value); + virtual ~Scalar(); + + bool SignExtend(uint32_t bit_pos); + + bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset); + + bool SetBit(uint32_t bit); + + bool ClearBit(uint32_t bit); + + const void *GetBytes() const; + + size_t GetByteSize() const; + + bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; + + size_t GetAsMemoryData(void *dst, size_t dst_len, + lldb::ByteOrder dst_byte_order, Status &error) const; + + bool IsZero() const; + + void Clear() { + m_type = e_void; + m_integer.clearAllBits(); + } + + const char *GetTypeAsCString() const; + + void GetValue(Stream *s, bool show_type) const; + + bool IsValid() const { + return (m_type >= e_sint) && (m_type <= e_long_double); + } + + bool Promote(Scalar::Type type); + + bool MakeSigned(); + + bool MakeUnsigned(); + + static const char *GetValueTypeAsCString(Scalar::Type value_type); + + static Scalar::Type + GetValueTypeForSignedIntegerWithByteSize(size_t byte_size); + + static Scalar::Type + GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size); + + static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size); + + //---------------------------------------------------------------------- + // All operators can benefits from the implicit conversions that will happen + // automagically by the compiler, so no temporary objects will need to be + // created. As a result, we currently don't need a variety of overloaded set + // value accessors. + //---------------------------------------------------------------------- + Scalar &operator=(const int i); + Scalar &operator=(unsigned int v); + Scalar &operator=(long v); + Scalar &operator=(unsigned long v); + Scalar &operator=(long long v); + Scalar &operator=(unsigned long long v); + Scalar &operator=(float v); + Scalar &operator=(double v); + Scalar &operator=(long double v); + Scalar &operator=(llvm::APInt v); + Scalar &operator=(const Scalar &rhs); // Assignment operator + Scalar &operator+=(const Scalar &rhs); + Scalar &operator<<=(const Scalar &rhs); // Shift left + Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic) + Scalar &operator&=(const Scalar &rhs); + + //---------------------------------------------------------------------- + // Shifts the current value to the right without maintaining the current sign + // of the value (if it is signed). + //---------------------------------------------------------------------- + bool ShiftRightLogical(const Scalar &rhs); // Returns true on success + + //---------------------------------------------------------------------- + // Takes the absolute value of the current value if it is signed, else the + // value remains unchanged. Returns false if the contained value has a void + // type. + //---------------------------------------------------------------------- + bool AbsoluteValue(); // Returns true on success + //---------------------------------------------------------------------- + // Negates the current value (even for unsigned values). Returns false if the + // contained value has a void type. + //---------------------------------------------------------------------- + bool UnaryNegate(); // Returns true on success + //---------------------------------------------------------------------- + // Inverts all bits in the current value as long as it isn't void or a + // float/double/long double type. Returns false if the contained value has a + // void/float/double/long double type, else the value is inverted and true is + // returned. + //---------------------------------------------------------------------- + bool OnesComplement(); // Returns true on success + + //---------------------------------------------------------------------- + // Access the type of the current value. + //---------------------------------------------------------------------- + Scalar::Type GetType() const { return m_type; } + + //---------------------------------------------------------------------- + // Returns a casted value of the current contained data without modifying the + // current value. FAIL_VALUE will be returned if the type of the value is + // void or invalid. + //---------------------------------------------------------------------- + int SInt(int fail_value = 0) const; + + unsigned char UChar(unsigned char fail_value = 0) const; + + signed char SChar(char fail_value = 0) const; + + unsigned short UShort(unsigned short fail_value = 0) const; + + short SShort(short fail_value = 0) const; + + unsigned int UInt(unsigned int fail_value = 0) const; + + long SLong(long fail_value = 0) const; + + unsigned long ULong(unsigned long fail_value = 0) const; + + long long SLongLong(long long fail_value = 0) const; + + unsigned long long ULongLong(unsigned long long fail_value = 0) const; + + llvm::APInt SInt128(llvm::APInt &fail_value) const; + + llvm::APInt UInt128(const llvm::APInt &fail_value) const; + + llvm::APInt SInt256(llvm::APInt &fail_value) const; + + llvm::APInt UInt256(const llvm::APInt &fail_value) const; + + float Float(float fail_value = 0.0f) const; + + double Double(double fail_value = 0.0) const; + + long double LongDouble(long double fail_value = 0.0) const; + + Status SetValueFromCString(const char *s, lldb::Encoding encoding, + size_t byte_size); + + Status SetValueFromData(DataExtractor &data, lldb::Encoding encoding, + size_t byte_size); + + static bool UIntValueIsValidForSize(uint64_t uval64, size_t total_byte_size) { + if (total_byte_size > 8) + return false; + + if (total_byte_size == 8) + return true; + + const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1; + return uval64 <= max; + } + + static bool SIntValueIsValidForSize(int64_t sval64, size_t total_byte_size) { + if (total_byte_size > 8) + return false; + + if (total_byte_size == 8) + return true; + + const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1; + const int64_t min = ~(max); + return min <= sval64 && sval64 <= max; + } + +protected: + typedef char schar_t; + typedef unsigned char uchar_t; + typedef short sshort_t; + typedef unsigned short ushort_t; + typedef int sint_t; + typedef unsigned int uint_t; + typedef long slong_t; + typedef unsigned long ulong_t; + typedef long long slonglong_t; + typedef unsigned long long ulonglong_t; + typedef float float_t; + typedef double double_t; + typedef long double long_double_t; + + //------------------------------------------------------------------ + // Classes that inherit from Scalar can see and modify these + //------------------------------------------------------------------ + Scalar::Type m_type; + llvm::APInt m_integer; + llvm::APFloat m_float; + bool m_ieee_quad = false; + +private: + friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator-(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator/(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator*(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator&(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator|(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator%(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator^(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs); + friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs); + friend bool operator==(const Scalar &lhs, const Scalar &rhs); + friend bool operator!=(const Scalar &lhs, const Scalar &rhs); + friend bool operator<(const Scalar &lhs, const Scalar &rhs); + friend bool operator<=(const Scalar &lhs, const Scalar &rhs); + friend bool operator>(const Scalar &lhs, const Scalar &rhs); + friend bool operator>=(const Scalar &lhs, const Scalar &rhs); +}; + +//---------------------------------------------------------------------- +// Split out the operators into a format where the compiler will be able to +// implicitly convert numbers into Scalar objects. +// +// This allows code like: +// Scalar two(2); +// Scalar four = two * 2; +// Scalar eight = 2 * four; // This would cause an error if the +// // operator* was implemented as a +// // member function. +// SEE: +// Item 19 of "Effective C++ Second Edition" by Scott Meyers +// Differentiate among members functions, non-member functions, and +// friend functions +//---------------------------------------------------------------------- +const Scalar operator+(const Scalar &lhs, const Scalar &rhs); +const Scalar operator-(const Scalar &lhs, const Scalar &rhs); +const Scalar operator/(const Scalar &lhs, const Scalar &rhs); +const Scalar operator*(const Scalar &lhs, const Scalar &rhs); +const Scalar operator&(const Scalar &lhs, const Scalar &rhs); +const Scalar operator|(const Scalar &lhs, const Scalar &rhs); +const Scalar operator%(const Scalar &lhs, const Scalar &rhs); +const Scalar operator^(const Scalar &lhs, const Scalar &rhs); +const Scalar operator<<(const Scalar &lhs, const Scalar &rhs); +const Scalar operator>>(const Scalar &lhs, const Scalar &rhs); +bool operator==(const Scalar &lhs, const Scalar &rhs); +bool operator!=(const Scalar &lhs, const Scalar &rhs); +bool operator<(const Scalar &lhs, const Scalar &rhs); +bool operator<=(const Scalar &lhs, const Scalar &rhs); +bool operator>(const Scalar &lhs, const Scalar &rhs); +bool operator>=(const Scalar &lhs, const Scalar &rhs); + +} // namespace lldb_private + +#endif // LLDB_UTILITY_SCALAR_H Index: lldb/trunk/include/lldb/Utility/State.h =================================================================== --- lldb/trunk/include/lldb/Utility/State.h +++ lldb/trunk/include/lldb/Utility/State.h @@ -0,0 +1,83 @@ +//===-- State.h -------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_STATE_H +#define LLDB_UTILITY_STATE_H + +#include "lldb/lldb-enumerations.h" // for StateType +#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/Support/FormatProviders.h" +#include "llvm/Support/raw_ostream.h" // for raw_ostream +#include // for uint32_t + +namespace lldb_private { + +//------------------------------------------------------------------ +/// Converts a StateType to a C string. +/// +/// @param[in] state +/// The StateType object to convert. +/// +/// @return +/// A NULL terminated C string that describes \a state. The +/// returned string comes from constant string buffers and does +/// not need to be freed. +//------------------------------------------------------------------ +const char *StateAsCString(lldb::StateType state); + +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is running. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is running, \b false otherwise. +//------------------------------------------------------------------ +bool StateIsRunningState(lldb::StateType state); + +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is stopped. Stopped can mean stopped when the process is still +/// around, or stopped when the process has exited or doesn't exist +/// yet. The \a must_exist argument tells us which of these cases is +/// desired. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @param[in] must_exist +/// A boolean that indicates the thread must also be alive +/// so states like unloaded or exited won't return true. +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is stopped. If \a must_exist is +/// \b true, then the process can't be exited or unloaded, +/// otherwise exited and unloaded or other states where the +/// process no longer exists are considered to be stopped. +//------------------------------------------------------------------ +bool StateIsStoppedState(lldb::StateType state, bool must_exist); + +const char *GetPermissionsAsCString(uint32_t permissions); + +} // namespace lldb_private + +namespace llvm { +template <> struct format_provider { + static void format(const lldb::StateType &state, raw_ostream &Stream, + StringRef Style) { + Stream << lldb_private::StateAsCString(state); + } +}; +} // namespace llvm + +#endif // LLDB_UTILITY_STATE_H Index: lldb/trunk/source/API/SBDebugger.cpp =================================================================== --- lldb/trunk/source/API/SBDebugger.cpp +++ lldb/trunk/source/API/SBDebugger.cpp @@ -41,7 +41,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -53,6 +52,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Index: lldb/trunk/source/API/SBProcess.cpp =================================================================== --- lldb/trunk/source/API/SBProcess.cpp +++ lldb/trunk/source/API/SBProcess.cpp @@ -18,7 +18,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" @@ -28,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" // Project includes Index: lldb/trunk/source/API/SBThread.cpp =================================================================== --- lldb/trunk/source/API/SBThread.cpp +++ lldb/trunk/source/API/SBThread.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -32,6 +31,7 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" Index: lldb/trunk/source/API/SBThreadPlan.cpp =================================================================== --- lldb/trunk/source/API/SBThreadPlan.cpp +++ lldb/trunk/source/API/SBThreadPlan.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" @@ -31,6 +30,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" Index: lldb/trunk/source/API/SBValue.cpp =================================================================== --- lldb/trunk/source/API/SBValue.cpp +++ lldb/trunk/source/API/SBValue.cpp @@ -18,7 +18,6 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" @@ -38,6 +37,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" #include "lldb/API/SBDebugger.h" Index: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp @@ -18,13 +18,13 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/STLExtras.h" Index: lldb/trunk/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp @@ -17,7 +17,6 @@ #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" @@ -32,6 +31,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Commands/CommandObjectRegister.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp @@ -10,8 +10,6 @@ #include "CommandObjectRegister.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpRegisterValue.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -27,6 +25,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Errno.h" using namespace lldb; Index: lldb/trunk/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/OptionParser.h" @@ -51,6 +50,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Timer.h" #include "llvm/Support/FileSystem.h" Index: lldb/trunk/source/Commands/CommandObjectThread.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp +++ lldb/trunk/source/Commands/CommandObjectThread.cpp @@ -14,7 +14,6 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/SourceManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" #include "lldb/Host/OptionParser.h" @@ -37,6 +36,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-private.h" using namespace lldb; Index: lldb/trunk/source/Commands/CommandObjectType.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp +++ lldb/trunk/source/Commands/CommandObjectType.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -39,6 +38,7 @@ #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StringList.h" // Other libraries and framework includes Index: lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp +++ lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp @@ -18,13 +18,13 @@ #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Core/CMakeLists.txt =================================================================== --- lldb/trunk/source/Core/CMakeLists.txt +++ lldb/trunk/source/Core/CMakeLists.txt @@ -34,12 +34,9 @@ ModuleList.cpp Opcode.cpp PluginManager.cpp - RegisterValue.cpp - Scalar.cpp SearchFilter.cpp Section.cpp SourceManager.cpp - State.cpp StreamAsynchronousIO.cpp StreamFile.cpp UserSettingsController.cpp Index: lldb/trunk/source/Core/Debugger.cpp =================================================================== --- lldb/trunk/source/Core/Debugger.cpp +++ lldb/trunk/source/Core/Debugger.cpp @@ -12,11 +12,10 @@ #include "lldb/Breakpoint/Breakpoint.h" // for Breakpoint, Brea... #include "lldb/Core/Event.h" // for Event, EventData... #include "lldb/Core/FormatEntity.h" -#include "lldb/Core/Listener.h" // for Listener -#include "lldb/Core/Mangled.h" // for Mangled -#include "lldb/Core/ModuleList.h" // for Mangled +#include "lldb/Core/Listener.h" // for Listener +#include "lldb/Core/Mangled.h" // for Mangled +#include "lldb/Core/ModuleList.h" // for Mangled #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamAsynchronousIO.h" #include "lldb/Core/StreamFile.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -43,7 +42,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadList.h" // for ThreadList #include "lldb/Utility/AnsiTerminal.h" -#include "lldb/Utility/Log.h" // for LLDB_LOG_OPTION_... +#include "lldb/Utility/Log.h" // for LLDB_LOG_OPTION_... +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StreamCallback.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Core/DumpRegisterValue.cpp =================================================================== --- lldb/trunk/source/Core/DumpRegisterValue.cpp +++ lldb/trunk/source/Core/DumpRegisterValue.cpp @@ -9,8 +9,8 @@ #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" Index: lldb/trunk/source/Core/EmulateInstruction.cpp =================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp +++ lldb/trunk/source/Core/EmulateInstruction.cpp @@ -12,7 +12,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" @@ -20,6 +19,7 @@ #include "lldb/Target/StackFrame.h" // for StackFrame #include "lldb/Utility/ConstString.h" // for ConstString #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" // for Stream, Stream::::eBinary #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Core/FormatEntity.cpp =================================================================== --- lldb/trunk/source/Core/FormatEntity.cpp +++ lldb/trunk/source/Core/FormatEntity.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" // for RegisterValue #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -45,9 +44,10 @@ #include "lldb/Utility/ArchSpec.h" // for ArchSpec #include "lldb/Utility/ConstString.h" // for ConstString, oper... #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" // for Log -#include "lldb/Utility/Logging.h" // for GetLogIfAllCatego... -#include "lldb/Utility/SharingPtr.h" // for SharingPtr +#include "lldb/Utility/Log.h" // for Log +#include "lldb/Utility/Logging.h" // for GetLogIfAllCatego... +#include "lldb/Utility/RegisterValue.h" // for RegisterValue +#include "lldb/Utility/SharingPtr.h" // for SharingPtr #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" // for StringList Index: lldb/trunk/source/Core/IOHandler.cpp =================================================================== --- lldb/trunk/source/Core/IOHandler.cpp +++ lldb/trunk/source/Core/IOHandler.cpp @@ -40,7 +40,6 @@ #ifndef LLDB_DISABLE_CURSES #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/Block.h" @@ -53,6 +52,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #endif #include "llvm/ADT/StringRef.h" // for StringRef Index: lldb/trunk/source/Core/RegisterValue.cpp =================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp +++ lldb/trunk/source/Core/RegisterValue.cpp @@ -1,905 +0,0 @@ -//===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/RegisterValue.h" - -#include "lldb/Core/Scalar.h" -#include "lldb/Utility/Args.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" -#include "lldb/Utility/StreamString.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-private-types.h" // for RegisterInfo, type128 - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" - -#include // for uint8_t, uint32_t, uint64_t -#include // for string -#include // for tie, tuple -#include - -#include // for assert -#include // for PRIx64 -#include // for sscanf - -using namespace lldb; -using namespace lldb_private; - -bool RegisterValue::GetData(DataExtractor &data) const { - return data.SetData(GetBytes(), GetByteSize(), GetByteOrder()) > 0; -} - -uint32_t RegisterValue::GetAsMemoryData(const RegisterInfo *reg_info, void *dst, - uint32_t dst_len, - lldb::ByteOrder dst_byte_order, - Status &error) const { - if (reg_info == nullptr) { - error.SetErrorString("invalid register info argument."); - return 0; - } - - // ReadRegister should have already been called on this object prior to - // calling this. - if (GetType() == eTypeInvalid) { - // No value has been read into this object... - error.SetErrorStringWithFormat( - "invalid register value type for register %s", reg_info->name); - return 0; - } - - if (dst_len > kMaxRegisterByteSize) { - error.SetErrorString("destination is too big"); - return 0; - } - - const uint32_t src_len = reg_info->byte_size; - - // Extract the register data into a data extractor - DataExtractor reg_data; - if (!GetData(reg_data)) { - error.SetErrorString("invalid register value to copy into"); - return 0; - } - - // Prepare a memory buffer that contains some or all of the register value - const uint32_t bytes_copied = - reg_data.CopyByteOrderedData(0, // src offset - src_len, // src length - dst, // dst buffer - dst_len, // dst length - dst_byte_order); // dst byte order - if (bytes_copied == 0) - error.SetErrorStringWithFormat( - "failed to copy data for register write of %s", reg_info->name); - - return bytes_copied; -} - -uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo *reg_info, - const void *src, uint32_t src_len, - lldb::ByteOrder src_byte_order, - Status &error) { - if (reg_info == nullptr) { - error.SetErrorString("invalid register info argument."); - return 0; - } - - // Moving from addr into a register - // - // Case 1: src_len == dst_len - // - // |AABBCCDD| Address contents - // |AABBCCDD| Register contents - // - // Case 2: src_len > dst_len - // - // Status! (The register should always be big enough to hold the data) - // - // Case 3: src_len < dst_len - // - // |AABB| Address contents - // |AABB0000| Register contents [on little-endian hardware] - // |0000AABB| Register contents [on big-endian hardware] - if (src_len > kMaxRegisterByteSize) { - error.SetErrorStringWithFormat( - "register buffer is too small to receive %u bytes of data.", src_len); - return 0; - } - - const uint32_t dst_len = reg_info->byte_size; - - if (src_len > dst_len) { - error.SetErrorStringWithFormat( - "%u bytes is too big to store in register %s (%u bytes)", src_len, - reg_info->name, dst_len); - return 0; - } - - // Use a data extractor to correctly copy and pad the bytes read into the - // register value - DataExtractor src_data(src, src_len, src_byte_order, 4); - - error = SetValueFromData(reg_info, src_data, 0, true); - if (error.Fail()) - return 0; - - // If SetValueFromData succeeded, we must have copied all of src_len - return src_len; -} - -bool RegisterValue::GetScalarValue(Scalar &scalar) const { - switch (m_type) { - case eTypeInvalid: - break; - case eTypeBytes: { - switch (buffer.length) { - default: - break; - case 1: - scalar = *(const uint8_t *)buffer.bytes; - return true; - case 2: - scalar = *(const uint16_t *)buffer.bytes; - return true; - case 4: - scalar = *(const uint32_t *)buffer.bytes; - return true; - case 8: - scalar = *(const uint64_t *)buffer.bytes; - return true; - case 16: - case 32: - if (buffer.length % sizeof(uint64_t) == 0) { - const auto length_in_bits = buffer.length * 8; - const auto length_in_uint64 = buffer.length / sizeof(uint64_t); - scalar = - llvm::APInt(length_in_bits, - llvm::ArrayRef((const uint64_t *)buffer.bytes, - length_in_uint64)); - return true; - } - break; - } - } break; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - scalar = m_scalar; - return true; - } - return false; -} - -void RegisterValue::Clear() { m_type = eTypeInvalid; } - -RegisterValue::Type RegisterValue::SetType(const RegisterInfo *reg_info) { - // To change the type, we simply copy the data in again, using the new format - RegisterValue copy; - DataExtractor copy_data; - if (copy.CopyValue(*this) && copy.GetData(copy_data)) - SetValueFromData(reg_info, copy_data, 0, true); - - return m_type; -} - -Status RegisterValue::SetValueFromData(const RegisterInfo *reg_info, - DataExtractor &src, - lldb::offset_t src_offset, - bool partial_data_ok) { - Status error; - - if (src.GetByteSize() == 0) { - error.SetErrorString("empty data."); - return error; - } - - if (reg_info->byte_size == 0) { - error.SetErrorString("invalid register info."); - return error; - } - - uint32_t src_len = src.GetByteSize() - src_offset; - - if (!partial_data_ok && (src_len < reg_info->byte_size)) { - error.SetErrorString("not enough data."); - return error; - } - - // Cap the data length if there is more than enough bytes for this register - // value - if (src_len > reg_info->byte_size) - src_len = reg_info->byte_size; - - // Zero out the value in case we get partial data... - memset(buffer.bytes, 0, sizeof(buffer.bytes)); - - type128 int128; - - m_type = eTypeInvalid; - switch (reg_info->encoding) { - case eEncodingInvalid: - break; - case eEncodingUint: - case eEncodingSint: - if (reg_info->byte_size == 1) - SetUInt8(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 2) - SetUInt16(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 4) - SetUInt32(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 8) - SetUInt64(src.GetMaxU64(&src_offset, src_len)); - else if (reg_info->byte_size <= 16) { - uint64_t data1 = src.GetU64(&src_offset); - uint64_t data2 = src.GetU64(&src_offset); - if (src.GetByteSize() == eByteOrderBig) { - int128.x[0] = data1; - int128.x[1] = data2; - } else { - int128.x[0] = data2; - int128.x[1] = data1; - } - SetUInt128(llvm::APInt(128, 2, int128.x)); - } - break; - case eEncodingIEEE754: - if (reg_info->byte_size == sizeof(float)) - SetFloat(src.GetFloat(&src_offset)); - else if (reg_info->byte_size == sizeof(double)) - SetDouble(src.GetDouble(&src_offset)); - else if (reg_info->byte_size == sizeof(long double)) - SetLongDouble(src.GetLongDouble(&src_offset)); - break; - case eEncodingVector: { - m_type = eTypeBytes; - buffer.length = reg_info->byte_size; - buffer.byte_order = src.GetByteOrder(); - assert(buffer.length <= kMaxRegisterByteSize); - if (buffer.length > kMaxRegisterByteSize) - buffer.length = kMaxRegisterByteSize; - if (src.CopyByteOrderedData( - src_offset, // offset within "src" to start extracting data - src_len, // src length - buffer.bytes, // dst buffer - buffer.length, // dst length - buffer.byte_order) == 0) // dst byte order - { - error.SetErrorStringWithFormat( - "failed to copy data for register write of %s", reg_info->name); - return error; - } - } - } - - if (m_type == eTypeInvalid) - error.SetErrorStringWithFormat( - "invalid register value type for register %s", reg_info->name); - return error; -} - -// Helper function for RegisterValue::SetValueFromString() -static bool ParseVectorEncoding(const RegisterInfo *reg_info, - llvm::StringRef vector_str, - const uint32_t byte_size, - RegisterValue *reg_value) { - // Example: vector_str = "{0x2c 0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a - // 0x2a 0x3e 0x84 0x4f 0x2a 0x3e}". - vector_str = vector_str.trim(); - vector_str.consume_front("{"); - vector_str.consume_back("}"); - vector_str = vector_str.trim(); - - char Sep = ' '; - - // The first split should give us: - // ('0x2c', '0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a 0x2a 0x3e 0x84 0x4f - // 0x2a 0x3e'). - llvm::StringRef car; - llvm::StringRef cdr = vector_str; - std::tie(car, cdr) = vector_str.split(Sep); - std::vector bytes; - unsigned byte = 0; - - // Using radix auto-sensing by passing 0 as the radix. Keep on processing the - // vector elements as long as the parsing succeeds and the vector size is < - // byte_size. - while (!car.getAsInteger(0, byte) && bytes.size() < byte_size) { - bytes.push_back(byte); - std::tie(car, cdr) = cdr.split(Sep); - } - - // Check for vector of exact byte_size elements. - if (bytes.size() != byte_size) - return false; - - reg_value->SetBytes(&(bytes.front()), byte_size, eByteOrderLittle); - return true; -} - -Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, - llvm::StringRef value_str) { - Status error; - if (reg_info == nullptr) { - error.SetErrorString("Invalid register info argument."); - return error; - } - - m_type = eTypeInvalid; - if (value_str.empty()) { - error.SetErrorString("Invalid c-string value string."); - return error; - } - const uint32_t byte_size = reg_info->byte_size; - - uint64_t uval64; - int64_t ival64; - float flt_val; - double dbl_val; - long double ldbl_val; - switch (reg_info->encoding) { - case eEncodingInvalid: - error.SetErrorString("Invalid encoding."); - break; - - case eEncodingUint: - if (byte_size > sizeof(uint64_t)) { - error.SetErrorStringWithFormat( - "unsupported unsigned integer byte size: %u", byte_size); - break; - } - if (value_str.getAsInteger(0, uval64)) { - error.SetErrorStringWithFormat( - "'%s' is not a valid unsigned integer string value", - value_str.str().c_str()); - break; - } - - if (!Args::UInt64ValueIsValidForByteSize(uval64, byte_size)) { - error.SetErrorStringWithFormat( - "value 0x%" PRIx64 - " is too large to fit in a %u byte unsigned integer value", - uval64, byte_size); - break; - } - - if (!SetUInt(uval64, reg_info->byte_size)) { - error.SetErrorStringWithFormat( - "unsupported unsigned integer byte size: %u", byte_size); - break; - } - // TODO: Shouldn't we be setting m_type here? - break; - - case eEncodingSint: - if (byte_size > sizeof(long long)) { - error.SetErrorStringWithFormat("unsupported signed integer byte size: %u", - byte_size); - break; - } - - if (value_str.getAsInteger(0, ival64)) { - error.SetErrorStringWithFormat( - "'%s' is not a valid signed integer string value", - value_str.str().c_str()); - break; - } - - if (!Args::SInt64ValueIsValidForByteSize(ival64, byte_size)) { - error.SetErrorStringWithFormat( - "value 0x%" PRIx64 - " is too large to fit in a %u byte signed integer value", - ival64, byte_size); - break; - } - - if (!SetUInt(ival64, reg_info->byte_size)) { - error.SetErrorStringWithFormat("unsupported signed integer byte size: %u", - byte_size); - break; - } - - // TODO: Shouldn't we be setting m_type here? - break; - - case eEncodingIEEE754: { - std::string value_string = value_str; - if (byte_size == sizeof(float)) { - if (::sscanf(value_string.c_str(), "%f", &flt_val) != 1) { - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_string.c_str()); - break; - } - m_scalar = flt_val; - m_type = eTypeFloat; - } else if (byte_size == sizeof(double)) { - if (::sscanf(value_string.c_str(), "%lf", &dbl_val) != 1) { - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_string.c_str()); - break; - } - m_scalar = dbl_val; - m_type = eTypeDouble; - } else if (byte_size == sizeof(long double)) { - if (::sscanf(value_string.c_str(), "%Lf", &ldbl_val) != 1) { - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_string.c_str()); - break; - } - m_scalar = ldbl_val; - m_type = eTypeLongDouble; - } else { - error.SetErrorStringWithFormat("unsupported float byte size: %u", - byte_size); - return error; - } - break; - } - case eEncodingVector: - if (!ParseVectorEncoding(reg_info, value_str, byte_size, this)) - error.SetErrorString("unrecognized vector encoding string value."); - break; - } - - return error; -} - -bool RegisterValue::SignExtend(uint32_t sign_bitpos) { - switch (m_type) { - case eTypeInvalid: - break; - - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - return m_scalar.SignExtend(sign_bitpos); - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - case eTypeBytes: - break; - } - return false; -} - -bool RegisterValue::CopyValue(const RegisterValue &rhs) { - if (this == &rhs) - return rhs.m_type == eTypeInvalid ? false : true; - - m_type = rhs.m_type; - switch (m_type) { - case eTypeInvalid: - return false; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - m_scalar = rhs.m_scalar; - break; - case eTypeBytes: - assert(rhs.buffer.length <= kMaxRegisterByteSize); - ::memcpy(buffer.bytes, rhs.buffer.bytes, kMaxRegisterByteSize); - buffer.length = rhs.buffer.length; - buffer.byte_order = rhs.buffer.byte_order; - break; - } - return true; -} - -uint16_t RegisterValue::GetAsUInt16(uint16_t fail_value, - bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - - switch (m_type) { - default: - break; - case eTypeUInt8: - case eTypeUInt16: - return m_scalar.UShort(fail_value); - case eTypeBytes: { - switch (buffer.length) { - default: - break; - case 1: - case 2: - return *(const uint16_t *)buffer.bytes; - } - } break; - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -uint32_t RegisterValue::GetAsUInt32(uint32_t fail_value, - bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.UInt(fail_value); - case eTypeBytes: { - switch (buffer.length) { - default: - break; - case 1: - case 2: - case 4: - return *(const uint32_t *)buffer.bytes; - } - } break; - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -uint64_t RegisterValue::GetAsUInt64(uint64_t fail_value, - bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.ULongLong(fail_value); - case eTypeBytes: { - switch (buffer.length) { - default: - break; - case 1: - return *(const uint8_t *)buffer.bytes; - case 2: - return *(const uint16_t *)buffer.bytes; - case 4: - return *(const uint32_t *)buffer.bytes; - case 8: - return *(const uint64_t *)buffer.bytes; - } - } break; - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value, - bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.UInt128(fail_value); - case eTypeBytes: { - switch (buffer.length) { - default: - break; - case 1: - case 2: - case 4: - case 8: - case 16: - return llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((const type128 *)buffer.bytes)->x); - } - } break; - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.Float(fail_value); - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.Double(fail_value); - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -long double RegisterValue::GetAsLongDouble(long double fail_value, - bool *success_ptr) const { - if (success_ptr) - *success_ptr = true; - switch (m_type) { - default: - break; - - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.LongDouble(); - } - if (success_ptr) - *success_ptr = false; - return fail_value; -} - -const void *RegisterValue::GetBytes() const { - switch (m_type) { - case eTypeInvalid: - break; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.GetBytes(); - case eTypeBytes: - return buffer.bytes; - } - return nullptr; -} - -uint32_t RegisterValue::GetByteSize() const { - switch (m_type) { - case eTypeInvalid: - break; - case eTypeUInt8: - return 1; - case eTypeUInt16: - return 2; - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar.GetByteSize(); - case eTypeBytes: - return buffer.length; - } - return 0; -} - -bool RegisterValue::SetUInt(uint64_t uint, uint32_t byte_size) { - if (byte_size == 0) { - SetUInt64(uint); - } else if (byte_size == 1) { - SetUInt8(uint); - } else if (byte_size <= 2) { - SetUInt16(uint); - } else if (byte_size <= 4) { - SetUInt32(uint); - } else if (byte_size <= 8) { - SetUInt64(uint); - } else if (byte_size <= 16) { - SetUInt128(llvm::APInt(128, uint)); - } else - return false; - return true; -} - -void RegisterValue::SetBytes(const void *bytes, size_t length, - lldb::ByteOrder byte_order) { - // If this assertion fires off we need to increase the size of buffer.bytes, - // or make it something that is allocated on the heap. Since the data buffer - // is in a union, we can't make it a collection class like SmallVector... - if (bytes && length > 0) { - assert(length <= sizeof(buffer.bytes) && - "Storing too many bytes in a RegisterValue."); - m_type = eTypeBytes; - buffer.length = length; - memcpy(buffer.bytes, bytes, length); - buffer.byte_order = byte_order; - } else { - m_type = eTypeInvalid; - buffer.length = 0; - } -} - -bool RegisterValue::operator==(const RegisterValue &rhs) const { - if (m_type == rhs.m_type) { - switch (m_type) { - case eTypeInvalid: - return true; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar == rhs.m_scalar; - case eTypeBytes: - if (buffer.length != rhs.buffer.length) - return false; - else { - uint8_t length = buffer.length; - if (length > kMaxRegisterByteSize) - length = kMaxRegisterByteSize; - return memcmp(buffer.bytes, rhs.buffer.bytes, length) == 0; - } - break; - } - } - return false; -} - -bool RegisterValue::operator!=(const RegisterValue &rhs) const { - if (m_type != rhs.m_type) - return true; - switch (m_type) { - case eTypeInvalid: - return false; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar != rhs.m_scalar; - case eTypeBytes: - if (buffer.length != rhs.buffer.length) { - return true; - } else { - uint8_t length = buffer.length; - if (length > kMaxRegisterByteSize) - length = kMaxRegisterByteSize; - return memcmp(buffer.bytes, rhs.buffer.bytes, length) != 0; - } - break; - } - return true; -} - -bool RegisterValue::ClearBit(uint32_t bit) { - switch (m_type) { - case eTypeInvalid: - break; - - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - if (bit < (GetByteSize() * 8)) { - return m_scalar.ClearBit(bit); - } - break; - - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - break; - - case eTypeBytes: - if (buffer.byte_order == eByteOrderBig || - buffer.byte_order == eByteOrderLittle) { - uint32_t byte_idx; - if (buffer.byte_order == eByteOrderBig) - byte_idx = buffer.length - (bit / 8) - 1; - else - byte_idx = bit / 8; - - const uint32_t byte_bit = bit % 8; - if (byte_idx < buffer.length) { - buffer.bytes[byte_idx] &= ~(1u << byte_bit); - return true; - } - } - break; - } - return false; -} - -bool RegisterValue::SetBit(uint32_t bit) { - switch (m_type) { - case eTypeInvalid: - break; - - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - if (bit < (GetByteSize() * 8)) { - return m_scalar.SetBit(bit); - } - break; - - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - break; - - case eTypeBytes: - if (buffer.byte_order == eByteOrderBig || - buffer.byte_order == eByteOrderLittle) { - uint32_t byte_idx; - if (buffer.byte_order == eByteOrderBig) - byte_idx = buffer.length - (bit / 8) - 1; - else - byte_idx = bit / 8; - - const uint32_t byte_bit = bit % 8; - if (byte_idx < buffer.length) { - buffer.bytes[byte_idx] |= (1u << byte_bit); - return true; - } - } - break; - } - return false; -} Index: lldb/trunk/source/Core/Scalar.cpp =================================================================== --- lldb/trunk/source/Core/Scalar.cpp +++ lldb/trunk/source/Core/Scalar.cpp @@ -1,2852 +0,0 @@ -//===-- Scalar.cpp ----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/Scalar.h" - -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Endian.h" -#include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" -#include "lldb/lldb-types.h" // for offset_t - -#include "llvm/ADT/SmallString.h" - -#include -#include - -using namespace lldb; -using namespace lldb_private; - -//---------------------------------------------------------------------- -// Promote to max type currently follows the ANSI C rule for type promotion in -// expressions. -//---------------------------------------------------------------------- -static Scalar::Type PromoteToMaxType( - const Scalar &lhs, // The const left hand side object - const Scalar &rhs, // The const right hand side object - Scalar &temp_value, // A modifiable temp value than can be used to hold - // either the promoted lhs or rhs object - const Scalar *&promoted_lhs_ptr, // Pointer to the resulting possibly - // promoted value of lhs (at most one of - // lhs/rhs will get promoted) - const Scalar *&promoted_rhs_ptr // Pointer to the resulting possibly - // promoted value of rhs (at most one of - // lhs/rhs will get promoted) - ) { - Scalar result; - // Initialize the promoted values for both the right and left hand side - // values to be the objects themselves. If no promotion is needed (both right - // and left have the same type), then the temp_value will not get used. - promoted_lhs_ptr = &lhs; - promoted_rhs_ptr = &rhs; - // Extract the types of both the right and left hand side values - Scalar::Type lhs_type = lhs.GetType(); - Scalar::Type rhs_type = rhs.GetType(); - - if (lhs_type > rhs_type) { - // Right hand side need to be promoted - temp_value = rhs; // Copy right hand side into the temp value - if (temp_value.Promote(lhs_type)) // Promote it - promoted_rhs_ptr = - &temp_value; // Update the pointer for the promoted right hand side - } else if (lhs_type < rhs_type) { - // Left hand side need to be promoted - temp_value = lhs; // Copy left hand side value into the temp value - if (temp_value.Promote(rhs_type)) // Promote it - promoted_lhs_ptr = - &temp_value; // Update the pointer for the promoted left hand side - } - - // Make sure our type promotion worked as expected - if (promoted_lhs_ptr->GetType() == promoted_rhs_ptr->GetType()) - return promoted_lhs_ptr->GetType(); // Return the resulting max type - - // Return the void type (zero) if we fail to promote either of the values. - return Scalar::e_void; -} - -Scalar::Scalar() : m_type(e_void), m_float((float)0) {} - -Scalar::Scalar(const Scalar &rhs) - : m_type(rhs.m_type), m_integer(rhs.m_integer), m_float(rhs.m_float) {} - -// Scalar::Scalar(const RegisterValue& reg) : -// m_type(e_void), -// m_data() -//{ -// switch (reg.info.encoding) -// { -// case eEncodingUint: // unsigned integer -// switch (reg.info.byte_size) -// { -// case 1: m_type = e_uint; m_data.uint = reg.value.uint8; break; -// case 2: m_type = e_uint; m_data.uint = reg.value.uint16; break; -// case 4: m_type = e_uint; m_data.uint = reg.value.uint32; break; -// case 8: m_type = e_ulonglong; m_data.ulonglong = reg.value.uint64; -// break; -// break; -// } -// break; -// -// case eEncodingSint: // signed integer -// switch (reg.info.byte_size) -// { -// case 1: m_type = e_sint; m_data.sint = reg.value.sint8; break; -// case 2: m_type = e_sint; m_data.sint = reg.value.sint16; break; -// case 4: m_type = e_sint; m_data.sint = reg.value.sint32; break; -// case 8: m_type = e_slonglong; m_data.slonglong = reg.value.sint64; -// break; -// break; -// } -// break; -// -// case eEncodingIEEE754: // float -// switch (reg.info.byte_size) -// { -// case 4: m_type = e_float; m_data.flt = reg.value.float32; break; -// case 8: m_type = e_double; m_data.dbl = reg.value.float64; break; -// break; -// } -// break; -// case eEncodingVector: // vector registers -// break; -// } -//} - -bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const { - size_t byte_size = GetByteSize(); - if (byte_size > 0) { - const uint8_t *bytes = reinterpret_cast(GetBytes()); - - if (limit_byte_size < byte_size) { - if (endian::InlHostByteOrder() == eByteOrderLittle) { - // On little endian systems if we want fewer bytes from the current - // type we just specify fewer bytes since the LSByte is first... - byte_size = limit_byte_size; - } else if (endian::InlHostByteOrder() == eByteOrderBig) { - // On big endian systems if we want fewer bytes from the current type - // have to advance our initial byte pointer and trim down the number of - // bytes since the MSByte is first - bytes += byte_size - limit_byte_size; - byte_size = limit_byte_size; - } - } - - data.SetData(bytes, byte_size, endian::InlHostByteOrder()); - return true; - } - data.Clear(); - return false; -} - -const void *Scalar::GetBytes() const { - const uint64_t *apint_words; - const uint8_t *bytes; - static float_t flt_val; - static double_t dbl_val; - static uint64_t swapped_words[4]; - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - bytes = reinterpret_cast(m_integer.getRawData()); - // getRawData always returns a pointer to an uint64_t. If we have a - // smaller type, we need to update the pointer on big-endian systems. - if (endian::InlHostByteOrder() == eByteOrderBig) { - size_t byte_size = m_integer.getBitWidth() / 8; - if (byte_size < 8) - bytes += 8 - byte_size; - } - return bytes; - case e_sint128: - case e_uint128: - apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of two uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the two words. - if (endian::InlHostByteOrder() == eByteOrderBig) { - swapped_words[0] = apint_words[1]; - swapped_words[1] = apint_words[0]; - apint_words = swapped_words; - } - return reinterpret_cast(apint_words); - case e_sint256: - case e_uint256: - apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of four uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the four words. - if (endian::InlHostByteOrder() == eByteOrderBig) { - swapped_words[0] = apint_words[3]; - swapped_words[1] = apint_words[2]; - swapped_words[2] = apint_words[1]; - swapped_words[3] = apint_words[0]; - apint_words = swapped_words; - } - return reinterpret_cast(apint_words); - case e_float: - flt_val = m_float.convertToFloat(); - return reinterpret_cast(&flt_val); - case e_double: - dbl_val = m_float.convertToDouble(); - return reinterpret_cast(&dbl_val); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - apint_words = ldbl_val.getRawData(); - // getRawData always returns a pointer to an array of two uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the two words. - if (endian::InlHostByteOrder() == eByteOrderBig) { - swapped_words[0] = apint_words[1]; - swapped_words[1] = apint_words[0]; - apint_words = swapped_words; - } - return reinterpret_cast(apint_words); - } - return nullptr; -} - -size_t Scalar::GetByteSize() const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (m_integer.getBitWidth() / 8); - case e_float: - return sizeof(float_t); - case e_double: - return sizeof(double_t); - case e_long_double: - return sizeof(long_double_t); - } - return 0; -} - -bool Scalar::IsZero() const { - llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8); - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return llvm::APInt::isSameValue(zero_int, m_integer); - case e_float: - case e_double: - case e_long_double: - return m_float.isZero(); - } - return false; -} - -void Scalar::GetValue(Stream *s, bool show_type) const { - if (show_type) - s->Printf("(%s) ", GetTypeAsCString()); - - switch (m_type) { - case e_void: - break; - case e_sint: - case e_slong: - case e_slonglong: - case e_sint128: - case e_sint256: - s->PutCString(m_integer.toString(10, true)); - break; - case e_uint: - case e_ulong: - case e_ulonglong: - case e_uint128: - case e_uint256: - s->PutCString(m_integer.toString(10, false)); - break; - case e_float: - case e_double: - case e_long_double: - llvm::SmallString<24> string; - m_float.toString(string); - s->Printf("%s", string.c_str()); - break; - } -} - -const char *Scalar::GetTypeAsCString() const { - switch (m_type) { - case e_void: - return "void"; - case e_sint: - return "int"; - case e_uint: - return "unsigned int"; - case e_slong: - return "long"; - case e_ulong: - return "unsigned long"; - case e_slonglong: - return "long long"; - case e_ulonglong: - return "unsigned long long"; - case e_sint128: - return "int128_t"; - case e_uint128: - return "unsigned int128_t"; - case e_sint256: - return "int256_t"; - case e_uint256: - return "unsigned int256_t"; - case e_float: - return "float"; - case e_double: - return "double"; - case e_long_double: - return "long double"; - } - return ""; -} - -Scalar &Scalar::operator=(const Scalar &rhs) { - if (this != &rhs) { - m_type = rhs.m_type; - m_integer = llvm::APInt(rhs.m_integer); - m_float = rhs.m_float; - } - return *this; -} - -Scalar &Scalar::operator=(const int v) { - m_type = e_sint; - m_integer = llvm::APInt(sizeof(int) * 8, v, true); - return *this; -} - -Scalar &Scalar::operator=(unsigned int v) { - m_type = e_uint; - m_integer = llvm::APInt(sizeof(int) * 8, v); - return *this; -} - -Scalar &Scalar::operator=(long v) { - m_type = e_slong; - m_integer = llvm::APInt(sizeof(long) * 8, v, true); - return *this; -} - -Scalar &Scalar::operator=(unsigned long v) { - m_type = e_ulong; - m_integer = llvm::APInt(sizeof(long) * 8, v); - return *this; -} - -Scalar &Scalar::operator=(long long v) { - m_type = e_slonglong; - m_integer = llvm::APInt(sizeof(long) * 8, v, true); - return *this; -} - -Scalar &Scalar::operator=(unsigned long long v) { - m_type = e_ulonglong; - m_integer = llvm::APInt(sizeof(long long) * 8, v); - return *this; -} - -Scalar &Scalar::operator=(float v) { - m_type = e_float; - m_float = llvm::APFloat(v); - return *this; -} - -Scalar &Scalar::operator=(double v) { - m_type = e_double; - m_float = llvm::APFloat(v); - return *this; -} - -Scalar &Scalar::operator=(long double v) { - m_type = e_long_double; - if (m_ieee_quad) - m_float = llvm::APFloat( - llvm::APFloat::IEEEquad(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); - else - m_float = llvm::APFloat( - llvm::APFloat::x87DoubleExtended(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); - return *this; -} - -Scalar &Scalar::operator=(llvm::APInt rhs) { - m_integer = llvm::APInt(rhs); - switch (m_integer.getBitWidth()) { - case 8: - case 16: - case 32: - if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) - m_type = e_sint; - else - m_type = e_uint; - break; - case 64: - if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) - m_type = e_slonglong; - else - m_type = e_ulonglong; - break; - case 128: - if (m_integer.isSignedIntN(BITWIDTH_INT128)) - m_type = e_sint128; - else - m_type = e_uint128; - break; - case 256: - if (m_integer.isSignedIntN(BITWIDTH_INT256)) - m_type = e_sint256; - else - m_type = e_uint256; - break; - } - return *this; -} - -Scalar::~Scalar() = default; - -bool Scalar::Promote(Scalar::Type type) { - bool success = false; - switch (m_type) { - case e_void: - break; - - case e_sint: - switch (type) { - case e_void: - break; - case e_sint: - success = true; - break; - case e_uint: - m_integer = m_integer.sextOrTrunc(sizeof(uint_t) * 8); - success = true; - break; - - case e_slong: - m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8); - success = true; - break; - - case e_ulong: - m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8); - success = true; - break; - - case e_slonglong: - m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8); - success = true; - break; - - case e_ulonglong: - m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); - success = true; - break; - - case e_sint128: - case e_uint128: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_uint: - switch (type) { - case e_void: - case e_sint: - break; - case e_uint: - success = true; - break; - case e_slong: - m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8); - success = true; - break; - - case e_ulong: - m_integer = m_integer.zextOrTrunc(sizeof(ulong_t) * 8); - success = true; - break; - - case e_slonglong: - m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8); - success = true; - break; - - case e_ulonglong: - m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8); - success = true; - break; - - case e_sint128: - case e_uint128: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_slong: - switch (type) { - case e_void: - case e_sint: - case e_uint: - break; - case e_slong: - success = true; - break; - case e_ulong: - m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8); - success = true; - break; - - case e_slonglong: - m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8); - success = true; - break; - - case e_ulonglong: - m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); - success = true; - break; - - case e_sint128: - case e_uint128: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_ulong: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - break; - case e_ulong: - success = true; - break; - case e_slonglong: - m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8); - success = true; - break; - - case e_ulonglong: - m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8); - success = true; - break; - - case e_sint128: - case e_uint128: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_slonglong: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - break; - case e_slonglong: - success = true; - break; - case e_ulonglong: - m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); - success = true; - break; - - case e_sint128: - case e_uint128: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_ulonglong: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - break; - case e_ulonglong: - success = true; - break; - case e_sint128: - case e_uint128: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_sint128: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - break; - case e_sint128: - success = true; - break; - case e_uint128: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); - success = true; - break; - - case e_sint256: - case e_uint256: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_uint128: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - break; - case e_uint128: - success = true; - break; - case e_sint256: - case e_uint256: - m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_sint256: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - break; - case e_sint256: - success = true; - break; - case e_uint256: - m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); - success = true; - break; - - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, true, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_uint256: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - break; - case e_uint256: - success = true; - break; - case e_float: - m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_double: - m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - - case e_long_double: - m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended()); - m_float.convertFromAPInt(m_integer, false, - llvm::APFloat::rmNearestTiesToEven); - success = true; - break; - } - break; - - case e_float: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - break; - case e_float: - success = true; - break; - case e_double: - m_float = llvm::APFloat((double_t)m_float.convertToFloat()); - success = true; - break; - - case e_long_double: { - bool ignore; - m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended(), - llvm::APFloat::rmNearestTiesToEven, &ignore); - success = true; - break; - } - } - break; - - case e_double: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - case e_float: - break; - case e_double: - success = true; - break; - case e_long_double: { - bool ignore; - m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad() - : llvm::APFloat::x87DoubleExtended(), - llvm::APFloat::rmNearestTiesToEven, &ignore); - success = true; - break; - } - } - break; - - case e_long_double: - switch (type) { - case e_void: - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - case e_float: - case e_double: - break; - case e_long_double: - success = true; - break; - } - break; - } - - if (success) - m_type = type; - return success; -} - -const char *Scalar::GetValueTypeAsCString(Scalar::Type type) { - switch (type) { - case e_void: - return "void"; - case e_sint: - return "int"; - case e_uint: - return "unsigned int"; - case e_slong: - return "long"; - case e_ulong: - return "unsigned long"; - case e_slonglong: - return "long long"; - case e_ulonglong: - return "unsigned long long"; - case e_float: - return "float"; - case e_double: - return "double"; - case e_long_double: - return "long double"; - case e_sint128: - return "int128_t"; - case e_uint128: - return "uint128_t"; - case e_sint256: - return "int256_t"; - case e_uint256: - return "uint256_t"; - } - return "???"; -} - -Scalar::Type -Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) { - if (byte_size <= sizeof(sint_t)) - return e_sint; - if (byte_size <= sizeof(slong_t)) - return e_slong; - if (byte_size <= sizeof(slonglong_t)) - return e_slonglong; - return e_void; -} - -Scalar::Type -Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) { - if (byte_size <= sizeof(uint_t)) - return e_uint; - if (byte_size <= sizeof(ulong_t)) - return e_ulong; - if (byte_size <= sizeof(ulonglong_t)) - return e_ulonglong; - return e_void; -} - -Scalar::Type Scalar::GetValueTypeForFloatWithByteSize(size_t byte_size) { - if (byte_size == sizeof(float_t)) - return e_float; - if (byte_size == sizeof(double_t)) - return e_double; - if (byte_size == sizeof(long_double_t)) - return e_long_double; - return e_void; -} - -bool Scalar::MakeSigned() { - bool success = false; - - switch (m_type) { - case e_void: - break; - case e_sint: - success = true; - break; - case e_uint: - m_type = e_sint; - success = true; - break; - case e_slong: - success = true; - break; - case e_ulong: - m_type = e_slong; - success = true; - break; - case e_slonglong: - success = true; - break; - case e_ulonglong: - m_type = e_slonglong; - success = true; - break; - case e_sint128: - success = true; - break; - case e_uint128: - m_type = e_sint128; - success = true; - break; - case e_sint256: - success = true; - break; - case e_uint256: - m_type = e_sint256; - success = true; - break; - case e_float: - success = true; - break; - case e_double: - success = true; - break; - case e_long_double: - success = true; - break; - } - - return success; -} - -bool Scalar::MakeUnsigned() { - bool success = false; - - switch (m_type) { - case e_void: - break; - case e_sint: - m_type = e_uint; - success = true; - break; - case e_uint: - success = true; - break; - case e_slong: - m_type = e_ulong; - success = true; - break; - case e_ulong: - success = true; - break; - case e_slonglong: - m_type = e_ulonglong; - success = true; - break; - case e_ulonglong: - success = true; - break; - case e_sint128: - m_type = e_uint128; - success = true; - break; - case e_uint128: - success = true; - break; - case e_sint256: - m_type = e_uint256; - success = true; - break; - case e_uint256: - success = true; - break; - case e_float: - success = true; - break; - case e_double: - success = true; - break; - case e_long_double: - success = true; - break; - } - - return success; -} - -signed char Scalar::SChar(char fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue(); - case e_float: - return (schar_t)m_float.convertToFloat(); - case e_double: - return (schar_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (schar_t)(ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue(); - } - return fail_value; -} - -unsigned char Scalar::UChar(unsigned char fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue(); - case e_float: - return (uchar_t)m_float.convertToFloat(); - case e_double: - return (uchar_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (uchar_t)(ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue(); - } - return fail_value; -} - -short Scalar::SShort(short fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)) - .getSExtValue(); - case e_float: - return (sshort_t)m_float.convertToFloat(); - case e_double: - return (sshort_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (sshort_t)(ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8)) - .getSExtValue(); - } - return fail_value; -} - -unsigned short Scalar::UShort(unsigned short fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8)) - .getZExtValue(); - case e_float: - return (ushort_t)m_float.convertToFloat(); - case e_double: - return (ushort_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (ushort_t)(ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8)) - .getZExtValue(); - } - return fail_value; -} - -int Scalar::SInt(int fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue(); - case e_float: - return (sint_t)m_float.convertToFloat(); - case e_double: - return (sint_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (sint_t)(ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue(); - } - return fail_value; -} - -unsigned int Scalar::UInt(unsigned int fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue(); - case e_float: - return (uint_t)m_float.convertToFloat(); - case e_double: - return (uint_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (uint_t)(ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue(); - } - return fail_value; -} - -long Scalar::SLong(long fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue(); - case e_float: - return (slong_t)m_float.convertToFloat(); - case e_double: - return (slong_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (slong_t)(ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue(); - } - return fail_value; -} - -unsigned long Scalar::ULong(unsigned long fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue(); - case e_float: - return (ulong_t)m_float.convertToFloat(); - case e_double: - return (ulong_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (ulong_t)(ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue(); - } - return fail_value; -} - -long long Scalar::SLongLong(long long fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)) - .getSExtValue(); - case e_float: - return (slonglong_t)m_float.convertToFloat(); - case e_double: - return (slonglong_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (slonglong_t)(ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8)) - .getSExtValue(); - } - return fail_value; -} - -unsigned long long Scalar::ULongLong(unsigned long long fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8)) - .getZExtValue(); - case e_float: - return (ulonglong_t)m_float.convertToFloat(); - case e_double: - return (ulonglong_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (ulonglong_t)(ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8)) - .getZExtValue(); - } - return fail_value; -} - -llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -llvm::APInt Scalar::SInt256(llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -llvm::APInt Scalar::UInt256(const llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -float Scalar::Float(float fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return llvm::APIntOps::RoundAPIntToFloat(m_integer); - case e_float: - return m_float.convertToFloat(); - case e_double: - return (float_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return ldbl_val.bitsToFloat(); - } - return fail_value; -} - -double Scalar::Double(double fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return llvm::APIntOps::RoundAPIntToDouble(m_integer); - case e_float: - return (double_t)m_float.convertToFloat(); - case e_double: - return m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return ldbl_val.bitsToFloat(); - } - return fail_value; -} - -long double Scalar::LongDouble(long double fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer); - case e_float: - return (long_double_t)m_float.convertToFloat(); - case e_double: - return (long_double_t)m_float.convertToDouble(); - case e_long_double: - llvm::APInt ldbl_val = m_float.bitcastToAPInt(); - return (long_double_t)ldbl_val.bitsToDouble(); - } - return fail_value; -} - -Scalar &Scalar::operator+=(const Scalar &rhs) { - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = a->m_integer + b->m_integer; - break; - - case e_float: - case e_double: - case e_long_double: - m_float = a->m_float + b->m_float; - break; - } - } - return *this; -} - -Scalar &Scalar::operator<<=(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - switch (rhs.m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = m_integer << rhs.m_integer; - break; - } - break; - } - return *this; -} - -bool Scalar::ShiftRightLogical(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - switch (rhs.m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = m_integer.lshr(rhs.m_integer); - break; - } - break; - } - return m_type != e_void; -} - -Scalar &Scalar::operator>>=(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - switch (rhs.m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = m_integer.ashr(rhs.m_integer); - break; - } - break; - } - return *this; -} - -Scalar &Scalar::operator&=(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - switch (rhs.m_type) { - case e_void: - case e_float: - case e_double: - case e_long_double: - m_type = e_void; - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer &= rhs.m_integer; - break; - } - break; - } - return *this; -} - -bool Scalar::AbsoluteValue() { - switch (m_type) { - case e_void: - break; - - case e_sint: - case e_slong: - case e_slonglong: - case e_sint128: - case e_sint256: - if (m_integer.isNegative()) - m_integer = -m_integer; - return true; - - case e_uint: - case e_ulong: - case e_ulonglong: - return true; - case e_uint128: - case e_uint256: - case e_float: - case e_double: - case e_long_double: - m_float.clearSign(); - return true; - } - return false; -} - -bool Scalar::UnaryNegate() { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = -m_integer; - return true; - case e_float: - case e_double: - case e_long_double: - m_float.changeSign(); - return true; - } - return false; -} - -bool Scalar::OnesComplement() { - switch (m_type) { - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer = ~m_integer; - return true; - - case e_void: - case e_float: - case e_double: - case e_long_double: - break; - } - return false; -} - -const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer + b->m_integer; - break; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result.m_float = a->m_float + b->m_float; - break; - } - } - return result; -} - -const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer - b->m_integer; - break; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result.m_float = a->m_float - b->m_float; - break; - } - } - return result; -} - -const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - if (b->m_integer != 0) { - result.m_integer = a->m_integer.sdiv(b->m_integer); - return result; - } - break; - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - if (b->m_integer != 0) { - result.m_integer = a->m_integer.udiv(b->m_integer); - return result; - } - break; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - if (!b->m_float.isZero()) { - result.m_float = a->m_float / b->m_float; - return result; - } - break; - } - } - // For division only, the only way it should make it here is if a promotion - // failed, or if we are trying to do a divide by zero. - result.m_type = Scalar::e_void; - return result; -} - -const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer * b->m_integer; - break; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result.m_float = a->m_float * b->m_float; - break; - } - } - return result; -} - -const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer & b->m_integer; - break; - case Scalar::e_void: - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - // No bitwise AND on floats, doubles of long doubles - result.m_type = Scalar::e_void; - break; - } - } - return result; -} - -const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer | b->m_integer; - break; - - case Scalar::e_void: - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - // No bitwise AND on floats, doubles of long doubles - result.m_type = Scalar::e_void; - break; - } - } - return result; -} - -const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - default: - break; - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - if (b->m_integer != 0) { - result.m_integer = a->m_integer.srem(b->m_integer); - return result; - } - break; - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - if (b->m_integer != 0) { - result.m_integer = a->m_integer.urem(b->m_integer); - return result; - } - break; - } - } - result.m_type = Scalar::e_void; - return result; -} - -const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) { - Scalar result; - Scalar temp_value; - const Scalar *a; - const Scalar *b; - if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != - Scalar::e_void) { - switch (result.m_type) { - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - result.m_integer = a->m_integer ^ b->m_integer; - break; - - case Scalar::e_void: - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - // No bitwise AND on floats, doubles of long doubles - result.m_type = Scalar::e_void; - break; - } - } - return result; -} - -const Scalar lldb_private::operator<<(const Scalar &lhs, const Scalar &rhs) { - Scalar result = lhs; - result <<= rhs; - return result; -} - -const Scalar lldb_private::operator>>(const Scalar &lhs, const Scalar &rhs) { - Scalar result = lhs; - result >>= rhs; - return result; -} - -Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding, - size_t byte_size) { - Status error; - if (value_str == nullptr || value_str[0] == '\0') { - error.SetErrorString("Invalid c-string value string."); - return error; - } - switch (encoding) { - case eEncodingInvalid: - error.SetErrorString("Invalid encoding."); - break; - - case eEncodingUint: - if (byte_size <= sizeof(uint64_t)) { - uint64_t uval64; - if (!llvm::to_integer(value_str, uval64)) - error.SetErrorStringWithFormat( - "'%s' is not a valid unsigned integer string value", value_str); - else if (!UIntValueIsValidForSize(uval64, byte_size)) - error.SetErrorStringWithFormat("value 0x%" PRIx64 - " is too large to fit in a %" PRIu64 - " byte unsigned integer value", - uval64, (uint64_t)byte_size); - else { - m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize(byte_size); - switch (m_type) { - case e_uint: - m_integer = llvm::APInt(sizeof(uint_t) * 8, uval64, false); - break; - case e_ulong: - m_integer = llvm::APInt(sizeof(ulong_t) * 8, uval64, false); - break; - case e_ulonglong: - m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, uval64, false); - break; - default: - error.SetErrorStringWithFormat( - "unsupported unsigned integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - break; - } - } - } else { - error.SetErrorStringWithFormat( - "unsupported unsigned integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - return error; - } - break; - - case eEncodingSint: - if (byte_size <= sizeof(int64_t)) { - int64_t sval64; - if (!llvm::to_integer(value_str, sval64)) - error.SetErrorStringWithFormat( - "'%s' is not a valid signed integer string value", value_str); - else if (!SIntValueIsValidForSize(sval64, byte_size)) - error.SetErrorStringWithFormat("value 0x%" PRIx64 - " is too large to fit in a %" PRIu64 - " byte signed integer value", - sval64, (uint64_t)byte_size); - else { - m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize(byte_size); - switch (m_type) { - case e_sint: - m_integer = llvm::APInt(sizeof(sint_t) * 8, sval64, true); - break; - case e_slong: - m_integer = llvm::APInt(sizeof(slong_t) * 8, sval64, true); - break; - case e_slonglong: - m_integer = llvm::APInt(sizeof(slonglong_t) * 8, sval64, true); - break; - default: - error.SetErrorStringWithFormat( - "unsupported signed integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - break; - } - } - } else { - error.SetErrorStringWithFormat( - "unsupported signed integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - return error; - } - break; - - case eEncodingIEEE754: - static float f_val; - static double d_val; - static long double l_val; - if (byte_size == sizeof(float)) { - if (::sscanf(value_str, "%f", &f_val) == 1) { - m_float = llvm::APFloat(f_val); - m_type = e_float; - } else - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_str); - } else if (byte_size == sizeof(double)) { - if (::sscanf(value_str, "%lf", &d_val) == 1) { - m_float = llvm::APFloat(d_val); - m_type = e_double; - } else - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_str); - } else if (byte_size == sizeof(long double)) { - if (::sscanf(value_str, "%Lf", &l_val) == 1) { - m_float = - llvm::APFloat(llvm::APFloat::x87DoubleExtended(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((type128 *)&l_val)->x)); - m_type = e_long_double; - } else - error.SetErrorStringWithFormat("'%s' is not a valid float string value", - value_str); - } else { - error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "", - (uint64_t)byte_size); - return error; - } - break; - - case eEncodingVector: - error.SetErrorString("vector encoding unsupported."); - break; - } - if (error.Fail()) - m_type = e_void; - - return error; -} - -Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding, - size_t byte_size) { - Status error; - - type128 int128; - type256 int256; - switch (encoding) { - case lldb::eEncodingInvalid: - error.SetErrorString("invalid encoding"); - break; - case lldb::eEncodingVector: - error.SetErrorString("vector encoding unsupported"); - break; - case lldb::eEncodingUint: { - lldb::offset_t offset = 0; - - switch (byte_size) { - case 1: - operator=((uint8_t)data.GetU8(&offset)); - break; - case 2: - operator=((uint16_t)data.GetU16(&offset)); - break; - case 4: - operator=((uint32_t)data.GetU32(&offset)); - break; - case 8: - operator=((uint64_t)data.GetU64(&offset)); - break; - case 16: - if (data.GetByteOrder() == eByteOrderBig) { - int128.x[1] = (uint64_t)data.GetU64(&offset); - int128.x[0] = (uint64_t)data.GetU64(&offset); - } else { - int128.x[0] = (uint64_t)data.GetU64(&offset); - int128.x[1] = (uint64_t)data.GetU64(&offset); - } - operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x)); - break; - case 32: - if (data.GetByteOrder() == eByteOrderBig) { - int256.x[3] = (uint64_t)data.GetU64(&offset); - int256.x[2] = (uint64_t)data.GetU64(&offset); - int256.x[1] = (uint64_t)data.GetU64(&offset); - int256.x[0] = (uint64_t)data.GetU64(&offset); - } else { - int256.x[0] = (uint64_t)data.GetU64(&offset); - int256.x[1] = (uint64_t)data.GetU64(&offset); - int256.x[2] = (uint64_t)data.GetU64(&offset); - int256.x[3] = (uint64_t)data.GetU64(&offset); - } - operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x)); - break; - default: - error.SetErrorStringWithFormat( - "unsupported unsigned integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - break; - } - } break; - case lldb::eEncodingSint: { - lldb::offset_t offset = 0; - - switch (byte_size) { - case 1: - operator=((int8_t)data.GetU8(&offset)); - break; - case 2: - operator=((int16_t)data.GetU16(&offset)); - break; - case 4: - operator=((int32_t)data.GetU32(&offset)); - break; - case 8: - operator=((int64_t)data.GetU64(&offset)); - break; - case 16: - if (data.GetByteOrder() == eByteOrderBig) { - int128.x[1] = (uint64_t)data.GetU64(&offset); - int128.x[0] = (uint64_t)data.GetU64(&offset); - } else { - int128.x[0] = (uint64_t)data.GetU64(&offset); - int128.x[1] = (uint64_t)data.GetU64(&offset); - } - operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x)); - break; - case 32: - if (data.GetByteOrder() == eByteOrderBig) { - int256.x[3] = (uint64_t)data.GetU64(&offset); - int256.x[2] = (uint64_t)data.GetU64(&offset); - int256.x[1] = (uint64_t)data.GetU64(&offset); - int256.x[0] = (uint64_t)data.GetU64(&offset); - } else { - int256.x[0] = (uint64_t)data.GetU64(&offset); - int256.x[1] = (uint64_t)data.GetU64(&offset); - int256.x[2] = (uint64_t)data.GetU64(&offset); - int256.x[3] = (uint64_t)data.GetU64(&offset); - } - operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x)); - break; - default: - error.SetErrorStringWithFormat( - "unsupported signed integer byte size: %" PRIu64 "", - (uint64_t)byte_size); - break; - } - } break; - case lldb::eEncodingIEEE754: { - lldb::offset_t offset = 0; - - if (byte_size == sizeof(float)) - operator=((float)data.GetFloat(&offset)); - else if (byte_size == sizeof(double)) - operator=((double)data.GetDouble(&offset)); - else if (byte_size == sizeof(long double)) - operator=((long double)data.GetLongDouble(&offset)); - else - error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "", - (uint64_t)byte_size); - } break; - } - - return error; -} - -bool Scalar::SignExtend(uint32_t sign_bit_pos) { - const uint32_t max_bit_pos = GetByteSize() * 8; - - if (sign_bit_pos < max_bit_pos) { - switch (m_type) { - case Scalar::e_void: - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - return false; - - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - if (max_bit_pos == sign_bit_pos) - return true; - else if (sign_bit_pos < (max_bit_pos - 1)) { - llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1); - llvm::APInt bitwize_and = m_integer & sign_bit; - if (bitwize_and.getBoolValue()) { - const llvm::APInt mask = - ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1); - m_integer |= mask; - } - return true; - } - break; - } - } - return false; -} - -size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len, - lldb::ByteOrder dst_byte_order, - Status &error) const { - // Get a data extractor that points to the native scalar data - DataExtractor data; - if (!GetData(data)) { - error.SetErrorString("invalid scalar value"); - return 0; - } - - const size_t src_len = data.GetByteSize(); - - // Prepare a memory buffer that contains some or all of the register value - const size_t bytes_copied = - data.CopyByteOrderedData(0, // src offset - src_len, // src length - dst, // dst buffer - dst_len, // dst length - dst_byte_order); // dst byte order - if (bytes_copied == 0) - error.SetErrorString("failed to copy data"); - - return bytes_copied; -} - -bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) { - if (bit_size == 0) - return true; - - switch (m_type) { - case Scalar::e_void: - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - break; - - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - m_integer = m_integer.ashr(bit_offset) - .sextOrTrunc(bit_size) - .sextOrSelf(8 * GetByteSize()); - return true; - - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - m_integer = m_integer.lshr(bit_offset) - .zextOrTrunc(bit_size) - .zextOrSelf(8 * GetByteSize()); - return true; - } - return false; -} - -bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) { - // If either entry is void then we can just compare the types - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return lhs.m_type == rhs.m_type; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - return a->m_integer == b->m_integer; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpEqual) - return true; - } - return false; -} - -bool lldb_private::operator!=(const Scalar &lhs, const Scalar &rhs) { - // If either entry is void then we can just compare the types - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return lhs.m_type != rhs.m_type; - - Scalar - temp_value; // A temp value that might get a copy of either promoted value - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - return a->m_integer != b->m_integer; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result != llvm::APFloat::cmpEqual) - return true; - } - return true; -} - -bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.slt(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.ult(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpLessThan) - return true; - } - return false; -} - -bool lldb_private::operator<=(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sle(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.ule(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpLessThan || - result == llvm::APFloat::cmpEqual) - return true; - } - return false; -} - -bool lldb_private::operator>(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sgt(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.ugt(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpGreaterThan) - return true; - } - return false; -} - -bool lldb_private::operator>=(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sge(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.uge(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpGreaterThan || - result == llvm::APFloat::cmpEqual) - return true; - } - return false; -} - -bool Scalar::ClearBit(uint32_t bit) { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer.clearBit(bit); - return true; - case e_float: - case e_double: - case e_long_double: - break; - } - return false; -} - -bool Scalar::SetBit(uint32_t bit) { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - m_integer.setBit(bit); - return true; - case e_float: - case e_double: - case e_long_double: - break; - } - return false; -} Index: lldb/trunk/source/Core/State.cpp =================================================================== --- lldb/trunk/source/Core/State.cpp +++ lldb/trunk/source/Core/State.cpp @@ -1,115 +0,0 @@ -//===-- State.cpp -----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/State.h" - -using namespace lldb; -using namespace lldb_private; - -const char *lldb_private::StateAsCString(StateType state) { - switch (state) { - case eStateInvalid: - return "invalid"; - case eStateUnloaded: - return "unloaded"; - case eStateConnected: - return "connected"; - case eStateAttaching: - return "attaching"; - case eStateLaunching: - return "launching"; - case eStateStopped: - return "stopped"; - case eStateRunning: - return "running"; - case eStateStepping: - return "stepping"; - case eStateCrashed: - return "crashed"; - case eStateDetached: - return "detached"; - case eStateExited: - return "exited"; - case eStateSuspended: - return "suspended"; - } - return "unknown"; -} - -const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) { - switch (permissions) { - case 0: - return "---"; - case ePermissionsWritable: - return "-w-"; - case ePermissionsReadable: - return "r--"; - case ePermissionsExecutable: - return "--x"; - case ePermissionsReadable | ePermissionsWritable: - return "rw-"; - case ePermissionsReadable | ePermissionsExecutable: - return "r-x"; - case ePermissionsWritable | ePermissionsExecutable: - return "-wx"; - case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable: - return "rwx"; - default: - break; - } - return "???"; -} - -bool lldb_private::StateIsRunningState(StateType state) { - switch (state) { - case eStateAttaching: - case eStateLaunching: - case eStateRunning: - case eStateStepping: - return true; - - case eStateConnected: - case eStateDetached: - case eStateInvalid: - case eStateUnloaded: - case eStateStopped: - case eStateCrashed: - case eStateExited: - case eStateSuspended: - break; - } - return false; -} - -bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) { - switch (state) { - case eStateInvalid: - case eStateConnected: - case eStateAttaching: - case eStateLaunching: - case eStateRunning: - case eStateStepping: - case eStateDetached: - break; - - case eStateUnloaded: - case eStateExited: - return !must_exist; - - case eStateStopped: - case eStateCrashed: - case eStateSuspended: - return true; - } - return false; -} Index: lldb/trunk/source/Core/Value.cpp =================================================================== --- lldb/trunk/source/Core/Value.cpp +++ lldb/trunk/source/Core/Value.cpp @@ -9,9 +9,8 @@ #include "lldb/Core/Value.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" // for Address #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -26,6 +25,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" // for InlHostByteOrder #include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS #include "lldb/lldb-forward.h" // for DataBufferSP, ModuleSP Index: lldb/trunk/source/Core/ValueObject.cpp =================================================================== --- lldb/trunk/source/Core/ValueObject.cpp +++ lldb/trunk/source/Core/ValueObject.cpp @@ -11,7 +11,6 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" // for Scalar #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResult.h" @@ -20,7 +19,7 @@ #include "lldb/Core/ValueObjectSyntheticFilter.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... -#include "lldb/DataFormatters/FormatManager.h" // for FormatManager +#include "lldb/DataFormatters/FormatManager.h" // for FormatManager #include "lldb/DataFormatters/StringPrinter.h" #include "lldb/DataFormatters/TypeFormat.h" // for TypeFormatImpl_F... #include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryOptions @@ -47,6 +46,7 @@ #include "lldb/Utility/Flags.h" // for Flags #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" // for GetLogIfAllCateg... +#include "lldb/Utility/Scalar.h" // for Scalar #include "lldb/Utility/SharingPtr.h" // for SharingPtr #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Core/ValueObjectCast.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectCast.cpp +++ lldb/trunk/source/Core/ValueObjectCast.cpp @@ -9,11 +9,11 @@ #include "lldb/Core/ValueObjectCast.h" -#include "lldb/Core/Scalar.h" // for operator!=, Scalar #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Utility/Scalar.h" // for operator!=, Scalar #include "lldb/Utility/Status.h" // for Status namespace lldb_private { Index: lldb/trunk/source/Core/ValueObjectChild.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp +++ lldb/trunk/source/Core/ValueObjectChild.cpp @@ -9,12 +9,12 @@ #include "lldb/Core/ValueObjectChild.h" -#include "lldb/Core/Scalar.h" // for Scalar -#include "lldb/Core/Value.h" // for Value, Value::ValueType::e... +#include "lldb/Core/Value.h" // for Value, Value::ValueType::e... #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Utility/Flags.h" // for Flags +#include "lldb/Utility/Scalar.h" // for Scalar #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-forward.h" // for ProcessSP, ModuleSP Index: lldb/trunk/source/Core/ValueObjectConstResult.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp @@ -9,7 +9,6 @@ #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/Scalar.h" // for Scalar #include "lldb/Core/ValueObjectDynamicValue.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" @@ -18,6 +17,7 @@ #include "lldb/Utility/DataBuffer.h" // for DataBuffer #include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" // for Scalar namespace lldb_private { class Module; Index: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp @@ -9,7 +9,6 @@ #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Core/Scalar.h" // for Scalar #include "lldb/Core/Value.h" // for Value, Value::Val... #include "lldb/Core/ValueObject.h" // for ValueObject #include "lldb/Core/ValueObjectConstResult.h" @@ -19,6 +18,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap #include "lldb/Utility/Endian.h" // for InlHostByteOrder +#include "lldb/Utility/Scalar.h" // for Scalar #include "lldb/Utility/SharingPtr.h" // for SharingPtr #include // for string Index: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectDynamicValue.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" @@ -20,6 +19,7 @@ #include "lldb/Utility/DataExtractor.h" // for DataExtractor #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet +#include "lldb/Utility/Scalar.h" // for Scalar, operator!= #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-types.h" // for addr_t, offset_t Index: lldb/trunk/source/Core/ValueObjectMemory.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp +++ lldb/trunk/source/Core/ValueObjectMemory.cpp @@ -8,13 +8,13 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectMemory.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" // for DataExtractor +#include "lldb/Utility/Scalar.h" // for Scalar, operator!= #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-types.h" // for addr_t #include "llvm/Support/ErrorHandling.h" // for llvm_unreachable Index: lldb/trunk/source/Core/ValueObjectRegister.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp +++ lldb/trunk/source/Core/ValueObjectRegister.cpp @@ -10,8 +10,7 @@ #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" // for Scalar -#include "lldb/Core/Value.h" // for Value, Value::ContextType:... +#include "lldb/Core/Value.h" // for Value, Value::ContextType:... #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/TypeSystem.h" // for TypeSystem #include "lldb/Target/ExecutionContext.h" @@ -20,6 +19,7 @@ #include "lldb/Target/StackFrame.h" // for StackFrame #include "lldb/Target/Target.h" #include "lldb/Utility/DataExtractor.h" // for DataExtractor +#include "lldb/Utility/Scalar.h" // for Scalar #include "lldb/Utility/Status.h" // for Status #include "lldb/Utility/Stream.h" // for Stream Index: lldb/trunk/source/Core/ValueObjectVariable.cpp =================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp +++ lldb/trunk/source/Core/ValueObjectVariable.cpp @@ -12,8 +12,6 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/AddressRange.h" // for AddressRange #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" // for DWARFExpression #include "lldb/Symbol/Declaration.h" // for Declaration @@ -27,7 +25,9 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataExtractor.h" // for DataExtractor +#include "lldb/Utility/DataExtractor.h" // for DataExtractor +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" // for Scalar, operator!= #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-private-enumerations.h" // for AddressType::eAddressTy... #include "lldb/lldb-types.h" // for addr_t Index: lldb/trunk/source/Expression/DWARFExpression.cpp =================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp +++ lldb/trunk/source/Expression/DWARFExpression.cpp @@ -16,12 +16,12 @@ #include #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/dwarf.h" #include "lldb/Utility/DataEncoder.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/VMRange.h" Index: lldb/trunk/source/Expression/FunctionCaller.cpp =================================================================== --- lldb/trunk/source/Expression/FunctionCaller.cpp +++ lldb/trunk/source/Expression/FunctionCaller.cpp @@ -14,7 +14,6 @@ // Project includes #include "lldb/Expression/FunctionCaller.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/DiagnosticManager.h" @@ -31,6 +30,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb_private; Index: lldb/trunk/source/Expression/IRInterpreter.cpp =================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp +++ lldb/trunk/source/Expression/IRInterpreter.cpp @@ -10,7 +10,6 @@ #include "lldb/Expression/IRInterpreter.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -19,6 +18,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Expression/IRMemoryMap.cpp =================================================================== --- lldb/trunk/source/Expression/IRMemoryMap.cpp +++ lldb/trunk/source/Expression/IRMemoryMap.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -16,6 +15,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" using namespace lldb_private; Index: lldb/trunk/source/Expression/Materializer.cpp =================================================================== --- lldb/trunk/source/Expression/Materializer.cpp +++ lldb/trunk/source/Expression/Materializer.cpp @@ -13,7 +13,6 @@ // Project includes #include "lldb/Expression/Materializer.h" #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/ExpressionVariable.h" @@ -27,6 +26,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp =================================================================== --- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp +++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp @@ -8,13 +8,13 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/common/NativeProcessProtocol.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/common/NativeThreadProtocol.h" #include "lldb/Host/common/SoftwareBreakpoint.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" using namespace lldb; Index: lldb/trunk/source/Host/common/NativeRegisterContext.cpp =================================================================== --- lldb/trunk/source/Host/common/NativeRegisterContext.cpp +++ lldb/trunk/source/Host/common/NativeRegisterContext.cpp @@ -9,8 +9,8 @@ #include "lldb/Host/common/NativeRegisterContext.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Host/PosixApi.h" #include "lldb/Host/common/NativeProcessProtocol.h" Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp @@ -42,9 +42,9 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Interpreter/OptionValueArch.cpp =================================================================== --- lldb/trunk/source/Interpreter/OptionValueArch.cpp +++ lldb/trunk/source/Interpreter/OptionValueArch.cpp @@ -13,11 +13,11 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Interpreter/OptionValueDictionary.cpp =================================================================== --- lldb/trunk/source/Interpreter/OptionValueDictionary.cpp +++ lldb/trunk/source/Interpreter/OptionValueDictionary.cpp @@ -14,10 +14,10 @@ // Other libraries and framework includes #include "llvm/ADT/StringRef.h" // Project includes -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp =================================================================== --- lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp +++ lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp @@ -9,13 +9,13 @@ #include "lldb/Interpreter/OptionValueFileSpec.h" -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -20,8 +20,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +28,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/ARMDefines.h" Index: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -19,8 +19,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +28,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Utility/ARM64_DWARF_Registers.h" Index: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -20,8 +20,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" @@ -29,6 +27,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -20,8 +20,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +28,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/ARMDefines.h" Index: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -20,8 +20,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -31,6 +29,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Utility/ARM64_DWARF_Registers.h" Index: lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -17,7 +17,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -31,6 +30,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -20,7 +20,6 @@ #include "Utility/PPC64_DWARF_Registers.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -35,6 +34,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "clang/AST/ASTContext.h" Index: lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -18,7 +18,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -19,7 +19,6 @@ // Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -33,6 +32,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/Symbols.h" #include "lldb/Interpreter/OptionValueProperties.h" @@ -29,6 +28,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwinKernel.h" Index: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/ClangASTContext.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" //#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF Index: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp =================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -12,7 +12,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolVendor.h" @@ -21,6 +20,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwin.h" #include "DynamicLoaderMacOS.h" Index: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -27,6 +26,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwin.h" #include "DynamicLoaderMacOSXDYLD.h" Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/Materializer.h" @@ -44,6 +43,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include "clang/AST/ASTConsumer.h" Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp @@ -27,7 +27,6 @@ // Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -44,6 +43,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -25,7 +25,6 @@ #include "clang/AST/ASTContext.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/dwarf.h" #include "lldb/Expression/IRExecutionUnit.h" #include "lldb/Expression/IRInterpreter.h" @@ -36,6 +35,7 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include Index: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp =================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -9,12 +9,12 @@ #include "EmulationStateARM.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Interpreter/OptionValueArray.h" #include "lldb/Interpreter/OptionValueDictionary.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "Utility/ARM_DWARF_Registers.h" Index: lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp =================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -13,10 +13,10 @@ #include "lldb/Core/Address.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "Plugins/Process/Utility/ARMDefines.h" Index: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp =================================================================== --- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -14,12 +14,12 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "llvm-c/Disassembler.h" #include "llvm/MC/MCAsmInfo.h" Index: lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp =================================================================== --- lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -14,12 +14,12 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "llvm-c/Disassembler.h" #include "llvm/MC/MCAsmInfo.h" Index: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/Interpreter/CommandObject.h" @@ -32,6 +31,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include Index: lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp @@ -13,7 +13,6 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/Symbol/GoASTContext.h" @@ -28,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "llvm/ADT/Twine.h" Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" @@ -32,6 +31,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -17,7 +17,6 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Expression/FunctionCaller.h" #include "lldb/Expression/UtilityFunction.h" #include "lldb/Symbol/ClangASTContext.h" @@ -29,6 +28,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -28,7 +28,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/DiagnosticManager.h" @@ -52,6 +51,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -20,7 +20,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DumpValueObjectOptions.h" #include "lldb/Expression/UserExpression.h" @@ -43,6 +42,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -23,7 +23,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/Host.h" @@ -41,6 +40,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp =================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp +++ lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp @@ -21,7 +21,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -39,6 +38,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StreamString.h" using namespace lldb; Index: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp =================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -20,7 +20,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" @@ -32,6 +31,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" Index: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -9,12 +9,12 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/UriParser.h" // Project includes Index: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -23,12 +23,12 @@ #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -21,12 +21,12 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -21,12 +21,12 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ lldb/trunk/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -21,12 +21,12 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp +++ lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp @@ -19,10 +19,10 @@ // C++ includes // LLDB includes -#include "lldb/Core/State.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "CFBundle.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -18,8 +18,8 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/State.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/State.h" // Project includes #include "FreeBSDThread.h" @@ -42,7 +42,6 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" @@ -50,6 +49,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/SmallString.h" using namespace lldb; Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -24,12 +24,12 @@ // Other libraries and framework includes #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "FreeBSDThread.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" @@ -44,7 +44,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" @@ -52,6 +51,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/State.h" #include "lldb/Host/posix/Fcntl.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -21,14 +21,14 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Host/Host.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "llvm/Support/Errno.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp @@ -7,9 +7,9 @@ // //===---------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "ProcessFreeBSD.h" #include "ProcessMonitor.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp @@ -7,9 +7,9 @@ // //===---------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h" #include "ProcessFreeBSD.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h" #include "ProcessFreeBSD.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "ProcessFreeBSD.h" #include "ProcessMonitor.h" Index: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp +++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" #include "Plugins/Process/FreeBSD/ProcessMonitor.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -25,8 +25,6 @@ // Other libraries and framework includes #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/PseudoTerminal.h" @@ -41,6 +39,8 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StringExtractor.h" #include "llvm/Support/Errno.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp @@ -9,10 +9,10 @@ #include "NativeRegisterContextLinux.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeThreadProtocol.h" #include "lldb/Host/linux/Ptrace.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -15,9 +15,9 @@ #include "Plugins/Process/Linux/Procfs.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -16,10 +16,10 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -21,12 +21,12 @@ #include "Plugins/Process/Utility/RegisterContextLinux_mips.h" #include "Plugins/Process/Utility/RegisterContextLinux_mips64.h" #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-enumerations.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp @@ -14,10 +14,10 @@ #include "NativeRegisterContextLinux_ppc64le.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp @@ -11,10 +11,10 @@ #include "NativeRegisterContextLinux_s390x.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -11,10 +11,10 @@ #include "NativeRegisterContextLinux_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" Index: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -16,12 +16,12 @@ #include "NativeRegisterContextLinux.h" #include "SingleStepCheck.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostNativeThread.h" #include "lldb/Host/linux/Ptrace.h" #include "lldb/Host/linux/Support.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/SmallString.h" Index: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -18,13 +18,13 @@ // Other libraries and framework includes #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/UUID.h" // Project includes Index: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -19,8 +19,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" -#include "lldb/Utility/UUID.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" @@ -37,7 +35,9 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StringExtractor.h" +#include "lldb/Utility/UUID.h" #include "llvm/Support/Threading.h" Index: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -12,7 +12,6 @@ #include "lldb/Utility/SafeMachO.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -20,6 +19,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "Plugins/Process/Utility/StopInfoMachException.h" Index: lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt =================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt +++ lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt @@ -5,7 +5,6 @@ NativeThreadNetBSD.cpp LINK_LIBS - lldbCore lldbHost lldbSymbol lldbTarget Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -15,12 +15,12 @@ // Other libraries and framework includes #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/common/NativeBreakpoint.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/posix/ProcessLauncherPosixFork.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/State.h" #include "llvm/Support/Errno.h" // System includes - They have to be included after framework includes because Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -11,10 +11,10 @@ #include "NativeRegisterContextNetBSD_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -14,9 +14,9 @@ #include "Plugins/Process/POSIX/CrashReason.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp @@ -12,12 +12,12 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "Plugins/Process/Utility/InstructionUtils.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp @@ -13,14 +13,14 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp @@ -12,12 +12,12 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -14,12 +14,12 @@ // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDummy.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDummy.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDummy.cpp @@ -11,7 +11,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/FuncUnwinders.h" @@ -28,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextDummy.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextHistory.cpp @@ -11,7 +11,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/FuncUnwinders.h" @@ -28,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextHistory.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -10,7 +10,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/ArmUnwindInfo.h" @@ -31,6 +30,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextLLDB.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp @@ -12,11 +12,11 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" // Project includes #include "lldb/Utility/StringExtractorGDBRemote.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp @@ -14,10 +14,10 @@ // Other libraries and framework includes // Project includes #include "DynamicRegisterInfo.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_arm.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_arm64.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_mips64.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp @@ -12,14 +12,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_powerpc.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_ppc64le.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_s390x.h" Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -11,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_x86.h" Index: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -18,7 +18,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostNativeProcessBase.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/windows/HostThreadWindows.h" @@ -28,6 +27,7 @@ #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/State.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Format.h" Index: lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThreadBase.h" #include "lldb/Host/windows/HostThreadWindows.h" @@ -15,6 +14,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" +#include "lldb/Utility/State.h" #include "Plugins/Process/Utility/UnwindLLDB.h" #include "ProcessWindows.h" Index: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-types.h" Index: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-types.h" Index: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -18,7 +18,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Target.h" @@ -26,6 +25,7 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/Threading.h" Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp @@ -9,8 +9,8 @@ #include "RegisterContextPOSIXCore_arm.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp @@ -9,8 +9,8 @@ #include "RegisterContextPOSIXCore_arm64.h" #include "Plugins/Process/elf-core/RegisterUtilities.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp @@ -9,8 +9,8 @@ #include "RegisterContextPOSIXCore_mips64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp @@ -9,9 +9,9 @@ #include "RegisterContextPOSIXCore_powerpc.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp @@ -9,9 +9,9 @@ #include "RegisterContextPOSIXCore_ppc64le.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h" #include "Plugins/Process/elf-core/RegisterUtilities.h" Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp @@ -9,9 +9,9 @@ #include "RegisterContextPOSIXCore_s390x.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -19,7 +19,6 @@ // Other libraries and framework includes #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/XML.h" #include "lldb/Symbol/Symbol.h" @@ -31,6 +30,7 @@ #include "lldb/Utility/JSON.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" // Project includes Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -21,8 +21,6 @@ #include // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Debug.h" #include "lldb/Host/File.h" @@ -41,6 +39,8 @@ #include "lldb/Utility/JSON.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UriParser.h" #include "llvm/ADT/Triple.h" Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -12,12 +12,12 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" // Project includes #include "ProcessGDBRemote.h" Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -34,7 +34,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/DataFormatters/FormatManager.h" @@ -68,6 +67,7 @@ #include "lldb/Utility/Args.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -10,7 +10,6 @@ #include "ThreadGDBRemote.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -20,6 +19,7 @@ #include "lldb/Target/UnixSignals.h" #include "lldb/Target/Unwind.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "ProcessGDBRemote.h" Index: lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -23,7 +23,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" // Project includes #include "ProcessMachCore.h" Index: lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp +++ lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp @@ -12,7 +12,6 @@ #include "lldb/Utility/SafeMachO.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -21,6 +20,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "ProcessMachCore.h" Index: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -16,7 +16,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/SectionLoadList.h" @@ -25,6 +24,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Threading.h" Index: lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp +++ lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp @@ -12,7 +12,7 @@ // Other libraries and framework includes #include "Utility/ARM_DWARF_Registers.h" -#include "lldb/Core/RegisterValue.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/lldb-enumerations.h" Index: lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp +++ lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp @@ -12,7 +12,7 @@ // Other libraries and framework includes #include "Utility/ARM64_DWARF_Registers.h" -#include "lldb/Core/RegisterValue.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/lldb-enumerations.h" Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -17,12 +17,12 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h =================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h @@ -15,9 +15,9 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/UnwindAssembly.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly { Index: lldb/trunk/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp +++ lldb/trunk/source/Symbol/ClangASTContext.cpp @@ -76,7 +76,6 @@ #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Core/UniqueCStringMap.h" @@ -97,6 +96,7 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Scalar.h" #include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h" #include "Plugins/SymbolFile/PDB/PDBASTParser.h" Index: lldb/trunk/source/Symbol/CompilerType.cpp =================================================================== --- lldb/trunk/source/Symbol/CompilerType.cpp +++ lldb/trunk/source/Symbol/CompilerType.cpp @@ -10,7 +10,6 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" @@ -20,6 +19,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" Index: lldb/trunk/source/Symbol/Type.cpp =================================================================== --- lldb/trunk/source/Symbol/Type.cpp +++ lldb/trunk/source/Symbol/Type.cpp @@ -14,9 +14,9 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Symbol/CompilerType.h" Index: lldb/trunk/source/Target/ExecutionContext.cpp =================================================================== --- lldb/trunk/source/Target/ExecutionContext.cpp +++ lldb/trunk/source/Target/ExecutionContext.cpp @@ -12,12 +12,12 @@ // Other libraries and framework includes // Project includes #include "lldb/Target/ExecutionContext.h" -#include "lldb/Core/State.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" using namespace lldb_private; Index: lldb/trunk/source/Target/Memory.cpp =================================================================== --- lldb/trunk/source/Target/Memory.cpp +++ lldb/trunk/source/Target/Memory.cpp @@ -14,10 +14,10 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/RangeMap.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/Process.cpp =================================================================== --- lldb/trunk/source/Target/Process.cpp +++ lldb/trunk/source/Target/Process.cpp @@ -25,7 +25,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRDynamicChecks.h" @@ -70,6 +69,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/SelectHelper.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/RegisterContext.cpp =================================================================== --- lldb/trunk/source/Target/RegisterContext.cpp +++ lldb/trunk/source/Target/RegisterContext.cpp @@ -13,8 +13,6 @@ // Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Target/ExecutionContext.h" @@ -24,6 +22,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/StackFrame.cpp =================================================================== --- lldb/trunk/source/Target/StackFrame.cpp +++ lldb/trunk/source/Target/StackFrame.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/FormatEntity.h" #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -34,6 +33,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/Target.cpp =================================================================== --- lldb/trunk/source/Target/Target.cpp +++ lldb/trunk/source/Target/Target.cpp @@ -29,7 +29,6 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/REPL.h" @@ -58,6 +57,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Target/TargetList.cpp =================================================================== --- lldb/trunk/source/Target/TargetList.cpp +++ lldb/trunk/source/Target/TargetList.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/Event.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -22,6 +21,7 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/TildeExpressionResolver.h" #include "lldb/Utility/Timer.h" Index: lldb/trunk/source/Target/Thread.cpp =================================================================== --- lldb/trunk/source/Target/Thread.cpp +++ lldb/trunk/source/Target/Thread.cpp @@ -18,7 +18,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" @@ -49,6 +48,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-enumerations.h" Index: lldb/trunk/source/Target/ThreadList.cpp =================================================================== --- lldb/trunk/source/Target/ThreadList.cpp +++ lldb/trunk/source/Target/ThreadList.cpp @@ -15,7 +15,6 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" @@ -23,6 +22,7 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/ThreadPlan.cpp =================================================================== --- lldb/trunk/source/Target/ThreadPlan.cpp +++ lldb/trunk/source/Target/ThreadPlan.cpp @@ -13,12 +13,12 @@ // Project includes #include "lldb/Target/ThreadPlan.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/ThreadPlanPython.cpp =================================================================== --- lldb/trunk/source/Target/ThreadPlanPython.cpp +++ lldb/trunk/source/Target/ThreadPlanPython.cpp @@ -14,7 +14,6 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Process.h" @@ -24,6 +23,7 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanPython.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Target/ThreadPlanTracer.cpp =================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/TypeList.h" @@ -30,6 +29,7 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; Index: lldb/trunk/source/Utility/CMakeLists.txt =================================================================== --- lldb/trunk/source/Utility/CMakeLists.txt +++ lldb/trunk/source/Utility/CMakeLists.txt @@ -60,9 +60,12 @@ Logging.cpp NameMatches.cpp Range.cpp + RegisterValue.cpp RegularExpression.cpp + Scalar.cpp SelectHelper.cpp SharingPtr.cpp + State.cpp Status.cpp Stream.cpp StreamCallback.cpp Index: lldb/trunk/source/Utility/RegisterValue.cpp =================================================================== --- lldb/trunk/source/Utility/RegisterValue.cpp +++ lldb/trunk/source/Utility/RegisterValue.cpp @@ -0,0 +1,905 @@ +//===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/RegisterValue.h" + +#include "lldb/Utility/Args.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS +#include "lldb/lldb-private-types.h" // for RegisterInfo, type128 + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" + +#include // for uint8_t, uint32_t, uint64_t +#include // for string +#include // for tie, tuple +#include + +#include // for assert +#include // for PRIx64 +#include // for sscanf + +using namespace lldb; +using namespace lldb_private; + +bool RegisterValue::GetData(DataExtractor &data) const { + return data.SetData(GetBytes(), GetByteSize(), GetByteOrder()) > 0; +} + +uint32_t RegisterValue::GetAsMemoryData(const RegisterInfo *reg_info, void *dst, + uint32_t dst_len, + lldb::ByteOrder dst_byte_order, + Status &error) const { + if (reg_info == nullptr) { + error.SetErrorString("invalid register info argument."); + return 0; + } + + // ReadRegister should have already been called on this object prior to + // calling this. + if (GetType() == eTypeInvalid) { + // No value has been read into this object... + error.SetErrorStringWithFormat( + "invalid register value type for register %s", reg_info->name); + return 0; + } + + if (dst_len > kMaxRegisterByteSize) { + error.SetErrorString("destination is too big"); + return 0; + } + + const uint32_t src_len = reg_info->byte_size; + + // Extract the register data into a data extractor + DataExtractor reg_data; + if (!GetData(reg_data)) { + error.SetErrorString("invalid register value to copy into"); + return 0; + } + + // Prepare a memory buffer that contains some or all of the register value + const uint32_t bytes_copied = + reg_data.CopyByteOrderedData(0, // src offset + src_len, // src length + dst, // dst buffer + dst_len, // dst length + dst_byte_order); // dst byte order + if (bytes_copied == 0) + error.SetErrorStringWithFormat( + "failed to copy data for register write of %s", reg_info->name); + + return bytes_copied; +} + +uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo *reg_info, + const void *src, uint32_t src_len, + lldb::ByteOrder src_byte_order, + Status &error) { + if (reg_info == nullptr) { + error.SetErrorString("invalid register info argument."); + return 0; + } + + // Moving from addr into a register + // + // Case 1: src_len == dst_len + // + // |AABBCCDD| Address contents + // |AABBCCDD| Register contents + // + // Case 2: src_len > dst_len + // + // Status! (The register should always be big enough to hold the data) + // + // Case 3: src_len < dst_len + // + // |AABB| Address contents + // |AABB0000| Register contents [on little-endian hardware] + // |0000AABB| Register contents [on big-endian hardware] + if (src_len > kMaxRegisterByteSize) { + error.SetErrorStringWithFormat( + "register buffer is too small to receive %u bytes of data.", src_len); + return 0; + } + + const uint32_t dst_len = reg_info->byte_size; + + if (src_len > dst_len) { + error.SetErrorStringWithFormat( + "%u bytes is too big to store in register %s (%u bytes)", src_len, + reg_info->name, dst_len); + return 0; + } + + // Use a data extractor to correctly copy and pad the bytes read into the + // register value + DataExtractor src_data(src, src_len, src_byte_order, 4); + + error = SetValueFromData(reg_info, src_data, 0, true); + if (error.Fail()) + return 0; + + // If SetValueFromData succeeded, we must have copied all of src_len + return src_len; +} + +bool RegisterValue::GetScalarValue(Scalar &scalar) const { + switch (m_type) { + case eTypeInvalid: + break; + case eTypeBytes: { + switch (buffer.length) { + default: + break; + case 1: + scalar = *(const uint8_t *)buffer.bytes; + return true; + case 2: + scalar = *(const uint16_t *)buffer.bytes; + return true; + case 4: + scalar = *(const uint32_t *)buffer.bytes; + return true; + case 8: + scalar = *(const uint64_t *)buffer.bytes; + return true; + case 16: + case 32: + if (buffer.length % sizeof(uint64_t) == 0) { + const auto length_in_bits = buffer.length * 8; + const auto length_in_uint64 = buffer.length / sizeof(uint64_t); + scalar = + llvm::APInt(length_in_bits, + llvm::ArrayRef((const uint64_t *)buffer.bytes, + length_in_uint64)); + return true; + } + break; + } + } break; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + scalar = m_scalar; + return true; + } + return false; +} + +void RegisterValue::Clear() { m_type = eTypeInvalid; } + +RegisterValue::Type RegisterValue::SetType(const RegisterInfo *reg_info) { + // To change the type, we simply copy the data in again, using the new format + RegisterValue copy; + DataExtractor copy_data; + if (copy.CopyValue(*this) && copy.GetData(copy_data)) + SetValueFromData(reg_info, copy_data, 0, true); + + return m_type; +} + +Status RegisterValue::SetValueFromData(const RegisterInfo *reg_info, + DataExtractor &src, + lldb::offset_t src_offset, + bool partial_data_ok) { + Status error; + + if (src.GetByteSize() == 0) { + error.SetErrorString("empty data."); + return error; + } + + if (reg_info->byte_size == 0) { + error.SetErrorString("invalid register info."); + return error; + } + + uint32_t src_len = src.GetByteSize() - src_offset; + + if (!partial_data_ok && (src_len < reg_info->byte_size)) { + error.SetErrorString("not enough data."); + return error; + } + + // Cap the data length if there is more than enough bytes for this register + // value + if (src_len > reg_info->byte_size) + src_len = reg_info->byte_size; + + // Zero out the value in case we get partial data... + memset(buffer.bytes, 0, sizeof(buffer.bytes)); + + type128 int128; + + m_type = eTypeInvalid; + switch (reg_info->encoding) { + case eEncodingInvalid: + break; + case eEncodingUint: + case eEncodingSint: + if (reg_info->byte_size == 1) + SetUInt8(src.GetMaxU32(&src_offset, src_len)); + else if (reg_info->byte_size <= 2) + SetUInt16(src.GetMaxU32(&src_offset, src_len)); + else if (reg_info->byte_size <= 4) + SetUInt32(src.GetMaxU32(&src_offset, src_len)); + else if (reg_info->byte_size <= 8) + SetUInt64(src.GetMaxU64(&src_offset, src_len)); + else if (reg_info->byte_size <= 16) { + uint64_t data1 = src.GetU64(&src_offset); + uint64_t data2 = src.GetU64(&src_offset); + if (src.GetByteSize() == eByteOrderBig) { + int128.x[0] = data1; + int128.x[1] = data2; + } else { + int128.x[0] = data2; + int128.x[1] = data1; + } + SetUInt128(llvm::APInt(128, 2, int128.x)); + } + break; + case eEncodingIEEE754: + if (reg_info->byte_size == sizeof(float)) + SetFloat(src.GetFloat(&src_offset)); + else if (reg_info->byte_size == sizeof(double)) + SetDouble(src.GetDouble(&src_offset)); + else if (reg_info->byte_size == sizeof(long double)) + SetLongDouble(src.GetLongDouble(&src_offset)); + break; + case eEncodingVector: { + m_type = eTypeBytes; + buffer.length = reg_info->byte_size; + buffer.byte_order = src.GetByteOrder(); + assert(buffer.length <= kMaxRegisterByteSize); + if (buffer.length > kMaxRegisterByteSize) + buffer.length = kMaxRegisterByteSize; + if (src.CopyByteOrderedData( + src_offset, // offset within "src" to start extracting data + src_len, // src length + buffer.bytes, // dst buffer + buffer.length, // dst length + buffer.byte_order) == 0) // dst byte order + { + error.SetErrorStringWithFormat( + "failed to copy data for register write of %s", reg_info->name); + return error; + } + } + } + + if (m_type == eTypeInvalid) + error.SetErrorStringWithFormat( + "invalid register value type for register %s", reg_info->name); + return error; +} + +// Helper function for RegisterValue::SetValueFromString() +static bool ParseVectorEncoding(const RegisterInfo *reg_info, + llvm::StringRef vector_str, + const uint32_t byte_size, + RegisterValue *reg_value) { + // Example: vector_str = "{0x2c 0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a + // 0x2a 0x3e 0x84 0x4f 0x2a 0x3e}". + vector_str = vector_str.trim(); + vector_str.consume_front("{"); + vector_str.consume_back("}"); + vector_str = vector_str.trim(); + + char Sep = ' '; + + // The first split should give us: + // ('0x2c', '0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a 0x2a 0x3e 0x84 0x4f + // 0x2a 0x3e'). + llvm::StringRef car; + llvm::StringRef cdr = vector_str; + std::tie(car, cdr) = vector_str.split(Sep); + std::vector bytes; + unsigned byte = 0; + + // Using radix auto-sensing by passing 0 as the radix. Keep on processing the + // vector elements as long as the parsing succeeds and the vector size is < + // byte_size. + while (!car.getAsInteger(0, byte) && bytes.size() < byte_size) { + bytes.push_back(byte); + std::tie(car, cdr) = cdr.split(Sep); + } + + // Check for vector of exact byte_size elements. + if (bytes.size() != byte_size) + return false; + + reg_value->SetBytes(&(bytes.front()), byte_size, eByteOrderLittle); + return true; +} + +Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, + llvm::StringRef value_str) { + Status error; + if (reg_info == nullptr) { + error.SetErrorString("Invalid register info argument."); + return error; + } + + m_type = eTypeInvalid; + if (value_str.empty()) { + error.SetErrorString("Invalid c-string value string."); + return error; + } + const uint32_t byte_size = reg_info->byte_size; + + uint64_t uval64; + int64_t ival64; + float flt_val; + double dbl_val; + long double ldbl_val; + switch (reg_info->encoding) { + case eEncodingInvalid: + error.SetErrorString("Invalid encoding."); + break; + + case eEncodingUint: + if (byte_size > sizeof(uint64_t)) { + error.SetErrorStringWithFormat( + "unsupported unsigned integer byte size: %u", byte_size); + break; + } + if (value_str.getAsInteger(0, uval64)) { + error.SetErrorStringWithFormat( + "'%s' is not a valid unsigned integer string value", + value_str.str().c_str()); + break; + } + + if (!Args::UInt64ValueIsValidForByteSize(uval64, byte_size)) { + error.SetErrorStringWithFormat( + "value 0x%" PRIx64 + " is too large to fit in a %u byte unsigned integer value", + uval64, byte_size); + break; + } + + if (!SetUInt(uval64, reg_info->byte_size)) { + error.SetErrorStringWithFormat( + "unsupported unsigned integer byte size: %u", byte_size); + break; + } + // TODO: Shouldn't we be setting m_type here? + break; + + case eEncodingSint: + if (byte_size > sizeof(long long)) { + error.SetErrorStringWithFormat("unsupported signed integer byte size: %u", + byte_size); + break; + } + + if (value_str.getAsInteger(0, ival64)) { + error.SetErrorStringWithFormat( + "'%s' is not a valid signed integer string value", + value_str.str().c_str()); + break; + } + + if (!Args::SInt64ValueIsValidForByteSize(ival64, byte_size)) { + error.SetErrorStringWithFormat( + "value 0x%" PRIx64 + " is too large to fit in a %u byte signed integer value", + ival64, byte_size); + break; + } + + if (!SetUInt(ival64, reg_info->byte_size)) { + error.SetErrorStringWithFormat("unsupported signed integer byte size: %u", + byte_size); + break; + } + + // TODO: Shouldn't we be setting m_type here? + break; + + case eEncodingIEEE754: { + std::string value_string = value_str; + if (byte_size == sizeof(float)) { + if (::sscanf(value_string.c_str(), "%f", &flt_val) != 1) { + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_string.c_str()); + break; + } + m_scalar = flt_val; + m_type = eTypeFloat; + } else if (byte_size == sizeof(double)) { + if (::sscanf(value_string.c_str(), "%lf", &dbl_val) != 1) { + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_string.c_str()); + break; + } + m_scalar = dbl_val; + m_type = eTypeDouble; + } else if (byte_size == sizeof(long double)) { + if (::sscanf(value_string.c_str(), "%Lf", &ldbl_val) != 1) { + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_string.c_str()); + break; + } + m_scalar = ldbl_val; + m_type = eTypeLongDouble; + } else { + error.SetErrorStringWithFormat("unsupported float byte size: %u", + byte_size); + return error; + } + break; + } + case eEncodingVector: + if (!ParseVectorEncoding(reg_info, value_str, byte_size, this)) + error.SetErrorString("unrecognized vector encoding string value."); + break; + } + + return error; +} + +bool RegisterValue::SignExtend(uint32_t sign_bitpos) { + switch (m_type) { + case eTypeInvalid: + break; + + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + return m_scalar.SignExtend(sign_bitpos); + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + case eTypeBytes: + break; + } + return false; +} + +bool RegisterValue::CopyValue(const RegisterValue &rhs) { + if (this == &rhs) + return rhs.m_type == eTypeInvalid ? false : true; + + m_type = rhs.m_type; + switch (m_type) { + case eTypeInvalid: + return false; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + m_scalar = rhs.m_scalar; + break; + case eTypeBytes: + assert(rhs.buffer.length <= kMaxRegisterByteSize); + ::memcpy(buffer.bytes, rhs.buffer.bytes, kMaxRegisterByteSize); + buffer.length = rhs.buffer.length; + buffer.byte_order = rhs.buffer.byte_order; + break; + } + return true; +} + +uint16_t RegisterValue::GetAsUInt16(uint16_t fail_value, + bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + + switch (m_type) { + default: + break; + case eTypeUInt8: + case eTypeUInt16: + return m_scalar.UShort(fail_value); + case eTypeBytes: { + switch (buffer.length) { + default: + break; + case 1: + case 2: + return *(const uint16_t *)buffer.bytes; + } + } break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +uint32_t RegisterValue::GetAsUInt32(uint32_t fail_value, + bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.UInt(fail_value); + case eTypeBytes: { + switch (buffer.length) { + default: + break; + case 1: + case 2: + case 4: + return *(const uint32_t *)buffer.bytes; + } + } break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +uint64_t RegisterValue::GetAsUInt64(uint64_t fail_value, + bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.ULongLong(fail_value); + case eTypeBytes: { + switch (buffer.length) { + default: + break; + case 1: + return *(const uint8_t *)buffer.bytes; + case 2: + return *(const uint16_t *)buffer.bytes; + case 4: + return *(const uint32_t *)buffer.bytes; + case 8: + return *(const uint64_t *)buffer.bytes; + } + } break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value, + bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.UInt128(fail_value); + case eTypeBytes: { + switch (buffer.length) { + default: + break; + case 1: + case 2: + case 4: + case 8: + case 16: + return llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + ((const type128 *)buffer.bytes)->x); + } + } break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.Float(fail_value); + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.Double(fail_value); + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +long double RegisterValue::GetAsLongDouble(long double fail_value, + bool *success_ptr) const { + if (success_ptr) + *success_ptr = true; + switch (m_type) { + default: + break; + + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.LongDouble(); + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +const void *RegisterValue::GetBytes() const { + switch (m_type) { + case eTypeInvalid: + break; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.GetBytes(); + case eTypeBytes: + return buffer.bytes; + } + return nullptr; +} + +uint32_t RegisterValue::GetByteSize() const { + switch (m_type) { + case eTypeInvalid: + break; + case eTypeUInt8: + return 1; + case eTypeUInt16: + return 2; + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar.GetByteSize(); + case eTypeBytes: + return buffer.length; + } + return 0; +} + +bool RegisterValue::SetUInt(uint64_t uint, uint32_t byte_size) { + if (byte_size == 0) { + SetUInt64(uint); + } else if (byte_size == 1) { + SetUInt8(uint); + } else if (byte_size <= 2) { + SetUInt16(uint); + } else if (byte_size <= 4) { + SetUInt32(uint); + } else if (byte_size <= 8) { + SetUInt64(uint); + } else if (byte_size <= 16) { + SetUInt128(llvm::APInt(128, uint)); + } else + return false; + return true; +} + +void RegisterValue::SetBytes(const void *bytes, size_t length, + lldb::ByteOrder byte_order) { + // If this assertion fires off we need to increase the size of buffer.bytes, + // or make it something that is allocated on the heap. Since the data buffer + // is in a union, we can't make it a collection class like SmallVector... + if (bytes && length > 0) { + assert(length <= sizeof(buffer.bytes) && + "Storing too many bytes in a RegisterValue."); + m_type = eTypeBytes; + buffer.length = length; + memcpy(buffer.bytes, bytes, length); + buffer.byte_order = byte_order; + } else { + m_type = eTypeInvalid; + buffer.length = 0; + } +} + +bool RegisterValue::operator==(const RegisterValue &rhs) const { + if (m_type == rhs.m_type) { + switch (m_type) { + case eTypeInvalid: + return true; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar == rhs.m_scalar; + case eTypeBytes: + if (buffer.length != rhs.buffer.length) + return false; + else { + uint8_t length = buffer.length; + if (length > kMaxRegisterByteSize) + length = kMaxRegisterByteSize; + return memcmp(buffer.bytes, rhs.buffer.bytes, length) == 0; + } + break; + } + } + return false; +} + +bool RegisterValue::operator!=(const RegisterValue &rhs) const { + if (m_type != rhs.m_type) + return true; + switch (m_type) { + case eTypeInvalid: + return false; + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + return m_scalar != rhs.m_scalar; + case eTypeBytes: + if (buffer.length != rhs.buffer.length) { + return true; + } else { + uint8_t length = buffer.length; + if (length > kMaxRegisterByteSize) + length = kMaxRegisterByteSize; + return memcmp(buffer.bytes, rhs.buffer.bytes, length) != 0; + } + break; + } + return true; +} + +bool RegisterValue::ClearBit(uint32_t bit) { + switch (m_type) { + case eTypeInvalid: + break; + + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + if (bit < (GetByteSize() * 8)) { + return m_scalar.ClearBit(bit); + } + break; + + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + break; + + case eTypeBytes: + if (buffer.byte_order == eByteOrderBig || + buffer.byte_order == eByteOrderLittle) { + uint32_t byte_idx; + if (buffer.byte_order == eByteOrderBig) + byte_idx = buffer.length - (bit / 8) - 1; + else + byte_idx = bit / 8; + + const uint32_t byte_bit = bit % 8; + if (byte_idx < buffer.length) { + buffer.bytes[byte_idx] &= ~(1u << byte_bit); + return true; + } + } + break; + } + return false; +} + +bool RegisterValue::SetBit(uint32_t bit) { + switch (m_type) { + case eTypeInvalid: + break; + + case eTypeUInt8: + case eTypeUInt16: + case eTypeUInt32: + case eTypeUInt64: + case eTypeUInt128: + if (bit < (GetByteSize() * 8)) { + return m_scalar.SetBit(bit); + } + break; + + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + break; + + case eTypeBytes: + if (buffer.byte_order == eByteOrderBig || + buffer.byte_order == eByteOrderLittle) { + uint32_t byte_idx; + if (buffer.byte_order == eByteOrderBig) + byte_idx = buffer.length - (bit / 8) - 1; + else + byte_idx = bit / 8; + + const uint32_t byte_bit = bit % 8; + if (byte_idx < buffer.length) { + buffer.bytes[byte_idx] |= (1u << byte_bit); + return true; + } + } + break; + } + return false; +} Index: lldb/trunk/source/Utility/Scalar.cpp =================================================================== --- lldb/trunk/source/Utility/Scalar.cpp +++ lldb/trunk/source/Utility/Scalar.cpp @@ -0,0 +1,2852 @@ +//===-- Scalar.cpp ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/Scalar.h" + +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-types.h" // for offset_t + +#include "llvm/ADT/SmallString.h" + +#include +#include + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Promote to max type currently follows the ANSI C rule for type promotion in +// expressions. +//---------------------------------------------------------------------- +static Scalar::Type PromoteToMaxType( + const Scalar &lhs, // The const left hand side object + const Scalar &rhs, // The const right hand side object + Scalar &temp_value, // A modifiable temp value than can be used to hold + // either the promoted lhs or rhs object + const Scalar *&promoted_lhs_ptr, // Pointer to the resulting possibly + // promoted value of lhs (at most one of + // lhs/rhs will get promoted) + const Scalar *&promoted_rhs_ptr // Pointer to the resulting possibly + // promoted value of rhs (at most one of + // lhs/rhs will get promoted) +) { + Scalar result; + // Initialize the promoted values for both the right and left hand side + // values to be the objects themselves. If no promotion is needed (both right + // and left have the same type), then the temp_value will not get used. + promoted_lhs_ptr = &lhs; + promoted_rhs_ptr = &rhs; + // Extract the types of both the right and left hand side values + Scalar::Type lhs_type = lhs.GetType(); + Scalar::Type rhs_type = rhs.GetType(); + + if (lhs_type > rhs_type) { + // Right hand side need to be promoted + temp_value = rhs; // Copy right hand side into the temp value + if (temp_value.Promote(lhs_type)) // Promote it + promoted_rhs_ptr = + &temp_value; // Update the pointer for the promoted right hand side + } else if (lhs_type < rhs_type) { + // Left hand side need to be promoted + temp_value = lhs; // Copy left hand side value into the temp value + if (temp_value.Promote(rhs_type)) // Promote it + promoted_lhs_ptr = + &temp_value; // Update the pointer for the promoted left hand side + } + + // Make sure our type promotion worked as expected + if (promoted_lhs_ptr->GetType() == promoted_rhs_ptr->GetType()) + return promoted_lhs_ptr->GetType(); // Return the resulting max type + + // Return the void type (zero) if we fail to promote either of the values. + return Scalar::e_void; +} + +Scalar::Scalar() : m_type(e_void), m_float((float)0) {} + +Scalar::Scalar(const Scalar &rhs) + : m_type(rhs.m_type), m_integer(rhs.m_integer), m_float(rhs.m_float) {} + +// Scalar::Scalar(const RegisterValue& reg) : +// m_type(e_void), +// m_data() +//{ +// switch (reg.info.encoding) +// { +// case eEncodingUint: // unsigned integer +// switch (reg.info.byte_size) +// { +// case 1: m_type = e_uint; m_data.uint = reg.value.uint8; break; +// case 2: m_type = e_uint; m_data.uint = reg.value.uint16; break; +// case 4: m_type = e_uint; m_data.uint = reg.value.uint32; break; +// case 8: m_type = e_ulonglong; m_data.ulonglong = reg.value.uint64; +// break; +// break; +// } +// break; +// +// case eEncodingSint: // signed integer +// switch (reg.info.byte_size) +// { +// case 1: m_type = e_sint; m_data.sint = reg.value.sint8; break; +// case 2: m_type = e_sint; m_data.sint = reg.value.sint16; break; +// case 4: m_type = e_sint; m_data.sint = reg.value.sint32; break; +// case 8: m_type = e_slonglong; m_data.slonglong = reg.value.sint64; +// break; +// break; +// } +// break; +// +// case eEncodingIEEE754: // float +// switch (reg.info.byte_size) +// { +// case 4: m_type = e_float; m_data.flt = reg.value.float32; break; +// case 8: m_type = e_double; m_data.dbl = reg.value.float64; break; +// break; +// } +// break; +// case eEncodingVector: // vector registers +// break; +// } +//} + +bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const { + size_t byte_size = GetByteSize(); + if (byte_size > 0) { + const uint8_t *bytes = reinterpret_cast(GetBytes()); + + if (limit_byte_size < byte_size) { + if (endian::InlHostByteOrder() == eByteOrderLittle) { + // On little endian systems if we want fewer bytes from the current + // type we just specify fewer bytes since the LSByte is first... + byte_size = limit_byte_size; + } else if (endian::InlHostByteOrder() == eByteOrderBig) { + // On big endian systems if we want fewer bytes from the current type + // have to advance our initial byte pointer and trim down the number of + // bytes since the MSByte is first + bytes += byte_size - limit_byte_size; + byte_size = limit_byte_size; + } + } + + data.SetData(bytes, byte_size, endian::InlHostByteOrder()); + return true; + } + data.Clear(); + return false; +} + +const void *Scalar::GetBytes() const { + const uint64_t *apint_words; + const uint8_t *bytes; + static float_t flt_val; + static double_t dbl_val; + static uint64_t swapped_words[4]; + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + bytes = reinterpret_cast(m_integer.getRawData()); + // getRawData always returns a pointer to an uint64_t. If we have a + // smaller type, we need to update the pointer on big-endian systems. + if (endian::InlHostByteOrder() == eByteOrderBig) { + size_t byte_size = m_integer.getBitWidth() / 8; + if (byte_size < 8) + bytes += 8 - byte_size; + } + return bytes; + case e_sint128: + case e_uint128: + apint_words = m_integer.getRawData(); + // getRawData always returns a pointer to an array of two uint64_t values, + // where the least-significant word always comes first. On big-endian + // systems we need to swap the two words. + if (endian::InlHostByteOrder() == eByteOrderBig) { + swapped_words[0] = apint_words[1]; + swapped_words[1] = apint_words[0]; + apint_words = swapped_words; + } + return reinterpret_cast(apint_words); + case e_sint256: + case e_uint256: + apint_words = m_integer.getRawData(); + // getRawData always returns a pointer to an array of four uint64_t values, + // where the least-significant word always comes first. On big-endian + // systems we need to swap the four words. + if (endian::InlHostByteOrder() == eByteOrderBig) { + swapped_words[0] = apint_words[3]; + swapped_words[1] = apint_words[2]; + swapped_words[2] = apint_words[1]; + swapped_words[3] = apint_words[0]; + apint_words = swapped_words; + } + return reinterpret_cast(apint_words); + case e_float: + flt_val = m_float.convertToFloat(); + return reinterpret_cast(&flt_val); + case e_double: + dbl_val = m_float.convertToDouble(); + return reinterpret_cast(&dbl_val); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + apint_words = ldbl_val.getRawData(); + // getRawData always returns a pointer to an array of two uint64_t values, + // where the least-significant word always comes first. On big-endian + // systems we need to swap the two words. + if (endian::InlHostByteOrder() == eByteOrderBig) { + swapped_words[0] = apint_words[1]; + swapped_words[1] = apint_words[0]; + apint_words = swapped_words; + } + return reinterpret_cast(apint_words); + } + return nullptr; +} + +size_t Scalar::GetByteSize() const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (m_integer.getBitWidth() / 8); + case e_float: + return sizeof(float_t); + case e_double: + return sizeof(double_t); + case e_long_double: + return sizeof(long_double_t); + } + return 0; +} + +bool Scalar::IsZero() const { + llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8); + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return llvm::APInt::isSameValue(zero_int, m_integer); + case e_float: + case e_double: + case e_long_double: + return m_float.isZero(); + } + return false; +} + +void Scalar::GetValue(Stream *s, bool show_type) const { + if (show_type) + s->Printf("(%s) ", GetTypeAsCString()); + + switch (m_type) { + case e_void: + break; + case e_sint: + case e_slong: + case e_slonglong: + case e_sint128: + case e_sint256: + s->PutCString(m_integer.toString(10, true)); + break; + case e_uint: + case e_ulong: + case e_ulonglong: + case e_uint128: + case e_uint256: + s->PutCString(m_integer.toString(10, false)); + break; + case e_float: + case e_double: + case e_long_double: + llvm::SmallString<24> string; + m_float.toString(string); + s->Printf("%s", string.c_str()); + break; + } +} + +const char *Scalar::GetTypeAsCString() const { + switch (m_type) { + case e_void: + return "void"; + case e_sint: + return "int"; + case e_uint: + return "unsigned int"; + case e_slong: + return "long"; + case e_ulong: + return "unsigned long"; + case e_slonglong: + return "long long"; + case e_ulonglong: + return "unsigned long long"; + case e_sint128: + return "int128_t"; + case e_uint128: + return "unsigned int128_t"; + case e_sint256: + return "int256_t"; + case e_uint256: + return "unsigned int256_t"; + case e_float: + return "float"; + case e_double: + return "double"; + case e_long_double: + return "long double"; + } + return ""; +} + +Scalar &Scalar::operator=(const Scalar &rhs) { + if (this != &rhs) { + m_type = rhs.m_type; + m_integer = llvm::APInt(rhs.m_integer); + m_float = rhs.m_float; + } + return *this; +} + +Scalar &Scalar::operator=(const int v) { + m_type = e_sint; + m_integer = llvm::APInt(sizeof(int) * 8, v, true); + return *this; +} + +Scalar &Scalar::operator=(unsigned int v) { + m_type = e_uint; + m_integer = llvm::APInt(sizeof(int) * 8, v); + return *this; +} + +Scalar &Scalar::operator=(long v) { + m_type = e_slong; + m_integer = llvm::APInt(sizeof(long) * 8, v, true); + return *this; +} + +Scalar &Scalar::operator=(unsigned long v) { + m_type = e_ulong; + m_integer = llvm::APInt(sizeof(long) * 8, v); + return *this; +} + +Scalar &Scalar::operator=(long long v) { + m_type = e_slonglong; + m_integer = llvm::APInt(sizeof(long) * 8, v, true); + return *this; +} + +Scalar &Scalar::operator=(unsigned long long v) { + m_type = e_ulonglong; + m_integer = llvm::APInt(sizeof(long long) * 8, v); + return *this; +} + +Scalar &Scalar::operator=(float v) { + m_type = e_float; + m_float = llvm::APFloat(v); + return *this; +} + +Scalar &Scalar::operator=(double v) { + m_type = e_double; + m_float = llvm::APFloat(v); + return *this; +} + +Scalar &Scalar::operator=(long double v) { + m_type = e_long_double; + if (m_ieee_quad) + m_float = llvm::APFloat( + llvm::APFloat::IEEEquad(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + else + m_float = llvm::APFloat( + llvm::APFloat::x87DoubleExtended(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + return *this; +} + +Scalar &Scalar::operator=(llvm::APInt rhs) { + m_integer = llvm::APInt(rhs); + switch (m_integer.getBitWidth()) { + case 8: + case 16: + case 32: + if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) + m_type = e_sint; + else + m_type = e_uint; + break; + case 64: + if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) + m_type = e_slonglong; + else + m_type = e_ulonglong; + break; + case 128: + if (m_integer.isSignedIntN(BITWIDTH_INT128)) + m_type = e_sint128; + else + m_type = e_uint128; + break; + case 256: + if (m_integer.isSignedIntN(BITWIDTH_INT256)) + m_type = e_sint256; + else + m_type = e_uint256; + break; + } + return *this; +} + +Scalar::~Scalar() = default; + +bool Scalar::Promote(Scalar::Type type) { + bool success = false; + switch (m_type) { + case e_void: + break; + + case e_sint: + switch (type) { + case e_void: + break; + case e_sint: + success = true; + break; + case e_uint: + m_integer = m_integer.sextOrTrunc(sizeof(uint_t) * 8); + success = true; + break; + + case e_slong: + m_integer = m_integer.sextOrTrunc(sizeof(slong_t) * 8); + success = true; + break; + + case e_ulong: + m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8); + success = true; + break; + + case e_slonglong: + m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8); + success = true; + break; + + case e_ulonglong: + m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); + success = true; + break; + + case e_sint128: + case e_uint128: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_uint: + switch (type) { + case e_void: + case e_sint: + break; + case e_uint: + success = true; + break; + case e_slong: + m_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8); + success = true; + break; + + case e_ulong: + m_integer = m_integer.zextOrTrunc(sizeof(ulong_t) * 8); + success = true; + break; + + case e_slonglong: + m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8); + success = true; + break; + + case e_ulonglong: + m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8); + success = true; + break; + + case e_sint128: + case e_uint128: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_slong: + switch (type) { + case e_void: + case e_sint: + case e_uint: + break; + case e_slong: + success = true; + break; + case e_ulong: + m_integer = m_integer.sextOrTrunc(sizeof(ulong_t) * 8); + success = true; + break; + + case e_slonglong: + m_integer = m_integer.sextOrTrunc(sizeof(slonglong_t) * 8); + success = true; + break; + + case e_ulonglong: + m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); + success = true; + break; + + case e_sint128: + case e_uint128: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_ulong: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + break; + case e_ulong: + success = true; + break; + case e_slonglong: + m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8); + success = true; + break; + + case e_ulonglong: + m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8); + success = true; + break; + + case e_sint128: + case e_uint128: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_slonglong: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + break; + case e_slonglong: + success = true; + break; + case e_ulonglong: + m_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8); + success = true; + break; + + case e_sint128: + case e_uint128: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_ulonglong: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + break; + case e_ulonglong: + success = true; + break; + case e_sint128: + case e_uint128: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_sint128: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + break; + case e_sint128: + success = true; + break; + case e_uint128: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128); + success = true; + break; + + case e_sint256: + case e_uint256: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_uint128: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + break; + case e_uint128: + success = true; + break; + case e_sint256: + case e_uint256: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_sint256: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + break; + case e_sint256: + success = true; + break; + case e_uint256: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256); + success = true; + break; + + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, true, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_uint256: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + break; + case e_uint256: + success = true; + break; + case e_float: + m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_double: + m_float = llvm::APFloat(llvm::APFloat::IEEEdouble()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + + case e_long_double: + m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended()); + m_float.convertFromAPInt(m_integer, false, + llvm::APFloat::rmNearestTiesToEven); + success = true; + break; + } + break; + + case e_float: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + break; + case e_float: + success = true; + break; + case e_double: + m_float = llvm::APFloat((double_t)m_float.convertToFloat()); + success = true; + break; + + case e_long_double: { + bool ignore; + m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended(), + llvm::APFloat::rmNearestTiesToEven, &ignore); + success = true; + break; + } + } + break; + + case e_double: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + case e_float: + break; + case e_double: + success = true; + break; + case e_long_double: { + bool ignore; + m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad() + : llvm::APFloat::x87DoubleExtended(), + llvm::APFloat::rmNearestTiesToEven, &ignore); + success = true; + break; + } + } + break; + + case e_long_double: + switch (type) { + case e_void: + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + case e_float: + case e_double: + break; + case e_long_double: + success = true; + break; + } + break; + } + + if (success) + m_type = type; + return success; +} + +const char *Scalar::GetValueTypeAsCString(Scalar::Type type) { + switch (type) { + case e_void: + return "void"; + case e_sint: + return "int"; + case e_uint: + return "unsigned int"; + case e_slong: + return "long"; + case e_ulong: + return "unsigned long"; + case e_slonglong: + return "long long"; + case e_ulonglong: + return "unsigned long long"; + case e_float: + return "float"; + case e_double: + return "double"; + case e_long_double: + return "long double"; + case e_sint128: + return "int128_t"; + case e_uint128: + return "uint128_t"; + case e_sint256: + return "int256_t"; + case e_uint256: + return "uint256_t"; + } + return "???"; +} + +Scalar::Type +Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) { + if (byte_size <= sizeof(sint_t)) + return e_sint; + if (byte_size <= sizeof(slong_t)) + return e_slong; + if (byte_size <= sizeof(slonglong_t)) + return e_slonglong; + return e_void; +} + +Scalar::Type +Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) { + if (byte_size <= sizeof(uint_t)) + return e_uint; + if (byte_size <= sizeof(ulong_t)) + return e_ulong; + if (byte_size <= sizeof(ulonglong_t)) + return e_ulonglong; + return e_void; +} + +Scalar::Type Scalar::GetValueTypeForFloatWithByteSize(size_t byte_size) { + if (byte_size == sizeof(float_t)) + return e_float; + if (byte_size == sizeof(double_t)) + return e_double; + if (byte_size == sizeof(long_double_t)) + return e_long_double; + return e_void; +} + +bool Scalar::MakeSigned() { + bool success = false; + + switch (m_type) { + case e_void: + break; + case e_sint: + success = true; + break; + case e_uint: + m_type = e_sint; + success = true; + break; + case e_slong: + success = true; + break; + case e_ulong: + m_type = e_slong; + success = true; + break; + case e_slonglong: + success = true; + break; + case e_ulonglong: + m_type = e_slonglong; + success = true; + break; + case e_sint128: + success = true; + break; + case e_uint128: + m_type = e_sint128; + success = true; + break; + case e_sint256: + success = true; + break; + case e_uint256: + m_type = e_sint256; + success = true; + break; + case e_float: + success = true; + break; + case e_double: + success = true; + break; + case e_long_double: + success = true; + break; + } + + return success; +} + +bool Scalar::MakeUnsigned() { + bool success = false; + + switch (m_type) { + case e_void: + break; + case e_sint: + m_type = e_uint; + success = true; + break; + case e_uint: + success = true; + break; + case e_slong: + m_type = e_ulong; + success = true; + break; + case e_ulong: + success = true; + break; + case e_slonglong: + m_type = e_ulonglong; + success = true; + break; + case e_ulonglong: + success = true; + break; + case e_sint128: + m_type = e_uint128; + success = true; + break; + case e_uint128: + success = true; + break; + case e_sint256: + m_type = e_uint256; + success = true; + break; + case e_uint256: + success = true; + break; + case e_float: + success = true; + break; + case e_double: + success = true; + break; + case e_long_double: + success = true; + break; + } + + return success; +} + +signed char Scalar::SChar(char fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue(); + case e_float: + return (schar_t)m_float.convertToFloat(); + case e_double: + return (schar_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (schar_t)(ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue(); + } + return fail_value; +} + +unsigned char Scalar::UChar(unsigned char fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue(); + case e_float: + return (uchar_t)m_float.convertToFloat(); + case e_double: + return (uchar_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (uchar_t)(ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue(); + } + return fail_value; +} + +short Scalar::SShort(short fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)) + .getSExtValue(); + case e_float: + return (sshort_t)m_float.convertToFloat(); + case e_double: + return (sshort_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (sshort_t)(ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8)) + .getSExtValue(); + } + return fail_value; +} + +unsigned short Scalar::UShort(unsigned short fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8)) + .getZExtValue(); + case e_float: + return (ushort_t)m_float.convertToFloat(); + case e_double: + return (ushort_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (ushort_t)(ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8)) + .getZExtValue(); + } + return fail_value; +} + +int Scalar::SInt(int fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue(); + case e_float: + return (sint_t)m_float.convertToFloat(); + case e_double: + return (sint_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (sint_t)(ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue(); + } + return fail_value; +} + +unsigned int Scalar::UInt(unsigned int fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue(); + case e_float: + return (uint_t)m_float.convertToFloat(); + case e_double: + return (uint_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (uint_t)(ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue(); + } + return fail_value; +} + +long Scalar::SLong(long fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue(); + case e_float: + return (slong_t)m_float.convertToFloat(); + case e_double: + return (slong_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (slong_t)(ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue(); + } + return fail_value; +} + +unsigned long Scalar::ULong(unsigned long fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue(); + case e_float: + return (ulong_t)m_float.convertToFloat(); + case e_double: + return (ulong_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (ulong_t)(ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue(); + } + return fail_value; +} + +long long Scalar::SLongLong(long long fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)) + .getSExtValue(); + case e_float: + return (slonglong_t)m_float.convertToFloat(); + case e_double: + return (slonglong_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (slonglong_t)(ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8)) + .getSExtValue(); + } + return fail_value; +} + +unsigned long long Scalar::ULongLong(unsigned long long fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8)) + .getZExtValue(); + case e_float: + return (ulonglong_t)m_float.convertToFloat(); + case e_double: + return (ulonglong_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (ulonglong_t)(ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8)) + .getZExtValue(); + } + return fail_value; +} + +llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return m_integer; + case e_float: + case e_double: + case e_long_double: + return m_float.bitcastToAPInt(); + } + return fail_value; +} + +llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return m_integer; + case e_float: + case e_double: + case e_long_double: + return m_float.bitcastToAPInt(); + } + return fail_value; +} + +llvm::APInt Scalar::SInt256(llvm::APInt &fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return m_integer; + case e_float: + case e_double: + case e_long_double: + return m_float.bitcastToAPInt(); + } + return fail_value; +} + +llvm::APInt Scalar::UInt256(const llvm::APInt &fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return m_integer; + case e_float: + case e_double: + case e_long_double: + return m_float.bitcastToAPInt(); + } + return fail_value; +} + +float Scalar::Float(float fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return llvm::APIntOps::RoundAPIntToFloat(m_integer); + case e_float: + return m_float.convertToFloat(); + case e_double: + return (float_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return ldbl_val.bitsToFloat(); + } + return fail_value; +} + +double Scalar::Double(double fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return llvm::APIntOps::RoundAPIntToDouble(m_integer); + case e_float: + return (double_t)m_float.convertToFloat(); + case e_double: + return m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return ldbl_val.bitsToFloat(); + } + return fail_value; +} + +long double Scalar::LongDouble(long double fail_value) const { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer); + case e_float: + return (long_double_t)m_float.convertToFloat(); + case e_double: + return (long_double_t)m_float.convertToDouble(); + case e_long_double: + llvm::APInt ldbl_val = m_float.bitcastToAPInt(); + return (long_double_t)ldbl_val.bitsToDouble(); + } + return fail_value; +} + +Scalar &Scalar::operator+=(const Scalar &rhs) { + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = a->m_integer + b->m_integer; + break; + + case e_float: + case e_double: + case e_long_double: + m_float = a->m_float + b->m_float; + break; + } + } + return *this; +} + +Scalar &Scalar::operator<<=(const Scalar &rhs) { + switch (m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + switch (rhs.m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = m_integer << rhs.m_integer; + break; + } + break; + } + return *this; +} + +bool Scalar::ShiftRightLogical(const Scalar &rhs) { + switch (m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + switch (rhs.m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = m_integer.lshr(rhs.m_integer); + break; + } + break; + } + return m_type != e_void; +} + +Scalar &Scalar::operator>>=(const Scalar &rhs) { + switch (m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + switch (rhs.m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = m_integer.ashr(rhs.m_integer); + break; + } + break; + } + return *this; +} + +Scalar &Scalar::operator&=(const Scalar &rhs) { + switch (m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + switch (rhs.m_type) { + case e_void: + case e_float: + case e_double: + case e_long_double: + m_type = e_void; + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer &= rhs.m_integer; + break; + } + break; + } + return *this; +} + +bool Scalar::AbsoluteValue() { + switch (m_type) { + case e_void: + break; + + case e_sint: + case e_slong: + case e_slonglong: + case e_sint128: + case e_sint256: + if (m_integer.isNegative()) + m_integer = -m_integer; + return true; + + case e_uint: + case e_ulong: + case e_ulonglong: + return true; + case e_uint128: + case e_uint256: + case e_float: + case e_double: + case e_long_double: + m_float.clearSign(); + return true; + } + return false; +} + +bool Scalar::UnaryNegate() { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = -m_integer; + return true; + case e_float: + case e_double: + case e_long_double: + m_float.changeSign(); + return true; + } + return false; +} + +bool Scalar::OnesComplement() { + switch (m_type) { + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer = ~m_integer; + return true; + + case e_void: + case e_float: + case e_double: + case e_long_double: + break; + } + return false; +} + +const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer + b->m_integer; + break; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result.m_float = a->m_float + b->m_float; + break; + } + } + return result; +} + +const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer - b->m_integer; + break; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result.m_float = a->m_float - b->m_float; + break; + } + } + return result; +} + +const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + if (b->m_integer != 0) { + result.m_integer = a->m_integer.sdiv(b->m_integer); + return result; + } + break; + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + if (b->m_integer != 0) { + result.m_integer = a->m_integer.udiv(b->m_integer); + return result; + } + break; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + if (!b->m_float.isZero()) { + result.m_float = a->m_float / b->m_float; + return result; + } + break; + } + } + // For division only, the only way it should make it here is if a promotion + // failed, or if we are trying to do a divide by zero. + result.m_type = Scalar::e_void; + return result; +} + +const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer * b->m_integer; + break; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result.m_float = a->m_float * b->m_float; + break; + } + } + return result; +} + +const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer & b->m_integer; + break; + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + // No bitwise AND on floats, doubles of long doubles + result.m_type = Scalar::e_void; + break; + } + } + return result; +} + +const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer | b->m_integer; + break; + + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + // No bitwise AND on floats, doubles of long doubles + result.m_type = Scalar::e_void; + break; + } + } + return result; +} + +const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + default: + break; + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + if (b->m_integer != 0) { + result.m_integer = a->m_integer.srem(b->m_integer); + return result; + } + break; + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + if (b->m_integer != 0) { + result.m_integer = a->m_integer.urem(b->m_integer); + return result; + } + break; + } + } + result.m_type = Scalar::e_void; + return result; +} + +const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) { + Scalar result; + Scalar temp_value; + const Scalar *a; + const Scalar *b; + if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) != + Scalar::e_void) { + switch (result.m_type) { + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + result.m_integer = a->m_integer ^ b->m_integer; + break; + + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + // No bitwise AND on floats, doubles of long doubles + result.m_type = Scalar::e_void; + break; + } + } + return result; +} + +const Scalar lldb_private::operator<<(const Scalar &lhs, const Scalar &rhs) { + Scalar result = lhs; + result <<= rhs; + return result; +} + +const Scalar lldb_private::operator>>(const Scalar &lhs, const Scalar &rhs) { + Scalar result = lhs; + result >>= rhs; + return result; +} + +Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding, + size_t byte_size) { + Status error; + if (value_str == nullptr || value_str[0] == '\0') { + error.SetErrorString("Invalid c-string value string."); + return error; + } + switch (encoding) { + case eEncodingInvalid: + error.SetErrorString("Invalid encoding."); + break; + + case eEncodingUint: + if (byte_size <= sizeof(uint64_t)) { + uint64_t uval64; + if (!llvm::to_integer(value_str, uval64)) + error.SetErrorStringWithFormat( + "'%s' is not a valid unsigned integer string value", value_str); + else if (!UIntValueIsValidForSize(uval64, byte_size)) + error.SetErrorStringWithFormat("value 0x%" PRIx64 + " is too large to fit in a %" PRIu64 + " byte unsigned integer value", + uval64, (uint64_t)byte_size); + else { + m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize(byte_size); + switch (m_type) { + case e_uint: + m_integer = llvm::APInt(sizeof(uint_t) * 8, uval64, false); + break; + case e_ulong: + m_integer = llvm::APInt(sizeof(ulong_t) * 8, uval64, false); + break; + case e_ulonglong: + m_integer = llvm::APInt(sizeof(ulonglong_t) * 8, uval64, false); + break; + default: + error.SetErrorStringWithFormat( + "unsupported unsigned integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + break; + } + } + } else { + error.SetErrorStringWithFormat( + "unsupported unsigned integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + return error; + } + break; + + case eEncodingSint: + if (byte_size <= sizeof(int64_t)) { + int64_t sval64; + if (!llvm::to_integer(value_str, sval64)) + error.SetErrorStringWithFormat( + "'%s' is not a valid signed integer string value", value_str); + else if (!SIntValueIsValidForSize(sval64, byte_size)) + error.SetErrorStringWithFormat("value 0x%" PRIx64 + " is too large to fit in a %" PRIu64 + " byte signed integer value", + sval64, (uint64_t)byte_size); + else { + m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize(byte_size); + switch (m_type) { + case e_sint: + m_integer = llvm::APInt(sizeof(sint_t) * 8, sval64, true); + break; + case e_slong: + m_integer = llvm::APInt(sizeof(slong_t) * 8, sval64, true); + break; + case e_slonglong: + m_integer = llvm::APInt(sizeof(slonglong_t) * 8, sval64, true); + break; + default: + error.SetErrorStringWithFormat( + "unsupported signed integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + break; + } + } + } else { + error.SetErrorStringWithFormat( + "unsupported signed integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + return error; + } + break; + + case eEncodingIEEE754: + static float f_val; + static double d_val; + static long double l_val; + if (byte_size == sizeof(float)) { + if (::sscanf(value_str, "%f", &f_val) == 1) { + m_float = llvm::APFloat(f_val); + m_type = e_float; + } else + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_str); + } else if (byte_size == sizeof(double)) { + if (::sscanf(value_str, "%lf", &d_val) == 1) { + m_float = llvm::APFloat(d_val); + m_type = e_double; + } else + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_str); + } else if (byte_size == sizeof(long double)) { + if (::sscanf(value_str, "%Lf", &l_val) == 1) { + m_float = + llvm::APFloat(llvm::APFloat::x87DoubleExtended(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + ((type128 *)&l_val)->x)); + m_type = e_long_double; + } else + error.SetErrorStringWithFormat("'%s' is not a valid float string value", + value_str); + } else { + error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "", + (uint64_t)byte_size); + return error; + } + break; + + case eEncodingVector: + error.SetErrorString("vector encoding unsupported."); + break; + } + if (error.Fail()) + m_type = e_void; + + return error; +} + +Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding, + size_t byte_size) { + Status error; + + type128 int128; + type256 int256; + switch (encoding) { + case lldb::eEncodingInvalid: + error.SetErrorString("invalid encoding"); + break; + case lldb::eEncodingVector: + error.SetErrorString("vector encoding unsupported"); + break; + case lldb::eEncodingUint: { + lldb::offset_t offset = 0; + + switch (byte_size) { + case 1: + operator=((uint8_t)data.GetU8(&offset)); + break; + case 2: + operator=((uint16_t)data.GetU16(&offset)); + break; + case 4: + operator=((uint32_t)data.GetU32(&offset)); + break; + case 8: + operator=((uint64_t)data.GetU64(&offset)); + break; + case 16: + if (data.GetByteOrder() == eByteOrderBig) { + int128.x[1] = (uint64_t)data.GetU64(&offset); + int128.x[0] = (uint64_t)data.GetU64(&offset); + } else { + int128.x[0] = (uint64_t)data.GetU64(&offset); + int128.x[1] = (uint64_t)data.GetU64(&offset); + } + operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x)); + break; + case 32: + if (data.GetByteOrder() == eByteOrderBig) { + int256.x[3] = (uint64_t)data.GetU64(&offset); + int256.x[2] = (uint64_t)data.GetU64(&offset); + int256.x[1] = (uint64_t)data.GetU64(&offset); + int256.x[0] = (uint64_t)data.GetU64(&offset); + } else { + int256.x[0] = (uint64_t)data.GetU64(&offset); + int256.x[1] = (uint64_t)data.GetU64(&offset); + int256.x[2] = (uint64_t)data.GetU64(&offset); + int256.x[3] = (uint64_t)data.GetU64(&offset); + } + operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x)); + break; + default: + error.SetErrorStringWithFormat( + "unsupported unsigned integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + break; + } + } break; + case lldb::eEncodingSint: { + lldb::offset_t offset = 0; + + switch (byte_size) { + case 1: + operator=((int8_t)data.GetU8(&offset)); + break; + case 2: + operator=((int16_t)data.GetU16(&offset)); + break; + case 4: + operator=((int32_t)data.GetU32(&offset)); + break; + case 8: + operator=((int64_t)data.GetU64(&offset)); + break; + case 16: + if (data.GetByteOrder() == eByteOrderBig) { + int128.x[1] = (uint64_t)data.GetU64(&offset); + int128.x[0] = (uint64_t)data.GetU64(&offset); + } else { + int128.x[0] = (uint64_t)data.GetU64(&offset); + int128.x[1] = (uint64_t)data.GetU64(&offset); + } + operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x)); + break; + case 32: + if (data.GetByteOrder() == eByteOrderBig) { + int256.x[3] = (uint64_t)data.GetU64(&offset); + int256.x[2] = (uint64_t)data.GetU64(&offset); + int256.x[1] = (uint64_t)data.GetU64(&offset); + int256.x[0] = (uint64_t)data.GetU64(&offset); + } else { + int256.x[0] = (uint64_t)data.GetU64(&offset); + int256.x[1] = (uint64_t)data.GetU64(&offset); + int256.x[2] = (uint64_t)data.GetU64(&offset); + int256.x[3] = (uint64_t)data.GetU64(&offset); + } + operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x)); + break; + default: + error.SetErrorStringWithFormat( + "unsupported signed integer byte size: %" PRIu64 "", + (uint64_t)byte_size); + break; + } + } break; + case lldb::eEncodingIEEE754: { + lldb::offset_t offset = 0; + + if (byte_size == sizeof(float)) + operator=((float)data.GetFloat(&offset)); + else if (byte_size == sizeof(double)) + operator=((double)data.GetDouble(&offset)); + else if (byte_size == sizeof(long double)) + operator=((long double)data.GetLongDouble(&offset)); + else + error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "", + (uint64_t)byte_size); + } break; + } + + return error; +} + +bool Scalar::SignExtend(uint32_t sign_bit_pos) { + const uint32_t max_bit_pos = GetByteSize() * 8; + + if (sign_bit_pos < max_bit_pos) { + switch (m_type) { + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + return false; + + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + if (max_bit_pos == sign_bit_pos) + return true; + else if (sign_bit_pos < (max_bit_pos - 1)) { + llvm::APInt sign_bit = llvm::APInt::getSignMask(sign_bit_pos + 1); + llvm::APInt bitwize_and = m_integer & sign_bit; + if (bitwize_and.getBoolValue()) { + const llvm::APInt mask = + ~(sign_bit) + llvm::APInt(m_integer.getBitWidth(), 1); + m_integer |= mask; + } + return true; + } + break; + } + } + return false; +} + +size_t Scalar::GetAsMemoryData(void *dst, size_t dst_len, + lldb::ByteOrder dst_byte_order, + Status &error) const { + // Get a data extractor that points to the native scalar data + DataExtractor data; + if (!GetData(data)) { + error.SetErrorString("invalid scalar value"); + return 0; + } + + const size_t src_len = data.GetByteSize(); + + // Prepare a memory buffer that contains some or all of the register value + const size_t bytes_copied = + data.CopyByteOrderedData(0, // src offset + src_len, // src length + dst, // dst buffer + dst_len, // dst length + dst_byte_order); // dst byte order + if (bytes_copied == 0) + error.SetErrorString("failed to copy data"); + + return bytes_copied; +} + +bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) { + if (bit_size == 0) + return true; + + switch (m_type) { + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + break; + + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + m_integer = m_integer.ashr(bit_offset) + .sextOrTrunc(bit_size) + .sextOrSelf(8 * GetByteSize()); + return true; + + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + m_integer = m_integer.lshr(bit_offset) + .zextOrTrunc(bit_size) + .zextOrSelf(8 * GetByteSize()); + return true; + } + return false; +} + +bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) { + // If either entry is void then we can just compare the types + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return lhs.m_type == rhs.m_type; + + Scalar temp_value; + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + return a->m_integer == b->m_integer; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result == llvm::APFloat::cmpEqual) + return true; + } + return false; +} + +bool lldb_private::operator!=(const Scalar &lhs, const Scalar &rhs) { + // If either entry is void then we can just compare the types + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return lhs.m_type != rhs.m_type; + + Scalar + temp_value; // A temp value that might get a copy of either promoted value + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_uint: + case Scalar::e_slong: + case Scalar::e_ulong: + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + case Scalar::e_sint128: + case Scalar::e_uint128: + case Scalar::e_sint256: + case Scalar::e_uint256: + return a->m_integer != b->m_integer; + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result != llvm::APFloat::cmpEqual) + return true; + } + return true; +} + +bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return false; + + Scalar temp_value; + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + return a->m_integer.slt(b->m_integer); + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + return a->m_integer.ult(b->m_integer); + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result == llvm::APFloat::cmpLessThan) + return true; + } + return false; +} + +bool lldb_private::operator<=(const Scalar &lhs, const Scalar &rhs) { + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return false; + + Scalar temp_value; + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + return a->m_integer.sle(b->m_integer); + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + return a->m_integer.ule(b->m_integer); + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result == llvm::APFloat::cmpLessThan || + result == llvm::APFloat::cmpEqual) + return true; + } + return false; +} + +bool lldb_private::operator>(const Scalar &lhs, const Scalar &rhs) { + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return false; + + Scalar temp_value; + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + return a->m_integer.sgt(b->m_integer); + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + return a->m_integer.ugt(b->m_integer); + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result == llvm::APFloat::cmpGreaterThan) + return true; + } + return false; +} + +bool lldb_private::operator>=(const Scalar &lhs, const Scalar &rhs) { + if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) + return false; + + Scalar temp_value; + const Scalar *a; + const Scalar *b; + llvm::APFloat::cmpResult result; + switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { + case Scalar::e_void: + break; + case Scalar::e_sint: + case Scalar::e_slong: + case Scalar::e_slonglong: + case Scalar::e_sint128: + case Scalar::e_sint256: + return a->m_integer.sge(b->m_integer); + case Scalar::e_uint: + case Scalar::e_ulong: + case Scalar::e_ulonglong: + case Scalar::e_uint128: + case Scalar::e_uint256: + return a->m_integer.uge(b->m_integer); + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + result = a->m_float.compare(b->m_float); + if (result == llvm::APFloat::cmpGreaterThan || + result == llvm::APFloat::cmpEqual) + return true; + } + return false; +} + +bool Scalar::ClearBit(uint32_t bit) { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer.clearBit(bit); + return true; + case e_float: + case e_double: + case e_long_double: + break; + } + return false; +} + +bool Scalar::SetBit(uint32_t bit) { + switch (m_type) { + case e_void: + break; + case e_sint: + case e_uint: + case e_slong: + case e_ulong: + case e_slonglong: + case e_ulonglong: + case e_sint128: + case e_uint128: + case e_sint256: + case e_uint256: + m_integer.setBit(bit); + return true; + case e_float: + case e_double: + case e_long_double: + break; + } + return false; +} Index: lldb/trunk/source/Utility/State.cpp =================================================================== --- lldb/trunk/source/Utility/State.cpp +++ lldb/trunk/source/Utility/State.cpp @@ -0,0 +1,115 @@ +//===-- State.cpp -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Utility/State.h" + +using namespace lldb; +using namespace lldb_private; + +const char *lldb_private::StateAsCString(StateType state) { + switch (state) { + case eStateInvalid: + return "invalid"; + case eStateUnloaded: + return "unloaded"; + case eStateConnected: + return "connected"; + case eStateAttaching: + return "attaching"; + case eStateLaunching: + return "launching"; + case eStateStopped: + return "stopped"; + case eStateRunning: + return "running"; + case eStateStepping: + return "stepping"; + case eStateCrashed: + return "crashed"; + case eStateDetached: + return "detached"; + case eStateExited: + return "exited"; + case eStateSuspended: + return "suspended"; + } + return "unknown"; +} + +const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) { + switch (permissions) { + case 0: + return "---"; + case ePermissionsWritable: + return "-w-"; + case ePermissionsReadable: + return "r--"; + case ePermissionsExecutable: + return "--x"; + case ePermissionsReadable | ePermissionsWritable: + return "rw-"; + case ePermissionsReadable | ePermissionsExecutable: + return "r-x"; + case ePermissionsWritable | ePermissionsExecutable: + return "-wx"; + case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable: + return "rwx"; + default: + break; + } + return "???"; +} + +bool lldb_private::StateIsRunningState(StateType state) { + switch (state) { + case eStateAttaching: + case eStateLaunching: + case eStateRunning: + case eStateStepping: + return true; + + case eStateConnected: + case eStateDetached: + case eStateInvalid: + case eStateUnloaded: + case eStateStopped: + case eStateCrashed: + case eStateExited: + case eStateSuspended: + break; + } + return false; +} + +bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) { + switch (state) { + case eStateInvalid: + case eStateConnected: + case eStateAttaching: + case eStateLaunching: + case eStateRunning: + case eStateStepping: + case eStateDetached: + break; + + case eStateUnloaded: + case eStateExited: + return !must_exist; + + case eStateStopped: + case eStateCrashed: + case eStateSuspended: + return true; + } + return false; +} Index: lldb/trunk/unittests/Core/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/Core/CMakeLists.txt +++ lldb/trunk/unittests/Core/CMakeLists.txt @@ -5,7 +5,6 @@ ListenerTest.cpp MangledTest.cpp ScalarTest.cpp - StateTest.cpp StreamCallbackTest.cpp LINK_LIBS Index: lldb/trunk/unittests/Core/ScalarTest.cpp =================================================================== --- lldb/trunk/unittests/Core/ScalarTest.cpp +++ lldb/trunk/unittests/Core/ScalarTest.cpp @@ -9,9 +9,9 @@ #include "gtest/gtest.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Testing/Support/Error.h" Index: lldb/trunk/unittests/Core/StateTest.cpp =================================================================== --- lldb/trunk/unittests/Core/StateTest.cpp +++ lldb/trunk/unittests/Core/StateTest.cpp @@ -1,21 +0,0 @@ -//===-- StateTest.cpp -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/State.h" -#include "llvm/Support/FormatVariadic.h" -#include "gtest/gtest.h" - -using namespace lldb; -using namespace lldb_private; - -TEST(StateTest, Formatv) { - EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); - EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); - EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str()); -} Index: lldb/trunk/unittests/Utility/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/Utility/CMakeLists.txt +++ lldb/trunk/unittests/Utility/CMakeLists.txt @@ -12,6 +12,8 @@ JSONTest.cpp LogTest.cpp NameMatchesTest.cpp + RegisterValueTest.cpp + StateTest.cpp StatusTest.cpp StreamTeeTest.cpp StreamTest.cpp Index: lldb/trunk/unittests/Utility/RegisterValueTest.cpp =================================================================== --- lldb/trunk/unittests/Utility/RegisterValueTest.cpp +++ lldb/trunk/unittests/Utility/RegisterValueTest.cpp @@ -0,0 +1,23 @@ +//===-- RegisterValueTest.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/RegisterValue.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(RegisterValueTest, GetSet8) { + RegisterValue R8(uint8_t(47)); + EXPECT_EQ(47u, R8.GetAsUInt8()); + R8 = uint8_t(42); + EXPECT_EQ(42u, R8.GetAsUInt8()); + EXPECT_EQ(42u, R8.GetAsUInt16()); + EXPECT_EQ(42u, R8.GetAsUInt32()); + EXPECT_EQ(42u, R8.GetAsUInt64()); +} Index: lldb/trunk/unittests/Utility/StateTest.cpp =================================================================== --- lldb/trunk/unittests/Utility/StateTest.cpp +++ lldb/trunk/unittests/Utility/StateTest.cpp @@ -0,0 +1,21 @@ +//===-- StateTest.cpp -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/State.h" +#include "llvm/Support/FormatVariadic.h" +#include "gtest/gtest.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(StateTest, Formatv) { + EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); + EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str()); +} Index: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h =================================================================== --- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h +++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h @@ -10,8 +10,8 @@ #ifndef LLDB_SERVER_TESTS_MESSAGEOBJECTS_H #define LLDB_SERVER_TESTS_MESSAGEOBJECTS_H -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/Host.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h"