From johnny.chen at apple.com Mon May 9 14:05:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 09 May 2011 19:05:46 -0000 Subject: [Lldb-commits] [lldb] r131089 - /lldb/trunk/source/Commands/CommandObjectPlatform.cpp Message-ID: <20110509190546.42B7F2A6C12C@llvm.org> Author: johnny Date: Mon May 9 14:05:46 2011 New Revision: 131089 URL: http://llvm.org/viewvc/llvm-project?rev=131089&view=rev Log: Fix the wrong error message for "platform process info", i.e., with no pid(s) specified for the command. Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=131089&r1=131088&r2=131089&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Mon May 9 14:05:46 2011 @@ -831,8 +831,8 @@ } else { - // Bad args - result.AppendError ("\"platform disconnect\" doesn't take any arguments"); + // No args + result.AppendError ("one or more process id(s) must be specified"); result.SetStatus (eReturnStatusFailed); } } From gclayton at apple.com Mon May 9 15:18:19 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 09 May 2011 20:18:19 -0000 Subject: [Lldb-commits] [lldb] r131096 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Instruction/ARM/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/UnwindAssembly/InstEmulation/ source/Target/ tools/debugserver/debugserver.xcodeproj/ Message-ID: <20110509201819.9DF2E2A6C12C@llvm.org> Author: gclayton Date: Mon May 9 15:18:18 2011 New Revision: 131096 URL: http://llvm.org/viewvc/llvm-project?rev=131096&view=rev Log: While implementing unwind information using UnwindAssemblyInstEmulation I ran into some cleanup I have been wanting to do when reading/writing registers. Previously all RegisterContext subclasses would need to implement: virtual bool ReadRegisterBytes (uint32_t reg, DataExtractor &data); virtual bool WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset = 0); There is now a new class specifically designed to hold register values: lldb_private::RegisterValue The new register context calls that subclasses must implement are: virtual bool ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) = 0; virtual bool WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) = 0; The RegisterValue class must be big enough to handle any register value. The class contains an enumeration for the value type, and then a union for the data value. Any integer/float values are stored directly in an appropriate host integer/float. Anything bigger is stored in a byte buffer that has a length and byte order. The RegisterValue class also knows how to copy register value bytes into in a buffer with a specified byte order which can be used to write the register value down into memory, and this does the right thing when not all bytes from the register values are needed (getting a uint8 from a uint32 register value..). All RegiterContext and other sources have been switched over to using the new regiter value class. Added: lldb/trunk/include/lldb/Core/RegisterValue.h lldb/trunk/source/Core/RegisterValue.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/include/lldb/Core/ValueObjectRegister.h lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/include/lldb/Target/RegisterContext.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Target/RegisterContext.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Mon May 9 15:18:18 2011 @@ -418,6 +418,52 @@ //------------------------------------------------------------------ const void* GetData (uint32_t *offset_ptr, uint32_t length) const; + + //------------------------------------------------------------------ + /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied + /// data is treated as a value that can be swapped to match the + /// specified byte order. + /// + /// For values that are larger than the supported integer sizes, + /// this function can be used to extract data in a specified byte + /// order. It can also be used to copy a smaller integer value from + /// to a larger value. The extra bytes left over will be padded + /// correctly according to the byte order of this object and the + /// \a dst_byte_order. This can be very handy when say copying a + /// partial data value into a register. + /// + /// @param[in] src_offset + /// The offset into this data from which to start copying an + /// endian entity + /// + /// @param[in] src_len + /// The length of the endian data to copy from this object + /// into the \a dst object + /// + /// @param[out] dst + /// The buffer where to place the endian data. The data might + /// need to be byte swapped (and appropriately padded with + /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order + /// does not match the byte order in this object. + /// + /// @param[in] dst_len + /// The length number of bytes that the endian value will + /// occupy is \a dst. + /// + /// @param[in] byte_order + /// The byte order that the endian value should be in the \a dst + /// buffer. + /// + /// @return + /// Returns the number of bytes that were copied, or zero if + /// anything goes wrong. + //------------------------------------------------------------------ + uint32_t + CopyByteOrderedData (uint32_t src_offset, + uint32_t src_len, + void *dst, + uint32_t dst_len, + lldb::ByteOrder dst_byte_order) const; //------------------------------------------------------------------ /// Get the data end pointer. Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Mon May 9 15:18:18 2011 @@ -88,10 +88,10 @@ Emulate (const ArchSpec &arch, uint32_t evaluate_options, void *baton, - EmulateInstruction::ReadMemory read_mem_callback, - EmulateInstruction::WriteMemory write_mem_calback, - EmulateInstruction::ReadRegister read_reg_callback, - EmulateInstruction::WriteRegister write_reg_callback); + EmulateInstruction::ReadMemoryCallback read_mem_callback, + EmulateInstruction::WriteMemoryCallback write_mem_calback, + EmulateInstruction::ReadRegisterCallback read_reg_callback, + EmulateInstruction::WriteRegisterCallback write_reg_callback); const Opcode & GetOpcode () const Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon May 9 15:18:18 2011 @@ -17,6 +17,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/Opcode.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Interpreter/NamedOptionValue.h" //---------------------------------------------------------------------- @@ -351,30 +352,30 @@ }; - typedef size_t (*ReadMemory) (EmulateInstruction *instruction, - void *baton, - const Context &context, - lldb::addr_t addr, - void *dst, - size_t length); - - typedef size_t (*WriteMemory) (EmulateInstruction *instruction, - void *baton, - const Context &context, - lldb::addr_t addr, - const void *dst, - size_t length); - - typedef bool (*ReadRegister) (EmulateInstruction *instruction, - void *baton, - const RegisterInfo ®_info, - uint64_t ®_value); - - typedef bool (*WriteRegister) (EmulateInstruction *instruction, - void *baton, - const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value); + typedef size_t (*ReadMemoryCallback) (EmulateInstruction *instruction, + void *baton, + const Context &context, + lldb::addr_t addr, + void *dst, + size_t length); + + typedef size_t (*WriteMemoryCallback) (EmulateInstruction *instruction, + void *baton, + const Context &context, + lldb::addr_t addr, + const void *dst, + size_t length); + + typedef bool (*ReadRegisterCallback) (EmulateInstruction *instruction, + void *baton, + const RegisterInfo *reg_info, + RegisterValue ®_value); + + typedef bool (*WriteRegisterCallback) (EmulateInstruction *instruction, + void *baton, + const Context &context, + const RegisterInfo *reg_info, + const RegisterValue ®_value); EmulateInstruction (const ArchSpec &arch); @@ -414,27 +415,60 @@ static const char * TranslateRegister (uint32_t reg_kind, uint32_t reg_num, std::string ®_name); + //---------------------------------------------------------------------- + // RegisterInfo variants + //---------------------------------------------------------------------- + bool + ReadRegister (const RegisterInfo *reg_info, + RegisterValue& reg_value); + uint64_t - ReadRegisterUnsigned (uint32_t reg_kind, - uint32_t reg_num, + ReadRegisterUnsigned (const RegisterInfo *reg_info, uint64_t fail_value, bool *success_ptr); + + bool + WriteRegister (const Context &context, + const RegisterInfo *ref_info, + const RegisterValue& reg_value); + + bool + WriteRegisterUnsigned (const Context &context, + const RegisterInfo *reg_info, + uint64_t reg_value); + + //---------------------------------------------------------------------- + // Register kind and number variants + //---------------------------------------------------------------------- + bool + ReadRegister (uint32_t reg_kind, + uint32_t reg_num, + RegisterValue& reg_value); + + bool + WriteRegister (const Context &context, + uint32_t reg_kind, + uint32_t reg_num, + const RegisterValue& reg_value); uint64_t - ReadRegisterUnsigned (const RegisterInfo ®_info, + ReadRegisterUnsigned (uint32_t reg_kind, + uint32_t reg_num, uint64_t fail_value, bool *success_ptr); bool - WriteRegisterUnsigned (const Context &context, + WriteRegisterUnsigned (const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value); - bool - WriteRegisterUnsigned (const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value); + + size_t + ReadMemory (const Context &context, + lldb::addr_t addr, + void *dst, + size_t dst_len); uint64_t ReadMemoryUnsigned (const Context &context, @@ -444,6 +478,12 @@ bool *success_ptr); bool + WriteMemory (const Context &context, + lldb::addr_t addr, + const void *src, + size_t src_len); + + bool WriteMemoryUnsigned (const Context &context, lldb::addr_t addr, uint64_t uval, @@ -499,16 +539,16 @@ static bool ReadRegisterFrame (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value); + const RegisterInfo *reg_info, + RegisterValue ®_value); static bool WriteRegisterFrame (EmulateInstruction *instruction, void *baton, const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value); + const RegisterInfo *reg_info, + const RegisterValue ®_value); static size_t ReadMemoryDefault (EmulateInstruction *instruction, @@ -529,40 +569,40 @@ static bool ReadRegisterDefault (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value); + const RegisterInfo *reg_info, + RegisterValue ®_value); static bool WriteRegisterDefault (EmulateInstruction *instruction, void *baton, const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value); + const RegisterInfo *reg_info, + const RegisterValue ®_value); void SetBaton (void *baton); void - SetCallbacks (ReadMemory read_mem_callback, - WriteMemory write_mem_callback, - ReadRegister read_reg_callback, - WriteRegister write_reg_callback); + SetCallbacks (ReadMemoryCallback read_mem_callback, + WriteMemoryCallback write_mem_callback, + ReadRegisterCallback read_reg_callback, + WriteRegisterCallback write_reg_callback); void - SetReadMemCallback (ReadMemory read_mem_callback); + SetReadMemCallback (ReadMemoryCallback read_mem_callback); void - SetWriteMemCallback (WriteMemory write_mem_callback); + SetWriteMemCallback (WriteMemoryCallback write_mem_callback); void - SetReadRegCallback (ReadRegister read_reg_callback); + SetReadRegCallback (ReadRegisterCallback read_reg_callback); void - SetWriteRegCallback (WriteRegister write_reg_callback); + SetWriteRegCallback (WriteRegisterCallback write_reg_callback); static bool - GetBestRegisterKindAndNumber (const RegisterInfo ®_info, + GetBestRegisterKindAndNumber (const RegisterInfo *reg_info, uint32_t ®_kind, uint32_t ®_num); @@ -571,14 +611,14 @@ const RegisterInfo ®_info); protected: - ArchSpec m_arch; - void * m_baton; - ReadMemory m_read_mem_callback; - WriteMemory m_write_mem_callback; - ReadRegister m_read_reg_callback; - WriteRegister m_write_reg_callback; - lldb::addr_t m_addr; - Opcode m_opcode; + ArchSpec m_arch; + void * m_baton; + ReadMemoryCallback m_read_mem_callback; + WriteMemoryCallback m_write_mem_callback; + ReadRegisterCallback m_read_reg_callback; + WriteRegisterCallback m_write_reg_callback; + lldb::addr_t m_addr; + Opcode m_opcode; private: Added: lldb/trunk/include/lldb/Core/RegisterValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131096&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h (added) +++ lldb/trunk/include/lldb/Core/RegisterValue.h Mon May 9 15:18:18 2011 @@ -0,0 +1,376 @@ +//===-- 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 + +// C Includes +#include + +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/lldb-private.h" +#include "lldb/Host/Endian.h" + +//#define ENABLE_128_BIT_SUPPORT 1 +namespace lldb_private { + + class RegisterValue + { + public: + enum + { + kMaxRegisterByteSize = 16u + }; + enum Type + { + eTypeInvalid, + eTypeUInt8, + eTypeUInt16, + eTypeUInt32, + eTypeUInt64, +#if defined (ENABLE_128_BIT_SUPPORT) + eTypeUInt128, +#endif + eTypeFloat, + eTypeDouble, + eTypeLongDouble, + eTypeBytes + }; + + RegisterValue () : + m_type (eTypeInvalid) + { + } + + RegisterValue (uint8_t inst) : + m_type (eTypeUInt8) + { + m_data.uint8 = inst; + } + + RegisterValue (uint16_t inst) : + m_type (eTypeUInt16) + { + m_data.uint16 = inst; + } + + RegisterValue (uint32_t inst) : + m_type (eTypeUInt32) + { + m_data.uint32 = inst; + } + + RegisterValue (uint64_t inst) : + m_type (eTypeUInt64) + { + m_data.uint64 = inst; + } + +#if defined (ENABLE_128_BIT_SUPPORT) + RegisterValue (__uint128_t inst) : + m_type (eTypeUInt128) + { + m_data.uint128 = inst; + } +#endif + RegisterValue (float value) : + m_type (eTypeFloat) + { + m_data.ieee_float = value; + } + + RegisterValue (double value) : + m_type (eTypeDouble) + { + m_data.ieee_double = value; + } + + RegisterValue (long double value) : + m_type (eTypeLongDouble) + { + m_data.ieee_long_double = value; + } + + 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); + + 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, + Error &error) const; + + uint32_t + SetFromMemoryData (const RegisterInfo *reg_info, + const void *src, + uint32_t src_len, + lldb::ByteOrder src_byte_order, + Error &error); + + bool + GetScalarValue (Scalar &scalar) const; + + uint8_t + GetAsUInt8 (uint8_t fail_value = UINT8_MAX, bool *success_ptr = NULL) const + { + if (m_type == eTypeUInt8) + { + if (success_ptr) + *success_ptr = true; + return m_data.uint8; + } + if (success_ptr) + *success_ptr = true; + return fail_value; + } + + uint16_t + GetAsUInt16 (uint16_t fail_value = UINT16_MAX, bool *success_ptr = NULL) const; + + uint32_t + GetAsUInt32 (uint32_t fail_value = UINT32_MAX, bool *success_ptr = NULL) const; + + uint64_t + GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const; + +#if defined (ENABLE_128_BIT_SUPPORT) + __uint128_t + GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const; +#endif + + float + GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const; + + double + GetAsDouble (double fail_value = 0.0, bool *success_ptr = NULL) const; + + long double + GetAsLongDouble (long double fail_value = 0.0, bool *success_ptr = NULL) const; + + void + SetValueToInvalid () + { + m_type = eTypeInvalid; + } + + void + operator = (uint8_t uint) + { + m_type = eTypeUInt8; + m_data.uint8 = uint; + } + + void + operator = (uint16_t uint) + { + m_type = eTypeUInt16; + m_data.uint16 = uint; + } + + void + operator = (uint32_t uint) + { + m_type = eTypeUInt32; + m_data.uint32 = uint; + } + + void + operator = (uint64_t uint) + { + m_type = eTypeUInt64; + m_data.uint64 = uint; + } + +#if defined (ENABLE_128_BIT_SUPPORT) + void + operator = (__uint128_t uint) + { + m_type = eTypeUInt128; + m_data.uint128 = uint; + } +#endif + void + operator = (float f) + { + m_type = eTypeFloat; + m_data.ieee_float = f; + } + + void + operator = (double f) + { + m_type = eTypeDouble; + m_data.ieee_double = f; + } + + void + operator = (long double f) + { + m_type = eTypeLongDouble; + m_data.ieee_long_double = f; + } + + void + SetUInt8 (uint8_t uint) + { + m_type = eTypeUInt8; + m_data.uint8 = uint; + } + + void + SetUInt16 (uint16_t uint) + { + m_type = eTypeUInt16; + m_data.uint16 = uint; + } + + void + SetUInt32 (uint32_t uint, Type t = eTypeUInt32) + { + m_type = t; + m_data.uint32 = uint; + } + + void + SetUInt64 (uint64_t uint, Type t = eTypeUInt64) + { + m_type = t; + m_data.uint64 = uint; + } + +#if defined (ENABLE_128_BIT_SUPPORT) + void + SetUInt128 (__uint128_t uint) + { + m_type = eTypeUInt128; + m_data.uint128 = uint; + } +#endif + bool + SetUInt (uint64_t uint, uint32_t byte_size); + + void + SetFloat (float f) + { + m_type = eTypeFloat; + m_data.ieee_float = f; + } + + void + SetDouble (double f) + { + m_type = eTypeDouble; + m_data.ieee_double = f; + } + + void + SetLongDouble (long double f) + { + m_type = eTypeLongDouble; + m_data.ieee_long_double = f; + } + + void + SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order); + + bool + SignExtend (uint32_t sign_bitpos); + + Error + SetValueFromCString (const RegisterInfo *reg_info, + const char *value_str); + + Error + SetValueFromData (const RegisterInfo *reg_info, + DataExtractor &data, + uint32_t offset, + bool partial_data_ok); + + bool + Dump (Stream *s, + const RegisterInfo *reg_info, + bool prefix_with_name, + lldb::Format format = lldb::eFormatDefault) const; + + void * + GetBytes (); + + const void * + GetBytes () const; + + lldb::ByteOrder + GetByteOrder () const + { + if (m_type == eTypeBytes) + return m_data.buffer.byte_order; + return lldb::endian::InlHostByteOrder(); + } + + uint32_t + GetByteSize () const; + + void + Clear(); + + protected: + + RegisterValue::Type m_type; + union + { + uint8_t uint8; + uint16_t uint16; + uint32_t uint32; + uint64_t uint64; +#if defined (ENABLE_128_BIT_SUPPORT) + __uint128_t uint128; +#endif + float ieee_float; + double ieee_double; + long double ieee_long_double; + 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; + } m_data; + }; + +} // namespace lldb_private + +#endif // lldb_RegisterValue_h Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Mon May 9 15:18:18 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObject.h" namespace lldb_private { @@ -161,14 +162,14 @@ UpdateValue (); lldb::RegisterContextSP m_reg_ctx_sp; - const RegisterInfo *m_reg_info; - uint32_t m_reg_num; + RegisterInfo m_reg_info; + RegisterValue m_reg_value; ConstString m_type_name; void *m_clang_type; private: void - ConstructObject (); + ConstructObject (uint32_t reg_num); friend class ValueObjectRegisterSet; ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Mon May 9 15:18:18 2011 @@ -347,6 +347,33 @@ static uint64_t StringToUInt64 (const char *s, uint64_t fail_value = 0, int base = 0, bool *success_ptr = NULL); + static bool + UInt64ValueIsValidForByteSize (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 + SInt64ValueIsValidForByteSize (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; + } + static lldb::addr_t StringToAddress (const char *s, lldb::addr_t fail_value = LLDB_INVALID_ADDRESS, bool *success_ptr = NULL); Modified: lldb/trunk/include/lldb/Target/RegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/RegisterContext.h (original) +++ lldb/trunk/include/lldb/Target/RegisterContext.h Mon May 9 15:18:18 2011 @@ -53,29 +53,23 @@ GetRegisterSet (uint32_t reg_set) = 0; virtual bool - ReadRegisterBytes (uint32_t reg, DataExtractor &data) = 0; + ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) = 0; virtual bool - ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0; - + WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) = 0; + virtual bool - WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset = 0) = 0; + ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0; virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) = 0; - + virtual uint32_t ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) = 0; //------------------------------------------------------------------ // Subclasses can override these functions if desired //------------------------------------------------------------------ - virtual bool - ReadRegisterValue (uint32_t reg, Scalar &value); - - virtual bool - WriteRegisterValue (uint32_t reg, const Scalar &value); - virtual uint32_t NumSupportedHardwareBreakpoints (); @@ -96,6 +90,12 @@ virtual bool HardwareSingleStep (bool enable); + + virtual Error + ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue ®_value); + + virtual Error + WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value); //------------------------------------------------------------------ // Subclasses should not override these Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon May 9 15:18:18 2011 @@ -112,6 +112,7 @@ class RegisterContext; class RegisterLocation; class RegisterLocationList; +class RegisterValue; class RegularExpression; class Scalar; class ScriptInterpreter; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon May 9 15:18:18 2011 @@ -386,6 +386,7 @@ 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */; }; 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; + 26C6886F137880C400407EDF /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1014,6 +1015,8 @@ 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileLineResolver.cpp; path = source/Core/FileLineResolver.cpp; sourceTree = ""; }; 26C5577B132575AD008FD8FE /* PlatformMacOSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformMacOSX.cpp; sourceTree = ""; }; 26C5577C132575AD008FD8FE /* PlatformMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformMacOSX.h; sourceTree = ""; }; + 26C6886D137880B900407EDF /* RegisterValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterValue.h; path = include/lldb/Core/RegisterValue.h; sourceTree = ""; }; + 26C6886E137880C400407EDF /* RegisterValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterValue.cpp; path = source/Core/RegisterValue.cpp; sourceTree = ""; }; 26C72C93124322890068DC16 /* SBStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBStream.h; path = include/lldb/API/SBStream.h; sourceTree = ""; }; 26C72C951243229A0068DC16 /* SBStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBStream.cpp; path = source/API/SBStream.cpp; sourceTree = ""; }; 26C81CA411335651004BDC5A /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Core/UUID.h; sourceTree = ""; }; @@ -1974,6 +1977,8 @@ 26BC7D7010F1B77400F91463 /* PluginInterface.h */, 26BC7D7110F1B77400F91463 /* PluginManager.h */, 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */, + 26C6886D137880B900407EDF /* RegisterValue.h */, + 26C6886E137880C400407EDF /* RegisterValue.cpp */, 26BC7D7310F1B77400F91463 /* RegularExpression.h */, 26BC7E8C10F1B85900F91463 /* RegularExpression.cpp */, 26BC7D7410F1B77400F91463 /* Scalar.h */, @@ -3283,6 +3288,7 @@ 260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */, 2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */, 268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */, + 26C6886F137880C400407EDF /* RegisterValue.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3862,7 +3868,6 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = dwarf; @@ -3895,7 +3900,6 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Mon May 9 15:18:18 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/Args.h" @@ -77,26 +78,24 @@ { if (reg_info) { - uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + RegisterValue reg_value; - DataExtractor reg_data; - - if (reg_ctx->ReadRegisterBytes(reg, reg_data)) + if (reg_ctx->ReadRegister (reg_info, reg_value)) { strm.Indent (); - strm.Printf ("%-12s = ", reg_info ? reg_info->name : ""); Format format; if (m_options.format == eFormatDefault) format = reg_info->format; else format = m_options.format; - reg_data.Dump(&strm, 0, format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + bool prefix_with_name = true; + reg_value.Dump(&strm, reg_info, prefix_with_name, m_options.format); if (((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) && (reg_info->byte_size == reg_ctx->GetThread().GetProcess().GetAddressByteSize())) { - addr_t reg_addr = reg_ctx->ReadRegisterAsUnsigned (reg, 0); - if (reg_addr) + addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS); + if (reg_addr != LLDB_INVALID_ADDRESS) { Address so_reg_addr; if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr)) @@ -393,11 +392,12 @@ if (reg_info) { - Scalar scalar; - Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size)); + RegisterValue reg_value; + + Error error (reg_value.SetValueFromCString (reg_info, value_str)); if (error.Success()) { - if (reg_ctx->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar)) + if (reg_ctx->WriteRegister (reg_info, reg_value)) { result.SetStatus (eReturnStatusSuccessFinishNoResult); return true; Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Mon May 9 15:18:18 2011 @@ -1035,6 +1035,116 @@ return bytes; } +// Extract data and swap if needed when doing the copy +uint32_t +DataExtractor::CopyByteOrderedData (uint32_t src_offset, + uint32_t src_len, + void *dst_void_ptr, + uint32_t dst_len, + ByteOrder dst_byte_order) const +{ + // Validate the source info + assert (ValidOffsetForDataOfSize(src_offset, src_len)); + assert (src_len > 0); + assert (m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle); + + // Validate the destination info + assert (dst_void_ptr != NULL); + assert (dst_len > 0); + assert (dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle); + + // Must have valid byte orders set in this object and for destination + if (!(dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle) || + !(m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle)) + return 0; + + uint32_t i; + uint8_t* dst = (uint8_t*)dst_void_ptr; + const uint8_t* src = (const uint8_t *)PeekData (src_offset, src_len); + if (src) + { + if (src_len >= dst_len) + { + // We are copying the entire value from src into dst. + // Calculate how many, if any, zeroes we need for the most + // significant bytes if "dst_len" is greater than "src_len"... + const uint32_t num_zeroes = dst_len - src_len; + if (dst_byte_order == eByteOrderBig) + { + // Big endian, so we lead with zeroes... + if (num_zeroes > 0) + ::memset (dst, 0, num_zeroes); + // Then either copy or swap the rest + if (m_byte_order == eByteOrderBig) + { + ::memcpy (dst + num_zeroes, src, src_len); + } + else + { + for (i=0; i 0) + ::memset (dst + src_len, 0, num_zeroes); + } + return src_len; + } + else + { + // We are only copying some of the value from src into dst.. + + if (dst_byte_order == eByteOrderBig) + { + // Big endian dst + if (m_byte_order == eByteOrderBig) + { + // Big endian dst, with big endian src + ::memcpy (dst, src + (src_len - dst_len), dst_len); + } + else + { + // Big endian dst, with little endian src + for (i=0; iReadRegisterBytes (reg_info->kinds[eRegisterKindLLDB], reg_data); + RegisterValue reg_value; + var_success = reg_ctx->ReadRegister (reg_info, reg_value); + if (var_success) { - reg_data.Dump(&s, 0, reg_info->format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + reg_value.Dump(&s, reg_info, false); } } Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Mon May 9 15:18:18 2011 @@ -782,10 +782,10 @@ Instruction::Emulate (const ArchSpec &arch, uint32_t evaluate_options, void *baton, - EmulateInstruction::ReadMemory read_mem_callback, - EmulateInstruction::WriteMemory write_mem_callback, - EmulateInstruction::ReadRegister read_reg_callback, - EmulateInstruction::WriteRegister write_reg_callback) + EmulateInstruction::ReadMemoryCallback read_mem_callback, + EmulateInstruction::WriteMemoryCallback write_mem_callback, + EmulateInstruction::ReadRegisterCallback read_reg_callback, + EmulateInstruction::WriteRegisterCallback write_reg_callback) { std::auto_ptr insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL)); if (insn_emulator_ap.get()) Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Mon May 9 15:18:18 2011 @@ -14,6 +14,8 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/RegisterValue.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Endian.h" #include "lldb/Symbol/UnwindPlan.h" @@ -64,42 +66,114 @@ } -uint64_t -EmulateInstruction::ReadRegisterUnsigned (uint32_t reg_kind, uint32_t reg_num, uint64_t fail_value, bool *success_ptr) +bool +EmulateInstruction::ReadRegister (const RegisterInfo *reg_info, RegisterValue& reg_value) +{ + if (m_read_reg_callback) + return m_read_reg_callback (this, m_baton, reg_info, reg_value); + return false; +} + +bool +EmulateInstruction::ReadRegister (uint32_t reg_kind, uint32_t reg_num, RegisterValue& reg_value) { RegisterInfo reg_info; if (GetRegisterInfo(reg_kind, reg_num, reg_info)) - return ReadRegisterUnsigned (reg_info, fail_value, success_ptr); + return ReadRegister (®_info, reg_value); + return false; +} + +uint64_t +EmulateInstruction::ReadRegisterUnsigned (uint32_t reg_kind, + uint32_t reg_num, + uint64_t fail_value, + bool *success_ptr) +{ + RegisterValue reg_value; + if (ReadRegister (reg_kind, reg_num, reg_value)) + return reg_value.GetAsUInt64(fail_value, success_ptr); if (success_ptr) *success_ptr = false; return fail_value; } uint64_t -EmulateInstruction::ReadRegisterUnsigned (const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr) -{ - uint64_t uval64 = 0; - bool success = m_read_reg_callback (this, m_baton, reg_info, uval64); +EmulateInstruction::ReadRegisterUnsigned (const RegisterInfo *reg_info, + uint64_t fail_value, + bool *success_ptr) +{ + RegisterValue reg_value; + if (ReadRegister (reg_info, reg_value)) + return reg_value.GetAsUInt64(fail_value, success_ptr); if (success_ptr) - *success_ptr = success; - if (!success) - uval64 = fail_value; - return uval64; + *success_ptr = false; + return fail_value; +} + +bool +EmulateInstruction::WriteRegister (const Context &context, + const RegisterInfo *reg_info, + const RegisterValue& reg_value) +{ + if (m_write_reg_callback) + return m_write_reg_callback (this, m_baton, context, reg_info, reg_value); + return false; +} + +bool +EmulateInstruction::WriteRegister (const Context &context, + uint32_t reg_kind, + uint32_t reg_num, + const RegisterValue& reg_value) +{ + RegisterInfo reg_info; + if (GetRegisterInfo(reg_kind, reg_num, reg_info)) + return WriteRegister (context, ®_info, reg_value); + return false; } + bool -EmulateInstruction::WriteRegisterUnsigned (const Context &context, uint32_t reg_kind, uint32_t reg_num, uint64_t reg_value) +EmulateInstruction::WriteRegisterUnsigned (const Context &context, + uint32_t reg_kind, + uint32_t reg_num, + uint64_t uint_value) { + RegisterInfo reg_info; if (GetRegisterInfo(reg_kind, reg_num, reg_info)) - return WriteRegisterUnsigned (context, reg_info, reg_value); + { + RegisterValue reg_value; + if (reg_value.SetUInt(uint_value, reg_info.byte_size)) + return WriteRegister (context, ®_info, reg_value); + } return false; } bool -EmulateInstruction::WriteRegisterUnsigned (const Context &context, const RegisterInfo ®_info, uint64_t reg_value) +EmulateInstruction::WriteRegisterUnsigned (const Context &context, + const RegisterInfo *reg_info, + uint64_t uint_value) +{ + + if (reg_info) + { + RegisterValue reg_value; + if (reg_value.SetUInt(uint_value, reg_info->byte_size)) + return WriteRegister (context, reg_info, reg_value); + } + return false; +} + +size_t +EmulateInstruction::ReadMemory (const Context &context, + lldb::addr_t addr, + void *dst, + size_t dst_len) { - return m_write_reg_callback (this, m_baton, context, reg_info, reg_value); + if (m_read_mem_callback) + return m_read_mem_callback (this, m_baton, context, addr, dst, dst_len) == dst_len; + return false; } uint64_t @@ -144,6 +218,17 @@ return false; } +bool +EmulateInstruction::WriteMemory (const Context &context, + lldb::addr_t addr, + const void *src, + size_t src_len) +{ + if (m_write_mem_callback) + return m_write_mem_callback (this, m_baton, context, addr, src, src_len) == src_len; + return false; +} + void EmulateInstruction::SetBaton (void *baton) @@ -152,10 +237,10 @@ } void -EmulateInstruction::SetCallbacks (ReadMemory read_mem_callback, - WriteMemory write_mem_callback, - ReadRegister read_reg_callback, - WriteRegister write_reg_callback) +EmulateInstruction::SetCallbacks (ReadMemoryCallback read_mem_callback, + WriteMemoryCallback write_mem_callback, + ReadRegisterCallback read_reg_callback, + WriteRegisterCallback write_reg_callback) { m_read_mem_callback = read_mem_callback; m_write_mem_callback = write_mem_callback; @@ -164,28 +249,28 @@ } void -EmulateInstruction::SetReadMemCallback (ReadMemory read_mem_callback) +EmulateInstruction::SetReadMemCallback (ReadMemoryCallback read_mem_callback) { m_read_mem_callback = read_mem_callback; } void -EmulateInstruction::SetWriteMemCallback (WriteMemory write_mem_callback) +EmulateInstruction::SetWriteMemCallback (WriteMemoryCallback write_mem_callback) { m_write_mem_callback = write_mem_callback; } void -EmulateInstruction::SetReadRegCallback (ReadRegister read_reg_callback) +EmulateInstruction::SetReadRegCallback (ReadRegisterCallback read_reg_callback) { m_read_reg_callback = read_reg_callback; } void -EmulateInstruction::SetWriteRegCallback (WriteRegister write_reg_callback) +EmulateInstruction::SetWriteRegCallback (WriteRegisterCallback write_reg_callback) { m_write_reg_callback = write_reg_callback; } @@ -255,46 +340,28 @@ bool EmulateInstruction::ReadRegisterFrame (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value) + const RegisterInfo *reg_info, + RegisterValue ®_value) { if (!baton) return false; StackFrame *frame = (StackFrame *) baton; - RegisterContext *reg_ctx = frame->GetRegisterContext().get(); - Scalar value; - - const uint32_t internal_reg_num = GetInternalRegisterNumber (reg_ctx, reg_info); - - if (internal_reg_num != LLDB_INVALID_REGNUM) - { - if (reg_ctx->ReadRegisterValue (internal_reg_num, value)) - { - reg_value = value.GetRawBits64 (0); - return true; - } - } - return false; + return frame->GetRegisterContext()->ReadRegister (reg_info, reg_value); } bool EmulateInstruction::WriteRegisterFrame (EmulateInstruction *instruction, void *baton, const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value) + const RegisterInfo *reg_info, + const RegisterValue ®_value) { if (!baton) return false; StackFrame *frame = (StackFrame *) baton; - RegisterContext *reg_ctx = frame->GetRegisterContext().get(); - Scalar value (reg_value); - const uint32_t internal_reg_num = GetInternalRegisterNumber (reg_ctx, reg_info); - if (internal_reg_num != LLDB_INVALID_REGNUM) - return reg_ctx->WriteRegisterValue (internal_reg_num, value); - return false; + return frame->GetRegisterContext()->WriteRegister (reg_info, reg_value); } size_t @@ -327,15 +394,15 @@ bool EmulateInstruction::ReadRegisterDefault (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value) + const RegisterInfo *reg_info, + RegisterValue ®_value) { - fprintf (stdout, " Read Register (%s)\n", reg_info.name); + fprintf (stdout, " Read Register (%s)\n", reg_info->name); uint32_t reg_kind, reg_num; if (GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) - reg_value = (uint64_t)reg_kind << 24 | reg_num; + reg_value.SetUInt64((uint64_t)reg_kind << 24 | reg_num); else - reg_value = 0; + reg_value.SetUInt64(0); return true; } @@ -344,10 +411,13 @@ EmulateInstruction::WriteRegisterDefault (EmulateInstruction *instruction, void *baton, const Context &context, - const RegisterInfo ®_info, - uint64_t reg_value) + const RegisterInfo *reg_info, + const RegisterValue ®_value) { - fprintf (stdout, " Write to Register (name = %s, value = 0x%llx, context = ", reg_info.name, reg_value); + StreamFile strm (stdout, false); + strm.Printf (" Write to Register (name = %s, value = " , reg_info->name); + reg_value.Dump(&strm, reg_info, false); + strm.PutCString (", context = "); context.Dump (stdout, instruction); return true; } @@ -548,41 +618,41 @@ } bool -EmulateInstruction::GetBestRegisterKindAndNumber (const RegisterInfo ®_info, +EmulateInstruction::GetBestRegisterKindAndNumber (const RegisterInfo *reg_info, uint32_t ®_kind, uint32_t ®_num) { // Generic and DWARF should be the two most popular register kinds when // emulating instructions since they are the most platform agnostic... - reg_num = reg_info.kinds[eRegisterKindGeneric]; + reg_num = reg_info->kinds[eRegisterKindGeneric]; if (reg_num != LLDB_INVALID_REGNUM) { reg_kind = eRegisterKindGeneric; return true; } - reg_num = reg_info.kinds[eRegisterKindDWARF]; + reg_num = reg_info->kinds[eRegisterKindDWARF]; if (reg_num != LLDB_INVALID_REGNUM) { reg_kind = eRegisterKindDWARF; return true; } - reg_num = reg_info.kinds[eRegisterKindLLDB]; + reg_num = reg_info->kinds[eRegisterKindLLDB]; if (reg_num != LLDB_INVALID_REGNUM) { reg_kind = eRegisterKindLLDB; return true; } - reg_num = reg_info.kinds[eRegisterKindGCC]; + reg_num = reg_info->kinds[eRegisterKindGCC]; if (reg_num != LLDB_INVALID_REGNUM) { reg_kind = eRegisterKindGCC; return true; } - reg_num = reg_info.kinds[eRegisterKindGDB]; + reg_num = reg_info->kinds[eRegisterKindGDB]; if (reg_num != LLDB_INVALID_REGNUM) { reg_kind = eRegisterKindGDB; @@ -595,7 +665,7 @@ EmulateInstruction::GetInternalRegisterNumber (RegisterContext *reg_ctx, const RegisterInfo ®_info) { uint32_t reg_kind, reg_num; - if (reg_ctx && GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) + if (reg_ctx && GetBestRegisterKindAndNumber (®_info, reg_kind, reg_num)) return reg_ctx->ConvertRegisterKindToRegisterNumber (reg_kind, reg_num); return LLDB_INVALID_REGNUM; } Added: lldb/trunk/source/Core/RegisterValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=131096&view=auto ============================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp (added) +++ lldb/trunk/source/Core/RegisterValue.cpp Mon May 9 15:18:18 2011 @@ -0,0 +1,896 @@ +//===-- 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" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/Scalar.h" +#include "lldb/Core/Stream.h" +#include "lldb/Interpreter/Args.h" + +using namespace lldb; +using namespace lldb_private; + + +bool +RegisterValue::Dump (Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, Format format) const +{ + DataExtractor data; + if (GetData (data)) + { + if (prefix_with_name && reg_info->name != NULL) + s->Printf ("%s = ", reg_info->name); + if (format == eFormatDefault) + format = reg_info->format; + + data.Dump (s, + 0, // Offset in "data" + format, // Format to use when dumping + reg_info->byte_size, // item_byte_size + 1, // item_count + UINT32_MAX, // num_per_line + LLDB_INVALID_ADDRESS, // base_addr + 0, // item_bit_size + 0); // item_bit_offset + return true; + } + return false; +} + + +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, + Error &error) const +{ + if (reg_info == NULL) + { + error.SetErrorString ("invalid register info argument."); + return 0; + } + + // ReadRegister should have already been called on tgus 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, + Error &error) +{ + if (reg_info == NULL) + { + 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 + // + // Error! (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); + + // Given the register info, set the value type of this RegisterValue object + SetType (reg_info); + // And make sure we were able to figure out what that register value was + RegisterValue::Type value_type = GetType(); + if (value_type == eTypeInvalid) + { + // No value has been read into this object... + error.SetErrorStringWithFormat("invalid register value type for register %s", reg_info->name); + return 0; + } + else if (value_type == eTypeBytes) + { + m_data.buffer.byte_order = src_byte_order; + } + + const uint32_t bytes_copied = src_data.CopyByteOrderedData (0, // src offset + src_len, // src length + GetBytes(), // dst buffer + GetByteSize(), // dst length + GetByteOrder()); // dst byte order + if (bytes_copied == 0) + error.SetErrorStringWithFormat("failed to copy data for register write of %s", reg_info->name); + + return bytes_copied; +} + +bool +RegisterValue::GetScalarValue (Scalar &scalar) const +{ + switch (m_type) + { + case eTypeInvalid: break; + case eTypeBytes: break; + case eTypeUInt8: scalar = m_data.uint8; return true; + case eTypeUInt16: scalar = m_data.uint16; return true; + case eTypeUInt32: scalar = m_data.uint32; return true; + case eTypeUInt64: scalar = m_data.uint64; return true; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: break; +#endif + case eTypeFloat: scalar = m_data.ieee_float; return true; + case eTypeDouble: scalar = m_data.ieee_double; return true; + case eTypeLongDouble: scalar = m_data.ieee_long_double; return true; + } + return false; +} + +void +RegisterValue::Clear() +{ + m_type = eTypeInvalid; +} + +RegisterValue::Type +RegisterValue::SetType (const RegisterInfo *reg_info) +{ + m_type = eTypeInvalid; + const uint32_t byte_size = reg_info->byte_size; + switch (reg_info->encoding) + { + case eEncodingInvalid: + break; + + case eEncodingUint: + case eEncodingSint: + if (byte_size == 1) + m_type = eTypeUInt8; + else if (byte_size <= 2) + m_type = eTypeUInt16; + else if (byte_size <= 4) + m_type = eTypeUInt32; + else if (byte_size <= 8) + m_type = eTypeUInt64; +#if defined (ENABLE_128_BIT_SUPPORT) + else if (byte_size <= 16) + m_type = eTypeUInt128; +#endif + break; + + case eEncodingIEEE754: + if (byte_size == sizeof(float)) + m_type = eTypeFloat; + if (byte_size == sizeof(double)) + m_type = eTypeDouble; + if (byte_size == sizeof(long double)) + m_type = eTypeLongDouble; + break; + + case eEncodingVector: + m_type = eTypeBytes; + break; + } + return m_type; +} + +Error +RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, uint32_t src_offset, bool partial_data_ok) +{ + Error 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 (m_data.buffer.bytes, 0, sizeof (m_data.buffer.bytes)); + + switch (SetType (reg_info)) + { + case eTypeInvalid: + error.SetErrorString(""); + break; + case eTypeUInt8: SetUInt8 (src.GetMaxU32 (&src_offset, src_len)); break; + case eTypeUInt16: SetUInt16 (src.GetMaxU32 (&src_offset, src_len)); break; + case eTypeUInt32: SetUInt32 (src.GetMaxU32 (&src_offset, src_len)); break; + case eTypeUInt64: SetUInt64 (src.GetMaxU64 (&src_offset, src_len)); break; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: + { + __uint128_t data1 = src.GetU64 (&src_offset); + __uint128_t data2 = src.GetU64 (&src_offset); + if (src.GetByteSize() == eByteOrderBig) + SetUInt128 (data1 << 64 + data2); + else + SetUInt128 (data2 << 64 + data1); + } + break; +#endif + case eTypeFloat: SetFloat (src.GetFloat (&src_offset)); break; + case eTypeDouble: SetDouble(src.GetDouble (&src_offset)); break; + case eTypeLongDouble: SetFloat (src.GetLongDouble (&src_offset)); break; + case eTypeBytes: + { + m_data.buffer.length = reg_info->byte_size; + m_data.buffer.byte_order = src.GetByteOrder(); + assert (m_data.buffer.length <= kMaxRegisterByteSize); + if (m_data.buffer.length > kMaxRegisterByteSize) + m_data.buffer.length = kMaxRegisterByteSize; + if (src.CopyByteOrderedData (src_offset, // offset within "src" to start extracting data + src_len, // src length + m_data.buffer.bytes, // dst buffer + m_data.buffer.length, // dst length + m_data.buffer.byte_order) == 0)// dst byte order + { + error.SetErrorString ("data copy failed data."); + return error; + } + } + } + + return error; +} + +Error +RegisterValue::SetValueFromCString (const RegisterInfo *reg_info, const char *value_str) +{ + Error error; + if (reg_info == NULL) + { + error.SetErrorString ("Invalid register info argument."); + return error; + } + + if (value_str == NULL && value_str[0] == '\0') + { + error.SetErrorString ("Invalid c-string value string."); + return error; + } + bool success = false; + const uint32_t byte_size = reg_info->byte_size; + switch (reg_info->encoding) + { + default: + case eEncodingInvalid: + error.SetErrorString ("Invalid encoding."); + break; + + case eEncodingUint: + if (byte_size <= sizeof (uint64_t)) + { + uint64_t uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value.\n", value_str); + else if (!Args::UInt64ValueIsValidForByteSize (uval64, byte_size)) + error.SetErrorStringWithFormat ("Value 0x%llx is too large to fit in a %u byte unsigned integer value.\n", uval64, byte_size); + else + { + if (!SetUInt (uval64, reg_info->byte_size)) + error.SetErrorStringWithFormat ("Unsupported unsigned integer byte size: %u.\n", byte_size); + } + } + else + { + error.SetErrorStringWithFormat ("Unsupported unsigned integer byte size: %u.\n", byte_size); + return error; + } + break; + + case eEncodingSint: + if (byte_size <= sizeof (long long)) + { + uint64_t sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value.\n", value_str); + else if (!Args::SInt64ValueIsValidForByteSize (sval64, byte_size)) + error.SetErrorStringWithFormat ("Value 0x%llx is too large to fit in a %u byte signed integer value.\n", sval64, byte_size); + else + { + if (!SetUInt (sval64, reg_info->byte_size)) + error.SetErrorStringWithFormat ("Unsupported signed integer byte size: %u.\n", byte_size); + } + } + else + { + error.SetErrorStringWithFormat ("Unsupported signed integer byte size: %u.\n", byte_size); + return error; + } + break; + + case eEncodingIEEE754: + if (byte_size == sizeof (float)) + { + if (::sscanf (value_str, "%f", &m_data.ieee_float) == 1) + m_type = eTypeFloat; + else + error.SetErrorStringWithFormat ("'%s' is not a valid float string value.\n", value_str); + } + else if (byte_size == sizeof (double)) + { + if (::sscanf (value_str, "%lf", &m_data.ieee_double) == 1) + m_type = eTypeDouble; + else + error.SetErrorStringWithFormat ("'%s' is not a valid float string value.\n", value_str); + } + else if (byte_size == sizeof (long double)) + { + if (::sscanf (value_str, "%Lf", &m_data.ieee_long_double) == 1) + m_type = eTypeLongDouble; + else + error.SetErrorStringWithFormat ("'%s' is not a valid float string value.\n", value_str); + } + else + { + error.SetErrorStringWithFormat ("Unsupported float byte size: %u.\n", byte_size); + return error; + } + break; + + case eEncodingVector: + error.SetErrorString ("Vector encoding unsupported."); + break; + } + if (error.Fail()) + m_type = eTypeInvalid; + + return error; +} + + +bool +RegisterValue::SignExtend (uint32_t sign_bitpos) +{ + switch (m_type) + { + case eTypeInvalid: + break; + + case eTypeUInt8: + if (sign_bitpos == (8-1)) + return true; + else if (sign_bitpos < (8-1)) + { + uint8_t sign_bit = 1u << sign_bitpos; + if (m_data.uint8 & sign_bit) + { + const uint8_t mask = ~(sign_bit) + 1u; + m_data.uint8 |= mask; + } + return true; + } + break; + + case eTypeUInt16: + if (sign_bitpos == (16-1)) + return true; + else if (sign_bitpos < (16-1)) + { + uint16_t sign_bit = 1u << sign_bitpos; + if (m_data.uint16 & sign_bit) + { + const uint16_t mask = ~(sign_bit) + 1u; + m_data.uint16 |= mask; + } + return true; + } + break; + + case eTypeUInt32: + if (sign_bitpos == (32-1)) + return true; + else if (sign_bitpos < (32-1)) + { + uint32_t sign_bit = 1u << sign_bitpos; + if (m_data.uint32 & sign_bit) + { + const uint32_t mask = ~(sign_bit) + 1u; + m_data.uint32 |= mask; + } + return true; + } + break; + + case eTypeUInt64: + if (sign_bitpos == (64-1)) + return true; + else if (sign_bitpos < (64-1)) + { + uint64_t sign_bit = 1ull << sign_bitpos; + if (m_data.uint64 & sign_bit) + { + const uint64_t mask = ~(sign_bit) + 1ull; + m_data.uint64 |= mask; + } + return true; + } + break; + +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: + if (sign_bitpos == (128-1)) + return true; + else if (sign_bitpos < (128-1)) + { + __uint128_t sign_bit = (__uint128_t)1u << sign_bitpos; + if (m_data.uint128 & sign_bit) + { + const uint128_t mask = ~(sign_bit) + 1u; + m_data.uint128 |= mask; + } + return true; + } + break; +#endif + case eTypeFloat: + case eTypeDouble: + case eTypeLongDouble: + case eTypeBytes: + break; + } + return false; +} + +bool +RegisterValue::CopyValue (const RegisterValue &rhs) +{ + m_type = rhs.m_type; + switch (m_type) + { + default: + case eTypeInvalid: + return false; + case eTypeUInt8: m_data.uint8 = rhs.m_data.uint8; break; + case eTypeUInt16: m_data.uint16 = rhs.m_data.uint16; break; + case eTypeUInt32: m_data.uint32 = rhs.m_data.uint32; break; + case eTypeUInt64: m_data.uint64 = rhs.m_data.uint64; break; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: m_data.uint128 = rhs.m_data.uint128; break; +#endif + case eTypeFloat: m_data.ieee_float = rhs.m_data.ieee_float; break; + case eTypeDouble: m_data.ieee_double = rhs.m_data.ieee_double; break; + case eTypeLongDouble: m_data.ieee_long_double = rhs.m_data.ieee_long_double; break; + case eTypeBytes: + assert (rhs.m_data.buffer.length <= kMaxRegisterByteSize); + ::memcpy (m_data.buffer.bytes, rhs.m_data.buffer.bytes, kMaxRegisterByteSize); + m_data.buffer.length = rhs.m_data.buffer.length; + m_data.buffer.byte_order = rhs.m_data.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: return m_data.uint8; + case eTypeUInt16: return m_data.uint16; + } + 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: return m_data.uint8; + case eTypeUInt16: return m_data.uint16; + case eTypeUInt32: return m_data.uint32; + case eTypeFloat: + if (sizeof(float) == sizeof(uint32_t)) + return m_data.uint32; + break; + case eTypeDouble: + if (sizeof(double) == sizeof(uint32_t)) + return m_data.uint32; + break; + case eTypeLongDouble: + if (sizeof(long double) == sizeof(uint32_t)) + return m_data.uint32; + 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: return m_data.uint8; + case eTypeUInt16: return m_data.uint16; + case eTypeUInt32: return m_data.uint32; + case eTypeUInt64: return m_data.uint64; + case eTypeFloat: + if (sizeof(float) == sizeof(uint64_t)) + return m_data.uint64; + break; + case eTypeDouble: + if (sizeof(double) == sizeof(uint64_t)) + return m_data.uint64; + break; + case eTypeLongDouble: + if (sizeof(long double) == sizeof(uint64_t)) + return m_data.uint64; + break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +#if defined (ENABLE_128_BIT_SUPPORT) +__uint128_t +RegisterValue::GetAsUInt128 (__uint128_t fail_value, bool *success_ptr) const +{ + if (success_ptr) + *success_ptr = true; + switch (m_type) + { + default: break; + case eTypeUInt8: return m_data.uint8; + case eTypeUInt16: return m_data.uint16; + case eTypeUInt32: return m_data.uint32; + case eTypeUInt64: return m_data.uint64; + case eTypeUInt128: return m_data.uint128; + case eTypeFloat: + if (sizeof(float) == sizeof(__uint128_t)) + return m_data.uint128; + break; + case eTypeDouble: + if (sizeof(double) == sizeof(__uint128_t)) + return m_data.uint128; + break; + case eTypeLongDouble: + if (sizeof(long double) == sizeof(__uint128_t)) + return m_data.uint128; + break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} +#endif +float +RegisterValue::GetAsFloat (float fail_value, bool *success_ptr) const +{ + if (success_ptr) + *success_ptr = true; + switch (m_type) + { + default: break; + case eTypeUInt32: + if (sizeof(float) == sizeof(m_data.uint32)) + return m_data.ieee_float; + break; + case eTypeUInt64: + if (sizeof(float) == sizeof(m_data.uint64)) + return m_data.ieee_float; + break; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: + if (sizeof(float) == sizeof(m_data.uint128)) + return m_data.ieee_float; + break; +#endif + case eTypeFloat: return m_data.ieee_float; + case eTypeDouble: + if (sizeof(float) == sizeof(double)) + return m_data.ieee_float; + break; + case eTypeLongDouble: + if (sizeof(float) == sizeof(long double)) + return m_data.ieee_float; + break; + } + 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: + if (sizeof(double) == sizeof(m_data.uint32)) + return m_data.ieee_double; + break; + + case eTypeUInt64: + if (sizeof(double) == sizeof(m_data.uint64)) + return m_data.ieee_double; + break; + +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: + if (sizeof(double) == sizeof(m_data.uint128)) + return m_data.ieee_double; +#endif + case eTypeFloat: return m_data.ieee_float; + case eTypeDouble: return m_data.ieee_double; + + case eTypeLongDouble: + if (sizeof(double) == sizeof(long double)) + return m_data.ieee_double; + break; + } + 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: + if (sizeof(long double) == sizeof(m_data.uint32)) + return m_data.ieee_long_double; + break; + + case eTypeUInt64: + if (sizeof(long double) == sizeof(m_data.uint64)) + return m_data.ieee_long_double; + break; + +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: + if (sizeof(long double) == sizeof(m_data.uint128)) + return m_data.ieee_long_double; +#endif + case eTypeFloat: return m_data.ieee_float; + case eTypeDouble: return m_data.ieee_double; + case eTypeLongDouble: return m_data.ieee_long_double; + break; + } + if (success_ptr) + *success_ptr = false; + return fail_value; +} + +const void * +RegisterValue::GetBytes () const +{ + switch (m_type) + { + case eTypeInvalid: break; + case eTypeUInt8: return &m_data.uint8; + case eTypeUInt16: return &m_data.uint16; + case eTypeUInt32: return &m_data.uint32; + case eTypeUInt64: return &m_data.uint64; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: return &m_data.uint128; +#endif + case eTypeFloat: return &m_data.ieee_float; + case eTypeDouble: return &m_data.ieee_double; + case eTypeLongDouble: return &m_data.ieee_long_double; + case eTypeBytes: return m_data.buffer.bytes; + } + return NULL; +} + +void * +RegisterValue::GetBytes () +{ + switch (m_type) + { + case eTypeInvalid: break; + case eTypeUInt8: return &m_data.uint8; + case eTypeUInt16: return &m_data.uint16; + case eTypeUInt32: return &m_data.uint32; + case eTypeUInt64: return &m_data.uint64; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: return &m_data.uint128; +#endif + case eTypeFloat: return &m_data.ieee_float; + case eTypeDouble: return &m_data.ieee_double; + case eTypeLongDouble: return &m_data.ieee_long_double; + case eTypeBytes: return m_data.buffer.bytes; + } + return NULL; +} + +uint32_t +RegisterValue::GetByteSize () const +{ + switch (m_type) + { + case eTypeInvalid: break; + case eTypeUInt8: return sizeof(m_data.uint8); + case eTypeUInt16: return sizeof(m_data.uint16); + case eTypeUInt32: return sizeof(m_data.uint32); + case eTypeUInt64: return sizeof(m_data.uint64); +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: return sizeof(m_data.uint128); +#endif + case eTypeFloat: return sizeof(m_data.ieee_float); + case eTypeDouble: return sizeof(m_data.ieee_double); + case eTypeLongDouble: return sizeof(m_data.ieee_long_double); + case eTypeBytes: return m_data.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); + } +#if defined (ENABLE_128_BIT_SUPPORT) + else if (byte_size <= 16) + { + SetUInt128 (uint); + } +#endif + 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 + // m_data.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... + assert (length <= sizeof (m_data.buffer.bytes)); + if (bytes && length > 0) + { + m_type = eTypeBytes; + m_data.buffer.length = length; + assert (length < sizeof (m_data.buffer.bytes)); + memcpy (m_data.buffer.bytes, bytes, length); + m_data.buffer.byte_order = byte_order; + } + else + { + m_type = eTypeInvalid; + m_data.buffer.length = 0; + } +} + Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Mon May 9 15:18:18 2011 @@ -252,28 +252,29 @@ #pragma mark ValueObjectRegister void -ValueObjectRegister::ConstructObject () +ValueObjectRegister::ConstructObject (uint32_t reg_num) { - m_reg_info = m_reg_ctx_sp->GetRegisterInfoAtIndex(m_reg_num); - if (m_reg_info) + const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoAtIndex (reg_num); + if (reg_info) { - if (m_reg_info->name) - m_name.SetCString(m_reg_info->name); - else if (m_reg_info->alt_name) - m_name.SetCString(m_reg_info->alt_name); + m_reg_info = *reg_info; + if (reg_info->name) + m_name.SetCString(reg_info->name); + else if (reg_info->alt_name) + m_name.SetCString(reg_info->alt_name); } } -ValueObjectRegister::ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx, uint32_t reg_num) : +ValueObjectRegister::ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num) : ValueObject (parent), - m_reg_ctx_sp (reg_ctx), - m_reg_info (NULL), - m_reg_num (reg_num), + m_reg_ctx_sp (reg_ctx_sp), + m_reg_info (), + m_reg_value (), m_type_name (), m_clang_type (NULL) { - assert (reg_ctx); - ConstructObject(); + assert (reg_ctx_sp.get()); + ConstructObject(reg_num); } ValueObjectSP @@ -285,13 +286,13 @@ ValueObjectRegister::ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx, uint32_t reg_num) : ValueObject (exe_scope), m_reg_ctx_sp (reg_ctx), - m_reg_info (NULL), - m_reg_num (reg_num), + m_reg_info (), + m_reg_value (), m_type_name (), m_clang_type (NULL) { assert (reg_ctx); - ConstructObject(); + ConstructObject(reg_num); } ValueObjectRegister::~ValueObjectRegister() @@ -301,7 +302,7 @@ lldb::clang_type_t ValueObjectRegister::GetClangType () { - if (m_clang_type == NULL && m_reg_info) + if (m_clang_type == NULL) { Process *process = m_reg_ctx_sp->CalculateProcess (); if (process) @@ -309,7 +310,8 @@ Module *exe_module = process->GetTarget().GetExecutableModule ().get(); if (exe_module) { - m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info->encoding, m_reg_info->byte_size * 8); + m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding, + m_reg_info.byte_size * 8); } } } @@ -346,7 +348,7 @@ size_t ValueObjectRegister::GetByteSize() { - return m_reg_info->byte_size; + return m_reg_info.byte_size; } bool @@ -355,41 +357,26 @@ m_error.Clear(); ExecutionContextScope *exe_scope = GetExecutionContextScope(); StackFrame *frame = exe_scope->CalculateStackFrame(); - if (frame) - { - m_reg_ctx_sp = frame->GetRegisterContext(); - if (m_reg_ctx_sp) - { - const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoAtIndex(m_reg_num); - if (m_reg_info != reg_info) - { - m_reg_info = reg_info; - if (m_reg_info) - { - if (m_reg_info->name) - m_name.SetCString(m_reg_info->name); - else if (m_reg_info->alt_name) - m_name.SetCString(m_reg_info->alt_name); - } - } - } - } - else + if (frame == NULL) { m_reg_ctx_sp.reset(); - m_reg_info = NULL; + m_reg_value.Clear(); } - if (m_reg_ctx_sp && m_reg_info) + if (m_reg_ctx_sp) { - if (m_reg_ctx_sp->ReadRegisterBytes (m_reg_num, m_data)) + if (m_reg_ctx_sp->ReadRegister (&m_reg_info, m_reg_value)) { - m_value.SetContext(Value::eContextTypeRegisterInfo, (void *)m_reg_info); - m_value.SetValueType(Value::eValueTypeHostAddress); - m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); - SetValueIsValid (true); - return true; + if (m_reg_value.GetData (m_data)) + { + m_data.SetAddressByteSize(m_reg_ctx_sp->GetThread().GetProcess().GetAddressByteSize()); + m_value.SetContext(Value::eContextTypeRegisterInfo, (void *)&m_reg_info); + m_value.SetValueType(Value::eValueTypeHostAddress); + m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); + SetValueIsValid (true); + return true; + } } } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon May 9 15:18:18 2011 @@ -20,6 +20,7 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Expression/ASTDumper.h" #include "lldb/Expression/ClangASTSource.h" @@ -686,25 +687,25 @@ return false; } - RegisterInfo *register_info = location_value->GetRegisterInfo(); + RegisterInfo *reg_info = location_value->GetRegisterInfo(); - if (!register_info) + if (!reg_info) { err.SetErrorStringWithFormat("Couldn't get the register information for %s", object_name.GetCString()); return false; } - RegisterContext *register_context = exe_ctx.GetRegisterContext(); + RegisterContext *reg_ctx = exe_ctx.GetRegisterContext(); - if (!register_context) + if (!reg_ctx) { - err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", object_name.GetCString(), register_info->name); + err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", object_name.GetCString(), reg_info->name); return false; } - uint32_t register_number = register_info->kinds[lldb::eRegisterKindLLDB]; + uint32_t register_number = reg_info->kinds[lldb::eRegisterKindLLDB]; - object_ptr = register_context->ReadRegisterAsUnsigned(register_number, 0x0); + object_ptr = reg_ctx->ReadRegisterAsUnsigned(register_number, 0x0); return true; } @@ -1328,26 +1329,27 @@ return false; } - lldb::addr_t mem; // The address of a spare memory area aused to hold the variable. + lldb::addr_t reg_addr = LLDB_INVALID_ADDRESS; // The address of a spare memory area aused to hold the variable. - RegisterInfo *register_info = location_value->GetRegisterInfo(); + RegisterInfo *reg_info = location_value->GetRegisterInfo(); - if (!register_info) + if (!reg_info) { err.SetErrorStringWithFormat("Couldn't get the register information for %s", name.GetCString()); return false; } - - RegisterContext *register_context = exe_ctx.GetRegisterContext(); - if (!register_context) + RegisterValue reg_value; + + RegisterContext *reg_ctx = exe_ctx.GetRegisterContext(); + + if (!reg_ctx) { - err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", name.GetCString(), register_info->name); + err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", name.GetCString(), reg_info->name); return false; } - uint32_t register_number = register_info->kinds[lldb::eRegisterKindLLDB]; - uint32_t register_byte_size = register_info->byte_size; + uint32_t register_byte_size = reg_info->byte_size; if (dematerialize) { @@ -1365,66 +1367,21 @@ return false; } - mem = expr_var->m_live_sp->GetValue().GetScalar().ULongLong(); - - // Moving from addr into a register - // - // Case 1: addr_byte_size and register_byte_size are the same - // - // |AABBCCDD| Address contents - // |AABBCCDD| Register contents - // - // Case 2: addr_byte_size is bigger than register_byte_size - // - // Error! (The register should always be big enough to hold the data) - // - // Case 3: register_byte_size is bigger than addr_byte_size - // - // |AABB| Address contents - // |AABB0000| Register contents [on little-endian hardware] - // |0000AABB| Register contents [on big-endian hardware] - - if (value_byte_size > register_byte_size) - { - err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), register_info->name); - return false; - } - - uint32_t register_offset; + reg_addr = expr_var->m_live_sp->GetValue().GetScalar().ULongLong(); - switch (exe_ctx.process->GetByteOrder()) - { - default: - err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name.GetCString()); + err = reg_ctx->ReadRegisterValueFromMemory (reg_info, reg_addr, value_byte_size, reg_value); + if (err.Fail()) return false; - case lldb::eByteOrderLittle: - register_offset = 0; - break; - case lldb::eByteOrderBig: - register_offset = register_byte_size - value_byte_size; - break; - } - - DataBufferHeap register_data (register_byte_size, 0); - - Error error; - if (exe_ctx.process->ReadMemory (mem, register_data.GetBytes() + register_offset, value_byte_size, error) != value_byte_size) - { - err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", name.GetCString(), error.AsCString()); - return false; - } - - DataExtractor register_extractor (register_data.GetBytes(), register_byte_size, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); - - if (!register_context->WriteRegisterBytes(register_number, register_extractor, 0)) + + if (!reg_ctx->WriteRegister (reg_info, reg_value)) { - err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), register_info->name); + err.SetErrorStringWithFormat("Couldn't write %s to register %s", name.GetCString(), reg_info->name); return false; } // Deallocate the spare area and clear the variable's live data. - Error deallocate_error = exe_ctx.process->DeallocateMemory(mem); + Error deallocate_error = exe_ctx.process->DeallocateMemory(reg_addr); if (!deallocate_error.Success()) { @@ -1441,11 +1398,11 @@ Error allocate_error; - mem = exe_ctx.process->AllocateMemory(value_byte_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - allocate_error); + reg_addr = exe_ctx.process->AllocateMemory (value_byte_size, + lldb::ePermissionsReadable | lldb::ePermissionsWritable, + allocate_error); - if (mem == LLDB_INVALID_ADDRESS) + if (reg_addr == LLDB_INVALID_ADDRESS) { err.SetErrorStringWithFormat("Couldn't allocate a memory area to store %s: %s", name.GetCString(), allocate_error.AsCString()); return false; @@ -1457,14 +1414,14 @@ type.GetASTContext(), type.GetOpaqueQualType(), name, - mem, + reg_addr, eAddressTypeLoad, value_byte_size); // Now write the location of the area into the struct. Error write_error; - if (!WriteAddressInto(exe_ctx, addr, mem, write_error)) + if (!WriteAddressInto(exe_ctx, addr, reg_addr, write_error)) { err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", name.GetCString(), write_error.AsCString()); return false; @@ -1489,7 +1446,7 @@ if (value_byte_size > register_byte_size) { - err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), register_info->name); + err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), reg_info->name); return false; } @@ -1507,28 +1464,18 @@ register_offset = register_byte_size - value_byte_size; break; } - - DataExtractor register_extractor; - - if (!register_context->ReadRegisterBytes(register_number, register_extractor)) - { - err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), register_info->name); - return false; - } - - const void *register_data = register_extractor.GetData(®ister_offset, value_byte_size); - - if (!register_data) + + RegisterValue reg_value; + + if (!reg_ctx->ReadRegister (reg_info, reg_value)) { - err.SetErrorStringWithFormat("Read but couldn't extract data for %s from %s", name.GetCString(), register_info->name); + err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), reg_info->name); return false; } - if (exe_ctx.process->WriteMemory (mem, register_data, value_byte_size, write_error) != value_byte_size) - { - err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", write_error.AsCString()); + err = reg_ctx->WriteRegisterValueToMemory(reg_info, reg_addr, value_byte_size, reg_value); + if (err.Fail()) return false; - } } } } @@ -1547,52 +1494,36 @@ Error &err ) { - uint32_t register_number = reg_info.kinds[lldb::eRegisterKindLLDB]; uint32_t register_byte_size = reg_info.byte_size; - + RegisterValue reg_value; if (dematerialize) { - DataBufferHeap register_data (register_byte_size, 0); - - Error read_error; - if (exe_ctx.process->ReadMemory (addr, register_data.GetBytes(), register_byte_size, read_error) != register_byte_size) + Error read_error (reg_ctx.ReadRegisterValueFromMemory(®_info, addr, register_byte_size, reg_value)); + if (read_error.Fail()) { err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", reg_info.name, read_error.AsCString()); return false; } - DataExtractor register_extractor (register_data.GetBytes(), register_byte_size, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); - - if (!reg_ctx.WriteRegisterBytes(register_number, register_extractor, 0)) + if (!reg_ctx.WriteRegister (®_info, reg_value)) { - err.SetErrorStringWithFormat("Couldn't read %s", reg_info.name); + err.SetErrorStringWithFormat("Couldn't write register %s (dematerialize)", reg_info.name); return false; } } else { - DataExtractor register_extractor; - - if (!reg_ctx.ReadRegisterBytes(register_number, register_extractor)) - { - err.SetErrorStringWithFormat("Couldn't read %s", reg_info.name); - return false; - } - - uint32_t register_offset = 0; - - const void *register_data = register_extractor.GetData(®ister_offset, register_byte_size); - if (!register_data) + if (!reg_ctx.ReadRegister(®_info, reg_value)) { - err.SetErrorStringWithFormat("Read but couldn't extract data for %s", reg_info.name); + err.SetErrorStringWithFormat("Couldn't read %s (materialize)", reg_info.name); return false; } - Error error; - if (exe_ctx.process->WriteMemory (addr, register_data, register_byte_size, error) != register_byte_size) + Error write_error (reg_ctx.WriteRegisterValueToMemory(®_info, addr, register_byte_size, reg_value)); + if (write_error.Fail()) { - err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", write_error.AsCString()); return false; } } Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon May 9 15:18:18 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/dwarf.h" #include "lldb/Core/Log.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" @@ -612,21 +613,21 @@ static bool ReadRegisterValueAsScalar ( - RegisterContext *reg_context, + RegisterContext *reg_ctx, uint32_t reg_kind, uint32_t reg_num, Error *error_ptr, Value &value ) { - if (reg_context == NULL) + if (reg_ctx == NULL) { if (error_ptr) error_ptr->SetErrorStringWithFormat("No register context in frame.\n"); } else { - uint32_t native_reg = reg_context->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num); + uint32_t native_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num); if (native_reg == LLDB_INVALID_REGNUM) { if (error_ptr) @@ -634,14 +635,29 @@ } else { - value.SetValueType (Value::eValueTypeScalar); - value.SetContext (Value::eContextTypeRegisterInfo, const_cast(reg_context->GetRegisterInfoAtIndex(native_reg))); - - if (reg_context->ReadRegisterValue (native_reg, value.GetScalar())) - return true; - - if (error_ptr) - error_ptr->SetErrorStringWithFormat("Failed to read register %u.\n", native_reg); + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(native_reg); + RegisterValue reg_value; + if (reg_ctx->ReadRegister (reg_info, reg_value)) + { + if (reg_value.GetScalarValue(value.GetScalar())) + { + value.SetValueType (Value::eValueTypeScalar); + value.SetContext (Value::eContextTypeRegisterInfo, const_cast(reg_info)); + if (error_ptr) + error_ptr->Clear(); + return true; + } + else + { + if (error_ptr) + error_ptr->SetErrorStringWithFormat("Failed to read register %u.\n", native_reg); + } + } + else + { + if (error_ptr) + error_ptr->SetErrorStringWithFormat("Failed to read register %u.\n", native_reg); + } } } return false; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon May 9 15:18:18 2011 @@ -501,9 +501,7 @@ data = MemARead(context, addr, 4, 0, &success); if (!success) return false; - RegisterInfo reg_info; - GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, reg_info); - if (!WriteRegisterUnsigned(context, reg_info, data)) + if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + i, data)) return false; addr += addr_byte_size; } @@ -802,12 +800,12 @@ break; case eEncodingA1: - // d = UInt(Rd); setflags = (S == ???1???); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C); + // d = UInt(Rd); setflags = (S == ?1?); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C); Rd = Bits32 (opcode, 15, 12); setflags = BitIsSet (opcode, 20); imm32 = ARMExpandImm_C (opcode, APSR_C, carry); - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rd == ?1111? && S == ?1? then SEE SUBS PC, LR and related instructions; if ((Rd == 15) && setflags) return EmulateSUBSPcLrEtc (opcode, encoding); @@ -1981,7 +1979,7 @@ GetRegisterInfo (eRegisterKindDWARF, start_reg + d + i, dwarf_reg); context.SetRegisterToRegisterPlusOffset ( dwarf_reg, sp_reg, addr - sp); // uint64_t to accommodate 64-bit registers. - uint64_t reg_value = ReadRegisterUnsigned(dwarf_reg, 0, &success); + uint64_t reg_value = ReadRegisterUnsigned (&dwarf_reg, 0, &success); if (!success) return false; if (!MemAWrite (context, addr, reg_value, reg_byte_size)) @@ -2077,7 +2075,7 @@ data = MemARead(context, addr, reg_byte_size, 0, &success); if (!success) return false; - if (!WriteRegisterUnsigned(context, dwarf_reg, data)) + if (!WriteRegisterUnsigned(context, &dwarf_reg, data)) return false; addr += reg_byte_size; } @@ -4232,7 +4230,7 @@ break; case eEncodingA1: - // if W == '1' && Rn == '1101??? && BitCount(register_list) >= 2 then SEE PUSH; + // if W == '1' && Rn == '1101? && BitCount(register_list) >= 2 then SEE PUSH; if (BitIsSet (opcode, 21) && (Bits32 (opcode, 19, 16) == 13) && BitCount (Bits32 (opcode, 15, 0)) >= 2) { // See Push @@ -9275,7 +9273,7 @@ if ConditionPassed() then EncodingSpecificOperations(); shifted = Shift(R[m], shift_t, shift_n, APSR.C); - (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ???1???); + (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ?1?); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -9300,7 +9298,7 @@ switch (encoding) { case eEncodingT1: - // d = UInt(Rd); m = UInt(Rm); setflags = (S == ???1???); + // d = UInt(Rd); m = UInt(Rm); setflags = (S == ?1?); d = Bits32 (opcode, 11, 8); m = Bits32 (opcode, 3, 0); setflags = BitIsSet (opcode, 20); @@ -9318,12 +9316,12 @@ break; case eEncodingA1: - // d = UInt(Rd); m = UInt(Rm); setflags = (S == ???1???); + // d = UInt(Rd); m = UInt(Rm); setflags = (S == ?1?); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); setflags = BitIsSet (opcode, 20); - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rd == ?1111? && S == ?1? then SEE SUBS PC, LR and related instructions; if (d == 15 && setflags) EmulateSUBSPcLrEtc (opcode, encoding); @@ -9342,7 +9340,7 @@ uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); - // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ???1???); + // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ?1?); uint32_t sp_val = ReadCoreReg (SP_REG, &success); if (!success) return false; @@ -9373,7 +9371,7 @@ EncodingSpecificOperations(); shift_n = UInt(R[s]<7:0>); shifted = Shift(R[m], shift_t, shift_n, APSR.C); - (result, carry, overflow) = AddWithCarry(R[n], shifted, ???0???); + (result, carry, overflow) = AddWithCarry(R[n], shifted, ?0?); R[d] = result; if setflags then APSR.N = result<31>; @@ -9402,7 +9400,7 @@ m = Bits32 (opcode, 3, 0); s = Bits32 (opcode, 11, 8); - // setflags = (S == ???1???); shift_t = DecodeRegShift(type); + // setflags = (S == ?1?); shift_t = DecodeRegShift(type); setflags = BitIsSet (opcode, 20); shift_t = DecodeRegShift (Bits32 (opcode, 6, 5)); @@ -9429,7 +9427,7 @@ uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); - // (result, carry, overflow) = AddWithCarry(R[n], shifted, ???0???); + // (result, carry, overflow) = AddWithCarry(R[n], shifted, ?0?); uint32_t Rn = ReadCoreReg (n, &success); if (!success) return false; @@ -9468,7 +9466,7 @@ if ConditionPassed() then EncodingSpecificOperations(); shifted = Shift(R[m], shift_t, shift_n, APSR.C); - (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ???1???); + (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ?1?); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -9507,9 +9505,9 @@ break; case eEncodingT2: - // if Rd == ???1111??? && S == ???1??? then SEE CMP (register); - // if Rn == ???1101??? then SEE SUB (SP minus register); - // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); + // if Rd == ?1111? && S == ?1? then SEE CMP (register); + // if Rn == ?1101? then SEE SUB (SP minus register); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ?1?); d = Bits32 (opcode, 11, 8); n = Bits32 (opcode, 19, 16); m = Bits32 (opcode, 3, 0); @@ -9525,14 +9523,14 @@ break; case eEncodingA1: - // if Rn == ???1101??? then SEE SUB (SP minus register); - // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); + // if Rn == ?1101? then SEE SUB (SP minus register); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ?1?); d = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); m = Bits32 (opcode, 3, 0); setflags = BitIsSet (opcode, 20); - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rd == ?1111? && S == ?1? then SEE SUBS PC, LR and related instructions; if ((d == 15) && setflags) EmulateSUBSPcLrEtc (opcode, encoding); @@ -9552,7 +9550,7 @@ uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); - // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ???1???); + // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ?1?); uint32_t Rn = ReadCoreReg (n, &success); if (!success) return false; @@ -9613,7 +9611,7 @@ switch (encoding) { case eEncodingT1: - // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:???00???, 32); + // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:?00?, 32); d = Bits32 (opcode, 11, 8); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -9719,13 +9717,13 @@ switch (encoding) { case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE STRBT; + // if P == ?0? && W == ?1? then SEE STRBT; // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 11, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); @@ -9817,14 +9815,14 @@ switch (encoding) { case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE STRT; - // if Rn == ???1101??? && P == ???1??? && U == ???0??? && W == ???1??? && imm12 == ???000000000100??? then SEE PUSH; + // if P == ?0? && W == ?1? then SEE STRT; + // if Rn == ?1101? && P == ?1? && U == ?0? && W == ?1? && imm12 == ?000000000100? then SEE PUSH; // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 11, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); @@ -9929,15 +9927,15 @@ switch (encoding) { case eEncodingT1: - //if P == ???0??? && W == ???0??? then SEE ???Related encodings???; - //if Rn == ???1111??? then SEE LDRD (literal); - //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:???00???, 32); + //if P == ?0? && W == ?0? then SEE ?Related encodings?; + //if Rn == ?1111? then SEE LDRD (literal); + //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:?00?, 32); t = Bits32 (opcode, 15, 12); t2 = Bits32 (opcode, 11, 8); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0) << 2; - //index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + //index = (P == ?1?); add = (U == ?1?); wback = (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); @@ -9953,8 +9951,8 @@ break; case eEncodingA1: - //if Rn == ???1111??? then SEE LDRD (literal); - //if Rt<0> == ???1??? then UNPREDICTABLE; + //if Rn == ?1111? then SEE LDRD (literal); + //if Rt<0> == ?1? then UNPREDICTABLE; //t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); t = Bits32 (opcode, 15, 12); if (BitIsSet (t, 0)) @@ -9963,12 +9961,12 @@ n = Bits32 (opcode, 19, 16); imm32 = (Bits32 (opcode, 11, 8) << 4) | Bits32 (opcode, 3, 0); - //index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + //index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); - //if P == ???0??? && W == ???1??? then UNPREDICTABLE; + //if P == ?0? && W == ?1? then UNPREDICTABLE; if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21)) return false; @@ -10074,7 +10072,7 @@ switch (encoding) { case eEncodingA1: - // if Rt<0> == ???1??? then UNPREDICTABLE; + // if Rt<0> == ?1? then UNPREDICTABLE; // t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); if (BitIsSet (t, 0)) @@ -10083,12 +10081,12 @@ n = Bits32 (opcode, 19, 16); m = Bits32 (opcode, 3, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); - // if P == ???0??? && W == ???1??? then UNPREDICTABLE; + // if P == ?0? && W == ?1? then UNPREDICTABLE; if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21)) return false; @@ -10201,14 +10199,14 @@ switch (encoding) { case eEncodingT1: - // if P == ???0??? && W == ???0??? then SEE ???Related encodings???; - // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:???00???, 32); + // if P == ?0? && W == ?0? then SEE ?Related encodings?; + // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:?00?, 32); t = Bits32 (opcode, 15, 12); t2 = Bits32 (opcode, 11, 8); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0) << 2; - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); @@ -10224,7 +10222,7 @@ break; case eEncodingA1: - // if Rt<0> == ???1??? then UNPREDICTABLE; + // if Rt<0> == ?1? then UNPREDICTABLE; // t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); t = Bits32 (opcode, 15, 12); if (BitIsSet (t, 0)) @@ -10234,12 +10232,12 @@ n = Bits32 (opcode, 19, 16); imm32 = (Bits32 (opcode, 11, 8) << 4) | Bits32 (opcode, 3, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); - // if P == ???0??? && W == ???1??? then UNPREDICTABLE; + // if P == ?0? && W == ?1? then UNPREDICTABLE; if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21)) return false; @@ -10349,7 +10347,7 @@ switch (encoding) { case eEncodingA1: - // if Rt<0> == ???1??? then UNPREDICTABLE; + // if Rt<0> == ?1? then UNPREDICTABLE; // t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); if (BitIsSet (t, 0)) @@ -10359,12 +10357,12 @@ n = Bits32 (opcode, 19, 16); m = Bits32 (opcode, 3, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // index = (P == ?1?); add = (U == ?1?); wback = (P == ?0?) || (W == ?1?); index = BitIsSet (opcode, 24); add = BitIsSet (opcode, 23); wback = BitIsClear (opcode, 24) || BitIsSet (opcode, 21); - // if P == ???0??? && W == ???1??? then UNPREDICTABLE; + // if P == ?0? && W == ?1? then UNPREDICTABLE; if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21)) return false; @@ -10490,25 +10488,25 @@ { case eEncodingT1: case eEncodingA1: - // if P == ???0??? && U == ???0??? && W == ???0??? then SEE ???Related encodings???; - // if P == ???0??? && U == ???1??? && W == ???1??? && Rn == ???1101??? then SEE VPOP; - // if P == ???1??? && W == ???0??? then SEE VLDR; - // if P == U && W == ???1??? then UNDEFINED; + // if P == ?0? && U == ?0? && W == ?0? then SEE ?Related encodings?; + // if P == ?0? && U == ?1? && W == ?1? && Rn == ?1101? then SEE VPOP; + // if P == ?1? && W == ?0? then SEE VLDR; + // if P == U && W == ?1? then UNDEFINED; if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21)) return false; // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !) - // single_regs = FALSE; add = (U == ???1???); wback = (W == ???1???); + // single_regs = FALSE; add = (U == ?1?); wback = (W == ?1?); single_regs = false; add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); - // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:???00???, 32); + // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:?00?, 32); d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0) << 2; - // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ???FLDMX???. + // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ?FLDMX?. regs = Bits32 (opcode, 7, 0) / 2; // if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE; @@ -10523,22 +10521,22 @@ case eEncodingT2: case eEncodingA2: - // if P == ???0??? && U == ???0??? && W == ???0??? then SEE ???Related encodings???; - // if P == ???0??? && U == ???1??? && W == ???1??? && Rn == ???1101??? then SEE VPOP; - // if P == ???1??? && W == ???0??? then SEE VLDR; - // if P == U && W == ???1??? then UNDEFINED; + // if P == ?0? && U == ?0? && W == ?0? then SEE ?Related encodings?; + // if P == ?0? && U == ?1? && W == ?1? && Rn == ?1101? then SEE VPOP; + // if P == ?1? && W == ?0? then SEE VLDR; + // if P == U && W == ?1? then UNDEFINED; if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21)) return false; // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !) - // single_regs = TRUE; add = (U == ???1???); wback = (W == ???1???); d = UInt(Vd:D); n = UInt(Rn); + // single_regs = TRUE; add = (U == ?1?); wback = (W == ?1?); d = UInt(Vd:D); n = UInt(Rn); single_regs = true; add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22); n = Bits32 (opcode, 19, 16); - // imm32 = ZeroExtend(imm8:???00???, 32); regs = UInt(imm8); + // imm32 = ZeroExtend(imm8:?00?, 32); regs = UInt(imm8); imm32 = Bits32 (opcode, 7, 0) << 2; regs = Bits32 (opcode, 7, 0); @@ -10682,25 +10680,25 @@ { case eEncodingT1: case eEncodingA1: - // if P == ???0??? && U == ???0??? && W == ???0??? then SEE ???Related encodings???; - // if P == ???1??? && U == ???0??? && W == ???1??? && Rn == ???1101??? then SEE VPUSH; - // if P == ???1??? && W == ???0??? then SEE VSTR; - // if P == U && W == ???1??? then UNDEFINED; + // if P == ?0? && U == ?0? && W == ?0? then SEE ?Related encodings?; + // if P == ?1? && U == ?0? && W == ?1? && Rn == ?1101? then SEE VPUSH; + // if P == ?1? && W == ?0? then SEE VSTR; + // if P == U && W == ?1? then UNDEFINED; if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21)) return false; // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !) - // single_regs = FALSE; add = (U == ???1???); wback = (W == ???1???); + // single_regs = FALSE; add = (U == ?1?); wback = (W == ?1?); single_regs = false; add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); - // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:???00???, 32); + // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:?00?, 32); d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0) << 2; - // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ???FSTMX???. + // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ?FSTMX?. regs = Bits32 (opcode, 7, 0) / 2; // if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE; @@ -10715,22 +10713,22 @@ case eEncodingT2: case eEncodingA2: - // if P == ???0??? && U == ???0??? && W == ???0??? then SEE ???Related encodings???; - // if P == ???1??? && U == ???0??? && W == ???1??? && Rn == ???1101??? then SEE VPUSH; - // if P == ???1??? && W == ???0??? then SEE VSTR; - // if P == U && W == ???1??? then UNDEFINED; + // if P == ?0? && U == ?0? && W == ?0? then SEE ?Related encodings?; + // if P == ?1? && U == ?0? && W == ?1? && Rn == ?1101? then SEE VPUSH; + // if P == ?1? && W == ?0? then SEE VSTR; + // if P == U && W == ?1? then UNDEFINED; if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21)) return false; // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !) - // single_regs = TRUE; add = (U == ???1???); wback = (W == ???1???); d = UInt(Vd:D); n = UInt(Rn); + // single_regs = TRUE; add = (U == ?1?); wback = (W == ?1?); d = UInt(Vd:D); n = UInt(Rn); single_regs = true; add = BitIsSet (opcode, 23); wback = BitIsSet (opcode, 21); d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22); n = Bits32 (opcode, 19, 16); - // imm32 = ZeroExtend(imm8:???00???, 32); regs = UInt(imm8); + // imm32 = ZeroExtend(imm8:?00?, 32); regs = UInt(imm8); imm32 = Bits32 (opcode, 7, 0) << 2; regs = Bits32 (opcode, 7, 0); @@ -10875,7 +10873,7 @@ { case eEncodingT1: case eEncodingA1: - // single_reg = FALSE; add = (U == ???1???); imm32 = ZeroExtend(imm8:???00???, 32); + // single_reg = FALSE; add = (U == ?1?); imm32 = ZeroExtend(imm8:?00?, 32); single_reg = false; add = BitIsSet (opcode, 23); imm32 = Bits32 (opcode, 7, 0) << 2; @@ -10888,7 +10886,7 @@ case eEncodingT2: case eEncodingA2: - // single_reg = TRUE; add = (U == ???1???); imm32 = ZeroExtend(imm8:???00???, 32); + // single_reg = TRUE; add = (U == ?1?); imm32 = ZeroExtend(imm8:?00?, 32); single_reg = true; add = BitIsSet (opcode, 23); imm32 = Bits32 (opcode, 7, 0) << 2; @@ -11004,7 +11002,7 @@ { case eEncodingT1: case eEncodingA1: - // single_reg = FALSE; add = (U == ???1???); imm32 = ZeroExtend(imm8:???00???, 32); + // single_reg = FALSE; add = (U == ?1?); imm32 = ZeroExtend(imm8:?00?, 32); single_reg = false; add = BitIsSet (opcode, 23); imm32 = Bits32 (opcode, 7, 0) << 2; @@ -11021,7 +11019,7 @@ case eEncodingT2: case eEncodingA2: - // single_reg = TRUE; add = (U == ???1???); imm32 = ZeroExtend(imm8:???00???, 32); + // single_reg = TRUE; add = (U == ?1?); imm32 = ZeroExtend(imm8:?00?, 32); single_reg = true; add = BitIsSet (opcode, 23); imm32 = Bits32 (opcode, 7, 0) << 2; @@ -11143,16 +11141,16 @@ case eEncodingA1: { // case type of - // when ???0111??? - // regs = 1; if align<1> == ???1??? then UNDEFINED; - // when ???1010??? - // regs = 2; if align == ???11??? then UNDEFINED; - // when ???0110??? - // regs = 3; if align<1> == ???1??? then UNDEFINED; - // when ???0010??? + // when ?0111? + // regs = 1; if align<1> == ?1? then UNDEFINED; + // when ?1010? + // regs = 2; if align == ?11? then UNDEFINED; + // when ?0110? + // regs = 3; if align<1> == ?1? then UNDEFINED; + // when ?0010? // regs = 4; // otherwise - // SEE ???Related encodings???; + // SEE ?Related encodings?; uint32_t type = Bits32 (opcode, 11, 8); uint32_t align = Bits32 (opcode, 5, 4); if (type == 7) // '0111' @@ -11181,7 +11179,7 @@ else return false; - // alignment = if align == ???00??? then 1 else 4 << UInt(align); + // alignment = if align == ?00? then 1 else 4 << UInt(align); if (align == 0) alignment = 1; else @@ -11306,13 +11304,13 @@ { uint32_t size = Bits32 (opcode, 11, 10); uint32_t index_align = Bits32 (opcode, 7, 4); - // if size == ???11??? then SEE VLD1 (single element to all lanes); + // if size == ?11? then SEE VLD1 (single element to all lanes); if (size == 3) return EmulateVLD1SingleAll (opcode, encoding); // case size of if (size == 0) // when '00' { - // if index_align<0> != ???0??? then UNDEFINED; + // if index_align<0> != ?0? then UNDEFINED; if (BitIsClear (index_align, 0)) return false; @@ -11322,9 +11320,9 @@ index = Bits32 (index_align, 3, 1); alignment = 1; } - else if (size == 1) // when ???01??? + else if (size == 1) // when ?01? { - // if index_align<1> != ???0??? then UNDEFINED; + // if index_align<1> != ?0? then UNDEFINED; if (BitIsClear (index_align, 1)) return false; @@ -11333,19 +11331,19 @@ esize = 16; index = Bits32 (index_align, 3, 2); - // alignment = if index_align<0> == ???0??? then 1 else 2; + // alignment = if index_align<0> == ?0? then 1 else 2; if (BitIsClear (index_align, 0)) alignment = 1; else alignment = 2; } - else if (size == 2) // when ???10??? + else if (size == 2) // when ?10? { - // if index_align<2> != ???0??? then UNDEFINED; + // if index_align<2> != ?0? then UNDEFINED; if (BitIsClear (index_align, 2)) return false; - // if index_align<1:0> != ???00??? && index_align<1:0> != ???11??? then UNDEFINED; + // if index_align<1:0> != ?00? && index_align<1:0> != ?11? then UNDEFINED; if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3)) return false; @@ -11354,7 +11352,7 @@ esize = 32; index = Bit32 (index_align, 3); - // alignment = if index_align<1:0> == ???00??? then 1 else 4; + // alignment = if index_align<1:0> == ?00? then 1 else 4; if (Bits32 (index_align, 1, 0) == 0) alignment = 1; else @@ -11484,35 +11482,35 @@ uint32_t align = Bits32 (opcode, 5, 4); // case type of - if (type == 7) // when ???0111??? + if (type == 7) // when ?0111? { - // regs = 1; if align<1> == ???1??? then UNDEFINED; + // regs = 1; if align<1> == ?1? then UNDEFINED; regs = 1; if (BitIsSet (align, 1)) return false; } - else if (type == 10) // when ???1010??? + else if (type == 10) // when ?1010? { - // regs = 2; if align == ???11??? then UNDEFINED; + // regs = 2; if align == ?11? then UNDEFINED; regs = 2; if (align == 3) return false; } - else if (type == 6) // when ???0110??? + else if (type == 6) // when ?0110? { - // regs = 3; if align<1> == ???1??? then UNDEFINED; + // regs = 3; if align<1> == ?1? then UNDEFINED; regs = 3; if (BitIsSet (align, 1)) return false; } - else if (type == 2) // when ???0010??? + else if (type == 2) // when ?0010? // regs = 4; regs = 4; else // otherwise - // SEE ???Related encodings???; + // SEE ?Related encodings?; return false; - // alignment = if align == ???00??? then 1 else 4 << UInt(align); + // alignment = if align == ?00? then 1 else 4 << UInt(align); if (align == 0) alignment = 0; else @@ -11642,14 +11640,14 @@ uint32_t size = Bits32 (opcode, 11, 10); uint32_t index_align = Bits32 (opcode, 7, 4); - // if size == ???11??? then UNDEFINED; + // if size == ?11? then UNDEFINED; if (size == 3) return false; // case size of - if (size == 0) // when ???00??? + if (size == 0) // when ?00? { - // if index_align<0> != ???0??? then UNDEFINED; + // if index_align<0> != ?0? then UNDEFINED; if (BitIsClear (index_align, 0)) return false; // ebytes = 1; esize = 8; index = UInt(index_align<3:1>); alignment = 1; @@ -11658,9 +11656,9 @@ index = Bits32 (index_align, 3, 1); alignment = 1; } - else if (size == 1) // when ???01??? + else if (size == 1) // when ?01? { - // if index_align<1> != ???0??? then UNDEFINED; + // if index_align<1> != ?0? then UNDEFINED; if (BitIsClear (index_align, 1)) return false; @@ -11669,19 +11667,19 @@ esize = 16; index = Bits32 (index_align, 3, 2); - // alignment = if index_align<0> == ???0??? then 1 else 2; + // alignment = if index_align<0> == ?0? then 1 else 2; if (BitIsClear (index_align, 0)) alignment = 1; else alignment = 2; } - else if (size == 2) // when ???10??? + else if (size == 2) // when ?10? { - // if index_align<2> != ???0??? then UNDEFINED; + // if index_align<2> != ?0? then UNDEFINED; if (BitIsClear (index_align, 2)) return false; - // if index_align<1:0> != ???00??? && index_align<1:0> != ???11??? then UNDEFINED; + // if index_align<1:0> != ?00? && index_align<1:0> != ?11? then UNDEFINED; if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3)) return false; @@ -11690,7 +11688,7 @@ esize = 32; index = Bit32 (index_align, 3); - // alignment = if index_align<1:0> == ???00??? then 1 else 4; + // alignment = if index_align<1:0> == ?00? then 1 else 4; if (Bits32 (index_align, 1, 0) == 0) alignment = 1; else @@ -11799,12 +11797,12 @@ case eEncodingT1: case eEncodingA1: { - //if size == ???11??? || (size == ???00??? && a == ???1???) then UNDEFINED; + //if size == ?11? || (size == ?00? && a == ?1?) then UNDEFINED; uint32_t size = Bits32 (opcode, 7, 6); if ((size == 3) || ((size == 0) && BitIsSet (opcode, 4))) return false; - //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == ???0??? then 1 else 2; + //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == ?0? then 1 else 2; ebytes = 1 << size; elements = 8 / ebytes; if (BitIsClear (opcode, 5)) @@ -11812,7 +11810,7 @@ else regs = 2; - //alignment = if a == ???0??? then 1 else ebytes; + //alignment = if a == ?0? then 1 else ebytes; if (BitIsClear (opcode, 4)) alignment = 1; else @@ -11909,19 +11907,19 @@ UNPREDICTABLE; operand2 = if register_form then Shift(R[m], shift_t, shift_n, APSR.C) else imm32; case opcode of - when ???0000??? result = R[n] AND operand2; // AND - when ???0001??? result = R[n] EOR operand2; // EOR - when ???0010??? (result, -, -) = AddWithCarry(R[n], NOT(operand2), ???1???); // SUB - when ???0011??? (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ???1???); // RSB - when ???0100??? (result, -, -) = AddWithCarry(R[n], operand2, ???0???); // ADD - when ???0101??? (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC - when ???0110??? (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC - when ???0111??? (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC - when ???1100??? result = R[n] OR operand2; // ORR - when ???1101??? result = operand2; // MOV - when ???1110??? result = R[n] AND NOT(operand2); // BIC - when ???1111??? result = NOT(operand2); // MVN - CPSRWriteByInstr(SPSR[], ???1111???, TRUE); + when ?0000? result = R[n] AND operand2; // AND + when ?0001? result = R[n] EOR operand2; // EOR + when ?0010? (result, -, -) = AddWithCarry(R[n], NOT(operand2), ?1?); // SUB + when ?0011? (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ?1?); // RSB + when ?0100? (result, -, -) = AddWithCarry(R[n], operand2, ?0?); // ADD + when ?0101? (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC + when ?0110? (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC + when ?0111? (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC + when ?1100? result = R[n] OR operand2; // ORR + when ?1101? result = operand2; // MOV + when ?1110? result = R[n] AND NOT(operand2); // BIC + when ?1111? result = NOT(operand2); // MVN + CPSRWriteByInstr(SPSR[], ?1111?, TRUE); BranchWritePC(result); #endif @@ -11941,7 +11939,7 @@ { case eEncodingT1: // if CurrentInstrSet() == InstrSet_ThumbEE then UNPREDICTABLE - // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = ???0010???; // = SUB + // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = ?0010?; // = SUB n = 14; imm32 = Bits32 (opcode, 7, 0); register_form = false; @@ -12002,62 +12000,62 @@ // case opcode of switch (code) { - case 0: // when ???0000??? + case 0: // when ?0000? // result = R[n] AND operand2; // AND result.result = Rn & operand2; break; - case 1: // when ???0001??? + case 1: // when ?0001? // result = R[n] EOR operand2; // EOR result.result = Rn ^ operand2; break; - case 2: // when ???0010??? - // (result, -, -) = AddWithCarry(R[n], NOT(operand2), ???1???); // SUB + case 2: // when ?0010? + // (result, -, -) = AddWithCarry(R[n], NOT(operand2), ?1?); // SUB result = AddWithCarry (Rn, ~(operand2), 1); break; - case 3: // when ???0011??? - // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ???1???); // RSB + case 3: // when ?0011? + // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ?1?); // RSB result = AddWithCarry (~(Rn), operand2, 1); break; - case 4: // when ???0100??? - // (result, -, -) = AddWithCarry(R[n], operand2, ???0???); // ADD + case 4: // when ?0100? + // (result, -, -) = AddWithCarry(R[n], operand2, ?0?); // ADD result = AddWithCarry (Rn, operand2, 0); break; - case 5: // when ???0101??? + case 5: // when ?0101? // (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC result = AddWithCarry (Rn, operand2, APSR_C); break; - case 6: // when ???0110??? + case 6: // when ?0110? // (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC result = AddWithCarry (Rn, ~(operand2), APSR_C); break; - case 7: // when ???0111??? + case 7: // when ?0111? // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC result = AddWithCarry (~(Rn), operand2, APSR_C); break; - case 10: // when ???1100??? + case 10: // when ?1100? // result = R[n] OR operand2; // ORR result.result = Rn | operand2; break; - case 11: // when ???1101??? + case 11: // when ?1101? // result = operand2; // MOV result.result = operand2; break; - case 12: // when ???1110??? + case 12: // when ?1110? // result = R[n] AND NOT(operand2); // BIC result.result = Rn & ~(operand2); break; - case 15: // when ???1111??? + case 15: // when ?1111? // result = NOT(operand2); // MVN result.result = ~(operand2); break; @@ -12065,7 +12063,7 @@ default: return false; } - // CPSRWriteByInstr(SPSR[], ???1111???, TRUE); + // CPSRWriteByInstr(SPSR[], ?1111?, TRUE); // For now, in emulation mode, we don't have access to the SPSR, so we will use the CPSR instead, and hope for // the best. @@ -13249,9 +13247,9 @@ if (m_opcode_cpsr == 0 || m_ignore_conditions == false) { m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindDWARF, - dwarf_cpsr, - 0, - &success); + dwarf_cpsr, + 0, + &success); } // Only return false if we are unable to read the CPSR if we care about conditions Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.cpp Mon May 9 15:18:18 2011 @@ -9,6 +9,7 @@ #include "EmulationStateARM.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/RegisterContext.h" @@ -33,33 +34,18 @@ bool EmulationStateARM::LoadPseudoRegistersFromFrame (StackFrame &frame) { - RegisterContext *reg_context = frame.GetRegisterContext().get(); - Scalar value; - uint64_t reg_value64; - uint32_t reg_value32; - + RegisterContext *reg_ctx = frame.GetRegisterContext().get(); bool success = true; + uint32_t reg_num; for (int i = dwarf_r0; i < dwarf_r0 + 17; ++i) { - uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i); - if (reg_context->ReadRegisterValue (internal_reg_num, value)) + reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i); + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num); + RegisterValue reg_value; + if (reg_ctx->ReadRegister (reg_info, reg_value)) { - reg_value32 = (uint32_t) value.GetRawBits64 (0); - m_gpr[i - dwarf_r0] = reg_value32; - } - else - success = false; - } - - for (int i = dwarf_s0; i < dwarf_s0 + 32; ++i) - { - uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i); - if (reg_context->ReadRegisterValue (internal_reg_num, value)) - { - uint32_t idx = i - dwarf_s0; - reg_value32 = (uint32_t) value.GetRawBits64 (0); - m_vfp_regs.sd_regs[idx / 2].s_reg[idx % 2] = reg_value32; + m_gpr[i - dwarf_r0] = reg_value.GetAsUInt32(); } else success = false; @@ -67,15 +53,17 @@ for (int i = dwarf_d0; i < dwarf_d0 + 32; ++i) { - uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i); - if (reg_context->ReadRegisterValue (internal_reg_num, value)) + reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i); + RegisterValue reg_value; + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num); + + if (reg_ctx->ReadRegister (reg_info, reg_value)) { uint32_t idx = i - dwarf_d0; - reg_value64 = value.GetRawBits64 (0); if (i < 16) - m_vfp_regs.sd_regs[idx].d_reg = reg_value64; + m_vfp_regs.sd_regs[idx].d_reg = reg_value.GetAsUInt64(); else - m_vfp_regs.d_regs[idx - 16] = reg_value64; + m_vfp_regs.d_regs[idx - 16] = reg_value.GetAsUInt64(); } else success = false; @@ -254,18 +242,20 @@ bool EmulationStateARM::ReadPseudoRegister (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value) + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value) { - if (!baton) + if (!baton || !reg_info) return false; bool success = true; EmulationStateARM *pseudo_state = (EmulationStateARM *) baton; + const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF]; + assert (dwarf_reg_num != LLDB_INVALID_REGNUM); + uint64_t reg_uval = pseudo_state->ReadPseudoRegisterValue (dwarf_reg_num, success); - assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM); - reg_value = pseudo_state->ReadPseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], success); - + if (success) + success = reg_value.SetUInt(reg_uval, reg_info->byte_size); return success; } @@ -274,15 +264,16 @@ EmulationStateARM::WritePseudoRegister (EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, - const RegisterInfo ®_info, - uint64_t reg_value) + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value) { - if (!baton) + if (!baton || !reg_info) return false; - assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM); EmulationStateARM *pseudo_state = (EmulationStateARM *) baton; - return pseudo_state->StorePseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], reg_value); + const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF]; + assert (dwarf_reg_num != LLDB_INVALID_REGNUM); + return pseudo_state->StorePseudoRegisterValue (dwarf_reg_num, reg_value.GetAsUInt64()); } bool Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h Mon May 9 15:18:18 2011 @@ -70,15 +70,15 @@ static bool ReadPseudoRegister (lldb_private::EmulateInstruction *instruction, void *baton, - const lldb_private::RegisterInfo ®_info, - uint64_t ®_value); + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value); static bool WritePseudoRegister (lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, - const lldb_private::RegisterInfo ®_info, - uint64_t reg_value); + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value); private: uint32_t m_gpr[17]; struct sd_regs Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp Mon May 9 15:18:18 2011 @@ -17,6 +17,7 @@ // Other libraries and framework includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Endian.h" @@ -627,8 +628,9 @@ bool -RegisterContextMach_arm::ReadRegisterValue (uint32_t reg, Scalar &value) +RegisterContextMach_arm::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = RegisterContextMach_arm::GetSetForNativeRegNum (reg); if (set == -1) @@ -656,7 +658,7 @@ case gpr_lr: case gpr_pc: case gpr_cpsr: - value = gpr.r[reg - gpr_r0]; + value.SetUInt32 (gpr.r[reg - gpr_r0]); break; case fpu_s0: @@ -691,24 +693,25 @@ case fpu_s29: case fpu_s30: case fpu_s31: - value = fpu.floats.s[reg]; + value.SetUInt32 (fpu.floats.s[reg], RegisterValue::eTypeFloat); break; case fpu_fpscr: - value = fpu.fpscr; + value.SetUInt32 (fpu.fpscr); break; case exc_exception: - value = exc.exception; + value.SetUInt32 (exc.exception); break; case exc_fsr: - value = exc.fsr; + value.SetUInt32 (exc.fsr); break; case exc_far: - value = exc.far; + value.SetUInt32 (exc.far); break; default: + value.SetValueToInvalid(); return false; } @@ -717,8 +720,10 @@ bool -RegisterContextMach_arm::WriteRegisterValue (uint32_t reg, const Scalar &value) +RegisterContextMach_arm::WriteRegister (const RegisterInfo *reg_info, + const RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = GetSetForNativeRegNum (reg); if (set == -1) @@ -746,7 +751,7 @@ case gpr_lr: case gpr_pc: case gpr_cpsr: - gpr.r[reg - gpr_r0] = value.UInt(0); + gpr.r[reg - gpr_r0] = value.GetAsUInt32(); break; case fpu_s0: @@ -781,21 +786,21 @@ case fpu_s29: case fpu_s30: case fpu_s31: - fpu.floats.s[reg] = value.UInt(0); + fpu.floats.s[reg] = value.GetAsUInt32(); break; case fpu_fpscr: - fpu.fpscr = value.UInt(0); + fpu.fpscr = value.GetAsUInt32(); break; case exc_exception: - exc.exception = value.UInt(0); + exc.exception = value.GetAsUInt32(); break; case exc_fsr: - exc.fsr = value.UInt(0); + exc.fsr = value.GetAsUInt32(); break; case exc_far: - exc.far = value.UInt(0); + exc.far = value.GetAsUInt32(); break; default: @@ -806,195 +811,6 @@ } bool -RegisterContextMach_arm::ReadRegisterBytes (uint32_t reg, DataExtractor &data) -{ - int set = RegisterContextMach_arm::GetSetForNativeRegNum (reg); - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL) - return false; - - switch (reg) - { - case gpr_r0: - case gpr_r1: - case gpr_r2: - case gpr_r3: - case gpr_r4: - case gpr_r5: - case gpr_r6: - case gpr_r7: - case gpr_r8: - case gpr_r9: - case gpr_r10: - case gpr_r11: - case gpr_r12: - case gpr_sp: - case gpr_lr: - case gpr_pc: - case gpr_cpsr: - data.SetData(&gpr.r[reg - gpr_r0], reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_s0: - case fpu_s1: - case fpu_s2: - case fpu_s3: - case fpu_s4: - case fpu_s5: - case fpu_s6: - case fpu_s7: - case fpu_s8: - case fpu_s9: - case fpu_s10: - case fpu_s11: - case fpu_s12: - case fpu_s13: - case fpu_s14: - case fpu_s15: - case fpu_s16: - case fpu_s17: - case fpu_s18: - case fpu_s19: - case fpu_s20: - case fpu_s21: - case fpu_s22: - case fpu_s23: - case fpu_s24: - case fpu_s25: - case fpu_s26: - case fpu_s27: - case fpu_s28: - case fpu_s29: - case fpu_s30: - case fpu_s31: - data.SetData(&fpu.floats.s[reg - fpu_s0], reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fpscr: - data.SetData(&fpu.fpscr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_exception: - data.SetData(&exc.exception, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_fsr: - data.SetData(&exc.fsr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_far: - data.SetData(&exc.far, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - default: - return false; - } - return true; -} - -bool -RegisterContextMach_arm::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) -{ - int set = GetSetForNativeRegNum (reg); - - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size)) - return false; - - uint32_t offset = data_offset; - switch (reg) - { - case gpr_r0: - case gpr_r1: - case gpr_r2: - case gpr_r3: - case gpr_r4: - case gpr_r5: - case gpr_r6: - case gpr_r7: - case gpr_r8: - case gpr_r9: - case gpr_r10: - case gpr_r11: - case gpr_r12: - case gpr_sp: - case gpr_lr: - case gpr_pc: - case gpr_cpsr: - gpr.r[reg - gpr_r0] = data.GetU32 (&offset); - break; - - case fpu_s0: - case fpu_s1: - case fpu_s2: - case fpu_s3: - case fpu_s4: - case fpu_s5: - case fpu_s6: - case fpu_s7: - case fpu_s8: - case fpu_s9: - case fpu_s10: - case fpu_s11: - case fpu_s12: - case fpu_s13: - case fpu_s14: - case fpu_s15: - case fpu_s16: - case fpu_s17: - case fpu_s18: - case fpu_s19: - case fpu_s20: - case fpu_s21: - case fpu_s22: - case fpu_s23: - case fpu_s24: - case fpu_s25: - case fpu_s26: - case fpu_s27: - case fpu_s28: - case fpu_s29: - case fpu_s30: - case fpu_s31: - fpu.floats.s[reg - fpu_s0] = data.GetU32 (&offset); - break; - - case fpu_fpscr: - fpu.fpscr = data.GetU32 (&offset); - break; - - case exc_exception: - fpu.fpscr = data.GetU32 (&offset); - break; - - case exc_fsr: - exc.fsr = data.GetU32 (&offset); - break; - - case exc_far: - exc.far = data.GetU32 (&offset); - break; - - default: - return false; - } - return WriteRegisterSet(set) == KERN_SUCCESS; -} - -bool RegisterContextMach_arm::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) { data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0)); Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h Mon May 9 15:18:18 2011 @@ -75,21 +75,17 @@ GetRegisterSet (uint32_t set); virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); - - virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - + ReadRegister (const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value); + + virtual bool + WriteRegister (const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value); + virtual bool ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); - - virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); virtual uint32_t Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp Mon May 9 15:18:18 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Endian.h" @@ -553,8 +554,10 @@ } bool -RegisterContextMach_i386::ReadRegisterValue (uint32_t reg, Scalar &value) +RegisterContextMach_i386::ReadRegister (const RegisterInfo *reg_info, + RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = RegisterContextMach_i386::GetSetForNativeRegNum (reg); if (set == -1) @@ -671,8 +674,10 @@ bool -RegisterContextMach_i386::WriteRegisterValue (uint32_t reg, const Scalar &value) +RegisterContextMach_i386::WriteRegister (const RegisterInfo *reg_info, + const RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = GetSetForNativeRegNum (reg); if (set == -1) @@ -699,47 +704,47 @@ case gpr_es: case gpr_fs: case gpr_gs: - (&gpr.eax)[reg - gpr_eax] = value.UInt(0); + (&gpr.eax)[reg - gpr_eax] = value.GetAsUInt32(); break; case fpu_fcw: - fpu.fcw = value.UInt(0); + fpu.fcw = value.GetAsUInt16(); break; case fpu_fsw: - fpu.fsw = value.UInt(0); + fpu.fsw = value.GetAsUInt16(); break; case fpu_ftw: - fpu.ftw = value.UInt(0); + fpu.ftw = value.GetAsUInt8(); break; case fpu_fop: - fpu.fop = value.UInt(0); + fpu.fop = value.GetAsUInt16(); break; case fpu_ip: - fpu.ip = value.UInt(0); + fpu.ip = value.GetAsUInt32(); break; case fpu_cs: - fpu.cs = value.UInt(0); + fpu.cs = value.GetAsUInt16(); break; case fpu_dp: - fpu.dp = value.UInt(0); + fpu.dp = value.GetAsUInt32(); break; case fpu_ds: - fpu.ds = value.UInt(0); + fpu.ds = value.GetAsUInt16(); break; case fpu_mxcsr: - fpu.mxcsr = value.UInt(0); + fpu.mxcsr = value.GetAsUInt32(); break; case fpu_mxcsrmask: - fpu.mxcsrmask = value.UInt(0); + fpu.mxcsrmask = value.GetAsUInt32(); break; case fpu_stmm0: @@ -752,7 +757,7 @@ case fpu_stmm7: // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() // must be used for these registers - //::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, reg_value.value.vector.uint8, 10); + ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize()); return false; case fpu_xmm0: @@ -765,254 +770,19 @@ case fpu_xmm7: // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() // must be used for these registers - //::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, reg_value.value.vector.uint8, 16); + ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize()); return false; case exc_trapno: - exc.trapno = value.UInt(0); + exc.trapno = value.GetAsUInt32(); break; case exc_err: - exc.err = value.UInt(0); + exc.err = value.GetAsUInt32(); break; case exc_faultvaddr: - exc.faultvaddr = value.UInt(0); - break; - - default: - return false; - } - return WriteRegisterSet(set) == KERN_SUCCESS; -} - -bool -RegisterContextMach_i386::ReadRegisterBytes (uint32_t reg, DataExtractor &data) -{ - int set = RegisterContextMach_i386::GetSetForNativeRegNum (reg); - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL) - return false; - - switch (reg) - { - case gpr_eax: - case gpr_ebx: - case gpr_ecx: - case gpr_edx: - case gpr_edi: - case gpr_esi: - case gpr_ebp: - case gpr_esp: - case gpr_ss: - case gpr_eflags: - case gpr_eip: - case gpr_cs: - case gpr_ds: - case gpr_es: - case gpr_fs: - case gpr_gs: - data.SetData(&gpr.eax + reg - gpr_eax, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fcw: - data.SetData(&fpu.fcw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fsw: - data.SetData(&fpu.fsw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ftw: - data.SetData(&fpu.ftw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fop: - data.SetData(&fpu.fop, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ip: - data.SetData(&fpu.ip, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_cs: - data.SetData(&fpu.cs, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_dp: - data.SetData(&fpu.dp, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ds: - data.SetData(&fpu.ds, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_mxcsr: - data.SetData(&fpu.mxcsr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_mxcsrmask: - data.SetData(&fpu.mxcsrmask, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - data.SetData(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - data.SetData(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_trapno: - data.SetData(&exc.trapno, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_err: - data.SetData(&exc.err, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_faultvaddr: - data.SetData(&exc.faultvaddr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - default: - return false; - } - return true; -} - -bool -RegisterContextMach_i386::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) -{ - int set = GetSetForNativeRegNum (reg); - - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size)) - return false; - - uint32_t offset = data_offset; - switch (reg) - { - case gpr_eax: - case gpr_ebx: - case gpr_ecx: - case gpr_edx: - case gpr_edi: - case gpr_esi: - case gpr_ebp: - case gpr_esp: - case gpr_ss: - case gpr_eflags: - case gpr_eip: - case gpr_cs: - case gpr_ds: - case gpr_es: - case gpr_fs: - case gpr_gs: - (&gpr.eax)[reg - gpr_eax] = data.GetU32 (&offset); - break; - - case fpu_fcw: - fpu.fcw = data.GetU16(&offset); - break; - - case fpu_fsw: - fpu.fsw = data.GetU16(&offset); - break; - - case fpu_ftw: - fpu.ftw = data.GetU8(&offset); - break; - - case fpu_fop: - fpu.fop = data.GetU16(&offset); - break; - - case fpu_ip: - fpu.ip = data.GetU32(&offset); - break; - - case fpu_cs: - fpu.cs = data.GetU16(&offset); - break; - - case fpu_dp: - fpu.dp = data.GetU32(&offset); - break; - - case fpu_ds: - fpu.ds = data.GetU16(&offset); - break; - - case fpu_mxcsr: - fpu.mxcsr = data.GetU32(&offset); - break; - - case fpu_mxcsrmask: - fpu.mxcsrmask = data.GetU32(&offset); - break; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size); - return false; - - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() - // must be used for these registers - ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size); - return false; - - case exc_trapno: - exc.trapno = data.GetU32 (&offset); - break; - - case exc_err: - exc.err = data.GetU32 (&offset); - break; - - case exc_faultvaddr: - exc.faultvaddr = data.GetU32 (&offset); + exc.faultvaddr = value.GetAsUInt32(); break; default: Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h Mon May 9 15:18:18 2011 @@ -43,21 +43,15 @@ GetRegisterSet (uint32_t set); virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); + ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - + WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); + virtual bool ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); - - virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); virtual uint32_t Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp Mon May 9 15:18:18 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Endian.h" @@ -600,10 +601,11 @@ bool -RegisterContextMach_x86_64::ReadRegisterValue (uint32_t reg, Scalar &value) +RegisterContextMach_x86_64::ReadRegister (const RegisterInfo *reg_info, + RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg); - if (set == -1) return false; @@ -684,11 +686,8 @@ case fpu_stmm5: case fpu_stmm6: case fpu_stmm7: - // These values don't fit into scalar types, - // RegisterContext::ReadRegisterBytes() must be used for these - // registers - //::memcpy (reg_value.value.vector.uint8, fpu.stmm[reg - fpu_stmm0].bytes, 10); - return false; + value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); + break; case fpu_xmm0: case fpu_xmm1: @@ -706,10 +705,8 @@ case fpu_xmm13: case fpu_xmm14: case fpu_xmm15: - // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() - // must be used for these registers - //::memcpy (reg_value.value.vector.uint8, fpu.xmm[reg - fpu_xmm0].bytes, 16); - return false; + value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); + break; case exc_trapno: value = exc.trapno; @@ -731,8 +728,10 @@ bool -RegisterContextMach_x86_64::WriteRegisterValue (uint32_t reg, const Scalar &value) +RegisterContextMach_x86_64::WriteRegister (const RegisterInfo *reg_info, + const RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg); if (set == -1) @@ -764,47 +763,47 @@ case gpr_cs: case gpr_fs: case gpr_gs: - (&gpr.rax)[reg - gpr_rax] = value.ULongLong(0); + (&gpr.rax)[reg - gpr_rax] = value.GetAsUInt64(); break; case fpu_fcw: - fpu.fcw = value.UInt(0); + fpu.fcw = value.GetAsUInt16(); break; case fpu_fsw: - fpu.fsw = value.UInt(0); + fpu.fsw = value.GetAsUInt16(); break; case fpu_ftw: - fpu.ftw = value.UInt(0); + fpu.ftw = value.GetAsUInt8(); break; case fpu_fop: - fpu.fop = value.UInt(0); + fpu.fop = value.GetAsUInt16(); break; case fpu_ip: - fpu.ip = value.UInt(0); + fpu.ip = value.GetAsUInt32(); break; case fpu_cs: - fpu.cs = value.UInt(0); + fpu.cs = value.GetAsUInt16(); break; case fpu_dp: - fpu.dp = value.UInt(0); + fpu.dp = value.GetAsUInt32(); break; case fpu_ds: - fpu.ds = value.UInt(0); + fpu.ds = value.GetAsUInt16(); break; case fpu_mxcsr: - fpu.mxcsr = value.UInt(0); + fpu.mxcsr = value.GetAsUInt32(); break; case fpu_mxcsrmask: - fpu.mxcsrmask = value.UInt(0); + fpu.mxcsrmask = value.GetAsUInt32(); break; case fpu_stmm0: @@ -815,272 +814,9 @@ case fpu_stmm5: case fpu_stmm6: case fpu_stmm7: - // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() - // must be used for these registers - //::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, reg_value.value.vector.uint8, 10); - return false; - - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - case fpu_xmm8: - case fpu_xmm9: - case fpu_xmm10: - case fpu_xmm11: - case fpu_xmm12: - case fpu_xmm13: - case fpu_xmm14: - case fpu_xmm15: - // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() - // must be used for these registers - //::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, reg_value.value.vector.uint8, 16); - return false; - - case exc_trapno: - exc.trapno = value.UInt(0); - break; - - case exc_err: - exc.err = value.UInt(0); + ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize()); break; - case exc_faultvaddr: - exc.faultvaddr = value.UInt(0); - break; - - default: - return false; - } - return WriteRegisterSet(set) == KERN_SUCCESS; -} - -bool -RegisterContextMach_x86_64::ReadRegisterBytes (uint32_t reg, DataExtractor &data) -{ - int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg); - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL) - return false; - - switch (reg) - { - case gpr_rax: - case gpr_rbx: - case gpr_rcx: - case gpr_rdx: - case gpr_rdi: - case gpr_rsi: - case gpr_rbp: - case gpr_rsp: - case gpr_r8: - case gpr_r9: - case gpr_r10: - case gpr_r11: - case gpr_r12: - case gpr_r13: - case gpr_r14: - case gpr_r15: - case gpr_rip: - case gpr_rflags: - case gpr_cs: - case gpr_fs: - case gpr_gs: - data.SetData(&gpr.rax + reg - gpr_rax, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fcw: - data.SetData(&fpu.fcw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fsw: - data.SetData(&fpu.fsw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ftw: - data.SetData(&fpu.ftw, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_fop: - data.SetData(&fpu.fop, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ip: - data.SetData(&fpu.ip, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_cs: - data.SetData(&fpu.cs, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_dp: - data.SetData(&fpu.dp, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_ds: - data.SetData(&fpu.ds, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_mxcsr: - data.SetData(&fpu.mxcsr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_mxcsrmask: - data.SetData(&fpu.mxcsrmask, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - data.SetData(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case fpu_xmm0: - case fpu_xmm1: - case fpu_xmm2: - case fpu_xmm3: - case fpu_xmm4: - case fpu_xmm5: - case fpu_xmm6: - case fpu_xmm7: - case fpu_xmm8: - case fpu_xmm9: - case fpu_xmm10: - case fpu_xmm11: - case fpu_xmm12: - case fpu_xmm13: - case fpu_xmm14: - case fpu_xmm15: - data.SetData(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_trapno: - data.SetData(&exc.trapno, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_err: - data.SetData(&exc.err, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - case exc_faultvaddr: - data.SetData(&exc.faultvaddr, reg_info->byte_size, lldb::endian::InlHostByteOrder()); - break; - - default: - return false; - } - return true; -} - -bool -RegisterContextMach_x86_64::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) -{ - int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg); - - if (set == -1) - return false; - - if (ReadRegisterSet(set, false) != KERN_SUCCESS) - return false; - - - const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size)) - return false; - - uint32_t offset = data_offset; - switch (reg) - { - case gpr_rax: - case gpr_rbx: - case gpr_rcx: - case gpr_rdx: - case gpr_rdi: - case gpr_rsi: - case gpr_rbp: - case gpr_rsp: - case gpr_r8: - case gpr_r9: - case gpr_r10: - case gpr_r11: - case gpr_r12: - case gpr_r13: - case gpr_r14: - case gpr_r15: - case gpr_rip: - case gpr_rflags: - case gpr_cs: - case gpr_fs: - case gpr_gs: - (&gpr.rax)[reg - gpr_rax] = data.GetU32 (&offset); - break; - - case fpu_fcw: - fpu.fcw = data.GetU16(&offset); - break; - - case fpu_fsw: - fpu.fsw = data.GetU16(&offset); - break; - - case fpu_ftw: - fpu.ftw = data.GetU8(&offset); - break; - - case fpu_fop: - fpu.fop = data.GetU16(&offset); - break; - - case fpu_ip: - fpu.ip = data.GetU32(&offset); - break; - - case fpu_cs: - fpu.cs = data.GetU16(&offset); - break; - - case fpu_dp: - fpu.dp = data.GetU32(&offset); - break; - - case fpu_ds: - fpu.ds = data.GetU16(&offset); - break; - - case fpu_mxcsr: - fpu.mxcsr = data.GetU32(&offset); - break; - - case fpu_mxcsrmask: - fpu.mxcsrmask = data.GetU32(&offset); - break; - - case fpu_stmm0: - case fpu_stmm1: - case fpu_stmm2: - case fpu_stmm3: - case fpu_stmm4: - case fpu_stmm5: - case fpu_stmm6: - case fpu_stmm7: - ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size); - return false; - case fpu_xmm0: case fpu_xmm1: case fpu_xmm2: @@ -1097,21 +833,19 @@ case fpu_xmm13: case fpu_xmm14: case fpu_xmm15: - // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() - // must be used for these registers - ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size); + ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize()); return false; case exc_trapno: - exc.trapno = data.GetU32 (&offset); + exc.trapno = value.GetAsUInt32(); break; case exc_err: - exc.err = data.GetU32 (&offset); + exc.err = value.GetAsUInt32(); break; case exc_faultvaddr: - exc.faultvaddr = data.GetU32 (&offset); + exc.faultvaddr = value.GetAsUInt64(); break; default: Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h Mon May 9 15:18:18 2011 @@ -42,21 +42,15 @@ GetRegisterSet (uint32_t set); virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); + ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - + WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); + virtual bool ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); - - virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); virtual uint32_t Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Mon May 9 15:18:18 2011 @@ -1,4 +1,4 @@ -//===-- lldb_ARMUtils.h -----------------------------------------*- C++ -*-===// +//===-- ARMUtils.h ----------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h Mon May 9 15:18:18 2011 @@ -1,4 +1,4 @@ -//===-- lldb_InstructionUtils.h ---------------------------------*- C++ -*-===// +//===-- InstructionUtils.h --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -36,7 +36,13 @@ static inline uint32_t Bit32 (const uint32_t bits, const uint32_t bit) { - return Bits32(bits, bit, bit); + return (bits >> bit) & 1u; +} + +static inline uint64_t +Bit64 (const uint64_t bits, const uint32_t bit) +{ + return (bits >> bit) & 1ull; } // Set the bit field(s) from the most significant bit (msbit) to the Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon May 9 15:18:18 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Log.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/Function.h" @@ -658,132 +659,99 @@ } bool -RegisterContextLLDB::ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data) +RegisterContextLLDB::ReadRegisterValueFromRegisterLocation (RegisterLocation regloc, + const RegisterInfo *reg_info, + RegisterValue &value) { if (!IsValid()) return false; + bool success = false; - if (regloc.type == eRegisterInRegister) + switch (regloc.type) { - data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize()); - data.SetByteOrder (m_thread.GetProcess().GetByteOrder()); - if (IsFrameZero ()) - { - return m_thread.GetRegisterContext()->ReadRegisterBytes (regloc.location.register_number, data); - } - else - { - return m_next_frame->ReadRegisterBytes (regloc.location.register_number, data); - } - } - if (regloc.type == eRegisterNotSaved) - { - return false; - } - if (regloc.type == eRegisterSavedAtHostMemoryLocation) - { - assert ("FIXME debugger inferior function call unwind"); - } - if (regloc.type != eRegisterSavedAtMemoryLocation) - { - assert ("Unknown RegisterLocation type."); - } - - const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum); - DataBufferSP data_sp (new DataBufferHeap (reg_info->byte_size, 0)); - data.SetData (data_sp, 0, reg_info->byte_size); - data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize()); - - if (regloc.type == eRegisterValueInferred) - { - data.SetByteOrder (lldb::endian::InlHostByteOrder()); - switch (reg_info->byte_size) + case eRegisterInRegister: { - case 1: - { - uint8_t val = regloc.location.register_value; - memcpy (data_sp->GetBytes(), &val, sizeof (val)); - data.SetByteOrder (lldb::endian::InlHostByteOrder()); - return true; - } - case 2: - { - uint16_t val = regloc.location.register_value; - memcpy (data_sp->GetBytes(), &val, sizeof (val)); - data.SetByteOrder (lldb::endian::InlHostByteOrder()); - return true; - } - case 4: + const RegisterInfo *other_reg_info = GetRegisterInfoAtIndex(regloc.location.register_number); + if (IsFrameZero ()) { - uint32_t val = regloc.location.register_value; - memcpy (data_sp->GetBytes(), &val, sizeof (val)); - data.SetByteOrder (lldb::endian::InlHostByteOrder()); - return true; + success = m_thread.GetRegisterContext()->ReadRegister (other_reg_info, value); } - case 8: + else { - uint64_t val = regloc.location.register_value; - memcpy (data_sp->GetBytes(), &val, sizeof (val)); - data.SetByteOrder (lldb::endian::InlHostByteOrder()); - return true; + success = m_next_frame->ReadRegister (other_reg_info, value); } } - return false; + break; + case eRegisterValueInferred: + success = value.SetUInt (regloc.location.inferred_value, reg_info->byte_size); + break; + + case eRegisterNotSaved: + break; + case eRegisterSavedAtHostMemoryLocation: + assert ("FIXME debugger inferior function call unwind"); + break; + case eRegisterSavedAtMemoryLocation: + { + Error error (ReadRegisterValueFromMemory(reg_info, + regloc.location.target_memory_location, + reg_info->byte_size, + value)); + success = error.Success(); + } + break; + default: + assert ("Unknown RegisterLocation type."); + break; } - - assert (regloc.type == eRegisterSavedAtMemoryLocation); - Error error; - data.SetByteOrder (m_thread.GetProcess().GetByteOrder()); - if (!m_thread.GetProcess().ReadMemory (regloc.location.target_memory_location, data_sp->GetBytes(), reg_info->byte_size, error)) - return false; - return true; + return success; } bool -RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data, uint32_t data_offset) +RegisterContextLLDB::WriteRegisterValueToRegisterLocation (RegisterLocation regloc, + const RegisterInfo *reg_info, + const RegisterValue &value) { if (!IsValid()) return false; - if (regloc.type == eRegisterInRegister) - { - if (IsFrameZero ()) - { - return m_thread.GetRegisterContext()->WriteRegisterBytes (regloc.location.register_number, data, data_offset); - } - else - { - return m_next_frame->WriteRegisterBytes (regloc.location.register_number, data, data_offset); - } - } - if (regloc.type == eRegisterNotSaved) - { - return false; - } - if (regloc.type == eRegisterValueInferred) - { - return false; - } - if (regloc.type == eRegisterSavedAtHostMemoryLocation) - { - assert ("FIXME debugger inferior function call unwind"); - } - if (regloc.type != eRegisterSavedAtMemoryLocation) + bool success = false; + + switch (regloc.type) { - assert ("Unknown RegisterLocation type."); + case eRegisterInRegister: + { + const RegisterInfo *other_reg_info = GetRegisterInfoAtIndex(regloc.location.register_number); + if (IsFrameZero ()) + { + success = m_thread.GetRegisterContext()->WriteRegister (other_reg_info, value); + } + else + { + success = m_next_frame->WriteRegister (other_reg_info, value); + } + } + break; + case eRegisterValueInferred: + case eRegisterNotSaved: + break; + case eRegisterSavedAtHostMemoryLocation: + assert ("FIXME debugger inferior function call unwind"); + break; + case eRegisterSavedAtMemoryLocation: + { + Error error (WriteRegisterValueToMemory (reg_info, + regloc.location.target_memory_location, + reg_info->byte_size, + value)); + success = error.Success(); + } + break; + default: + assert ("Unknown RegisterLocation type."); + break; } - - Error error; - const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum); - if (reg_info->byte_size == 0) - return false; - uint8_t *buf = (uint8_t*) alloca (reg_info->byte_size); - if (data.ExtractBytes (data_offset, reg_info->byte_size, m_thread.GetProcess().GetByteOrder(), buf) != reg_info->byte_size) - return false; - if (m_thread.GetProcess().WriteMemory (regloc.location.target_memory_location, buf, reg_info->byte_size, error) != reg_info->byte_size) - return false; - - return true; + return success; } @@ -818,10 +786,10 @@ if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum) && sp_regnum == lldb_regnum) { - // make sure we won't lose precision copying an addr_t (m_cfa) into a uint64_t (.register_value) + // make sure we won't lose precision copying an addr_t (m_cfa) into a uint64_t (.inferred_value) assert (sizeof (addr_t) <= sizeof (uint64_t)); regloc.type = eRegisterValueInferred; - regloc.location.register_value = m_cfa; + regloc.location.inferred_value = m_cfa; m_registers[lldb_regnum] = regloc; return true; } @@ -976,7 +944,7 @@ { int offset = unwindplan_regloc.GetOffset(); regloc.type = eRegisterValueInferred; - regloc.location.register_value = m_cfa + offset; + regloc.location.inferred_value = m_cfa + offset; m_registers[lldb_regnum] = regloc; return true; } @@ -1027,7 +995,7 @@ if (unwindplan_regloc.IsDWARFExpression()) { regloc.type = eRegisterValueInferred; - regloc.location.register_value = val; + regloc.location.inferred_value = val; m_registers[lldb_regnum] = regloc; return true; } @@ -1090,18 +1058,14 @@ return false; } - uint32_t offset = 0; - DataExtractor data; - data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize()); - data.SetByteOrder (m_thread.GetProcess().GetByteOrder()); - + const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum); + RegisterValue reg_value; // if this is frame 0 (currently executing frame), get the requested reg contents from the actual thread registers if (IsFrameZero ()) { - if (m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_regnum, data)) + if (m_thread.GetRegisterContext()->ReadRegister (reg_info, reg_value)) { - data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize()); - value = data.GetAddress (&offset); + value = reg_value.GetAsUInt64(); return true; } return false; @@ -1112,29 +1076,29 @@ { return false; } - if (!ReadRegisterBytesFromRegisterLocation (lldb_regnum, regloc, data)) + if (ReadRegisterValueFromRegisterLocation (regloc, reg_info, reg_value)) { - return false; + value = reg_value.GetAsUInt64(); + return true; } - data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize()); - value = data.GetAddress (&offset); - return true; + return false; } // Find the value of a register in THIS frame bool -RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data) +RegisterContextLLDB::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (!IsValid()) return false; + const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB]; if (log && IsLogVerbose ()) { log->Printf("%*sFrame %u looking for register saved location for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_reg); + lldb_regnum); } // If this is the 0th frame, hand this over to the live register context @@ -1144,31 +1108,32 @@ { log->Printf("%*sFrame %u passing along to the live register context for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_reg); + lldb_regnum); } - return m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_reg, data); + return m_thread.GetRegisterContext()->ReadRegister (reg_info, value); } RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc)) return false; - return ReadRegisterBytesFromRegisterLocation (lldb_reg, regloc, data); + return ReadRegisterValueFromRegisterLocation (regloc, reg_info, value); } bool -RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data, uint32_t data_offset) +RegisterContextLLDB::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &value) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (!IsValid()) return false; + const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB]; if (log && IsLogVerbose ()) { log->Printf("%*sFrame %u looking for register saved location for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_reg); + lldb_regnum); } // If this is the 0th frame, hand this over to the live register context @@ -1178,17 +1143,17 @@ { log->Printf("%*sFrame %u passing along to the live register context for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_reg); + lldb_regnum); } - return m_thread.GetRegisterContext()->WriteRegisterBytes (lldb_reg, data, data_offset); + return m_thread.GetRegisterContext()->WriteRegister (reg_info, value); } RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc)) return false; - return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset); + return WriteRegisterValueToRegisterLocation (regloc, reg_info, value); } // Don't need to implement this one Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon May 9 15:18:18 2011 @@ -50,13 +50,13 @@ GetRegisterSet (uint32_t reg_set); virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); + ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); virtual bool - ReadAllRegisterValues (lldb::DataBufferSP &data_sp); - + WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); + virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); + ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); @@ -92,7 +92,7 @@ eRegisterSavedAtMemoryLocation, // register is saved at a specific word of target mem (target_memory_location) eRegisterInRegister, // register is available in a (possible other) register (register_number) eRegisterSavedAtHostMemoryLocation, // register is saved at a word in lldb's address space - eRegisterValueInferred // register val was computed (and is in register_value) + eRegisterValueInferred // register val was computed (and is in inferred_value) }; struct RegisterLocation @@ -103,7 +103,7 @@ lldb::addr_t target_memory_location; uint32_t register_number; // in eRegisterKindLLDB register numbering system void* host_memory_location; - uint64_t register_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset + uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset } location; }; @@ -138,10 +138,14 @@ SavedLocationForRegister (uint32_t lldb_regnum, RegisterLocation ®loc); bool - ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data); + ReadRegisterValueFromRegisterLocation (RegisterLocation regloc, + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); bool - WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data, uint32_t data_offset); + WriteRegisterValueToRegisterLocation (RegisterLocation regloc, + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); // Get the contents of a general purpose (address-size) register for this frame // (usually retrieved from the m_next_frame) Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp Mon May 9 15:18:18 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/StreamString.h" #include "lldb/Target/Thread.h" @@ -80,17 +81,14 @@ bool -RegisterContextMacOSXFrameBackchain::ReadRegisterValue (uint32_t reg, Scalar &value) +RegisterContextMacOSXFrameBackchain::ReadRegister (const RegisterInfo *reg_info, + RegisterValue &value) { if (!m_cursor_is_valid) return false; uint64_t reg_value = LLDB_INVALID_ADDRESS; - const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (reg); - if (reg_info == NULL) - return false; - switch (reg_info->kinds[eRegisterKindGeneric]) { case LLDB_REGNUM_GENERIC_PC: @@ -116,34 +114,9 @@ break; case eEncodingUint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = (uint32_t)reg_value; - return true; - - case 8: - value = (uint64_t)reg_value; - return true; - } - break; - case eEncodingSint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = (int32_t)reg_value; - return true; - - case 8: - value = (int64_t)reg_value; - return true; - } - break; + value.SetUInt(reg_value, reg_info->byte_size); + return true; case eEncodingIEEE754: switch (reg_info->byte_size) @@ -151,12 +124,12 @@ case sizeof (float): if (sizeof (float) == sizeof(uint32_t)) { - value = (uint32_t)reg_value; + value.SetUInt32(reg_value, RegisterValue::eTypeFloat); return true; } else if (sizeof (float) == sizeof(uint64_t)) { - value = (uint64_t)reg_value; + value.SetUInt64(reg_value, RegisterValue::eTypeFloat); return true; } break; @@ -164,12 +137,12 @@ case sizeof (double): if (sizeof (double) == sizeof(uint32_t)) { - value = (uint32_t)reg_value; + value.SetUInt32(reg_value, RegisterValue::eTypeDouble); return true; } else if (sizeof (double) == sizeof(uint64_t)) { - value = (uint64_t)reg_value; + value.SetUInt64(reg_value, RegisterValue::eTypeDouble); return true; } break; @@ -177,12 +150,12 @@ case sizeof (long double): if (sizeof (long double) == sizeof(uint32_t)) { - value = (uint32_t)reg_value; + value.SetUInt32(reg_value, RegisterValue::eTypeLongDouble); return true; } else if (sizeof (long double) == sizeof(uint64_t)) { - value = (uint64_t)reg_value; + value.SetUInt64(reg_value, RegisterValue::eTypeLongDouble); return true; } break; @@ -192,45 +165,15 @@ return false; } - -bool -RegisterContextMacOSXFrameBackchain::ReadRegisterBytes (uint32_t reg, DataExtractor &data) -{ - Scalar reg_value; - - if (ReadRegisterValue (reg, reg_value)) - { - if (reg_value.GetData(data)) - { - // "reg_value" is local and now "data" points to the data within - // "reg_value", so we must make a copy that will live within "data" - DataBufferSP data_sp (new DataBufferHeap (data.GetDataStart(), data.GetByteSize())); - data.SetData (data_sp, 0, data.GetByteSize()); - return true; - } - } - return false; -} - - -bool -RegisterContextMacOSXFrameBackchain::WriteRegisterValue (uint32_t reg, const Scalar &value) -{ - // Not supported yet. We could easily add support for this by remembering - // the address of each entry (it would need to be part of the cursor) - return false; -} - - bool -RegisterContextMacOSXFrameBackchain::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) +RegisterContextMacOSXFrameBackchain::WriteRegister (const RegisterInfo *reg_info, + const RegisterValue &value) { // Not supported yet. We could easily add support for this by remembering // the address of each entry (it would need to be part of the cursor) return false; } - bool RegisterContextMacOSXFrameBackchain::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) { Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h Mon May 9 15:18:18 2011 @@ -51,21 +51,15 @@ GetRegisterSet (uint32_t reg_set); virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); + ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - + WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); + virtual bool ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset); - - virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); virtual uint32_t Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon May 9 15:18:18 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/StreamString.h" // Project includes @@ -115,65 +116,14 @@ bool -GDBRemoteRegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value) +GDBRemoteRegisterContext::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value) { // Read the register - if (ReadRegisterBytes (reg, m_reg_data)) + if (ReadRegisterBytes (reg_info, value, m_reg_data)) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - uint32_t offset = reg_info->byte_offset; - switch (reg_info->encoding) - { - case eEncodingUint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = m_reg_data.GetMaxU32 (&offset, reg_info->byte_size); - return true; - - case 8: - value = m_reg_data.GetMaxU64 (&offset, reg_info->byte_size); - return true; - } - break; - - case eEncodingSint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = (int32_t)m_reg_data.GetMaxU32 (&offset, reg_info->byte_size); - return true; - - case 8: - value = m_reg_data.GetMaxS64 (&offset, reg_info->byte_size); - return true; - } - break; - - case eEncodingIEEE754: - switch (reg_info->byte_size) - { - case sizeof (float): - value = m_reg_data.GetFloat (&offset); - return true; - - case sizeof (double): - value = m_reg_data.GetDouble (&offset); - return true; - - case sizeof (long double): - value = m_reg_data.GetLongDouble (&offset); - return true; - } - break; - - default: - break; - } + const bool partial_data_ok = false; + Error error (value.SetValueFromData(reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok)); + return error.Success(); } return false; } @@ -206,14 +156,14 @@ bool -GDBRemoteRegisterContext::ReadRegisterBytes (uint32_t reg, DataExtractor &data) +GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data) { GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); InvalidateIfNeeded(false); - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - assert (reg_info); + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + if (!m_reg_valid[reg]) { Mutex::Locker locker; @@ -243,6 +193,7 @@ else { // Get each register individually + if (thread_suffix_supported) packet_len = ::snprintf (packet, sizeof(packet), "p%x;thread:%4.4x;", reg, m_thread.GetID()); else @@ -274,21 +225,18 @@ bool -GDBRemoteRegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value) +GDBRemoteRegisterContext::WriteRegister (const RegisterInfo *reg_info, + const RegisterValue &value) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info) - { - DataExtractor data; - if (value.GetData (data, reg_info->byte_size)) - return WriteRegisterBytes (reg, data, 0); - } + DataExtractor data; + if (value.GetData (data)) + return WriteRegisterBytes (reg_info, value, data, 0); return false; } bool -GDBRemoteRegisterContext::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) +GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, const RegisterValue &value, DataExtractor &data, uint32_t data_offset) { GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); // FIXME: This check isn't right because IsRunning checks the Public state, but this @@ -297,34 +245,21 @@ // if (gdb_comm.IsRunning()) // return false; - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - - if (reg_info) - { - // Grab a pointer to where we are going to put this register - uint8_t *dst = const_cast(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size)); - - if (dst == NULL) - return false; - - // Grab a pointer to where we are going to grab the new value from - const uint8_t *src = data.PeekData(0, reg_info->byte_size); + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; - if (src == NULL) - return false; - - if (data.GetByteOrder() == m_reg_data.GetByteOrder()) - { - // No swapping, just copy the bytes - ::memcpy (dst, src, reg_info->byte_size); - } - else - { - // Swap the bytes - for (uint32_t i=0; ibyte_size; ++i) - dst[i] = src[reg_info->byte_size - 1 - i]; - } + // Grab a pointer to where we are going to put this register + uint8_t *dst = const_cast(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size)); + if (dst == NULL) + return false; + + + if (data.CopyByteOrderedData (data_offset, // src offset + reg_info->byte_size, // src length + dst, // dst + reg_info->byte_size, // dst length + m_reg_data.GetByteOrder())) // dst byte order + { Mutex::Locker locker; if (gdb_comm.GetSequenceMutex (locker)) { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Mon May 9 15:18:18 2011 @@ -208,21 +208,15 @@ GetRegisterSet (uint32_t reg_set); virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); + ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - + WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); + virtual bool ReadAllRegisterValues (lldb::DataBufferSP &data_sp); virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset); - - virtual bool WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); virtual uint32_t @@ -232,6 +226,17 @@ friend class ThreadGDBRemote; bool + ReadRegisterBytes (const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value, + lldb_private::DataExtractor &data); + + bool + WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value, + lldb_private::DataExtractor &data, + uint32_t data_offset); + + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); void Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Mon May 9 15:18:18 2011 @@ -103,7 +103,8 @@ // We use the address byte size to be safe for any future addresss sizes RegisterInfo sp_reg_info; m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp_reg_info); - SetRegisterValue(sp_reg_info, (1ull << ((addr_byte_size * 8) - 1))); + m_initial_sp = (1ull << ((addr_byte_size * 8) - 1)); + SetRegisterValue(sp_reg_info, m_initial_sp); const InstructionList &inst_list = disasm_sp->GetInstructionList (); const size_t num_instructions = inst_list.GetSize(); @@ -155,7 +156,7 @@ UnwindAssembly * UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch) { - std::auto_ptr inst_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypePrologueEpilogue, NULL)); + std::auto_ptr inst_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypePrologueEpilogue, NULL)); // Make sure that all prologue instructions are handled if (inst_emulator_ap.get()) return new UnwindAssemblyInstEmulation (arch, inst_emulator_ap.release()); @@ -215,28 +216,34 @@ uint64_t -UnwindAssemblyInstEmulation::MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info) +UnwindAssemblyInstEmulation::MakeRegisterKindValuePair (const RegisterInfo ®_info) { uint32_t reg_kind, reg_num; - if (EmulateInstruction::GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) + if (EmulateInstruction::GetBestRegisterKindAndNumber (®_info, reg_kind, reg_num)) return (uint64_t)reg_kind << 24 | reg_num; return 0ull; } void -UnwindAssemblyInstEmulation::SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value) +UnwindAssemblyInstEmulation::SetRegisterValue (const RegisterInfo ®_info, const RegisterValue ®_value) { m_register_values[MakeRegisterKindValuePair (reg_info)] = reg_value; } -uint64_t -UnwindAssemblyInstEmulation::GetRegisterValue (const lldb_private::RegisterInfo ®_info) +bool +UnwindAssemblyInstEmulation::GetRegisterValue (const RegisterInfo ®_info, RegisterValue ®_value) { const uint64_t reg_id = MakeRegisterKindValuePair (reg_info); RegisterValueMap::const_iterator pos = m_register_values.find(reg_id); if (pos != m_register_values.end()) - return pos->second; - return MakeRegisterKindValuePair (reg_info); + { + reg_value = pos->second; + return true; // We had a real value that comes from an opcode that wrote + // to it... + } + // We are making up a value that is recognizable... + reg_value.SetUInt(reg_id, reg_info.byte_size); + return false; } @@ -280,6 +287,7 @@ switch (context.type) { + default: case EmulateInstruction::eContextInvalid: case EmulateInstruction::eContextReadOpcode: case EmulateInstruction::eContextImmediate: @@ -299,6 +307,7 @@ case EmulateInstruction::eContextReturnFromException: case EmulateInstruction::eContextPopRegisterOffStack: case EmulateInstruction::eContextAdjustStackPointer: + assert (!"unhandled case, add code to handle this!"); break; case EmulateInstruction::eContextPushRegisterOnStack: @@ -308,8 +317,8 @@ { UnwindPlan::Row::RegisterLocation regloc; const uint32_t dwarf_reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindDWARF]; - const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset; - regloc.SetIsCFAPlusOffset (reg_cfa_offset); + //const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset; + regloc.SetAtCFAPlusOffset (addr - inst_emulator->m_initial_sp); inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); } break; @@ -320,8 +329,6 @@ } break; - break; - } return dst_len; @@ -330,14 +337,19 @@ bool UnwindAssemblyInstEmulation::ReadRegister (EmulateInstruction *instruction, void *baton, - const RegisterInfo ®_info, - uint64_t ®_value) + const RegisterInfo *reg_info, + RegisterValue ®_value) { - UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - reg_value = inst_emulator->GetRegisterValue (reg_info); - - printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => value = 0x%16.16llx\n", reg_info.name, reg_value); + if (baton && reg_info) + { + UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; + bool synthetic = inst_emulator->GetRegisterValue (*reg_info, reg_value); + StreamFile strm (stdout, false); + strm.Printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => synthetic_value = %i, value = ", reg_info->name, synthetic); + reg_value.Dump(&strm, reg_info, false, eFormatDefault); + strm.EOL(); + } return true; } @@ -345,20 +357,24 @@ UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, - const RegisterInfo ®_info, - uint64_t reg_value) + const RegisterInfo *reg_info, + const RegisterValue ®_value) { + if (!baton || !reg_info) + return false; + UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - - printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = 0x%16.16llx, context =", - reg_info.name, - reg_value); + StreamFile strm (stdout, false); + strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name); + reg_value.Dump(&strm, reg_info, false, eFormatDefault); + strm.PutCString (", context = "); context.Dump(stdout, instruction); - inst_emulator->SetRegisterValue (reg_info, reg_value); + inst_emulator->SetRegisterValue (*reg_info, reg_value); switch (context.type) { + default: case EmulateInstruction::eContextInvalid: case EmulateInstruction::eContextReadOpcode: case EmulateInstruction::eContextImmediate: @@ -377,6 +393,7 @@ case EmulateInstruction::eContextAdvancePC: case EmulateInstruction::eContextReturnFromException: case EmulateInstruction::eContextPushRegisterOnStack: + assert (!"unhandled case, add code to handle this!"); break; case EmulateInstruction::eContextPopRegisterOffStack: @@ -385,7 +402,7 @@ { case EmulateInstruction::eInfoTypeRegisterPlusOffset: { - const uint32_t dwarf_reg_num = reg_info.kinds[eRegisterKindDWARF]; + const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF]; UnwindPlan::Row::RegisterLocation regloc; regloc.SetSame(); inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); @@ -400,16 +417,7 @@ break; case EmulateInstruction::eContextAdjustStackPointer: - switch (context.info_type) - { - case EmulateInstruction::eInfoTypeImmediateSigned: - inst_emulator->m_curr_row.SetCFAOffset (inst_emulator->m_curr_row.GetCFAOffset() + context.info.signed_immediate); - break; - - default: - assert (!"unhandled case, add code to handle this!"); - break; - } + inst_emulator->m_curr_row.SetCFAOffset (reg_value.GetAsUInt64() - inst_emulator->m_initial_sp); break; } return true; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Mon May 9 15:18:18 2011 @@ -12,6 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/EmulateInstruction.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/UnwindAssembly.h" @@ -89,15 +90,15 @@ static bool ReadRegister (lldb_private::EmulateInstruction *instruction, void *baton, - const lldb_private::RegisterInfo ®_info, - uint64_t ®_value); + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value); static bool WriteRegister (lldb_private::EmulateInstruction *instruction, void *baton, const lldb_private::EmulateInstruction::Context &context, - const lldb_private::RegisterInfo ®_info, - uint64_t reg_value); + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value); // Call CreateInstance to get an instance of this class @@ -120,17 +121,20 @@ MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info); void - SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value); + SetRegisterValue (const lldb_private::RegisterInfo ®_info, + const lldb_private::RegisterValue ®_value); - uint64_t - GetRegisterValue (const lldb_private::RegisterInfo ®_info); + bool + GetRegisterValue (const lldb_private::RegisterInfo ®_info, + lldb_private::RegisterValue ®_value); std::auto_ptr m_inst_emulator_ap; lldb_private::AddressRange* m_range_ptr; lldb_private::Thread* m_thread_ptr; lldb_private::UnwindPlan* m_unwind_plan_ptr; lldb_private::UnwindPlan::Row m_curr_row; - typedef std::map RegisterValueMap; + uint64_t m_initial_sp; + typedef std::map RegisterValueMap; RegisterValueMap m_register_values; }; Modified: lldb/trunk/source/Target/RegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/source/Target/RegisterContext.cpp (original) +++ lldb/trunk/source/Target/RegisterContext.cpp Mon May 9 15:18:18 2011 @@ -13,6 +13,7 @@ // Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Endian.h" #include "lldb/Target/ExecutionContext.h" @@ -150,9 +151,13 @@ { if (reg != LLDB_INVALID_REGNUM) { - Scalar value; - if (ReadRegisterValue (reg, value)) - return value.GetRawBits64(fail_value); + const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); + if (reg_info) + { + RegisterValue value; + if (ReadRegister (reg_info, value)) + return value.GetAsUInt64(); + } } return fail_value; } @@ -162,8 +167,14 @@ { if (reg == LLDB_INVALID_REGNUM) return false; - Scalar value(uval); - return WriteRegisterValue (reg, value); + const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); + if (reg_info) + { + RegisterValue value; + if (value.SetUInt(uval, reg_info->byte_size)) + return WriteRegister (reg_info, value); + } + return false; } lldb::tid_t @@ -215,6 +226,127 @@ return false; } +Error +RegisterContext::ReadRegisterValueFromMemory (const RegisterInfo *reg_info, + lldb::addr_t src_addr, + uint32_t src_len, + RegisterValue ®_value) +{ + Error error; + if (reg_info == NULL) + { + error.SetErrorString ("invalid register info argument."); + return error; + } + + + // Moving from addr into a register + // + // Case 1: src_len == dst_len + // + // |AABBCCDD| Address contents + // |AABBCCDD| Register contents + // + // Case 2: src_len > dst_len + // + // Error! (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 > RegisterValue::kMaxRegisterByteSize) + { + error.SetErrorString ("register too small to receive memory data"); + return error; + } + + 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 error; + } + + Process &process = m_thread.GetProcess(); + uint8_t src[RegisterValue::kMaxRegisterByteSize]; + + // Read the memory + const uint32_t bytes_read = process.ReadMemory (src_addr, src, src_len, error); + + // Make sure the memory read succeeded... + if (bytes_read != src_len) + { + if (error.Success()) + { + // This might happen if we read _some_ bytes but not all + error.SetErrorStringWithFormat("read %u of %u bytes", bytes_read, src_len); + } + return error; + } + + // We now have a memory buffer that contains the part or all of the register + // value. Set the register value using this memory data. + // TODO: we might need to add a parameter to this function in case the byte + // order of the memory data doesn't match the process. For now we are assuming + // they are the same. + reg_value.SetFromMemoryData (reg_info, + src, + src_len, + process.GetByteOrder(), + error); + return error; +} + +Error +RegisterContext::WriteRegisterValueToMemory (const RegisterInfo *reg_info, + lldb::addr_t dst_addr, + uint32_t dst_len, + const RegisterValue ®_value) +{ + + uint8_t dst[RegisterValue::kMaxRegisterByteSize]; + + Error error; + + Process &process = m_thread.GetProcess(); + + // TODO: we might need to add a parameter to this function in case the byte + // order of the memory data doesn't match the process. For now we are assuming + // they are the same. + + const uint32_t bytes_copied = reg_value.GetAsMemoryData (reg_info, + dst, + dst_len, + process.GetByteOrder(), + error); + + if (error.Success()) + { + if (bytes_copied == 0) + { + error.SetErrorString("byte copy failed."); + } + else + { + const uint32_t bytes_written = process.WriteMemory (dst_addr, dst, bytes_copied, error); + if (bytes_written != bytes_copied) + { + if (error.Success()) + { + // This might happen if we read _some_ bytes but not all + error.SetErrorStringWithFormat("only wrote %u of %u bytes", bytes_written, bytes_copied); + } + } + } + } + + return error; + +} + Target * RegisterContext::CalculateTarget () { @@ -274,124 +406,124 @@ return false; } -bool -RegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value) -{ - DataExtractor data; - if (!ReadRegisterBytes (reg, data)) - return false; - - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - uint32_t offset = 0; - switch (reg_info->encoding) - { - case eEncodingInvalid: - case eEncodingVector: - break; - - case eEncodingUint: - switch (reg_info->byte_size) - { - case 1: - { - value = data.GetU8 (&offset); - return true; - } - case 2: - { - value = data.GetU16 (&offset); - return true; - } - case 4: - { - value = data.GetU32 (&offset); - return true; - } - case 8: - { - value = data.GetU64 (&offset); - return true; - } - } - break; - case eEncodingSint: - switch (reg_info->byte_size) - { - case 1: - { - int8_t v; - if (data.ExtractBytes (0, sizeof (int8_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int8_t)) - return false; - value = v; - return true; - } - case 2: - { - int16_t v; - if (data.ExtractBytes (0, sizeof (int16_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int16_t)) - return false; - value = v; - return true; - } - case 4: - { - int32_t v; - if (data.ExtractBytes (0, sizeof (int32_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int32_t)) - return false; - value = v; - return true; - } - case 8: - { - int64_t v; - if (data.ExtractBytes (0, sizeof (int64_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int64_t)) - return false; - value = v; - return true; - } - } - break; - case eEncodingIEEE754: - switch (reg_info->byte_size) - { - case sizeof (float): - { - float v; - if (data.ExtractBytes (0, sizeof (float), lldb::endian::InlHostByteOrder(), &v) != sizeof (float)) - return false; - value = v; - return true; - } - case sizeof (double): - { - double v; - if (data.ExtractBytes (0, sizeof (double), lldb::endian::InlHostByteOrder(), &v) != sizeof (double)) - return false; - value = v; - return true; - } - case sizeof (long double): - { - double v; - if (data.ExtractBytes (0, sizeof (long double), lldb::endian::InlHostByteOrder(), &v) != sizeof (long double)) - return false; - value = v; - return true; - } - } - break; - } - return false; -} - -bool -RegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value) -{ - DataExtractor data; - if (!value.IsValid()) - return false; - if (!value.GetData (data)) - return false; - - return WriteRegisterBytes (reg, data); -} +//bool +//RegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value) +//{ +// DataExtractor data; +// if (!ReadRegisterBytes (reg, data)) +// return false; +// +// const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); +// uint32_t offset = 0; +// switch (reg_info->encoding) +// { +// case eEncodingInvalid: +// case eEncodingVector: +// break; +// +// case eEncodingUint: +// switch (reg_info->byte_size) +// { +// case 1: +// { +// value = data.GetU8 (&offset); +// return true; +// } +// case 2: +// { +// value = data.GetU16 (&offset); +// return true; +// } +// case 4: +// { +// value = data.GetU32 (&offset); +// return true; +// } +// case 8: +// { +// value = data.GetU64 (&offset); +// return true; +// } +// } +// break; +// case eEncodingSint: +// switch (reg_info->byte_size) +// { +// case 1: +// { +// int8_t v; +// if (data.ExtractBytes (0, sizeof (int8_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int8_t)) +// return false; +// value = v; +// return true; +// } +// case 2: +// { +// int16_t v; +// if (data.ExtractBytes (0, sizeof (int16_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int16_t)) +// return false; +// value = v; +// return true; +// } +// case 4: +// { +// int32_t v; +// if (data.ExtractBytes (0, sizeof (int32_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int32_t)) +// return false; +// value = v; +// return true; +// } +// case 8: +// { +// int64_t v; +// if (data.ExtractBytes (0, sizeof (int64_t), lldb::endian::InlHostByteOrder(), &v) != sizeof (int64_t)) +// return false; +// value = v; +// return true; +// } +// } +// break; +// case eEncodingIEEE754: +// switch (reg_info->byte_size) +// { +// case sizeof (float): +// { +// float v; +// if (data.ExtractBytes (0, sizeof (float), lldb::endian::InlHostByteOrder(), &v) != sizeof (float)) +// return false; +// value = v; +// return true; +// } +// case sizeof (double): +// { +// double v; +// if (data.ExtractBytes (0, sizeof (double), lldb::endian::InlHostByteOrder(), &v) != sizeof (double)) +// return false; +// value = v; +// return true; +// } +// case sizeof (long double): +// { +// double v; +// if (data.ExtractBytes (0, sizeof (long double), lldb::endian::InlHostByteOrder(), &v) != sizeof (long double)) +// return false; +// value = v; +// return true; +// } +// } +// break; +// } +// return false; +//} +// +//bool +//RegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value) +//{ +// DataExtractor data; +// if (!value.IsValid()) +// return false; +// if (!value.GetData (data)) +// return false; +// +// return WriteRegisterBytes (reg, data); +//} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=131096&r1=131095&r2=131096&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon May 9 15:18:18 2011 @@ -359,6 +359,7 @@ 26CE05C7115C36870022F371 /* ShellScript */, 26CE0591115C31C20022F371 /* Sources */, 26CE0592115C31C20022F371 /* Frameworks */, + 26C6886A13787FC900407EDF /* Codesign hack */, ); buildRules = ( ); @@ -397,6 +398,20 @@ /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ + 26C6886A13787FC900407EDF /* Codesign hack */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Codesign hack"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "codesign --force --keychain ~/Library/Keychains/login.keychain --sign lldb_codesign \"$CODESIGNING_FOLDER_PATH\""; + }; 26CE05C7115C36870022F371 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -565,7 +580,6 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -595,7 +609,6 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -605,7 +618,6 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -635,7 +647,6 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; From gclayton at apple.com Mon May 9 15:23:11 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 09 May 2011 20:23:11 -0000 Subject: [Lldb-commits] [lldb] r131097 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110509202311.2BF162A6C12C@llvm.org> Author: gclayton Date: Mon May 9 15:23:10 2011 New Revision: 131097 URL: http://llvm.org/viewvc/llvm-project?rev=131097&view=rev Log: Revert some unintended project changes from my last checkin. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131097&r1=131096&r2=131097&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon May 9 15:23:10 2011 @@ -3868,6 +3868,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = dwarf; @@ -3900,6 +3901,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=131097&r1=131096&r2=131097&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon May 9 15:23:10 2011 @@ -359,7 +359,6 @@ 26CE05C7115C36870022F371 /* ShellScript */, 26CE0591115C31C20022F371 /* Sources */, 26CE0592115C31C20022F371 /* Frameworks */, - 26C6886A13787FC900407EDF /* Codesign hack */, ); buildRules = ( ); @@ -398,20 +397,6 @@ /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ - 26C6886A13787FC900407EDF /* Codesign hack */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Codesign hack"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "codesign --force --keychain ~/Library/Keychains/login.keychain --sign lldb_codesign \"$CODESIGNING_FOLDER_PATH\""; - }; 26CE05C7115C36870022F371 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -580,6 +565,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -609,6 +595,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -618,6 +605,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -647,6 +635,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; From johnny.chen at apple.com Mon May 9 15:51:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 09 May 2011 20:51:47 -0000 Subject: [Lldb-commits] [lldb] r131100 - /lldb/trunk/test/platform/TestPlatformCommand.py Message-ID: <20110509205147.DF7682A6C12C@llvm.org> Author: johnny Date: Mon May 9 15:51:47 2011 New Revision: 131100 URL: http://llvm.org/viewvc/llvm-project?rev=131100&view=rev Log: Add a test case test_process_info_with_no_arg(self) to 'class PlatformCommandTestCase' for http://llvm.org/viewvc/llvm-project?rev=131089&view=rev. Modified: lldb/trunk/test/platform/TestPlatformCommand.py Modified: lldb/trunk/test/platform/TestPlatformCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/platform/TestPlatformCommand.py?rev=131100&r1=131099&r2=131100&view=diff ============================================================================== --- lldb/trunk/test/platform/TestPlatformCommand.py (original) +++ lldb/trunk/test/platform/TestPlatformCommand.py Mon May 9 15:51:47 2011 @@ -22,6 +22,11 @@ self.expect("platform process list", substrs = ['PID', 'ARCH', 'NAME']) + def test_process_info_with_no_arg(self): + """This is expected to fail and to return a proper error message.""" + self.expect("platform process info", error=True, + substrs = ['one or more process id(s) must be specified']) + def test_status(self): self.expect("platform status", substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname']) From scallanan at apple.com Mon May 9 17:04:36 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 09 May 2011 22:04:36 -0000 Subject: [Lldb-commits] [lldb] r131104 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangUserExpression.h include/lldb/Target/ThreadPlanCallFunction.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110509220436.606ED2A6C12C@llvm.org> Author: spyffe Date: Mon May 9 17:04:36 2011 New Revision: 131104 URL: http://llvm.org/viewvc/llvm-project?rev=131104&view=rev Log: Fixed a bug in which expression-local variables were treated as being permanently resident in target memory. In fact, since the expression's stack frame is deleted and potentially re-used after the expression completes, the variables need to be treated as being freeze-dried. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon May 9 17:04:36 2011 @@ -425,6 +425,12 @@ /// A ClangExpressionVariable containing the result of the /// expression, for potential re-use. /// + /// @param[in] stack_frame_top, stack_frame_bottom + /// If not LLDB_INVALID_ADDRESS, the bounds for the stack frame + /// in which the expression ran. A result whose address falls + /// inside this stack frame is dematerialized as a value + /// requiring rematerialization. + /// /// @param[in] error /// An Error to populate with any messages related to /// dematerializing the struct. @@ -435,6 +441,8 @@ bool Dematerialize (ExecutionContext &exe_ctx, lldb::ClangExpressionVariableSP &result_sp, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, Error &error); //------------------------------------------------------------------ @@ -817,6 +825,12 @@ /// @param[in] exe_ctx /// The execution context to use. /// + /// @param[in] stack_frame_top, stack_frame_bottom + /// If not LLDB_INVALID_ADDRESS, the bounds for the stack frame + /// in which the expression ran. A result whose address falls + /// inside this stack frame is dematerialized as a value + /// requiring rematerialization. + /// /// @param[out] result /// If the struct is being dematerialized, a pointer into which the /// location of the result persistent variable is placed. If not, @@ -832,6 +846,8 @@ bool DoMaterialize (bool dematerialize, ExecutionContext &exe_ctx, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, lldb::ClangExpressionVariableSP *result_sp_ptr, Error &err); @@ -858,6 +874,12 @@ /// @param[in] addr /// The address at which to materialize the variable. /// + /// @param[in] stack_frame_top, stack_frame_bottom + /// If not LLDB_INVALID_ADDRESS, the bounds for the stack frame + /// in which the expression ran. A result whose address falls + /// inside this stack frame is dematerialized as a value + /// requiring rematerialization. + /// /// @param[in] err /// An Error to populate with any messages related to /// (de)materializing the persistent variable. @@ -870,6 +892,8 @@ ExecutionContext &exe_ctx, lldb::ClangExpressionVariableSP &var_sp, lldb::addr_t addr, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, Error &err); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon May 9 17:04:36 2011 @@ -134,10 +134,34 @@ GetThreadPlanToExecuteJITExpression (Stream &error_stream, ExecutionContext &exe_ctx); + //------------------------------------------------------------------ + /// Apply the side effects of the function to program state. + /// + /// @param[in] error_stream + /// A stream to print errors to. + /// + /// @param[in] exe_ctx + /// The execution context to use when looking up entities that + /// are needed for parsing (locations of variables, etc.) + /// + /// @param[in] result + /// A pointer to direct at the persistent variable in which the + /// expression's result is stored. + /// + /// @param[in] function_stack_pointer + /// A pointer to the base of the function's stack frame. This + /// is used to determine whether the expession result resides in + /// memory that will still be valid, or whether it needs to be + /// treated as homeless for the purpose of future expressions. + /// + /// @return + /// A Process::Execution results value. + //------------------------------------------------------------------ bool FinalizeJITExecution (Stream &error_stream, ExecutionContext &exe_ctx, - lldb::ClangExpressionVariableSP &result); + lldb::ClangExpressionVariableSP &result, + lldb::addr_t function_stack_pointer = LLDB_INVALID_ADDRESS); //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Mon May 9 17:04:36 2011 @@ -70,6 +70,16 @@ return true; } + // Return the stack pointer that the function received + // on entry. Any stack address below this should be + // considered invalid after the function has been + // cleaned up. + lldb::addr_t + GetFunctionStackPointer() + { + return m_function_sp; + } + // Classes that derive from ClangFunction, and implement // their own WillPop methods should call this so that the // thread state gets restored if the plan gets discarded. @@ -97,6 +107,7 @@ Address m_function_addr; Address m_start_addr; lldb::addr_t m_arg_addr; + lldb::addr_t m_function_sp; ValueList *m_args; Process &m_process; Thread &m_thread; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon May 9 17:04:36 2011 @@ -588,7 +588,12 @@ m_material_vars->m_process = exe_ctx.process; - bool result = DoMaterialize(false /* dematerialize */, exe_ctx, NULL, err); + bool result = DoMaterialize(false /* dematerialize */, + exe_ctx, + LLDB_INVALID_ADDRESS /* top of stack frame */, + LLDB_INVALID_ADDRESS /* bottom of stack frame */, + NULL, /* result SP */ + err); if (result) struct_address = m_material_vars->m_materialized_location; @@ -717,10 +722,12 @@ ( ExecutionContext &exe_ctx, ClangExpressionVariableSP &result_sp, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, Error &err ) { - return DoMaterialize(true, exe_ctx, &result_sp, err); + return DoMaterialize(true, exe_ctx, stack_frame_top, stack_frame_bottom, &result_sp, err); DidDematerialize(); } @@ -825,6 +832,8 @@ ( bool dematerialize, ExecutionContext &exe_ctx, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, lldb::ClangExpressionVariableSP *result_sp_ptr, Error &err ) @@ -948,7 +957,9 @@ if (!DoMaterializeOnePersistentVariable (dematerialize, exe_ctx, member_sp, - m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, + m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, + stack_frame_top, + stack_frame_bottom, err)) return false; } @@ -1027,6 +1038,8 @@ ExecutionContext &exe_ctx, ClangExpressionVariableSP &var_sp, lldb::addr_t addr, + lldb::addr_t stack_frame_top, + lldb::addr_t stack_frame_bottom, Error &err ) { @@ -1103,10 +1116,7 @@ log->Printf("Dematerializing %s from 0x%llx", var_sp->GetName().GetCString(), (uint64_t)mem); // Read the contents of the spare memory area - - if (log) - log->Printf("Read"); - + var_sp->ValueUpdated (); if (exe_ctx.process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size) { @@ -1114,6 +1124,20 @@ return false; } + if (stack_frame_top != LLDB_INVALID_ADDRESS && + stack_frame_bottom != LLDB_INVALID_ADDRESS && + mem >= stack_frame_bottom && + mem <= stack_frame_top) + { + // If the variable is resident in the stack frame created by the expression, + // then it cannot be relied upon to stay around. We treat it as needing + // reallocation. + + var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated; + var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation; + var_sp->m_flags &= ~ClangExpressionVariable::EVIsProgramReference; + } + var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsFreezeDry; } Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon May 9 17:04:36 2011 @@ -421,7 +421,8 @@ bool ClangUserExpression::FinalizeJITExecution (Stream &error_stream, ExecutionContext &exe_ctx, - lldb::ClangExpressionVariableSP &result) + lldb::ClangExpressionVariableSP &result, + lldb::addr_t function_stack_pointer) { Error expr_error; @@ -444,8 +445,11 @@ log->Printf(" Structure contents:\n%s", args.GetData()); } } + + lldb::addr_t function_stack_bottom = function_stack_pointer - Host::GetPageSize(); + - if (!m_expr_decl_map->Dematerialize(exe_ctx, result, expr_error)) + if (!m_expr_decl_map->Dematerialize(exe_ctx, result, function_stack_pointer, function_stack_bottom, expr_error)) { error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error")); return false; @@ -497,6 +501,8 @@ if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) return eExecutionSetupError; + + lldb::addr_t function_stack_pointer = static_cast(call_plan_sp.get())->GetFunctionStackPointer(); call_plan_sp->SetPrivate(true); @@ -506,12 +512,12 @@ log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --"); ExecutionResults execution_result = exe_ctx.process->RunThreadPlan (exe_ctx, - call_plan_sp, - stop_others, - try_all_threads, - discard_on_error, - single_thread_timeout_usec, - error_stream); + call_plan_sp, + stop_others, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_stream); if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --"); @@ -531,7 +537,7 @@ return execution_result; } - if (FinalizeJITExecution (error_stream, exe_ctx, result)) + if (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_pointer)) return eExecutionCompleted; else return eExecutionSetupError; Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131104&r1=131103&r2=131104&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Mon May 9 17:04:36 2011 @@ -49,7 +49,8 @@ m_args (NULL), m_process (thread.GetProcess()), m_thread (thread), - m_takedown_done (false) + m_takedown_done (false), + m_function_sp(NULL) { SetOkayToDiscard (discard_on_error); @@ -64,7 +65,7 @@ SetBreakpoints(); - lldb::addr_t spBelowRedZone = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); + m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); ModuleSP executableModuleSP (target.GetExecutableModule()); @@ -110,7 +111,7 @@ lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (!abi->PrepareTrivialCall(thread, - spBelowRedZone, + m_function_sp, FunctionLoadAddr, StartLoadAddr, m_arg_addr, From ctice at apple.com Mon May 9 18:06:58 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 09 May 2011 23:06:58 -0000 Subject: [Lldb-commits] [lldb] r131110 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Core/Debugger.h source/API/SBDebugger.cpp source/Core/Debugger.cpp tools/driver/Driver.h tools/driver/IOChannel.cpp Message-ID: <20110509230658.4C2A12A6C12C@llvm.org> Author: ctice Date: Mon May 9 18:06:58 2011 New Revision: 131110 URL: http://llvm.org/viewvc/llvm-project?rev=131110&view=rev Log: Make sure writing asynchronous output only backs up & overwrites prompt if the IOChannel input reader is the top input reader. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/tools/driver/Driver.h lldb/trunk/tools/driver/IOChannel.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Mon May 9 18:06:58 2011 @@ -166,6 +166,9 @@ void NotifyTopInputReader (lldb::InputReaderAction notification); + bool + InputReaderIsTopReader (const lldb::SBInputReader &reader); + const char * GetInstanceName (); Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon May 9 18:06:58 2011 @@ -391,6 +391,9 @@ void NotifyTopInputReader (lldb::InputReaderAction notification); + bool + InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp); + static lldb::DebuggerSP FindDebuggerWithID (lldb::user_id_t id); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon May 9 18:06:58 2011 @@ -619,6 +619,24 @@ if (m_opaque_sp) m_opaque_sp->DispatchInputEndOfFile (); } + +bool +SBDebugger::InputReaderIsTopReader (const lldb::SBInputReader &reader) +{ + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + if (log) + log->Printf ("SBDebugger(%p)::InputReaderIsTopReader (SBInputReader(%p))", m_opaque_sp.get(), &reader); + + if (m_opaque_sp && reader.IsValid()) + { + InputReaderSP reader_sp (*reader); + return m_opaque_sp->InputReaderIsTopReader (reader_sp); + } + + return false; +} + void SBDebugger::PushInputReader (SBInputReader &reader) Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon May 9 18:06:58 2011 @@ -437,6 +437,25 @@ } } +bool +Debugger::InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp) +{ + if (reader_sp) + { + InputReaderSP top_reader_sp (GetCurrentInputReader()); + if (top_reader_sp) + { + return (reader_sp.get() == top_reader_sp.get()); + } + else + return false; + } + else + return false; + +} + + void Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len) { Modified: lldb/trunk/tools/driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.h (original) +++ lldb/trunk/tools/driver/Driver.h Mon May 9 18:06:58 2011 @@ -122,6 +122,12 @@ { return m_debugger; } + + bool + EditlineReaderIsTop () + { + return m_debugger.InputReaderIsTopReader (m_editline_reader); + } private: lldb::SBDebugger m_debugger; Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=131110&r1=131109&r2=131110&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Mon May 9 18:06:58 2011 @@ -499,7 +499,7 @@ // Use the mutex to make sure OutWrite and ErrWrite do not interfere with each other's output. IOLocker locker (m_output_mutex); - if (asynchronous) + if (m_driver->EditlineReaderIsTop() && asynchronous) ::fwrite (undo_prompt_string, 1, 4, m_out_file); ::fwrite (buffer, 1, len, m_out_file); if (asynchronous) From johnny.chen at apple.com Mon May 9 18:41:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 09 May 2011 23:41:06 -0000 Subject: [Lldb-commits] [lldb] r131111 - /lldb/trunk/test/expression_command/test/TestExprs2.py Message-ID: <20110509234106.62CDF2A6C12C@llvm.org> Author: johnny Date: Mon May 9 18:41:06 2011 New Revision: 131111 URL: http://llvm.org/viewvc/llvm-project?rev=131111&view=rev Log: Add TestExprs2.py for recent check-ins related to the 'expression' subsystem. Added: lldb/trunk/test/expression_command/test/TestExprs2.py Added: lldb/trunk/test/expression_command/test/TestExprs2.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs2.py?rev=131111&view=auto ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs2.py (added) +++ lldb/trunk/test/expression_command/test/TestExprs2.py Mon May 9 18:41:06 2011 @@ -0,0 +1,66 @@ +""" +Test some more expression commands. +""" + +import os +import unittest2 +import lldb +import lldbutil +from lldbtest import * + +class ExprCommands2TestCase(TestBase): + + mydir = os.path.join("expression_command", "test") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.cpp', + '// Please test many expressions while stopped at this line:') + + def test_more_expr_commands(self): + """Test some more expression commands.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + # Does static casting work? + self.expect("expression (int*)argv", + startstr = "(int *) $0 = 0x") + # (int *) $0 = 0x00007fff5fbff258 + + # Do anonymous symbols work? + self.expect("expression ((char**)environ)[0]", + startstr = "(char *) $1 = 0x") + # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render" + + # Do return values containing the contents of expression locals work? + self.expect("expression int i = 5; i", + startstr = "(int) $2 = 5") + # (int) $2 = 5 + self.expect("expression $2 + 1", + startstr = "(int) $3 = 6") + # (int) $3 = 6 + + # Do return values containing the results of static expressions work? + self.expect("expression 20 + 3", + startstr = "(int) $4 = 23") + # (int) $4 = 5 + self.expect("expression $4 + 1", + startstr = "(int) $5 = 24") + # (int) $5 = 6 + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From johnny.chen at apple.com Tue May 10 14:21:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 May 2011 19:21:13 -0000 Subject: [Lldb-commits] [lldb] r131144 - in /lldb/trunk/test: lldbutil.py python_api/lldbutil/TestRegistersIterator.py Message-ID: <20110510192113.E92292A6C12C@llvm.org> Author: johnny Date: Tue May 10 14:21:13 2011 New Revision: 131144 URL: http://llvm.org/viewvc/llvm-project?rev=131144&view=rev Log: Add a utility function get_registers(frame, kind) to get the registers of a given frame and of a given kind. Also add three convenience functions get_GPRs(frame), get_FPRs(frame), and get_ESRs(frame) to get the general purpose registers, the floating point registers, and the exception state registers. Add TestRegistersIterator.py to test these added functions of lldbutil.py. Added: lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131144&r1=131143&r2=131144&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue May 10 14:21:13 2011 @@ -416,9 +416,9 @@ print >> output, "Register sets for " + repr(frame) - registerList = frame.GetRegisters() - print >> output, "Frame registers (size of register set = %d):" % registerList.GetSize() - for value in registerList: + registerSet = frame.GetRegisters() # Return type of SBValueList. + print >> output, "Frame registers (size of register set = %d):" % registerSet.GetSize() + for value in registerSet: #print >> output, value print >> output, "%s (number of children = %d):" % (value.GetName(), value.GetNumChildren()) for child in value: @@ -426,3 +426,36 @@ if string_buffer: return output.getvalue() + +def get_registers(frame, kind): + """Returns the registers given the frame and the kind of registers desired. + + Returns None if there's no such kind. + """ + registerSet = frame.GetRegisters() # Return type of SBValueList. + for value in registerSet: + if kind.lower() in value.GetName().lower(): + return value + + return None + +def get_GPRs(frame): + """Returns the general purpose registers of the frame as an SBValue. + + The returned SBValue object is iterable. + """ + return get_registers(frame, "general purpose") + +def get_FPRs(frame): + """Returns the floating point registers of the frame as an SBValue. + + The returned SBValue object is iterable. + """ + return get_registers(frame, "floating point") + +def get_ESRs(frame): + """Returns the exception state registers of the frame as an SBValue. + + The returned SBValue object is iterable. + """ + return get_registers(frame, "exception state") Added: lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py?rev=131144&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (added) +++ lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py Tue May 10 14:21:13 2011 @@ -0,0 +1,72 @@ +""" +Test the iteration protocol for frame registers. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class RegistersIteratorTestCase(TestBase): + + mydir = "python_api/lldbutil" + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line1 = line_number('main.cpp', '// Set break point at this line.') + + def test_iter_registers(self): + """Test iterator works correctly for lldbutil.iter_registers().""" + self.buildDefault() + self.iter_registers() + + def iter_registers(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + import lldbutil + for thread in self.process: + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + for frame in thread: + # Dump the registers of this frame using iter_registers(). + if self.TraceOn(): + print frame + + for kind in ["General Purpose Registers", + "Floating Point Registers", + "Exception State Registers"]: + REGs = lldbutil.get_registers(frame, kind) + if self.TraceOn(): + print "%s:" % kind + for reg in REGs: + self.assertTrue(reg.IsValid()) + if self.TraceOn(): + print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) + + # And these should also work. + self.assertTrue(lldbutil.get_GPRs(frame)) + self.assertTrue(lldbutil.get_FPRs(frame)) + self.assertTrue(lldbutil.get_ESRs(frame)) + break + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From scallanan at apple.com Tue May 10 14:47:39 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 10 May 2011 19:47:39 -0000 Subject: [Lldb-commits] [lldb] r131145 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20110510194739.7DA7A2A6C12C@llvm.org> Author: spyffe Date: Tue May 10 14:47:39 2011 New Revision: 131145 URL: http://llvm.org/viewvc/llvm-project?rev=131145&view=rev Log: Fixed a bug that caused types to be incorrectly looked up. Queries for global types were made too specific -- including the current module and compile unit in the query was limiting the search when we wanted a truly global search. Modified: lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=131145&r1=131144&r2=131145&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue May 10 14:47:39 2011 @@ -9,6 +9,7 @@ #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Interpreter/Args.h" #include "lldb/Symbol/CompileUnit.h" @@ -453,7 +454,11 @@ if (module_sp && module_sp->FindTypes (*this, name, false, 1, types)) return types.GetTypeAtIndex(0); - if (!return_value.get() && target_sp && target_sp->GetImages().FindTypes (*this, name, false, 1, types)) + SymbolContext sc_for_global_search; + + sc_for_global_search.target_sp = target_sp; + + if (!return_value.get() && target_sp && target_sp->GetImages().FindTypes (sc_for_global_search, name, false, 1, types)) return types.GetTypeAtIndex(0); return return_value; From johnny.chen at apple.com Tue May 10 16:36:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 May 2011 21:36:11 -0000 Subject: [Lldb-commits] [lldb] r131154 - in /lldb/trunk/test: expression_command/two-files/ expression_command/two-files/Makefile expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py expression_command/two-files/foo.m expression_command/two-files/main.c foundation/Makefile Message-ID: <20110510213611.CCA8B2A6C12C@llvm.org> Author: johnny Date: Tue May 10 16:36:11 2011 New Revision: 131154 URL: http://llvm.org/viewvc/llvm-project?rev=131154&view=rev Log: Add TestObjCTypeQueryFromOtherCompileUnit.py to test that when stopped in the 'main.c' compile unit, which has an external reference to symbols defined in foo.m, the type query: in this case, 'expression (NSArray*)array_token' continues to work. This test is to accompany http://llvm.org/viewvc/llvm-project?rev=131145&view=rev. Added: lldb/trunk/test/expression_command/two-files/ lldb/trunk/test/expression_command/two-files/Makefile lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py lldb/trunk/test/expression_command/two-files/foo.m lldb/trunk/test/expression_command/two-files/main.c Modified: lldb/trunk/test/foundation/Makefile Added: lldb/trunk/test/expression_command/two-files/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/Makefile?rev=131154&view=auto ============================================================================== --- lldb/trunk/test/expression_command/two-files/Makefile (added) +++ lldb/trunk/test/expression_command/two-files/Makefile Tue May 10 16:36:11 2011 @@ -0,0 +1,8 @@ +LEVEL = ../../make + +C_SOURCES := main.c +OBJC_SOURCES := foo.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation \ No newline at end of file Added: lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py?rev=131154&view=auto ============================================================================== --- lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py (added) +++ lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Tue May 10 16:36:11 2011 @@ -0,0 +1,54 @@ +""" +Regression test for : + +The expression parser's type search only looks in the current compilation unit for types. +""" + +import unittest2 +import lldb +from lldbtest import * + +class ObjCTypeQueryTestCase(TestBase): + + mydir = os.path.join("expression_command", "two-files") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.c', + "// Set breakpoint here, then do 'expr (NSArray*)array_token'.") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """The expression parser's type search should be wider than the current compilation unit.""" + self.buildDsym() + self.type_query_from_other_cu() + + def test_with_dwarf(self): + """The expression parser's type search should be wider than the current compilation unit.""" + self.buildDwarf() + self.type_query_from_other_cu() + + def type_query_from_other_cu(self): + """The expression parser's type search should be wider than the current compilation unit.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.c -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = %d" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + # Now do a NSArry type query from the 'main.c' compile uint. + self.expect("expression (NSArray*)array_token", + substrs = ['(NSArray *) $0 =']) + # (NSArray *) $0 = 0x00007fff70118398 + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/two-files/foo.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/foo.m?rev=131154&view=auto ============================================================================== --- lldb/trunk/test/expression_command/two-files/foo.m (added) +++ lldb/trunk/test/expression_command/two-files/foo.m Tue May 10 16:36:11 2011 @@ -0,0 +1,28 @@ +#import + +NSMutableArray * +GetArray () +{ + static NSMutableArray *the_array = NULL; + if (the_array == NULL) + the_array = [[NSMutableArray alloc] init]; + return the_array; +} + +int +AddElement (char *value) +{ + NSString *element = [NSString stringWithUTF8String: value]; + int cur_elem = [GetArray() count]; + [GetArray() addObject: element]; + return cur_elem; +} + +const char * +GetElement (int idx) +{ + if (idx >= [GetArray() count]) + return NULL; + else + return [[GetArray() objectAtIndex: idx] UTF8String]; +} Added: lldb/trunk/test/expression_command/two-files/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/main.c?rev=131154&view=auto ============================================================================== --- lldb/trunk/test/expression_command/two-files/main.c (added) +++ lldb/trunk/test/expression_command/two-files/main.c Tue May 10 16:36:11 2011 @@ -0,0 +1,19 @@ +#include + +extern int AddElement (char *value); +extern char *GetElement (int idx); +extern void *GetArray(); + +int +main () +{ + + int idx = AddElement ("some string"); + void *array_token = GetArray(); + + char *string = GetElement (0); // Set breakpoint here, then do 'expr (NSArray*)array_token'. + if (string) + printf ("This: %s.\n", string); + + return 0; +} Modified: lldb/trunk/test/foundation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/Makefile?rev=131154&r1=131153&r2=131154&view=diff ============================================================================== --- lldb/trunk/test/foundation/Makefile (original) +++ lldb/trunk/test/foundation/Makefile Tue May 10 16:36:11 2011 @@ -3,6 +3,6 @@ OBJC_SOURCES := main.m my-base.m #OBJC_SOURCES := const-strings.m -LDFLAGS = $(CFLAGS) -lobjc -framework Foundation - include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation From johnny.chen at apple.com Tue May 10 17:46:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 May 2011 22:46:13 -0000 Subject: [Lldb-commits] [lldb] r131165 - /lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Message-ID: <20110510224613.B0F492A6C12F@llvm.org> Author: johnny Date: Tue May 10 17:46:13 2011 New Revision: 131165 URL: http://llvm.org/viewvc/llvm-project?rev=131165&view=rev Log: More string matching criterion. Modified: lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Modified: lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py?rev=131165&r1=131164&r2=131165&view=diff ============================================================================== --- lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py (original) +++ lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Tue May 10 17:46:13 2011 @@ -43,7 +43,7 @@ # Now do a NSArry type query from the 'main.c' compile uint. self.expect("expression (NSArray*)array_token", - substrs = ['(NSArray *) $0 =']) + substrs = ['(NSArray *) $0 = 0x']) # (NSArray *) $0 = 0x00007fff70118398 From johnny.chen at apple.com Tue May 10 18:01:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 May 2011 23:01:44 -0000 Subject: [Lldb-commits] [lldb] r131168 - /lldb/trunk/test/lldbutil.py Message-ID: <20110510230144.4A8182A6C12C@llvm.org> Author: johnny Date: Tue May 10 18:01:44 2011 New Revision: 131168 URL: http://llvm.org/viewvc/llvm-project?rev=131168&view=rev Log: Add more docstrings for get_GPRs(frame), getFPRs(frame), and get_ESRs(frame). Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131168&r1=131167&r2=131168&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue May 10 18:01:44 2011 @@ -442,20 +442,38 @@ def get_GPRs(frame): """Returns the general purpose registers of the frame as an SBValue. - The returned SBValue object is iterable. + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_GPRs + regs = get_GPRs(frame) + for reg in regs: + print "%s => %s" % (reg.GetName(), reg.GetValue()) + ... """ return get_registers(frame, "general purpose") def get_FPRs(frame): """Returns the floating point registers of the frame as an SBValue. - The returned SBValue object is iterable. + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_FPRs + regs = get_FPRs(frame) + for reg in regs: + print "%s => %s" % (reg.GetName(), reg.GetValue()) + ... """ return get_registers(frame, "floating point") def get_ESRs(frame): """Returns the exception state registers of the frame as an SBValue. - The returned SBValue object is iterable. + The returned SBValue object is iterable. An example: + ... + from lldbutil import get_ESRs + regs = get_ESRs(frame) + for reg in regs: + print "%s => %s" % (reg.GetName(), reg.GetValue()) + ... """ return get_registers(frame, "exception state") From ctice at apple.com Wed May 11 11:07:07 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 11 May 2011 16:07:07 -0000 Subject: [Lldb-commits] [lldb] r131185 - in /lldb/trunk: include/lldb/Interpreter/CommandInterpreter.h source/Interpreter/CommandInterpreter.cpp Message-ID: <20110511160707.1B5E02A6C12C@llvm.org> Author: ctice Date: Wed May 11 11:07:06 2011 New Revision: 131185 URL: http://llvm.org/viewvc/llvm-project?rev=131185&view=rev Log: Add ability to recognize/handle quotes around commands (e.g. '"target" create' works as well as 'target create'). Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=131185&r1=131184&r2=131185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Wed May 11 11:07:06 2011 @@ -105,7 +105,9 @@ bool StripFirstWord (std::string &command_string, - std::string &next_word); + std::string &next_word, + bool &was_quoted, + char "e_char); void BuildAliasResult (const char *alias_name, Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=131185&r1=131184&r2=131185&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed May 11 11:07:06 2011 @@ -789,7 +789,7 @@ } bool -CommandInterpreter::StripFirstWord (std::string &command_string, std::string &word) +CommandInterpreter::StripFirstWord (std::string &command_string, std::string &word, bool &was_quoted, char "e_char) { std::string white_space (" \t\v"); size_t start; @@ -798,19 +798,48 @@ start = command_string.find_first_not_of (white_space); if (start != std::string::npos) { - end = command_string.find_first_of (white_space, start); - if (end != std::string::npos) - { - word = command_string.substr (start, end - start); - command_string = command_string.substr (end); - size_t pos = command_string.find_first_not_of (white_space); - if ((pos != 0) && (pos != std::string::npos)) - command_string = command_string.substr (pos); + size_t len = command_string.size() - start; + if (len >= 2 + && ((command_string[start] == '\'') || (command_string[start] == '"'))) + { + was_quoted = true; + quote_char = command_string[start]; + std::string quote_string = command_string.substr (start, 1); + start = start + 1; + end = command_string.find (quote_string, start); + if (end != std::string::npos) + { + word = command_string.substr (start, end - start); + if (end + 1 < len) + command_string = command_string.substr (end+1); + else + command_string.erase (); + size_t pos = command_string.find_first_not_of (white_space); + if ((pos != 0) && (pos != std::string::npos)) + command_string = command_string.substr (pos); + } + else + { + word = command_string.substr (start - 1); + command_string.erase (); + } } else { - word = command_string.substr (start); - command_string.erase(); + end = command_string.find_first_of (white_space, start); + if (end != std::string::npos) + { + word = command_string.substr (start, end - start); + command_string = command_string.substr (end); + size_t pos = command_string.find_first_not_of (white_space); + if ((pos != 0) && (pos != std::string::npos)) + command_string = command_string.substr (pos); + } + else + { + word = command_string.substr (start); + command_string.erase(); + } } } @@ -964,7 +993,7 @@ result.SetStatus (eReturnStatusSuccessFinishNoResult); return true; } - + // Phase 1. // Before we do ANY kind of argument processing, etc. we need to figure out what the real/final command object @@ -979,7 +1008,9 @@ size_t actual_cmd_name_len = 0; while (!done) { - StripFirstWord (command_string, next_word); + bool was_quoted = false; + char quote_char = '\0'; + StripFirstWord (command_string, next_word, was_quoted, quote_char); if (!cmd_obj && AliasExists (next_word.c_str())) { std::string alias_result; @@ -1017,13 +1048,29 @@ } else { - revised_command_line.Printf (" %s", next_word.c_str()); + if (was_quoted) + { + if (quote_char == '"') + revised_command_line.Printf (" \"%s\"", next_word.c_str()); + else + revised_command_line.Printf (" '%s'", next_word.c_str()); + } + else + revised_command_line.Printf (" %s", next_word.c_str()); done = true; } } else { - revised_command_line.Printf (" %s", next_word.c_str()); + if (was_quoted) + { + if (quote_char == '"') + revised_command_line.Printf (" \"%s\"", next_word.c_str()); + else + revised_command_line.Printf (" '%s'", next_word.c_str()); + } + else + revised_command_line.Printf (" %s", next_word.c_str()); done = true; } From gclayton at apple.com Wed May 11 13:39:18 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 11 May 2011 18:39:18 -0000 Subject: [Lldb-commits] [lldb] r131193 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ lldb.xcodeproj/xcshareddata/xcschemes/ source/ source/Commands/ source/Core/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/ArchDefaultUnwindPlan/ source/Plugins/ArchVolatileRegs/ source/Plugins/Instruction/ARM/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/Process/Utility/ source/Plugins/Process/g... Message-ID: <20110511183919.02F932A6C12C@llvm.org> Author: gclayton Date: Wed May 11 13:39:18 2011 New Revision: 131193 URL: http://llvm.org/viewvc/llvm-project?rev=131193&view=rev Log: Moved all code from ArchDefaultUnwindPlan and ArchVolatileRegs into their respective ABI plugins as they were plug-ins that supplied ABI specfic info. Also hookep up the UnwindAssemblyInstEmulation so that it can generate the unwind plans for ARM. Changed the way ABI plug-ins are handed out when you get an instance from the plug-in manager. They used to return pointers that would be mananged individually by each client that requested them, but now they are handed out as shared pointers since there is no state in the ABI objects, they can be shared. Added: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h lldb/trunk/source/Plugins/ABI/MacOSX-arm/Makefile Removed: lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Target/ArchVolatileRegs.h lldb/trunk/source/Plugins/ArchDefaultUnwindPlan/ lldb/trunk/source/Plugins/ArchVolatileRegs/ Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Symbol/UnwindPlan.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h lldb/trunk/source/Symbol/FuncUnwinders.cpp lldb/trunk/source/Symbol/UnwindPlan.cpp lldb/trunk/source/Target/ABI.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp lldb/trunk/source/lldb.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Wed May 11 13:39:18 2011 @@ -113,6 +113,9 @@ // Add or subtract a value from the stack eContextAdjustStackPointer, + // Adjust the frame pointer for the current frame + eContextSetFramePointer, + // Add or subtract a value from a base address register (other than SP) eContextAdjustBaseRegister, @@ -234,6 +237,12 @@ } info; + Context () : + type (eContextInvalid), + info_type (eInfoTypeNoArgs) + { + } + void SetRegisterPlusOffset (RegisterInfo base_reg, int64_t signed_offset) @@ -347,7 +356,7 @@ } void - Dump (FILE *fh, + Dump (Stream &s, EmulateInstruction *instruction) const; }; Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Wed May 11 13:39:18 2011 @@ -270,40 +270,6 @@ static UnwindAssemblyCreateInstance GetUnwindAssemblyCreateCallbackForPluginName (const char *name); - //------------------------------------------------------------------ - // ArchDefaultUnwindPlan - //------------------------------------------------------------------ - static bool - RegisterPlugin (const char *name, - const char *description, - ArchDefaultUnwindPlanCreateInstance create_callback); - - static bool - UnregisterPlugin (ArchDefaultUnwindPlanCreateInstance create_callback); - - static ArchDefaultUnwindPlanCreateInstance - GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx); - - static ArchDefaultUnwindPlanCreateInstance - GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name); - - //------------------------------------------------------------------ - // ArchVolatileRegs - //------------------------------------------------------------------ - static bool - RegisterPlugin (const char *name, - const char *description, - ArchVolatileRegsCreateInstance create_callback); - - static bool - UnregisterPlugin (ArchVolatileRegsCreateInstance create_callback); - - static ArchVolatileRegsCreateInstance - GetArchVolatileRegsCreateCallbackAtIndex (uint32_t idx); - - static ArchVolatileRegsCreateInstance - GetArchVolatileRegsCreateCallbackForPluginName (const char *name); - }; Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (original) +++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Wed May 11 13:39:18 2011 @@ -50,8 +50,8 @@ unspecified, // not specified, we may be able to assume this // is the same register. gcc doesn't specify all // initial values so we really don't know... - isUndefined, // reg is not available, e.g. volatile reg - isSame, // reg is unchanged + undefined, // reg is not available, e.g. volatile reg + same, // reg is unchanged atCFAPlusOffset, // reg = deref(CFA + offset) isCFAPlusOffset, // reg = CFA + offset inOtherRegister, // reg = other reg @@ -68,39 +68,129 @@ bool operator == (const RegisterLocation& rhs) const; - void SetUnspecified(); + bool + operator != (const RegisterLocation &rhs) const + { + return !(*this == rhs); + } + + void + SetUnspecified() + { + m_type = unspecified; + } - void SetUndefined(); + void + SetUndefined() + { + m_type = undefined; + } - void SetSame(); + void + SetSame() + { + m_type = same; + } - bool IsSame () const { return m_type == isSame; } + bool + IsSame () const + { + return m_type == same; + } - bool IsUnspecified () const { return m_type == unspecified; } + bool + IsUnspecified () const + { + return m_type == unspecified; + } - bool IsCFAPlusOffset () const { return m_type == isCFAPlusOffset; } + bool + IsCFAPlusOffset () const + { + return m_type == isCFAPlusOffset; + } - bool IsAtCFAPlusOffset () const { return m_type == atCFAPlusOffset; } + bool + IsAtCFAPlusOffset () const + { + return m_type == atCFAPlusOffset; + } - bool IsInOtherRegister () const { return m_type == inOtherRegister; } + bool + IsInOtherRegister () const + { + return m_type == inOtherRegister; + } - bool IsAtDWARFExpression () const { return m_type == atDWARFExpression; } + bool + IsAtDWARFExpression () const + { + return m_type == atDWARFExpression; + } - bool IsDWARFExpression () const { return m_type == isDWARFExpression; } + bool + IsDWARFExpression () const + { + return m_type == isDWARFExpression; + } - void SetAtCFAPlusOffset (int32_t offset); + void + SetAtCFAPlusOffset (int32_t offset) + { + m_type = atCFAPlusOffset; + m_location.offset = offset; + } - void SetIsCFAPlusOffset (int32_t offset); + void + SetIsCFAPlusOffset (int32_t offset) + { + m_type = isCFAPlusOffset; + m_location.offset = offset; + } - void SetInRegister (uint32_t reg_num); + void + SetInRegister (uint32_t reg_num) + { + m_type = inOtherRegister; + m_location.reg_num = reg_num; + } - uint32_t GetRegisterNumber () const { return m_location.reg_num; } + uint32_t + GetRegisterNumber () const + { + if (m_type == inOtherRegister) + return m_location.reg_num; + return LLDB_INVALID_REGNUM; + } - RestoreType GetLocationType () const { return m_type; } + RestoreType + GetLocationType () const + { + return m_type; + } - int32_t GetOffset () const { return m_location.offset; } + int32_t + GetOffset () const + { + if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset) + return m_location.offset; + return 0; + } - void GetDWARFExpr (const uint8_t **opcodes, uint16_t& len) const { *opcodes = m_location.expr.opcodes; len = m_location.expr.length; } + void + GetDWARFExpr (const uint8_t **opcodes, uint16_t& len) const + { + if (m_type == atDWARFExpression || m_type == isDWARFExpression) + { + *opcodes = m_location.expr.opcodes; + len = m_location.expr.length; + } + else + { + *opcodes = NULL; + len = 0; + } + } void SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len); @@ -109,13 +199,27 @@ SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len); const uint8_t * - GetDWARFExpressionBytes () { return m_location.expr.opcodes; } + GetDWARFExpressionBytes () + { + if (m_type == atDWARFExpression || m_type == isDWARFExpression) + return m_location.expr.opcodes; + return NULL; + } int - GetDWARFExpressionLength () { return m_location.expr.length; } + GetDWARFExpressionLength () + { + if (m_type == atDWARFExpression || m_type == isDWARFExpression) + return m_location.expr.length; + return 0; + } void - Dump (Stream &s) const; + Dump (Stream &s, + const UnwindPlan* unwind_plan, + const UnwindPlan::Row* row, + Thread* thread, + bool verbose) const; private: RestoreType m_type; // How do we locate this register? @@ -165,12 +269,39 @@ { return m_cfa_reg_num; } + + bool + SetRegisterLocationToAtCFAPlusOffset (uint32_t reg_num, + int32_t offset, + bool can_replace); + + bool + SetRegisterLocationToIsCFAPlusOffset (uint32_t reg_num, + int32_t offset, + bool can_replace); + + bool + SetRegisterLocationToUndefined (uint32_t reg_num, + bool can_replace, + bool can_replace_only_if_unspecified); + + bool + SetRegisterLocationToUnspecified (uint32_t reg_num, + bool can_replace); + + bool + SetRegisterLocationToRegister (uint32_t reg_num, + uint32_t other_reg_num, + bool can_replace); + + bool + SetRegisterLocationToSame (uint32_t reg_num, + bool must_replace); + + void - SetCFARegister (uint32_t reg_num) - { - m_cfa_reg_num = reg_num; - } + SetCFARegister (uint32_t reg_num); int32_t GetCFAOffset () const @@ -195,7 +326,28 @@ Clear (); void - Dump (Stream& s, int register_kind, Thread* thread) const; + Dump (Stream& s, const UnwindPlan* unwind_plan, Thread* thread, lldb::addr_t base_addr) const; + + bool + operator == (const Row &rhs) const + { + if (m_offset == rhs.m_offset && + m_cfa_reg_num != rhs.m_cfa_reg_num && + m_cfa_offset != rhs.m_cfa_offset) + return m_register_locations == rhs.m_register_locations; + return false; + } + + bool + operator != (const Row &rhs) const + { + if (m_offset != rhs.m_offset || + m_cfa_reg_num != rhs.m_cfa_reg_num || + m_cfa_offset != rhs.m_cfa_offset) + return true; + + return m_register_locations != rhs.m_register_locations; + } protected: typedef std::map collection; @@ -208,10 +360,10 @@ public: - UnwindPlan () : + UnwindPlan (uint32_t reg_kind) : m_row_list (), m_plan_valid_address_range (), - m_register_kind (UINT32_MAX), + m_register_kind (reg_kind), m_source_name () { } @@ -221,7 +373,7 @@ } void - Dump (Stream& s, Thread* thread) const; + Dump (Stream& s, Thread* thread, lldb::addr_t base_addr) const; void AppendRow (const Row& row); @@ -233,11 +385,25 @@ const Row* GetRowForFunctionOffset (int offset) const; - void - SetRegisterKind (uint32_t rk); + uint32_t + GetRegisterKind () const + { + return m_register_kind; + } + void + SetRegisterKind (uint32_t kind) + { + m_register_kind = kind; + } + uint32_t - GetRegisterKind (void) const; + GetInitialCFARegister () const + { + if (m_row_list.empty()) + return LLDB_INVALID_REGNUM; + return m_row_list.front().GetCFARegister(); + } // This UnwindPlan may not be valid at every address of the function span. // For instance, a FastUnwindPlan will not be valid at the prologue setup @@ -245,6 +411,12 @@ void SetPlanValidAddressRange (const AddressRange& range); + const AddressRange & + GetAddressRange () const + { + return m_plan_valid_address_range; + } + bool PlanValidAtAddress (Address addr); @@ -254,6 +426,9 @@ const UnwindPlan::Row& GetRowAtIndex (uint32_t idx) const; + const UnwindPlan::Row& + GetLastRow () const; + lldb_private::ConstString GetSourceName () const; @@ -268,12 +443,16 @@ { m_row_list.clear(); m_plan_valid_address_range.Clear(); - m_register_kind = UINT32_MAX; + m_register_kind = lldb::eRegisterKindDWARF; m_source_name.Clear(); } + const RegisterInfo * + GetRegisterInfo (Thread* thread, uint32_t reg_num) const; + private: + typedef std::vector collection; collection m_row_list; AddressRange m_plan_valid_address_range; Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Wed May 11 13:39:18 2011 @@ -45,9 +45,19 @@ virtual bool GetReturnValue (Thread &thread, Value &value) const = 0; - - static ABI* + + virtual bool + CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0; + + virtual bool + CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0; + + virtual bool + RegisterIsVolatile (const RegisterInfo *reg_info) = 0; + + static lldb::ABISP FindPlugin (const ArchSpec &arch); + protected: //------------------------------------------------------------------ // Classes that inherit from ABI can see and modify these Removed: lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h?rev=131192&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Target/ArchDefaultUnwindPlan.h (removed) @@ -1,43 +0,0 @@ -//===-- ArchDefaultUnwindPlan.h ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_ArchDefaultUnwindPlan_h_ -#define utility_ArchDefaultUnwindPlan_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class ArchDefaultUnwindPlan : - public PluginInterface -{ -public: - - virtual - ~ArchDefaultUnwindPlan(); - - virtual lldb::UnwindPlanSP - GetArchDefaultUnwindPlan (Thread& thread, - const Address ¤t_pc) = 0; - - static lldb::ArchDefaultUnwindPlanSP - FindPlugin (const ArchSpec &arch); - -protected: - ArchDefaultUnwindPlan(); -private: - DISALLOW_COPY_AND_ASSIGN (ArchDefaultUnwindPlan); -}; - -} // namespace lldb_private - -#endif //utility_ArchDefaultUnwindPlan_h_ - - Removed: lldb/trunk/include/lldb/Target/ArchVolatileRegs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ArchVolatileRegs.h?rev=131192&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ArchVolatileRegs.h (original) +++ lldb/trunk/include/lldb/Target/ArchVolatileRegs.h (removed) @@ -1,53 +0,0 @@ -//===-- ArchVolatileRegs.h --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_ArchVolatileRegs_h_ -#define utility_ArchVolatileRegs_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/PluginInterface.h" - -namespace lldb_private { - -class ArchVolatileRegs : - public PluginInterface -{ -public: - - virtual - ~ArchVolatileRegs(); - - // Given a register number (in the eRegisterKindLLDB register numbering - // scheme), returns true if the register is defined to be "volatile" in - // this architecture -- that is, a function is not required to preserve - // the contents of the register. - // If r8 is defined to be volatile, it means that a function can put - // values in that register without saving the previous contents. - // If r8 is defined to be non-volatile (preseved), a function must save - // the value in the register before it is used. - - // The thread reference is needed to get a RegisterContext to look up by - // register names. - - virtual bool - RegisterIsVolatile (lldb_private::Thread& thread, uint32_t regnum) = 0; - - static ArchVolatileRegs* - FindPlugin (const ArchSpec &arch); - -protected: - ArchVolatileRegs(); -private: - DISALLOW_COPY_AND_ASSIGN (ArchVolatileRegs); -}; - -} // namespace lldb_private - -#endif //utility_ArchVolatileRegs_h_ - Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed May 11 13:39:18 2011 @@ -2457,7 +2457,7 @@ ShouldBroadcastEvent (Event *event_ptr); public: - const ABI * + const lldb::ABISP & GetABI (); DynamicLoader * Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Wed May 11 13:39:18 2011 @@ -21,7 +21,6 @@ typedef SharedPtr::Type ABISP; typedef SharedPtr::Type AddressResolverSP; - typedef SharedPtr::Type ArchDefaultUnwindPlanSP; typedef SharedPtr::Type BatonSP; typedef SharedPtr::Type BlockSP; typedef SharedPtr::Type BreakpointSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Wed May 11 13:39:18 2011 @@ -22,8 +22,6 @@ class AddressRange; class AddressResolver; class ArchSpec; -class ArchDefaultUnwindPlan; -class ArchVolatileRegs; class Args; class Baton; class Block; Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Wed May 11 13:39:18 2011 @@ -16,7 +16,7 @@ namespace lldb_private { - typedef ABI* (*ABICreateInstance) (const ArchSpec &arch); + typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch); typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch); typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process, bool force); typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length); @@ -32,8 +32,6 @@ typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id, uint32_t type); typedef ThreadPlan * (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, void *baton); typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch); - typedef ArchDefaultUnwindPlan* (*ArchDefaultUnwindPlanCreateInstance) (const ArchSpec &arch); - typedef ArchVolatileRegs* (*ArchVolatileRegsCreateInstance) (const ArchSpec &arch); typedef int (*ComparisonFunction)(const void *, const void *); } // namespace lldb_private Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed May 11 13:39:18 2011 @@ -13,8 +13,6 @@ 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; - 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */; }; - 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; }; @@ -214,8 +212,6 @@ 2689008713353E2200698AC0 /* ScriptInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */; }; 2689008813353E2200698AC0 /* ScriptInterpreterNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */; }; 2689008913353E2200698AC0 /* ScriptInterpreterPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0C10F1B8DD00F91463 /* ScriptInterpreterPython.cpp */; }; - 2689008A13353E4200698AC0 /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */; }; - 2689008B13353E4200698AC0 /* ABISysV_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 493C63F11189203300914D5E /* ABISysV_x86_64.cpp */; }; 2689008C13353E4200698AC0 /* DisassemblerLLVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C897410F57C5600BB2B04 /* DisassemblerLLVM.cpp */; }; 2689008D13353E4200698AC0 /* DynamicLoaderMacOSXDYLD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */; }; 2689008E13353E4200698AC0 /* DynamicLoaderStatic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268A683D1321B53B000E3FB8 /* DynamicLoaderStatic.cpp */; }; @@ -370,10 +366,9 @@ 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */; }; - 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */; }; - 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; 2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2697A54C133A6305004E4240 /* PlatformDarwin.h */; }; + 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; }; 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; 26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; @@ -386,13 +381,15 @@ 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */; }; 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; - 26C6886F137880C400407EDF /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A14133BEC76005B64B7 /* lldb-public.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; }; 26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */; }; + 26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E071379E7AD0080DC73 /* ABIMacOSX_arm.cpp */; }; + 26DB3E1C1379E7AD0080DC73 /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E0F1379E7AD0080DC73 /* ABIMacOSX_i386.cpp */; }; + 26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E131379E7AD0080DC73 /* ABISysV_x86_64.cpp */; }; 26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; }; 26DC6A1D1337FECA00FF7998 /* lldb-platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */; }; 26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -650,10 +647,6 @@ 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = ""; }; 26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; }; 26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; }; - 2630BFAB1365F3140070C534 /* ArchDefaultUnwindPlan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchDefaultUnwindPlan.h; path = include/lldb/Target/ArchDefaultUnwindPlan.h; sourceTree = ""; }; - 2630BFAC1365F3140070C534 /* ArchVolatileRegs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArchVolatileRegs.h; path = include/lldb/Target/ArchVolatileRegs.h; sourceTree = ""; }; - 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Target/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; - 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchVolatileRegs.cpp; path = source/Target/ArchVolatileRegs.cpp; sourceTree = ""; }; 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; }; 26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = ""; }; @@ -734,10 +727,6 @@ 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyInstEmulation.cpp; sourceTree = ""; }; 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; - 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; - 2692BA1E136614D000F9E14D /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; - 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; - 2692BA22136614FC00F9E14D /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchVolatileRegs-x86.h"; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; 269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = ""; }; 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformDarwin.cpp; sourceTree = ""; }; @@ -1036,6 +1025,12 @@ 26D9FDC612F784E60003F2EE /* EmulateInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulateInstruction.h; path = include/lldb/Core/EmulateInstruction.h; sourceTree = ""; }; 26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstruction.cpp; path = source/Core/EmulateInstruction.cpp; sourceTree = ""; }; 26DAFD9711529BC7005A394E /* ExecutionContextScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContextScope.h; path = include/lldb/Target/ExecutionContextScope.h; sourceTree = ""; }; + 26DB3E071379E7AD0080DC73 /* ABIMacOSX_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ABIMacOSX_arm.cpp; sourceTree = ""; }; + 26DB3E081379E7AD0080DC73 /* ABIMacOSX_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ABIMacOSX_arm.h; sourceTree = ""; }; + 26DB3E0F1379E7AD0080DC73 /* ABIMacOSX_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ABIMacOSX_i386.cpp; sourceTree = ""; }; + 26DB3E101379E7AD0080DC73 /* ABIMacOSX_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ABIMacOSX_i386.h; sourceTree = ""; }; + 26DB3E131379E7AD0080DC73 /* ABISysV_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ABISysV_x86_64.cpp; sourceTree = ""; }; + 26DB3E141379E7AD0080DC73 /* ABISysV_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ABISysV_x86_64.h; sourceTree = ""; }; 26DC6A101337FE6900FF7998 /* lldb-platform */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-platform"; sourceTree = BUILT_PRODUCTS_DIR; }; 26DC6A1C1337FECA00FF7998 /* lldb-platform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-platform.cpp"; path = "tools/lldb-platform/lldb-platform.cpp"; sourceTree = ""; }; 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-forward-rtti.h"; path = "include/lldb/lldb-forward-rtti.h"; sourceTree = ""; }; @@ -1091,15 +1086,11 @@ 491193501226386000578B7F /* ASTStructExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTStructExtractor.cpp; path = source/Expression/ASTStructExtractor.cpp; sourceTree = ""; }; 49307AAD11DEA4D90081F992 /* IRForTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRForTarget.cpp; path = source/Expression/IRForTarget.cpp; sourceTree = ""; }; 49307AB111DEA4F20081F992 /* IRForTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRForTarget.h; path = include/lldb/Expression/IRForTarget.h; sourceTree = ""; }; - 493C63F01189203300914D5E /* ABISysV_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABISysV_x86_64.h; path = "ABI/SysV-x86_64/ABISysV_x86_64.h"; sourceTree = ""; }; - 493C63F11189203300914D5E /* ABISysV_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABISysV_x86_64.cpp; path = "ABI/SysV-x86_64/ABISysV_x86_64.cpp"; sourceTree = ""; }; 49445C2512245E3600C11A81 /* ClangExpressionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionParser.cpp; path = source/Expression/ClangExpressionParser.cpp; sourceTree = ""; }; 49445C2912245E5500C11A81 /* ClangExpressionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionParser.h; path = include/lldb/Expression/ClangExpressionParser.h; sourceTree = ""; }; 49445E341225AB6A00C11A81 /* ClangUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangUserExpression.h; path = include/lldb/Expression/ClangUserExpression.h; sourceTree = ""; }; 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PathMappingList.cpp; path = source/Target/PathMappingList.cpp; sourceTree = ""; }; 495BBACF119A0DE700418BEA /* PathMappingList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PathMappingList.h; path = include/lldb/Target/PathMappingList.h; sourceTree = ""; }; - 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABIMacOSX_i386.cpp; path = "ABI/MacOSX-i386/ABIMacOSX_i386.cpp"; sourceTree = ""; }; - 497650CF11A21BEE008DDB57 /* ABIMacOSX_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABIMacOSX_i386.h; path = "ABI/MacOSX-i386/ABIMacOSX_i386.h"; sourceTree = ""; }; 497C86BD122823D800B54702 /* ClangUtilityFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUtilityFunction.cpp; path = source/Expression/ClangUtilityFunction.cpp; sourceTree = ""; }; 497C86C1122823F300B54702 /* ClangUtilityFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangUtilityFunction.h; path = include/lldb/Expression/ClangUtilityFunction.h; sourceTree = ""; }; 497E7B331188ED300065CCA1 /* ABI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ABI.h; path = include/lldb/Target/ABI.h; sourceTree = ""; }; @@ -1376,9 +1367,7 @@ 260C897110F57C5600BB2B04 /* Plugins */ = { isa = PBXGroup; children = ( - 26AC3F481365F4620065C7EF /* ArchDefaultUnwindPlan */, - 26AC3F4C1365F5260065C7EF /* ArchVolatileRegs */, - 493C63D711891A8000914D5E /* ABI */, + 26DB3E051379E7AD0080DC73 /* ABI */, 260C897210F57C5600BB2B04 /* Disassembler */, 260C897810F57C5600BB2B04 /* DynamicLoader */, 26D9FDCA12F785120003F2EE /* Instruction */, @@ -1828,24 +1817,6 @@ path = x86; sourceTree = ""; }; - 2692BA1C136614D000F9E14D /* x86 */ = { - isa = PBXGroup; - children = ( - 2692BA1D136614D000F9E14D /* ArchDefaultUnwindPlan-x86.cpp */, - 2692BA1E136614D000F9E14D /* ArchDefaultUnwindPlan-x86.h */, - ); - path = x86; - sourceTree = ""; - }; - 2692BA20136614FC00F9E14D /* x86 */ = { - isa = PBXGroup; - children = ( - 2692BA21136614FC00F9E14D /* ArchVolatileRegs-x86.cpp */, - 2692BA22136614FC00F9E14D /* ArchVolatileRegs-x86.h */, - ); - path = x86; - sourceTree = ""; - }; 26A3B4AB1181454800381BC2 /* BSD-Archive */ = { isa = PBXGroup; children = ( @@ -1864,22 +1835,6 @@ path = UnwindAssembly; sourceTree = ""; }; - 26AC3F481365F4620065C7EF /* ArchDefaultUnwindPlan */ = { - isa = PBXGroup; - children = ( - 2692BA1C136614D000F9E14D /* x86 */, - ); - path = ArchDefaultUnwindPlan; - sourceTree = ""; - }; - 26AC3F4C1365F5260065C7EF /* ArchVolatileRegs */ = { - isa = PBXGroup; - children = ( - 2692BA20136614FC00F9E14D /* x86 */, - ); - path = ArchVolatileRegs; - sourceTree = ""; - }; 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( @@ -2308,10 +2263,6 @@ children = ( 497E7B331188ED300065CCA1 /* ABI.h */, 497E7B9D1188F6690065CCA1 /* ABI.cpp */, - 2630BFAB1365F3140070C534 /* ArchDefaultUnwindPlan.h */, - 2630BFAD1365F3220070C534 /* ArchDefaultUnwindPlan.cpp */, - 2630BFAC1365F3140070C534 /* ArchVolatileRegs.h */, - 2630BFAE1365F3220070C534 /* ArchVolatileRegs.cpp */, 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */, 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */, 26BC7DF110F1B81A00F91463 /* DynamicLoader.h */, @@ -2455,6 +2406,43 @@ path = ARM; sourceTree = ""; }; + 26DB3E051379E7AD0080DC73 /* ABI */ = { + isa = PBXGroup; + children = ( + 26DB3E061379E7AD0080DC73 /* MacOSX-arm */, + 26DB3E0E1379E7AD0080DC73 /* MacOSX-i386 */, + 26DB3E121379E7AD0080DC73 /* SysV-x86_64 */, + ); + path = ABI; + sourceTree = ""; + }; + 26DB3E061379E7AD0080DC73 /* MacOSX-arm */ = { + isa = PBXGroup; + children = ( + 26DB3E071379E7AD0080DC73 /* ABIMacOSX_arm.cpp */, + 26DB3E081379E7AD0080DC73 /* ABIMacOSX_arm.h */, + ); + path = "MacOSX-arm"; + sourceTree = ""; + }; + 26DB3E0E1379E7AD0080DC73 /* MacOSX-i386 */ = { + isa = PBXGroup; + children = ( + 26DB3E0F1379E7AD0080DC73 /* ABIMacOSX_i386.cpp */, + 26DB3E101379E7AD0080DC73 /* ABIMacOSX_i386.h */, + ); + path = "MacOSX-i386"; + sourceTree = ""; + }; + 26DB3E121379E7AD0080DC73 /* SysV-x86_64 */ = { + isa = PBXGroup; + children = ( + 26DB3E131379E7AD0080DC73 /* ABISysV_x86_64.cpp */, + 26DB3E141379E7AD0080DC73 /* ABISysV_x86_64.h */, + ); + path = "SysV-x86_64"; + sourceTree = ""; + }; 26DC6A1B1337FEA400FF7998 /* lldb-platform */ = { isa = PBXGroup; children = ( @@ -2503,33 +2491,6 @@ sourceTree = ""; usesTabs = 0; }; - 493C63D711891A8000914D5E /* ABI */ = { - isa = PBXGroup; - children = ( - 497650CD11A21BD8008DDB57 /* MacOSX-i386 */, - 493C63EA11891FCD00914D5E /* SysV-x86_64 */, - ); - name = ABI; - sourceTree = ""; - }; - 493C63EA11891FCD00914D5E /* SysV-x86_64 */ = { - isa = PBXGroup; - children = ( - 493C63F11189203300914D5E /* ABISysV_x86_64.cpp */, - 493C63F01189203300914D5E /* ABISysV_x86_64.h */, - ); - name = "SysV-x86_64"; - sourceTree = ""; - }; - 497650CD11A21BD8008DDB57 /* MacOSX-i386 */ = { - isa = PBXGroup; - children = ( - 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */, - 497650CF11A21BEE008DDB57 /* ABIMacOSX_i386.h */, - ); - name = "MacOSX-i386"; - sourceTree = ""; - }; 4C139EA0124A8AC7000BFF8D /* CPlusPlus */ = { isa = PBXGroup; children = ( @@ -3125,8 +3086,6 @@ 2689008713353E2200698AC0 /* ScriptInterpreter.cpp in Sources */, 2689008813353E2200698AC0 /* ScriptInterpreterNone.cpp in Sources */, 2689008913353E2200698AC0 /* ScriptInterpreterPython.cpp in Sources */, - 2689008A13353E4200698AC0 /* ABIMacOSX_i386.cpp in Sources */, - 2689008B13353E4200698AC0 /* ABISysV_x86_64.cpp in Sources */, 2689008C13353E4200698AC0 /* DisassemblerLLVM.cpp in Sources */, 2689008D13353E4200698AC0 /* DynamicLoaderMacOSXDYLD.cpp in Sources */, 2689008E13353E4200698AC0 /* DynamicLoaderStatic.cpp in Sources */, @@ -3273,11 +3232,7 @@ 9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */, 9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */, 9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */, - 2630BFAF1365F3220070C534 /* ArchDefaultUnwindPlan.cpp in Sources */, - 2630BFB01365F3220070C534 /* ArchVolatileRegs.cpp in Sources */, 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */, - 2692BA1F136614D800F9E14D /* ArchDefaultUnwindPlan-x86.cpp in Sources */, - 2692BA231366150100F9E14D /* ArchVolatileRegs-x86.cpp in Sources */, 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */, 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */, 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */, @@ -3288,7 +3243,10 @@ 260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */, 2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */, 268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */, - 26C6886F137880C400407EDF /* RegisterValue.cpp in Sources */, + 26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */, + 26DB3E1C1379E7AD0080DC73 /* ABIMacOSX_i386.cpp in Sources */, + 26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */, + 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3488,8 +3446,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", @@ -3539,8 +3495,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", @@ -3582,8 +3536,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; OTHER_CFLAGS = "-Wparentheses"; @@ -3624,8 +3576,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; OTHER_CFLAGS = "-Wparentheses"; @@ -3868,7 +3818,6 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = dwarf; @@ -3901,7 +3850,6 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 46; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed May 11 13:39:18 2011 @@ -75,7 +75,8 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" - useCustomWorkingDirectory = "NO" + useCustomWorkingDirectory = "YES" + customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "YES"> Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Wed May 11 13:39:18 2011 @@ -113,7 +113,7 @@ return false; } - const ABI *abi = process->GetABI (); + const ABI *abi = process->GetABI().get(); if (!abi) { result.AppendError ("The current process has no ABI."); Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Wed May 11 13:39:18 2011 @@ -372,8 +372,10 @@ void *dst, size_t length) { - fprintf (stdout, " Read from Memory (address = 0x%llx, length = %zu, context = ", addr, length); - context.Dump (stdout, instruction); + StreamFile strm (stdout, false); + strm.Printf (" Read from Memory (address = 0x%llx, length = %zu, context = ", addr, length); + context.Dump (strm, instruction); + strm.EOL(); *((uint64_t *) dst) = 0xdeadbeef; return length; } @@ -386,8 +388,10 @@ const void *dst, size_t length) { - fprintf (stdout, " Write to Memory (address = 0x%llx, length = %zu, context = ", addr, length); - context.Dump (stdout, instruction); + StreamFile strm (stdout, false); + strm.Printf (" Write to Memory (address = 0x%llx, length = %zu, context = ", addr, length); + context.Dump (strm, instruction); + strm.EOL(); return length; } @@ -397,7 +401,8 @@ const RegisterInfo *reg_info, RegisterValue ®_value) { - fprintf (stdout, " Read Register (%s)\n", reg_info->name); + StreamFile strm (stdout, false); + strm.Printf (" Read Register (%s)\n", reg_info->name); uint32_t reg_kind, reg_num; if (GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num)) reg_value.SetUInt64((uint64_t)reg_kind << 24 | reg_num); @@ -418,86 +423,87 @@ strm.Printf (" Write to Register (name = %s, value = " , reg_info->name); reg_value.Dump(&strm, reg_info, false); strm.PutCString (", context = "); - context.Dump (stdout, instruction); + context.Dump (strm, instruction); + strm.EOL(); return true; } void -EmulateInstruction::Context::Dump (FILE *fh, +EmulateInstruction::Context::Dump (Stream &strm, EmulateInstruction *instruction) const { switch (type) { case eContextReadOpcode: - fprintf (fh, "reading opcode"); + strm.PutCString ("reading opcode"); break; case eContextImmediate: - fprintf (fh, "immediate"); + strm.PutCString ("immediate"); break; case eContextPushRegisterOnStack: - fprintf (fh, "push register"); + strm.PutCString ("push register"); break; case eContextPopRegisterOffStack: - fprintf (fh, "pop register"); + strm.PutCString ("pop register"); break; case eContextAdjustStackPointer: - fprintf (fh, "adjust sp"); + strm.PutCString ("adjust sp"); break; case eContextAdjustBaseRegister: - fprintf (fh, "adjusting (writing value back to) a base register"); + strm.PutCString ("adjusting (writing value back to) a base register"); break; case eContextRegisterPlusOffset: - fprintf (fh, "register + offset"); + strm.PutCString ("register + offset"); break; case eContextRegisterStore: - fprintf (fh, "store register"); + strm.PutCString ("store register"); break; case eContextRegisterLoad: - fprintf (fh, "load register"); + strm.PutCString ("load register"); break; case eContextRelativeBranchImmediate: - fprintf (fh, "relative branch immediate"); + strm.PutCString ("relative branch immediate"); break; case eContextAbsoluteBranchRegister: - fprintf (fh, "absolute branch register"); + strm.PutCString ("absolute branch register"); break; case eContextSupervisorCall: - fprintf (fh, "supervisor call"); + strm.PutCString ("supervisor call"); break; case eContextTableBranchReadMemory: - fprintf (fh, "table branch read memory"); + strm.PutCString ("table branch read memory"); break; case eContextWriteRegisterRandomBits: - fprintf (fh, "write random bits to a register"); + strm.PutCString ("write random bits to a register"); break; case eContextWriteMemoryRandomBits: - fprintf (fh, "write random bits to a memory address"); + strm.PutCString ("write random bits to a memory address"); break; case eContextArithmetic: - fprintf (fh, "arithmetic"); + strm.PutCString ("arithmetic"); break; case eContextReturnFromException: - fprintf (fh, "return from exception"); + strm.PutCString ("return from exception"); break; default: - fprintf (fh, "unrecognized context."); + strm.PutCString ("unrecognized context."); break; } @@ -505,99 +511,93 @@ { case eInfoTypeRegisterPlusOffset: { - fprintf (fh, - " (reg_plus_offset = %s%+lld)\n", - info.RegisterPlusOffset.reg.name, - info.RegisterPlusOffset.signed_offset); + strm.Printf (" (reg_plus_offset = %s%+lld)", + info.RegisterPlusOffset.reg.name, + info.RegisterPlusOffset.signed_offset); } break; case eInfoTypeRegisterPlusIndirectOffset: { - fprintf (fh, " (reg_plus_reg = %s + %s)\n", - info.RegisterPlusIndirectOffset.base_reg.name, - info.RegisterPlusIndirectOffset.offset_reg.name); + strm.Printf (" (reg_plus_reg = %s + %s)", + info.RegisterPlusIndirectOffset.base_reg.name, + info.RegisterPlusIndirectOffset.offset_reg.name); } break; case eInfoTypeRegisterToRegisterPlusOffset: { - fprintf (fh, " (base_and_imm_offset = %s%+lld, data_reg = %s)\n", - info.RegisterToRegisterPlusOffset.base_reg.name, - info.RegisterToRegisterPlusOffset.offset, - info.RegisterToRegisterPlusOffset.data_reg.name); + strm.Printf (" (base_and_imm_offset = %s%+lld, data_reg = %s)", + info.RegisterToRegisterPlusOffset.base_reg.name, + info.RegisterToRegisterPlusOffset.offset, + info.RegisterToRegisterPlusOffset.data_reg.name); } break; case eInfoTypeRegisterToRegisterPlusIndirectOffset: { - fprintf (fh, " (base_and_reg_offset = %s + %s, data_reg = %s)\n", - info.RegisterToRegisterPlusIndirectOffset.base_reg.name, - info.RegisterToRegisterPlusIndirectOffset.offset_reg.name, - info.RegisterToRegisterPlusIndirectOffset.data_reg.name); + strm.Printf (" (base_and_reg_offset = %s + %s, data_reg = %s)", + info.RegisterToRegisterPlusIndirectOffset.base_reg.name, + info.RegisterToRegisterPlusIndirectOffset.offset_reg.name, + info.RegisterToRegisterPlusIndirectOffset.data_reg.name); } break; case eInfoTypeRegisterRegisterOperands: { - fprintf (fh, " (register to register binary op: %s and %s)\n", - info.RegisterRegisterOperands.operand1.name, - info.RegisterRegisterOperands.operand2.name); + strm.Printf (" (register to register binary op: %s and %s)", + info.RegisterRegisterOperands.operand1.name, + info.RegisterRegisterOperands.operand2.name); } break; case eInfoTypeOffset: - fprintf (fh, " (signed_offset = %+lld)\n", info.signed_offset); + strm.Printf (" (signed_offset = %+lld)", info.signed_offset); break; case eInfoTypeRegister: - fprintf (fh, " (reg = %s)\n", info.reg.name); + strm.Printf (" (reg = %s)", info.reg.name); break; case eInfoTypeImmediate: - fprintf (fh, - " (unsigned_immediate = %llu (0x%16.16llx))\n", - info.unsigned_immediate, - info.unsigned_immediate); + strm.Printf (" (unsigned_immediate = %llu (0x%16.16llx))", + info.unsigned_immediate, + info.unsigned_immediate); break; case eInfoTypeImmediateSigned: - fprintf (fh, - " (signed_immediate = %+lld (0x%16.16llx))\n", - info.signed_immediate, - info.signed_immediate); + strm.Printf (" (signed_immediate = %+lld (0x%16.16llx))", + info.signed_immediate, + info.signed_immediate); break; case eInfoTypeAddress: - fprintf (fh, " (address = 0x%llx)\n", info.address); + strm.Printf (" (address = 0x%llx)", info.address); break; case eInfoTypeISAAndImmediate: - fprintf (fh, - " (isa = %u, unsigned_immediate = %u (0x%8.8x))\n", - info.ISAAndImmediate.isa, - info.ISAAndImmediate.unsigned_data32, - info.ISAAndImmediate.unsigned_data32); + strm.Printf (" (isa = %u, unsigned_immediate = %u (0x%8.8x))", + info.ISAAndImmediate.isa, + info.ISAAndImmediate.unsigned_data32, + info.ISAAndImmediate.unsigned_data32); break; case eInfoTypeISAAndImmediateSigned: - fprintf (fh, - " (isa = %u, signed_immediate = %i (0x%8.8x))\n", - info.ISAAndImmediateSigned.isa, - info.ISAAndImmediateSigned.signed_data32, - info.ISAAndImmediateSigned.signed_data32); + strm.Printf (" (isa = %u, signed_immediate = %i (0x%8.8x))", + info.ISAAndImmediateSigned.isa, + info.ISAAndImmediateSigned.signed_data32, + info.ISAAndImmediateSigned.signed_data32); break; case eInfoTypeISA: - fprintf (fh, " (isa = %u)\n", info.isa); + strm.Printf (" (isa = %u)", info.isa); break; case eInfoTypeNoArgs: - fprintf (fh, " \n"); break; default: - fprintf (fh, " (unknown )\n"); + strm.Printf (" (unknown )"); break; } } Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Wed May 11 13:39:18 2011 @@ -1663,213 +1663,3 @@ return NULL; } -#pragma mark ArchDefaultUnwindPlan - -struct ArchDefaultUnwindPlanInstance -{ - ArchDefaultUnwindPlanInstance() : - name(), - description(), - create_callback(NULL) - { - } - - std::string name; - std::string description; - ArchDefaultUnwindPlanCreateInstance create_callback; -}; - -typedef std::vector ArchDefaultUnwindPlanInstances; - -static Mutex & -GetArchDefaultUnwindPlanMutex () -{ - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); - return g_instances_mutex; -} - -static ArchDefaultUnwindPlanInstances & -GetArchDefaultUnwindPlanInstances () -{ - static ArchDefaultUnwindPlanInstances g_instances; - return g_instances; -} - - -bool -PluginManager::RegisterPlugin -( - const char *name, - const char *description, - ArchDefaultUnwindPlanCreateInstance create_callback -) -{ - if (create_callback) - { - ArchDefaultUnwindPlanInstance instance; - assert (name && name[0]); - instance.name = name; - if (description && description[0]) - instance.description = description; - instance.create_callback = create_callback; - Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); - GetArchDefaultUnwindPlanInstances ().push_back (instance); - } - return false; -} - -bool -PluginManager::UnregisterPlugin (ArchDefaultUnwindPlanCreateInstance create_callback) -{ - if (create_callback) - { - Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); - ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); - - ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == create_callback) - { - instances.erase(pos); - return true; - } - } - } - return false; -} - -ArchDefaultUnwindPlanCreateInstance -PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx) -{ - Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); - ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); - if (idx < instances.size()) - return instances[idx].create_callback; - return NULL; -} - - -ArchDefaultUnwindPlanCreateInstance -PluginManager::GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name) -{ - if (name && name[0]) - { - llvm::StringRef name_sref(name); - Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); - ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); - - ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++ pos) - { - if (name_sref.equals (pos->name)) - return pos->create_callback; - } - } - return NULL; -} - -#pragma mark ArchVolatileRegs - -struct ArchVolatileRegsInstance -{ - ArchVolatileRegsInstance() : - name(), - description(), - create_callback(NULL) - { - } - - std::string name; - std::string description; - ArchVolatileRegsCreateInstance create_callback; -}; - -typedef std::vector ArchVolatileRegsInstances; - -static Mutex & -GetArchVolatileRegsMutex () -{ - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); - return g_instances_mutex; -} - -static ArchVolatileRegsInstances & -GetArchVolatileRegsInstances () -{ - static ArchVolatileRegsInstances g_instances; - return g_instances; -} - -bool -PluginManager::RegisterPlugin -( - const char *name, - const char *description, - ArchVolatileRegsCreateInstance create_callback -) -{ - if (create_callback) - { - ArchVolatileRegsInstance instance; - assert (name && name[0]); - instance.name = name; - if (description && description[0]) - instance.description = description; - instance.create_callback = create_callback; - Mutex::Locker locker (GetArchVolatileRegsMutex ()); - GetArchVolatileRegsInstances ().push_back (instance); - } - return false; -} - -bool -PluginManager::UnregisterPlugin (ArchVolatileRegsCreateInstance create_callback) -{ - if (create_callback) - { - Mutex::Locker locker (GetArchVolatileRegsMutex ()); - ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); - - ArchVolatileRegsInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == create_callback) - { - instances.erase(pos); - return true; - } - } - } - return false; -} - -ArchVolatileRegsCreateInstance -PluginManager::GetArchVolatileRegsCreateCallbackAtIndex (uint32_t idx) -{ - Mutex::Locker locker (GetArchVolatileRegsMutex ()); - ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); - if (idx < instances.size()) - return instances[idx].create_callback; - return NULL; -} - -ArchVolatileRegsCreateInstance -PluginManager::GetArchVolatileRegsCreateCallbackForPluginName (const char *name) -{ - if (name && name[0]) - { - llvm::StringRef name_sref(name); - Mutex::Locker locker (GetArchVolatileRegsMutex ()); - ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); - - ArchVolatileRegsInstances::iterator pos, end = instances.end(); - for (pos = instances.begin(); pos != end; ++ pos) - { - if (name_sref.equals (pos->name)) - return pos->create_callback; - } - } - return NULL; -} - Added: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=131193&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (added) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Wed May 11 13:39:18 2011 @@ -0,0 +1,807 @@ +//===-- ABIMacOSX_arm.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ABIMacOSX_arm.h" + +#include "lldb/Core/ConstString.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Scalar.h" +#include "lldb/Core/Value.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + +#include "llvm/ADT/Triple.h" + +#include "Utility/ARM_DWARF_Registers.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +static const char *pluginName = "ABIMacOSX_arm"; +static const char *pluginDesc = "Mac OS X ABI for arm targets"; +static const char *pluginShort = "abi.macosx-arm"; + +size_t +ABIMacOSX_arm::GetRedZoneSize () const +{ + return 0; +} + +//------------------------------------------------------------------ +// Static Functions +//------------------------------------------------------------------ +ABISP +ABIMacOSX_arm::CreateInstance (const ArchSpec &arch) +{ + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + if ((arch_type == llvm::Triple::arm) || + (arch_type == llvm::Triple::thumb)) + { + if (!g_abi_sp) + g_abi_sp.reset (new ABIMacOSX_arm); + return g_abi_sp; + } + return ABISP(); +} + +bool +ABIMacOSX_arm::PrepareTrivialCall (Thread &thread, + addr_t sp, + addr_t functionAddress, + addr_t returnAddress, + addr_t arg, + addr_t *this_arg, + addr_t *cmd_arg) const +{ +// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); +// if (!reg_ctx) +// return false; +//#define CHAIN_EBP +// +//#ifndef CHAIN_EBP +// uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); +//#endif +// uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); +// uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); +// +// // Make room for the argument(s) on the stack +// +// if (this_arg && cmd_arg) +// sp -= 12; +// else if (this_arg) +// sp -= 8; +// else +// sp -= 4; +// +// // Align the SP +// +// sp &= ~(0xfull); // 16-byte alignment +// +// // Write the argument on the stack +// +// Error error; +// +// if (this_arg && cmd_arg) +// { +// uint32_t cmd_argU32 = *cmd_arg & 0xffffffffull; +// uint32_t this_argU32 = *this_arg & 0xffffffffull; +// uint32_t argU32 = arg & 0xffffffffull; +// +// if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) +// return false; +// if (thread.GetProcess().WriteMemory(sp + 4, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) +// return false; +// if (thread.GetProcess().WriteMemory(sp + 8, &argU32, sizeof(argU32), error) != sizeof(argU32)) +// return false; +// } +// else if (this_arg) +// { +// uint32_t this_argU32 = *this_arg & 0xffffffffull; +// uint32_t argU32 = arg & 0xffffffffull; +// +// if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) +// return false; +// if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) +// return false; +// } +// else +// { +// uint32_t argU32 = arg & 0xffffffffull; +// +// if (thread.GetProcess().WriteMemory (sp, &argU32, sizeof(argU32), error) != sizeof(argU32)) +// return false; +// } +// +// // The return address is pushed onto the stack. +// +// sp -= 4; +// uint32_t returnAddressU32 = returnAddress; +// if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) +// return false; +// +// // %esp is set to the actual stack value. +// +// if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) +// return false; +// +//#ifndef CHAIN_EBP +// // %ebp is set to a fake value, in our case 0x0x00000000 +// +// if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) +// return false; +//#endif +// +// // %eip is set to the address of the called function. +// +// if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) +// return false; +// +// return true; + return false; +} + +bool +ABIMacOSX_arm::PrepareNormalCall (Thread &thread, + addr_t sp, + addr_t functionAddress, + addr_t returnAddress, + ValueList &args) const +{ +// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); +// if (!reg_ctx) +// return false; +// Error error; +// uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); +// uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); +// uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); +// +// // Do the argument layout +// +// std::vector argLayout; // 4-byte chunks, as discussed in the ABI Function Call Guide +// +// size_t numArgs = args.GetSize(); +// size_t index; +// +// for (index = 0; index < numArgs; ++index) +// { +// Value *val = args.GetValueAtIndex(index); +// +// if (!val) +// return false; +// +// switch (val->GetValueType()) +// { +// case Value::eValueTypeScalar: +// { +// Scalar &scalar = val->GetScalar(); +// switch (scalar.GetType()) +// { +// case Scalar::e_void: +// default: +// 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: +// { +// uint64_t data = scalar.ULongLong(); +// +// switch (scalar.GetByteSize()) +// { +// default: +// return false; +// case 1: +// argLayout.push_back((uint32_t)(data & 0xffull)); +// break; +// case 2: +// argLayout.push_back((uint32_t)(data & 0xffffull)); +// break; +// case 4: +// argLayout.push_back((uint32_t)(data & 0xffffffffull)); +// break; +// case 8: +// argLayout.push_back((uint32_t)(data & 0xffffffffull)); +// argLayout.push_back((uint32_t)(data >> 32)); +// break; +// } +// } +// break; +// case Scalar::e_float: +// { +// float data = scalar.Float(); +// uint32_t dataRaw = *((uint32_t*)(&data)); +// argLayout.push_back(dataRaw); +// } +// break; +// case Scalar::e_double: +// { +// double data = scalar.Double(); +// uint32_t *dataRaw = ((uint32_t*)(&data)); +// argLayout.push_back(dataRaw[0]); +// argLayout.push_back(dataRaw[1]); +// } +// break; +// case Scalar::e_long_double: +// { +// long double data = scalar.Double(); +// uint32_t *dataRaw = ((uint32_t*)(&data)); +// while ((argLayout.size() * 4) & 0xf) +// argLayout.push_back(0); +// argLayout.push_back(dataRaw[0]); +// argLayout.push_back(dataRaw[1]); +// argLayout.push_back(dataRaw[2]); +// argLayout.push_back(dataRaw[3]); +// } +// break; +// } +// } +// break; +// case Value::eValueTypeHostAddress: +// switch (val->GetContextType()) +// { +// default: +// return false; +// case Value::eContextTypeClangType: +// { +// void *val_type = val->GetClangType(); +// uint32_t cstr_length; +// +// if (ClangASTContext::IsCStringType (val_type, cstr_length)) +// { +// const char *cstr = (const char*)val->GetScalar().ULongLong(); +// cstr_length = strlen(cstr); +// +// // Push the string onto the stack immediately. +// +// sp -= (cstr_length + 1); +// +// if (thread.GetProcess().WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1)) +// return false; +// +// // Put the address of the string into the argument array. +// +// argLayout.push_back((uint32_t)(sp & 0xffffffff)); +// } +// else +// { +// return false; +// } +// } +// break; +// } +// break; +// case Value::eValueTypeFileAddress: +// case Value::eValueTypeLoadAddress: +// default: +// return false; +// } +// } +// +// // Make room for the arguments on the stack +// +// sp -= 4 * argLayout.size(); +// +// // Align the SP +// +// sp &= ~(0xfull); // 16-byte alignment +// +// // Write the arguments on the stack +// +// size_t numChunks = argLayout.size(); +// +// for (index = 0; index < numChunks; ++index) +// if (thread.GetProcess().WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t)) +// return false; +// +// // The return address is pushed onto the stack. +// +// sp -= 4; +// uint32_t returnAddressU32 = returnAddress; +// if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) +// return false; +// +// // %esp is set to the actual stack value. +// +// if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) +// return false; +// +// // %ebp is set to a fake value, in our case 0x0x00000000 +// +// if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) +// return false; +// +// // %eip is set to the address of the called function. +// +// if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) +// return false; +// +// return true; + return false; +} + +static bool +ReadIntegerArgument (Scalar &scalar, + unsigned int bit_width, + bool is_signed, + Process &process, + addr_t ¤t_stack_argument) +{ +// if (bit_width > 64) +// return false; // Scalar can't hold large integer arguments +// +// uint64_t arg_contents; +// uint32_t read_data; +// Error error; +// +// if (bit_width > 32) +// { +// if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) +// return false; +// +// arg_contents = read_data; +// +// if (process.ReadMemory(current_stack_argument + 4, &read_data, sizeof(read_data), error) != sizeof(read_data)) +// return false; +// +// arg_contents |= ((uint64_t)read_data) << 32; +// +// current_stack_argument += 8; +// } +// else { +// if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) +// return false; +// +// arg_contents = read_data; +// +// current_stack_argument += 4; +// } +// +// if (is_signed) +// { +// switch (bit_width) +// { +// default: +// return false; +// case 8: +// scalar = (int8_t)(arg_contents & 0xff); +// break; +// case 16: +// scalar = (int16_t)(arg_contents & 0xffff); +// break; +// case 32: +// scalar = (int32_t)(arg_contents & 0xffffffff); +// break; +// case 64: +// scalar = (int64_t)arg_contents; +// break; +// } +// } +// else +// { +// switch (bit_width) +// { +// default: +// return false; +// case 8: +// scalar = (uint8_t)(arg_contents & 0xff); +// break; +// case 16: +// scalar = (uint16_t)(arg_contents & 0xffff); +// break; +// case 32: +// scalar = (uint32_t)(arg_contents & 0xffffffff); +// break; +// case 64: +// scalar = (uint64_t)arg_contents; +// break; +// } +// } +// +// return true; + return false; +} + +bool +ABIMacOSX_arm::GetArgumentValues (Thread &thread, + ValueList &values) const +{ +// unsigned int num_values = values.GetSize(); +// unsigned int value_index; +// +// // Extract the Clang AST context from the PC so that we can figure out type +// // sizes +// +// clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); +// +// // Get the pointer to the first stack argument so we have a place to start +// // when reading data +// +// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); +// +// if (!reg_ctx) +// return false; +// +// addr_t sp = reg_ctx->GetSP(0); +// +// if (!sp) +// return false; +// +// addr_t current_stack_argument = sp + 4; // jump over return address +// +// for (value_index = 0; +// value_index < num_values; +// ++value_index) +// { +// Value *value = values.GetValueAtIndex(value_index); +// +// if (!value) +// return false; +// +// // We currently only support extracting values with Clang QualTypes. +// // Do we care about others? +// switch (value->GetContextType()) +// { +// default: +// return false; +// case Value::eContextTypeClangType: +// { +// void *value_type = value->GetClangType(); +// bool is_signed; +// +// if (ClangASTContext::IsIntegerType (value_type, is_signed)) +// { +// size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); +// +// ReadIntegerArgument(value->GetScalar(), +// bit_width, +// is_signed, +// thread.GetProcess(), +// current_stack_argument); +// } +// else if (ClangASTContext::IsPointerType (value_type)) +// { +// ReadIntegerArgument(value->GetScalar(), +// 32, +// false, +// thread.GetProcess(), +// current_stack_argument); +// } +// } +// break; +// } +// } +// +// return true; + return false; +} + +bool +ABIMacOSX_arm::GetReturnValue (Thread &thread, + Value &value) const +{ +// switch (value.GetContextType()) +// { +// default: +// return false; +// case Value::eContextTypeClangType: +// { +// // Extract the Clang AST context from the PC so that we can figure out type +// // sizes +// +// clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); +// +// // Get the pointer to the first stack argument so we have a place to start +// // when reading data +// +// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); +// +// void *value_type = value.GetClangType(); +// bool is_signed; +// +// if (ClangASTContext::IsIntegerType (value_type, is_signed)) +// { +// size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); +// +// unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; +// unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; +// +// switch (bit_width) +// { +// default: +// case 128: +// // Scalar can't hold 128-bit literals, so we don't handle this +// return false; +// case 64: +// uint64_t raw_value; +// raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; +// raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32; +// if (is_signed) +// value.GetScalar() = (int64_t)raw_value; +// else +// value.GetScalar() = (uint64_t)raw_value; +// break; +// case 32: +// if (is_signed) +// value.GetScalar() = (int32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); +// else +// value.GetScalar() = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); +// break; +// case 16: +// if (is_signed) +// value.GetScalar() = (int16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); +// else +// value.GetScalar() = (uint16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); +// break; +// case 8: +// if (is_signed) +// value.GetScalar() = (int8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); +// else +// value.GetScalar() = (uint8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); +// break; +// } +// } +// else if (ClangASTContext::IsPointerType (value_type)) +// { +// unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; +// uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; +// value.GetScalar() = ptr; +// } +// else +// { +// // not handled yet +// return false; +// } +// } +// break; +// } +// +// return true; + return false; +} + +bool +ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t lr_reg_num = LLDB_INVALID_REGNUM; + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + case eRegisterKindGCC: + lr_reg_num = dwarf_lr; + sp_reg_num = dwarf_sp; + pc_reg_num = dwarf_pc; + break; + + case eRegisterKindGeneric: + lr_reg_num = LLDB_REGNUM_GENERIC_RA; + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (lr_reg_num == LLDB_INVALID_REGNUM || + sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + unwind_plan.Clear(); + unwind_plan.SetRegisterKind (eRegisterKindDWARF); + + UnwindPlan::Row row; + + // Our previous Call Frame Address is the stack pointer + row.SetCFARegister (sp_reg_num); + + // Our previous PC is in the LR + row.SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + unwind_plan.AppendRow (row); + + // All other registers are the same. + + unwind_plan.SetSourceName (pluginName); + return true; +} + +bool +ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t fp_reg_num = LLDB_INVALID_REGNUM; + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + case eRegisterKindGCC: + fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11 + sp_reg_num = dwarf_sp; + pc_reg_num = dwarf_pc; + break; + + case eRegisterKindGeneric: + fp_reg_num = LLDB_REGNUM_GENERIC_FP; + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (fp_reg_num == LLDB_INVALID_REGNUM || + sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + UnwindPlan::Row row; + const int32_t ptr_size = 8; + + unwind_plan.SetRegisterKind (eRegisterKindGeneric); + row.SetCFARegister (fp_reg_num); + row.SetCFAOffset (2 * ptr_size); + row.SetOffset (0); + + row.SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + + unwind_plan.AppendRow (row); + unwind_plan.SetSourceName ("arm-apple-darwin default unwind plan"); + return true; +} + +bool +ABIMacOSX_arm::RegisterIsVolatile (const RegisterInfo *reg_info) +{ + if (reg_info) + { + // Volatile registers include: ebx, ebp, esi, edi, esp, eip + const char *name = reg_info->name; + if (name[0] == 'r') + { + switch (name[1]) + { + case '0': return name[2] == '\0'; // r0 + case '1': + switch (name[2]) + { + case '\0': + return true; // r1 + case '2': + case '3': + return name[2] == '\0'; // r12 - r13 + default: + break; + } + break; + + case '2': return name[2] == '\0'; // r2 + case '3': return name[2] == '\0'; // r3 + case '9': return name[2] == '\0'; // r9 (apple-darwin only...) + + break; + } + } + else if (name[0] == 'd') + { + switch (name[1]) + { + case '0': + return name[2] == '\0'; // d0 + + case '1': + switch (name[2]) + { + case '\0': + return true; // d1; + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d16 - d19 + default: + break; + } + break; + + case '2': + switch (name[2]) + { + case '\0': + return true; // d2; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d20 - d29 + default: + break; + } + break; + + case '3': + switch (name[2]) + { + case '\0': + return true; // d3; + case '0': + case '1': + return name[3] == '\0'; // d30 - d31 + default: + break; + } + case '4': + case '5': + case '6': + case '7': + return name[2] == '\0'; // d4 - d7 + + default: + break; + } + } + else if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') + return true; + } + return false; +} + +void +ABIMacOSX_arm::Initialize() +{ + PluginManager::RegisterPlugin (pluginName, + pluginDesc, + CreateInstance); +} + +void +ABIMacOSX_arm::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + +//------------------------------------------------------------------ +// PluginInterface protocol +//------------------------------------------------------------------ +const char * +ABIMacOSX_arm::GetPluginName() +{ + return pluginName; +} + +const char * +ABIMacOSX_arm::GetShortPluginName() +{ + return pluginShort; +} + +uint32_t +ABIMacOSX_arm::GetPluginVersion() +{ + return 1; +} + Added: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=131193&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (added) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Wed May 11 13:39:18 2011 @@ -0,0 +1,95 @@ +//===-- ABIMacOSX_arm.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_ABIMacOSX_arm_h_ +#define liblldb_ABIMacOSX_arm_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Target/ABI.h" + +class ABIMacOSX_arm : public lldb_private::ABI +{ +public: + ~ABIMacOSX_arm() { } + + virtual size_t + GetRedZoneSize () const; + + virtual bool + PrepareTrivialCall (lldb_private::Thread &thread, + lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + lldb::addr_t arg, + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const; + + virtual bool + PrepareNormalCall (lldb_private::Thread &thread, + lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + lldb_private::ValueList &args) const; + + virtual bool + GetArgumentValues (lldb_private::Thread &thread, + lldb_private::ValueList &values) const; + + virtual bool + GetReturnValue (lldb_private::Thread &thread, + lldb_private::Value &value) const; + + virtual bool + CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); + + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb::ABISP + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + +protected: +private: + ABIMacOSX_arm() : + lldb_private::ABI() + { + // Call CreateInstance instead. + } +}; + +#endif // liblldb_ABIMacOSX_arm_h_ Added: lldb/trunk/source/Plugins/ABI/MacOSX-arm/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/Makefile?rev=131193&view=auto ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/Makefile (added) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/Makefile Wed May 11 13:39:18 2011 @@ -0,0 +1,14 @@ +##===- source/Plugins/ABI/MacOSX-arm/Makefile ------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===--------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginABIMacOSX_arm +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Wed May 11 13:39:18 2011 @@ -15,6 +15,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Scalar.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" @@ -40,13 +41,17 @@ //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ -lldb_private::ABI * +ABISP ABIMacOSX_i386::CreateInstance (const ArchSpec &arch) { + static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::x86) - return new ABIMacOSX_i386; - - return NULL; + { + if (!g_abi_sp) + g_abi_sp.reset (new ABIMacOSX_i386); + return g_abi_sp; + } + return ABISP(); } bool @@ -560,6 +565,145 @@ return true; } +bool +ABIMacOSX_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + sp_reg_num = dwarf_esp; + pc_reg_num = dwarf_eip; + break; + + case eRegisterKindGCC: + sp_reg_num = gcc_esp; + pc_reg_num = gcc_eip; + break; + + case eRegisterKindGDB: + sp_reg_num = gdb_esp; + pc_reg_num = gdb_eip; + break; + + case eRegisterKindGeneric: + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + UnwindPlan::Row row; + row.SetCFARegister (sp_reg_num); + row.SetCFAOffset (4); + row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, false); + unwind_plan.AppendRow (row); + unwind_plan.SetSourceName (pluginName); + return true; +} + +bool +ABIMacOSX_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t fp_reg_num = LLDB_INVALID_REGNUM; + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + fp_reg_num = dwarf_ebp; + sp_reg_num = dwarf_esp; + pc_reg_num = dwarf_eip; + break; + + case eRegisterKindGCC: + fp_reg_num = gcc_ebp; + sp_reg_num = gcc_esp; + pc_reg_num = gcc_eip; + break; + + case eRegisterKindGDB: + fp_reg_num = gdb_ebp; + sp_reg_num = gdb_esp; + pc_reg_num = gdb_eip; + break; + + case eRegisterKindGeneric: + fp_reg_num = LLDB_REGNUM_GENERIC_FP; + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (fp_reg_num == LLDB_INVALID_REGNUM || + sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + UnwindPlan::Row row; + const int32_t ptr_size = 4; + + unwind_plan.SetRegisterKind (eRegisterKindGeneric); + row.SetCFARegister (fp_reg_num); + row.SetCFAOffset (2 * ptr_size); + row.SetOffset (0); + + row.SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + row.SetRegisterLocationToAtCFAPlusOffset(sp_reg_num, ptr_size * 0, true); + + unwind_plan.AppendRow (row); + unwind_plan.SetSourceName ("i386 default unwind plan"); + return true; +} + +bool +ABIMacOSX_i386::RegisterIsVolatile (const RegisterInfo *reg_info) +{ + return RegisterIsCalleeSaved (reg_info); +} + +bool +ABIMacOSX_i386::RegisterIsCalleeSaved (const RegisterInfo *reg_info) +{ + if (reg_info) + { + // Volatile registers include: ebx, ebp, esi, edi, esp, eip + const char *name = reg_info->name; + if (name[0] == 'e') + { + switch (name[1]) + { + case 'b': + if (name[2] == 'x' || name[2] == 'p') + return name[0] == '\0'; + break; + case 'd': + if (name[2] == 'i') + return name[0] == '\0'; + break; + case 'i': + if (name[2] == 'p') + return name[0] == '\0'; + break; + case 's': + if (name[2] == 'i' || name[2] == 'p') + return name[0] == '\0'; + break; + } + } + } + return false; +} + void ABIMacOSX_i386::Initialize() { Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Wed May 11 13:39:18 2011 @@ -17,71 +17,195 @@ #include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" #include "lldb/Core/Value.h" - -namespace lldb_private { - class ABIMacOSX_i386 : +class ABIMacOSX_i386 : public lldb_private::ABI +{ +public: + + enum { - public: - ~ABIMacOSX_i386() { } - - virtual size_t - GetRedZoneSize () const; - - virtual bool - PrepareTrivialCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const; - - virtual bool - PrepareNormalCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - ValueList &args) const; - - virtual bool - GetArgumentValues (Thread &thread, - ValueList &values) const; - - virtual bool - GetReturnValue (Thread &thread, - Value &value) const; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static lldb_private::ABI * - CreateInstance (const ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - - protected: - private: - ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead. + gcc_eax = 0, + gcc_ecx, + gcc_edx, + gcc_ebx, + gcc_ebp, + gcc_esp, + gcc_esi, + gcc_edi, + gcc_eip, + gcc_eflags }; -} // namespace lldb_private + enum + { + dwarf_eax = 0, + dwarf_ecx, + dwarf_edx, + dwarf_ebx, + dwarf_esp, + dwarf_ebp, + dwarf_esi, + dwarf_edi, + dwarf_eip, + dwarf_eflags, + dwarf_stmm0 = 11, + dwarf_stmm1, + dwarf_stmm2, + dwarf_stmm3, + dwarf_stmm4, + dwarf_stmm5, + dwarf_stmm6, + dwarf_stmm7, + dwarf_xmm0 = 21, + dwarf_xmm1, + dwarf_xmm2, + dwarf_xmm3, + dwarf_xmm4, + dwarf_xmm5, + dwarf_xmm6, + dwarf_xmm7, + dwarf_ymm0 = dwarf_xmm0, + dwarf_ymm1 = dwarf_xmm1, + dwarf_ymm2 = dwarf_xmm2, + dwarf_ymm3 = dwarf_xmm3, + dwarf_ymm4 = dwarf_xmm4, + dwarf_ymm5 = dwarf_xmm5, + dwarf_ymm6 = dwarf_xmm6, + dwarf_ymm7 = dwarf_xmm7, + }; + + enum + { + gdb_eax = 0, + gdb_ecx = 1, + gdb_edx = 2, + gdb_ebx = 3, + gdb_esp = 4, + gdb_ebp = 5, + gdb_esi = 6, + gdb_edi = 7, + gdb_eip = 8, + gdb_eflags = 9, + gdb_cs = 10, + gdb_ss = 11, + gdb_ds = 12, + gdb_es = 13, + gdb_fs = 14, + gdb_gs = 15, + gdb_stmm0 = 16, + gdb_stmm1 = 17, + gdb_stmm2 = 18, + gdb_stmm3 = 19, + gdb_stmm4 = 20, + gdb_stmm5 = 21, + gdb_stmm6 = 22, + gdb_stmm7 = 23, + gdb_fctrl = 24, gdb_fcw = gdb_fctrl, + gdb_fstat = 25, gdb_fsw = gdb_fstat, + gdb_ftag = 26, gdb_ftw = gdb_ftag, + gdb_fiseg = 27, gdb_fpu_cs = gdb_fiseg, + gdb_fioff = 28, gdb_ip = gdb_fioff, + gdb_foseg = 29, gdb_fpu_ds = gdb_foseg, + gdb_fooff = 30, gdb_dp = gdb_fooff, + gdb_fop = 31, + gdb_xmm0 = 32, + gdb_xmm1 = 33, + gdb_xmm2 = 34, + gdb_xmm3 = 35, + gdb_xmm4 = 36, + gdb_xmm5 = 37, + gdb_xmm6 = 38, + gdb_xmm7 = 39, + gdb_mxcsr = 40, + gdb_mm0 = 41, + gdb_mm1 = 42, + gdb_mm2 = 43, + gdb_mm3 = 44, + gdb_mm4 = 45, + gdb_mm5 = 46, + gdb_mm6 = 47, + gdb_mm7 = 48, + gdb_ymm0 = gdb_xmm0, + gdb_ymm1 = gdb_xmm1, + gdb_ymm2 = gdb_xmm2, + gdb_ymm3 = gdb_xmm3, + gdb_ymm4 = gdb_xmm4, + gdb_ymm5 = gdb_xmm5, + gdb_ymm6 = gdb_xmm6, + gdb_ymm7 = gdb_xmm7 + }; + + ~ABIMacOSX_i386() { } + + virtual size_t + GetRedZoneSize () const; + + virtual bool + PrepareTrivialCall (lldb_private::Thread &thread, + lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + lldb::addr_t arg, + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const; + + virtual bool + PrepareNormalCall (lldb_private::Thread &thread, + lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + lldb_private::ValueList &args) const; + + virtual bool + GetArgumentValues (lldb_private::Thread &thread, + lldb_private::ValueList &values) const; + + virtual bool + GetReturnValue (lldb_private::Thread &thread, + lldb_private::Value &value) const; + + virtual bool + CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); + + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb::ABISP + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + +protected: + bool + RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + +private: + ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead. +}; + #endif // liblldb_ABI_h_ Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Wed May 11 13:39:18 2011 @@ -17,6 +17,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -32,6 +33,8 @@ static const char *pluginDesc = "System V ABI for x86_64 targets"; static const char *pluginShort = "abi.sysv-x86_64"; + + size_t ABISysV_x86_64::GetRedZoneSize () const { @@ -41,12 +44,17 @@ //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ -lldb_private::ABI * +ABISP ABISysV_x86_64::CreateInstance (const ArchSpec &arch) { + static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::x86_64) - return new ABISysV_x86_64; - return NULL; + { + if (!g_abi_sp) + g_abi_sp.reset (new ABISysV_x86_64); + return g_abi_sp; + } + return ABISP(); } bool @@ -446,6 +454,143 @@ return true; } +bool +ABISysV_x86_64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + case eRegisterKindGCC: + sp_reg_num = gcc_dwarf_rsp; + pc_reg_num = gcc_dwarf_rip; + break; + + case eRegisterKindGDB: + sp_reg_num = gdb_rsp; + pc_reg_num = gdb_rip; + break; + + case eRegisterKindGeneric: + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + UnwindPlan::Row row; + row.SetCFARegister (sp_reg_num); + row.SetCFAOffset (8); + row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -8, false); + unwind_plan.AppendRow (row); + unwind_plan.SetSourceName (pluginName); + return true; +} + +bool +ABISysV_x86_64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) +{ + uint32_t reg_kind = unwind_plan.GetRegisterKind(); + uint32_t fp_reg_num = LLDB_INVALID_REGNUM; + uint32_t sp_reg_num = LLDB_INVALID_REGNUM; + uint32_t pc_reg_num = LLDB_INVALID_REGNUM; + + switch (reg_kind) + { + case eRegisterKindDWARF: + case eRegisterKindGCC: + fp_reg_num = gcc_dwarf_rbp; + sp_reg_num = gcc_dwarf_rsp; + pc_reg_num = gcc_dwarf_rip; + break; + + case eRegisterKindGDB: + fp_reg_num = gdb_rbp; + sp_reg_num = gdb_rsp; + pc_reg_num = gdb_rip; + break; + + case eRegisterKindGeneric: + fp_reg_num = LLDB_REGNUM_GENERIC_FP; + sp_reg_num = LLDB_REGNUM_GENERIC_SP; + pc_reg_num = LLDB_REGNUM_GENERIC_PC; + break; + } + + if (fp_reg_num == LLDB_INVALID_REGNUM || + sp_reg_num == LLDB_INVALID_REGNUM || + pc_reg_num == LLDB_INVALID_REGNUM) + return false; + + UnwindPlan::Row row; + + const int32_t ptr_size = 8; + row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); + row.SetCFAOffset (2 * ptr_size); + row.SetOffset (0); + + row.SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row.SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + row.SetRegisterLocationToAtCFAPlusOffset(sp_reg_num, ptr_size * 0, true); + + unwind_plan.AppendRow (row); + unwind_plan.SetSourceName ("x86_64 default unwind plan"); + return true; +} + +bool +ABISysV_x86_64::RegisterIsVolatile (const RegisterInfo *reg_info) +{ + return !RegisterIsCalleeSaved (reg_info); +} + +bool +ABISysV_x86_64::RegisterIsCalleeSaved (const RegisterInfo *reg_info) +{ + if (reg_info) + { + // Volatile registers include: rbx, rbp, rsp, r12, r13, r14, r15, rip + const char *name = reg_info->name; + if (name[0] == 'r') + { + switch (name[1]) + { + case '1': // r12, r13, r14, r15 + if (name[2] >= '2' && name[2] <= '5') + return name[3] == '\0'; + break; + + case 'b': // rbp, rbx + if (name[2] == 'p' || name[2] == 'x') + return name[3] == '\0'; + break; + + case 'i': // rip + if (name[2] == 'p') + return name[3] == '\0'; + break; + + case 's': // rsp + if (name[2] == 'p') + return name[3] == '\0'; + break; + + default: + break; + } + } + } + return false; +} + + + void ABISysV_x86_64::Initialize() { Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Wed May 11 13:39:18 2011 @@ -17,19 +17,158 @@ #include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" -namespace lldb_private { - class ABISysV_x86_64 : public lldb_private::ABI { public: - ~ABISysV_x86_64() { } + + enum gcc_dwarf_regnums + { + gcc_dwarf_rax = 0, + gcc_dwarf_rdx, + gcc_dwarf_rcx, + gcc_dwarf_rbx, + gcc_dwarf_rsi, + gcc_dwarf_rdi, + gcc_dwarf_rbp, + gcc_dwarf_rsp, + gcc_dwarf_r8, + gcc_dwarf_r9, + gcc_dwarf_r10, + gcc_dwarf_r11, + gcc_dwarf_r12, + gcc_dwarf_r13, + gcc_dwarf_r14, + gcc_dwarf_r15, + gcc_dwarf_rip, + gcc_dwarf_xmm0, + gcc_dwarf_xmm1, + gcc_dwarf_xmm2, + gcc_dwarf_xmm3, + gcc_dwarf_xmm4, + gcc_dwarf_xmm5, + gcc_dwarf_xmm6, + gcc_dwarf_xmm7, + gcc_dwarf_xmm8, + gcc_dwarf_xmm9, + gcc_dwarf_xmm10, + gcc_dwarf_xmm11, + gcc_dwarf_xmm12, + gcc_dwarf_xmm13, + gcc_dwarf_xmm14, + gcc_dwarf_xmm15, + gcc_dwarf_stmm0, + gcc_dwarf_stmm1, + gcc_dwarf_stmm2, + gcc_dwarf_stmm3, + gcc_dwarf_stmm4, + gcc_dwarf_stmm5, + gcc_dwarf_stmm6, + gcc_dwarf_stmm7, + gcc_dwarf_ymm0 = gcc_dwarf_xmm0, + gcc_dwarf_ymm1 = gcc_dwarf_xmm1, + gcc_dwarf_ymm2 = gcc_dwarf_xmm2, + gcc_dwarf_ymm3 = gcc_dwarf_xmm3, + gcc_dwarf_ymm4 = gcc_dwarf_xmm4, + gcc_dwarf_ymm5 = gcc_dwarf_xmm5, + gcc_dwarf_ymm6 = gcc_dwarf_xmm6, + gcc_dwarf_ymm7 = gcc_dwarf_xmm7, + gcc_dwarf_ymm8 = gcc_dwarf_xmm8, + gcc_dwarf_ymm9 = gcc_dwarf_xmm9, + gcc_dwarf_ymm10 = gcc_dwarf_xmm10, + gcc_dwarf_ymm11 = gcc_dwarf_xmm11, + gcc_dwarf_ymm12 = gcc_dwarf_xmm12, + gcc_dwarf_ymm13 = gcc_dwarf_xmm13, + gcc_dwarf_ymm14 = gcc_dwarf_xmm14, + gcc_dwarf_ymm15 = gcc_dwarf_xmm15 + }; + + enum gdb_regnums + { + gdb_rax = 0, + gdb_rbx = 1, + gdb_rcx = 2, + gdb_rdx = 3, + gdb_rsi = 4, + gdb_rdi = 5, + gdb_rbp = 6, + gdb_rsp = 7, + gdb_r8 = 8, + gdb_r9 = 9, + gdb_r10 = 10, + gdb_r11 = 11, + gdb_r12 = 12, + gdb_r13 = 13, + gdb_r14 = 14, + gdb_r15 = 15, + gdb_rip = 16, + gdb_rflags = 17, + gdb_cs = 18, + gdb_ss = 19, + gdb_ds = 20, + gdb_es = 21, + gdb_fs = 22, + gdb_gs = 23, + gdb_stmm0 = 24, + gdb_stmm1 = 25, + gdb_stmm2 = 26, + gdb_stmm3 = 27, + gdb_stmm4 = 28, + gdb_stmm5 = 29, + gdb_stmm6 = 30, + gdb_stmm7 = 31, + gdb_fctrl = 32, gdb_fcw = gdb_fctrl, + gdb_fstat = 33, gdb_fsw = gdb_fstat, + gdb_ftag = 34, gdb_ftw = gdb_ftag, + gdb_fiseg = 35, gdb_fpu_cs = gdb_fiseg, + gdb_fioff = 36, gdb_ip = gdb_fioff, + gdb_foseg = 37, gdb_fpu_ds = gdb_foseg, + gdb_fooff = 38, gdb_dp = gdb_fooff, + gdb_fop = 39, + gdb_xmm0 = 40, + gdb_xmm1 = 41, + gdb_xmm2 = 42, + gdb_xmm3 = 43, + gdb_xmm4 = 44, + gdb_xmm5 = 45, + gdb_xmm6 = 46, + gdb_xmm7 = 47, + gdb_xmm8 = 48, + gdb_xmm9 = 49, + gdb_xmm10 = 50, + gdb_xmm11 = 51, + gdb_xmm12 = 52, + gdb_xmm13 = 53, + gdb_xmm14 = 54, + gdb_xmm15 = 55, + gdb_mxcsr = 56, + gdb_ymm0 = gdb_xmm0, + gdb_ymm1 = gdb_xmm1, + gdb_ymm2 = gdb_xmm2, + gdb_ymm3 = gdb_xmm3, + gdb_ymm4 = gdb_xmm4, + gdb_ymm5 = gdb_xmm5, + gdb_ymm6 = gdb_xmm6, + gdb_ymm7 = gdb_xmm7, + gdb_ymm8 = gdb_xmm8, + gdb_ymm9 = gdb_xmm9, + gdb_ymm10 = gdb_xmm10, + gdb_ymm11 = gdb_xmm11, + gdb_ymm12 = gdb_xmm12, + gdb_ymm13 = gdb_xmm13, + gdb_ymm14 = gdb_xmm14, + gdb_ymm15 = gdb_xmm15 + }; + + ~ABISysV_x86_64() + { + } virtual size_t GetRedZoneSize () const; virtual bool - PrepareTrivialCall (Thread &thread, + PrepareTrivialCall (lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, @@ -38,19 +177,28 @@ lldb::addr_t *cmd_arg) const; virtual bool - PrepareNormalCall (Thread &thread, + PrepareNormalCall (lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - ValueList &args) const; + lldb_private::ValueList &args) const; virtual bool - GetArgumentValues (Thread &thread, - ValueList &values) const; + GetArgumentValues (lldb_private::Thread &thread, + lldb_private::ValueList &values) const; virtual bool - GetReturnValue (Thread &thread, - Value &value) const; + GetReturnValue (lldb_private::Thread &thread, + lldb_private::Value &value) const; + + virtual bool + CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan); + + virtual bool + RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); //------------------------------------------------------------------ // Static Functions @@ -61,8 +209,8 @@ static void Terminate(); - static lldb_private::ABI * - CreateInstance (const ArchSpec &arch); + static lldb::ABISP + CreateInstance (const lldb_private::ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol @@ -77,10 +225,12 @@ GetPluginVersion(); protected: + + bool + RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + private: ABISysV_x86_64() : lldb_private::ABI() { } // Call CreateInstance instead. }; -} // namespace lldb_private - #endif // liblldb_ABI_h_ Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed May 11 13:39:18 2011 @@ -576,7 +576,7 @@ addr_t addr = sp + sp_offset; // a pointer to the stack area EmulateInstruction::Context context; - context.type = EmulateInstruction::eContextAdjustStackPointer; + context.type = eContextSetFramePointer; RegisterInfo sp_reg; GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, sp_offset); @@ -13413,17 +13413,16 @@ bool EmulateInstructionARM::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan) { + unwind_plan.Clear(); unwind_plan.SetRegisterKind (eRegisterKindDWARF); UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; // Our previous Call Frame Address is the stack pointer row.SetCFARegister (dwarf_sp); // Our previous PC is in the LR - regloc.SetInRegister(dwarf_lr); - row.SetRegisterInfo (dwarf_pc, regloc); + row.SetRegisterLocationToRegister(dwarf_pc, dwarf_lr, true); unwind_plan.AppendRow (row); // All other registers are the same. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Wed May 11 13:39:18 2011 @@ -391,7 +391,7 @@ // The Update function is called with the address of an added region. So we grab that address, and // feed it into ReadRegions. Of course, our friend the ABI will get the values for us. Process *process = context->exe_ctx.process; - const ABI *abi = process->GetABI(); + const ABI *abi = process->GetABI().get(); ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext(); ValueList argument_values; @@ -624,7 +624,7 @@ lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); Process *process = thread.CalculateProcess(); - const ABI *abi = process->GetABI(); + const ABI *abi = process->GetABI().get(); if (abi == NULL) return ret_plan_sp; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Wed May 11 13:39:18 2011 @@ -21,8 +21,7 @@ #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Expression/DWARFExpression.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" -#include "lldb/Target/ArchVolatileRegs.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" @@ -247,12 +246,12 @@ log->Printf("%*sFrame %u using architectural default unwind method", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } - const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); - if (arch_default_sp) + ABI *abi = m_thread.GetProcess().GetABI().get(); + if (abi) { - m_fast_unwind_plan_sp.reset(); - m_full_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); + m_fast_unwind_plan_sp.reset (); + m_full_unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); + abi->CreateDefaultUnwindPlan(*m_full_unwind_plan_sp); m_frame_type = eNormalFrame; m_all_registers_available = false; m_current_offset = -1; @@ -519,10 +518,14 @@ UnwindPlanSP unwind_plan_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); UnwindPlanSP arch_default_unwind_plan_sp; - const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); - if (arch_default_sp) - arch_default_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); + + + ABI *abi = m_thread.GetProcess().GetABI().get(); + if (abi) + { + arch_default_unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); + abi->CreateDefaultUnwindPlan(*arch_default_unwind_plan_sp); + } bool behaves_like_zeroth_frame = false; if (IsFrameZero () @@ -871,18 +874,21 @@ { // If a volatile register is being requested, we don't want to forward m_next_frame's register contents // up the stack -- the register is not retrievable at this frame. - const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchVolatileRegs *volatile_regs = ArchVolatileRegs::FindPlugin (arch); - if (volatile_regs && volatile_regs->RegisterIsVolatile (m_thread, lldb_regnum)) + ABI *abi = m_thread.GetProcess().GetABI().get(); + if (abi) { - if (log) + const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum); + if (reg_info && abi->RegisterIsVolatile (reg_info)) { - log->Printf("%*sFrame %u did not supply reg location for %d because it is volatile", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_regnum); - } - return false; - } + if (log) + { + log->Printf("%*sFrame %u did not supply reg location for %d because it is volatile", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + lldb_regnum); + } + return false; + } + } if (IsFrameZero ()) { Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Wed May 11 13:39:18 2011 @@ -12,7 +12,6 @@ #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" #include "lldb/Target/Process.h" Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Wed May 11 13:39:18 2011 @@ -147,8 +147,8 @@ { case llvm::Triple::x86_64: case llvm::Triple::x86: -// case llvm::Triple::arm: -// case llvm::Triple::thumb: + case llvm::Triple::arm: + case llvm::Triple::thumb: m_unwinder_ap.reset (new UnwindLLDB (*this)); break; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Wed May 11 13:39:18 2011 @@ -16,8 +16,9 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Error.h" +#include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/StreamFile.h" +#include "lldb/Core/StreamString.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -37,49 +38,19 @@ Thread& thread, UnwindPlan& unwind_plan) { -#if 0 - UnwindPlan::Row row; - UnwindPlan::Row::RegisterLocation regloc; - - m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); - row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 8); - row.SetOffset (0); - - regloc.SetAtCFAPlusOffset (2 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -8); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); - regloc.SetIsCFAPlusOffset (0); - row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - - m_unwind_plan_sp->AppendRow (row); - m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); -#endif - if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid() && m_inst_emulator_ap.get()) { -#if 0 - Target &target = thread.GetProcess().GetTarget(); - const ArchSpec &target_arch = target.GetArchitecture(); - bool prefer_file_cache = true; - Error error; - DataBufferHeap data_buffer (range.GetByteSize(), 0); - if (target.ReadMemory (range.GetBaseAddress(), - prefer_file_cache, - data_buffer.GetBytes(), - data_buffer.GetByteSize(), - error) == data_buffer.GetByteSize()) - { - DataExtractor data (data_buffer.GetBytes(), - data_buffer.GetByteSize(), - target_arch.GetByteOrder(), - target_arch.GetAddressByteSize()); - } -#endif - StreamFile strm (stdout, false); + + // The the instruction emulation subclass setup the unwind plan for the + // first instruction. + m_inst_emulator_ap->CreateFunctionEntryUnwind (unwind_plan); + + // CreateFunctionEntryUnwind should have created the first row. If it + // doesn't, then we are done. + if (unwind_plan.GetRowCount() == 0) + return false; ExecutionContext exe_ctx; thread.CalculateExecutionContext(exe_ctx); @@ -87,6 +58,9 @@ NULL, exe_ctx, range)); + + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + if (disasm_sp) { @@ -98,13 +72,19 @@ const bool show_address = true; const bool show_bytes = true; const bool raw = false; - // Initialize the stack pointer with a known value. In the 32 bit case + // Initialize the CFA with a known value. In the 32 bit case // it will be 0x80000000, and in the 64 bit case 0x8000000000000000. // We use the address byte size to be safe for any future addresss sizes - RegisterInfo sp_reg_info; - m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp_reg_info); + m_inst_emulator_ap->GetRegisterInfo (unwind_plan.GetRegisterKind(), + unwind_plan.GetInitialCFARegister(), + m_cfa_reg_info); + + m_fp_is_cfa = false; + m_register_values.clear(); + m_pushed_regs.clear(); + m_initial_sp = (1ull << ((addr_byte_size * 8) - 1)); - SetRegisterValue(sp_reg_info, m_initial_sp); + SetRegisterValue (m_cfa_reg_info, m_initial_sp); const InstructionList &inst_list = disasm_sp->GetInstructionList (); const size_t num_instructions = inst_list.GetSize(); @@ -112,26 +92,51 @@ { Instruction *inst = inst_list.GetInstructionAtIndex (0).get(); const addr_t base_addr = inst->GetAddress().GetFileAddress(); + // Initialize the current row with the one row that was created + // from the CreateFunctionEntryUnwind call above... + m_curr_row = unwind_plan.GetLastRow(); for (size_t idx=0; idxDump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); - strm.EOL(); + + if (log) + { + StreamString strm; + inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); + log->PutCString (strm.GetData()); + } m_inst_emulator_ap->SetInstruction (inst->GetOpcode(), inst->GetAddress(), exe_ctx.target); - m_curr_row.SetOffset (inst->GetAddress().GetFileAddress() + inst->GetOpcode().GetByteSize() - base_addr); m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions); + + if (unwind_plan.GetLastRow() != m_curr_row) + { + // Be sure to not edit the offset unless our row has changed + // so that the "!=" call above doesn't trigger every time + m_curr_row.SetOffset (inst->GetAddress().GetFileAddress() + inst->GetOpcode().GetByteSize() - base_addr); + // Append the new row + unwind_plan.AppendRow (m_curr_row); + } } } } } + + if (log) + { + StreamString strm; + lldb::addr_t base_addr = range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget()); + strm.Printf ("Resulting unwind rows for [0x%llx - 0x%llx):", base_addr, base_addr + range.GetByteSize()); + unwind_plan.Dump(strm, &thread, base_addr); + log->PutCString (strm.GetData()); + } + return unwind_plan.GetRowCount() > 0; } return false; } @@ -255,12 +260,18 @@ void *dst, size_t dst_len) { - //UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - printf ("UnwindAssemblyInstEmulation::ReadMemory (addr = 0x%16.16llx, dst = %p, dst_len = %zu, context = ", - addr, - dst, - dst_len); - context.Dump(stdout, instruction); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + + if (log) + { + StreamString strm; + strm.Printf ("UnwindAssemblyInstEmulation::ReadMemory (addr = 0x%16.16llx, dst = %p, dst_len = %zu, context = ", + addr, + dst, + dst_len); + context.Dump(strm, instruction); + log->PutCString (strm.GetData ()); + } return dst_len; } @@ -272,19 +283,39 @@ const void *dst, size_t dst_len) { - UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - + if (baton && dst && dst_len) + return ((UnwindAssemblyInstEmulation *)baton)->WriteMemory (instruction, context, addr, dst, dst_len); + return 0; +} + +size_t +UnwindAssemblyInstEmulation::WriteMemory (EmulateInstruction *instruction, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t dst_len) +{ DataExtractor data (dst, dst_len, instruction->GetArchitecture ().GetByteOrder(), instruction->GetArchitecture ().GetAddressByteSize()); - StreamFile strm(stdout, false); - strm.PutCString ("UnwindAssemblyInstEmulation::WriteMemory ("); - data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); - strm.PutCString (", context = "); - context.Dump(stdout, instruction); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + + if (log) + { + StreamString strm; + + strm.PutCString ("UnwindAssemblyInstEmulation::WriteMemory ("); + data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); + strm.PutCString (", context = "); + context.Dump(strm, instruction); + log->PutCString (strm.GetData()); + } + const bool can_replace = true; + const bool cant_replace = false; + switch (context.type) { default: @@ -307,25 +338,45 @@ case EmulateInstruction::eContextReturnFromException: case EmulateInstruction::eContextPopRegisterOffStack: case EmulateInstruction::eContextAdjustStackPointer: - assert (!"unhandled case, add code to handle this!"); break; case EmulateInstruction::eContextPushRegisterOnStack: - switch (context.info_type) { - case EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset: + uint32_t reg_num = LLDB_INVALID_REGNUM; + bool is_return_address_reg = false; + const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind(); + if (context.info_type == EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset) + { + reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[unwind_reg_kind]; + if (context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_RA) + is_return_address_reg = true; + } + else + { + assert (!"unhandled case, add code to handle this!"); + } + + if (reg_num != LLDB_INVALID_REGNUM) + { + if (m_pushed_regs.find (reg_num) == m_pushed_regs.end()) { - UnwindPlan::Row::RegisterLocation regloc; - const uint32_t dwarf_reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindDWARF]; - //const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset; - regloc.SetAtCFAPlusOffset (addr - inst_emulator->m_initial_sp); - inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); + m_pushed_regs[reg_num] = addr; + const int32_t offset = addr - m_initial_sp; + m_curr_row.SetRegisterLocationToAtCFAPlusOffset (reg_num, offset, cant_replace); + if (is_return_address_reg) + { + // This push was pushing the return address register, + // so this is also how we will unwind the PC... + RegisterInfo pc_reg_info; + if (instruction->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, pc_reg_info)) + { + uint32_t pc_reg_num = pc_reg_info.kinds[unwind_reg_kind]; + if (pc_reg_num != LLDB_INVALID_REGNUM) + m_curr_row.SetRegisterLocationToAtCFAPlusOffset (pc_reg_num, offset, can_replace); + } + } } - break; - - default: - assert (!"unhandled case, add code to handle this!"); - break; + } } break; @@ -340,15 +391,27 @@ const RegisterInfo *reg_info, RegisterValue ®_value) { + if (baton && reg_info) - { - UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - bool synthetic = inst_emulator->GetRegisterValue (*reg_info, reg_value); + return ((UnwindAssemblyInstEmulation *)baton)->ReadRegister (instruction, reg_info, reg_value); + return false; +} +bool +UnwindAssemblyInstEmulation::ReadRegister (EmulateInstruction *instruction, + const RegisterInfo *reg_info, + RegisterValue ®_value) +{ + bool synthetic = GetRegisterValue (*reg_info, reg_value); - StreamFile strm (stdout, false); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + + if (log) + { + + StreamString strm; strm.Printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => synthetic_value = %i, value = ", reg_info->name, synthetic); reg_value.Dump(&strm, reg_info, false, eFormatDefault); - strm.EOL(); + log->PutCString(strm.GetData()); } return true; } @@ -360,17 +423,31 @@ const RegisterInfo *reg_info, const RegisterValue ®_value) { - if (!baton || !reg_info) - return false; + if (baton && reg_info) + return ((UnwindAssemblyInstEmulation *)baton)->WriteRegister (instruction, context, reg_info, reg_value); + return false; +} +bool +UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction, + const EmulateInstruction::Context &context, + const RegisterInfo *reg_info, + const RegisterValue ®_value) +{ + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton; - StreamFile strm (stdout, false); - strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name); - reg_value.Dump(&strm, reg_info, false, eFormatDefault); - strm.PutCString (", context = "); - context.Dump(stdout, instruction); + if (log) + { + + StreamString strm; + strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name); + reg_value.Dump(&strm, reg_info, false, eFormatDefault); + strm.PutCString (", context = "); + context.Dump(strm, instruction); + log->PutCString(strm.GetData()); + } - inst_emulator->SetRegisterValue (*reg_info, reg_value); + const bool must_replace = true; + SetRegisterValue (*reg_info, reg_value); switch (context.type) { @@ -393,31 +470,48 @@ case EmulateInstruction::eContextAdvancePC: case EmulateInstruction::eContextReturnFromException: case EmulateInstruction::eContextPushRegisterOnStack: - assert (!"unhandled case, add code to handle this!"); +// { +// const uint32_t reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()]; +// if (reg_num != LLDB_INVALID_REGNUM) +// { +// const bool can_replace_only_if_unspecified = true; +// +// m_curr_row.SetRegisterLocationToUndefined (reg_num, +// can_replace_only_if_unspecified, +// can_replace_only_if_unspecified); +// } +// } break; case EmulateInstruction::eContextPopRegisterOffStack: { - switch (context.info_type) + const uint32_t reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()]; + if (reg_num != LLDB_INVALID_REGNUM) { - case EmulateInstruction::eInfoTypeRegisterPlusOffset: - { - const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF]; - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetSame(); - inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc); - } - break; - - default: - assert (!"unhandled case, add code to handle this!"); - break; + m_curr_row.SetRegisterLocationToSame (reg_num, must_replace); } } break; + case EmulateInstruction::eContextSetFramePointer: + if (!m_fp_is_cfa) + { + m_fp_is_cfa = true; + m_cfa_reg_info = *reg_info; + const uint32_t cfa_reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()]; + assert (cfa_reg_num != LLDB_INVALID_REGNUM); + m_curr_row.SetCFARegister(cfa_reg_num); + m_curr_row.SetCFAOffset(m_initial_sp - reg_value.GetAsUInt64()); + } + break; + case EmulateInstruction::eContextAdjustStackPointer: - inst_emulator->m_curr_row.SetCFAOffset (reg_value.GetAsUInt64() - inst_emulator->m_initial_sp); + // If we have created a frame using the frame pointer, don't follow + // subsequent adjustments to the stack pointer. + if (!m_fp_is_cfa) + { + m_curr_row.SetCFAOffset (m_initial_sp - reg_value.GetAsUInt64()); + } break; } return true; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h Wed May 11 13:39:18 2011 @@ -101,6 +101,31 @@ const lldb_private::RegisterValue ®_value); +// size_t +// ReadMemory (lldb_private::EmulateInstruction *instruction, +// const lldb_private::EmulateInstruction::Context &context, +// lldb::addr_t addr, +// void *dst, +// size_t length); + + size_t + WriteMemory (lldb_private::EmulateInstruction *instruction, + const lldb_private::EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t length); + + bool + ReadRegister (lldb_private::EmulateInstruction *instruction, + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value); + + bool + WriteRegister (lldb_private::EmulateInstruction *instruction, + const lldb_private::EmulateInstruction::Context &context, + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value); + // Call CreateInstance to get an instance of this class UnwindAssemblyInstEmulation (const lldb_private::ArchSpec &arch, lldb_private::EmulateInstruction *inst_emulator) : @@ -108,7 +133,12 @@ m_inst_emulator_ap (inst_emulator), m_range_ptr (NULL), m_thread_ptr (NULL), - m_unwind_plan_ptr (NULL) + m_unwind_plan_ptr (NULL), + m_curr_row (), + m_cfa_reg_info (), + m_fp_is_cfa (false), + m_register_values (), + m_pushed_regs() { if (m_inst_emulator_ap.get()) { @@ -133,9 +163,13 @@ lldb_private::Thread* m_thread_ptr; lldb_private::UnwindPlan* m_unwind_plan_ptr; lldb_private::UnwindPlan::Row m_curr_row; + typedef std::map PushedRegisterToAddrMap; uint64_t m_initial_sp; + lldb_private::RegisterInfo m_cfa_reg_info; + bool m_fp_is_cfa; typedef std::map RegisterValueMap; RegisterValueMap m_register_values; + PushedRegisterToAddrMap m_pushed_regs; }; #endif // liblldb_UnwindAssemblyInstEmulation_h_ Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Wed May 11 13:39:18 2011 @@ -14,7 +14,8 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Symbol/UnwindTable.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" +#include "lldb/Target/ABI.h" +#include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnwindAssembly.h" @@ -83,7 +84,7 @@ DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); if (eh_frame) { - m_unwind_plan_call_site_sp.reset (new UnwindPlan); + m_unwind_plan_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); if (!eh_frame->GetUnwindPlan (current_pc, *m_unwind_plan_call_site_sp)) m_unwind_plan_call_site_sp.reset(); } @@ -111,7 +112,7 @@ if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == NULL) { m_tried_unwind_at_non_call_site = true; - m_unwind_plan_non_call_site_sp.reset (new UnwindPlan); + m_unwind_plan_non_call_site_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp)) m_unwind_plan_non_call_site_sp.reset(); } @@ -137,7 +138,7 @@ if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == NULL) { m_tried_unwind_fast = true; - m_unwind_plan_fast_sp.reset (new UnwindPlan); + m_unwind_plan_fast_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp)) m_unwind_plan_fast_sp.reset(); } @@ -167,9 +168,13 @@ Target *target = thread.CalculateTarget(); if (target) { - ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (target->GetArchitecture ())); - if (arch_default_sp) - m_unwind_plan_arch_default_sp = arch_default_sp->GetArchDefaultUnwindPlan (thread, current_pc); + ABI *abi = thread.GetProcess().GetABI().get(); + if (abi) + { + m_unwind_plan_arch_default_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); + if (m_unwind_plan_arch_default_sp) + abi->CreateDefaultUnwindPlan(*m_unwind_plan_arch_default_sp); + } } } Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (original) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Wed May 11 13:39:18 2011 @@ -20,15 +20,29 @@ bool UnwindPlan::Row::RegisterLocation::operator == (const UnwindPlan::Row::RegisterLocation& rhs) const { - if (m_type != rhs.m_type) - return false; - if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset) - return m_location.offset == rhs.m_location.offset; - if (m_type == inOtherRegister) - return m_location.reg_num == rhs.m_location.reg_num; - if (m_type == atDWARFExpression || m_type == isDWARFExpression) - if (m_location.expr.length == rhs.m_location.expr.length) - return !memcmp (m_location.expr.opcodes, rhs.m_location.expr.opcodes, m_location.expr.length); + if (m_type == rhs.m_type) + { + switch (m_type) + { + case unspecified: + case undefined: + case same: + return true; + + case atCFAPlusOffset: + case isCFAPlusOffset: + return m_location.offset == rhs.m_location.offset; + + case inOtherRegister: + return m_location.reg_num == rhs.m_location.reg_num; + + case atDWARFExpression: + case isDWARFExpression: + if (m_location.expr.length == rhs.m_location.expr.length) + return !memcmp (m_location.expr.opcodes, rhs.m_location.expr.opcodes, m_location.expr.length); + break; + } + } return false; } @@ -53,74 +67,85 @@ } void -UnwindPlan::Row::RegisterLocation::SetUnspecified () -{ - m_type = unspecified; -} - -void -UnwindPlan::Row::RegisterLocation::SetUndefined () -{ - m_type = isUndefined; -} - -void -UnwindPlan::Row::RegisterLocation::SetSame () -{ - m_type = isSame; -} - - -void -UnwindPlan::Row::RegisterLocation::SetAtCFAPlusOffset (int32_t offset) -{ - m_type = atCFAPlusOffset; - m_location.offset = offset; -} - -void -UnwindPlan::Row::RegisterLocation::SetIsCFAPlusOffset (int32_t offset) -{ - m_type = isCFAPlusOffset; - m_location.offset = offset; -} - -void -UnwindPlan::Row::RegisterLocation::SetInRegister (uint32_t reg_num) -{ - m_type = inOtherRegister; - m_location.reg_num = reg_num; -} - -void -UnwindPlan::Row::RegisterLocation::Dump (Stream &s) const +UnwindPlan::Row::RegisterLocation::Dump (Stream &s, const UnwindPlan* unwind_plan, const UnwindPlan::Row* row, Thread* thread, bool verbose) const { switch (m_type) { case unspecified: - s.PutCString ("unspecified"); + if (verbose) + s.PutCString ("="); + else + s.PutCString ("=!"); break; - case isUndefined: - s.PutCString ("isUndefined"); + case undefined: + if (verbose) + s.PutCString ("="); + else + s.PutCString ("=?"); break; - case isSame: - s.PutCString ("isSame"); + case same: + s.PutCString ("= "); break; + case atCFAPlusOffset: - s.Printf ("atCFAPlusOffset %d", m_location.offset); - break; case isCFAPlusOffset: - s.Printf ("isCFAPlusOffset %d", m_location.offset); + { + s.PutChar('='); + if (m_type == atCFAPlusOffset) + s.PutChar('['); + if (verbose) + s.Printf ("CFA%+d", m_location.offset); + + if (unwind_plan && row) + { + const uint32_t cfa_reg = row->GetCFARegister(); + const RegisterInfo *cfa_reg_info = unwind_plan->GetRegisterInfo (thread, cfa_reg); + const int32_t offset = row->GetCFAOffset() + m_location.offset; + if (verbose) + { + if (cfa_reg_info) + s.Printf (" (%s%+d)", cfa_reg_info->name, offset); + else + s.Printf (" (reg(%u)%+d)", cfa_reg_info->name, offset); + } + else + { + if (cfa_reg_info) + s.Printf ("%s", cfa_reg_info->name); + else + s.Printf ("reg(%u)", cfa_reg_info->name); + if (offset != 0) + s.Printf ("%+d", offset); + } + } + if (m_type == atCFAPlusOffset) + s.PutChar(']'); + } break; + case inOtherRegister: - s.Printf ("inOtherRegister %d", m_location.reg_num); + { + const RegisterInfo *other_reg_info = NULL; + if (unwind_plan) + other_reg_info = unwind_plan->GetRegisterInfo (thread, m_location.reg_num); + if (other_reg_info) + s.Printf ("=%s", other_reg_info->name); + else + s.Printf ("=reg(%u)", m_location.reg_num); + } break; + case atDWARFExpression: - s.PutCString ("atDWARFExpression"); - break; case isDWARFExpression: - s.PutCString ("isDWARFExpression"); + { + s.PutChar('='); + if (m_type == atDWARFExpression) + s.PutCString("[dwarf-expr]"); + else + s.PutCString("dwarf-expr"); + } break; + } } @@ -134,48 +159,30 @@ } void -UnwindPlan::Row::Dump (Stream& s, int register_kind, Thread* thread) const +UnwindPlan::Row::Dump (Stream& s, const UnwindPlan* unwind_plan, Thread* thread, addr_t base_addr) const { - RegisterContext *reg_ctx = NULL; - const RegisterInfo *rinfo = NULL; - int translated_regnum; - if (thread && thread->GetRegisterContext()) - reg_ctx = thread->GetRegisterContext().get(); - - s.Printf ("offset %ld, CFA reg ", (long) GetOffset()); - if (reg_ctx - && (translated_regnum = reg_ctx->ConvertRegisterKindToRegisterNumber (register_kind, GetCFARegister())) != -1 - && (rinfo = reg_ctx->GetRegisterInfoAtIndex (translated_regnum)) != NULL - && rinfo->name != NULL - && rinfo->name[0] != '\0') - { - s.Printf ("%s, ", rinfo->name); - } + const RegisterInfo *reg_info = unwind_plan->GetRegisterInfo (thread, GetCFARegister()); + + if (base_addr != LLDB_INVALID_ADDRESS) + s.Printf ("0x%16.16llx: CFA=", base_addr + GetOffset()); else - { - s.Printf ("%d, ", (int)(int) GetCFARegister()); - } - s.Printf ("CFA offset %d", (int) GetCFAOffset ()); + s.Printf ("0x%8.8x: CFA=", GetOffset()); + + if (reg_info) + s.Printf ("%s", reg_info->name); + else + s.Printf ("reg(%u)", GetCFARegister()); + s.Printf ("%+3d =>", GetCFAOffset ()); for (collection::const_iterator idx = m_register_locations.begin (); idx != m_register_locations.end (); ++idx) { - s.PutCString (" ["); - bool printed_name = false; - if (reg_ctx) - { - translated_regnum = reg_ctx->ConvertRegisterKindToRegisterNumber (register_kind, idx->first); - rinfo = reg_ctx->GetRegisterInfoAtIndex (translated_regnum); - if (rinfo && rinfo->name) - { - s.Printf ("%s ", rinfo->name); - printed_name = true; - } - } - if (!printed_name) - { - s.Printf ("reg %d ", idx->first); - } - idx->second.Dump(s); - s.PutCString ("]"); + reg_info = unwind_plan->GetRegisterInfo (thread, idx->first); + if (reg_info) + s.Printf ("%s", reg_info->name); + else + s.Printf ("reg(%u)", idx->first); + const bool verbose = false; + idx->second.Dump(s, unwind_plan, this, thread, verbose); + s.PutChar (' '); } s.EOL(); } @@ -206,6 +213,87 @@ m_register_locations[reg_num] = register_location; } +bool +UnwindPlan::Row::SetRegisterLocationToAtCFAPlusOffset (uint32_t reg_num, int32_t offset, bool can_replace) +{ + if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end()) + return false; + RegisterLocation reg_loc; + reg_loc.SetAtCFAPlusOffset(offset); + m_register_locations[reg_num] = reg_loc; + return true; +} + +bool +UnwindPlan::Row::SetRegisterLocationToIsCFAPlusOffset (uint32_t reg_num, int32_t offset, bool can_replace) +{ + if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end()) + return false; + RegisterLocation reg_loc; + reg_loc.SetIsCFAPlusOffset(offset); + m_register_locations[reg_num] = reg_loc; + return true; +} + +bool +UnwindPlan::Row::SetRegisterLocationToUndefined (uint32_t reg_num, bool can_replace, bool can_replace_only_if_unspecified) +{ + collection::iterator pos = m_register_locations.find(reg_num); + collection::iterator end = m_register_locations.end(); + + if (pos != end) + { + if (!can_replace) + return false; + if (can_replace_only_if_unspecified && !pos->second.IsUnspecified()) + return false; + } + RegisterLocation reg_loc; + reg_loc.SetUndefined(); + m_register_locations[reg_num] = reg_loc; + return true; +} + +bool +UnwindPlan::Row::SetRegisterLocationToUnspecified (uint32_t reg_num, bool can_replace) +{ + if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end()) + return false; + RegisterLocation reg_loc; + reg_loc.SetUnspecified(); + m_register_locations[reg_num] = reg_loc; + return true; +} + +bool +UnwindPlan::Row::SetRegisterLocationToRegister (uint32_t reg_num, + uint32_t other_reg_num, + bool can_replace) +{ + if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end()) + return false; + RegisterLocation reg_loc; + reg_loc.SetInRegister(other_reg_num); + m_register_locations[reg_num] = reg_loc; + return true; +} + +bool +UnwindPlan::Row::SetRegisterLocationToSame (uint32_t reg_num, bool must_replace) +{ + if (must_replace && m_register_locations.find(reg_num) == m_register_locations.end()) + return false; + RegisterLocation reg_loc; + reg_loc.SetSame(); + m_register_locations[reg_num] = reg_loc; + return true; +} + +void +UnwindPlan::Row::SetCFARegister (uint32_t reg_num) +{ + m_cfa_reg_num = reg_num; +} void UnwindPlan::AppendRow (const UnwindPlan::Row &row) @@ -253,22 +341,18 @@ return m_row_list[idx]; } -int -UnwindPlan::GetRowCount () const -{ - return m_row_list.size (); -} - -void -UnwindPlan::SetRegisterKind (uint32_t rk) +const UnwindPlan::Row& +UnwindPlan::GetLastRow () const { - m_register_kind = rk; + // You must call GetRowCount() first to make sure there is at least one row + assert (!m_row_list.empty()); + return m_row_list.back(); } -uint32_t -UnwindPlan::GetRegisterKind (void) const +int +UnwindPlan::GetRowCount () const { - return m_register_kind; + return m_row_list.size (); } void @@ -294,7 +378,7 @@ } void -UnwindPlan::Dump (Stream& s, Thread *thread) const +UnwindPlan::Dump (Stream& s, Thread *thread, lldb::addr_t base_addr) const { if (!m_source_name.IsEmpty()) { @@ -318,13 +402,14 @@ case eRegisterKindGeneric: s.PutCString (" [eRegisterKindGeneric]"); break; case eRegisterKindGDB: s.PutCString (" [eRegisterKindGDB]"); break; case eRegisterKindLLDB: s.PutCString (" [eRegisterKindLLDB]"); break; - default: break; + default: s.PutCString (" [eRegisterKind???]"); break; } s.EOL(); - for (int i = 0; IsValidRowIndex (i); i++) + collection::const_iterator pos, begin = m_row_list.begin(), end = m_row_list.end(); + for (pos = begin; pos != end; ++pos) { - s.Printf ("UnwindPlan row at index %d: ", i); - m_row_list[i].Dump(s, m_register_kind, thread); + s.Printf ("row[%u]: ", (uint32_t)std::distance (begin, pos)); + pos->Dump(s, this, thread, base_addr); } } @@ -339,3 +424,24 @@ { return m_source_name; } + +const RegisterInfo * +UnwindPlan::GetRegisterInfo (Thread* thread, uint32_t unwind_reg) const +{ + if (thread) + { + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + if (reg_ctx) + { + uint32_t reg; + if (m_register_kind == eRegisterKindLLDB) + reg = unwind_reg; + else + reg = reg_ctx->ConvertRegisterKindToRegisterNumber (m_register_kind, unwind_reg); + if (reg != LLDB_INVALID_REGNUM) + return reg_ctx->GetRegisterInfoAtIndex (reg); + } + } + return NULL; +} + Modified: lldb/trunk/source/Target/ABI.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Target/ABI.cpp (original) +++ lldb/trunk/source/Target/ABI.cpp Wed May 11 13:39:18 2011 @@ -13,23 +13,23 @@ using namespace lldb; using namespace lldb_private; -ABI* +ABISP ABI::FindPlugin (const ArchSpec &arch) { - std::auto_ptr abi_ap; + ABISP abi_sp; ABICreateInstance create_callback; for (uint32_t idx = 0; (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != NULL; ++idx) { - abi_ap.reset (create_callback(arch)); + abi_sp = create_callback(arch); - if (abi_ap.get()) - return abi_ap.release(); + if (abi_sp) + return abi_sp; } - - return NULL; + abi_sp.reset(); + return abi_sp; } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed May 11 13:39:18 2011 @@ -1349,13 +1349,12 @@ return error; } -const ABI * +const lldb::ABISP & Process::GetABI() { - if (m_abi_sp.get() == NULL) - m_abi_sp.reset(ABI::FindPlugin(m_target.GetArchitecture())); - - return m_abi_sp.get(); + if (!m_abi_sp) + m_abi_sp = ABI::FindPlugin(m_target.GetArchitecture()); + return m_abi_sp; } LanguageRuntime * Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed May 11 13:39:18 2011 @@ -56,7 +56,7 @@ Process& process = thread.GetProcess(); Target& target = process.GetTarget(); - const ABI *abi = process.GetABI(); + const ABI *abi = process.GetABI().get(); if (!abi) return; Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Wed May 11 13:39:18 2011 @@ -112,7 +112,7 @@ m_disassembler = Disassembler::FindPlugin(arch, NULL); - m_abi = process.GetABI(); + m_abi = process.GetABI().get(); ModuleSP exe_module_sp (target.GetExecutableModule()); Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Wed May 11 13:39:18 2011 @@ -32,11 +32,10 @@ #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" -#include "Plugins/ArchDefaultUnwindPlan/x86/ArchDefaultUnwindPlan-x86.h" -#include "Plugins/ArchVolatileRegs/x86/ArchVolatileRegs-x86.h" #if defined (__APPLE__) #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" +#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" @@ -85,17 +84,15 @@ SymbolFileSymtab::Initialize(); UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); - ArchDefaultUnwindPlan_x86_64::Initialize(); - ArchDefaultUnwindPlan_i386::Initialize(); - ArchVolatileRegs_x86::Initialize(); EmulateInstructionARM::Initialize (); + ABIMacOSX_i386::Initialize(); + ABIMacOSX_arm::Initialize(); + ABISysV_x86_64::Initialize(); #if defined (__APPLE__) //---------------------------------------------------------------------- // Apple/Darwin hosted plugins //---------------------------------------------------------------------- - ABIMacOSX_i386::Initialize(); - ABISysV_x86_64::Initialize(); DynamicLoaderMacOSXDYLD::Initialize(); SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); @@ -154,10 +151,10 @@ SymbolFileSymtab::Terminate(); UnwindAssembly_x86::Terminate(); UnwindAssemblyInstEmulation::Terminate(); - ArchDefaultUnwindPlan_i386::Terminate(); - ArchDefaultUnwindPlan_x86_64::Terminate(); - ArchVolatileRegs_x86::Terminate(); EmulateInstructionARM::Terminate (); + ABIMacOSX_i386::Terminate(); + ABIMacOSX_arm::Terminate(); + ABISysV_x86_64::Terminate(); #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=131193&r1=131192&r2=131193&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed May 11 13:39:18 2011 @@ -359,6 +359,7 @@ 26CE05C7115C36870022F371 /* ShellScript */, 26CE0591115C31C20022F371 /* Sources */, 26CE0592115C31C20022F371 /* Frameworks */, + 26C688951378864600407EDF /* Codesign Hack */, ); buildRules = ( ); @@ -397,6 +398,20 @@ /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ + 26C688951378864600407EDF /* Codesign Hack */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Codesign Hack"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "codesign --force --keychain ~/Library/Keychains/login.keychain --sign lldb_codesign \"$CODESIGNING_FOLDER_PATH\""; + }; 26CE05C7115C36870022F371 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -565,7 +580,6 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -595,7 +609,6 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -605,7 +618,6 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 131; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -635,7 +647,6 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; From johnny.chen at apple.com Wed May 11 19:32:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 May 2011 00:32:42 -0000 Subject: [Lldb-commits] [lldb] r131213 - in /lldb/trunk/test: ./ python_api/lldbutil/ python_api/lldbutil/frame/ python_api/lldbutil/iter/ python_api/lldbutil/process/ Message-ID: <20110512003242.459352A6C12C@llvm.org> Author: johnny Date: Wed May 11 19:32:41 2011 New Revision: 131213 URL: http://llvm.org/viewvc/llvm-project?rev=131213&view=rev Log: Add two utility functions: o get_parent_frame(frame) o get_args_as_string(frame) to lldbutil.py and create TestFrameUtils.py to exercise the utils. Plus re-arrange the test/python_api/lldbutil to have three directories for testing iteration, process stack traces, and the just added frame utils. Added: lldb/trunk/test/python_api/lldbutil/frame/ lldb/trunk/test/python_api/lldbutil/frame/Makefile - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/frame/main.c lldb/trunk/test/python_api/lldbutil/iter/ lldb/trunk/test/python_api/lldbutil/iter/Makefile - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py lldb/trunk/test/python_api/lldbutil/iter/main.cpp - copied unchanged from r131194, lldb/trunk/test/python_api/lldbutil/main.cpp lldb/trunk/test/python_api/lldbutil/process/ lldb/trunk/test/python_api/lldbutil/process/Makefile - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py lldb/trunk/test/python_api/lldbutil/process/main.cpp - copied unchanged from r131194, lldb/trunk/test/python_api/lldbutil/main.cpp Removed: lldb/trunk/test/python_api/lldbutil/Makefile lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py lldb/trunk/test/python_api/lldbutil/main.cpp Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131213&r1=131212&r2=131213&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed May 11 19:32:41 2011 @@ -409,6 +409,37 @@ # Utility functions related to Frames # =================================== +def get_parent_frame(frame): + """ + Returns the parent frame of the input frame object; None if not available. + """ + thread = frame.GetThread() + parent_found = False + for f in thread: + if parent_found: + return f + if f.GetFrameID() == frame.GetFrameID(): + parent_found = True + + # If we reach here, no parent has been found, return None. + return None + +def get_args_as_string(frame): + """ + Returns the args of the input frame object as a string. + """ + # arguments => True + # locals => False + # statics => False + # in_scope_only => True + vars = frame.GetVariables(True, False, False, True) # type of SBValueList + args = [] # list of strings + for var in vars: + args.append("(%s)%s=%s" % (var.GetTypeName(), + var.GetName(), + var.GetValue(frame))) + return "%s(%s)" % (frame.GetFunction().GetName(), ", ".join(args)) + def print_registers(frame, string_buffer = False): """Prints all the register sets of the frame.""" Removed: lldb/trunk/test/python_api/lldbutil/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/Makefile?rev=131212&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/Makefile (original) +++ lldb/trunk/test/python_api/lldbutil/Makefile (removed) @@ -1,6 +0,0 @@ -LEVEL = ../../make - -CXX_SOURCES := main.cpp -MAKE_DSYM :=NO - -include $(LEVEL)/Makefile.rules Removed: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=131212&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (removed) @@ -1,133 +0,0 @@ -""" -Test the iteration protocol for some lldb container objects. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * - -class LLDBIteratorTestCase(TestBase): - - mydir = "python_api/lldbutil" - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line numbers to break inside main(). - self.line1 = line_number('main.cpp', '// Set break point at this line.') - self.line2 = line_number('main.cpp', '// And that line.') - - def test_lldb_iter_1(self): - """Test module_iter works correctly for SBTarget -> SBModule.""" - self.buildDefault() - self.lldb_iter_1() - - def test_lldb_iter_2(self): - """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" - self.buildDefault() - self.lldb_iter_2() - - def test_lldb_iter_3(self): - """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" - self.buildDefault() - self.lldb_iter_3() - - def lldb_iter_1(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - - if not rc.Success() or not self.process.IsValid(): - self.fail("SBTarget.LaunchProcess() failed") - - from lldbutil import get_description - yours = [] - for i in range(target.GetNumModules()): - yours.append(target.GetModuleAtIndex(i)) - mine = [] - for m in target.module_iter(): - mine.append(m) - - self.assertTrue(len(yours) == len(mine)) - for i in range(len(yours)): - if self.TraceOn(): - print "yours[%d]='%s'" % (i, get_description(yours[i])) - print "mine[%d]='%s'" % (i, get_description(mine[i])) - self.assertTrue(yours[i] == mine[i], - "UUID+FileSpec of yours[{0}] and mine[{0}] matches".format(i)) - - def lldb_iter_2(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - - self.assertTrue(target.GetNumBreakpoints() == 2) - - from lldbutil import get_description - yours = [] - for i in range(target.GetNumBreakpoints()): - yours.append(target.GetBreakpointAtIndex(i)) - mine = [] - for m in target.breakpoint_iter(): - mine.append(m) - - self.assertTrue(len(yours) == len(mine)) - for i in range(len(yours)): - if self.TraceOn(): - print "yours[%d]='%s'" % (i, get_description(yours[i])) - print "mine[%d]='%s'" % (i, get_description(mine[i])) - self.assertTrue(yours[i] == mine[i], - "ID of yours[{0}] and mine[{0}] matches".format(i)) - - def lldb_iter_3(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - - if not rc.Success() or not self.process.IsValid(): - self.fail("SBTarget.LaunchProcess() failed") - - from lldbutil import print_stacktrace - stopped_due_to_breakpoint = False - for thread in self.process: - if self.TraceOn(): - print_stacktrace(thread) - ID = thread.GetThreadID() - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - stopped_due_to_breakpoint = True - for frame in thread: - self.assertTrue(frame.GetThread().GetThreadID() == ID) - if self.TraceOn(): - print frame - - self.assertTrue(stopped_due_to_breakpoint) - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Removed: lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py?rev=131212&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (removed) @@ -1,57 +0,0 @@ -""" -Test SBprocess and SBThread APIs with printing of the stack traces using lldbutil. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * - -class ThreadsStackTracesTestCase(TestBase): - - mydir = "python_api/lldbutil" - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.cpp', '// Set break point at this line.') - - def test_stack_traces(self): - """Test SBprocess and SBThread APIs with printing of the stack traces.""" - self.buildDefault() - self.break_and_print_stacktraces() - - def break_and_print_stacktraces(self): - """Break at main.cpp:68 and do a threads dump""" - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - - if not rc.Success() or not self.process.IsValid(): - self.fail("SBTarget.LaunchProcess() failed") - - import lldbutil - if self.process.GetState() != lldb.eStateStopped: - self.fail("Process should be in the 'stopped' state, " - "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) - - if self.TraceOn(): - lldbutil.print_stacktraces(self.process) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Removed: lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py?rev=131212&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (removed) @@ -1,72 +0,0 @@ -""" -Test the iteration protocol for frame registers. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * - -class RegistersIteratorTestCase(TestBase): - - mydir = "python_api/lldbutil" - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.line1 = line_number('main.cpp', '// Set break point at this line.') - - def test_iter_registers(self): - """Test iterator works correctly for lldbutil.iter_registers().""" - self.buildDefault() - self.iter_registers() - - def iter_registers(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - - if not rc.Success() or not self.process.IsValid(): - self.fail("SBTarget.LaunchProcess() failed") - - import lldbutil - for thread in self.process: - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - for frame in thread: - # Dump the registers of this frame using iter_registers(). - if self.TraceOn(): - print frame - - for kind in ["General Purpose Registers", - "Floating Point Registers", - "Exception State Registers"]: - REGs = lldbutil.get_registers(frame, kind) - if self.TraceOn(): - print "%s:" % kind - for reg in REGs: - self.assertTrue(reg.IsValid()) - if self.TraceOn(): - print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) - - # And these should also work. - self.assertTrue(lldbutil.get_GPRs(frame)) - self.assertTrue(lldbutil.get_FPRs(frame)) - self.assertTrue(lldbutil.get_ESRs(frame)) - break - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Copied: lldb/trunk/test/python_api/lldbutil/frame/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/Makefile?p2=lldb/trunk/test/python_api/lldbutil/frame/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/Makefile (original) +++ lldb/trunk/test/python_api/lldbutil/frame/Makefile Wed May 11 19:32:41 2011 @@ -1,6 +1,6 @@ -LEVEL = ../../make +LEVEL = ../../../make -CXX_SOURCES := main.cpp +C_SOURCES := main.c MAKE_DSYM :=NO include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=131213&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (added) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Wed May 11 19:32:41 2011 @@ -0,0 +1,62 @@ +""" +Test utility functions for the frame object. +""" + +import os +import unittest2 +import lldb +from lldbtest import * + +class FrameUtilsTestCase(TestBase): + + mydir = "python_api/lldbutil/frame" + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line = line_number('main.c', + "// Find the line number here.") + + def test_frame_utils(self): + """Test utility functions for the frame object.""" + self.buildDefault(dictionary={'C_SOURCES': 'main.c'}) + self.frame_utils() + + def frame_utils(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.c", self.line) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchSimple(None, None, os.getcwd()) + + if not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + self.assertTrue(self.process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + import lldbutil + thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + frame1 = thread.GetFrameAtIndex(1) + parent = lldbutil.get_parent_frame(frame0) + self.assertTrue(parent.IsValid() and parent.GetFrameID() == frame1.GetFrameID()) + frame0_args = lldbutil.get_args_as_string(frame0) + parent_args = lldbutil.get_args_as_string(parent) + self.assertTrue(frame0_args and parent_args) + if self.TraceOn(): + lldbutil.print_stacktrace(thread) + print "Current frame: %s" % frame0_args + print "Parent frame: %s" % parent_args + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/lldbutil/frame/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/main.c?rev=131213&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/main.c (added) +++ lldb/trunk/test/python_api/lldbutil/frame/main.c Wed May 11 19:32:41 2011 @@ -0,0 +1,47 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +int a(int); +int b(int); +int c(int); + +int a(int val) +{ + if (val <= 1) + return b(val); + else if (val >= 3) + return c(val); + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; // Find the line number here. +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) + printf("a(3) returns %d\n", A3); + + return 0; +} Copied: lldb/trunk/test/python_api/lldbutil/iter/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/Makefile?p2=lldb/trunk/test/python_api/lldbutil/iter/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/Makefile (original) +++ lldb/trunk/test/python_api/lldbutil/iter/Makefile Wed May 11 19:32:41 2011 @@ -1,4 +1,4 @@ -LEVEL = ../../make +LEVEL = ../../../make CXX_SOURCES := main.cpp MAKE_DSYM :=NO Copied: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?p2=lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py&p1=lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Wed May 11 19:32:41 2011 @@ -10,7 +10,7 @@ class LLDBIteratorTestCase(TestBase): - mydir = "python_api/lldbutil" + mydir = "python_api/lldbutil/iter" def setUp(self): # Call super's setUp(). Copied: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?p2=lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py&p1=lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Wed May 11 19:32:41 2011 @@ -10,7 +10,7 @@ class RegistersIteratorTestCase(TestBase): - mydir = "python_api/lldbutil" + mydir = "python_api/lldbutil/iter" def setUp(self): # Call super's setUp(). Removed: lldb/trunk/test/python_api/lldbutil/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/main.cpp?rev=131212&view=auto ============================================================================== --- lldb/trunk/test/python_api/lldbutil/main.cpp (original) +++ lldb/trunk/test/python_api/lldbutil/main.cpp (removed) @@ -1,128 +0,0 @@ -//===-- main.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 -#include -#include -#include -#include -#include - -pthread_t g_thread_1 = NULL; -pthread_t g_thread_2 = NULL; -pthread_t g_thread_3 = NULL; - -typedef enum { - eGet, - eAssign, - eClearBits -} MaskAction; - -uint32_t mask_access (MaskAction action, uint32_t mask = 0); - -uint32_t -mask_access (MaskAction action, uint32_t mask) -{ - static pthread_mutex_t g_mask_mutex = PTHREAD_MUTEX_INITIALIZER; - static uint32_t g_mask = 0; - ::pthread_mutex_lock (&g_mask_mutex); - switch (action) - { - case eGet: - break; - - case eAssign: - g_mask |= mask; - break; - - case eClearBits: - g_mask &= ~mask; - break; - } - uint32_t new_mask = g_mask; - ::pthread_mutex_unlock (&g_mask_mutex); - return new_mask; -} - -void * -thread_func (void *arg) -{ - uint32_t thread_index = *((uint32_t *)arg); - uint32_t thread_mask = (1u << (thread_index)); - printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); - - while (mask_access(eGet) & thread_mask) - { - // random micro second sleep from zero to 3 seconds - int usec = ::rand() % 3000000; - printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); - ::usleep (usec); - printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line. - } - printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); - return NULL; -} - - -int main (int argc, char const *argv[]) -{ - int err; - void *thread_result = NULL; - uint32_t thread_index_1 = 1; - uint32_t thread_index_2 = 2; - uint32_t thread_index_3 = 3; - uint32_t thread_mask_1 = (1u << thread_index_1); - uint32_t thread_mask_2 = (1u << thread_index_2); - uint32_t thread_mask_3 = (1u << thread_index_3); - - // Make a mask that will keep all threads alive - mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line. - - // Create 3 threads - err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); - err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); - err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); - - char line[64]; - while (mask_access(eGet) != 0) - { - printf ("Enter thread index to kill or ENTER for all:\n"); - fflush (stdout); - // Kill threads by index, or ENTER for all threads - - if (fgets (line, sizeof(line), stdin)) - { - if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') - { - printf ("Exiting all threads...\n"); - break; - } - int32_t index = strtoul (line, NULL, 0); - switch (index) - { - case 1: mask_access (eClearBits, thread_mask_1); break; - case 2: mask_access (eClearBits, thread_mask_2); break; - case 3: mask_access (eClearBits, thread_mask_3); break; - } - continue; - } - - break; - } - - // Clear all thread bits to they all exit - mask_access (eClearBits, UINT32_MAX); - - // Join all of our threads - err = ::pthread_join (g_thread_1, &thread_result); - err = ::pthread_join (g_thread_2, &thread_result); - err = ::pthread_join (g_thread_3, &thread_result); - - return 0; -} Copied: lldb/trunk/test/python_api/lldbutil/process/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/Makefile?p2=lldb/trunk/test/python_api/lldbutil/process/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/Makefile (original) +++ lldb/trunk/test/python_api/lldbutil/process/Makefile Wed May 11 19:32:41 2011 @@ -1,4 +1,4 @@ -LEVEL = ../../make +LEVEL = ../../../make CXX_SOURCES := main.cpp MAKE_DSYM :=NO Copied: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?p2=lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py&p1=lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py&r1=131194&r2=131213&rev=131213&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Wed May 11 19:32:41 2011 @@ -10,7 +10,7 @@ class ThreadsStackTracesTestCase(TestBase): - mydir = "python_api/lldbutil" + mydir = "python_api/lldbutil/process" def setUp(self): # Call super's setUp(). From jingham at apple.com Wed May 11 20:12:29 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 12 May 2011 01:12:29 -0000 Subject: [Lldb-commits] [lldb] r131217 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20110512011229.0ED7B2A6C12C@llvm.org> Author: jingham Date: Wed May 11 20:12:28 2011 New Revision: 131217 URL: http://llvm.org/viewvc/llvm-project?rev=131217&view=rev Log: Make sure you have an executable module before trying to print its name. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=131217&r1=131216&r2=131217&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed May 11 20:12:28 2011 @@ -97,7 +97,10 @@ } else { - s->PutCString (GetExecutableModule()->GetFileSpec().GetFilename().GetCString()); + if (GetExecutableModule()) + s->PutCString (GetExecutableModule()->GetFileSpec().GetFilename().GetCString()); + else + s->PutCString ("No executable module."); } } From gclayton at apple.com Wed May 11 20:34:06 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 May 2011 01:34:06 -0000 Subject: [Lldb-commits] [lldb] r131218 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110512013406.2FEA32A6C12C@llvm.org> Author: gclayton Date: Wed May 11 20:34:06 2011 New Revision: 131218 URL: http://llvm.org/viewvc/llvm-project?rev=131218&view=rev Log: Remove the custom working directory form the xcscheme. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=131218&r1=131217&r2=131218&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed May 11 20:34:06 2011 @@ -75,7 +75,7 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" - useCustomWorkingDirectory = "YES" + useCustomWorkingDirectory = "NO" customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "YES"> @@ -88,6 +88,12 @@ ReferencedContainer = "container:lldb.xcodeproj"> + + + + Author: jingham Date: Wed May 11 21:06:14 2011 New Revision: 131219 URL: http://llvm.org/viewvc/llvm-project?rev=131219&view=rev Log: Target::EvaluateExpression should suppress stop hooks. Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=131219&r1=131218&r2=131219&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Wed May 11 21:06:14 2011 @@ -591,6 +591,20 @@ size_t GetStopHookSize(); + bool + SetSuppresStopHooks (bool suppress) + { + bool old_value = m_suppress_stop_hooks; + m_suppress_stop_hooks = suppress; + return old_value; + } + + bool + GetSuppressStopHooks () + { + return m_suppress_stop_hooks; + } + // StopHookSP & // GetStopHookByIndex (size_t index); // @@ -709,6 +723,7 @@ typedef std::map StopHookCollection; StopHookCollection m_stop_hooks; lldb::user_id_t m_stop_hook_next_id; + bool m_suppress_stop_hooks; //------------------------------------------------------------------ // Methods. Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=131219&r1=131218&r2=131219&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed May 11 21:06:14 2011 @@ -59,7 +59,8 @@ m_scratch_ast_context_ap (NULL), m_persistent_variables (), m_stop_hooks (), - m_stop_hook_next_id (0) + m_stop_hook_next_id (0), + m_suppress_stop_hooks (false) { SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed"); SetEventName (eBroadcastBitModulesLoaded, "modules-loaded"); @@ -900,6 +901,11 @@ ExecutionResults execution_results = eExecutionSetupError; result_valobj_sp.reset(); + + // We shouldn't run stop hooks in expressions. + // Be sure to reset this if you return anywhere within this function. + bool old_suppress_value = m_suppress_stop_hooks; + m_suppress_stop_hooks = true; ExecutionContext exe_ctx; if (frame) @@ -1002,6 +1008,9 @@ result_valobj_sp); } } + + m_suppress_stop_hooks = old_suppress_value; + return execution_results; } @@ -1068,6 +1077,9 @@ void Target::RunStopHooks () { + if (m_suppress_stop_hooks) + return; + if (!m_process_sp) return; From gclayton at apple.com Wed May 11 21:14:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 May 2011 02:14:57 -0000 Subject: [Lldb-commits] [lldb] r131221 - in /lldb/trunk: include/lldb/Target/ABI.h lldb.xcodeproj/project.pbxproj source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110512021457.22EA32A6C12C@llvm.org> Author: gclayton Date: Wed May 11 21:14:56 2011 New Revision: 131221 URL: http://llvm.org/viewvc/llvm-project?rev=131221&view=rev Log: Cleaned up the ABI::PrepareTrivialCall() function to take three argument pointers: virtual bool PrepareTrivialCall (Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t *arg1_ptr, lldb::addr_t *arg2_ptr, lldb::addr_t *arg3_ptr) const = 0; Prior to this it was: virtual bool PrepareTrivialCall (Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, lldb::addr_t *this_arg, lldb::addr_t *cmd_arg) const = 0; This was because the function that called this slowly added more features to be able to call a C++ member function that might have a "this" pointer, and then later added "self + cmd" support for objective C. Cleaning this code up and the code that calls it makes it easier to implement the functions for new targets. The MacOSX_arm::PrepareTrivialCall() is now filled in and ready for testing. Modified: lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Wed May 11 21:14:56 2011 @@ -34,9 +34,9 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const = 0; + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const = 0; virtual bool GetArgumentValues (Thread &thread, Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed May 11 21:14:56 2011 @@ -2870,7 +2870,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh $SRCROOT/scripts/build-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $CONFIGURATION_BUILD_DIR \"\"\n"; + shellScript = "$SRCROOT/scripts/build-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $CONFIGURATION_BUILD_DIR \"\"\n"; }; 9A19ACE2116563A700E0D453 /* Finish swig wrapper classes (lldb) */ = { isa = PBXShellScriptBuildPhase; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Wed May 11 21:14:56 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/Error.h" #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/Symbol/ClangASTContext.h" @@ -62,280 +63,64 @@ bool ABIMacOSX_arm::PrepareTrivialCall (Thread &thread, addr_t sp, - addr_t functionAddress, - addr_t returnAddress, - addr_t arg, - addr_t *this_arg, - addr_t *cmd_arg) const -{ -// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); -// if (!reg_ctx) -// return false; -//#define CHAIN_EBP -// -//#ifndef CHAIN_EBP -// uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); -//#endif -// uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); -// uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); -// -// // Make room for the argument(s) on the stack -// -// if (this_arg && cmd_arg) -// sp -= 12; -// else if (this_arg) -// sp -= 8; -// else -// sp -= 4; -// -// // Align the SP -// -// sp &= ~(0xfull); // 16-byte alignment -// -// // Write the argument on the stack -// -// Error error; -// -// if (this_arg && cmd_arg) -// { -// uint32_t cmd_argU32 = *cmd_arg & 0xffffffffull; -// uint32_t this_argU32 = *this_arg & 0xffffffffull; -// uint32_t argU32 = arg & 0xffffffffull; -// -// if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) -// return false; -// if (thread.GetProcess().WriteMemory(sp + 4, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) -// return false; -// if (thread.GetProcess().WriteMemory(sp + 8, &argU32, sizeof(argU32), error) != sizeof(argU32)) -// return false; -// } -// else if (this_arg) -// { -// uint32_t this_argU32 = *this_arg & 0xffffffffull; -// uint32_t argU32 = arg & 0xffffffffull; -// -// if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) -// return false; -// if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) -// return false; -// } -// else -// { -// uint32_t argU32 = arg & 0xffffffffull; -// -// if (thread.GetProcess().WriteMemory (sp, &argU32, sizeof(argU32), error) != sizeof(argU32)) -// return false; -// } -// -// // The return address is pushed onto the stack. -// -// sp -= 4; -// uint32_t returnAddressU32 = returnAddress; -// if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) -// return false; -// -// // %esp is set to the actual stack value. -// -// if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) -// return false; -// -//#ifndef CHAIN_EBP -// // %ebp is set to a fake value, in our case 0x0x00000000 -// -// if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) -// return false; -//#endif -// -// // %eip is set to the address of the called function. -// -// if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) -// return false; -// -// return true; - return false; -} + addr_t function_addr, + addr_t return_addr, + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const +{ + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; + + const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); -bool -ABIMacOSX_arm::PrepareNormalCall (Thread &thread, - addr_t sp, - addr_t functionAddress, - addr_t returnAddress, - ValueList &args) const -{ -// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); -// if (!reg_ctx) -// return false; -// Error error; -// uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); -// uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); -// uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); -// -// // Do the argument layout -// -// std::vector argLayout; // 4-byte chunks, as discussed in the ABI Function Call Guide -// -// size_t numArgs = args.GetSize(); -// size_t index; -// -// for (index = 0; index < numArgs; ++index) -// { -// Value *val = args.GetValueAtIndex(index); -// -// if (!val) -// return false; -// -// switch (val->GetValueType()) -// { -// case Value::eValueTypeScalar: -// { -// Scalar &scalar = val->GetScalar(); -// switch (scalar.GetType()) -// { -// case Scalar::e_void: -// default: -// 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: -// { -// uint64_t data = scalar.ULongLong(); -// -// switch (scalar.GetByteSize()) -// { -// default: -// return false; -// case 1: -// argLayout.push_back((uint32_t)(data & 0xffull)); -// break; -// case 2: -// argLayout.push_back((uint32_t)(data & 0xffffull)); -// break; -// case 4: -// argLayout.push_back((uint32_t)(data & 0xffffffffull)); -// break; -// case 8: -// argLayout.push_back((uint32_t)(data & 0xffffffffull)); -// argLayout.push_back((uint32_t)(data >> 32)); -// break; -// } -// } -// break; -// case Scalar::e_float: -// { -// float data = scalar.Float(); -// uint32_t dataRaw = *((uint32_t*)(&data)); -// argLayout.push_back(dataRaw); -// } -// break; -// case Scalar::e_double: -// { -// double data = scalar.Double(); -// uint32_t *dataRaw = ((uint32_t*)(&data)); -// argLayout.push_back(dataRaw[0]); -// argLayout.push_back(dataRaw[1]); -// } -// break; -// case Scalar::e_long_double: -// { -// long double data = scalar.Double(); -// uint32_t *dataRaw = ((uint32_t*)(&data)); -// while ((argLayout.size() * 4) & 0xf) -// argLayout.push_back(0); -// argLayout.push_back(dataRaw[0]); -// argLayout.push_back(dataRaw[1]); -// argLayout.push_back(dataRaw[2]); -// argLayout.push_back(dataRaw[3]); -// } -// break; -// } -// } -// break; -// case Value::eValueTypeHostAddress: -// switch (val->GetContextType()) -// { -// default: -// return false; -// case Value::eContextTypeClangType: -// { -// void *val_type = val->GetClangType(); -// uint32_t cstr_length; -// -// if (ClangASTContext::IsCStringType (val_type, cstr_length)) -// { -// const char *cstr = (const char*)val->GetScalar().ULongLong(); -// cstr_length = strlen(cstr); -// -// // Push the string onto the stack immediately. -// -// sp -= (cstr_length + 1); -// -// if (thread.GetProcess().WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1)) -// return false; -// -// // Put the address of the string into the argument array. -// -// argLayout.push_back((uint32_t)(sp & 0xffffffff)); -// } -// else -// { -// return false; -// } -// } -// break; -// } -// break; -// case Value::eValueTypeFileAddress: -// case Value::eValueTypeLoadAddress: -// default: -// return false; -// } -// } -// -// // Make room for the arguments on the stack -// -// sp -= 4 * argLayout.size(); -// -// // Align the SP -// -// sp &= ~(0xfull); // 16-byte alignment -// -// // Write the arguments on the stack -// -// size_t numChunks = argLayout.size(); -// -// for (index = 0; index < numChunks; ++index) -// if (thread.GetProcess().WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t)) -// return false; -// -// // The return address is pushed onto the stack. -// -// sp -= 4; -// uint32_t returnAddressU32 = returnAddress; -// if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) -// return false; -// -// // %esp is set to the actual stack value. -// -// if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) -// return false; -// -// // %ebp is set to a fake value, in our case 0x0x00000000 -// -// if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) -// return false; -// -// // %eip is set to the address of the called function. -// -// if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) -// return false; -// -// return true; - return false; + RegisterValue reg_value; + + if (arg1_ptr) + { + reg_value.SetUInt32(*arg1_ptr); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r0"), reg_value)) + return false; + } + + if (arg2_ptr) + { + assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + + reg_value.SetUInt32(*arg2_ptr); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r1"), reg_value)) + return false; + } + + if (arg3_ptr) + { + assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + assert (arg2_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + + reg_value.SetUInt32(*arg3_ptr); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r2"), reg_value)) + return false; + } + + // Set "lr" to the return address into "lr" + if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) + return false; + + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) + return false; + + // Set "pc" to the address requested + if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, function_addr)) + return false; + + return true; } + static bool ReadIntegerArgument (Scalar &scalar, unsigned int bit_width, Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Wed May 11 21:14:56 2011 @@ -28,18 +28,11 @@ virtual bool PrepareTrivialCall (lldb_private::Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, + lldb::addr_t func_addr, lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const; - - virtual bool - PrepareNormalCall (lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb_private::ValueList &args) const; + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const; virtual bool GetArgumentValues (lldb_private::Thread &thread, Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Wed May 11 21:14:56 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/UnwindPlan.h" @@ -57,93 +58,105 @@ bool ABIMacOSX_i386::PrepareTrivialCall (Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const + lldb::addr_t func_addr, + lldb::addr_t return_addr, + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const +// lldb::addr_t arg, +// lldb::addr_t *this_arg, +// lldb::addr_t *cmd_arg) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) return false; -#define CHAIN_EBP - -#ifndef CHAIN_EBP - uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); -#endif - uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + // When writing a register value down to memory, the register info used + // to write memory just needs to have the correct size of a 32 bit register, + // the actual register it pertains to is not important, just the size needs + // to be correct. Here we use "eax"... + const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); + // Make room for the argument(s) on the stack + + Error error; + RegisterValue reg_value; - if (this_arg && cmd_arg) + // Write any arguments onto the stack + if (arg1_ptr && arg2_ptr && arg3_ptr) sp -= 12; - else if (this_arg) + else if (arg1_ptr && arg2_ptr) sp -= 8; - else + else if (arg1_ptr) sp -= 4; - - // Align the SP - + + // Align the SP sp &= ~(0xfull); // 16-byte alignment - // Write the argument on the stack - - Error error; - - if (this_arg && cmd_arg) + if (arg1_ptr) { - uint32_t cmd_argU32 = *cmd_arg & 0xffffffffull; - uint32_t this_argU32 = *this_arg & 0xffffffffull; - uint32_t argU32 = arg & 0xffffffffull; - - if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) - return false; - if (thread.GetProcess().WriteMemory(sp + 4, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) - return false; - if (thread.GetProcess().WriteMemory(sp + 8, &argU32, sizeof(argU32), error) != sizeof(argU32)) - return false; - } - else if (this_arg) - { - uint32_t this_argU32 = *this_arg & 0xffffffffull; - uint32_t argU32 = arg & 0xffffffffull; - - if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) + reg_value.SetUInt32(*arg1_ptr); + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) return false; - if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) - return false; - } - else - { - uint32_t argU32 = arg & 0xffffffffull; - if (thread.GetProcess().WriteMemory (sp, &argU32, sizeof(argU32), error) != sizeof(argU32)) - return false; + if (arg2_ptr) + { + assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + reg_value.SetUInt32(*arg2_ptr); + // The register info used to write memory just needs to have the correct + // size of a 32 bit register, the actual register it pertains to is not + // important, just the size needs to be correct. Here we use "eax"... + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp + 4, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) + return false; + + if (arg3_ptr) + { + assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + assert (arg2_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + reg_value.SetUInt32(*arg3_ptr); + // The register info used to write memory just needs to have the correct + // size of a 32 bit register, the actual register it pertains to is not + // important, just the size needs to be correct. Here we use "eax"... + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp + 8, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) + return false; + } + } } - // The return address is pushed onto the stack. + // The return address is pushed onto the stack (yes after we just set the + // alignment above!). sp -= 4; - uint32_t returnAddressU32 = returnAddress; - if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) + reg_value.SetUInt32(return_addr); + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) return false; // %esp is set to the actual stack value. - if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) - return false; - -#ifndef CHAIN_EBP - // %ebp is set to a fake value, in our case 0x0x00000000 - - if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) + if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) return false; -#endif // %eip is set to the address of the called function. - if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) + if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, func_addr)) return false; return true; @@ -152,17 +165,17 @@ bool ABIMacOSX_i386::PrepareNormalCall (Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, + lldb::addr_t func_addr, + lldb::addr_t return_addr, ValueList &args) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) return false; Error error; - uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); - uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + uint32_t fp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); + uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); // Do the argument layout @@ -307,23 +320,23 @@ // The return address is pushed onto the stack. sp -= 4; - uint32_t returnAddressU32 = returnAddress; + uint32_t returnAddressU32 = return_addr; if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) return false; // %esp is set to the actual stack value. - if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) return false; // %ebp is set to a fake value, in our case 0x0x00000000 - if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) + if (!reg_ctx->WriteRegisterFromUnsigned(fp_reg_num, 0x00000000)) return false; // %eip is set to the address of the called function. - if (!reg_ctx->WriteRegisterFromUnsigned(eipID, functionAddress)) + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, func_addr)) return false; return true; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Wed May 11 21:14:56 2011 @@ -144,17 +144,17 @@ virtual bool PrepareTrivialCall (lldb_private::Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const; + lldb::addr_t func_addr, + lldb::addr_t return_addr, + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const; virtual bool PrepareNormalCall (lldb_private::Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, + lldb::addr_t func_addr, + lldb::addr_t return_addr, lldb_private::ValueList &args) const; virtual bool Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Wed May 11 21:14:56 2011 @@ -15,6 +15,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/UnwindPlan.h" @@ -60,116 +61,77 @@ bool ABISysV_x86_64::PrepareTrivialCall (Thread &thread, lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const + lldb::addr_t func_addr, + lldb::addr_t return_addr, + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); if (log) - log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n functionAddress = 0x%llx\n returnAddress = 0x%llx\n arg = 0x%llx\n this_arg = %p(0x%llx)\n cmd_arg = %p(0x%llx)\n)", + log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n func_addr = 0x%llx\n return_addr = 0x%llx\n arg1_ptr = %p (0x%llx)\n arg2_ptr = %p (0x%llx)\n arg3_ptr = %p (0x%llx)\n)", (void*)&thread, (uint64_t)sp, - (uint64_t)functionAddress, - (uint64_t)returnAddress, - (void*)arg, - this_arg, - this_arg ? (uint64_t)*this_arg : (uint64_t)0, - cmd_arg, - cmd_arg ? (uint64_t)*cmd_arg : (uint64_t)0); + (uint64_t)func_addr, + (uint64_t)return_addr, + arg1_ptr, arg1_ptr ? (uint64_t)*arg1_ptr : (uint64_t) 0, + arg2_ptr, arg2_ptr ? (uint64_t)*arg2_ptr : (uint64_t) 0, + arg3_ptr, arg3_ptr ? (uint64_t)*arg3_ptr : (uint64_t) 0); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) return false; - - uint32_t rdiID = reg_ctx->GetRegisterInfoByName("rdi", 0)->kinds[eRegisterKindLLDB]; -#define CHAIN_RBP - -#ifndef CHAIN_RBP - uint32_t rbpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); -#endif - - uint32_t ripID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - uint32_t rspID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - - // The argument is in %rdi, and not on the stack. - if (cmd_arg) - { - if (log) - log->PutCString("The trivial call has a self and a _cmd pointer"); - - uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; - uint32_t rdxID = reg_ctx->GetRegisterInfoByName("rdx", 0)->kinds[eRegisterKindLLDB]; - - if (log) - log->Printf("About to write 'self' (0x%llx) into RDI", (uint64_t)*this_arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg)) - return false; - - if (log) - log->Printf("About to write '_cmd' (0x%llx) into RSI", (uint64_t)*cmd_arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *cmd_arg)) - return false; - - if (log) - log->Printf("About to write the argument (0x%llx) into RDX", (uint64_t)arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rdxID, arg)) - return false; - } - else if (this_arg) - { - if (log) - log->PutCString("The trivial call has a this pointer"); - - uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; - - if (log) - log->Printf("About to write 'this' (0x%llx) into RDI", (uint64_t)*this_arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg)) - return false; - - if (log) - log->Printf("About to write the argument (0x%llx) into RSI", (uint64_t)arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, arg)) - return false; - } - else + RegisterValue reg_value; + if (arg1_ptr) { if (log) - log->PutCString("The trivial call does not have a this pointer"); - - if (log) - log->Printf("About to write the argument (0x%llx) into RDI", (uint64_t)arg); - - if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, arg)) + log->Printf("About to write arg1 (0x%llx) into RDI", (uint64_t)*arg1_ptr); + + reg_value.SetUInt64(*arg1_ptr); + if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rdi", 0), reg_value)) return false; + + if (arg2_ptr) + { + if (log) + log->Printf("About to write arg2 (0x%llx) into RSI", (uint64_t)*arg2_ptr); + + reg_value.SetUInt64(*arg2_ptr); + if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rsi", 0), reg_value)) + return false; + + if (arg3_ptr) + { + if (log) + log->Printf("About to write arg3 (0x%llx) into RDX", (uint64_t)*arg3_ptr); + reg_value.SetUInt64(*arg3_ptr); + if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rdx", 0), reg_value)) + return false; + } + } } + // First, align the SP - + if (log) log->Printf("16-byte aligning SP: 0x%llx to 0x%llx", (uint64_t)sp, (uint64_t)(sp & ~0xfull)); sp &= ~(0xfull); // 16-byte alignment - // The return address is pushed onto the stack. - + // The return address is pushed onto the stack (yes after the alignment...) sp -= 8; - uint64_t returnAddressU64 = returnAddress; - Error error; - + + reg_value.SetUInt64 (return_addr); + if (log) - log->Printf("Pushing the return address onto the stack: new SP 0x%llx, return address 0x%llx", (uint64_t)sp, (uint64_t)returnAddressU64); - - if (thread.GetProcess().WriteMemory (sp, &returnAddressU64, sizeof(returnAddressU64), error) != sizeof(returnAddressU64)) + log->Printf("Pushing the return address onto the stack: new SP 0x%llx, return address 0x%llx", (uint64_t)sp, (uint64_t)return_addr); + + const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfoByName("rip"); + Error error (reg_ctx->WriteRegisterValueToMemory(pc_reg_info, sp, pc_reg_info->byte_size, reg_value)); + if (error.Fail()) return false; // %rsp is set to the actual stack value. @@ -177,37 +139,23 @@ if (log) log->Printf("Writing SP (0x%llx) down", (uint64_t)sp); - if (!reg_ctx->WriteRegisterFromUnsigned(rspID, sp)) + reg_value.SetUInt64(sp); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("rsp"), reg_value)) return false; -#ifndef CHAIN_RBP - // %rbp is set to a fake value, in our case 0x0000000000000000. - - if (!reg_ctx->WriteRegisterFromUnsigned(rbpID, 0x000000000000000)) - return false; -#endif - // %rip is set to the address of the called function. if (log) - log->Printf("Writing new IP (0x%llx) down", (uint64_t)functionAddress); + log->Printf("Writing new IP (0x%llx) down", (uint64_t)func_addr); - if (!reg_ctx->WriteRegisterFromUnsigned(ripID, functionAddress)) + reg_value.SetUInt64(func_addr); + + if (!reg_ctx->WriteRegister(pc_reg_info, func_addr)) return false; return true; } -bool -ABISysV_x86_64::PrepareNormalCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - ValueList &args) const -{ - return false; -} - static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, bool is_signed, Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Wed May 11 21:14:56 2011 @@ -172,16 +172,9 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) const; - - virtual bool - PrepareNormalCall (lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - lldb_private::ValueList &args) const; + lldb::addr_t *arg1_ptr, + lldb::addr_t *arg2_ptr, + lldb::addr_t *arg3_ptr) const; virtual bool GetArgumentValues (lldb_private::Thread &thread, Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131221&r1=131220&r2=131221&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed May 11 21:14:56 2011 @@ -110,14 +110,39 @@ m_function_addr = function; lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); - if (!abi->PrepareTrivialCall(thread, - m_function_sp, - FunctionLoadAddr, - StartLoadAddr, - m_arg_addr, - this_arg, - cmd_arg)) - return; + if (this_arg && cmd_arg) + { + if (!abi->PrepareTrivialCall (thread, + m_function_sp, + FunctionLoadAddr, + StartLoadAddr, + this_arg, + cmd_arg, + &m_arg_addr)) + return; + } + else if (this_arg) + { + if (!abi->PrepareTrivialCall (thread, + m_function_sp, + FunctionLoadAddr, + StartLoadAddr, + this_arg, + &m_arg_addr, + NULL)) + return; + } + else + { + if (!abi->PrepareTrivialCall (thread, + m_function_sp, + FunctionLoadAddr, + StartLoadAddr, + &m_arg_addr, + NULL, + NULL)) + return; + } ReportRegisterState ("Function call was set up. Register state was:"); From johnny.chen at apple.com Thu May 12 13:48:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 May 2011 18:48:11 -0000 Subject: [Lldb-commits] [lldb] r131236 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110512184811.8F2A92A6C12C@llvm.org> Author: johnny Date: Thu May 12 13:48:11 2011 New Revision: 131236 URL: http://llvm.org/viewvc/llvm-project?rev=131236&view=rev Log: Construction of the RegisterReaderArg instance should happen after we have a valid base_addr, not before. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131236&r1=131235&r2=131236&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu May 12 13:48:11 2011 @@ -168,13 +168,13 @@ { addr_t base_addr = LLDB_INVALID_ADDRESS; - RegisterReaderArg rra(base_addr + EDInstByteSize(m_inst), m_disassembler); - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) base_addr = GetAddress().GetLoadAddress (exe_ctx->target); if (base_addr == LLDB_INVALID_ADDRESS) base_addr = GetAddress().GetFileAddress (); + RegisterReaderArg rra(base_addr + EDInstByteSize(m_inst), m_disassembler); + printTokenized = true; // Handle the opcode column. From mminutoli at gmail.com Thu May 12 16:39:27 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 12 May 2011 23:39:27 +0200 Subject: [Lldb-commits] [PATCH 1/4] Fixed includes Message-ID: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> Headers have been moved to /includes/lldb/Interpreter. This patch reflects this change. --- source/Interpreter/OptionGroupArchitecture.cpp | 2 +- source/Interpreter/OptionGroupBoolean.cpp | 2 +- source/Interpreter/OptionGroupFile.cpp | 2 +- source/Interpreter/OptionGroupFormat.cpp | 2 +- source/Interpreter/OptionGroupOutputFile.cpp | 2 +- source/Interpreter/OptionGroupUInt64.cpp | 2 +- source/Interpreter/OptionGroupUUID.cpp | 2 +- .../Interpreter/OptionGroupValueObjectDisplay.cpp | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp index a523f3c..9446f2e 100644 --- a/source/Interpreter/OptionGroupArchitecture.cpp +++ b/source/Interpreter/OptionGroupArchitecture.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupArchitecture.h" +#include "lldb/Interpreter/OptionGroupArchitecture.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp index f1fd62b..f5403cf 100644 --- a/source/Interpreter/OptionGroupBoolean.cpp +++ b/source/Interpreter/OptionGroupBoolean.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupBoolean.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp index 86acede..b16399a 100644 --- a/source/Interpreter/OptionGroupFile.cpp +++ b/source/Interpreter/OptionGroupFile.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupFile.h" +#include "lldb/Interpreter/OptionGroupFile.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp index 213255e..a42099d 100644 --- a/source/Interpreter/OptionGroupFormat.cpp +++ b/source/Interpreter/OptionGroupFormat.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupFormat.h" +#include "lldb/Interpreter/OptionGroupFormat.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp index 2a4e8dc..541c8b4 100644 --- a/source/Interpreter/OptionGroupOutputFile.cpp +++ b/source/Interpreter/OptionGroupOutputFile.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupOutputFile.h" +#include "lldb/Interpreter/OptionGroupOutputFile.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp index d0ab1ef..76d0260 100644 --- a/source/Interpreter/OptionGroupUInt64.cpp +++ b/source/Interpreter/OptionGroupUInt64.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupUInt64.h" +#include "lldb/Interpreter/OptionGroupUInt64.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp index e436f61..b1b3c77 100644 --- a/source/Interpreter/OptionGroupUUID.cpp +++ b/source/Interpreter/OptionGroupUUID.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupUUID.h" +#include "lldb/Interpreter/OptionGroupUUID.h" // C Includes // C++ Includes diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp index 3150ea7..edc5dbb 100644 --- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupValueObjectDisplay.h" +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" // C Includes // C++ Includes @@ -123,4 +123,4 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp // If we don't have any targets, then dynamic values won't do us much good. use_dynamic = lldb::eNoDynamicValues; } -} \ No newline at end of file +} -- 1.7.3.4 From mminutoli at gmail.com Thu May 12 16:39:28 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 12 May 2011 23:39:28 +0200 Subject: [Lldb-commits] [PATCH 2/4] added missing header. In-Reply-To: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> References: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305236370-28191-2-git-send-email-mminutoli@gmail.com> PATH_MAX is in limits.h on Linux. --- .../Process/gdb-remote/GDBRemoteCommunication.cpp | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 93e4166..ac99855 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -11,6 +11,7 @@ #include "GDBRemoteCommunication.h" // C Includes +#include #include // C++ Includes -- 1.7.3.4 From mminutoli at gmail.com Thu May 12 16:39:29 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 12 May 2011 23:39:29 +0200 Subject: [Lldb-commits] [PATCH 3/4] Removed launch in new terminal In-Reply-To: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> References: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305236370-28191-3-git-send-email-mminutoli@gmail.com> This method has been removed from the API. This fix the compilation breakage due to its presence. --- source/Host/common/Host.cpp | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index a665472..b699bc8 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -1173,19 +1173,4 @@ LaunchApplication (const FileSpec &app_file_spec) return LLDB_INVALID_PROCESS_ID; } -lldb::pid_t -Host::LaunchInNewTerminal -( - const char *tty_name, - const char **argv, - const char **envp, - const char *working_dir, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr -) -{ - return LLDB_INVALID_PROCESS_ID; -} - #endif -- 1.7.3.4 From mminutoli at gmail.com Thu May 12 16:39:30 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 12 May 2011 23:39:30 +0200 Subject: [Lldb-commits] [PATCH 4/4] Fix API changes in PlatformLinux and RegisterContext. In-Reply-To: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> References: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305236370-28191-4-git-send-email-mminutoli@gmail.com> This patch add a "fake" attach waiting for a real implementation and solve the build break due to the lack of this method. It also propose a solution to the API changes in RegisterContext. I upgraded also the the python version in the makefile. My linux installation has python2.7 and AFAIK also the latest ubuntu has this version of python so maybe is worth upgrading. --- Makefile | 2 +- source/Plugins/Platform/Linux/PlatformLinux.cpp | 14 ++++++++++- source/Plugins/Platform/Linux/PlatformLinux.h | 6 ++++- source/Plugins/Process/Linux/ProcessMonitor.cpp | 15 ++++++----- source/Plugins/Process/Linux/ProcessMonitor.h | 4 +- .../Process/Linux/RegisterContextLinux_i386.cpp | 25 +++++++++++++++++++- .../Process/Linux/RegisterContextLinux_i386.h | 12 +++++++++ .../Process/Linux/RegisterContextLinux_x86_64.cpp | 5 ++++ .../Process/Linux/RegisterContextLinux_x86_64.h | 12 +++++++++ 9 files changed, 82 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index a84e244..4357ccc 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ LEVEL := $(LLDB_LEVEL)/../.. include $(LEVEL)/Makefile.common # Set Python include directory -PYTHON_INC_DIR = /usr/include/python2.6 +PYTHON_INC_DIR = /usr/include/python2.7/ # Set common LLDB build flags. CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp index 379a08e..f37a312 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -192,7 +192,7 @@ PlatformLinux::~PlatformLinux() } bool -PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { return Host::GetProcessInfo (pid, process_info); } @@ -247,3 +247,15 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, bp_site->SetTrapOpcode(opcode, opcode_size); return opcode_size; } + +lldb::ProcessSP +PlatformLinux::Attach(lldb::pid_t pid, + Debugger &debugger, + Target *target, + Listener &listener, + Error &error) +{ + ProcessSP processSP; + assert(!"Not implemented yet!"); + return processSP; +} diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h index bb9f62c..cbe18eb 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/source/Plugins/Platform/Linux/PlatformLinux.h @@ -85,7 +85,7 @@ namespace lldb_private { const UUID* uuid, FileSpec &local_file); virtual bool - GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info); + GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info); virtual bool GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch); @@ -94,6 +94,10 @@ namespace lldb_private { GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site); + virtual lldb::ProcessSP + Attach(lldb::pid_t pid, Debugger &debugger, Target *target, + Listener &listener, Error &error); + protected: diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp index 48a57a8..f482c01 100644 --- a/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -20,6 +20,7 @@ // C++ Includes // Other libraries and framework includes #include "lldb/Core/Error.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Host.h" #include "lldb/Target/Thread.h" @@ -221,7 +222,7 @@ WriteOperation::Execute(ProcessMonitor *monitor) class ReadRegOperation : public Operation { public: - ReadRegOperation(unsigned offset, Scalar &value, bool &result) + ReadRegOperation(unsigned offset, RegisterValue &value, bool &result) : m_offset(offset), m_value(value), m_result(result) { } @@ -229,7 +230,7 @@ public: private: unsigned m_offset; - Scalar &m_value; + RegisterValue &m_value; bool &m_result; }; @@ -257,7 +258,7 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) class WriteRegOperation : public Operation { public: - WriteRegOperation(unsigned offset, const Scalar &value, bool &result) + WriteRegOperation(unsigned offset, const RegisterValue &value, bool &result) : m_offset(offset), m_value(value), m_result(result) { } @@ -265,7 +266,7 @@ public: private: unsigned m_offset; - const Scalar &m_value; + const RegisterValue &m_value; bool &m_result; }; @@ -274,7 +275,7 @@ WriteRegOperation::Execute(ProcessMonitor *monitor) { lldb::pid_t pid = monitor->GetPID(); - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.ULong())) + if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) m_result = false; else m_result = true; @@ -1097,7 +1098,7 @@ ProcessMonitor::WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, } bool -ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value) +ProcessMonitor::ReadRegisterValue(unsigned offset, RegisterValue &value) { bool result; ReadRegOperation op(offset, value, result); @@ -1106,7 +1107,7 @@ ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value) } bool -ProcessMonitor::WriteRegisterValue(unsigned offset, const Scalar &value) +ProcessMonitor::WriteRegisterValue(unsigned offset, const RegisterValue &value) { bool result; WriteRegOperation op(offset, value, result); diff --git a/source/Plugins/Process/Linux/ProcessMonitor.h b/source/Plugins/Process/Linux/ProcessMonitor.h index 1bfdb86..0f2f61c 100644 --- a/source/Plugins/Process/Linux/ProcessMonitor.h +++ b/source/Plugins/Process/Linux/ProcessMonitor.h @@ -100,14 +100,14 @@ public: /// /// This method is provided for use by RegisterContextLinux derivatives. bool - ReadRegisterValue(unsigned offset, lldb_private::Scalar &value); + ReadRegisterValue(unsigned offset, lldb_private::RegisterValue &value); /// Writes the given value to the register identified by the given /// (architecture dependent) offset. /// /// This method is provided for use by RegisterContextLinux derivatives. bool - WriteRegisterValue(unsigned offset, const lldb_private::Scalar &value); + WriteRegisterValue(unsigned offset, const lldb_private::RegisterValue &value); /// Reads all general purpose registers into the specified buffer. bool diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp index 6bee0c9..0a8ec5a 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp @@ -1,4 +1,4 @@ -//===-- RegisterContextLinux_i386.cpp ----------------------------*- C++ -*-===// +//===-- RegisterContextLinux_i386.cpp ---------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -411,6 +411,17 @@ RegisterContextLinux_i386::GetRegisterSet(uint32_t set) } bool +RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, + RegisterValue &value) +{ + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + ProcessMonitor &monitor = GetMonitor(); + return monitor.ReadRegisterValue(GetRegOffset(reg), value); +} + +#if 0 + +bool RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg, Scalar &value) { @@ -441,12 +452,16 @@ RegisterContextLinux_i386::ReadRegisterBytes(uint32_t reg, return status; } +#endif + bool RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } +#if 0 + bool RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg, const Scalar &value) @@ -463,6 +478,14 @@ RegisterContextLinux_i386::WriteRegisterBytes(uint32_t reg, return false; } +#endif + +bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info, + const RegisterValue &value) +{ + return false; +} + bool RegisterContextLinux_i386::WriteAllRegisterValues(const DataBufferSP &data) { diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.h b/source/Plugins/Process/Linux/RegisterContextLinux_i386.h index 890fd88..ef3a76b 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.h +++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.h @@ -42,21 +42,33 @@ public: const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); +#if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); bool ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); +#endif + + virtual bool + ReadRegister(const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); +#if 0 bool WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); bool WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); +#endif + + virtual bool + WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp index 27ca5b8..012690f 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp @@ -475,6 +475,7 @@ RegisterContextLinux_x86_64::GetRegisterSet(uint32_t set) return NULL; } +#if 0 bool RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, Scalar &value) @@ -506,12 +507,15 @@ RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg, return status; } +#endif + bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } +#if 0 bool RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, const Scalar &value) @@ -527,6 +531,7 @@ RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg, { return false; } +#endif bool RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h index 48540b4..2d210c6 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h @@ -41,21 +41,33 @@ public: const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); +#if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); bool ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); +#endif + + virtual bool + ReadRegister(const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); +#if 0 bool WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); bool WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); +#endif + + virtual bool + WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); -- 1.7.3.4 From johnny.chen at apple.com Thu May 12 16:58:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 May 2011 21:58:22 -0000 Subject: [Lldb-commits] [lldb] r131253 - /lldb/trunk/test/stop-hook/TestStopHookMechanism.py Message-ID: <20110512215822.A3DC22A6C12C@llvm.org> Author: johnny Date: Thu May 12 16:58:22 2011 New Revision: 131253 URL: http://llvm.org/viewvc/llvm-project?rev=131253&view=rev Log: Cleaned up the expected substring for output from the stop-hook mechanism. Modified: lldb/trunk/test/stop-hook/TestStopHookMechanism.py Modified: lldb/trunk/test/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stop-hook/TestStopHookMechanism.py?rev=131253&r1=131252&r2=131253&view=diff ============================================================================== --- lldb/trunk/test/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/stop-hook/TestStopHookMechanism.py Thu May 12 16:58:22 2011 @@ -69,7 +69,7 @@ #self.DebugPExpect(child) # Verify that the 'Stop Hooks' mechanism is fired off. self.expect(child.before, exe=False, - substrs = ['(void *) $0 = 0x']) + substrs = ['(void *) $']) # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range. child.sendline('process continue') @@ -80,7 +80,7 @@ #self.DebugPExpect(child) # Verify that the 'Stop Hooks' mechanism is NOT BEING fired off. self.expect(child.before, exe=False, matching=False, - substrs = ['(void *) $0 = 0x']) + substrs = ['(void *) $']) if __name__ == '__main__': From johnny.chen at apple.com Thu May 12 17:25:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 May 2011 22:25:54 -0000 Subject: [Lldb-commits] [lldb] r131256 - in /lldb/trunk/source/Plugins/Disassembler/llvm: DisassemblerLLVM.cpp DisassemblerLLVM.h Message-ID: <20110512222554.197A92A6C12C@llvm.org> Author: johnny Date: Thu May 12 17:25:53 2011 New Revision: 131256 URL: http://llvm.org/viewvc/llvm-project?rev=131256&view=rev Log: Fix the InstructionLLVM::Dump() so that for Triple::arm, PC reads as the address of the current instruction plus 8. And for Triple::thumb, it is plus 4. rdar://problem/9170971 lldb disassembly's symbol information not correct (off by 2?) Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131256&r1=131255&r2=131256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu May 12 17:25:53 2011 @@ -77,10 +77,10 @@ InstructionLLVM::InstructionLLVM (const Address &addr, AddressClass addr_class, EDDisassemblerRef disassembler, - bool force_raw) : + llvm::Triple::ArchType arch_type) : Instruction (addr, addr_class), m_disassembler (disassembler), - m_force_raw (force_raw) + m_arch_type (arch_type) { } @@ -154,8 +154,13 @@ int numTokens = -1; + // FIXME!!! + /* Remove the following section of code related to force_raw .... */ + bool force_raw = m_arch_type == llvm::Triple::arm || + m_arch_type == llvm::Triple::thumb; if (!raw) - raw = m_force_raw; + raw = force_raw; + /* .... when we fix the edis for arm/thumb. */ if (!raw) numTokens = EDNumTokens(m_inst); @@ -173,7 +178,16 @@ if (base_addr == LLDB_INVALID_ADDRESS) base_addr = GetAddress().GetFileAddress (); - RegisterReaderArg rra(base_addr + EDInstByteSize(m_inst), m_disassembler); + lldb::addr_t PC = base_addr + EDInstByteSize(m_inst); + + // When executing an ARM instruction, PC reads as the address of the + // current instruction plus 8. And for Thumb, it is plus 4. + if (m_arch_type == llvm::Triple::arm) + PC = base_addr + 8; + else if (m_arch_type == llvm::Triple::thumb) + PC = base_addr + 4; + + RegisterReaderArg rra(PC, m_disassembler); printTokenized = true; @@ -488,20 +502,11 @@ if (inst_address_class == eAddressClassCodeAlternateISA) use_thumb = true; } - bool force_raw = false; - switch (m_arch.GetMachine()) - { - case llvm::Triple::arm: - case llvm::Triple::thumb: - force_raw = true; - break; - default: - break; - } + InstructionSP inst_sp (new InstructionLLVM (inst_addr, inst_address_class, use_thumb ? m_disassembler_thumb : m_disassembler, - force_raw)); + m_arch.GetMachine())); size_t inst_byte_size = inst_sp->Decode (*this, data, data_offset); Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=131256&r1=131255&r2=131256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Thu May 12 17:25:53 2011 @@ -22,7 +22,7 @@ InstructionLLVM (const lldb_private::Address &addr, lldb_private::AddressClass addr_class, EDDisassemblerRef disassembler, - bool force_raw); + llvm::Triple::ArchType arch_type); virtual ~InstructionLLVM(); @@ -46,7 +46,7 @@ protected: EDDisassemblerRef m_disassembler; EDInstRef m_inst; - bool m_force_raw; + llvm::Triple::ArchType m_arch_type; }; From scallanan at apple.com Thu May 12 18:54:16 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 12 May 2011 23:54:16 -0000 Subject: [Lldb-commits] [lldb] r131263 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangExpressionVariable.h include/lldb/Symbol/ClangASTContext.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangExpressionParser.cpp source/Symbol/ClangASTContext.cpp test/alias_tests/TestAliases.py test/expression_command/test/TestExprs.py Message-ID: <20110512235416.E92A72A6C12C@llvm.org> Author: spyffe Date: Thu May 12 18:54:16 2011 New Revision: 131263 URL: http://llvm.org/viewvc/llvm-project?rev=131263&view=rev Log: Introduced support for UnknownAnyTy, the Clang type representing variables whose type must be inferred from the way they are used. Functions without debug information now return UnknownAnyTy and must be cast. Variables with no debug information are not yet using UnknownAnyTy; instead they are assumed to be void*. Support for variables of unknown type is coming (and, in fact, some relevant support functions are included in this commit) but will take a bit of extra effort. The testsuite has also been updated to reflect the new requirement that the result of printf be cast, i.e. expr (int) printf("Hello world!") Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/test/alias_tests/TestAliases.py lldb/trunk/test/expression_command/test/TestExprs.py Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Thu May 12 18:54:16 2011 @@ -85,6 +85,16 @@ WillParse (ExecutionContext &exe_ctx); //------------------------------------------------------------------ + /// [Used by ClangExpressionParser] For each variable that had an unknown + /// type at the beginning of parsing, determine its final type now. + /// + /// @return + /// True on success; false otherwise. + //------------------------------------------------------------------ + bool + ResolveUnknownTypes(); + + //------------------------------------------------------------------ /// Disable the state needed for parsing and IR transformation. //------------------------------------------------------------------ void Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Thu May 12 18:54:16 2011 @@ -223,7 +223,8 @@ EVNeedsAllocation = 1 << 2, ///< Space for this variable has yet to be allocated in the target process EVIsFreezeDried = 1 << 3, ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results) EVNeedsFreezeDry = 1 << 4, ///< Copy from m_live_sp to m_frozen_sp during dematerialization - EVKeepInTarget = 1 << 5 ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it + EVKeepInTarget = 1 << 5, ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it + EVUnknownType = 1 << 6 ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete }; uint16_t m_flags; // takes elements of Flags Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu May 12 18:54:16 2011 @@ -159,6 +159,15 @@ lldb::clang_type_t GetBuiltInType_objc_Class(); + + static lldb::clang_type_t + GetUnknownAnyType(clang::ASTContext *ast); + + lldb::clang_type_t + GetUnknownAnyType() + { + return ClangASTContext::GetUnknownAnyType(getASTContext()); + } lldb::clang_type_t GetBuiltInType_objc_selector(); Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Thu May 12 18:54:16 2011 @@ -232,9 +232,9 @@ proto_info.Variadic = true; - QualType generic_function_type(m_ast_source.m_ast_context.getFunctionType (m_ast_source.m_ast_context.getSizeType(), // result - NULL, // argument types - 0, // number of arguments + QualType generic_function_type(m_ast_source.m_ast_context.getFunctionType (m_ast_source.m_ast_context.UnknownAnyTy, // result + NULL, // argument types + 0, // number of arguments proto_info)); return AddFunDecl(generic_function_type.getAsOpaquePtr()); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu May 12 18:54:16 2011 @@ -1295,8 +1295,15 @@ } if (log) - log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), type.GetOpaqueQualType()); - + { + StreamString my_stream_string; + + ClangASTType::DumpTypeDescription (type.GetASTContext(), + type.GetOpaqueQualType(), + &my_stream_string); + + log->Printf("%s %s with type %s", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), my_stream_string.GetString().c_str()); + } if (!location_value.get()) { @@ -2095,13 +2102,13 @@ clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); - TypeFromUser user_type (ClangASTContext::GetVoidPtrType(scratch_ast_context, false), + TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)), scratch_ast_context); - TypeFromParser parser_type (ClangASTContext::GetVoidPtrType(context.GetASTContext(), false), + TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(context.GetASTContext(), true)), context.GetASTContext()); - NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType())); + NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); std::string decl_name(context.m_decl_name.getAsString()); ConstString entity_name(decl_name.c_str()); @@ -2111,7 +2118,6 @@ m_parser_vars->m_exe_ctx->process->GetByteOrder(), m_parser_vars->m_exe_ctx->process->GetAddressByteSize())); assert (entity.get()); - entity->EnableParserVars(); std::auto_ptr symbol_location(new Value); @@ -2123,11 +2129,13 @@ symbol_location->GetScalar() = symbol_load_addr; symbol_location->SetValueType(Value::eValueTypeLoadAddress); + entity->EnableParserVars(); entity->m_parser_vars->m_parser_type = parser_type; entity->m_parser_vars->m_named_decl = var_decl; entity->m_parser_vars->m_llvm_value = NULL; entity->m_parser_vars->m_lldb_value = symbol_location.release(); entity->m_parser_vars->m_lldb_sym = &symbol; + //entity->m_flags |= ClangExpressionVariable::EVUnknownType; if (log) { @@ -2147,6 +2155,61 @@ } } +bool +ClangExpressionDeclMap::ResolveUnknownTypes() +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); + + for (size_t index = 0, num_entities = m_found_entities.GetSize(); + index < num_entities; + ++index) + { + ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index); + + if (entity->m_flags & ClangExpressionVariable::EVUnknownType) + { + const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl; + const VarDecl *var_decl = dyn_cast(named_decl); + + if (!var_decl) + { + if (log) + log->Printf("Entity of unknown type does not have a VarDecl"); + return false; + } + + if (log) + { + std::string var_decl_print_string; + llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); + var_decl->print(var_decl_print_stream); + var_decl_print_stream.flush(); + + log->Printf("Variable of unknown type now has Decl %s", var_decl_print_string.c_str()); + } + + QualType var_type = var_decl->getType(); + TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext()); + + lldb::clang_type_t copied_type = ClangASTContext::CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr()); + + TypeFromUser user_type(copied_type, scratch_ast_context); + + entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); + entity->m_parser_vars->m_parser_type = parser_type; + + entity->SetClangAST(user_type.GetASTContext()); + entity->SetClangType(user_type.GetOpaqueQualType()); + + entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType); + } + } + + return true; +} + void ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context, const RegisterInfo *reg_info) Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu May 12 18:54:16 2011 @@ -17,6 +17,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangExpression.h" +#include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/IRDynamicChecks.h" #include "lldb/Expression/IRForTarget.h" #include "lldb/Expression/IRToDWARF.h" @@ -352,7 +353,7 @@ ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext()); diag_buf->EndSourceFile(); - + TextDiagnosticBuffer::const_iterator diag_iterator; int num_errors = 0; @@ -377,6 +378,15 @@ ++diag_iterator) stream.Printf("note: %s\n", (*diag_iterator).second.c_str()); + if (!num_errors) + { + if (m_expr.DeclMap() && !m_expr.DeclMap()->ResolveUnknownTypes()) + { + stream.Printf("error: Couldn't infer the type of a variable\n"); + num_errors++; + } + } + return num_errors; } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu May 12 18:54:16 2011 @@ -897,6 +897,12 @@ } clang_type_t +ClangASTContext::GetUnknownAnyType(clang::ASTContext *ast) +{ + return ast->UnknownAnyTy.getAsOpaquePtr(); +} + +clang_type_t ClangASTContext::GetCStringType (bool is_const) { QualType char_type(getASTContext()->CharTy); Modified: lldb/trunk/test/alias_tests/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/TestAliases.py?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/test/alias_tests/TestAliases.py (original) +++ lldb/trunk/test/alias_tests/TestAliases.py Thu May 12 18:54:16 2011 @@ -94,8 +94,8 @@ self.expect ("run", patterns = [ "Process .* launched: .*a.out" ]) - self.expect (r'''expression printf("\x68\x65\x6c\x6c\x6f\n")''', - substrs = [ "(unsigned long) $", + self.expect (r'''expression (int) printf("\x68\x65\x6c\x6c\x6f\n")''', + substrs = [ "(int) $", "= 6" ]) self.expect ("hello", Modified: lldb/trunk/test/expression_command/test/TestExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=131263&r1=131262&r2=131263&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs.py (original) +++ lldb/trunk/test/expression_command/test/TestExprs.py Thu May 12 18:54:16 2011 @@ -182,36 +182,36 @@ substrs = ['(char) $', "'a'"]) - # runCmd: expression printf ("\n\n\tHello there!\n") - # output: (unsigned long) $1 = 16 - self.expect(r'''expression printf ("\n\n\tHello there!\n")''', - substrs = ['(unsigned long) $', + # runCmd: expression (int) printf ("\n\n\tHello there!\n") + # output: (int) $1 = 16 + self.expect(r'''expression (int) printf ("\n\n\tHello there!\n")''', + substrs = ['(int) $', '16']) - # runCmd: expression printf("\t\x68\n") - # output: (unsigned long) $2 = 3 - self.expect(r'''expression printf("\t\x68\n")''', - substrs = ['(unsigned long) $', + # runCmd: expression (int) printf("\t\x68\n") + # output: (int) $2 = 3 + self.expect(r'''expression (int) printf("\t\x68\n")''', + substrs = ['(int) $', '3']) - # runCmd: expression printf("\"\n") - # output: (unsigned long) $3 = 2 - self.expect(r'''expression printf("\"\n")''', - substrs = ['(unsigned long) $', + # runCmd: expression (int) printf("\"\n") + # output: (int) $3 = 2 + self.expect(r'''expression (int) printf("\"\n")''', + substrs = ['(int) $', '2']) - # runCmd: expression printf("'\n") - # output: (unsigned long) $4 = 2 - self.expect(r'''expression printf("'\n")''', - substrs = ['(unsigned long) $', + # runCmd: expression (int) printf("'\n") + # output: (int) $4 = 2 + self.expect(r'''expression (int) printf("'\n")''', + substrs = ['(int) $', '2']) - # runCmd: command alias print_hi expression printf ("\n\tHi!\n") + # runCmd: command alias print_hi expression (int) printf ("\n\tHi!\n") # output: - self.runCmd(r'''command alias print_hi expression printf ("\n\tHi!\n")''') + self.runCmd(r'''command alias print_hi expression (int) printf ("\n\tHi!\n")''') # This fails currently. self.expect('print_hi', - substrs = ['(unsigned long) $', + substrs = ['(int) $', '6']) From johnny.chen at apple.com Thu May 12 19:44:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 00:44:49 -0000 Subject: [Lldb-commits] [lldb] r131273 - /lldb/trunk/test/lldbutil.py Message-ID: <20110513004449.B36A82A6C12C@llvm.org> Author: johnny Date: Thu May 12 19:44:49 2011 New Revision: 131273 URL: http://llvm.org/viewvc/llvm-project?rev=131273&view=rev Log: When trying to print out the function name corresponding to the frame, if the function obj from the frame is not valid, try look for the symbol in the symbol table. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131273&r1=131272&r2=131273&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu May 12 19:44:49 2011 @@ -438,7 +438,13 @@ args.append("(%s)%s=%s" % (var.GetTypeName(), var.GetName(), var.GetValue(frame))) - return "%s(%s)" % (frame.GetFunction().GetName(), ", ".join(args)) + if frame.GetFunction().IsValid(): + name = frame.GetFunction().GetName() + elif frame.GetSymbol().IsValid(): + name = frame.GetSymbol().GetName() + else: + name = "" + return "%s(%s)" % (name, ", ".join(args)) def print_registers(frame, string_buffer = False): """Prints all the register sets of the frame.""" From scallanan at apple.com Fri May 13 13:27:02 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 13 May 2011 18:27:02 -0000 Subject: [Lldb-commits] [lldb] r131299 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20110513182702.5B6CF2A6C12C@llvm.org> Author: spyffe Date: Fri May 13 13:27:02 2011 New Revision: 131299 URL: http://llvm.org/viewvc/llvm-project?rev=131299&view=rev Log: For cases where a const function is inaccurately reported as non-const in the debug information, added a fallback to GetFunctionAddress, adding the const qualifier after the fact and searching again. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131299&r1=131298&r2=131299&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri May 13 13:27:02 2011 @@ -500,6 +500,8 @@ { assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + // Back out in all cases where we're not fully initialized if (m_parser_vars->m_exe_ctx->target == NULL) return false; @@ -512,6 +514,30 @@ m_parser_vars->m_sym_ctx.FindFunctionsByName(name, include_symbols, append, sc_list); if (!sc_list.GetSize()) + { + // We occasionally get debug information in which a const function is reported + // as non-const, so the mangled name is wrong. This is a hack to compensate. + + Mangled mangled(name.GetCString(), true); + + ConstString demangled_name = mangled.GetDemangledName(); + + if (strlen(demangled_name.GetCString())) + { + std::string const_name_scratch(demangled_name.GetCString()); + + const_name_scratch.append(" const"); + + ConstString const_name(const_name_scratch.c_str()); + + m_parser_vars->m_sym_ctx.FindFunctionsByName(const_name, include_symbols, append, sc_list); + + if (log) + log->Printf("Found %d results with const name %s", sc_list.GetSize(), const_name.GetCString()); + } + } + + if (!sc_list.GetSize()) return false; SymbolContext sym_ctx; From johnny.chen at apple.com Fri May 13 13:45:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 11:45:49 -0700 Subject: [Lldb-commits] [PATCH 1/4] Fixed includes In-Reply-To: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> References: <1305236370-28191-1-git-send-email-mminutoli@gmail.com> Message-ID: <4A05B854-0D57-42B0-9E12-B8C0EE8A85D8@apple.com> Hi Marco, I'll be reviewing/applying your patches. Thanks. Johnny On May 12, 2011, at 2:39 PM, Marco Minutoli wrote: > Headers have been moved to /includes/lldb/Interpreter. This patch > reflects this change. > --- > source/Interpreter/OptionGroupArchitecture.cpp | 2 +- > source/Interpreter/OptionGroupBoolean.cpp | 2 +- > source/Interpreter/OptionGroupFile.cpp | 2 +- > source/Interpreter/OptionGroupFormat.cpp | 2 +- > source/Interpreter/OptionGroupOutputFile.cpp | 2 +- > source/Interpreter/OptionGroupUInt64.cpp | 2 +- > source/Interpreter/OptionGroupUUID.cpp | 2 +- > .../Interpreter/OptionGroupValueObjectDisplay.cpp | 4 ++-- > 8 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp > index a523f3c..9446f2e 100644 > --- a/source/Interpreter/OptionGroupArchitecture.cpp > +++ b/source/Interpreter/OptionGroupArchitecture.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupArchitecture.h" > +#include "lldb/Interpreter/OptionGroupArchitecture.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp > index f1fd62b..f5403cf 100644 > --- a/source/Interpreter/OptionGroupBoolean.cpp > +++ b/source/Interpreter/OptionGroupBoolean.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupBoolean.h" > +#include "lldb/Interpreter/OptionGroupBoolean.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp > index 86acede..b16399a 100644 > --- a/source/Interpreter/OptionGroupFile.cpp > +++ b/source/Interpreter/OptionGroupFile.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupFile.h" > +#include "lldb/Interpreter/OptionGroupFile.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp > index 213255e..a42099d 100644 > --- a/source/Interpreter/OptionGroupFormat.cpp > +++ b/source/Interpreter/OptionGroupFormat.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupFormat.h" > +#include "lldb/Interpreter/OptionGroupFormat.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp > index 2a4e8dc..541c8b4 100644 > --- a/source/Interpreter/OptionGroupOutputFile.cpp > +++ b/source/Interpreter/OptionGroupOutputFile.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupOutputFile.h" > +#include "lldb/Interpreter/OptionGroupOutputFile.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp > index d0ab1ef..76d0260 100644 > --- a/source/Interpreter/OptionGroupUInt64.cpp > +++ b/source/Interpreter/OptionGroupUInt64.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupUInt64.h" > +#include "lldb/Interpreter/OptionGroupUInt64.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp > index e436f61..b1b3c77 100644 > --- a/source/Interpreter/OptionGroupUUID.cpp > +++ b/source/Interpreter/OptionGroupUUID.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupUUID.h" > +#include "lldb/Interpreter/OptionGroupUUID.h" > > // C Includes > // C++ Includes > diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp > index 3150ea7..edc5dbb 100644 > --- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp > +++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp > @@ -7,7 +7,7 @@ > // > //===----------------------------------------------------------------------===// > > -#include "OptionGroupValueObjectDisplay.h" > +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" > > // C Includes > // C++ Includes > @@ -123,4 +123,4 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp > // If we don't have any targets, then dynamic values won't do us much good. > use_dynamic = lldb::eNoDynamicValues; > } > -} > \ No newline at end of file > +} > -- > 1.7.3.4 > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Fri May 13 14:57:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 19:57:46 -0000 Subject: [Lldb-commits] [lldb] r131303 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20110513195746.0D9362A6C12C@llvm.org> Author: johnny Date: Fri May 13 14:57:45 2011 New Revision: 131303 URL: http://llvm.org/viewvc/llvm-project?rev=131303&view=rev Log: This method has been removed from the API. This fix the compilation breakage due to its presence. Patch by Marco Minutoli Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=131303&r1=131302&r2=131303&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Fri May 13 14:57:45 2011 @@ -1173,19 +1173,4 @@ return LLDB_INVALID_PROCESS_ID; } -lldb::pid_t -Host::LaunchInNewTerminal -( - const char *tty_name, - const char **argv, - const char **envp, - const char *working_dir, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr -) -{ - return LLDB_INVALID_PROCESS_ID; -} - #endif From johnny.chen at apple.com Fri May 13 15:07:25 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 20:07:25 -0000 Subject: [Lldb-commits] [lldb] r131304 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Message-ID: <20110513200725.EEF362A6C12C@llvm.org> Author: johnny Date: Fri May 13 15:07:25 2011 New Revision: 131304 URL: http://llvm.org/viewvc/llvm-project?rev=131304&view=rev Log: PATH_MAX is in limits.h on Linux. Patch by Marco Minutoli Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=131304&r1=131303&r2=131304&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Fri May 13 15:07:25 2011 @@ -11,6 +11,7 @@ #include "GDBRemoteCommunication.h" // C Includes +#include #include // C++ Includes From johnny.chen at apple.com Fri May 13 15:21:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 20:21:08 -0000 Subject: [Lldb-commits] [lldb] r131306 - in /lldb/trunk/source/Interpreter: OptionGroupArchitecture.cpp OptionGroupBoolean.cpp OptionGroupFile.cpp OptionGroupFormat.cpp OptionGroupOutputFile.cpp OptionGroupUInt64.cpp OptionGroupUUID.cpp OptionGroupValueObjectDisplay.cpp Message-ID: <20110513202108.C4B552A6C12C@llvm.org> Author: johnny Date: Fri May 13 15:21:08 2011 New Revision: 131306 URL: http://llvm.org/viewvc/llvm-project?rev=131306&view=rev Log: Headers have been moved to /includes/lldb/Interpreter. This patch reflects this change. Marco Minutoli Modified: lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp lldb/trunk/source/Interpreter/OptionGroupFile.cpp lldb/trunk/source/Interpreter/OptionGroupFormat.cpp lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp lldb/trunk/source/Interpreter/OptionGroupUUID.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Modified: lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupArchitecture.h" +#include "lldb/Interpreter/OptionGroupArchitecture.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupBoolean.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupBoolean.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFile.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupFile.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupFile.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupFile.h" +#include "lldb/Interpreter/OptionGroupFile.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupFormat.h" +#include "lldb/Interpreter/OptionGroupFormat.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupOutputFile.h" +#include "lldb/Interpreter/OptionGroupOutputFile.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupUInt64.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupUInt64.h" +#include "lldb/Interpreter/OptionGroupUInt64.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupUUID.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupUUID.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupUUID.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupUUID.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupUUID.h" +#include "lldb/Interpreter/OptionGroupUUID.h" // C Includes // C++ Includes Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=131306&r1=131305&r2=131306&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Fri May 13 15:21:08 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OptionGroupValueObjectDisplay.h" +#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" // C Includes // C++ Includes @@ -123,4 +123,4 @@ // If we don't have any targets, then dynamic values won't do us much good. use_dynamic = lldb::eNoDynamicValues; } -} \ No newline at end of file +} From johnny.chen at apple.com Fri May 13 16:29:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 21:29:50 -0000 Subject: [Lldb-commits] [lldb] r131313 - in /lldb/trunk/source/Plugins: Platform/Linux/PlatformLinux.cpp Platform/Linux/PlatformLinux.h Process/Linux/ProcessMonitor.cpp Process/Linux/ProcessMonitor.h Process/Linux/RegisterContextLinux_i386.cpp Process/Linux/RegisterContextLinux_i386.h Process/Linux/RegisterContextLinux_x86_64.cpp Process/Linux/RegisterContextLinux_x86_64.h Message-ID: <20110513212950.93D2E2A6C12C@llvm.org> Author: johnny Date: Fri May 13 16:29:50 2011 New Revision: 131313 URL: http://llvm.org/viewvc/llvm-project?rev=131313&view=rev Log: This patch add a "fake" attach waiting for a real implementation and solve the build break due to the lack of this method. It also propose a solution to the API changes in RegisterContext. I upgraded also the the python version in the makefile. My linux installation has python2.7 and AFAIK also the latest ubuntu has this version of python so maybe is worth upgrading. Patch by Marco Minutoli [Note: I had to hand merge in the diffs since patch thinks it is a corrupt patch.] Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Fri May 13 16:29:50 2011 @@ -192,7 +192,7 @@ } bool -PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { return Host::GetProcessInfo (pid, process_info); } @@ -247,3 +247,15 @@ bp_site->SetTrapOpcode(opcode, opcode_size); return opcode_size; } + +lldb::ProcessSP +PlatformLinux::Attach(lldb::pid_t pid, + Debugger &debugger, + Target *target, + Listener &listener, + Error &error) +{ + ProcessSP processSP; + assert(!"Not implemented yet!"); + return processSP; +} Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Fri May 13 16:29:50 2011 @@ -85,7 +85,7 @@ const UUID* uuid, FileSpec &local_file); virtual bool - GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info); + GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info); virtual bool GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch); @@ -94,6 +94,10 @@ GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site); + virtual lldb::ProcessSP + Attach(lldb::pid_t pid, Debugger &debugger, Target *target, + Listener &listener, Error &error); + protected: Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Fri May 13 16:29:50 2011 @@ -20,6 +20,7 @@ // C++ Includes // Other libraries and framework includes #include "lldb/Core/Error.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/Host.h" #include "lldb/Target/Thread.h" @@ -221,7 +222,7 @@ class ReadRegOperation : public Operation { public: - ReadRegOperation(unsigned offset, Scalar &value, bool &result) + ReadRegOperation(unsigned offset, RegisterValue &value, bool &result) : m_offset(offset), m_value(value), m_result(result) { } @@ -229,7 +230,7 @@ private: unsigned m_offset; - Scalar &m_value; + RegisterValue &m_value; bool &m_result; }; @@ -257,7 +258,7 @@ class WriteRegOperation : public Operation { public: - WriteRegOperation(unsigned offset, const Scalar &value, bool &result) + WriteRegOperation(unsigned offset, const RegisterValue &value, bool &result) : m_offset(offset), m_value(value), m_result(result) { } @@ -265,7 +266,7 @@ private: unsigned m_offset; - const Scalar &m_value; + const RegisterValue &m_value; bool &m_result; }; @@ -274,7 +275,7 @@ { lldb::pid_t pid = monitor->GetPID(); - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.ULong())) + if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) m_result = false; else m_result = true; @@ -1097,7 +1098,7 @@ } bool -ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value) +ProcessMonitor::ReadRegisterValue(unsigned offset, RegisterValue &value) { bool result; ReadRegOperation op(offset, value, result); @@ -1106,7 +1107,7 @@ } bool -ProcessMonitor::WriteRegisterValue(unsigned offset, const Scalar &value) +ProcessMonitor::WriteRegisterValue(unsigned offset, const RegisterValue &value) { bool result; WriteRegOperation op(offset, value, result); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Fri May 13 16:29:50 2011 @@ -100,14 +100,14 @@ /// /// This method is provided for use by RegisterContextLinux derivatives. bool - ReadRegisterValue(unsigned offset, lldb_private::Scalar &value); + ReadRegisterValue(unsigned offset, lldb_private::RegisterValue &value); /// Writes the given value to the register identified by the given /// (architecture dependent) offset. /// /// This method is provided for use by RegisterContextLinux derivatives. bool - WriteRegisterValue(unsigned offset, const lldb_private::Scalar &value); + WriteRegisterValue(unsigned offset, const lldb_private::RegisterValue &value); /// Reads all general purpose registers into the specified buffer. bool Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp Fri May 13 16:29:50 2011 @@ -1,4 +1,4 @@ -//===-- RegisterContextLinux_i386.cpp ----------------------------*- C++ -*-===// +//===-- RegisterContextLinux_i386.cpp ---------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -411,6 +411,17 @@ } bool +RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, + RegisterValue &value) +{ + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + ProcessMonitor &monitor = GetMonitor(); + return monitor.ReadRegisterValue(GetRegOffset(reg), value); +} + +#if 0 + +bool RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg, Scalar &value) { @@ -441,12 +452,16 @@ return status; } +#endif + bool RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } +#if 0 + bool RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg, const Scalar &value) @@ -463,6 +478,14 @@ return false; } +#endif + +bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info, + const RegisterValue &value) +{ + return false; +} + bool RegisterContextLinux_i386::WriteAllRegisterValues(const DataBufferSP &data) { Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h Fri May 13 16:29:50 2011 @@ -42,21 +42,33 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); +#if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); bool ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); +#endif + + virtual bool + ReadRegister(const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); +#if 0 bool WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); bool WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); +#endif + + virtual bool + WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Fri May 13 16:29:50 2011 @@ -475,6 +475,7 @@ return NULL; } +#if 0 bool RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, Scalar &value) @@ -506,12 +507,15 @@ return status; } +#endif + bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } +#if 0 bool RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, const Scalar &value) @@ -527,6 +531,7 @@ { return false; } +#endif bool RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h?rev=131313&r1=131312&r2=131313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Fri May 13 16:29:50 2011 @@ -41,21 +41,33 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); +#if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); bool ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); +#endif + + virtual bool + ReadRegister(const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); +#if 0 bool WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); bool WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0); +#endif + + virtual bool + WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); From johnny.chen at apple.com Fri May 13 16:55:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 21:55:30 -0000 Subject: [Lldb-commits] [lldb] r131319 - /lldb/trunk/test/lldbutil.py Message-ID: <20110513215530.ED08C2A6C12C@llvm.org> Author: johnny Date: Fri May 13 16:55:30 2011 New Revision: 131319 URL: http://llvm.org/viewvc/llvm-project?rev=131319&view=rev Log: Test commit from a git-svn-cloned lldb/trunk repository. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131319&r1=131318&r2=131319&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Fri May 13 16:55:30 2011 @@ -1,5 +1,7 @@ """ This LLDB module contains miscellaneous utilities. +Some of the test suite takes advantage of the utility functions defined here. +They can also be useful for general purpose lldb scripting. """ import lldb From johnny.chen at apple.com Fri May 13 18:42:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 May 2011 23:42:45 -0000 Subject: [Lldb-commits] [lldb] r131324 - /lldb/trunk/test/python_api/frame/TestFrames.py Message-ID: <20110513234245.1E9EE2A6C12C@llvm.org> Author: johnny Date: Fri May 13 18:42:44 2011 New Revision: 131324 URL: http://llvm.org/viewvc/llvm-project?rev=131324&view=rev Log: Clean up the test a little bit; and use lldbutil.get_GPRs(frame) to retrieve the general purpose register set. Modified: lldb/trunk/test/python_api/frame/TestFrames.py Modified: lldb/trunk/test/python_api/frame/TestFrames.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/TestFrames.py?rev=131324&r1=131323&r2=131324&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/TestFrames.py (original) +++ lldb/trunk/test/python_api/frame/TestFrames.py Fri May 13 18:42:44 2011 @@ -64,10 +64,7 @@ frame = thread.GetFrameAtIndex(i) if self.TraceOn(): print "frame:", frame - #print "frame.FindValue('val', lldb.eValueTypeVariableArgument)", frame.FindValue('val', lldb.eValueTypeVariableArgument).GetValue(frame) - #print "frame.FindValue('ch', lldb.eValueTypeVariableArgument)", frame.FindValue('ch', lldb.eValueTypeVariableArgument).GetValue(frame) - #print "frame.EvaluateExpression('val'):", frame.EvaluateExpression('val').GetValue(frame) - #print "frame.EvaluateExpression('ch'):", frame.EvaluateExpression('ch').GetValue(frame) + name = frame.GetFunction().GetName() if name == 'a': callsOfA = callsOfA + 1 @@ -81,17 +78,14 @@ valList = frame.GetVariables(True, False, False, True) argList = [] for val in valList: - #self.DebugSBValue(frame, val) argList.append("(%s)%s=%s" % (val.GetTypeName(), val.GetName(), val.GetValue(frame))) print >> session, "%s(%s)" % (name, ", ".join(argList)) # Also check the generic pc & stack pointer. We can't test their absolute values, - # but they should be valid. - # It is kind of goofy that the register set is a value, and then we just have - # to magically know that element 0 is the GPR set... - gpr_reg_set = frame.GetRegisters().GetValueAtIndex(0) + # but they should be valid. Uses get_GPRs() from the lldbutil module. + gpr_reg_set = lldbutil.get_GPRs(frame) pc_value = gpr_reg_set.GetChildMemberWithName("pc") self.assertTrue (pc_value.IsValid(), "We should have a valid PC.") self.assertTrue (int(pc_value.GetValue(frame), 0) == frame.GetPC(), "PC gotten as a value should equal frame's GetPC") From jingham at apple.com Fri May 13 19:40:38 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 14 May 2011 00:40:38 -0000 Subject: [Lldb-commits] [lldb] r131331 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Message-ID: <20110514004038.275352A6C12C@llvm.org> Author: jingham Date: Fri May 13 19:40:37 2011 New Revision: 131331 URL: http://llvm.org/viewvc/llvm-project?rev=131331&view=rev Log: For the purposes of setting breakpoints treat methods defined in the class and methods defined in a category on the class as the same. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=131331&r1=131330&r2=131331&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri May 13 19:40:37 2011 @@ -809,6 +809,24 @@ // accelerator tables size_t method_name_len = name_len - (method_name - name) - 1; func_selectors.Insert (ConstString (method_name, method_name_len), die_info); + + // Also see if this is a "category" on our class. If so strip off the category name, + // and add the class name without it to the basename table. + + const char *first_paren = strnstr (name, "(", method_name - name); + if (first_paren) + { + const char *second_paren = strnstr (first_paren, ")", method_name - first_paren); + if (second_paren) + { + std::string buffer (name, first_paren - name); + buffer.append (second_paren + 1); + ConstString uncategoried_name (buffer.c_str()); + func_basenames.Insert (uncategoried_name, die_info); + func_fullnames.Insert (uncategoried_name, die_info); + + } + } } } } From jingham at apple.com Fri May 13 20:11:02 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 14 May 2011 01:11:02 -0000 Subject: [Lldb-commits] [lldb] r131333 - /lldb/trunk/source/Breakpoint/Breakpoint.cpp Message-ID: <20110514011102.8EB762A6C12C@llvm.org> Author: jingham Date: Fri May 13 20:11:02 2011 New Revision: 131333 URL: http://llvm.org/viewvc/llvm-project?rev=131333&view=rev Log: Breakpoint::Description with eDescriptionLevelBrief should just print the number of locations, printing the list of locations is pointless. Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=131333&r1=131332&r2=131333&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri May 13 20:11:02 2011 @@ -420,7 +420,9 @@ break; } - if (show_locations) + // The brief description is just the location name (1.2 or whatever). That's pointless to + // show in the breakpoint's description, so suppress it. + if (show_locations && level != lldb::eDescriptionLevelBrief) { s->IndentMore(); for (size_t i = 0; i < num_locations; ++i) From gclayton at apple.com Fri May 13 20:50:35 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 May 2011 01:50:35 -0000 Subject: [Lldb-commits] [lldb] r131334 - in /lldb/trunk: include/lldb/Target/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20110514015035.B4D1A2A6C12C@llvm.org> Author: gclayton Date: Fri May 13 20:50:35 2011 New Revision: 131334 URL: http://llvm.org/viewvc/llvm-project?rev=131334&view=rev Log: Expand the ABI prepare trivial function call to allow 6 simple args. Modified: lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Fri May 13 20:50:35 2011 @@ -34,10 +34,13 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const = 0; - + lldb::addr_t *arg1_ptr = NULL, + lldb::addr_t *arg2_ptr = NULL, + lldb::addr_t *arg3_ptr = NULL, + lldb::addr_t *arg4_ptr = NULL, + lldb::addr_t *arg5_ptr = NULL, + lldb::addr_t *arg6_ptr = NULL) const = 0; + virtual bool GetArgumentValues (Thread &thread, ValueList &values) const = 0; Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Fri May 13 20:50:35 2011 @@ -30,7 +30,18 @@ bool discard_on_error = true, lldb::addr_t *this_arg = 0, lldb::addr_t *cmd_arg = 0); - + + ThreadPlanCallFunction (Thread &thread, + Address &function, + bool stop_other_threads, + bool discard_on_error, + lldb::addr_t *arg1_ptr = NULL, + lldb::addr_t *arg2_ptr = NULL, + lldb::addr_t *arg3_ptr = NULL, + lldb::addr_t *arg4_ptr = NULL, + lldb::addr_t *arg5_ptr = NULL, + lldb::addr_t *arg6_ptr = NULL); + virtual ~ThreadPlanCallFunction (); @@ -106,9 +117,7 @@ bool m_stop_other_threads; Address m_function_addr; Address m_start_addr; - lldb::addr_t m_arg_addr; lldb::addr_t m_function_sp; - ValueList *m_args; Process &m_process; Thread &m_thread; Thread::RegisterCheckpoint m_register_backup; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri May 13 20:50:35 2011 @@ -65,9 +65,12 @@ addr_t sp, addr_t function_addr, addr_t return_addr, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const + addr_t *arg1_ptr, + addr_t *arg2_ptr, + addr_t *arg3_ptr, + addr_t *arg4_ptr, + addr_t *arg5_ptr, + addr_t *arg6_ptr) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) @@ -84,25 +87,41 @@ reg_value.SetUInt32(*arg1_ptr); if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r0"), reg_value)) return false; - } - - if (arg2_ptr) - { - assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) - reg_value.SetUInt32(*arg2_ptr); - if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r1"), reg_value)) - return false; - } - - if (arg3_ptr) - { - assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) - assert (arg2_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) + if (arg2_ptr) + { + reg_value.SetUInt32(*arg2_ptr); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r1"), reg_value)) + return false; - reg_value.SetUInt32(*arg3_ptr); - if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r2"), reg_value)) - return false; + if (arg3_ptr) + { + reg_value.SetUInt32(*arg3_ptr); + if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("r2"), reg_value)) + return false; + if (arg4_ptr) + { + reg_value.SetUInt32(*arg4_ptr); + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3"); + if (!reg_ctx->WriteRegister (reg_info, reg_value)) + return false; + if (arg5_ptr) + { + reg_value.SetUInt32(*arg5_ptr); + sp -= 4; + if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) + return false; + if (arg6_ptr) + { + reg_value.SetUInt32(*arg6_ptr); + sp -= 4; + if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) + return false; + } + } + } + } + } } // Set "lr" to the return address into "lr" Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Fri May 13 20:50:35 2011 @@ -30,9 +30,12 @@ lldb::addr_t sp, lldb::addr_t func_addr, lldb::addr_t returnAddress, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const; + lldb::addr_t *arg1_ptr = NULL, + lldb::addr_t *arg2_ptr = NULL, + lldb::addr_t *arg3_ptr = NULL, + lldb::addr_t *arg4_ptr = NULL, + lldb::addr_t *arg5_ptr = NULL, + lldb::addr_t *arg6_ptr = NULL) const; virtual bool GetArgumentValues (lldb_private::Thread &thread, Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri May 13 20:50:35 2011 @@ -57,15 +57,15 @@ bool ABIMacOSX_i386::PrepareTrivialCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t return_addr, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const -// lldb::addr_t arg, -// lldb::addr_t *this_arg, -// lldb::addr_t *cmd_arg) const + addr_t sp, + addr_t func_addr, + addr_t return_addr, + addr_t *arg1_ptr, + addr_t *arg2_ptr, + addr_t *arg3_ptr, + addr_t *arg4_ptr, + addr_t *arg5_ptr, + addr_t *arg6_ptr) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) @@ -85,12 +85,30 @@ RegisterValue reg_value; // Write any arguments onto the stack - if (arg1_ptr && arg2_ptr && arg3_ptr) - sp -= 12; - else if (arg1_ptr && arg2_ptr) - sp -= 8; - else if (arg1_ptr) + if (arg1_ptr) + { sp -= 4; + if (arg2_ptr) + { + sp -= 4; + if (arg3_ptr) + { + sp -= 4; + if (arg4_ptr) + { + sp -= 4; + if (arg5_ptr) + { + sp -= 4; + if (arg6_ptr) + { + sp -= 4; + } + } + } + } + } + } // Align the SP sp &= ~(0xfull); // 16-byte alignment @@ -107,7 +125,6 @@ if (arg2_ptr) { - assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) reg_value.SetUInt32(*arg2_ptr); // The register info used to write memory just needs to have the correct // size of a 32 bit register, the actual register it pertains to is not @@ -121,8 +138,6 @@ if (arg3_ptr) { - assert (arg1_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) - assert (arg2_ptr != NULL); // Remove this after we know the assertion isn't firing (5/11/2011) reg_value.SetUInt32(*arg3_ptr); // The register info used to write memory just needs to have the correct // size of a 32 bit register, the actual register it pertains to is not @@ -133,6 +148,46 @@ reg_value); if (error.Fail()) return false; + + if (arg4_ptr) + { + reg_value.SetUInt32(*arg4_ptr); + // The register info used to write memory just needs to have the correct + // size of a 32 bit register, the actual register it pertains to is not + // important, just the size needs to be correct. Here we use "eax"... + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp + 12, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) + return false; + if (arg5_ptr) + { + reg_value.SetUInt32(*arg5_ptr); + // The register info used to write memory just needs to have the correct + // size of a 32 bit register, the actual register it pertains to is not + // important, just the size needs to be correct. Here we use "eax"... + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp + 16, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) + return false; + if (arg6_ptr) + { + reg_value.SetUInt32(*arg6_ptr); + // The register info used to write memory just needs to have the correct + // size of a 32 bit register, the actual register it pertains to is not + // important, just the size needs to be correct. Here we use "eax"... + error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, + sp + 20, + reg_info_32->byte_size, + reg_value); + if (error.Fail()) + return false; + } + } + } } } } @@ -164,9 +219,9 @@ bool ABIMacOSX_i386::PrepareNormalCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t return_addr, + addr_t sp, + addr_t func_addr, + addr_t return_addr, ValueList &args) const { RegisterContext *reg_ctx = thread.GetRegisterContext().get(); Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Fri May 13 20:50:35 2011 @@ -146,9 +146,12 @@ lldb::addr_t sp, lldb::addr_t func_addr, lldb::addr_t return_addr, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const; + lldb::addr_t *arg1_ptr = NULL, + lldb::addr_t *arg2_ptr = NULL, + lldb::addr_t *arg3_ptr = NULL, + lldb::addr_t *arg4_ptr = NULL, + lldb::addr_t *arg5_ptr = NULL, + lldb::addr_t *arg6_ptr = NULL) const; virtual bool PrepareNormalCall (lldb_private::Thread &thread, Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri May 13 20:50:35 2011 @@ -60,13 +60,19 @@ bool ABISysV_x86_64::PrepareTrivialCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t return_addr, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const + addr_t sp, + addr_t func_addr, + addr_t return_addr, + addr_t *arg1_ptr, + addr_t *arg2_ptr, + addr_t *arg3_ptr, + addr_t *arg4_ptr, + addr_t *arg5_ptr, + addr_t *arg6_ptr) const { + if (arg4_ptr || arg5_ptr || arg6_ptr) + return false; + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); if (log) Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Fri May 13 20:50:35 2011 @@ -172,9 +172,12 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t *arg1_ptr, - lldb::addr_t *arg2_ptr, - lldb::addr_t *arg3_ptr) const; + lldb::addr_t *arg1_ptr = NULL, + lldb::addr_t *arg2_ptr = NULL, + lldb::addr_t *arg3_ptr = NULL, + lldb::addr_t *arg4_ptr = NULL, + lldb::addr_t *arg5_ptr = NULL, + lldb::addr_t *arg6_ptr = NULL) const; virtual bool GetArgumentValues (lldb_private::Thread &thread, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri May 13 20:50:35 2011 @@ -45,6 +45,8 @@ m_supports_vCont_s (eLazyBoolCalculate), m_supports_vCont_S (eLazyBoolCalculate), m_qHostInfo_is_valid (eLazyBoolCalculate), + m_supports__m (eLazyBoolCalculate), + m_supports__M (eLazyBoolCalculate), m_supports_qProcessInfoPID (true), m_supports_qfProcessInfo (true), m_supports_qUserName (true), @@ -130,6 +132,9 @@ m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; + m_supports__m = eLazyBoolCalculate; + m_supports__M = eLazyBoolCalculate; + m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; m_supports_qUserName = true; @@ -1016,17 +1021,23 @@ addr_t GDBRemoteCommunicationClient::AllocateMemory (size_t size, uint32_t permissions) { - char packet[64]; - const int packet_len = ::snprintf (packet, sizeof(packet), "_M%zx,%s%s%s", size, - permissions & lldb::ePermissionsReadable ? "r" : "", - permissions & lldb::ePermissionsWritable ? "w" : "", - permissions & lldb::ePermissionsExecutable ? "x" : ""); - assert (packet_len < sizeof(packet)); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + if (m_supports__M != eLazyBoolNo) { - if (!response.IsErrorResponse()) - return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); + m_supports__M = eLazyBoolYes; + char packet[64]; + const int packet_len = ::snprintf (packet, sizeof(packet), "_M%zx,%s%s%s", size, + permissions & lldb::ePermissionsReadable ? "r" : "", + permissions & lldb::ePermissionsWritable ? "w" : "", + permissions & lldb::ePermissionsExecutable ? "x" : ""); + assert (packet_len < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + { + if (response.IsUnsupportedResponse()) + m_supports__M = eLazyBoolNo; + else if (!response.IsErrorResponse()) + return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); + } } return LLDB_INVALID_ADDRESS; } @@ -1034,14 +1045,20 @@ bool GDBRemoteCommunicationClient::DeallocateMemory (addr_t addr) { - char packet[64]; - const int packet_len = ::snprintf(packet, sizeof(packet), "_m%llx", (uint64_t)addr); - assert (packet_len < sizeof(packet)); - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + if (m_supports__m != eLazyBoolNo) { - if (response.IsOKResponse()) - return true; + m_supports__m = eLazyBoolYes; + char packet[64]; + const int packet_len = ::snprintf(packet, sizeof(packet), "_m%llx", (uint64_t)addr); + assert (packet_len < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + { + if (response.IsOKResponse()) + return true; + else if (response.IsUnsupportedResponse()) + m_supports__m = eLazyBoolNo; + } } return false; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Fri May 13 20:50:35 2011 @@ -305,6 +305,18 @@ bool SetCurrentThreadForRun (int tid); + lldb_private::LazyBool + SupportsAllocateMemory () const + { + return m_supports__M; + } + + lldb_private::LazyBool + SupportsDeallocateMemory () const + { + return m_supports__m; + } + protected: //------------------------------------------------------------------ @@ -319,6 +331,9 @@ lldb_private::LazyBool m_supports_vCont_s; lldb_private::LazyBool m_supports_vCont_S; lldb_private::LazyBool m_qHostInfo_is_valid; + lldb_private::LazyBool m_supports__m; + lldb_private::LazyBool m_supports__M; + bool m_supports_qProcessInfoPID:1, m_supports_qfProcessInfo:1, @@ -330,6 +345,7 @@ m_supports_z2:1, m_supports_z3:1, m_supports_z4:1; + lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri May 13 20:50:35 2011 @@ -11,8 +11,9 @@ #include #include #include -#include +#include // for mmap #include +#include #include // C++ Includes @@ -38,6 +39,7 @@ #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Target.h" #include "lldb/Target/TargetList.h" +#include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/PseudoTerminal.h" // Project includes @@ -1541,7 +1543,93 @@ lldb::addr_t ProcessGDBRemote::DoAllocateMemory (size_t size, uint32_t permissions, Error &error) { - addr_t allocated_addr = m_gdb_comm.AllocateMemory (size, permissions); + addr_t allocated_addr = LLDB_INVALID_ADDRESS; + + LazyBool supported = m_gdb_comm.SupportsAllocateMemory(); + switch (supported) + { + case eLazyBoolCalculate: + case eLazyBoolYes: + allocated_addr = m_gdb_comm.AllocateMemory (size, permissions); + if (allocated_addr != LLDB_INVALID_ADDRESS || supported == eLazyBoolYes) + return allocated_addr; + + case eLazyBoolNo: + // Call mmap() to create executable memory in the inferior.. + { + Thread *thread = GetThreadList().GetSelectedThread().get(); + if (thread == NULL) + thread = GetThreadList().GetThreadAtIndex(0).get(); + + const bool append = true; + const bool include_symbols = true; + SymbolContextList sc_list; + const uint32_t count = m_target.GetImages().FindFunctions (ConstString ("mmap"), + eFunctionNameTypeFull, + include_symbols, + append, + sc_list); + if (count > 0) + { + SymbolContext sc; + if (sc_list.GetContextAtIndex(0, sc)) + { + const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; + const bool use_inline_block_range = false; + const bool stop_other_threads = true; + const bool discard_on_error = true; + const bool try_all_threads = true; + const uint32_t single_thread_timeout_usec = 500000; + addr_t arg1_addr = 0; + addr_t arg2_len = size; + addr_t arg3_prot = PROT_NONE; + addr_t arg4_flags = MAP_ANON; + addr_t arg5_fd = -1; + addr_t arg6_offset = 0; + if (permissions & lldb::ePermissionsReadable) + arg3_prot |= PROT_READ; + if (permissions & lldb::ePermissionsWritable) + arg3_prot |= PROT_WRITE; + if (permissions & lldb::ePermissionsExecutable) + arg3_prot |= PROT_EXEC; + + AddressRange mmap_range; + if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) + { + lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread, + mmap_range.GetBaseAddress(), + stop_other_threads, + discard_on_error, + &arg1_addr, + &arg2_len, + &arg3_prot, + &arg4_flags, + &arg5_fd, + &arg6_offset)); + if (call_plan_sp) + { + StreamFile error_strm; + StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); + if (frame) + { + ExecutionContext exe_ctx; + frame->CalculateExecutionContext (exe_ctx); + ExecutionResults results = RunThreadPlan (exe_ctx, + call_plan_sp, + stop_other_threads, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_strm); + } + } + } + } + } + } + break; + } + if (allocated_addr == LLDB_INVALID_ADDRESS) error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %u", size, permissions); else Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131334&r1=131333&r2=131334&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Fri May 13 20:50:35 2011 @@ -37,20 +37,18 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread, Address &function, - lldb::addr_t arg, + addr_t arg, bool stop_other_threads, bool discard_on_error, - lldb::addr_t *this_arg, - lldb::addr_t *cmd_arg) : + addr_t *this_arg, + addr_t *cmd_arg) : ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), - m_arg_addr (arg), - m_args (NULL), m_process (thread.GetProcess()), m_thread (thread), m_takedown_done (false), - m_function_sp(NULL) + m_function_sp (NULL) { SetOkayToDiscard (discard_on_error); @@ -92,7 +90,7 @@ } } - lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target); + addr_t start_load_addr = m_start_addr.GetLoadAddress(&target); // Checkpoint the thread state so we can restore it later. if (log && log->GetVerbose()) @@ -108,17 +106,17 @@ thread.SetStopInfoToNothing(); m_function_addr = function; - lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); + addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (this_arg && cmd_arg) { if (!abi->PrepareTrivialCall (thread, m_function_sp, FunctionLoadAddr, - StartLoadAddr, + start_load_addr, this_arg, cmd_arg, - &m_arg_addr)) + &arg)) return; } else if (this_arg) @@ -126,10 +124,9 @@ if (!abi->PrepareTrivialCall (thread, m_function_sp, FunctionLoadAddr, - StartLoadAddr, + start_load_addr, this_arg, - &m_arg_addr, - NULL)) + &arg)) return; } else @@ -137,10 +134,104 @@ if (!abi->PrepareTrivialCall (thread, m_function_sp, FunctionLoadAddr, - StartLoadAddr, - &m_arg_addr, - NULL, - NULL)) + start_load_addr, + &arg)) + return; + } + + ReportRegisterState ("Function call was set up. Register state was:"); + + m_valid = true; +} + + +ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread, + Address &function, + bool stop_other_threads, + bool discard_on_error, + addr_t *arg1_ptr, + addr_t *arg2_ptr, + addr_t *arg3_ptr, + addr_t *arg4_ptr, + addr_t *arg5_ptr, + addr_t *arg6_ptr) : + ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), + m_valid (false), + m_stop_other_threads (stop_other_threads), + m_process (thread.GetProcess()), + m_thread (thread), + m_takedown_done (false), + m_function_sp(NULL) +{ + SetOkayToDiscard (discard_on_error); + + Process& process = thread.GetProcess(); + Target& target = process.GetTarget(); + const ABI *abi = process.GetABI().get(); + + if (!abi) + return; + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + + SetBreakpoints(); + + m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); + + ModuleSP executableModuleSP (target.GetExecutableModule()); + + if (!executableModuleSP) + { + log->Printf ("Can't execute code without an executable module."); + return; + } + else + { + ObjectFile *objectFile = executableModuleSP->GetObjectFile(); + if (!objectFile) + { + log->Printf ("Could not find object file for module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); + return; + } + m_start_addr = objectFile->GetEntryPointAddress(); + if (!m_start_addr.IsValid()) + { + log->Printf ("Could not find entry point address for executable module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); + return; + } + } + + addr_t start_load_addr = m_start_addr.GetLoadAddress(&target); + + // Checkpoint the thread state so we can restore it later. + if (log && log->GetVerbose()) + ReportRegisterState ("About to checkpoint thread before function call. Original register state was:"); + + if (!thread.CheckpointThreadState (m_stored_thread_state)) + { + if (log) + log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state."); + return; + } + // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding... + thread.SetStopInfoToNothing(); + + m_function_addr = function; + addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); + + if (!abi->PrepareTrivialCall (thread, + m_function_sp, + FunctionLoadAddr, + start_load_addr, + arg1_ptr, + arg2_ptr, + arg3_ptr, + arg4_ptr, + arg5_ptr, + arg6_ptr)) + { return; } @@ -205,18 +296,15 @@ } void -ThreadPlanCallFunction::GetDescription (Stream *s, lldb::DescriptionLevel level) +ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level) { - if (level == lldb::eDescriptionLevelBrief) + if (level == eDescriptionLevelBrief) { s->Printf("Function call thread plan"); } else { - if (m_args) - s->Printf("Thread plan to call 0x%llx with parsed arguments", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr); - else - s->Printf("Thread plan to call 0x%llx void * argument at: 0x%llx", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr); + s->Printf("Thread plan to call 0x%llx", m_function_addr.GetLoadAddress(&m_process.GetTarget())); } } @@ -248,12 +336,12 @@ // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on. // If it is not an internal breakpoint, consult OkayToDiscard. - lldb::StopInfoSP stop_info_sp = GetPrivateStopReason(); + StopInfoSP stop_info_sp = GetPrivateStopReason(); if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint) { uint64_t break_site_id = stop_info_sp->GetValue(); - lldb::BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id); + BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id); if (bp_site_sp) { uint32_t num_owners = bp_site_sp->GetNumberOfOwners(); @@ -386,7 +474,7 @@ bool ThreadPlanCallFunction::BreakpointsExplainStop() { - lldb::StopInfoSP stop_info_sp = GetPrivateStopReason(); + StopInfoSP stop_info_sp = GetPrivateStopReason(); if (m_cxx_language_runtime && m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp)) From gclayton at apple.com Sat May 14 20:25:55 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 01:25:55 -0000 Subject: [Lldb-commits] [lldb] r131370 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Target/ source/Expression/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/Process/gdb-remote/ source/Plugins/UnwindAssembly/InstEmulation/ source/Target/ Message-ID: <20110515012555.DFF422A6C12C@llvm.org> Author: gclayton Date: Sat May 14 20:25:55 2011 New Revision: 131370 URL: http://llvm.org/viewvc/llvm-project?rev=131370&view=rev Log: Added the ability to get the return value from a ThreadPlanCallFunction thread plan. In order to get the return value, you can call: void ThreadPlanCallFunction::RequestReturnValue (lldb::ValueSP &return_value_sp); This registers a shared pointer to a return value that will get filled in if everything goes well. After the thread plan is run the return value will be extracted for you. Added an ifdef to be able to switch between the LLVM MCJIT and the standand JIT. We currently have the standard JIT selected because we have some work to do to get the MCJIT fuctioning properly. Added the ability to call functions with 6 argument in the x86_64 ABI. Added the ability for GDBRemoteCommunicationClient to detect if the allocate and deallocate memory packets are supported and to not call allocate memory ("_M") or deallocate ("_m") if we find they aren't supported. Modified the ProcessGDBRemote::DoAllocateMemory(...) and ProcessGDBRemote::DoDeallocateMemory(...) to be able to deal with the allocate and deallocate memory packets not being supported. If they are not supported, ProcessGDBRemote will switch to calling "mmap" and "munmap" to allocate and deallocate memory instead using our trivial function call support. Modified the "void ProcessGDBRemote::DidLaunchOrAttach()" to correctly ignore the qHostInfo triple information if any was specified in the target. Currently if the target only specifies an architecture when creating the target: (lldb) target create --arch i386 a.out Then the vendor, os and environemnt will be adopted by the target. If the target was created with any triple that specifies more than the arch: (lldb) target create --arch i386-unknown-unknown a.out Then the target will maintain its triple and not adopt any new values. This can be used to help force bare board debugging where the dynamic loader for static files will get used and users can then use "target modules load ..." to set addressses for any files that are desired. Added back some convenience functions to the lldb_private::RegisterContext class for writing registers with unsigned values. Also made all RegisterContext constructors explicit to make sure we know when an integer is being converted to a RegisterValue. Modified: lldb/trunk/include/lldb/Core/RegisterValue.h lldb/trunk/include/lldb/Target/RegisterContext.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Target/RegisterContext.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Core/RegisterValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h (original) +++ lldb/trunk/include/lldb/Core/RegisterValue.h Sat May 14 20:25:55 2011 @@ -51,24 +51,28 @@ { } + explicit RegisterValue (uint8_t inst) : m_type (eTypeUInt8) { m_data.uint8 = inst; } + explicit RegisterValue (uint16_t inst) : m_type (eTypeUInt16) { m_data.uint16 = inst; } + explicit RegisterValue (uint32_t inst) : m_type (eTypeUInt32) { m_data.uint32 = inst; } + explicit RegisterValue (uint64_t inst) : m_type (eTypeUInt64) { @@ -76,30 +80,35 @@ } #if defined (ENABLE_128_BIT_SUPPORT) + explicit RegisterValue (__uint128_t inst) : m_type (eTypeUInt128) { m_data.uint128 = inst; } #endif + explicit RegisterValue (float value) : m_type (eTypeFloat) { m_data.ieee_float = value; } + explicit RegisterValue (double value) : m_type (eTypeDouble) { m_data.ieee_double = value; } + explicit RegisterValue (long double value) : m_type (eTypeLongDouble) { m_data.ieee_long_double = value; } + explicit RegisterValue (uint8_t *bytes, size_t length, lldb::ByteOrder byte_order) { SetBytes (bytes, length, byte_order); Modified: lldb/trunk/include/lldb/Target/RegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/RegisterContext.h (original) +++ lldb/trunk/include/lldb/Target/RegisterContext.h Sat May 14 20:25:55 2011 @@ -142,10 +142,15 @@ uint64_t ReadRegisterAsUnsigned (uint32_t reg, uint64_t fail_value); + uint64_t + ReadRegisterAsUnsigned (const RegisterInfo *reg_info, uint64_t fail_value); + bool WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval); bool + WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval); + bool ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t& target_regnum); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Sat May 14 20:25:55 2011 @@ -80,7 +80,28 @@ { return true; } - + + // To get the return value from a function call you must create a + // lldb::ValueSP that contains a valid clang type in its context and call + // RequestReturnValue. The ValueSP will be stored and when the function is + // done executing, the object will check if there is a requested return + // value. If there is, the return value will be retrieved using the + // ABI::GetReturnValue() for the ABI in the process. Then after the thread + // plan is complete, you can call "GetReturnValue()" to retrieve the value + // that was extracted. + + const lldb::ValueSP & + GetReturnValue () + { + return m_return_value_sp; + } + + void + RequestReturnValue (lldb::ValueSP &return_value_sp) + { + m_return_value_sp = return_value_sp; + } + // Return the stack pointer that the function received // on entry. Any stack address below this should be // considered invalid after the function has been @@ -112,7 +133,6 @@ bool BreakpointsExplainStop (); - bool m_use_abi; bool m_valid; bool m_stop_other_threads; Address m_function_addr; @@ -125,6 +145,7 @@ LanguageRuntime *m_cxx_language_runtime; LanguageRuntime *m_objc_language_runtime; Thread::ThreadStateCheckpoint m_stored_thread_state; + lldb::ValueSP m_return_value_sp; // If this contains a valid pointer, use the ABI to extract values when complete bool m_takedown_done; // We want to ensure we only do the takedown once. This ensures that. DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunction); Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Sat May 14 20:25:55 2011 @@ -71,6 +71,8 @@ typedef SharedPtr::Type UserSettingsControllerSP; typedef SharedPtr::Type UnwindPlanSP; typedef SharedPtr::Type ValueObjectSP; + typedef SharedPtr::Type ValueSP; + typedef SharedPtr::Type ValueListSP; typedef SharedPtr::Type VariableSP; typedef SharedPtr::Type VariableListSP; typedef SharedPtr::Type ValueObjectListSP; Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Sat May 14 20:25:55 2011 @@ -52,7 +52,13 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" + +#define USE_STANDARD_JIT +#if defined (USE_STANDARD_JIT) #include "llvm/ExecutionEngine/JIT.h" +#else +#include "llvm/ExecutionEngine/MCJIT.h" +#endif #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Support/ErrorHandling.h" @@ -550,12 +556,24 @@ llvm::TargetMachine::setRelocationModel(llvm::Reloc::PIC_); +#if defined (USE_STANDARD_JIT) m_execution_engine.reset(llvm::ExecutionEngine::createJIT (module, &error_string, jit_memory_manager, CodeGenOpt::Less, true, CodeModel::Small)); +#else + EngineBuilder builder(module); + builder.setEngineKind(EngineKind::JIT) + .setErrorStr(&error_string) + .setJITMemoryManager(jit_memory_manager) + .setOptLevel(CodeGenOpt::Less) + .setAllocateGVsWithCode(true) + .setCodeModel(CodeModel::Small) + .setUseMCJIT(true); + m_execution_engine.reset(builder.create()); +#endif if (!m_execution_engine.get()) { Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Sat May 14 20:25:55 2011 @@ -70,9 +70,6 @@ addr_t *arg5_ptr, addr_t *arg6_ptr) const { - if (arg4_ptr || arg5_ptr || arg6_ptr) - return false; - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); if (log) @@ -89,32 +86,58 @@ if (!reg_ctx) return false; - RegisterValue reg_value; + const RegisterInfo *reg_info = NULL; if (arg1_ptr) { + reg_info = reg_ctx->GetRegisterInfoByName("rdi", 0); if (log) - log->Printf("About to write arg1 (0x%llx) into RDI", (uint64_t)*arg1_ptr); + log->Printf("About to write arg1 (0x%llx) into %s", (uint64_t)*arg1_ptr, reg_info->name); - reg_value.SetUInt64(*arg1_ptr); - if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rdi", 0), reg_value)) + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg1_ptr)) return false; if (arg2_ptr) { + reg_info = reg_ctx->GetRegisterInfoByName("rsi", 0); if (log) - log->Printf("About to write arg2 (0x%llx) into RSI", (uint64_t)*arg2_ptr); - - reg_value.SetUInt64(*arg2_ptr); - if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rsi", 0), reg_value)) + log->Printf("About to write arg2 (0x%llx) into %s", (uint64_t)*arg2_ptr, reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg2_ptr)) return false; if (arg3_ptr) { + reg_info = reg_ctx->GetRegisterInfoByName("rdx", 0); if (log) - log->Printf("About to write arg3 (0x%llx) into RDX", (uint64_t)*arg3_ptr); - reg_value.SetUInt64(*arg3_ptr); - if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName("rdx", 0), reg_value)) + log->Printf("About to write arg3 (0x%llx) into %s", (uint64_t)*arg3_ptr, reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg3_ptr)) return false; + + if (arg4_ptr) + { + reg_info = reg_ctx->GetRegisterInfoByName("rcx", 0); + if (log) + log->Printf("About to write arg4 (0x%llx) into %s", (uint64_t)*arg4_ptr, reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg4_ptr)) + return false; + + if (arg5_ptr) + { + reg_info = reg_ctx->GetRegisterInfoByName("r8", 0); + if (log) + log->Printf("About to write arg5 (0x%llx) into %s", (uint64_t)*arg5_ptr, reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg5_ptr)) + return false; + + if (arg6_ptr) + { + reg_info = reg_ctx->GetRegisterInfoByName("r9", 0); + if (log) + log->Printf("About to write arg6 (0x%llx) into %s", (uint64_t)*arg6_ptr, reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned (reg_info, *arg6_ptr)) + return false; + } + } + } } } } @@ -130,6 +153,7 @@ // The return address is pushed onto the stack (yes after the alignment...) sp -= 8; + RegisterValue reg_value; reg_value.SetUInt64 (return_addr); if (log) @@ -145,8 +169,7 @@ if (log) log->Printf("Writing SP (0x%llx) down", (uint64_t)sp); - reg_value.SetUInt64(sp); - if (!reg_ctx->WriteRegister (reg_ctx->GetRegisterInfoByName("rsp"), reg_value)) + if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfoByName("rsp"), sp)) return false; // %rip is set to the address of the called function. @@ -154,9 +177,7 @@ if (log) log->Printf("Writing new IP (0x%llx) down", (uint64_t)func_addr); - reg_value.SetUInt64(func_addr); - - if (!reg_ctx->WriteRegister(pc_reg_info, func_addr)) + if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) return false; return true; @@ -222,13 +243,13 @@ default: return false; case 8: - scalar = (uint8_t)(arg_contents & 0xff); + scalar = (uint8_t)(arg_contents & 0xffu); break; case 16: - scalar = (uint16_t)(arg_contents & 0xffff); + scalar = (uint16_t)(arg_contents & 0xffffu); break; case 32: - scalar = (uint32_t)(arg_contents & 0xffffffff); + scalar = (uint32_t)(arg_contents & 0xffffffffu); break; case 64: scalar = (uint64_t)arg_contents; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Sat May 14 20:25:55 2011 @@ -381,9 +381,9 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton, - StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id) + StoppointCallbackContext *context, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id) { AppleObjCVTables *vtable_handler = (AppleObjCVTables *) baton; if (vtable_handler->InitializeVTableSymbols()) Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Sat May 14 20:25:55 2011 @@ -45,8 +45,7 @@ m_supports_vCont_s (eLazyBoolCalculate), m_supports_vCont_S (eLazyBoolCalculate), m_qHostInfo_is_valid (eLazyBoolCalculate), - m_supports__m (eLazyBoolCalculate), - m_supports__M (eLazyBoolCalculate), + m_supports_alloc_dealloc_memory (eLazyBoolCalculate), m_supports_qProcessInfoPID (true), m_supports_qfProcessInfo (true), m_supports_qUserName (true), @@ -132,8 +131,7 @@ m_supports_vCont_s = eLazyBoolCalculate; m_supports_vCont_S = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; - m_supports__m = eLazyBoolCalculate; - m_supports__M = eLazyBoolCalculate; + m_supports_alloc_dealloc_memory = eLazyBoolCalculate; m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; @@ -1021,9 +1019,9 @@ addr_t GDBRemoteCommunicationClient::AllocateMemory (size_t size, uint32_t permissions) { - if (m_supports__M != eLazyBoolNo) + if (m_supports_alloc_dealloc_memory != eLazyBoolNo) { - m_supports__M = eLazyBoolYes; + m_supports_alloc_dealloc_memory = eLazyBoolYes; char packet[64]; const int packet_len = ::snprintf (packet, sizeof(packet), "_M%zx,%s%s%s", size, permissions & lldb::ePermissionsReadable ? "r" : "", @@ -1034,7 +1032,7 @@ if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { if (response.IsUnsupportedResponse()) - m_supports__M = eLazyBoolNo; + m_supports_alloc_dealloc_memory = eLazyBoolNo; else if (!response.IsErrorResponse()) return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); } @@ -1045,9 +1043,9 @@ bool GDBRemoteCommunicationClient::DeallocateMemory (addr_t addr) { - if (m_supports__m != eLazyBoolNo) + if (m_supports_alloc_dealloc_memory != eLazyBoolNo) { - m_supports__m = eLazyBoolYes; + m_supports_alloc_dealloc_memory = eLazyBoolYes; char packet[64]; const int packet_len = ::snprintf(packet, sizeof(packet), "_m%llx", (uint64_t)addr); assert (packet_len < sizeof(packet)); @@ -1057,7 +1055,7 @@ if (response.IsOKResponse()) return true; else if (response.IsUnsupportedResponse()) - m_supports__m = eLazyBoolNo; + m_supports_alloc_dealloc_memory = eLazyBoolNo; } } return false; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Sat May 14 20:25:55 2011 @@ -306,15 +306,9 @@ SetCurrentThreadForRun (int tid); lldb_private::LazyBool - SupportsAllocateMemory () const + SupportsAllocDeallocMemory () const { - return m_supports__M; - } - - lldb_private::LazyBool - SupportsDeallocateMemory () const - { - return m_supports__m; + return m_supports_alloc_dealloc_memory; } protected: @@ -331,8 +325,7 @@ lldb_private::LazyBool m_supports_vCont_s; lldb_private::LazyBool m_supports_vCont_S; lldb_private::LazyBool m_qHostInfo_is_valid; - lldb_private::LazyBool m_supports__m; - lldb_private::LazyBool m_supports__M; + lldb_private::LazyBool m_supports_alloc_dealloc_memory; bool m_supports_qProcessInfoPID:1, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sat May 14 20:25:55 2011 @@ -34,6 +34,7 @@ #include "lldb/Core/State.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" +#include "lldb/Core/Value.h" #include "lldb/Host/TimeValue.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" @@ -654,14 +655,18 @@ // Fill in what is missing in the triple const llvm::Triple &remote_triple = gdb_remote_arch.GetTriple(); llvm::Triple &target_triple = target_arch.GetTriple(); - if (target_triple.getVendor() == llvm::Triple::UnknownVendor) + if (target_triple.getVendorName().size() == 0) + { target_triple.setVendor (remote_triple.getVendor()); - if (target_triple.getOS() == llvm::Triple::UnknownOS) - target_triple.setOS (remote_triple.getOS()); + if (target_triple.getOSName().size() == 0) + { + target_triple.setOS (remote_triple.getOS()); - if (target_triple.getEnvironment() == llvm::Triple::UnknownEnvironment) - target_triple.setEnvironment (remote_triple.getEnvironment()); + if (target_triple.getEnvironmentName().size() == 0) + target_triple.setEnvironment (remote_triple.getEnvironment()); + } + } } } else @@ -1545,7 +1550,7 @@ { addr_t allocated_addr = LLDB_INVALID_ADDRESS; - LazyBool supported = m_gdb_comm.SupportsAllocateMemory(); + LazyBool supported = m_gdb_comm.SupportsAllocDeallocMemory(); switch (supported) { case eLazyBoolCalculate: @@ -1596,31 +1601,44 @@ AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { - lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread, - mmap_range.GetBaseAddress(), - stop_other_threads, - discard_on_error, - &arg1_addr, - &arg2_len, - &arg3_prot, - &arg4_flags, - &arg5_fd, - &arg6_offset)); + ThreadPlanCallFunction *call_function_thread_plan = new ThreadPlanCallFunction (*thread, + mmap_range.GetBaseAddress(), + stop_other_threads, + discard_on_error, + &arg1_addr, + &arg2_len, + &arg3_prot, + &arg4_flags, + &arg5_fd, + &arg6_offset); + lldb::ThreadPlanSP call_plan_sp (call_function_thread_plan); if (call_plan_sp) { + ValueSP return_value_sp (new Value); + ClangASTContext *clang_ast_context = m_target.GetScratchClangASTContext(); + lldb::clang_type_t clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); + return_value_sp->SetValueType (Value::eValueTypeScalar); + return_value_sp->SetContext (Value::eContextTypeClangType, clang_void_ptr_type); + call_function_thread_plan->RequestReturnValue (return_value_sp); + StreamFile error_strm; StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); if (frame) { ExecutionContext exe_ctx; frame->CalculateExecutionContext (exe_ctx); - ExecutionResults results = RunThreadPlan (exe_ctx, - call_plan_sp, - stop_other_threads, - try_all_threads, - discard_on_error, - single_thread_timeout_usec, - error_strm); + ExecutionResults result = RunThreadPlan (exe_ctx, + call_plan_sp, + stop_other_threads, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_strm); + if (result == eExecutionCompleted) + { + allocated_addr = return_value_sp->GetScalar().ULongLong(); + m_addr_to_mmap_size[allocated_addr] = size; + } } } } @@ -1641,8 +1659,91 @@ ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr) { Error error; - if (!m_gdb_comm.DeallocateMemory (addr)) - error.SetErrorStringWithFormat("unable to deallocate memory at 0x%llx", addr); + LazyBool supported = m_gdb_comm.SupportsAllocDeallocMemory(); + + switch (supported) + { + case eLazyBoolCalculate: + // We should never be deallocating memory without allocating memory + // first so we should never get eLazyBoolCalculate + error.SetErrorString ("tried to deallocate memory without ever allocating memory"); + break; + + case eLazyBoolYes: + if (!m_gdb_comm.DeallocateMemory (addr)) + error.SetErrorStringWithFormat("unable to deallocate memory at 0x%llx", addr); + break; + + case eLazyBoolNo: + // Call munmap() to create executable memory in the inferior.. + { + MMapMap::iterator pos = m_addr_to_mmap_size.find(addr); + if (pos != m_addr_to_mmap_size.end()) + { + Thread *thread = GetThreadList().GetSelectedThread().get(); + if (thread == NULL) + thread = GetThreadList().GetThreadAtIndex(0).get(); + + const bool append = true; + const bool include_symbols = true; + SymbolContextList sc_list; + const uint32_t count = m_target.GetImages().FindFunctions (ConstString ("munmap"), + eFunctionNameTypeFull, + include_symbols, + append, + sc_list); + if (count > 0) + { + SymbolContext sc; + if (sc_list.GetContextAtIndex(0, sc)) + { + const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; + const bool use_inline_block_range = false; + const bool stop_other_threads = true; + const bool discard_on_error = true; + const bool try_all_threads = true; + const uint32_t single_thread_timeout_usec = 500000; + addr_t arg1_addr = addr; + addr_t arg2_len = pos->second; + + AddressRange munmap_range; + if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range)) + { + lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread, + munmap_range.GetBaseAddress(), + stop_other_threads, + discard_on_error, + &arg1_addr, + &arg2_len)); + if (call_plan_sp) + { + StreamFile error_strm; + StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); + if (frame) + { + ExecutionContext exe_ctx; + frame->CalculateExecutionContext (exe_ctx); + ExecutionResults result = RunThreadPlan (exe_ctx, + call_plan_sp, + stop_other_threads, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_strm); + if (result == eExecutionCompleted) + { + m_addr_to_mmap_size.erase (pos); + } + } + } + } + } + } + } + } + break; + } + return error; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Sat May 14 20:25:55 2011 @@ -303,6 +303,7 @@ lldb::thread_t m_async_thread; typedef std::vector tid_collection; typedef std::vector< std::pair > tid_sig_collection; + typedef std::map MMapMap; tid_collection m_continue_c_tids; // 'c' for continue tid_sig_collection m_continue_C_tids; // 'C' for continue with signal tid_collection m_continue_s_tids; // 's' for step @@ -312,7 +313,7 @@ bool m_waiting_for_attach; bool m_local_debugserver; // Is the debugserver process we are talking to local or on another machine. std::vector m_thread_observation_bps; - + MMapMap m_addr_to_mmap_size; bool StartAsyncThread (); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Sat May 14 20:25:55 2011 @@ -43,7 +43,6 @@ m_dispatch_queue_name (), m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS) { -// ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD | GDBR_LOG_VERBOSE, "ThreadGDBRemote::ThreadGDBRemote ( pid = %i, tid = 0x%4.4x, )", m_process.GetID(), GetID()); ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID()); } Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Sat May 14 20:25:55 2011 @@ -84,7 +84,9 @@ m_pushed_regs.clear(); m_initial_sp = (1ull << ((addr_byte_size * 8) - 1)); - SetRegisterValue (m_cfa_reg_info, m_initial_sp); + RegisterValue cfa_reg_value; + cfa_reg_value.SetUInt (m_initial_sp, m_cfa_reg_info.byte_size); + SetRegisterValue (m_cfa_reg_info, cfa_reg_value); const InstructionList &inst_list = disasm_sp->GetInstructionList (); const size_t num_instructions = inst_list.GetSize(); Modified: lldb/trunk/source/Target/RegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Target/RegisterContext.cpp (original) +++ lldb/trunk/source/Target/RegisterContext.cpp Sat May 14 20:25:55 2011 @@ -150,14 +150,18 @@ RegisterContext::ReadRegisterAsUnsigned (uint32_t reg, uint64_t fail_value) { if (reg != LLDB_INVALID_REGNUM) + return ReadRegisterAsUnsigned (GetRegisterInfoAtIndex (reg), fail_value); + return fail_value; +} + +uint64_t +RegisterContext::ReadRegisterAsUnsigned (const RegisterInfo *reg_info, uint64_t fail_value) +{ + if (reg_info) { - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info) - { - RegisterValue value; - if (ReadRegister (reg_info, value)) - return value.GetAsUInt64(); - } + RegisterValue value; + if (ReadRegister (reg_info, value)) + return value.GetAsUInt64(); } return fail_value; } @@ -167,7 +171,12 @@ { if (reg == LLDB_INVALID_REGNUM) return false; - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); + return WriteRegisterFromUnsigned (GetRegisterInfoAtIndex (reg), uval); +} + +bool +RegisterContext::WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval) +{ if (reg_info) { RegisterValue value; Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131370&r1=131369&r2=131370&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Sat May 14 20:25:55 2011 @@ -272,6 +272,13 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (!m_takedown_done) { + // TODO: how do we tell if all went well? + if (m_return_value_sp) + { + const ABI *abi = m_thread.GetProcess().GetABI().get(); + if (abi) + abi->GetReturnValue(m_thread, *m_return_value_sp); + } if (log) log->Printf ("DoTakedown called for thread 0x%4.4x, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); m_takedown_done = true; From gclayton at apple.com Sat May 14 20:30:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 01:30:30 -0000 Subject: [Lldb-commits] [lldb] r131371 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110515013030.483F72A6C12C@llvm.org> Author: gclayton Date: Sat May 14 20:30:30 2011 New Revision: 131371 URL: http://llvm.org/viewvc/llvm-project?rev=131371&view=rev Log: Modified the lldb.xcodeproj to not have the headers in a copy files phase for lldb-core. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131371&r1=131370&r2=131371&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat May 14 20:30:30 2011 @@ -17,13 +17,10 @@ 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; }; 264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A97BD133918BC0017F0BE /* PlatformRemoteGDBServer.cpp */; }; - 264A97C0133918BC0017F0BE /* PlatformRemoteGDBServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 264A97BE133918BC0017F0BE /* PlatformRemoteGDBServer.h */; }; 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; - 26651A16133BF9CD005B64B7 /* Opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A15133BF9CC005B64B7 /* Opcode.h */; }; 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26651A17133BF9DF005B64B7 /* Opcode.cpp */; }; 266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266603C91345B5A8004DA8B6 /* ConnectionSharedMemory.cpp */; }; - 266603CD1345B5C0004DA8B6 /* ConnectionSharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 266603CC1345B5C0004DA8B6 /* ConnectionSharedMemory.h */; }; 2668020E115FD12C008E1FE4 /* lldb-defines.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668020F115FD12C008E1FE4 /* lldb-enumerations.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26680214115FD12C008E1FE4 /* lldb-types.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2910F1B3BC00F91463 /* lldb-types.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -67,33 +64,21 @@ 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; 266E8C6A13528ABC000C2042 /* lldb-platform in Resources */ = {isa = PBXBuildFile; fileRef = 26DC6A101337FE6900FF7998 /* lldb-platform */; }; - 2671A0CE134825F6003A87BB /* ConnectionMachPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 2671A0CD134825F6003A87BB /* ConnectionMachPort.h */; }; 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; }; 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; - 26744EF21338317700EF765A /* GDBRemoteCommunicationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */; }; 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; - 26744EF41338317700EF765A /* GDBRemoteCommunicationServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */; }; 267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; }; 267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; }; 2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */; }; 268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536F1370AE7200D186A3 /* OptionGroupUInt64.cpp */; }; - 2689000013353DB600698AC0 /* BreakpointResolverAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5010FE554D00271C65 /* BreakpointResolverAddress.h */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; - 2689000213353DB600698AC0 /* BreakpointResolverFileLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5110FE554D00271C65 /* BreakpointResolverFileLine.h */; }; 2689000313353DB600698AC0 /* BreakpointResolverFileLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5410FE555900271C65 /* BreakpointResolverFileLine.cpp */; }; - 2689000413353DB600698AC0 /* BreakpointResolverName.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D0DD5210FE554D00271C65 /* BreakpointResolverName.h */; }; 2689000513353DB600698AC0 /* BreakpointResolverName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5510FE555900271C65 /* BreakpointResolverName.cpp */; }; - 2689000613353DB600698AC0 /* BreakpointSite.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF710F1B71400F91463 /* BreakpointSite.h */; }; 2689000713353DB600698AC0 /* BreakpointSite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1310F1B83100F91463 /* BreakpointSite.cpp */; }; - 2689000813353DB600698AC0 /* BreakpointSiteList.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF810F1B71400F91463 /* BreakpointSiteList.h */; }; 2689000913353DB600698AC0 /* BreakpointSiteList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1410F1B83100F91463 /* BreakpointSiteList.cpp */; }; - 2689000A13353DB600698AC0 /* Stoppoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CFA10F1B71400F91463 /* Stoppoint.h */; }; 2689000B13353DB600698AC0 /* Stoppoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */; }; - 2689000C13353DB600698AC0 /* StoppointCallbackContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CED10F1B71400F91463 /* StoppointCallbackContext.h */; }; 2689000D13353DB600698AC0 /* StoppointCallbackContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0910F1B83100F91463 /* StoppointCallbackContext.cpp */; }; - 2689000E13353DB600698AC0 /* StoppointLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */; }; 2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */; }; - 2689001013353DB600698AC0 /* WatchpointLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */; }; 2689001113353DB600698AC0 /* WatchpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */; }; 2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; 2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; }; @@ -344,30 +329,19 @@ 268901161335BBC300698AC0 /* liblldb-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2689FFCA13353D7A00698AC0 /* liblldb-core.a */; }; 2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7410F1B85900F91463 /* lldb.cpp */; }; 2689FFDB13353DA300698AC0 /* lldb-log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7510F1B85900F91463 /* lldb-log.cpp */; }; - 2689FFEE13353DB600698AC0 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CEE10F1B71400F91463 /* Breakpoint.h */; }; 2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0A10F1B83100F91463 /* Breakpoint.cpp */; }; - 2689FFF013353DB600698AC0 /* BreakpointID.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CEF10F1B71400F91463 /* BreakpointID.h */; }; 2689FFF113353DB600698AC0 /* BreakpointID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0B10F1B83100F91463 /* BreakpointID.cpp */; }; - 2689FFF213353DB600698AC0 /* BreakpointIDList.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF010F1B71400F91463 /* BreakpointIDList.h */; }; 2689FFF313353DB600698AC0 /* BreakpointIDList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0C10F1B83100F91463 /* BreakpointIDList.cpp */; }; - 2689FFF413353DB600698AC0 /* BreakpointList.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF110F1B71400F91463 /* BreakpointList.h */; }; 2689FFF513353DB600698AC0 /* BreakpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0D10F1B83100F91463 /* BreakpointList.cpp */; }; - 2689FFF613353DB600698AC0 /* BreakpointLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF210F1B71400F91463 /* BreakpointLocation.h */; }; 2689FFF713353DB600698AC0 /* BreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0E10F1B83100F91463 /* BreakpointLocation.cpp */; }; - 2689FFF813353DB600698AC0 /* BreakpointLocationCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF310F1B71400F91463 /* BreakpointLocationCollection.h */; }; 2689FFF913353DB600698AC0 /* BreakpointLocationCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0F10F1B83100F91463 /* BreakpointLocationCollection.cpp */; }; - 2689FFFA13353DB600698AC0 /* BreakpointLocationList.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF410F1B71400F91463 /* BreakpointLocationList.h */; }; 2689FFFB13353DB600698AC0 /* BreakpointLocationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1010F1B83100F91463 /* BreakpointLocationList.cpp */; }; - 2689FFFC13353DB600698AC0 /* BreakpointOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF510F1B71400F91463 /* BreakpointOptions.h */; }; 2689FFFD13353DB600698AC0 /* BreakpointOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1110F1B83100F91463 /* BreakpointOptions.cpp */; }; - 2689FFFE13353DB600698AC0 /* BreakpointResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7CF610F1B71400F91463 /* BreakpointResolver.h */; }; 2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1210F1B83100F91463 /* BreakpointResolver.cpp */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; - 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; - 2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2697A54C133A6305004E4240 /* PlatformDarwin.h */; }; 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; }; 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; @@ -418,11 +392,8 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; - 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; - 4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */; }; 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; - 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */; }; 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; @@ -435,7 +406,6 @@ 9A3576A8116E9AB700E8ED2F /* SBHostOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; }; 9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */; }; - 9A4F35121368A54100823F52 /* StreamAsynchronousIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */; }; 9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; }; 9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AA69DAE118A023300D753A0 /* SBInputReader.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */; }; @@ -2637,36 +2607,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 2689FFEE13353DB600698AC0 /* Breakpoint.h in Headers */, - 2689FFF013353DB600698AC0 /* BreakpointID.h in Headers */, - 2689FFF213353DB600698AC0 /* BreakpointIDList.h in Headers */, - 2689FFF413353DB600698AC0 /* BreakpointList.h in Headers */, - 2689FFF613353DB600698AC0 /* BreakpointLocation.h in Headers */, - 2689FFF813353DB600698AC0 /* BreakpointLocationCollection.h in Headers */, - 2689FFFA13353DB600698AC0 /* BreakpointLocationList.h in Headers */, - 2689FFFC13353DB600698AC0 /* BreakpointOptions.h in Headers */, - 2689FFFE13353DB600698AC0 /* BreakpointResolver.h in Headers */, - 2689000013353DB600698AC0 /* BreakpointResolverAddress.h in Headers */, - 2689000213353DB600698AC0 /* BreakpointResolverFileLine.h in Headers */, - 2689000413353DB600698AC0 /* BreakpointResolverName.h in Headers */, - 2689000613353DB600698AC0 /* BreakpointSite.h in Headers */, - 2689000813353DB600698AC0 /* BreakpointSiteList.h in Headers */, - 2689000A13353DB600698AC0 /* Stoppoint.h in Headers */, - 2689000C13353DB600698AC0 /* StoppointCallbackContext.h in Headers */, - 2689000E13353DB600698AC0 /* StoppointLocation.h in Headers */, - 2689001013353DB600698AC0 /* WatchpointLocation.h in Headers */, - 26744EF21338317700EF765A /* GDBRemoteCommunicationClient.h in Headers */, - 26744EF41338317700EF765A /* GDBRemoteCommunicationServer.h in Headers */, - 264A97C0133918BC0017F0BE /* PlatformRemoteGDBServer.h in Headers */, - 2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */, - 26651A16133BF9CD005B64B7 /* Opcode.h in Headers */, - 266603CD1345B5C0004DA8B6 /* ConnectionSharedMemory.h in Headers */, - 2671A0CE134825F6003A87BB /* ConnectionMachPort.h in Headers */, - 4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */, - 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */, - 9A4F35121368A54100823F52 /* StreamAsynchronousIO.h in Headers */, - 4C2FAE2F135E3A70001EDE44 /* SharedCluster.h in Headers */, - 2692BA16136610C100F9E14D /* UnwindAssemblyInstEmulation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; From gclayton at apple.com Sat May 14 23:12:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 04:12:08 -0000 Subject: [Lldb-commits] [lldb] r131376 - in /lldb/trunk: include/lldb/Core/RegisterValue.h include/lldb/Interpreter/NamedOptionValue.h include/lldb/lldb-defines.h source/Commands/CommandObjectRegister.cpp source/Core/Debugger.cpp source/Core/EmulateInstruction.cpp source/Core/RegisterValue.cpp source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp tools/debugserver/source/DNBDefs.h tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Message-ID: <20110515041208.2380D2A6C12C@llvm.org> Author: gclayton Date: Sat May 14 23:12:07 2011 New Revision: 131376 URL: http://llvm.org/viewvc/llvm-project?rev=131376&view=rev Log: Added generic register numbers for simple ABI argument registers and defined the appropriate registers for arm and x86_64. The register names for the arguments that are the size of a pointer or less are all named "arg1", "arg2", etc. This allows you to read these registers by name: (lldb) register read arg1 arg2 arg3 ... You can also now specify you want to see alternate register names when executing the read register command: (lldb) register read --alternate (lldb) register read -A Modified: lldb/trunk/include/lldb/Core/RegisterValue.h lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h lldb/trunk/include/lldb/lldb-defines.h lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Core/RegisterValue.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/tools/debugserver/source/DNBDefs.h lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Modified: lldb/trunk/include/lldb/Core/RegisterValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h (original) +++ lldb/trunk/include/lldb/Core/RegisterValue.h Sat May 14 23:12:07 2011 @@ -334,7 +334,8 @@ Dump (Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, - lldb::Format format = lldb::eFormatDefault) const; + bool prefix_with_alt_name, + lldb::Format format) const; void * GetBytes (); Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original) +++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Sat May 14 23:12:07 2011 @@ -134,6 +134,12 @@ { return m_value_was_set; } + + void + SetOptionWasSet () + { + m_value_was_set = true; + } protected: bool m_value_was_set; // This can be used to see if a value has been set Modified: lldb/trunk/include/lldb/lldb-defines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-defines.h (original) +++ lldb/trunk/include/lldb/lldb-defines.h Sat May 14 23:12:07 2011 @@ -56,8 +56,15 @@ #define LLDB_REGNUM_GENERIC_FP 2 // Frame Pointer #define LLDB_REGNUM_GENERIC_RA 3 // Return Address #define LLDB_REGNUM_GENERIC_FLAGS 4 // Processor flags register - -//---------------------------------------------------------------------- +#define LLDB_REGNUM_GENERIC_ARG1 5 // The register that would contain pointer size or less argument 1 (if any) +#define LLDB_REGNUM_GENERIC_ARG2 6 // The register that would contain pointer size or less argument 2 (if any) +#define LLDB_REGNUM_GENERIC_ARG3 7 // The register that would contain pointer size or less argument 3 (if any) +#define LLDB_REGNUM_GENERIC_ARG4 8 // The register that would contain pointer size or less argument 4 (if any) +#define LLDB_REGNUM_GENERIC_ARG5 9 // The register that would contain pointer size or less argument 5 (if any) +#define LLDB_REGNUM_GENERIC_ARG6 10 // The register that would contain pointer size or less argument 6 (if any) +#define LLDB_REGNUM_GENERIC_ARG7 11 // The register that would contain pointer size or less argument 7 (if any) +#define LLDB_REGNUM_GENERIC_ARG8 12 // The register that would contain pointer size or less argument 8 (if any) +//--------------------------------------------------------------------- /// Invalid value definitions //---------------------------------------------------------------------- #define LLDB_INVALID_ADDRESS UINT64_MAX Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Sat May 14 23:12:07 2011 @@ -89,8 +89,9 @@ else format = m_options.format; - bool prefix_with_name = true; - reg_value.Dump(&strm, reg_info, prefix_with_name, m_options.format); + bool prefix_with_altname = m_options.alternate_name; + bool prefix_with_name = !prefix_with_altname; + reg_value.Dump(&strm, reg_info, prefix_with_name, prefix_with_altname, m_options.format); if (((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) && (reg_info->byte_size == reg_ctx->GetThread().GetProcess().GetAddressByteSize())) { @@ -245,7 +246,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter), set_indexes (OptionValue::ConvertTypeToMask (OptionValue::eTypeUInt64)), - dump_all_sets (false, false) // Initial and default values are false + dump_all_sets (false, false), // Initial and default values are false + alternate_name (false, false) { OptionParsingStarting(); } @@ -275,9 +277,21 @@ break; case 'a': - dump_all_sets.SetCurrentValue(true); + // When we don't use OptionValue::SetValueFromCString(const char *) to + // set an option value, it won't be marked as being set in the options + // so we make a call to let users know the value was set via option + dump_all_sets.SetCurrentValue (true); + dump_all_sets.SetOptionWasSet (); break; + case 'A': + // When we don't use OptionValue::SetValueFromCString(const char *) to + // set an option value, it won't be marked as being set in the options + // so we make a call to let users know the value was set via option + alternate_name.SetCurrentValue (true); + dump_all_sets.SetOptionWasSet (); + break; + default: error.SetErrorStringWithFormat("Unrecognized short option '%c'\n", short_option); break; @@ -291,6 +305,7 @@ format = eFormatDefault; set_indexes.Clear(); dump_all_sets.Clear(); + alternate_name.Clear(); } const OptionDefinition* @@ -307,6 +322,7 @@ lldb::Format format; OptionValueArray set_indexes; OptionValueBoolean dump_all_sets; + OptionValueBoolean alternate_name; }; CommandOptions m_options; @@ -315,9 +331,10 @@ OptionDefinition CommandObjectRegisterRead::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format to use when dumping register values."}, - { LLDB_OPT_SET_1 , false, "set" , 's', required_argument, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."}, - { LLDB_OPT_SET_2 , false, "all" , 'a', no_argument , NULL, 0, eArgTypeNone , "Show all register sets."}, + { LLDB_OPT_SET_ALL, false, "format" , 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format to use when dumping register values."}, + { LLDB_OPT_SET_ALL, false, "alternate", 'A', no_argument , NULL, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."}, + { LLDB_OPT_SET_1 , false, "set" , 's', required_argument, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."}, + { LLDB_OPT_SET_2 , false, "all" , 'a', no_argument , NULL, 0, eArgTypeNone , "Show all register sets."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat May 14 23:12:07 2011 @@ -1112,7 +1112,7 @@ var_success = reg_ctx->ReadRegister (reg_info, reg_value); if (var_success) { - reg_value.Dump(&s, reg_info, false); + reg_value.Dump(&s, reg_info, false, false, eFormatDefault); } } Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Sat May 14 23:12:07 2011 @@ -421,7 +421,7 @@ { StreamFile strm (stdout, false); strm.Printf (" Write to Register (name = %s, value = " , reg_info->name); - reg_value.Dump(&strm, reg_info, false); + reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); strm.PutCString (", context = "); context.Dump (strm, instruction); strm.EOL(); Modified: lldb/trunk/source/Core/RegisterValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp (original) +++ lldb/trunk/source/Core/RegisterValue.cpp Sat May 14 23:12:07 2011 @@ -24,13 +24,49 @@ bool -RegisterValue::Dump (Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, Format format) const +RegisterValue::Dump (Stream *s, + const RegisterInfo *reg_info, + bool prefix_with_name, + bool prefix_with_alt_name, + Format format) const { DataExtractor data; if (GetData (data)) { - if (prefix_with_name && reg_info->name != NULL) - s->Printf ("%s = ", reg_info->name); + bool name_printed = false; + if (prefix_with_name) + { + if (reg_info->name) + { + s->Printf ("%s", reg_info->name); + name_printed = true; + } + else if (reg_info->alt_name) + { + s->Printf ("%s", reg_info->alt_name); + prefix_with_alt_name = false; + name_printed = true; + } + } + if (prefix_with_alt_name) + { + if (name_printed) + s->PutChar ('/'); + if (reg_info->alt_name) + { + s->Printf ("%s", reg_info->alt_name); + name_printed = true; + } + else if (!name_printed) + { + // No alternate name but we were asked to display a name, so show the main name + s->Printf ("%s", reg_info->name); + name_printed = true; + } + } + if (name_printed) + s->PutCString (" = "); + if (format == eFormatDefault) format = reg_info->format; Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Sat May 14 23:12:07 2011 @@ -412,7 +412,7 @@ StreamString strm; strm.Printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => synthetic_value = %i, value = ", reg_info->name, synthetic); - reg_value.Dump(&strm, reg_info, false, eFormatDefault); + reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); log->PutCString(strm.GetData()); } return true; @@ -442,7 +442,7 @@ StreamString strm; strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name); - reg_value.Dump(&strm, reg_info, false, eFormatDefault); + reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); strm.PutCString (", context = "); context.Dump(strm, instruction); log->PutCString(strm.GetData()); Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBDefs.h (original) +++ lldb/trunk/tools/debugserver/source/DNBDefs.h Sat May 14 23:12:07 2011 @@ -163,6 +163,14 @@ #define GENERIC_REGNUM_FP 2 // Frame Pointer #define GENERIC_REGNUM_RA 3 // Return Address #define GENERIC_REGNUM_FLAGS 4 // Processor flags register +#define GENERIC_REGNUM_ARG1 5 // The register that would contain pointer size or less argument 1 (if any) +#define GENERIC_REGNUM_ARG2 6 // The register that would contain pointer size or less argument 2 (if any) +#define GENERIC_REGNUM_ARG3 7 // The register that would contain pointer size or less argument 3 (if any) +#define GENERIC_REGNUM_ARG4 8 // The register that would contain pointer size or less argument 4 (if any) +#define GENERIC_REGNUM_ARG5 9 // The register that would contain pointer size or less argument 5 (if any) +#define GENERIC_REGNUM_ARG6 10 // The register that would contain pointer size or less argument 6 (if any) +#define GENERIC_REGNUM_ARG7 11 // The register that would contain pointer size or less argument 7 (if any) +#define GENERIC_REGNUM_ARG8 12 // The register that would contain pointer size or less argument 8 (if any) enum DNBRegisterType { Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Sat May 14 23:12:07 2011 @@ -2544,10 +2544,10 @@ const DNBRegisterInfo DNBArchMachARM::g_gpr_registers[] = { - DEFINE_GPR_IDX ( 0, r0, NULL, INVALID_NUB_REGNUM ), - DEFINE_GPR_IDX ( 1, r1, NULL, INVALID_NUB_REGNUM ), - DEFINE_GPR_IDX ( 2, r2, NULL, INVALID_NUB_REGNUM ), - DEFINE_GPR_IDX ( 3, r3, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 0, r0,"arg1", GENERIC_REGNUM_ARG1 ), + DEFINE_GPR_IDX ( 1, r1,"arg2", GENERIC_REGNUM_ARG2 ), + DEFINE_GPR_IDX ( 2, r2,"arg3", GENERIC_REGNUM_ARG3 ), + DEFINE_GPR_IDX ( 3, r3,"arg4", GENERIC_REGNUM_ARG4 ), DEFINE_GPR_IDX ( 4, r4, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX ( 5, r5, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX ( 6, r6, NULL, INVALID_NUB_REGNUM ), @@ -2560,7 +2560,7 @@ DEFINE_GPR_NAME (sp, "r13", GENERIC_REGNUM_SP ), DEFINE_GPR_NAME (lr, "r14", GENERIC_REGNUM_RA ), DEFINE_GPR_NAME (pc, "r15", GENERIC_REGNUM_PC ), - DEFINE_GPR_NAME (cpsr, NULL, GENERIC_REGNUM_FLAGS ) + DEFINE_GPR_NAME (cpsr, "flags", GENERIC_REGNUM_FLAGS ) }; // Floating point registers Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=131376&r1=131375&r2=131376&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Sat May 14 23:12:07 2011 @@ -819,6 +819,7 @@ #define DEFINE_GPR(reg) { e_regSetGPR, gpr_##reg, #reg, NULL, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), gcc_dwarf_##reg, gcc_dwarf_##reg, INVALID_NUB_REGNUM, gdb_##reg } #define DEFINE_GPR_ALT(reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), gcc_dwarf_##reg, gcc_dwarf_##reg, gen, gdb_##reg } #define DEFINE_GPR_ALT2(reg, alt) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, gdb_##reg } +#define DEFINE_GPR_ALT3(reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, gen, gdb_##reg } // General purpose registers for 64 bit const DNBRegisterInfo @@ -826,22 +827,22 @@ { DEFINE_GPR (rax), DEFINE_GPR (rbx), - DEFINE_GPR (rcx), - DEFINE_GPR (rdx), - DEFINE_GPR (rdi), - DEFINE_GPR (rsi), - DEFINE_GPR_ALT (rbp, "fp", GENERIC_REGNUM_FP), - DEFINE_GPR_ALT (rsp, "sp", GENERIC_REGNUM_SP), - DEFINE_GPR (r8), - DEFINE_GPR (r9), + DEFINE_GPR_ALT (rcx , "arg4", GENERIC_REGNUM_ARG4), + DEFINE_GPR_ALT (rdx , "arg3", GENERIC_REGNUM_ARG3), + DEFINE_GPR_ALT (rdi , "arg1", GENERIC_REGNUM_ARG1), + DEFINE_GPR_ALT (rsi , "arg2", GENERIC_REGNUM_ARG2), + DEFINE_GPR_ALT (rbp , "fp" , GENERIC_REGNUM_FP), + DEFINE_GPR_ALT (rsp , "sp" , GENERIC_REGNUM_SP), + DEFINE_GPR_ALT (r8 , "arg5", GENERIC_REGNUM_ARG5), + DEFINE_GPR_ALT (r9 , "arg6", GENERIC_REGNUM_ARG6), DEFINE_GPR (r10), DEFINE_GPR (r11), DEFINE_GPR (r12), DEFINE_GPR (r13), DEFINE_GPR (r14), DEFINE_GPR (r15), - DEFINE_GPR_ALT (rip, "pc", GENERIC_REGNUM_PC), - DEFINE_GPR_ALT2 (rflags, "flags"), + DEFINE_GPR_ALT (rip , "pc", GENERIC_REGNUM_PC), + DEFINE_GPR_ALT3 (rflags, "flags", GENERIC_REGNUM_FLAGS), DEFINE_GPR_ALT2 (cs, NULL), DEFINE_GPR_ALT2 (fs, NULL), DEFINE_GPR_ALT2 (gs, NULL), From mminutoli at gmail.com Sun May 15 03:52:40 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 15 May 2011 10:52:40 +0200 Subject: [Lldb-commits] Compilation fixed on linux. Message-ID: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> Hi all, with the following patch series lldb is compiling again on Linux. In patch 1/3 I have added all the Makefiles needed to compile the missing plugin. I tried to follow the naming convention for library names but I'm not totally sure of what I choose so if you could have a look I will be more than happy to fix them. All the rest are just fixes to make the whole thing compiling but again any feedback is more than welcome. Best regards Marco From mminutoli at gmail.com Sun May 15 03:52:41 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 15 May 2011 10:52:41 +0200 Subject: [Lldb-commits] [PATCH 1/3] Added Makefiles for new plugins. In-Reply-To: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305449563-27734-2-git-send-email-mminutoli@gmail.com> This patch add makefiles to build: * ArchDefaultUnwindPlan * ArchVolatileRegs * UnwindAssembly --- lib/Makefile | 6 +++++- source/Plugins/ArchDefaultUnwindPlan/x86/Makefile | 15 +++++++++++++++ source/Plugins/ArchVolatileRegs/x86/Makefile | 15 +++++++++++++++ source/Plugins/Makefile | 3 ++- .../Plugins/UnwindAssembly/InstEmulation/Makefile | 15 +++++++++++++++ source/Plugins/UnwindAssembly/x86/Makefile | 15 +++++++++++++++ 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 source/Plugins/ArchDefaultUnwindPlan/x86/Makefile create mode 100644 source/Plugins/ArchVolatileRegs/x86/Makefile create mode 100644 source/Plugins/UnwindAssembly/InstEmulation/Makefile create mode 100644 source/Plugins/UnwindAssembly/x86/Makefile diff --git a/lib/Makefile b/lib/Makefile index 29025a7..c5c276d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 LINK_LIBS_IN_SHARED = 1 SHARED_LIBRARY = 1 -PYTHON_BUILD_FLAGS = -lpython2.6 +PYTHON_BUILD_FLAGS = -lpython2.7 # Include all archives in liblldb.a files USEDLIBS = lldbAPI.a \ @@ -28,6 +28,8 @@ USEDLIBS = lldbAPI.a \ lldbHostCommon.a \ lldbInitAndLog.a \ lldbInterpreter.a \ + lldbPluginArchDefaultUnwindPlan_x86.a \ + lldbPluginArchVolatileRegs_x86.a \ lldbPluginABIMacOSX_i386.a \ lldbPluginABISysV_x86_64.a \ lldbPluginDisassemblerLLVM.a \ @@ -39,6 +41,8 @@ USEDLIBS = lldbAPI.a \ lldbPluginProcessGDBRemote.a \ lldbPluginSymbolFileDWARF.a \ lldbPluginSymbolFileSymtab.a \ + lldbPluginUnwindAssembly.a \ + lldbPluginUnwindAssemblyInstEmulation.a \ lldbPluginUtility.a \ lldbSymbol.a \ lldbTarget.a \ diff --git a/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile new file mode 100644 index 0000000..6b68703 --- /dev/null +++ b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile @@ -0,0 +1,15 @@ +##===- source/Plugins/ArchDefaultUnwindPlan/x86/Makefile ---*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginArchDefaultUnwindPlan_x86 +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile diff --git a/source/Plugins/ArchVolatileRegs/x86/Makefile b/source/Plugins/ArchVolatileRegs/x86/Makefile new file mode 100644 index 0000000..2580127 --- /dev/null +++ b/source/Plugins/ArchVolatileRegs/x86/Makefile @@ -0,0 +1,15 @@ +##===- source/Plugins/ArchVolatileRegs/x86/Makefile --------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginArchVolatileRegs_x86 +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile diff --git a/source/Plugins/Makefile b/source/Plugins/Makefile index 4261d7e..fa32536 100644 --- a/source/Plugins/Makefile +++ b/source/Plugins/Makefile @@ -15,7 +15,8 @@ include $(LLDB_LEVEL)/../../Makefile.config DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ SymbolFile/Symtab Process/Utility DynamicLoader/Static \ - Platform Process/gdb-remote Instruction/ARM + Platform Process/gdb-remote Instruction/ARM ArchDefaultUnwindPlan/x86 \ + ArchVolatileRegs/x86 UnwindAssembly/x86 UnwindAssembly/InstEmulation ifeq ($(HOST_OS),Darwin) DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ diff --git a/source/Plugins/UnwindAssembly/InstEmulation/Makefile b/source/Plugins/UnwindAssembly/InstEmulation/Makefile new file mode 100644 index 0000000..1ab4aaf --- /dev/null +++ b/source/Plugins/UnwindAssembly/InstEmulation/Makefile @@ -0,0 +1,15 @@ +##==- source/Plugins/UnwindAssembly/InstEmulation/Makefile -*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginUnwindAssemblyInstEmulation +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile diff --git a/source/Plugins/UnwindAssembly/x86/Makefile b/source/Plugins/UnwindAssembly/x86/Makefile new file mode 100644 index 0000000..eb16484 --- /dev/null +++ b/source/Plugins/UnwindAssembly/x86/Makefile @@ -0,0 +1,15 @@ +##===- source/Plugins/UnwindAssembly/x86/Makefile ----------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginUnwindAssembly +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile -- 1.7.3.4 From mminutoli at gmail.com Sun May 15 03:52:42 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 15 May 2011 10:52:42 +0200 Subject: [Lldb-commits] [PATCH 2/3] API fix and missing headers. In-Reply-To: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305449563-27734-3-git-send-email-mminutoli@gmail.com> Host.cpp was missing Error.h and the implementation of LaunchProcess. Once againg I have added a "fake" implementation waiting for a real one. Fixed the call GetAddressRange to reflect the new interface in DynamicLoaderLinuxDYLD.cpp. Added string.h to ARM_DWARF_Registers.cpp that is needed for ::memset. --- source/Host/linux/Host.cpp | 10 ++++++++++ .../Linux-DYLD/DynamicLoaderLinuxDYLD.cpp | 2 +- source/Utility/ARM_DWARF_Registers.cpp | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp index b0d43e8..4ebacc5 100644 --- a/source/Host/linux/Host.cpp +++ b/source/Host/linux/Host.cpp @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Error.h" #include "lldb/Host/Host.h" using namespace lldb; @@ -33,3 +34,12 @@ Host::GetOSVersion(uint32_t &major, status = sscanf(un.release, "%u.%u.%u", &major, &minor, &update); return status == 3; } + +Error +Host::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + assert(!"Not implemented yet!!!"); + return error; +} + diff --git a/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp b/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp index 1eda619..898c36e 100644 --- a/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp +++ b/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp @@ -321,7 +321,7 @@ DynamicLoaderLinuxDYLD::GetStepThroughTrampolinePlan(Thread &thread, bool stop) AddressRange range; if (target_symbols.GetContextAtIndex(i, context)) { - context.GetAddressRange(eSymbolContextEverything, range); + context.GetAddressRange(eSymbolContextEverything, 0, false, range); lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target); if (addr != LLDB_INVALID_ADDRESS) addrs.push_back(addr); diff --git a/source/Utility/ARM_DWARF_Registers.cpp b/source/Utility/ARM_DWARF_Registers.cpp index 384171e..64a0ea6 100644 --- a/source/Utility/ARM_DWARF_Registers.cpp +++ b/source/Utility/ARM_DWARF_Registers.cpp @@ -9,6 +9,8 @@ #include "ARM_DWARF_Registers.h" +#include + using namespace lldb; using namespace lldb_private; -- 1.7.3.4 From mminutoli at gmail.com Sun May 15 03:52:43 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 15 May 2011 10:52:43 +0200 Subject: [Lldb-commits] [PATCH 3/3] A bit of clean up. In-Reply-To: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305449563-27734-4-git-send-email-mminutoli@gmail.com> Removed ifdeffed out functions and added the implementation of WriteRegister for x86_64 architecture. --- .../Process/Linux/RegisterContextLinux_i386.cpp | 59 +------------------- .../Process/Linux/RegisterContextLinux_x86_64.cpp | 46 ++------------- .../Process/Linux/RegisterContextLinux_x86_64.h | 17 ------ 3 files changed, 9 insertions(+), 113 deletions(-) diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp index 0a8ec5a..cc669d5 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp @@ -419,71 +419,18 @@ RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, return monitor.ReadRegisterValue(GetRegOffset(reg), value); } -#if 0 - -bool -RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg, - Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - bool RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 - -bool -RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg, - const Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.WriteRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} - -#endif - bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value) { - return false; + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteRegisterValue(GetRegOffset(reg), value); } bool diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp index 012690f..a3ce221 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp @@ -475,65 +475,31 @@ RegisterContextLinux_x86_64::GetRegisterSet(uint32_t set) return NULL; } -#if 0 bool -RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, - Scalar &value) +RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.ReadRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - -bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 bool -RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, - const Scalar &value) +RegisterContextLinux_x86_64::WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.WriteRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} -#endif - -bool RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) { return false; diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h index 2d210c6..d288d53 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h @@ -41,14 +41,6 @@ public: const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); -#if 0 - bool - ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); - - bool - ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); -#endif - virtual bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); @@ -56,15 +48,6 @@ public: bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); -#if 0 - bool - WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); - - bool - WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, - uint32_t data_offset = 0); -#endif - virtual bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); -- 1.7.3.4 From gclayton at apple.com Sun May 15 12:52:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 17:52:30 -0000 Subject: [Lldb-commits] [lldb] r131387 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Message-ID: <20110515175231.084722A6C12C@llvm.org> Author: gclayton Date: Sun May 15 12:52:30 2011 New Revision: 131387 URL: http://llvm.org/viewvc/llvm-project?rev=131387&view=rev Log: Fixed the default ARM registers to have the generic argument definitions and names. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131387&r1=131386&r2=131387&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Sun May 15 12:52:30 2011 @@ -412,10 +412,10 @@ static RegisterInfo g_register_infos[] = { // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB // ====== ====== === === ============= ============ =================== =================== ====================== === ==== - { "r0", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, 0, 0 }}, - { "r1", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, 1, 1 }}, - { "r2", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, 2, 2 }}, - { "r3", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, 3, 3 }}, + { "r0", "arg1", 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1,0, 0 }}, + { "r1", "arg2", 4, 0, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2,1, 1 }}, + { "r2", "arg3", 4, 0, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3,2, 2 }}, + { "r3", "arg4", 4, 0, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4,3, 3 }}, { "r4", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, 4, 4 }}, { "r5", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, 5, 5 }}, { "r6", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, 6, 6 }}, @@ -437,7 +437,7 @@ { "f6", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }}, { "f7", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }}, { "fps", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }}, - { "cpsr", "psr", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }}, + { "cpsr","flags", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }}, { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }}, { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }}, { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }}, From gclayton at apple.com Sun May 15 15:29:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 13:29:44 -0700 Subject: [Lldb-commits] [PATCH 1/3] Added Makefiles for new plugins. In-Reply-To: <1305449563-27734-2-git-send-email-mminutoli@gmail.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> <1305449563-27734-2-git-send-email-mminutoli@gmail.com> Message-ID: <7E687674-0CE8-4293-AC27-615E9EEEF402@apple.com> The ArchDefaultUnwindPlan and ArchVolatileRegs no longer exist in the SVN repository. Did you GIT repo not pick up this fact? So the the following directories no longer exist: source/Plugins/ArchDefaultUnwindPlan source/Plugins/ArchVolatileRegs And of course their original .h files that defined the plug-in interface. On May 15, 2011, at 1:52 AM, Marco Minutoli wrote: > This patch add makefiles to build: > * ArchDefaultUnwindPlan > * ArchVolatileRegs > * UnwindAssembly > --- > lib/Makefile | 6 +++++- > source/Plugins/ArchDefaultUnwindPlan/x86/Makefile | 15 +++++++++++++++ > source/Plugins/ArchVolatileRegs/x86/Makefile | 15 +++++++++++++++ > source/Plugins/Makefile | 3 ++- > .../Plugins/UnwindAssembly/InstEmulation/Makefile | 15 +++++++++++++++ > source/Plugins/UnwindAssembly/x86/Makefile | 15 +++++++++++++++ > 6 files changed, 67 insertions(+), 2 deletions(-) > create mode 100644 source/Plugins/ArchDefaultUnwindPlan/x86/Makefile > create mode 100644 source/Plugins/ArchVolatileRegs/x86/Makefile > create mode 100644 source/Plugins/UnwindAssembly/InstEmulation/Makefile > create mode 100644 source/Plugins/UnwindAssembly/x86/Makefile > > diff --git a/lib/Makefile b/lib/Makefile > index 29025a7..c5c276d 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 > LINK_LIBS_IN_SHARED = 1 > SHARED_LIBRARY = 1 > > -PYTHON_BUILD_FLAGS = -lpython2.6 > +PYTHON_BUILD_FLAGS = -lpython2.7 > > # Include all archives in liblldb.a files > USEDLIBS = lldbAPI.a \ > @@ -28,6 +28,8 @@ USEDLIBS = lldbAPI.a \ > lldbHostCommon.a \ > lldbInitAndLog.a \ > lldbInterpreter.a \ > + lldbPluginArchDefaultUnwindPlan_x86.a \ > + lldbPluginArchVolatileRegs_x86.a \ > lldbPluginABIMacOSX_i386.a \ > lldbPluginABISysV_x86_64.a \ > lldbPluginDisassemblerLLVM.a \ > @@ -39,6 +41,8 @@ USEDLIBS = lldbAPI.a \ > lldbPluginProcessGDBRemote.a \ > lldbPluginSymbolFileDWARF.a \ > lldbPluginSymbolFileSymtab.a \ > + lldbPluginUnwindAssembly.a \ > + lldbPluginUnwindAssemblyInstEmulation.a \ > lldbPluginUtility.a \ > lldbSymbol.a \ > lldbTarget.a \ > diff --git a/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile > new file mode 100644 > index 0000000..6b68703 > --- /dev/null > +++ b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile > @@ -0,0 +1,15 @@ > +##===- source/Plugins/ArchDefaultUnwindPlan/x86/Makefile ---*- Makefile -*-===## > +# > +# The LLVM Compiler Infrastructure > +# > +# This file is distributed under the University of Illinois Open Source > +# License. See LICENSE.TXT for details. > +# > +##===----------------------------------------------------------------------===## > + > + > +LLDB_LEVEL := ../../../.. > +LIBRARYNAME := lldbPluginArchDefaultUnwindPlan_x86 > +BUILD_ARCHIVE = 1 > + > +include $(LLDB_LEVEL)/Makefile > diff --git a/source/Plugins/ArchVolatileRegs/x86/Makefile b/source/Plugins/ArchVolatileRegs/x86/Makefile > new file mode 100644 > index 0000000..2580127 > --- /dev/null > +++ b/source/Plugins/ArchVolatileRegs/x86/Makefile > @@ -0,0 +1,15 @@ > +##===- source/Plugins/ArchVolatileRegs/x86/Makefile --------*- Makefile -*-===## > +# > +# The LLVM Compiler Infrastructure > +# > +# This file is distributed under the University of Illinois Open Source > +# License. See LICENSE.TXT for details. > +# > +##===----------------------------------------------------------------------===## > + > + > +LLDB_LEVEL := ../../../.. > +LIBRARYNAME := lldbPluginArchVolatileRegs_x86 > +BUILD_ARCHIVE = 1 > + > +include $(LLDB_LEVEL)/Makefile > diff --git a/source/Plugins/Makefile b/source/Plugins/Makefile > index 4261d7e..fa32536 100644 > --- a/source/Plugins/Makefile > +++ b/source/Plugins/Makefile > @@ -15,7 +15,8 @@ include $(LLDB_LEVEL)/../../Makefile.config > DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ > ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ > SymbolFile/Symtab Process/Utility DynamicLoader/Static \ > - Platform Process/gdb-remote Instruction/ARM > + Platform Process/gdb-remote Instruction/ARM ArchDefaultUnwindPlan/x86 \ > + ArchVolatileRegs/x86 UnwindAssembly/x86 UnwindAssembly/InstEmulation > > ifeq ($(HOST_OS),Darwin) > DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ > diff --git a/source/Plugins/UnwindAssembly/InstEmulation/Makefile b/source/Plugins/UnwindAssembly/InstEmulation/Makefile > new file mode 100644 > index 0000000..1ab4aaf > --- /dev/null > +++ b/source/Plugins/UnwindAssembly/InstEmulation/Makefile > @@ -0,0 +1,15 @@ > +##==- source/Plugins/UnwindAssembly/InstEmulation/Makefile -*- Makefile -*-===## > +# > +# The LLVM Compiler Infrastructure > +# > +# This file is distributed under the University of Illinois Open Source > +# License. See LICENSE.TXT for details. > +# > +##===----------------------------------------------------------------------===## > + > + > +LLDB_LEVEL := ../../../.. > +LIBRARYNAME := lldbPluginUnwindAssemblyInstEmulation > +BUILD_ARCHIVE = 1 > + > +include $(LLDB_LEVEL)/Makefile > diff --git a/source/Plugins/UnwindAssembly/x86/Makefile b/source/Plugins/UnwindAssembly/x86/Makefile > new file mode 100644 > index 0000000..eb16484 > --- /dev/null > +++ b/source/Plugins/UnwindAssembly/x86/Makefile > @@ -0,0 +1,15 @@ > +##===- source/Plugins/UnwindAssembly/x86/Makefile ----------*- Makefile -*-===## > +# > +# The LLVM Compiler Infrastructure > +# > +# This file is distributed under the University of Illinois Open Source > +# License. See LICENSE.TXT for details. > +# > +##===----------------------------------------------------------------------===## > + > + > +LLDB_LEVEL := ../../../.. > +LIBRARYNAME := lldbPluginUnwindAssembly > +BUILD_ARCHIVE = 1 > + > +include $(LLDB_LEVEL)/Makefile > -- > 1.7.3.4 > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From mminutoli at gmail.com Sun May 15 15:38:34 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 15 May 2011 22:38:34 +0200 Subject: [Lldb-commits] [PATCH 1/3] Added Makefiles for new plugins. In-Reply-To: <7E687674-0CE8-4293-AC27-615E9EEEF402@apple.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> <1305449563-27734-2-git-send-email-mminutoli@gmail.com> <7E687674-0CE8-4293-AC27-615E9EEEF402@apple.com> Message-ID: Unfortunately not. Maybe I am a bit out of date :). I am going to rebase and check all the other things. Just to ask is there any "official" git clone of the SVN repository? On Sun, May 15, 2011 at 10:29 PM, Greg Clayton wrote: > The ArchDefaultUnwindPlan and ArchVolatileRegs no longer exist in the SVN repository. Did you GIT repo not pick up this fact? > > So the the following directories no longer exist: > > source/Plugins/ArchDefaultUnwindPlan > source/Plugins/ArchVolatileRegs > > And of course their original .h files that defined the plug-in interface. > > > On May 15, 2011, at 1:52 AM, Marco Minutoli wrote: > >> This patch add makefiles to build: >> ? ? * ArchDefaultUnwindPlan >> ? ? * ArchVolatileRegs >> ? ? * UnwindAssembly >> --- >> lib/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?6 +++++- >> source/Plugins/ArchDefaultUnwindPlan/x86/Makefile ?| ? 15 +++++++++++++++ >> source/Plugins/ArchVolatileRegs/x86/Makefile ? ? ? | ? 15 +++++++++++++++ >> source/Plugins/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 ++- >> .../Plugins/UnwindAssembly/InstEmulation/Makefile ?| ? 15 +++++++++++++++ >> source/Plugins/UnwindAssembly/x86/Makefile ? ? ? ? | ? 15 +++++++++++++++ >> 6 files changed, 67 insertions(+), 2 deletions(-) >> create mode 100644 source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >> create mode 100644 source/Plugins/ArchVolatileRegs/x86/Makefile >> create mode 100644 source/Plugins/UnwindAssembly/InstEmulation/Makefile >> create mode 100644 source/Plugins/UnwindAssembly/x86/Makefile >> >> diff --git a/lib/Makefile b/lib/Makefile >> index 29025a7..c5c276d 100644 >> --- a/lib/Makefile >> +++ b/lib/Makefile >> @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 >> LINK_LIBS_IN_SHARED = 1 >> SHARED_LIBRARY = 1 >> >> -PYTHON_BUILD_FLAGS = -lpython2.6 >> +PYTHON_BUILD_FLAGS = -lpython2.7 >> >> # Include all archives in liblldb.a files >> USEDLIBS = lldbAPI.a \ >> @@ -28,6 +28,8 @@ USEDLIBS = lldbAPI.a \ >> ? ? ? lldbHostCommon.a \ >> ? ? ? lldbInitAndLog.a \ >> ? ? ? lldbInterpreter.a \ >> + ? ? lldbPluginArchDefaultUnwindPlan_x86.a \ >> + ? ? lldbPluginArchVolatileRegs_x86.a \ >> ? ? ? lldbPluginABIMacOSX_i386.a \ >> ? ? ? lldbPluginABISysV_x86_64.a \ >> ? ? ? lldbPluginDisassemblerLLVM.a \ >> @@ -39,6 +41,8 @@ USEDLIBS = lldbAPI.a \ >> ? ? ? lldbPluginProcessGDBRemote.a \ >> ? ? ? lldbPluginSymbolFileDWARF.a \ >> ? ? ? lldbPluginSymbolFileSymtab.a \ >> + ? ? lldbPluginUnwindAssembly.a \ >> + ? ? lldbPluginUnwindAssemblyInstEmulation.a \ >> ? ? ? lldbPluginUtility.a \ >> ? ? ? lldbSymbol.a \ >> ? ? ? lldbTarget.a \ >> diff --git a/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >> new file mode 100644 >> index 0000000..6b68703 >> --- /dev/null >> +++ b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >> @@ -0,0 +1,15 @@ >> +##===- source/Plugins/ArchDefaultUnwindPlan/x86/Makefile ---*- Makefile -*-===## >> +# >> +# ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +# >> +# This file is distributed under the University of Illinois Open Source >> +# License. See LICENSE.TXT for details. >> +# >> +##===----------------------------------------------------------------------===## >> + >> + >> +LLDB_LEVEL := ../../../.. >> +LIBRARYNAME := lldbPluginArchDefaultUnwindPlan_x86 >> +BUILD_ARCHIVE = 1 >> + >> +include $(LLDB_LEVEL)/Makefile >> diff --git a/source/Plugins/ArchVolatileRegs/x86/Makefile b/source/Plugins/ArchVolatileRegs/x86/Makefile >> new file mode 100644 >> index 0000000..2580127 >> --- /dev/null >> +++ b/source/Plugins/ArchVolatileRegs/x86/Makefile >> @@ -0,0 +1,15 @@ >> +##===- source/Plugins/ArchVolatileRegs/x86/Makefile --------*- Makefile -*-===## >> +# >> +# ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +# >> +# This file is distributed under the University of Illinois Open Source >> +# License. See LICENSE.TXT for details. >> +# >> +##===----------------------------------------------------------------------===## >> + >> + >> +LLDB_LEVEL := ../../../.. >> +LIBRARYNAME := lldbPluginArchVolatileRegs_x86 >> +BUILD_ARCHIVE = 1 >> + >> +include $(LLDB_LEVEL)/Makefile >> diff --git a/source/Plugins/Makefile b/source/Plugins/Makefile >> index 4261d7e..fa32536 100644 >> --- a/source/Plugins/Makefile >> +++ b/source/Plugins/Makefile >> @@ -15,7 +15,8 @@ include $(LLDB_LEVEL)/../../Makefile.config >> DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm ?\ >> ? ? ? ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ >> ? ? ? SymbolFile/Symtab Process/Utility DynamicLoader/Static \ >> - ? ? Platform Process/gdb-remote Instruction/ARM >> + ? ? Platform Process/gdb-remote Instruction/ARM ArchDefaultUnwindPlan/x86 \ >> + ? ? ArchVolatileRegs/x86 UnwindAssembly/x86 UnwindAssembly/InstEmulation >> >> ifeq ($(HOST_OS),Darwin) >> DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ >> diff --git a/source/Plugins/UnwindAssembly/InstEmulation/Makefile b/source/Plugins/UnwindAssembly/InstEmulation/Makefile >> new file mode 100644 >> index 0000000..1ab4aaf >> --- /dev/null >> +++ b/source/Plugins/UnwindAssembly/InstEmulation/Makefile >> @@ -0,0 +1,15 @@ >> +##==- source/Plugins/UnwindAssembly/InstEmulation/Makefile -*- Makefile -*-===## >> +# >> +# ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +# >> +# This file is distributed under the University of Illinois Open Source >> +# License. See LICENSE.TXT for details. >> +# >> +##===----------------------------------------------------------------------===## >> + >> + >> +LLDB_LEVEL := ../../../.. >> +LIBRARYNAME := lldbPluginUnwindAssemblyInstEmulation >> +BUILD_ARCHIVE = 1 >> + >> +include $(LLDB_LEVEL)/Makefile >> diff --git a/source/Plugins/UnwindAssembly/x86/Makefile b/source/Plugins/UnwindAssembly/x86/Makefile >> new file mode 100644 >> index 0000000..eb16484 >> --- /dev/null >> +++ b/source/Plugins/UnwindAssembly/x86/Makefile >> @@ -0,0 +1,15 @@ >> +##===- source/Plugins/UnwindAssembly/x86/Makefile ----------*- Makefile -*-===## >> +# >> +# ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +# >> +# This file is distributed under the University of Illinois Open Source >> +# License. See LICENSE.TXT for details. >> +# >> +##===----------------------------------------------------------------------===## >> + >> + >> +LLDB_LEVEL := ../../../.. >> +LIBRARYNAME := lldbPluginUnwindAssembly >> +BUILD_ARCHIVE = 1 >> + >> +include $(LLDB_LEVEL)/Makefile >> -- >> 1.7.3.4 >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > From gclayton at apple.com Sun May 15 15:49:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 13:49:01 -0700 Subject: [Lldb-commits] [PATCH 1/3] Added Makefiles for new plugins. In-Reply-To: References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> <1305449563-27734-2-git-send-email-mminutoli@gmail.com> <7E687674-0CE8-4293-AC27-615E9EEEF402@apple.com> Message-ID: <33BD5E68-C27F-4E43-96F3-33411A910026@apple.com> Not yet, but I am hoping to make one soon. I am really getting into git in the past couple of days and really like what I am seeing. Greg Clayton On May 15, 2011, at 1:38 PM, Marco Minutoli wrote: > Unfortunately not. Maybe I am a bit out of date :). > > I am going to rebase and check all the other things. > > Just to ask is there any "official" git clone of the SVN repository? > > > On Sun, May 15, 2011 at 10:29 PM, Greg Clayton wrote: >> The ArchDefaultUnwindPlan and ArchVolatileRegs no longer exist in the SVN repository. Did you GIT repo not pick up this fact? >> >> So the the following directories no longer exist: >> >> source/Plugins/ArchDefaultUnwindPlan >> source/Plugins/ArchVolatileRegs >> >> And of course their original .h files that defined the plug-in interface. >> >> >> On May 15, 2011, at 1:52 AM, Marco Minutoli wrote: >> >>> This patch add makefiles to build: >>> * ArchDefaultUnwindPlan >>> * ArchVolatileRegs >>> * UnwindAssembly >>> --- >>> lib/Makefile | 6 +++++- >>> source/Plugins/ArchDefaultUnwindPlan/x86/Makefile | 15 +++++++++++++++ >>> source/Plugins/ArchVolatileRegs/x86/Makefile | 15 +++++++++++++++ >>> source/Plugins/Makefile | 3 ++- >>> .../Plugins/UnwindAssembly/InstEmulation/Makefile | 15 +++++++++++++++ >>> source/Plugins/UnwindAssembly/x86/Makefile | 15 +++++++++++++++ >>> 6 files changed, 67 insertions(+), 2 deletions(-) >>> create mode 100644 source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >>> create mode 100644 source/Plugins/ArchVolatileRegs/x86/Makefile >>> create mode 100644 source/Plugins/UnwindAssembly/InstEmulation/Makefile >>> create mode 100644 source/Plugins/UnwindAssembly/x86/Makefile >>> >>> diff --git a/lib/Makefile b/lib/Makefile >>> index 29025a7..c5c276d 100644 >>> --- a/lib/Makefile >>> +++ b/lib/Makefile >>> @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 >>> LINK_LIBS_IN_SHARED = 1 >>> SHARED_LIBRARY = 1 >>> >>> -PYTHON_BUILD_FLAGS = -lpython2.6 >>> +PYTHON_BUILD_FLAGS = -lpython2.7 >>> >>> # Include all archives in liblldb.a files >>> USEDLIBS = lldbAPI.a \ >>> @@ -28,6 +28,8 @@ USEDLIBS = lldbAPI.a \ >>> lldbHostCommon.a \ >>> lldbInitAndLog.a \ >>> lldbInterpreter.a \ >>> + lldbPluginArchDefaultUnwindPlan_x86.a \ >>> + lldbPluginArchVolatileRegs_x86.a \ >>> lldbPluginABIMacOSX_i386.a \ >>> lldbPluginABISysV_x86_64.a \ >>> lldbPluginDisassemblerLLVM.a \ >>> @@ -39,6 +41,8 @@ USEDLIBS = lldbAPI.a \ >>> lldbPluginProcessGDBRemote.a \ >>> lldbPluginSymbolFileDWARF.a \ >>> lldbPluginSymbolFileSymtab.a \ >>> + lldbPluginUnwindAssembly.a \ >>> + lldbPluginUnwindAssemblyInstEmulation.a \ >>> lldbPluginUtility.a \ >>> lldbSymbol.a \ >>> lldbTarget.a \ >>> diff --git a/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >>> new file mode 100644 >>> index 0000000..6b68703 >>> --- /dev/null >>> +++ b/source/Plugins/ArchDefaultUnwindPlan/x86/Makefile >>> @@ -0,0 +1,15 @@ >>> +##===- source/Plugins/ArchDefaultUnwindPlan/x86/Makefile ---*- Makefile -*-===## >>> +# >>> +# The LLVM Compiler Infrastructure >>> +# >>> +# This file is distributed under the University of Illinois Open Source >>> +# License. See LICENSE.TXT for details. >>> +# >>> +##===----------------------------------------------------------------------===## >>> + >>> + >>> +LLDB_LEVEL := ../../../.. >>> +LIBRARYNAME := lldbPluginArchDefaultUnwindPlan_x86 >>> +BUILD_ARCHIVE = 1 >>> + >>> +include $(LLDB_LEVEL)/Makefile >>> diff --git a/source/Plugins/ArchVolatileRegs/x86/Makefile b/source/Plugins/ArchVolatileRegs/x86/Makefile >>> new file mode 100644 >>> index 0000000..2580127 >>> --- /dev/null >>> +++ b/source/Plugins/ArchVolatileRegs/x86/Makefile >>> @@ -0,0 +1,15 @@ >>> +##===- source/Plugins/ArchVolatileRegs/x86/Makefile --------*- Makefile -*-===## >>> +# >>> +# The LLVM Compiler Infrastructure >>> +# >>> +# This file is distributed under the University of Illinois Open Source >>> +# License. See LICENSE.TXT for details. >>> +# >>> +##===----------------------------------------------------------------------===## >>> + >>> + >>> +LLDB_LEVEL := ../../../.. >>> +LIBRARYNAME := lldbPluginArchVolatileRegs_x86 >>> +BUILD_ARCHIVE = 1 >>> + >>> +include $(LLDB_LEVEL)/Makefile >>> diff --git a/source/Plugins/Makefile b/source/Plugins/Makefile >>> index 4261d7e..fa32536 100644 >>> --- a/source/Plugins/Makefile >>> +++ b/source/Plugins/Makefile >>> @@ -15,7 +15,8 @@ include $(LLDB_LEVEL)/../../Makefile.config >>> DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ >>> ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ >>> SymbolFile/Symtab Process/Utility DynamicLoader/Static \ >>> - Platform Process/gdb-remote Instruction/ARM >>> + Platform Process/gdb-remote Instruction/ARM ArchDefaultUnwindPlan/x86 \ >>> + ArchVolatileRegs/x86 UnwindAssembly/x86 UnwindAssembly/InstEmulation >>> >>> ifeq ($(HOST_OS),Darwin) >>> DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ >>> diff --git a/source/Plugins/UnwindAssembly/InstEmulation/Makefile b/source/Plugins/UnwindAssembly/InstEmulation/Makefile >>> new file mode 100644 >>> index 0000000..1ab4aaf >>> --- /dev/null >>> +++ b/source/Plugins/UnwindAssembly/InstEmulation/Makefile >>> @@ -0,0 +1,15 @@ >>> +##==- source/Plugins/UnwindAssembly/InstEmulation/Makefile -*- Makefile -*-===## >>> +# >>> +# The LLVM Compiler Infrastructure >>> +# >>> +# This file is distributed under the University of Illinois Open Source >>> +# License. See LICENSE.TXT for details. >>> +# >>> +##===----------------------------------------------------------------------===## >>> + >>> + >>> +LLDB_LEVEL := ../../../.. >>> +LIBRARYNAME := lldbPluginUnwindAssemblyInstEmulation >>> +BUILD_ARCHIVE = 1 >>> + >>> +include $(LLDB_LEVEL)/Makefile >>> diff --git a/source/Plugins/UnwindAssembly/x86/Makefile b/source/Plugins/UnwindAssembly/x86/Makefile >>> new file mode 100644 >>> index 0000000..eb16484 >>> --- /dev/null >>> +++ b/source/Plugins/UnwindAssembly/x86/Makefile >>> @@ -0,0 +1,15 @@ >>> +##===- source/Plugins/UnwindAssembly/x86/Makefile ----------*- Makefile -*-===## >>> +# >>> +# The LLVM Compiler Infrastructure >>> +# >>> +# This file is distributed under the University of Illinois Open Source >>> +# License. See LICENSE.TXT for details. >>> +# >>> +##===----------------------------------------------------------------------===## >>> + >>> + >>> +LLDB_LEVEL := ../../../.. >>> +LIBRARYNAME := lldbPluginUnwindAssembly >>> +BUILD_ARCHIVE = 1 >>> + >>> +include $(LLDB_LEVEL)/Makefile >>> -- >>> 1.7.3.4 >>> >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >> >> From wilsons at start.ca Sun May 15 17:36:04 2011 From: wilsons at start.ca (Stephen Wilson) Date: Sun, 15 May 2011 18:36:04 -0400 Subject: [Lldb-commits] [PATCH 1/3] Added Makefiles for new plugins. In-Reply-To: <1305449563-27734-2-git-send-email-mminutoli@gmail.com> References: <1305449563-27734-1-git-send-email-mminutoli@gmail.com> <1305449563-27734-2-git-send-email-mminutoli@gmail.com> Message-ID: <20110515223604.GA11732@wicker.gateway.2wire.net> Hi Marco, On Sun, May 15, 2011 at 10:52:41AM +0200, Marco Minutoli wrote: > diff --git a/lib/Makefile b/lib/Makefile > index 29025a7..c5c276d 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 > LINK_LIBS_IN_SHARED = 1 > SHARED_LIBRARY = 1 > > -PYTHON_BUILD_FLAGS = -lpython2.6 > +PYTHON_BUILD_FLAGS = -lpython2.7 Perhaps when you respin this patch you might use "$(shell python-config --ldflags)" here instead? -- steve From scallanan at apple.com Sun May 15 17:34:38 2011 From: scallanan at apple.com (Sean Callanan) Date: Sun, 15 May 2011 22:34:38 -0000 Subject: [Lldb-commits] [lldb] r131391 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl source/Expression/IRForTarget.cpp source/Symbol/ClangASTContext.cpp source/Symbol/ClangASTType.cpp Message-ID: <20110515223438.E63C92A6C12C@llvm.org> Author: spyffe Date: Sun May 15 17:34:38 2011 New Revision: 131391 URL: http://llvm.org/viewvc/llvm-project?rev=131391&view=rev Log: Updated to use the latest LLVM/Clang, to pick up JIT changes. Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=131391&r1=131390&r2=131391&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=131391&r1=131390&r2=131391&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Sun May 15 17:34:38 2011 @@ -26,7 +26,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "129495"; +our $llvm_revision = "131389"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=131391&r1=131390&r2=131391&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Sun May 15 17:34:38 2011 @@ -455,7 +455,9 @@ values[0] = new_result_global; values[1] = new_constant_int; - MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), values, 2); + ArrayRef value_ref(values, 2); + + MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), value_ref); NamedMDNode *named_metadata = llvm_module.getNamedMetadata("clang.global.decl.ptrs"); named_metadata->addOperand(persistent_global_md); @@ -1097,8 +1099,10 @@ llvm::Value* values[2]; values[0] = persistent_global; values[1] = constant_int; + + ArrayRef value_ref(values, 2); - MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), values, 2); + MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), value_ref); named_metadata->addOperand(persistent_global_md); // Now, since the variable is a pointer variable, we will drop in a load of that @@ -1490,7 +1494,9 @@ Value *values[1]; values[0] = func_name; - MDNode *func_metadata = MDNode::get(llvm_module.getContext(), values, 1); + ArrayRef value_ref(values, 1); + + MDNode *func_metadata = MDNode::get(llvm_module.getContext(), value_ref); llvm_call_inst->setMetadata("lldb.call.realName", func_metadata); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=131391&r1=131390&r2=131391&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun May 15 17:34:38 2011 @@ -2355,6 +2355,7 @@ case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCClass: case clang::BuiltinType::ObjCSel: + case clang::BuiltinType::BoundMember: return 1; } break; @@ -4338,7 +4339,7 @@ const TypedefType *typedef_type = qual_type->getAs(); if (typedef_type) { - const TypedefDecl *typedef_decl = typedef_type->getDecl(); + const TypedefNameDecl *typedef_decl = typedef_type->getDecl(); return_name = typedef_decl->getQualifiedNameAsString(); } else Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=131391&r1=131390&r2=131391&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Sun May 15 17:34:38 2011 @@ -60,7 +60,7 @@ const clang::TypedefType *typedef_type = qual_type->getAs(); if (typedef_type) { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); + const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString()); if (!clang_typedef_name.empty()) clang_type_name.SetCString (clang_typedef_name.c_str()); @@ -1014,7 +1014,7 @@ const clang::TypedefType *typedef_type = qual_type->getAs(); if (typedef_type) { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); + const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString()); if (!clang_typedef_name.empty()) s->PutCString (clang_typedef_name.c_str()); From gclayton at apple.com Sun May 15 17:49:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 22:49:24 -0000 Subject: [Lldb-commits] [lldb] r131392 - in /lldb/trunk: source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp tools/darwin-debug/darwin-debug.cpp Message-ID: <20110515224924.751982A6C12C@llvm.org> Author: gclayton Date: Sun May 15 17:49:24 2011 New Revision: 131392 URL: http://llvm.org/viewvc/llvm-project?rev=131392&view=rev Log: Added the ability to get a 32 or 64 bit simple return value from the ABIMacOSX_arm plugin. Modified darwin-debug to print out the exectuable, working directory and arguments a bit differently. Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/tools/darwin-debug/darwin-debug.cpp Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=131392&r1=131391&r2=131392&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Sun May 15 17:49:24 2011 @@ -108,14 +108,12 @@ if (arg5_ptr) { reg_value.SetUInt32(*arg5_ptr); - sp -= 4; if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) return false; if (arg6_ptr) { reg_value.SetUInt32(*arg6_ptr); - sp -= 4; - if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) + if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp + 4, reg_info->byte_size, reg_value).Fail()) return false; } } @@ -300,84 +298,81 @@ ABIMacOSX_arm::GetReturnValue (Thread &thread, Value &value) const { -// switch (value.GetContextType()) -// { -// default: -// return false; -// case Value::eContextTypeClangType: -// { -// // Extract the Clang AST context from the PC so that we can figure out type -// // sizes -// -// clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); -// -// // Get the pointer to the first stack argument so we have a place to start -// // when reading data -// -// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); -// -// void *value_type = value.GetClangType(); -// bool is_signed; -// -// if (ClangASTContext::IsIntegerType (value_type, is_signed)) -// { -// size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); -// -// unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; -// unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; -// -// switch (bit_width) -// { -// default: -// case 128: -// // Scalar can't hold 128-bit literals, so we don't handle this -// return false; -// case 64: -// uint64_t raw_value; -// raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; -// raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32; -// if (is_signed) -// value.GetScalar() = (int64_t)raw_value; -// else -// value.GetScalar() = (uint64_t)raw_value; -// break; -// case 32: -// if (is_signed) -// value.GetScalar() = (int32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); -// else -// value.GetScalar() = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); -// break; -// case 16: -// if (is_signed) -// value.GetScalar() = (int16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); -// else -// value.GetScalar() = (uint16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); -// break; -// case 8: -// if (is_signed) -// value.GetScalar() = (int8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); -// else -// value.GetScalar() = (uint8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); -// break; -// } -// } -// else if (ClangASTContext::IsPointerType (value_type)) -// { -// unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; -// uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; -// value.GetScalar() = ptr; -// } -// else -// { -// // not handled yet -// return false; -// } -// } -// break; -// } -// -// return true; - return false; + switch (value.GetContextType()) + { + default: + return false; + case Value::eContextTypeClangType: + { + // Extract the Clang AST context from the PC so that we can figure out type + // sizes + + clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); + + // Get the pointer to the first stack argument so we have a place to start + // when reading data + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + void *value_type = value.GetClangType(); + bool is_signed; + + const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0); + if (ClangASTContext::IsIntegerType (value_type, is_signed)) + { + size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); + + switch (bit_width) + { + default: + return false; + case 64: + { + const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0); + uint64_t raw_value; + raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & UINT32_MAX)) << 32; + if (is_signed) + value.GetScalar() = (int64_t)raw_value; + else + value.GetScalar() = (uint64_t)raw_value; + } + break; + case 32: + if (is_signed) + value.GetScalar() = (int32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + break; + case 16: + if (is_signed) + value.GetScalar() = (int16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + break; + case 8: + if (is_signed) + value.GetScalar() = (int8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + break; + } + } + else if (ClangASTContext::IsPointerType (value_type)) + { + uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + value.GetScalar() = ptr; + } + else + { + // not handled yet + return false; + } + } + break; + } + + return true; } bool Modified: lldb/trunk/tools/darwin-debug/darwin-debug.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/darwin-debug.cpp?rev=131392&r1=131391&r2=131392&view=diff ============================================================================== --- lldb/trunk/tools/darwin-debug/darwin-debug.cpp (original) +++ lldb/trunk/tools/darwin-debug/darwin-debug.cpp Sun May 15 17:49:24 2011 @@ -282,14 +282,18 @@ close (s); system("clear"); + printf ("Launching: '%s'\n", argv[0]); if (working_dir.empty()) { char cwd[PATH_MAX]; const char *cwd_ptr = getcwd(cwd, sizeof(cwd)); - printf ("Launching '%s' in '%s' for debug with %u arguments:\n", argv[0], cwd_ptr, argc); + printf ("Working directory: '%s'\n", cwd_ptr); } else - printf ("Launching '%s' in '%s' for debug with %u arguments:\n", argv[0], working_dir.c_str(), argc); + { + printf ("Working directory: '%s'\n", working_dir.c_str()); + } + printf ("%i arguments:\n", argc); for (int i=0; i Author: gclayton Date: Sun May 15 18:46:54 2011 New Revision: 131393 URL: http://llvm.org/viewvc/llvm-project?rev=131393&view=rev Log: Properly handle when commands are not unsupported in the GDB remote clients. Prior to this fix we would often call SendPacketAndWaitForResponse() which returns the number of bytes in the response. The UNSUPPORTED response in the GDB remote protocol is zero bytes and we were checking for it inside an if statement: if (SendPacketAndWaitForResponse(...)) { if (response.IsUnsupportedResponse()) { // UNSUPPORTED... // This will never happen... } } We now handle is properly as: if (SendPacketAndWaitForResponse(...)) { } else { // UNSUPPORTED... } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131393&r1=131392&r2=131393&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Sun May 15 18:46:54 2011 @@ -810,11 +810,7 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse ("qHostInfo", response, false)) { - if (response.IsUnsupportedResponse()) - { - return false; - } - else if (response.IsNormalResponse()) + if (response.IsNormalResponse()) { std::string name; std::string value; @@ -1031,11 +1027,13 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { - if (response.IsUnsupportedResponse()) - m_supports_alloc_dealloc_memory = eLazyBoolNo; - else if (!response.IsErrorResponse()) + if (!response.IsErrorResponse()) return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS); } + else + { + m_supports_alloc_dealloc_memory = eLazyBoolNo; + } } return LLDB_INVALID_ADDRESS; } @@ -1054,8 +1052,10 @@ { if (response.IsOKResponse()) return true; - else if (response.IsUnsupportedResponse()) - m_supports_alloc_dealloc_memory = eLazyBoolNo; + } + else + { + m_supports_alloc_dealloc_memory = eLazyBoolNo; } } return false; @@ -1241,14 +1241,13 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { - if (response.IsUnsupportedResponse()) - { - m_supports_qProcessInfoPID = false; - return false; - } - return DecodeProcessInfoResponse (response, process_info); } + else + { + m_supports_qProcessInfoPID = false; + return false; + } } return false; } @@ -1332,12 +1331,6 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) { - if (response.IsUnsupportedResponse()) - { - m_supports_qfProcessInfo = false; - return 0; - } - do { ProcessInstanceInfo process_info; @@ -1348,6 +1341,11 @@ response.SetFilePos(0); } while (SendPacketAndWaitForResponse ("qsProcessInfo", strlen ("qsProcessInfo"), response, false)); } + else + { + m_supports_qfProcessInfo = false; + return 0; + } } return process_infos.GetSize(); @@ -1364,12 +1362,6 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { - if (response.IsUnsupportedResponse()) - { - m_supports_qUserName = false; - return false; - } - if (response.IsNormalResponse()) { // Make sure we parsed the right number of characters. The response is @@ -1379,6 +1371,11 @@ return true; } } + else + { + m_supports_qUserName = false; + return false; + } } return false; @@ -1395,12 +1392,6 @@ StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { - if (response.IsUnsupportedResponse()) - { - m_supports_qGroupName = false; - return false; - } - if (response.IsNormalResponse()) { // Make sure we parsed the right number of characters. The response is @@ -1410,6 +1401,11 @@ return true; } } + else + { + m_supports_qGroupName = false; + return false; + } } return false; } @@ -1488,12 +1484,7 @@ } StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false)) - { - if (response.IsUnsupportedResponse()) - return false; - return true; - } + return SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false) > 0; return false; } @@ -1588,13 +1579,15 @@ assert (packet_len < sizeof(packet)); if (SendPacketAndWaitForResponse(packet, packet_len, response, false)) { - if (response.IsUnsupportedResponse()) - m_supports_qThreadStopInfo = false; - else if (response.IsNormalResponse()) + if (response.IsNormalResponse()) return true; else return false; } + else + { + m_supports_qThreadStopInfo = false; + } } if (SetCurrentThread (tid)) return GetStopReply (response); @@ -1630,20 +1623,21 @@ { if (response.IsOKResponse()) return 0; - if (response.IsUnsupportedResponse()) - { - switch (type) - { - case eBreakpointSoftware: m_supports_z0 = false; break; - case eBreakpointHardware: m_supports_z1 = false; break; - case eWatchpointWrite: m_supports_z2 = false; break; - case eWatchpointRead: m_supports_z3 = false; break; - case eWatchpointReadWrite: m_supports_z4 = false; break; - default: break; - } - } else if (response.IsErrorResponse()) return response.GetError(); } + else + { + switch (type) + { + case eBreakpointSoftware: m_supports_z0 = false; break; + case eBreakpointHardware: m_supports_z1 = false; break; + case eWatchpointWrite: m_supports_z2 = false; break; + case eWatchpointRead: m_supports_z3 = false; break; + case eWatchpointReadWrite: m_supports_z4 = false; break; + default: break; + } + } + return UINT8_MAX; } From gclayton at apple.com Sun May 15 18:56:53 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 15 May 2011 23:56:53 -0000 Subject: [Lldb-commits] [lldb] r131394 - in /lldb/trunk/source: Expression/ClangExpressionParser.cpp Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110515235653.0E42E2A6C12C@llvm.org> Author: gclayton Date: Sun May 15 18:56:52 2011 New Revision: 131394 URL: http://llvm.org/viewvc/llvm-project?rev=131394&view=rev Log: Dump JIT memory requirements when "log enable lldb expr" logging is enabled. Correctly handle invalid 32-bit mmap fail return value in ProcessGDBRemote. Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=131394&r1=131393&r2=131394&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Sun May 15 18:56:52 2011 @@ -620,9 +620,14 @@ std::map::iterator fun_pos = jit_memory_manager->m_functions.begin(); std::map::iterator fun_end = jit_memory_manager->m_functions.end(); - + for (; fun_pos != fun_end; ++fun_pos) - alloc_size += (*fun_pos).second - (*fun_pos).first; + { + size_t mem_size = fun_pos->second - fun_pos->first; + if (log) + log->Printf ("JIT memory: [%p - %p) size = %zu", fun_pos->first, fun_pos->second, mem_size); + alloc_size += mem_size; + } Error alloc_error; func_allocation_addr = exc_context.process->AllocateMemory (alloc_size, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=131394&r1=131393&r2=131394&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun May 15 18:56:52 2011 @@ -1637,7 +1637,13 @@ if (result == eExecutionCompleted) { allocated_addr = return_value_sp->GetScalar().ULongLong(); - m_addr_to_mmap_size[allocated_addr] = size; + if (GetAddressByteSize() == 4) + { + if (allocated_addr == UINT32_MAX) + allocated_addr = LLDB_INVALID_ADDRESS; + } + if (allocated_addr != LLDB_INVALID_ADDRESS) + m_addr_to_mmap_size[allocated_addr] = size; } } } From gclayton at apple.com Sun May 15 21:35:02 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 16 May 2011 02:35:02 -0000 Subject: [Lldb-commits] [lldb] r131397 - in /lldb/trunk/source: Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Symbol/ClangASTType.cpp Target/Process.cpp Message-ID: <20110516023502.C6F8B2A6C12C@llvm.org> Author: gclayton Date: Sun May 15 21:35:02 2011 New Revision: 131397 URL: http://llvm.org/viewvc/llvm-project?rev=131397&view=rev Log: Fixed an issue where large memory writes might not get chunked up into smaller packets in GDB remote. Also fixed a compiler warning for an unhandled case for a switch. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=131397&r1=131396&r2=131397&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun May 15 21:35:02 2011 @@ -1520,6 +1520,14 @@ size_t ProcessGDBRemote::DoWriteMemory (addr_t addr, const void *buf, size_t size, Error &error) { + if (size > m_max_memory_size) + { + // Keep memory read sizes down to a sane limit. This function will be + // called multiple times in order to complete the task by + // lldb_private::Process so it is ok to do this. + size = m_max_memory_size; + } + StreamString packet; packet.Printf("M%llx,%zx:", addr, size); packet.PutBytesAsRawHex8(buf, size, lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder()); Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=131397&r1=131396&r2=131397&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Sun May 15 21:35:02 2011 @@ -262,6 +262,7 @@ //default: assert(0 && "Unknown builtin type!"); case clang::BuiltinType::UnknownAny: case clang::BuiltinType::Void: + case clang::BuiltinType::BoundMember: break; case clang::BuiltinType::Bool: return lldb::eFormatBoolean; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131397&r1=131396&r2=131397&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun May 15 21:35:02 2011 @@ -1913,7 +1913,7 @@ BreakpointSiteList::collection::const_iterator end = m_breakpoint_site_list.GetMap()->end(); if (iter == end || iter->second->GetLoadAddress() > addr + size) - return DoWriteMemory(addr, buf, size, error); + return WriteMemoryPrivate (addr, buf, size, error); BreakpointSiteList::collection::const_iterator pos; size_t bytes_written = 0; From gclayton at apple.com Sun May 15 22:02:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 16 May 2011 03:02:32 -0000 Subject: [Lldb-commits] [lldb] r131398 - in /lldb/trunk/source/Plugins/Process/gdb-remote: GDBRemoteRegisterContext.cpp GDBRemoteRegisterContext.h Message-ID: <20110516030232.A840C2A6C12C@llvm.org> Author: gclayton Date: Sun May 15 22:02:32 2011 New Revision: 131398 URL: http://llvm.org/viewvc/llvm-project?rev=131398&view=rev Log: Add support for the 'G' packet not being implemented or returning an error. If we are asked to restore all register values, we need to fall back to restoring each register one by one. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131398&r1=131397&r2=131398&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Sun May 15 22:02:32 2011 @@ -230,13 +230,13 @@ { DataExtractor data; if (value.GetData (data)) - return WriteRegisterBytes (reg_info, value, data, 0); + return WriteRegisterBytes (reg_info, data, 0); return false; } bool -GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, const RegisterValue &value, DataExtractor &data, uint32_t data_offset) +GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset) { GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote()); // FIXME: This check isn't right because IsRunning checks the Public state, but this @@ -386,13 +386,51 @@ const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID())) { - if (gdb_comm.SendPacketAndWaitForResponse((const char *)data_sp->GetBytes(), - data_sp->GetByteSize(), - response, - false)) + // The data_sp contains the entire G response packet including the + // G, and if the thread suffix is supported, it has the thread suffix + // as well. + const char *G_packet = (const char *)data_sp->GetBytes(); + size_t G_packet_len = data_sp->GetByteSize(); + if (gdb_comm.SendPacketAndWaitForResponse (G_packet, + G_packet_len, + response, + false)) { if (response.IsOKResponse()) return true; + else if (response.IsErrorResponse()) + { + uint32_t num_restored = 0; + // We need to manually go through all of the registers and + // restore them manually + DataExtractor data (G_packet + 1, // Skip the leading 'G' + G_packet_len - 1, + m_reg_data.GetByteOrder(), + m_reg_data.GetAddressByteSize()); + + //ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data) + const RegisterInfo *reg_info; + for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx) + { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + + // Only write down the registers that need to be written + // if we are going to be doing registers individually. + bool write_reg = true; + const uint32_t reg_byte_offset = reg_info->byte_offset; + const uint32_t reg_byte_size = reg_info->byte_size; + if (m_reg_valid[reg]) + { + const uint8_t *current_src = m_reg_data.PeekData(reg_byte_offset, reg_byte_size); + const uint8_t *restore_src = data.PeekData(reg_byte_offset, reg_byte_size); + if (current_src && restore_src) + write_reg = memcmp (current_src, restore_src, reg_byte_size) != 0; + } + if (WriteRegisterBytes(reg_info, data, reg_byte_offset)) + ++num_restored; + } + return num_restored > 0; + } } } } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=131398&r1=131397&r2=131398&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Sun May 15 22:02:32 2011 @@ -232,7 +232,6 @@ bool WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, - const lldb_private::RegisterValue &value, lldb_private::DataExtractor &data, uint32_t data_offset);