From ctice at apple.com Mon Sep 20 00:20:03 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Sep 2010 05:20:03 -0000 Subject: [Lldb-commits] [lldb] r114321 - in /lldb/trunk: include/lldb/API/ include/lldb/Symbol/ lldb.xcodeproj/ scripts/ source/API/ source/Symbol/ Message-ID: <20100920052003.858762A6C12C@llvm.org> Author: ctice Date: Mon Sep 20 00:20:02 2010 New Revision: 114321 URL: http://llvm.org/viewvc/llvm-project?rev=114321&view=rev Log: Add GetDescription() and __repr__ () methods to most API classes, to allow "print" from inside Python to print out the objects in a more useful manner. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBEvent.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/API/SBLineEntry.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/API/SBType.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/API/SBCommandReturnObject.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBError.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBLineEntry.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBSymbol.cpp lldb/trunk/source/API/SBSymbolContext.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBType.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Symbol/Block.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Mon Sep 20 00:20:02 2010 @@ -44,6 +44,16 @@ bool OffsetAddress (addr_t offset); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBFrame; Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Mon Sep 20 00:20:02 2010 @@ -49,6 +49,16 @@ lldb::SBBlock GetFirstChild (); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject *, which contains a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Mon Sep 20 00:20:02 2010 @@ -104,8 +104,8 @@ size_t GetNumLocations() const; - void - GetDescription (FILE *, const char *description_level); + bool + GetDescription (const char *description_level, lldb::SBStream &description); static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); @@ -116,6 +116,13 @@ static lldb::SBBreakpointLocation GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBBreakpointLocation; friend class SBTarget; Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Sep 20 00:20:02 2010 @@ -68,12 +68,19 @@ bool IsResolved (); - void - GetDescription (FILE *f, const char *description_level); + bool + GetDescription (const char *description_level, lldb::SBStream &description); SBBreakpoint GetBreakpoint (); + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBBreakpoint; Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Mon Sep 20 00:20:02 2010 @@ -58,6 +58,16 @@ void AppendMessage (const char *message); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBCommandInterpreter; friend class SBOptions; Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Mon Sep 20 00:20:02 2010 @@ -50,6 +50,16 @@ #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Sep 20 00:20:02 2010 @@ -154,6 +154,16 @@ static lldb::SBStringList GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + uint32_t GetTerminalWidth () const; Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Mon Sep 20 00:20:02 2010 @@ -10,6 +10,11 @@ #ifndef LLDB_SBDefines_h_ #define LLDB_SBDefines_h_ +// In order to guarantee correct working with Python, Python.h *MUST* be +// the *FIRST* header file included: + +#include + // C Includes // C++ Includes // Other libraries and framework includes @@ -49,6 +54,7 @@ class SBModule; class SBProcess; class SBSourceManager; +class SBStream; class SBStringList; class SBSymbol; class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Mon Sep 20 00:20:02 2010 @@ -65,6 +65,16 @@ bool IsValid () const; + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBArguments; friend class SBDebugger; Modified: lldb/trunk/include/lldb/API/SBEvent.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBEvent.h (original) +++ lldb/trunk/include/lldb/API/SBEvent.h Mon Sep 20 00:20:02 2010 @@ -10,10 +10,11 @@ #ifndef LLDB_SBEvent_h_ #define LLDB_SBEvent_h_ +#include "lldb/API/SBDefines.h" + #include #include -#include "lldb/API/SBDefines.h" namespace lldb { @@ -53,6 +54,16 @@ static const char * GetCStringFromEvent (const lldb::SBEvent &event); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBListener; friend class SBBroadcaster; Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Mon Sep 20 00:20:02 2010 @@ -51,6 +51,16 @@ static int ResolvePath (const char *src_path, char *dst_path, size_t dst_len); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBBlock; friend class SBCompileUnit; Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 20 00:20:02 2010 @@ -112,6 +112,16 @@ lldb::SBValue LookupVarInScope (const char *var_name, const char *scope); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBValue; Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Mon Sep 20 00:20:02 2010 @@ -39,6 +39,16 @@ operator != (const lldb::SBFunction &rhs) const; #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Mon Sep 20 00:20:02 2010 @@ -46,6 +46,16 @@ void Print (FILE *out); + //bool + //GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + //PyObject * + //__repr__ (); + private: //lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp; Modified: lldb/trunk/include/lldb/API/SBLineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBLineEntry.h (original) +++ lldb/trunk/include/lldb/API/SBLineEntry.h Mon Sep 20 00:20:02 2010 @@ -58,6 +58,16 @@ #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBCompileUnit; friend class SBFrame; Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Mon Sep 20 00:20:02 2010 @@ -49,6 +49,16 @@ ResolveSymbolContextForAddress (const lldb::SBAddress& addr, uint32_t resolve_scope); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: friend class SBSymbolContext; friend class SBTarget; Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Mon Sep 20 00:20:02 2010 @@ -152,6 +152,16 @@ lldb::SBBroadcaster GetBroadcaster () const; + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It take no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBAddress; friend class SBBreakpoint; Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Mon Sep 20 00:20:02 2010 @@ -55,6 +55,19 @@ Clear (); protected: + friend class SBAddress; + friend class SBBlock; + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBCompileUnit; + friend class SBEvent; + friend class SBFrame; + friend class SBFunction; + friend class SBModule; + friend class SBSymbol; + friend class SBSymbolContext; + friend class SBTarget; + friend class SBThread; #ifndef SWIG Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Mon Sep 20 00:20:02 2010 @@ -40,6 +40,15 @@ operator != (const lldb::SBSymbol &rhs) const; #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); private: friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Mon Sep 20 00:20:02 2010 @@ -71,6 +71,16 @@ void SetSymbolContext (const lldb_private::SymbolContext *sc_ptr); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + private: std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Mon Sep 20 00:20:02 2010 @@ -142,6 +142,16 @@ #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: friend class SBAddress; friend class SBDebugger; Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Mon Sep 20 00:20:02 2010 @@ -88,6 +88,15 @@ #endif + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); protected: friend class SBBreakpoint; Modified: lldb/trunk/include/lldb/API/SBType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBType.h (original) +++ lldb/trunk/include/lldb/API/SBType.h Mon Sep 20 00:20:02 2010 @@ -54,6 +54,16 @@ static bool IsPointerType (void *opaque_type); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It takes no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); + protected: void *m_ast; void *m_type; Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Mon Sep 20 00:20:02 2010 @@ -85,6 +85,15 @@ bool TypeIsPtrType (); + bool + GetDescription (lldb::SBStream &description); + + // The following function gets called by Python when a user tries to print + // an object of this class. It take no arguments and returns a + // PyObject * representing a char * (and it must be named "__repr__"); + + PyObject * + __repr__ (); protected: friend class SBValueList; Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 20 00:20:02 2010 @@ -185,6 +185,10 @@ DumpSymbolContext(Stream *s); void + DumpAddressRanges (Stream *s, + lldb::addr_t base_addr); + + void GetDescription (Stream *s, Function *function, lldb::DescriptionLevel level, Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 20 00:20:02 2010 @@ -2974,6 +2974,7 @@ GCC_MODEL_TUNING = G5; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = 4.2; + HEADER_SEARCH_PATHS = /usr/include/python2.6; INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -3063,6 +3064,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = 4.2; + HEADER_SEARCH_PATHS = /usr/include/python2.6; INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -3102,6 +3104,7 @@ GCC_MODEL_TUNING = G5; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = 4.2; + HEADER_SEARCH_PATHS = /usr/include/python2.6; INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Mon Sep 20 00:20:02 2010 @@ -90,6 +90,7 @@ #include "lldb/API/SBModule.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" @@ -143,6 +144,7 @@ %include "lldb/API/SBModule.h" %include "lldb/API/SBProcess.h" %include "lldb/API/SBSourceManager.h" +%include "lldb/API/SBStream.h" %include "lldb/API/SBStringList.h" %include "lldb/API/SBSymbol.h" %include "lldb/API/SBSymbolContext.h" Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Mon Sep 20 00:20:02 2010 @@ -9,6 +9,7 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/Address.h" using namespace lldb; @@ -136,3 +137,24 @@ } +bool +SBAddress::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + m_opaque_ap->DumpDebug (description.get()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBAddress::__repr__ () +{ + SBStream description; + description.ref(); // Make sure it contains a valid StreamString. + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Mon Sep 20 00:20:02 2010 @@ -9,8 +9,10 @@ #include "lldb/API/SBBlock.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SymbolContext.h" using namespace lldb; using namespace lldb_private; @@ -132,4 +134,36 @@ } - +bool +SBBlock::GetDescription (SBStream &description) +{ + if (m_opaque_ptr) + { + lldb::user_id_t id = m_opaque_ptr->GetID(); + description.Printf ("Block: {id: %d} ", id); + if (IsInlined()) + { + description.Printf (" (inlined, '%s') ", GetInlinedName()); + } + lldb_private::SymbolContext sc; + m_opaque_ptr->CalculateSymbolContext (&sc); + if (sc.function) + { + m_opaque_ptr->DumpAddressRanges (description.get(), + sc.function->GetAddressRange().GetBaseAddress().GetFileAddress()); + } + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBBlock::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Mon Sep 20 00:20:02 2010 @@ -12,6 +12,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBThread.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -321,12 +322,9 @@ return 0; } -void -SBBreakpoint::GetDescription (FILE *f, const char *description_level) +bool +SBBreakpoint::GetDescription (const char *description_level, SBStream &description) { - if (f == NULL) - return; - if (m_opaque_sp) { DescriptionLevel level; @@ -339,11 +337,23 @@ else level = eDescriptionLevelBrief; - StreamFile str (f); - m_opaque_sp->GetDescription (&str, level); - str.EOL(); + m_opaque_sp->GetDescription (description.get(), level); + description.get()->EOL(); } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBBreakpoint::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription ("full", description); + return PyString_FromString (description.GetData()); } bool Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Sep 20 00:20:02 2010 @@ -7,9 +7,15 @@ // //===----------------------------------------------------------------------===// +// In order to guarantee correct working with Python, Python.h *MUST* be +// the *FIRST* header file included: + +#include + #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBDebugger.h" +#include "lldb/API/SBStream.h" #include "lldb/lldb-types.h" #include "lldb/lldb-defines.h" @@ -191,12 +197,9 @@ m_opaque_sp = break_loc_sp; } -void -SBBreakpointLocation::GetDescription (FILE *f, const char *description_level) +bool +SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description) { - if (f == NULL) - return; - if (m_opaque_sp) { DescriptionLevel level; @@ -209,11 +212,22 @@ else level = eDescriptionLevelBrief; - StreamFile str (f); - - m_opaque_sp->GetDescription (&str, level); - str.EOL(); + m_opaque_sp->GetDescription (description.get(), level); + description.get()->EOL(); } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBBreakpointLocation::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription ("full", description); + return PyString_FromString (description.GetData()); } SBBreakpoint Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Mon Sep 20 00:20:02 2010 @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Interpreter/CommandReturnObject.h" - #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBStream.h" + +#include "lldb/Interpreter/CommandReturnObject.h" using namespace lldb; using namespace lldb_private; @@ -160,3 +161,38 @@ m_opaque_ap.reset (ptr); } +bool +SBCommandReturnObject::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + description.Printf ("Status: "); + lldb::ReturnStatus status = m_opaque_ap->GetStatus(); + if (status == lldb::eReturnStatusStarted) + description.Printf ("Started"); + else if (status == lldb::eReturnStatusInvalid) + description.Printf ("Invalid"); + else if (m_opaque_ap->Succeeded()) + description.Printf ("Success"); + else + description.Printf ("Fail"); + + if (GetOutputSize() > 0) + description.Printf ("\nOutput Message:\n%s", GetOutput()); + + if (GetErrorSize() > 0) + description.Printf ("\nError Message:\n%s", GetError()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBCommandReturnObject::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Mon Sep 20 00:20:02 2010 @@ -9,6 +9,7 @@ #include "lldb/API/SBCompileUnit.h" #include "lldb/API/SBLineEntry.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/LineTable.h" @@ -118,3 +119,25 @@ { return *m_opaque_ptr; } + +bool +SBCompileUnit::GetDescription (SBStream &description) +{ + if (m_opaque_ptr) + { + m_opaque_ptr->Dump (description.get(), false); + } + else + description.Printf ("No Value"); + + return true; +} + +PyObject * +SBCompileUnit::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Sep 20 00:20:02 2010 @@ -25,6 +25,7 @@ #include "lldb/API/SBInputReader.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" @@ -669,3 +670,26 @@ return false; } +bool +SBDebugger::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + const char *name = m_opaque_sp->GetInstanceName().AsCString(); + lldb::user_id_t id = m_opaque_sp->GetID(); + description.Printf ("Debugger (instance: '%s', id: %d)", name, id); + } + else + description.Printf ("No value"); + + return true; +} + + +PyObject * +SBDebugger::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBError.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBError.cpp (original) +++ lldb/trunk/source/API/SBError.cpp Mon Sep 20 00:20:02 2010 @@ -8,7 +8,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBError.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/Error.h" + #include using namespace lldb; @@ -178,3 +180,29 @@ return *m_opaque_ap; } +bool +SBError::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + if (Success()) + description.Printf ("Status: Success"); + else + { + const char * err_string = GetCString(); + description.Printf ("Status: Error: %s", (err_string != NULL ? err_string : "")); + } + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBError::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Mon Sep 20 00:20:02 2010 @@ -9,6 +9,7 @@ #include "lldb/API/SBEvent.h" #include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/Event.h" #include "lldb/Core/Stream.h" @@ -150,3 +151,24 @@ } +bool +SBEvent::GetDescription (SBStream &description) +{ + if (m_opaque) + { + m_opaque->Dump (description.get()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBEvent::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/FileSpec.h" using namespace lldb; @@ -138,3 +139,30 @@ m_opaque_ap.reset (new FileSpec (fs)); } +bool +SBFileSpec::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + const char *filename = GetFilename(); + const char *dir_name = GetDirectory(); + if (!filename && !dir_name) + description.Printf ("No value"); + else if (!dir_name) + description.Printf ("%s", filename); + else + description.Printf ("%s/%s", dir_name, filename); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBFileSpec::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Sep 20 00:20:02 2010 @@ -34,6 +34,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBThread.h" @@ -203,7 +204,13 @@ if (!found) var_sp.reset(); } - SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp))); + if (var_sp) + { + SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp))); + return sb_value; + } + + SBValue sb_value; return sb_value; } @@ -249,7 +256,14 @@ var_sp.reset(); } } - SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp))); + + if (var_sp) + { + SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp))); + return sb_value; + } + + SBValue sb_value; return sb_value; } @@ -375,3 +389,24 @@ return value_list; } +bool +SBFrame::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + m_opaque_sp->Dump (description.get(), true, false); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBFrame::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Mon Sep 20 00:20:02 2010 @@ -9,6 +9,7 @@ #include "lldb/API/SBFunction.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/Function.h" using namespace lldb; @@ -62,3 +63,25 @@ { return m_opaque_ptr != rhs.m_opaque_ptr; } + +bool +SBFunction::GetDescription (SBStream &description) +{ + if (m_opaque_ptr) + { + m_opaque_ptr->Dump (description.get(), false); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBFunction::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBLineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLineEntry.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBLineEntry.cpp (original) +++ lldb/trunk/source/API/SBLineEntry.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBLineEntry.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/LineEntry.h" using namespace lldb; @@ -152,7 +153,30 @@ return *m_opaque_ap; } +bool +SBLineEntry::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + // Line entry: File, line x {, column y}: Addresses: - + char file_path[PATH_MAX*2]; + m_opaque_ap->file.GetPath (file_path, sizeof (file_path)); + description.Printf ("Line entry: %s, line %d", file_path, GetLine()); + if (GetColumn() > 0) + description.Printf (", column %d", GetColumn()); + description.Printf (": Addresses: 0x%p - 0x%p", GetStartAddress().GetFileAddress() , + GetEndAddress().GetFileAddress()); + } + else + description.Printf ("No value"); + return true; +} - - +PyObject * +SBLineEntry::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Mon Sep 20 00:20:02 2010 @@ -11,6 +11,7 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" using namespace lldb; @@ -127,3 +128,24 @@ return sb_sc; } +bool +SBModule::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + m_opaque_sp->Dump (description.get()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBModule::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Mon Sep 20 00:20:02 2010 @@ -30,6 +30,7 @@ #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" using namespace lldb; @@ -466,3 +467,29 @@ return m_opaque_sp.get(); } +bool +SBProcess::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + char path[PATH_MAX]; + GetTarget().GetExecutable().GetPath (path, sizeof(path)); + description.Printf ("Process {pid: %d, executable %s\n", (int) GetProcessID(), path); + description.Printf (" instance name: %s, state: %s, thread cnt: %d}", + m_opaque_sp->GetInstanceName().AsCString(), + SBDebugger::StateAsCString (GetState()), + GetNumThreads()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBProcess::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbol.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/Symbol.h" using namespace lldb; @@ -62,3 +63,25 @@ { return m_opaque_ptr != rhs.m_opaque_ptr; } + +bool +SBSymbol::GetDescription (SBStream &description) +{ + if (m_opaque_ptr) + { + m_opaque_ptr->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBSymbol::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBStream.h" #include "lldb/Symbol/SymbolContext.h" using namespace lldb; @@ -146,5 +147,24 @@ return m_opaque_ap.get(); } +bool +SBSymbolContext::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL); + } + else + description.Printf ("No value"); + return true; +} +PyObject * +SBSymbolContext::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Sep 20 00:20:02 2010 @@ -13,6 +13,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBModule.h" +#include "lldb/API/SBStream.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointList.h" @@ -500,3 +501,25 @@ out_stream); } } + +bool +SBTarget::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + m_opaque_sp->Dump (description.get()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBTarget::__repr__ () +{ + SBStream description; + description.ref(); + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Mon Sep 20 00:20:02 2010 @@ -11,6 +11,7 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" @@ -412,3 +413,26 @@ { return *m_opaque_sp; } + +bool +SBThread::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + m_opaque_sp->DumpInfo (description.ref(), true, true, true, LLDB_INVALID_INDEX32); + description.Printf (" %d frames, (instance name: %s)", GetNumFrames(), + m_opaque_sp->GetInstanceName().AsCString()); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBThread::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/API/SBType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBType.cpp (original) +++ lldb/trunk/source/API/SBType.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBType.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/ConstString.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTType.h" @@ -144,6 +145,53 @@ return SBType (pointee_type ? m_ast : NULL, pointee_type); } +bool +SBType::GetDescription (SBStream &description) +{ + const char *name = GetName(); + uint64_t byte_size = GetByteSize(); + uint64_t num_children = GetNumberChildren (true); + bool is_ptr = IsPointerType (); + + description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : ""), byte_size); + if (is_ptr) + { + SBType pointee_type = GetPointeeType(); + const char *pointee_name = pointee_type.GetName(); + description.Printf (", (* %s)", (pointee_name != NULL ? pointee_name : "")); + } + else if (num_children > 0) + { + description.Printf (", %d members:\n", num_children); + for (uint32_t i = 0; i < num_children; ++i) + { + SBTypeMember field; + GetChildAtIndex (true, i, field); + const char *field_name = field.GetName(); + SBType field_type = field.GetType(); + const char *field_type_name = field_type.GetName(); + + description.Printf (" %s (type: %s", (field_name != NULL ? field_name : ""), + (field_type_name != NULL ? field_type_name : "")); + + if (field.IsBitfield()) + { + size_t width = field.GetBitfieldWidth (); + description.Printf (" , %d bits", (int) width); + } + description.Printf (")\n"); + } + } + return true; +} + +PyObject * +SBType::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} SBTypeMember::SBTypeMember () : m_ast (NULL), Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Mon Sep 20 00:20:02 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBValue.h" +#include "lldb/API/SBStream.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Module.h" @@ -268,3 +269,35 @@ { return m_opaque_sp; } + +bool +SBValue::GetDescription (SBStream &description) +{ + if (m_opaque_sp) + { + const char *name = GetName(); + const char *type_name = GetTypeName (); + size_t byte_size = GetByteSize (); + uint32_t num_children = GetNumChildren (); + bool is_stale = ValueIsStale (); + description.Printf ("name: '%s', type: %s, size: %d", (name != NULL ? name : ""), + (type_name != NULL ? type_name : ""), (int) byte_size); + if (num_children > 0) + description.Printf (", num_children: %d", num_children); + + if (is_stale) + description.Printf (" [value is stale]"); + } + else + description.Printf ("No value"); + + return true; +} + +PyObject * +SBValue::__repr__ () +{ + SBStream description; + GetDescription (description); + return PyString_FromString (description.GetData()); +} Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=114321&r1=114320&r2=114321&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 20 00:20:02 2010 @@ -236,6 +236,17 @@ s->Printf(", Block{0x%8.8x}", GetID()); } +void +Block::DumpAddressRanges (Stream *s, lldb::addr_t base_addr) +{ + if (!m_ranges.empty()) + { + std::vector::const_iterator pos, end = m_ranges.end(); + for (pos = m_ranges.begin(); pos != end; ++pos) + pos->Dump (s, base_addr); + } +} + bool Block::Contains (addr_t range_offset) const { From bugzilla-daemon at llvm.org Mon Sep 20 05:43:24 2010 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Mon, 20 Sep 2010 05:43:24 -0500 (CDT) Subject: [Lldb-commits] [Bug 8188] New: DW_CFA_same_value unsupported Message-ID: http://llvm.org/bugs/show_bug.cgi?id=8188 Summary: DW_CFA_same_value unsupported Product: lldb Version: unspecified Platform: PC OS/Version: MacOS X Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: vyacheslav.p.zakharin at intel.com Hello, There is a bug in the way you handle DW_CFA_same_value in lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp. A compiler may save a non-volatile register into memory and then restore it from there. In this case there will be two DWARF directives: DW_CFA_expression DW_CFA_same_value Now assume that the code was rearranged in the following way: if () goto call_throw; call_throw: Consider the case where is true, so we jump to the throw point right after CFA allocation. According to the unwinding procedure we have to read all DWARF directives up to the point where an exception occurs. When we come to the throw point during the unwinding procedure we think that the register is located in memory (since DW_CFA_same_value is ignored) and try to restore it from where. The result is a bunch of junk in the register. There used to be the same bug in GCC, but it has been fixed since 4.0.0. Please consider fixing it in your product. Thank you, Slava -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From ctice at apple.com Mon Sep 20 11:21:42 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Sep 2010 16:21:42 -0000 Subject: [Lldb-commits] [lldb] r114326 - in /lldb/trunk/source/API: SBAddress.cpp SBBlock.cpp SBCompileUnit.cpp SBEvent.cpp SBFunction.cpp SBTarget.cpp Message-ID: <20100920162142.231232A6C12C@llvm.org> Author: ctice Date: Mon Sep 20 11:21:41 2010 New Revision: 114326 URL: http://llvm.org/viewvc/llvm-project?rev=114326&view=rev Log: Fix indentations. Modified: lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Mon Sep 20 11:21:41 2010 @@ -141,9 +141,9 @@ SBAddress::GetDescription (SBStream &description) { if (m_opaque_ap.get()) - { + { m_opaque_ap->DumpDebug (description.get()); - } + } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Mon Sep 20 11:21:41 2010 @@ -138,21 +138,21 @@ SBBlock::GetDescription (SBStream &description) { if (m_opaque_ptr) - { + { lldb::user_id_t id = m_opaque_ptr->GetID(); description.Printf ("Block: {id: %d} ", id); if (IsInlined()) - { + { description.Printf (" (inlined, '%s') ", GetInlinedName()); - } + } lldb_private::SymbolContext sc; m_opaque_ptr->CalculateSymbolContext (&sc); if (sc.function) - { + { m_opaque_ptr->DumpAddressRanges (description.get(), sc.function->GetAddressRange().GetBaseAddress().GetFileAddress()); - } - } + } + } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Mon Sep 20 11:21:41 2010 @@ -124,11 +124,11 @@ SBCompileUnit::GetDescription (SBStream &description) { if (m_opaque_ptr) - { + { m_opaque_ptr->Dump (description.get(), false); - } + } else - description.Printf ("No Value"); + description.Printf ("No Value"); return true; } Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Mon Sep 20 11:21:41 2010 @@ -155,11 +155,11 @@ SBEvent::GetDescription (SBStream &description) { if (m_opaque) - { + { m_opaque->Dump (description.get()); - } + } else - description.Printf ("No value"); + description.Printf ("No value"); return true; } Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Mon Sep 20 11:21:41 2010 @@ -72,7 +72,7 @@ m_opaque_ptr->Dump (description.get(), false); } else - description.Printf ("No value"); + description.Printf ("No value"); return true; } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=114326&r1=114325&r2=114326&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Sep 20 11:21:41 2010 @@ -506,9 +506,9 @@ SBTarget::GetDescription (SBStream &description) { if (m_opaque_sp) - { + { m_opaque_sp->Dump (description.get()); - } + } else description.Printf ("No value"); From johnny.chen at apple.com Mon Sep 20 11:36:43 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Sep 2010 16:36:43 -0000 Subject: [Lldb-commits] [lldb] r114328 - in /lldb/trunk: source/Core/Debugger.cpp test/settings/TestSettings.py Message-ID: <20100920163643.E2F152A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 11:36:43 2010 New Revision: 114328 URL: http://llvm.org/viewvc/llvm-project?rev=114328&view=rev Log: Fixed lldb 'settings set term-widt 70' command not working. rdar://problem/8449849 Modified: lldb/trunk/source/Core/Debugger.cpp lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114328&r1=114327&r2=114328&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Sep 20 11:36:43 2010 @@ -1311,7 +1311,7 @@ char *end = NULL; const uint32_t width = ::strtoul (value, &end, 0); - if (end && end == '\0') + if (end && end[0] == '\0') { if (width >= 10 || width <= 1024) valid = true; Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114328&r1=114327&r2=114328&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Sep 20 11:36:43 2010 @@ -30,9 +30,6 @@ self.expect("settings show", substrs = ["prompt (string) = 'lldb2'"]) - @unittest2.expectedFailure - # rdar://problem/8449849 - # settings test case failure (probably after r114252) def test_set_term_width(self): """Test that 'set term-width' actually changes the term-width.""" From johnny.chen at apple.com Mon Sep 20 12:04:41 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Sep 2010 17:04:41 -0000 Subject: [Lldb-commits] [lldb] r114330 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20100920170441.C05822A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 12:04:41 2010 New Revision: 114330 URL: http://llvm.org/viewvc/llvm-project?rev=114330&view=rev Log: Fixed wrong logic in validating term-width value; should be && instead of ||. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114330&r1=114329&r2=114330&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Sep 20 12:04:41 2010 @@ -1313,7 +1313,7 @@ if (end && end[0] == '\0') { - if (width >= 10 || width <= 1024) + if (width >= 10 && width <= 1024) valid = true; else err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n"); From johnny.chen at apple.com Mon Sep 20 12:25:45 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Sep 2010 17:25:45 -0000 Subject: [Lldb-commits] [lldb] r114332 - /lldb/trunk/test/dotest.py Message-ID: <20100920172545.398A92A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 12:25:45 2010 New Revision: 114332 URL: http://llvm.org/viewvc/llvm-project?rev=114332&view=rev Log: Added comments. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114332&r1=114331&r2=114332&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Sep 20 12:25:45 2010 @@ -247,6 +247,9 @@ sys.stdout.write("proceeding...\n") pass +# +# Walk through the testdirs while collecting test cases. +# for testdir in testdirs: os.path.walk(testdir, visit, 'Test') From johnny.chen at apple.com Mon Sep 20 13:07:51 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Sep 2010 18:07:51 -0000 Subject: [Lldb-commits] [lldb] r114333 - /lldb/trunk/test/dotest.py Message-ID: <20100920180751.28CBC2A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 13:07:50 2010 New Revision: 114333 URL: http://llvm.org/viewvc/llvm-project?rev=114333&view=rev Log: More modularizations. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114333&r1=114332&r2=114333&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Sep 20 13:07:50 2010 @@ -202,6 +202,26 @@ sys.path[1:1] = [lldbPath] +def doDelay(delta): + """Delaying startup for delta-seconds to facilitate debugger attachment.""" + def alarm_handler(*args): + raise Exception("timeout") + + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(delta) + sys.stdout.write("pid=%d\n" % os.getpid()) + sys.stdout.write("Enter RET to proceed (or timeout after %d seconds):" % + delta) + sys.stdout.flush() + try: + text = sys.stdin.readline() + except: + text = "" + signal.alarm(0) + sys.stdout.write("proceeding...\n") + pass + + def visit(prefix, dir, names): """Visitor function for os.path.walk(path, visit, arg).""" @@ -219,6 +239,44 @@ suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base)) +def lldbLoggings(): + """Check and do lldb loggings if necessary.""" + + # Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is + # defined. Use ${LLDB_LOG} to specify the log file. + ci = lldb.DBG.GetCommandInterpreter() + res = lldb.SBCommandReturnObject() + if ("LLDB_LOG" in os.environ): + if ("LLDB_LOG_OPTION" in os.environ): + lldb_log_option = os.environ["LLDB_LOG_OPTION"] + else: + lldb_log_option = "event process" + ci.HandleCommand( + "log enable -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, + res) + if not res.Succeeded(): + raise Exception('log enable failed (check LLDB_LOG env variable.') + # Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined. + # Use ${GDB_REMOTE_LOG} to specify the log file. + if ("GDB_REMOTE_LOG" in os.environ): + if ("GDB_REMOTE_LOG_OPTION" in os.environ): + gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"] + else: + gdb_remote_log_option = "packets" + ci.HandleCommand( + "log enable -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + + gdb_remote_log_option, + res) + if not res.Succeeded(): + raise Exception('log enable failed (check GDB_REMOTE_LOG env variable.') + + +############################################ +# # +# Execution of the test driver starts here # +# # +############################################ + # # Start the actions by first parsing the options while setting up the test # directories, followed by setting up the search paths for lldb utilities; @@ -231,21 +289,7 @@ # If '-d' is specified, do a delay of 10 seconds for the debugger to attach. # if delay: - def alarm_handler(*args): - raise Exception("timeout") - - signal.signal(signal.SIGALRM, alarm_handler) - signal.alarm(10) - sys.stdout.write("pid=" + str(os.getpid()) + '\n') - sys.stdout.write("Enter RET to proceed (or timeout after 10 seconds):") - sys.stdout.flush() - try: - text = sys.stdin.readline() - except: - text = "" - signal.alarm(0) - sys.stdout.write("proceeding...\n") - pass + doDelay(10) # # Walk through the testdirs while collecting test cases. @@ -254,6 +298,8 @@ os.path.walk(testdir, visit, 'Test') # Now that we have loaded all the test cases, run the whole test suite. + +# First, write out the number of collected test cases. err.writeln(separator) err.writeln("Collected %d test%s" % (suite.countTestCases(), suite.countTestCases() != 1 and "s" or "")) @@ -268,33 +314,8 @@ # Create a singleton SBDebugger in the lldb namespace. lldb.DBG = lldb.SBDebugger.Create() -# Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is -# defined. Use ${LLDB_LOG} to specify the log file. -ci = lldb.DBG.GetCommandInterpreter() -res = lldb.SBCommandReturnObject() -if ("LLDB_LOG" in os.environ): - if ("LLDB_LOG_OPTION" in os.environ): - lldb_log_option = os.environ["LLDB_LOG_OPTION"] - else: - lldb_log_option = "event process" - ci.HandleCommand( - "log enable -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, - res) - if not res.Succeeded(): - raise Exception('log enable failed (check LLDB_LOG env variable.') -# Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined. -# Use ${GDB_REMOTE_LOG} to specify the log file. -if ("GDB_REMOTE_LOG" in os.environ): - if ("GDB_REMOTE_LOG_OPTION" in os.environ): - gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"] - else: - gdb_remote_log_option = "packets" - ci.HandleCommand( - "log enable -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " - + gdb_remote_log_option, - res) - if not res.Succeeded(): - raise Exception('log enable failed (check GDB_REMOTE_LOG env variable.') +# Turn on lldb loggings if necessary. +lldbLoggings() # Install the control-c handler. unittest2.signals.installHandler() @@ -302,6 +323,8 @@ # Invoke the default TextTestRunner to run the test suite. result = unittest2.TextTestRunner(verbosity=verbose).run(suite) +# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined. +# This should not be necessary now. if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ): import subprocess print "Terminating Test suite..." From ctice at apple.com Mon Sep 20 15:44:43 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Sep 2010 20:44:43 -0000 Subject: [Lldb-commits] [lldb] r114352 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Target/ source/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/ObjectContainer/Universal-Mach-O/ source/Target/ test/settings/ Message-ID: <20100920204443.92AA22A6C12C@llvm.org> Author: ctice Date: Mon Sep 20 15:44:43 2010 New Revision: 114352 URL: http://llvm.org/viewvc/llvm-project?rev=114352&view=rev Log: Add UserSettings to Target class, making Target settings the parent of Process settings; add 'default-arch' as a class-wide setting for Target. Replace lldb::GetDefaultArchitecture with Target::GetDefaultArchitecture & Target::SetDefaultArchitecture. Add 'use-external-editor' as user setting to Debugger class & update code appropriately. Add Error parameter to methods that get user settings, for easier reporting of bad requests. Fix various other minor related bugs. Fix test cases to work with new changes. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/lldb-private.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/lldb.cpp lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Sep 20 15:44:43 2010 @@ -113,7 +113,7 @@ SetUseExternalEditor (bool input); bool - UseExternalEditor (); + GetUseExternalEditor (); bool GetDefaultArchitecture (char *arch_name, size_t arch_name_len); Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon Sep 20 15:44:43 2010 @@ -63,7 +63,8 @@ void GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value); + StringList &value, + Error &err); uint32_t GetTerminalWidth () const @@ -90,6 +91,7 @@ m_prompt.assign (p); else m_prompt.assign ("(lldb) "); + BroadcastPromptChange (m_instance_name, m_prompt.c_str()); } lldb::ScriptLanguage @@ -104,6 +106,20 @@ m_script_lang = script_lang; } + bool + GetUseExternalEditor () const + { + return m_use_external_editor; + } + + bool + SetUseExternalEditor (bool use_external_editor_p) + { + bool old_value = m_use_external_editor; + m_use_external_editor = use_external_editor_p; + return old_value; + } + protected: void @@ -128,11 +144,15 @@ static const ConstString & TermWidthVarName (); + static const ConstString & + UseExternalEditorVarName (); + private: uint32_t m_term_width; std::string m_prompt; lldb::ScriptLanguage m_script_lang; + bool m_use_external_editor; }; @@ -275,20 +295,6 @@ static lldb::DebuggerSP FindDebuggerWithID (lldb::user_id_t id); - bool - SetUseExternalEditor (bool value) - { - bool old_value = m_use_external_editor; - m_use_external_editor = value; - return old_value; - } - - bool - UseExternalEditor () - { - return m_use_external_editor; - } - static lldb::DebuggerSP FindDebuggerWithInstanceName (const ConstString &instance_name); Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Mon Sep 20 15:44:43 2010 @@ -74,13 +74,15 @@ virtual bool GetGlobalVariable (const ConstString &var_name, - StringList &value); + StringList &value, + Error &err); // End of pure virtual functions. StringList GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type, - const char *debugger_instance_name); + const char *debugger_instance_name, + Error &err); Error SetVariable (const char *full_dot_name, @@ -371,7 +373,8 @@ virtual void GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value) = 0; + StringList &value, + Error &err) = 0; virtual void CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Sep 20 15:44:43 2010 @@ -72,7 +72,8 @@ void GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value); + StringList &value, + Error &err); const Args & Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Mon Sep 20 15:44:43 2010 @@ -21,6 +21,7 @@ #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Event.h" #include "lldb/Core/ModuleList.h" +#include "lldb/Core/UserSettingsController.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContextScope.h" @@ -31,13 +32,106 @@ namespace lldb_private { +class TargetInstanceSettings : public InstanceSettings +{ +public: + + TargetInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); + + TargetInstanceSettings (const TargetInstanceSettings &rhs); + + virtual + ~TargetInstanceSettings (); + + TargetInstanceSettings& + operator= (const TargetInstanceSettings &rhs); + + void + UpdateInstanceSettingsVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const ConstString &instance_name, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error &err, + bool pending); + + void + GetInstanceSettingsValue (const SettingEntry &entry, + const ConstString &var_name, + StringList &value, + Error &err); + +protected: + + void + CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, + bool pending); + + const ConstString + CreateInstanceName (); + +private: + +}; + class Target : public Broadcaster, - public ExecutionContextScope + public ExecutionContextScope, + public TargetInstanceSettings { public: friend class TargetList; + class SettingsController : public UserSettingsController + { + public: + SettingsController (); + + virtual + ~SettingsController (); + + bool + SetGlobalVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + const lldb::VarSetOperationType op, + Error&err); + + bool + GetGlobalVariable (const ConstString &var_name, + StringList &value, + Error &err); + + static SettingEntry global_settings_table[]; + static SettingEntry instance_settings_table[]; + + protected: + + lldb::InstanceSettingsSP + CreateInstanceSettings (const char *instance_name); + + static const ConstString & + DefArchVarName (); + + private: + + // Class-wide settings. + ArchSpec m_default_architecture; + + DISALLOW_COPY_AND_ASSIGN (SettingsController); + }; + + static lldb::UserSettingsControllerSP + GetSettingsController (bool finish = false); + + static ArchSpec + GetDefaultArchitecture (); + + static void + SetDefaultArchitecture (ArchSpec new_arch); + //------------------------------------------------------------------ /// Broadcaster event bits definitions. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Mon Sep 20 15:44:43 2010 @@ -53,7 +53,8 @@ void GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value); + StringList &value, + Error &err); RegularExpression * GetSymbolsToAvoidRegexp() Modified: lldb/trunk/include/lldb/lldb-private.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private.h (original) +++ lldb/trunk/include/lldb/lldb-private.h Mon Sep 20 15:44:43 2010 @@ -67,11 +67,6 @@ const char * GetVoteAsCString (lldb::Vote vote); - -// The function below can be moved into lldb::Debugger when/if we get one -ArchSpec & -GetDefaultArchitecture (); - } // namespace lldb_private Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Sep 20 15:44:43 2010 @@ -303,7 +303,8 @@ { if (arch_name && arch_name_len) { - ArchSpec &default_arch = lldb_private::GetDefaultArchitecture (); + ArchSpec default_arch = lldb_private::Target::GetDefaultArchitecture (); + if (default_arch.IsValid()) { ::snprintf (arch_name, arch_name_len, "%s", default_arch.AsCString()); @@ -324,7 +325,7 @@ ArchSpec arch (arch_name); if (arch.IsValid()) { - lldb_private::GetDefaultArchitecture () = arch; + lldb_private::Target::SetDefaultArchitecture (arch); return true; } } @@ -388,7 +389,7 @@ if (m_opaque_sp) { FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); + ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); TargetSP target_sp; Error error; @@ -431,7 +432,7 @@ if (m_opaque_sp) { FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); + ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); TargetSP target_sp; Error error; @@ -593,12 +594,22 @@ { SBStringList ret_value; lldb::SettableVariableType var_type; + lldb_private:Error err; lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); - StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name); - for (unsigned i = 0; i != value.GetSize(); ++i) - ret_value.AppendString (value.GetStringAtIndex(i)); + StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name, err); + + if (err.Success()) + { + for (unsigned i = 0; i != value.GetSize(); ++i) + ret_value.AppendString (value.GetStringAtIndex(i)); + } + else + { + ret_value.AppendString (err.AsCString()); + } + return ret_value; } @@ -662,10 +673,10 @@ } bool -SBDebugger::UseExternalEditor () +SBDebugger::GetUseExternalEditor () { if (m_opaque_sp) - return m_opaque_sp->UseExternalEditor (); + return m_opaque_sp->GetUseExternalEditor (); else return false; } Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 20 15:44:43 2010 @@ -129,7 +129,7 @@ { bool already_shown = false; SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); - if (m_interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) + if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Mon Sep 20 15:44:43 2010 @@ -272,7 +272,7 @@ bool -CommandObjectSettingsShow::Execute ( Args& command, +CommandObjectSettingsShow::Execute (Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -285,13 +285,13 @@ // The user requested to see the value of a particular variable. lldb::SettableVariableType var_type; const char *variable_name = command.GetArgumentAtIndex (0); - StringList value = root_settings->GetVariable (variable_name, var_type, - m_interpreter.GetDebugger().GetInstanceName().AsCString()); + StringList value = root_settings->GetVariable (variable_name, var_type, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), + err); - if (value.GetSize() == 0) + if (err.Fail ()) { - result.AppendErrorWithFormat ("Unable to find variable named '%s'. " - "Try 'show' to see all variable values.\n", variable_name); + result.AppendError (err.AsCString()); result.SetStatus (eReturnStatusFailed); } @@ -304,8 +304,10 @@ tmp_str.Printf (" (%s)", UserSettingsController::GetTypeString (var_type)); type_name = (char *) tmp_str.GetData(); } - - if (value.GetSize() == 1) + + if (value.GetSize() == 0) + result.AppendMessageWithFormat ("%s%s = ''\n", variable_name, type_name); + else if (value.GetSize() == 1) result.AppendMessageWithFormat ("%s%s = '%s'\n", variable_name, type_name, value.GetStringAtIndex (0)); else { Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Sep 20 15:44:43 2010 @@ -63,7 +63,7 @@ bool already_shown = false; StackFrameSP frame_sp = thread->GetStackFrameAtIndex(0); SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); - if (interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) + if (interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); } Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Sep 20 15:44:43 2010 @@ -1248,7 +1248,8 @@ InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), m_term_width (80), m_prompt (), - m_script_lang () + m_script_lang (), + m_use_external_editor (false) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -1272,7 +1273,8 @@ DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) : InstanceSettings (*(Debugger::GetSettingsController().get()), CreateInstanceName ().AsCString()), m_prompt (rhs.m_prompt), - m_script_lang (rhs.m_script_lang) + m_script_lang (rhs.m_script_lang), + m_use_external_editor (rhs.m_use_external_editor) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings, false); @@ -1291,6 +1293,7 @@ m_term_width = rhs.m_term_width; m_prompt = rhs.m_prompt; m_script_lang = rhs.m_script_lang; + m_use_external_editor = rhs.m_use_external_editor; } return *this; @@ -1366,12 +1369,17 @@ m_term_width = ::strtoul (value, NULL, 0); } } + else if (var_name == UseExternalEditorVarName ()) + { + UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, err); + } } void DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value) + StringList &value, + Error &err) { if (var_name == PromptVarName()) { @@ -1388,6 +1396,15 @@ width_str.Printf ("%d", m_term_width); value.AppendString (width_str.GetData()); } + else if (var_name == UseExternalEditorVarName()) + { + if (m_use_external_editor) + value.AppendString ("true"); + else + value.AppendString ("false"); + } + else + err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); } void @@ -1414,7 +1431,9 @@ BroadcastPromptChange (new_name, m_prompt.c_str()); } + m_term_width = new_debugger_settings->m_term_width; m_script_lang = new_debugger_settings->m_script_lang; + m_use_external_editor = new_debugger_settings->m_use_external_editor; } @@ -1492,6 +1511,14 @@ return term_width_var_name; } +const ConstString & +DebuggerInstanceSettings::UseExternalEditorVarName () +{ + static ConstString use_external_editor_var_name ("use-external-editor"); + + return use_external_editor_var_name; +} + //-------------------------------------------------- // SettingsController Variable Tables //-------------------------------------------------- @@ -1515,5 +1542,6 @@ { "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." }, { "script-lang" , eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, { "prompt" , eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, + { "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." }, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Mon Sep 20 15:44:43 2010 @@ -57,7 +57,8 @@ UserSettingsController::GetGlobalVariable ( const ConstString &var_name, - StringList &value + StringList &value, + Error &err ) { return false; @@ -92,38 +93,33 @@ void UserSettingsController::InitializeGlobalVariables () { - static bool global_initialized = false; int num_entries; const char *prefix = GetLevelName().AsCString(); - if (! global_initialized) + num_entries = m_settings.global_settings.size(); + for (int i = 0; i < num_entries; ++i) { - num_entries = m_settings.global_settings.size(); - for (int i = 0; i < num_entries; ++i) + SettingEntry &entry = m_settings.global_settings[i]; + if (entry.default_value != NULL) { - SettingEntry &entry = m_settings.global_settings[i]; - if (entry.default_value != NULL) - { - StreamString full_name; - if (prefix[0] != '\0') - full_name.Printf ("%s.%s", prefix, entry.var_name); - else - full_name.Printf ("%s", entry.var_name); - SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false, ""); - } - else if ((entry.var_type == lldb::eSetVarTypeEnum) - && (entry.enum_values != NULL)) - { - StreamString full_name; - if (prefix[0] != '\0') - full_name.Printf ("%s.%s", prefix, entry.var_name); - else - full_name.Printf ("%s", entry.var_name); - SetVariable (full_name.GetData(), entry.enum_values[0].string_value, lldb::eVarSetOperationAssign, - false, ""); - } + StreamString full_name; + if (prefix[0] != '\0') + full_name.Printf ("%s.%s", prefix, entry.var_name); + else + full_name.Printf ("%s", entry.var_name); + SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false, ""); + } + else if ((entry.var_type == lldb::eSetVarTypeEnum) + && (entry.enum_values != NULL)) + { + StreamString full_name; + if (prefix[0] != '\0') + full_name.Printf ("%s.%s", prefix, entry.var_name); + else + full_name.Printf ("%s", entry.var_name); + SetVariable (full_name.GetData(), entry.enum_values[0].string_value, lldb::eVarSetOperationAssign, + false, ""); } - global_initialized = true; } } @@ -501,7 +497,8 @@ ( const char *full_dot_name, lldb::SettableVariableType &var_type, - const char *debugger_instance_name + const char *debugger_instance_name, + Error &err ) { Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name); @@ -519,7 +516,7 @@ if ((prefix != m_settings.level_name) && (m_settings.level_name.GetLength () > 0)) { - value.AppendString ("Invalid variable name"); + err.SetErrorString ("Invalid variable name"); return value; } @@ -548,7 +545,7 @@ new_name += '.'; new_name += names.GetArgumentAtIndex (j); } - return child->GetVariable (new_name.c_str(), var_type, debugger_instance_name); + return child->GetVariable (new_name.c_str(), var_type, debugger_instance_name, err); } } @@ -565,7 +562,7 @@ if (current_settings != NULL) { - current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); } else { @@ -578,14 +575,14 @@ if (pos != m_pending_settings.end()) { lldb::InstanceSettingsSP settings_sp = pos->second; - settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); } else { if (m_settings.level_name.GetLength() > 0) { // No valid instance name; assume they want the default settings. - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); } else { @@ -598,13 +595,13 @@ ConstString dbg_name (debugger_instance_name); InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); if (dbg_settings) - dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); } } } } else - value.AppendString ("Invalid variable name"); + err.SetErrorString ("Invalid variable name"); } } else @@ -613,18 +610,18 @@ if ((global_entry == NULL) && (instance_entry == NULL)) { - value.AppendString ("Invalid variable name"); + err.SetErrorString ("Invalid variable name"); } else if (global_entry) { var_type = global_entry->var_type; - GetGlobalVariable (const_var_name, value); + GetGlobalVariable (const_var_name, value, err); } else if (instance_entry) { var_type = instance_entry->var_type; if (m_settings.level_name.GetLength() > 0) - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); else { // We're at the Debugger level; use the debugger's instance settings. @@ -636,7 +633,7 @@ ConstString dbg_name (tmp_name.GetData()); InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); if (dbg_settings) - dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); } } } @@ -719,7 +716,7 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList value; - m_default_settings->GetInstanceSettingsValue (entry, var_name, value); + m_default_settings->GetInstanceSettingsValue (entry, var_name, value, err); std::string value_str; if (value.GetSize() == 1) @@ -780,7 +777,8 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList tmp_value; - m_default_settings->GetInstanceSettingsValue (entry, var_name, tmp_value); + Error err; + m_default_settings->GetInstanceSettingsValue (entry, var_name, tmp_value, err); StreamString value_string; @@ -819,7 +817,8 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList tmp_value; - settings_sp->GetInstanceSettingsValue (entry, var_name, tmp_value); + Error err; + settings_sp->GetInstanceSettingsValue (entry, var_name, tmp_value, err); StreamString value_str; @@ -885,7 +884,8 @@ SettingEntry &entry = m_settings.instance_settings[i]; const ConstString var_name (entry.var_name); StringList tmp_value; - settings->GetInstanceSettingsValue (entry, var_name, tmp_value); + Error err; + settings->GetInstanceSettingsValue (entry, var_name, tmp_value, err); StreamString tmp_value_str; if (tmp_value.GetSize() == 0) @@ -1362,7 +1362,7 @@ else full_var_name.Printf ("%s", entry.var_name); StringList value = root->GetVariable (full_var_name.GetData(), var_type, - interpreter.GetDebugger().GetInstanceName().AsCString()); + interpreter.GetDebugger().GetInstanceName().AsCString(), err); description.Clear(); if (value.GetSize() == 1) description.Printf ("%s (%s) = '%s'", full_var_name.GetData(), GetTypeString (entry.var_type), Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Sep 20 15:44:43 2010 @@ -138,16 +138,7 @@ // Non-CommandObjectCrossref commands can now be created. - lldb::ScriptLanguage script_language; - lldb::SettableVariableType var_type = lldb::eSetVarTypeString; - StringList value; - const char *dbg_name = GetDebugger().GetInstanceName().AsCString(); - StreamString var_name; - var_name.Printf ("[%s].script-lang", dbg_name); - value = Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, - m_debugger.GetInstanceName().AsCString()); - bool success; - script_language = Args::StringToScriptLanguage (value.GetStringAtIndex(0), lldb::eScriptLanguageDefault, &success); + lldb::ScriptLanguage script_language = m_debugger.GetScriptLanguage(); m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos (*this)); m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this)); @@ -778,21 +769,13 @@ const char * CommandInterpreter::GetPrompt () { - lldb::SettableVariableType var_type; - const char *instance_name = GetDebugger().GetInstanceName().AsCString(); - StreamString var_name; - var_name.Printf ("[%s].prompt", instance_name); - return Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, instance_name).GetStringAtIndex(0); + return m_debugger.GetPrompt(); } void CommandInterpreter::SetPrompt (const char *new_prompt) { - const char *instance_name = GetDebugger().GetInstanceName().AsCString(); - StreamString name_str; - name_str.Printf ("[%s].prompt", instance_name); - Debugger::GetSettingsController()->SetVariable (name_str.GetData(), new_prompt, lldb::eVarSetOperationAssign, - false, m_debugger.GetInstanceName().AsCString()); + m_debugger.SetPrompt (new_prompt); } void Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Mon Sep 20 15:44:43 2010 @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -204,7 +205,7 @@ // architecture: if (!m_module->GetArchitecture().IsValid()) { - arch = lldb_private::GetDefaultArchitecture (); + arch = Target::GetDefaultArchitecture (); if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Sep 20 15:44:43 2010 @@ -1851,7 +1851,7 @@ //-------------------------------------------------------------- Process::SettingsController::SettingsController () : - UserSettingsController ("process", Debugger::GetSettingsController()) + UserSettingsController ("process", Target::GetSettingsController()) { m_default_settings.reset (new ProcessInstanceSettings (*this, false, InstanceSettings::GetDefaultName().AsCString())); @@ -1991,7 +1991,8 @@ void ProcessInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, - StringList &value) + StringList &value, + Error &err) { if (var_name == RunArgsVarName()) { @@ -2038,7 +2039,7 @@ value.AppendString ("false"); } else - value.AppendString ("unrecognized variable name"); + err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); } const ConstString Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Sep 20 15:44:43 2010 @@ -35,6 +35,7 @@ //---------------------------------------------------------------------- Target::Target(Debugger &debugger) : Broadcaster("Target"), + TargetInstanceSettings (*(Target::GetSettingsController().get())), m_debugger (debugger), m_images(), m_section_load_list (), @@ -743,3 +744,233 @@ { return m_scratch_ast_context_ap.get(); } + +lldb::UserSettingsControllerSP +Target::GetSettingsController (bool finish) +{ + static lldb::UserSettingsControllerSP g_settings_controller (new SettingsController); + static bool initialized = false; + + if (!initialized) + { + initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, + Target::SettingsController::global_settings_table, + Target::SettingsController::instance_settings_table); + } + + if (finish) + { + UserSettingsController::FinalizeSettingsController (g_settings_controller); + g_settings_controller.reset(); + initialized = false; + } + + return g_settings_controller; +} + +ArchSpec +Target::GetDefaultArchitecture () +{ + lldb::UserSettingsControllerSP settings_controller = Target::GetSettingsController(); + lldb::SettableVariableType var_type; + Error err; + StringList result = settings_controller->GetVariable ("target.default-arch", var_type, "[]", err); + + const char *default_name = ""; + if (result.GetSize() == 1 && err.Success()) + default_name = result.GetStringAtIndex (0); + + ArchSpec default_arch (default_name); + return default_arch; +} + +void +Target::SetDefaultArchitecture (ArchSpec new_arch) +{ + if (new_arch.IsValid()) + Target::GetSettingsController ()->SetVariable ("target.default-arch", new_arch.AsCString(), + lldb::eVarSetOperationAssign, false, "[]"); +} + +//-------------------------------------------------------------- +// class Target::SettingsController +//-------------------------------------------------------------- + +Target::SettingsController::SettingsController () : + UserSettingsController ("target", Debugger::GetSettingsController()), + m_default_architecture () +{ + m_default_settings.reset (new TargetInstanceSettings (*this, false, + InstanceSettings::GetDefaultName().AsCString())); +} + +Target::SettingsController::~SettingsController () +{ +} + +lldb::InstanceSettingsSP +Target::SettingsController::CreateInstanceSettings (const char *instance_name) +{ + TargetInstanceSettings *new_settings = new TargetInstanceSettings (*(Target::GetSettingsController().get()), + false, instance_name); + lldb::InstanceSettingsSP new_settings_sp (new_settings); + return new_settings_sp; +} + +const ConstString & +Target::SettingsController::DefArchVarName () +{ + static ConstString def_arch_var_name ("default-arch"); + + return def_arch_var_name; +} + +bool +Target::SettingsController::SetGlobalVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + const lldb::VarSetOperationType op, + Error&err) +{ + if (var_name == DefArchVarName()) + { + ArchSpec tmp_spec (value); + if (tmp_spec.IsValid()) + m_default_architecture = tmp_spec; + else + err.SetErrorStringWithFormat ("'%s' is not a valid architecture.", value); + } + return true; +} + + +bool +Target::SettingsController::GetGlobalVariable (const ConstString &var_name, + StringList &value, + Error &err) +{ + if (var_name == DefArchVarName()) + { + value.AppendString (m_default_architecture.AsCString()); + return true; + } + else + err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + + return false; +} + +//-------------------------------------------------------------- +// class TargetInstanceSettings +//-------------------------------------------------------------- + +TargetInstanceSettings::TargetInstanceSettings (UserSettingsController &owner, bool live_instance, + const char *name) : + InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance) +{ + // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called + // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. + // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + // This is true for CreateInstanceName() too. + + if (GetInstanceName () == InstanceSettings::InvalidName()) + { + ChangeInstanceName (std::string (CreateInstanceName().AsCString())); + m_owner.RegisterInstanceSettings (this); + } + + if (live_instance) + { + const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); + CopyInstanceSettings (pending_settings,false); + //m_owner.RemovePendingSettings (m_instance_name); + } +} + +TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) : + InstanceSettings (*(Target::GetSettingsController().get()), CreateInstanceName().AsCString()) +{ + if (m_instance_name != InstanceSettings::GetDefaultName()) + { + const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); + CopyInstanceSettings (pending_settings,false); + //m_owner.RemovePendingSettings (m_instance_name); + } +} + +TargetInstanceSettings::~TargetInstanceSettings () +{ +} + +TargetInstanceSettings& +TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs) +{ + if (this != &rhs) + { + } + + return *this; +} + + +void +TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const ConstString &instance_name, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error &err, + bool pending) +{ + // Currently 'target' does not have any instance settings. +} + +void +TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, + bool pending) +{ + // Currently 'target' does not have any instance settings. +} + +void +TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, + const ConstString &var_name, + StringList &value, + Error &err) +{ + // Currently 'target' does not have any instance settings. +} + +const ConstString +TargetInstanceSettings::CreateInstanceName () +{ + static int instance_count = 1; + StreamString sstr; + + sstr.Printf ("target_%d", instance_count); + ++instance_count; + + const ConstString ret_val (sstr.GetData()); + return ret_val; +} + +//-------------------------------------------------- +// Target::SettingsController Variable Tables +//-------------------------------------------------- + +SettingEntry +Target::SettingsController::global_settings_table[] = +{ + //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, + { "default-arch", eSetVarTypeString, "x86_64", NULL, false, false, "Default architecture to choose, when there's a choice." }, + { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } +}; + +SettingEntry +Target::SettingsController::instance_settings_table[] = +{ + //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, + { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } +}; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Sep 20 15:44:43 2010 @@ -1064,8 +1064,9 @@ void ThreadInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, - const ConstString &var_name, - StringList &value) + const ConstString &var_name, + StringList &value, + Error &err) { if (var_name == StepAvoidRegexpVarName()) { @@ -1076,10 +1077,10 @@ regexp_text.append ("\""); value.AppendString (regexp_text.c_str()); } - + } else - value.AppendString ("unrecognized variable name"); + err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); } const ConstString Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Sep 20 15:44:43 2010 @@ -79,8 +79,9 @@ SymbolVendorMacOSX::Initialize(); #endif Debugger::GetSettingsController (false); + Target::GetSettingsController (false); Process::GetSettingsController (false); - Thread::GetSettingsController (false); + Thread::GetSettingsController (false); #ifdef __linux__ ProcessLinux::Initialize(); #endif @@ -115,9 +116,10 @@ SymbolVendorMacOSX::Terminate(); #endif + Thread::GetSettingsController (true); Process::GetSettingsController (true); + Target::GetSettingsController (true); Debugger::GetSettingsController (true); - Thread::GetSettingsController (true); #ifdef __linux__ ProcessLinux::Terminate(); @@ -135,14 +137,6 @@ return g_version_string; } -ArchSpec & -lldb_private::GetDefaultArchitecture () -{ - static ArchSpec g_default_arch; - return g_default_arch; -} - - const char * lldb_private::GetVoteAsCString (lldb::Vote vote) { Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114352&r1=114351&r2=114352&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Sep 20 15:44:43 2010 @@ -61,8 +61,8 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set the run-args and the env-vars. - self.runCmd('settings set process.run-args A B C') - self.runCmd('settings set process.env-vars ["MY_ENV_VAR"]=YES') + self.runCmd('settings set target.process.run-args A B C') + self.runCmd('settings set target.process.env-vars ["MY_ENV_VAR"]=YES') self.runCmd("run", RUN_SUCCEEDED) @@ -76,18 +76,18 @@ @unittest2.expectedFailure # rdar://problem/8435794 - # settings set process.output-path does not seem to work + # settings set target.process.output-path does not seem to work def test_set_output_path(self): - """Test that setting process.output-path for the launched process works.""" + """Test that setting target.process.output-path for the launched process works.""" self.buildDefault() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set the output-path and verify it is set. - self.runCmd("settings set process.output-path 'stdout.txt'") - self.expect("settings show process.output-path", - startstr = "process.output-path (string) = 'stdout.txt'") + self.runCmd("settings set target.process.output-path 'stdout.txt'") + self.expect("settings show target.process.output-path", + startstr = "target.process.output-path (string) = 'stdout.txt'") self.runCmd("run", RUN_SUCCEEDED) From ctice at apple.com Mon Sep 20 16:37:42 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Sep 2010 21:37:42 -0000 Subject: [Lldb-commits] [lldb] r114361 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/UserSettingsController.h include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Target.cpp source/Target/Thread.cpp Message-ID: <20100920213743.0AA412A6C12C@llvm.org> Author: ctice Date: Mon Sep 20 16:37:42 2010 New Revision: 114361 URL: http://llvm.org/viewvc/llvm-project?rev=114361&view=rev Log: Make GetInstanceSettingsValue methods take an Error * rather than an Error &, and have them return a bool to indicate success or not. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon Sep 20 16:37:42 2010 @@ -60,11 +60,11 @@ Error &err, bool pending); - void + bool GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err); + Error *err); uint32_t GetTerminalWidth () const Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Mon Sep 20 16:37:42 2010 @@ -370,11 +370,11 @@ Error &err, bool pending) = 0; - virtual void + virtual bool GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err) = 0; + Error *err) = 0; virtual void CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Sep 20 16:37:42 2010 @@ -69,11 +69,11 @@ Error &err, bool pending); - void + bool GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err); + Error *err); const Args & Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Mon Sep 20 16:37:42 2010 @@ -56,11 +56,11 @@ Error &err, bool pending); - void + bool GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err); + Error *err); protected: Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Mon Sep 20 16:37:42 2010 @@ -50,11 +50,11 @@ Error &err, bool pending); - void + bool GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err); + Error *err); RegularExpression * GetSymbolsToAvoidRegexp() Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Sep 20 16:37:42 2010 @@ -1375,11 +1375,11 @@ } } -void +bool DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err) + Error *err) { if (var_name == PromptVarName()) { @@ -1404,7 +1404,12 @@ value.AppendString ("false"); } else - err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + { + if (err) + err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + return false; + } + return true; } void Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Mon Sep 20 16:37:42 2010 @@ -562,7 +562,7 @@ if (current_settings != NULL) { - current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); } else { @@ -575,14 +575,14 @@ if (pos != m_pending_settings.end()) { lldb::InstanceSettingsSP settings_sp = pos->second; - settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); } else { if (m_settings.level_name.GetLength() > 0) { // No valid instance name; assume they want the default settings. - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); } else { @@ -595,7 +595,7 @@ ConstString dbg_name (debugger_instance_name); InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); if (dbg_settings) - dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); } } } @@ -621,7 +621,7 @@ { var_type = instance_entry->var_type; if (m_settings.level_name.GetLength() > 0) - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); else { // We're at the Debugger level; use the debugger's instance settings. @@ -633,7 +633,7 @@ ConstString dbg_name (tmp_name.GetData()); InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); if (dbg_settings) - dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, err); + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err); } } } @@ -716,7 +716,7 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList value; - m_default_settings->GetInstanceSettingsValue (entry, var_name, value, err); + m_default_settings->GetInstanceSettingsValue (entry, var_name, value, NULL); std::string value_str; if (value.GetSize() == 1) @@ -777,8 +777,7 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList tmp_value; - Error err; - m_default_settings->GetInstanceSettingsValue (entry, var_name, tmp_value, err); + m_default_settings->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL); StreamString value_string; @@ -817,8 +816,7 @@ SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); StringList tmp_value; - Error err; - settings_sp->GetInstanceSettingsValue (entry, var_name, tmp_value, err); + settings_sp->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL); StreamString value_str; @@ -884,8 +882,7 @@ SettingEntry &entry = m_settings.instance_settings[i]; const ConstString var_name (entry.var_name); StringList tmp_value; - Error err; - settings->GetInstanceSettingsValue (entry, var_name, tmp_value, err); + settings->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL); StreamString tmp_value_str; if (tmp_value.GetSize() == 0) Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Sep 20 16:37:42 2010 @@ -1988,11 +1988,11 @@ m_disable_aslr = new_process_settings->m_disable_aslr; } -void +bool ProcessInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err) + Error *err) { if (var_name == RunArgsVarName()) { @@ -2039,7 +2039,12 @@ value.AppendString ("false"); } else - err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + { + if (err) + err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + return false; + } + return true; } const ConstString Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Sep 20 16:37:42 2010 @@ -934,11 +934,11 @@ // Currently 'target' does not have any instance settings. } -void +bool TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err) + Error *err) { // Currently 'target' does not have any instance settings. } Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114361&r1=114360&r2=114361&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Sep 20 16:37:42 2010 @@ -1062,11 +1062,11 @@ m_avoid_regexp_ap.reset (); } -void +bool ThreadInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value, - Error &err) + Error *err) { if (var_name == StepAvoidRegexpVarName()) { @@ -1080,7 +1080,12 @@ } else - err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + { + if (err) + err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); + return false; + } + return true; } const ConstString From ctice at apple.com Mon Sep 20 16:52:58 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Sep 2010 21:52:58 -0000 Subject: [Lldb-commits] [lldb] r114364 - /lldb/trunk/source/Interpreter/Options.cpp Message-ID: <20100920215258.6DC552A6C12C@llvm.org> Author: ctice Date: Mon Sep 20 16:52:58 2010 New Revision: 114364 URL: http://llvm.org/viewvc/llvm-project?rev=114364&view=rev Log: Make the short option print out before the long option in the command options detailed help section (since it's sorted by short option). Modified: lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=114364&r1=114363&r2=114364&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Mon Sep 20 16:52:58 2010 @@ -572,10 +572,10 @@ strm.EOL(); strm.Indent (); - strm.Printf ("--%s", full_options_table[i].long_option); + strm.Printf ("-%c", full_options_table[i].short_option); if (full_options_table[i].argument_name != NULL) strm.Printf (" %s", full_options_table[i].argument_name); - strm.Printf (" ( -%c", full_options_table[i].short_option); + strm.Printf (" ( --%s", full_options_table[i].long_option); if (full_options_table[i].argument_name != NULL) strm.Printf (" %s", full_options_table[i].argument_name); strm.PutCString(" )\n"); From johnny.chen at apple.com Mon Sep 20 18:51:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Sep 2010 23:51:28 -0000 Subject: [Lldb-commits] [lldb] r114377 - /lldb/trunk/test/conditional_break/conditional_break.py Message-ID: <20100920235128.0EAD52A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 18:51:27 2010 New Revision: 114377 URL: http://llvm.org/viewvc/llvm-project?rev=114377&view=rev Log: Changed this breakpoint callback function to print to the stdout instead of stderr so as not to disrupt the information emitted by the unittest framework. Modified: lldb/trunk/test/conditional_break/conditional_break.py Modified: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=114377&r1=114376&r2=114377&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (original) +++ lldb/trunk/test/conditional_break/conditional_break.py Mon Sep 20 18:51:27 2010 @@ -24,15 +24,15 @@ # of the leaf function c() is a(). If it's not the right caller, we ask the # command interpreter to continue execution. - print >> sys.stderr, "Checking call frames..." + print >> sys.stdout, "Checking call frames..." lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: funcs = lldbutil.GetFunctionNames(thread) - print >> sys.stderr, funcs[0], "called from", funcs[1] + print >> sys.stdout, funcs[0], "called from", funcs[1] if (funcs[0] == 'c' and funcs[1] == 'a'): - print >> sys.stderr, "Stopped at c() with immediate caller as a()." + print >> sys.stdout, "Stopped at c() with immediate caller as a()." else: - print >> sys.stderr, "Continuing..." + print >> sys.stdout, "Continuing..." ci.HandleCommand("process continue", res) return True From johnny.chen at apple.com Mon Sep 20 19:09:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 00:09:27 -0000 Subject: [Lldb-commits] [lldb] r114380 - in /lldb/trunk: examples/test/ examples/test/.lldbtest-config examples/test/lldbtest-stderr examples/test/lldbtest-stdout examples/test/usage-config test/dotest.py test/plugins/darwin.py Message-ID: <20100921000927.379EC2A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 19:09:27 2010 New Revision: 114380 URL: http://llvm.org/viewvc/llvm-project?rev=114380&view=rev Log: Added the capability to source the configFile specified via the "-c" option in order to customize the running of the test suite. For the time being, the supported customizations are: o redirecting stdout and/or stderr o specifying a list of compilers to build the test programs o specifying a list of architectures to build the test programs for Also checked into the examples/test directory some example files which demonstrate the usage for the above customizations. $ ./dotest.py -v -c ~/.lldbtest-config persistent_variables $ cat ~/.lldbtest-config sys.stderr = open("/tmp/lldbtest-stderr", "w") sys.stdout = open("/tmp/lldbtest-stdout", "w") compilers = ["gcc", "llvm-gcc"] archs = ["x86_64", "i386"] $ cat /tmp/lldbtest-stderr ---------------------------------------------------------------------- Collected 1 test Configuration: arch=x86_64 compiler=gcc test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) Test that lldb persistent variables works correctly. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.397s OK Configuration: arch=x86_64 compiler=llvm-gcc test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) Test that lldb persistent variables works correctly. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.282s OK Configuration: arch=i386 compiler=gcc test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) Test that lldb persistent variables works correctly. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.297s OK Configuration: arch=i386 compiler=llvm-gcc test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) Test that lldb persistent variables works correctly. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.269s OK $ cat /tmp/lldbtest-stdout $ Added: lldb/trunk/examples/test/ lldb/trunk/examples/test/.lldbtest-config lldb/trunk/examples/test/lldbtest-stderr lldb/trunk/examples/test/lldbtest-stdout lldb/trunk/examples/test/usage-config Modified: lldb/trunk/test/dotest.py lldb/trunk/test/plugins/darwin.py Added: lldb/trunk/examples/test/.lldbtest-config URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/.lldbtest-config?rev=114380&view=auto ============================================================================== --- lldb/trunk/examples/test/.lldbtest-config (added) +++ lldb/trunk/examples/test/.lldbtest-config Mon Sep 20 19:09:27 2010 @@ -0,0 +1,5 @@ +sys.stderr = open("/tmp/lldbtest-stderr", "w") +sys.stdout = open("/tmp/lldbtest-stdout", "w") +compilers = ["gcc", "llvm-gcc"] +archs = ["x86_64", "i386"] + Added: lldb/trunk/examples/test/lldbtest-stderr URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/lldbtest-stderr?rev=114380&view=auto ============================================================================== --- lldb/trunk/examples/test/lldbtest-stderr (added) +++ lldb/trunk/examples/test/lldbtest-stderr Mon Sep 20 19:09:27 2010 @@ -0,0 +1,39 @@ +---------------------------------------------------------------------- +Collected 1 test + + +Configuration: arch=x86_64 compiler=gcc +test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) +Test that lldb persistent variables works correctly. ... ok + +---------------------------------------------------------------------- +Ran 1 test in 1.397s + +OK + +Configuration: arch=x86_64 compiler=llvm-gcc +test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) +Test that lldb persistent variables works correctly. ... ok + +---------------------------------------------------------------------- +Ran 1 test in 1.282s + +OK + +Configuration: arch=i386 compiler=gcc +test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) +Test that lldb persistent variables works correctly. ... ok + +---------------------------------------------------------------------- +Ran 1 test in 1.297s + +OK + +Configuration: arch=i386 compiler=llvm-gcc +test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase) +Test that lldb persistent variables works correctly. ... ok + +---------------------------------------------------------------------- +Ran 1 test in 1.269s + +OK Added: lldb/trunk/examples/test/lldbtest-stdout URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/lldbtest-stdout?rev=114380&view=auto ============================================================================== (empty) Added: lldb/trunk/examples/test/usage-config URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/test/usage-config?rev=114380&view=auto ============================================================================== --- lldb/trunk/examples/test/usage-config (added) +++ lldb/trunk/examples/test/usage-config Mon Sep 20 19:09:27 2010 @@ -0,0 +1,10 @@ +# This is an example of using the "-c" option to source a config file to +# reassign the system stderr and stdout and to exercise different combinations +# of architectures and compilers. +# +# The config file is checked in as .lldbtest-config and the redirected stderr +# and stdout are checked in as lldbtest-stderr and lldbtest-stdout, all in the +# the same directory as this file. + +[15:36:32] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -c ~/.lldbtest-config persistent_variables +[15:40:55] johnny:/Volumes/data/lldb/svn/trunk/test $ Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114380&r1=114379&r2=114380&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Sep 20 19:09:27 2010 @@ -48,6 +48,9 @@ # The config file is optional. configFile = None +# The dictionary as a result of sourcing configFile. +config = {} + # Delay startup in order for the debugger to attach. delay = False @@ -63,9 +66,6 @@ # Separator string. separator = '-' * 70 -# Decorated sys.stderr for our consumption. -err = _WritelnDecorator(sys.stderr) - def usage(): print """ @@ -73,6 +73,7 @@ where options: -h : print this help message and exit (also --help) -c : read a config file specified after this option + (see also lldb-trunk/example/test/usage-config) -d : delay startup for 10 seconds (in order for the debugger to attach) -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module @@ -154,6 +155,25 @@ if len(sys.argv) > index: testdirs = map(os.path.abspath, sys.argv[index:]) + # Source the configFile if specified. + # The side effect, if any, will be felt from this point on. An example + # config file may be these simple two lines: + # + # sys.stderr = open("/tmp/lldbtest-stderr", "w") + # sys.stdout = open("/tmp/lldbtest-stdout", "w") + # + # which will reassign the two file objects to sys.stderr and sys.stdout, + # respectively. + # + # See also lldb-trunk/example/test/usage-config. + global config + if configFile: + # Pass config (a dictionary) as the locals namespace for side-effect. + execfile(configFile, globals(), config) + #print "config:", config + #print "sys.stderr:", sys.stderr + #print "sys.stdout:", sys.stdout + def setupSysPath(): """Add LLDB.framework/Resources/Python to the search paths for modules.""" @@ -297,13 +317,15 @@ for testdir in testdirs: os.path.walk(testdir, visit, 'Test') +# # Now that we have loaded all the test cases, run the whole test suite. +# # First, write out the number of collected test cases. -err.writeln(separator) -err.writeln("Collected %d test%s" % (suite.countTestCases(), - suite.countTestCases() != 1 and "s" or "")) -err.writeln() +sys.stderr.write(separator + "\n") +sys.stderr.write("Collected %d test%s\n\n" + % (suite.countTestCases(), + suite.countTestCases() != 1 and "s" or "")) # For the time being, let's bracket the test runner within the # lldb.SBDebugger.Initialize()/Terminate() pair. @@ -320,8 +342,41 @@ # Install the control-c handler. unittest2.signals.installHandler() -# Invoke the default TextTestRunner to run the test suite. -result = unittest2.TextTestRunner(verbosity=verbose).run(suite) +# +# Invoke the default TextTestRunner to run the test suite, possibly iterating +# over different configurations. +# + +iterCompilers = False +iterArchs = False + +from types import * +if "archs" in config: + archs = config["archs"] + if type(archs) is ListType and len(archs) >= 1: + iterArchs = True +if "compilers" in config: + compilers = config["compilers"] + if type(compilers) is ListType and len(compilers) >= 1: + iterCompilers = True + +for ia in range(len(archs) if iterArchs else 1): + archConfig = "" + if iterArchs: + os.environ["LLDB_ARCH"] = archs[ia] + archConfig = "arch=%s" % archs[ia] + for ic in range(len(compilers) if iterCompilers else 1): + if iterCompilers: + os.environ["LLDB_CC"] = compilers[ic] + configString = "%s compiler=%s" % (archConfig, compilers[ic]) + else: + configString = archConfig + + # Invoke the test runner. + if iterArchs or iterCompilers: + sys.stderr.write("\nConfiguration: " + configString + "\n") + result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose).run(suite) + # Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined. # This should not be necessary now. Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=114380&r1=114379&r2=114380&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Mon Sep 20 19:09:27 2010 @@ -7,6 +7,9 @@ If neither the compiler keyword argument nor the LLDB_CC environment variable is specified, no CC make variable is passed to the make command. The Makefile gets to define the default CC being used. + +Same idea holds for LLDB_ARCH environment variable, which maps to the ARCH make +variable. """ import os @@ -16,7 +19,7 @@ def getCCSpec(compiler): """ - Helper function to return the key-value pair string to specify the compiler + Helper function to return the key-value string to specify the compiler used for the make system. """ cc = compiler if compiler else None @@ -26,27 +29,42 @@ # Note the leading space character. return (" CC=" + cc) if cc else "" +def getArchSpec(architecture): + """ + Helper function to return the key-value string to specify the architecture + used for the make system. + """ + arch = architecture if architecture else None + if not arch and "LLDB_ARCH" in os.environ: + arch = os.environ["LLDB_ARCH"] + + # Note the leading space character. + return (" ARCH=" + arch) if arch else "" + -def buildDefault(compiler=None): +def buildDefault(architecture=None, compiler=None): """Build the binaries the default way.""" lldbtest.system(["/bin/sh", "-c", - "make clean; make" + getCCSpec(compiler)]) + "make clean; make" + + getArchSpec(architecture) + getCCSpec(compiler)]) # True signifies that we can handle building default. return True -def buildDsym(compiler=None): +def buildDsym(architecture=None, compiler=None): """Build the binaries with dsym debug info.""" lldbtest.system(["/bin/sh", "-c", - "make clean; make MAKE_DSYM=YES" + getCCSpec(compiler)]) + "make clean; make MAKE_DSYM=YES" + + getArchSpec(architecture) + getCCSpec(compiler)]) # True signifies that we can handle building dsym. return True -def buildDwarf(compiler=None): +def buildDwarf(architecture=None, compiler=None): """Build the binaries with dwarf debug info.""" lldbtest.system(["/bin/sh", "-c", - "make clean; make MAKE_DSYM=NO" + getCCSpec(compiler)]) + "make clean; make MAKE_DSYM=NO" + + getArchSpec(architecture) + getCCSpec(compiler)]) # True signifies that we can handle building dsym. return True From johnny.chen at apple.com Mon Sep 20 19:16:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 00:16:09 -0000 Subject: [Lldb-commits] [lldb] r114381 - /lldb/trunk/test/dotest.py Message-ID: <20100921001609.35EB82A6C12C@llvm.org> Author: johnny Date: Mon Sep 20 19:16:09 2010 New Revision: 114381 URL: http://llvm.org/viewvc/llvm-project?rev=114381&view=rev Log: Changed the order of two assignment stmts. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114381&r1=114380&r2=114381&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Sep 20 19:16:09 2010 @@ -347,8 +347,8 @@ # over different configurations. # -iterCompilers = False iterArchs = False +iterCompilers = False from types import * if "archs" in config: From scallanan at apple.com Mon Sep 20 19:44:12 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 21 Sep 2010 00:44:12 -0000 Subject: [Lldb-commits] [lldb] r114384 - in /lldb/trunk: include/lldb/Expression/ include/lldb/Target/ source/Expression/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Symbol/ source/Target/ Message-ID: <20100921004413.286162A6C12C@llvm.org> Author: spyffe Date: Mon Sep 20 19:44:12 2010 New Revision: 114384 URL: http://llvm.org/viewvc/llvm-project?rev=114384&view=rev Log: Removed the hacky "#define this ___clang_this" handler for C++ classes. Replaced it with a less hacky approach: - If an expression is defined in the context of a method of class A, then that expression is wrapped as ___clang_class::___clang_expr(void*) { ... } instead of ___clang_expr(void*) { ... }. - ___clang_class is resolved as the type of the target of the "this" pointer in the method the expression is defined in. - When reporting the type of ___clang_class, a method with the signature ___clang_expr(void*) is added to that class, so that Clang doesn't complain about a method being defined without a corresponding declaration. - Whenever the expression gets called, "this" gets looked up, type-checked, and then passed in as the first argument. This required the following changes: - The ABIs were changed to support passing of the "this" pointer as part of trivial calls. - ThreadPlanCallFunction and ClangFunction were changed to support passing of an optional "this" pointer. - ClangUserExpression was extended to perform the wrapping described above. - ClangASTSource was changed to revert the changes required by the hack. - ClangExpressionParser, IRForTarget, and ClangExpressionDeclMap were changed to handle different manglings of ___clang_expr flexibly. This meant no longer searching for a function called ___clang_expr, but rather looking for a function whose name *contains* ___clang_expr. - ClangExpressionParser and ClangExpressionDeclMap now remember whether "this" is required, and know how to look it up as necessary. A few inheritance bugs remain, and I'm trying to resolve these. But it is now possible to use "this" as well as refer implicitly to member variables, when in the proper context. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRForTarget.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/Symbol/ClangASTContext.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Mon Sep 20 19:44:12 2010 @@ -161,15 +161,8 @@ /// /// @param[in] type /// The opaque QualType for the VarDecl being registered. - /// - /// @param[in] override_name - /// In some cases, the name needs to be overridden (such as when - /// searching for ___clang_this, which should resolve to this). - /// This is the name to be used instead of what is being searched - /// for. //------------------------------------------------------------------ - clang::NamedDecl *AddVarDecl(void *type, - const char *override_name = NULL); + clang::NamedDecl *AddVarDecl(void *type); //------------------------------------------------------------------ /// Create a FunDecl with the name being searched for and the provided Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Sep 20 19:44:12 2010 @@ -267,6 +267,27 @@ Error &error); //------------------------------------------------------------------ + /// [Used by CommandObjectExpression] Get the "this" pointer + /// from a given execution context. + /// + /// @param[out] object_ptr + /// The this pointer. + /// + /// @param[in] exe_ctx + /// The execution context at which to dump the struct. + /// + /// @param[in] error + /// An Error to populate with any messages related to + /// finding the "this" pointer. + /// + /// @return + /// True on success; false otherwise. + //------------------------------------------------------------------ + bool GetObjectPointer(lldb::addr_t &object_ptr, + ExecutionContext *exe_ctx, + Error &error); + + //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Pretty-print a materialized /// struct, which must have been materialized by Materialize(), /// byte for byte on a given stream. @@ -340,6 +361,7 @@ lldb::addr_t m_allocated_area; ///< The base of the memory allocated for the struct. Starts on a potentially unaligned address and may therefore be larger than the struct. lldb::addr_t m_materialized_location; ///< The address at which the struct is placed. Falls inside the allocated area. std::string m_result_name; ///< The name of the result variable ($1, for example) + TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if one exists. //------------------------------------------------------------------ /// Given a stack frame, find a variable that matches the given name and @@ -415,14 +437,9 @@ /// /// @param[in] var /// The LLDB Variable that needs a Decl. - /// - /// @param[in] override_name - /// A new name to give the Decl, if the one being looked for needs - /// to be overriden. Example: this for ___clang_this. //------------------------------------------------------------------ void AddOneVariable(NameSearchContext &context, - Variable *var, - const char *override_name); + Variable *var); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given @@ -462,9 +479,15 @@ /// The NameSearchContext to use when constructing the Decl. /// /// @param[in] type - /// The LLDB Type that needs to be created. - //------------------------------------------------------------------ - void AddOneType(NameSearchContext &context, Type *type); + /// The type that needs to be created. + /// + /// @param[in] add_method + /// True if a method with signature void ___clang_expr(void*) + /// should be added to the C++ class type passed in + //------------------------------------------------------------------ + void AddOneType(NameSearchContext &context, + TypeFromUser &type, + bool add_method = false); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing the struct. Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Mon Sep 20 19:44:12 2010 @@ -262,6 +262,10 @@ /// @param[in] errors /// The stream to write errors to. /// + /// @param[in] this_arg + /// If non-NULL, the function is invoked like a C++ method, with the + /// value pointed to by the pointer as its 'this' argument. + /// /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ @@ -271,7 +275,8 @@ bool stop_others, bool try_all_threads, uint32_t single_thread_timeout_usec, - Stream &errors); + Stream &errors, + lldb::addr_t* this_arg = 0); //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. @@ -415,6 +420,10 @@ /// @param[in] discard_on_error /// True if the thread plan may simply be discarded if an error occurs. /// + /// @param[in] this_arg + /// If non-NULL, the function is invoked like a C++ method, with the + /// value pointed to by the pointer as its 'this' argument. + /// /// @return /// A ThreadPlan for executing the function. //------------------------------------------------------------------ @@ -424,7 +433,8 @@ lldb::addr_t &args_addr_ref, Stream &errors, bool stop_others, - bool discard_on_error = true); + bool discard_on_error = true, + lldb::addr_t *this_arg = 0); //------------------------------------------------------------------ /// Get a thread plan to run the function this ClangFunction was created with. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Sep 20 19:44:12 2010 @@ -171,6 +171,12 @@ } private: + //------------------------------------------------------------------ + /// Populate m_cplusplus and m_objetivec based on the environment. + //------------------------------------------------------------------ + void + ScanContext(ExecutionContext &exe_ctx); + std::string m_expr_text; ///< The text of the expression, as typed by the user std::string m_transformed_text; ///< The text of the expression, as send to the parser @@ -178,6 +184,10 @@ std::auto_ptr m_local_variables; ///< The local expression variables, if the expression is DWARF. std::auto_ptr m_dwarf_opcodes; ///< The DWARF opcodes for the expression. May be NULL. lldb::addr_t m_jit_addr; ///< The address of the JITted code. LLDB_INVALID_ADDRESS if invalid. + + bool m_cplusplus; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method). + bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method). + bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression doesn't really use them and they can be NULL. }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Mon Sep 20 19:44:12 2010 @@ -34,7 +34,8 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg) const = 0; + lldb::addr_t arg, + lldb::addr_t *this_arg) const = 0; virtual bool PrepareNormalCall (Thread &thread, Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Mon Sep 20 19:44:12 2010 @@ -27,7 +27,8 @@ Address &function, lldb::addr_t arg, bool stop_other_threads, - bool discard_on_error = true); + bool discard_on_error = true, + lldb::addr_t *this_arg = 0); ThreadPlanCallFunction (Thread &thread, Address &function, Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Sep 20 19:44:12 2010 @@ -85,15 +85,8 @@ return &ASTSource.Context; } -clang::NamedDecl *NameSearchContext::AddVarDecl(void *type, - const char *override_name) { - IdentifierInfo *ii = NULL; - - if (override_name) - ii = &ASTSource.Context.Idents.get(override_name); - else - ii = Name.getAsIdentifierInfo(); - +clang::NamedDecl *NameSearchContext::AddVarDecl(void *type) { + IdentifierInfo *ii = Name.getAsIdentifierInfo(); clang::NamedDecl *Decl = VarDecl::Create(ASTSource.Context, const_cast(DC), Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 20 19:44:12 2010 @@ -300,6 +300,78 @@ } bool +ClangExpressionDeclMap::GetObjectPointer(lldb::addr_t &object_ptr, + ExecutionContext *exe_ctx, + Error &err) +{ + if (!exe_ctx || !exe_ctx->frame || !exe_ctx->target || !exe_ctx->process) + { + err.SetErrorString("Couldn't load 'this' because the context is incomplete"); + return false; + } + + if (!m_object_pointer_type.GetOpaqueQualType()) + { + err.SetErrorString("Couldn't load 'this' because its type is unknown"); + return false; + } + + Variable *object_ptr_var = FindVariableInScope(*exe_ctx->frame, "this", &m_object_pointer_type); + + if (!object_ptr_var) + { + err.SetErrorString("Couldn't find 'this' with appropriate type in scope"); + return false; + } + + std::auto_ptr location_value(GetVariableValue(*exe_ctx, + object_ptr_var, + m_object_pointer_type.GetASTContext())); + + if (!location_value.get()) + { + err.SetErrorString("Couldn't get the location for 'this'"); + return false; + } + + if (location_value->GetValueType() == Value::eValueTypeLoadAddress) + { + lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); + uint32_t address_byte_size = exe_ctx->target->GetArchitecture().GetAddressByteSize(); + lldb::ByteOrder address_byte_order = exe_ctx->process->GetByteOrder(); + + if (ClangASTType::GetClangTypeBitWidth(m_object_pointer_type.GetASTContext(), m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) + { + err.SetErrorStringWithFormat("'this' is not of an expected pointer size"); + return false; + } + + DataBufferHeap data; + data.SetByteSize(address_byte_size); + Error read_error; + + if (exe_ctx->process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) + { + err.SetErrorStringWithFormat("Coldn't read 'this' from the target: %s", read_error.AsCString()); + return false; + } + + DataExtractor extractor(data.GetBytes(), data.GetByteSize(), address_byte_order, address_byte_size); + + uint32_t offset = 0; + + object_ptr = extractor.GetPointer(&offset); + + return true; + } + else + { + err.SetErrorString("'this' is not in memory; LLDB must be extended to handle registers"); + return false; + } +} + +bool ClangExpressionDeclMap::Dematerialize (ExecutionContext *exe_ctx, ClangExpressionVariable *&result, Error &err) @@ -763,24 +835,54 @@ const char *name) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - - const char* override_name = NULL; - - if (!strcmp(name, "___clang_this")) - override_name = "this"; - if (!strcmp(name, "___clang_self")) - override_name = "self"; - - const char *search_name = (override_name ? override_name : name); - + if (log) - log->Printf("Hunting for a definition for %s", search_name); + log->Printf("Hunting for a definition for %s", name); // Back out in all cases where we're not fully initialized if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) return; + + ConstString name_cs(name); + + if (!strcmp(name, "___clang_class")) + { + // Clang is looking for the type of "this" + + VariableList *vars = m_exe_ctx->frame->GetVariableList(false); + + if (!vars) + return; + + lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); + + if (!this_var) + return; + + Type *this_type = this_var->GetType(); + + if (!this_type) + return; + + TypeFromUser this_user_type(this_type->GetOpaqueClangQualType(), + this_type->GetClangAST()); + + m_object_pointer_type = this_user_type; + + void *pointer_target_type; + + if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(), + &pointer_target_type)) + return; + + TypeFromUser class_user_type(pointer_target_type, + this_type->GetClangAST()); + + AddOneType(context, class_user_type, true); + + return; + } - ConstString name_cs(search_name); SymbolContextList sym_ctxs; m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); @@ -813,10 +915,10 @@ } } - Variable *var = FindVariableInScope(*m_exe_ctx->frame, search_name); + Variable *var = FindVariableInScope(*m_exe_ctx->frame, name); if (var) - AddOneVariable(context, var, override_name); + AddOneVariable(context, var); ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); @@ -943,8 +1045,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, - Variable* var, - const char *override_name) + Variable* var) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -957,10 +1058,10 @@ &ut, &pt); - NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType(), override_name); + NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); - entity.m_name = (override_name ? override_name : context.Name.getAsString()); + entity.m_name = context.Name.getAsString(); entity.m_user_type = ut; entity.EnableParserVars(); @@ -1081,12 +1182,34 @@ void ClangExpressionDeclMap::AddOneType(NameSearchContext &context, - Type *type) + TypeFromUser &ut, + bool add_method) { - TypeFromUser ut(type->GetOpaqueClangQualType(), - type->GetClangAST()); + clang::ASTContext *parser_ast_context = context.GetASTContext(); + clang::ASTContext *user_ast_context = ut.GetASTContext(); + + void *copied_type = ClangASTContext::CopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); + + TypeFromParser parser_type(copied_type, parser_ast_context); - void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), ut.GetASTContext(), ut.GetOpaqueQualType()); + if (add_method && ClangASTContext::IsAggregateType(copied_type)) + { + void *args[1]; + + args[0] = ClangASTContext::GetVoidPtrType(parser_ast_context, false); + + void *method_type = ClangASTContext::CreateFunctionType (parser_ast_context, + ClangASTContext::GetBuiltInType_void(parser_ast_context), + args, + 1, + false, + ClangASTContext::GetTypeQualifiers(copied_type)); + + ClangASTContext::AddMethodToCXXRecordType(parser_ast_context, + copied_type, + "___clang_expr", + method_type); + } context.AddTypeDecl(copied_type); } Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Mon Sep 20 19:44:12 2010 @@ -326,6 +326,24 @@ return num_errors; } +static bool FindFunctionInModule (std::string &mangled_name, + llvm::Module *module, + const char *orig_name) +{ + for (llvm::Module::iterator fi = module->getFunctionList().begin(), fe = module->getFunctionList().end(); + fi != fe; + ++fi) + { + if (fi->getName().str().find(orig_name) != std::string::npos) + { + mangled_name = fi->getName().str(); + return true; + } + } + + return false; +} + Error ClangExpressionParser::MakeDWARF () { @@ -357,7 +375,16 @@ return err; } - IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream()); + std::string function_name; + + if (!FindFunctionInModule(function_name, module, m_expr.FunctionName())) + { + err.SetErrorToGenericError(); + err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName()); + return err; + } + + IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream(), function_name.c_str()); if (!ir_to_dwarf.runOnModule(*module)) { @@ -375,6 +402,8 @@ lldb::addr_t &func_end, ExecutionContext &exe_ctx) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + Error err; llvm::Module *module = m_code_generator->ReleaseModule(); @@ -386,6 +415,22 @@ return err; } + // Find the actual name of the function (it's often mangled somehow) + + std::string function_name; + + if (!FindFunctionInModule(function_name, module, m_expr.FunctionName())) + { + err.SetErrorToGenericError(); + err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName()); + return err; + } + else + { + if(log) + log->Printf("Found function %s for %s", function_name.c_str(), m_expr.FunctionName()); + } + ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL if (decl_map) @@ -406,7 +451,7 @@ IRForTarget ir_for_target(decl_map, target_machine->getTargetData(), m_expr.NeedsVariableResolution(), - m_expr.FunctionName()); + function_name.c_str()); if (!ir_for_target.runOnModule(*module)) { @@ -417,7 +462,7 @@ if (m_expr.NeedsValidation()) { - IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), m_expr.FunctionName()); + IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str()); if (!ir_dynamic_checks.runOnModule(*module)) { @@ -448,7 +493,7 @@ m_execution_engine->DisableLazyCompilation(); - llvm::Function *function = module->getFunction (m_expr.FunctionName()); + llvm::Function *function = module->getFunction (function_name.c_str()); // We don't actually need the function pointer here, this just forces it to get resolved. @@ -463,7 +508,7 @@ return err; } - m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(m_expr.FunctionName(), (lldb::addr_t)fun_ptr)); + m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr)); ExecutionContext &exc_context(exe_ctx); @@ -525,7 +570,7 @@ { (*pos).m_remote_addr = m_jit_mm->GetRemoteAddressForLocal ((*pos).m_local_addr); - if (!(*pos).m_name.compare(m_expr.FunctionName())) + if (!(*pos).m_name.compare(function_name.c_str())) { func_end = m_jit_mm->GetRemoteRangeForLocal ((*pos).m_local_addr).second; func_addr = (*pos).m_remote_addr; @@ -554,7 +599,7 @@ for (pos = m_jitted_functions.begin(); pos < end; pos++) { - if (strcmp(pos->m_name.c_str(), name) == 0) + if (strstr(pos->m_name.c_str(), name)) { func_local_addr = pos->m_local_addr; func_remote_addr = pos->m_remote_addr; Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Sep 20 19:44:12 2010 @@ -359,7 +359,7 @@ } ThreadPlan * -ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t func_addr, lldb::addr_t &args_addr, Stream &errors, bool stop_others, bool discard_on_error) +ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t func_addr, lldb::addr_t &args_addr, Stream &errors, bool stop_others, bool discard_on_error, lldb::addr_t *this_arg) { // FIXME: Use the errors Stream for better error reporting. @@ -377,7 +377,9 @@ ThreadPlan *new_plan = new ThreadPlanCallFunction (*exe_ctx.thread, wrapper_address, args_addr, - stop_others, discard_on_error); + stop_others, + discard_on_error, + this_arg); return new_plan; } @@ -456,7 +458,8 @@ bool stop_others, bool try_all_threads, uint32_t single_thread_timeout_usec, - Stream &errors) + Stream &errors, + lldb::addr_t *this_arg) { // Save this value for restoration of the execution context after we run uint32_t tid = exe_ctx.thread->GetIndexID(); @@ -480,7 +483,7 @@ ClangFunction::ExecutionResults return_value = eExecutionSetupError; - lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, errors, stop_others, false)); + lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, errors, stop_others, false, this_arg)); ThreadPlanCallFunction *call_plan_ptr = static_cast (call_plan_sp.get()); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Sep 20 19:44:12 2010 @@ -27,28 +27,21 @@ #include "lldb/Expression/ASTResultSynthesizer.h" #include "lldb/Expression/ClangUserExpression.h" #include "lldb/Host/Host.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" using namespace lldb_private; ClangUserExpression::ClangUserExpression (const char *expr) : m_expr_text(expr), - m_jit_addr(LLDB_INVALID_ADDRESS) + m_transformed_text(), + m_jit_addr(LLDB_INVALID_ADDRESS), + m_cplusplus(false), + m_objectivec(false), + m_needs_object_ptr(false) { - StreamString m_transformed_stream; - - m_transformed_stream.Printf("#define this ___clang_this \n" - "#define self ___clang_self \n" - "extern \"C\" void \n" - "%s(void *___clang_arg) \n" - "{ \n" - "%s; \n" - "} \n", - FunctionName(), - m_expr_text.c_str()); - - m_transformed_text = m_transformed_stream.GetData(); } ClangUserExpression::~ClangUserExpression () @@ -61,11 +54,65 @@ return new ASTResultSynthesizer(passthrough); } +void +ClangUserExpression::ScanContext(ExecutionContext &exe_ctx) +{ + if (!exe_ctx.frame) + return; + + VariableList *vars = exe_ctx.frame->GetVariableList(false); + + if (!vars) + return; + + if (vars->FindVariable(ConstString("this")).get()) + m_cplusplus = true; + else if (vars->FindVariable(ConstString("self")).get()) + m_objectivec = true; +} + bool ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + ScanContext(exe_ctx); + + StreamString m_transformed_stream; + + //////////////////////////////////// + // Generate the expression + // + + if (m_cplusplus) + { + m_transformed_stream.Printf("void \n" + "___clang_class::%s(void *___clang_arg) \n" + "{ \n" + " %s; \n" + "} \n", + FunctionName(), + m_expr_text.c_str()); + + m_needs_object_ptr = true; + } + else + { + m_transformed_stream.Printf("void \n" + "%s(void *___clang_arg) \n" + "{ \n" + " %s; \n" + "} \n", + FunctionName(), + m_expr_text.c_str()); + } + + m_transformed_text = m_transformed_stream.GetData(); + + + if (log) + log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); + //////////////////////////////////// // Set up the target and compiler // @@ -187,15 +234,27 @@ Error materialize_error; + lldb::addr_t object_ptr = NULL; + + if (m_needs_object_ptr && !(m_expr_decl_map->GetObjectPointer(object_ptr, &exe_ctx, materialize_error))) + { + error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); + return false; + } + if (!m_expr_decl_map->Materialize(&exe_ctx, struct_address, materialize_error)) { - error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString("unknown error")); + error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString()); return false; } if (log) { log->Printf("Function address : 0x%llx", (uint64_t)m_jit_addr); + + if (m_needs_object_ptr) + log->Printf("Object pointer : 0x%llx", (uint64_t)object_ptr); + log->Printf("Structure address : 0x%llx", (uint64_t)struct_address); StreamString args; @@ -216,7 +275,14 @@ } ClangFunction::ExecutionResults execution_result = - ClangFunction::ExecuteFunction (exe_ctx, m_jit_addr, struct_address, true, true, 10000, error_stream); + ClangFunction::ExecuteFunction (exe_ctx, + m_jit_addr, + struct_address, + true, + true, + 10000, + error_stream, + (m_needs_object_ptr ? &object_ptr : NULL)); if (execution_result != ClangFunction::eExecutionCompleted) { Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Mon Sep 20 19:44:12 2010 @@ -71,16 +71,36 @@ return true; // Find the result variable. If it doesn't exist, we can give up right here. - - Value *result_value = M.getNamedValue("___clang_expr_result"); - if (!result_value) + ValueSymbolTable& value_symbol_table = M.getValueSymbolTable(); + + const char *result_name = NULL; + + for (ValueSymbolTable::iterator vi = value_symbol_table.begin(), ve = value_symbol_table.end(); + vi != ve; + ++vi) + { + if (strstr(vi->first(), "___clang_expr_result")) + result_name = vi->first(); + } + + if (!result_name) { if (log) log->PutCString("Couldn't find result variable"); - + return true; } + + Value *result_value = M.getNamedValue(result_name); + + if (!result_value) + { + if (log) + log->PutCString("Result variable had no data"); + + return false; + } if (log) log->Printf("Found result in the IR: %s", PrintValue(result_value, false).c_str()); @@ -935,6 +955,16 @@ Argument *argument = iter; + if (argument->getName().equals("this")) + { + ++iter; + + if (iter == F.getArgumentList().end()) + return false; + + argument = iter; + } + if (!argument->getName().equals("___clang_arg")) return false; 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=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Mon Sep 20 19:44:12 2010 @@ -57,7 +57,8 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg) const + lldb::addr_t arg, + lldb::addr_t *this_arg) const { RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) @@ -70,9 +71,12 @@ 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 on the stack + // Make room for the argument(s) on the stack - sp -= 4; + if (this_arg) + sp -= 8; + else + sp -= 4; // Align the SP @@ -80,10 +84,25 @@ // Write the argument on the stack - uint32_t argU32 = arg & 0xffffffffull; Error error; - if (thread.GetProcess().WriteMemory (sp, &argU32, sizeof(argU32), error) != sizeof(argU32)) - return false; + + 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. 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=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Mon Sep 20 19:44:12 2010 @@ -34,7 +34,8 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg) const; + lldb::addr_t arg, + lldb::addr_t *this_arg) const; virtual bool PrepareNormalCall (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=114384&r1=114383&r2=114384&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 Mon Sep 20 19:44:12 2010 @@ -57,7 +57,8 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg) const + lldb::addr_t arg, + lldb::addr_t *this_arg) const { RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) @@ -74,9 +75,22 @@ uint32_t rspID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); // The argument is in %rdi, and not on the stack. - - if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, arg)) - return false; + + if (this_arg) + { + uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; + + if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg)) + return false; + + if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, arg)) + return false; + } + else + { + if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, arg)) + return false; + } // First, align the SP 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=114384&r1=114383&r2=114384&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 Mon Sep 20 19:44:12 2010 @@ -33,7 +33,8 @@ lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, - lldb::addr_t arg) const; + lldb::addr_t arg, + lldb::addr_t *this_arg) const; virtual bool PrepareNormalCall (Thread &thread, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Mon Sep 20 19:44:12 2010 @@ -807,12 +807,12 @@ ClangASTContext::AddMethodToCXXRecordType ( clang::ASTContext *ast_context, - void *record_clang_type, + void *record_opaque_type, const char *name, - void *method_type + void *method_opaque_type ) { - if (!record_clang_type || !method_type || !name) + if (!record_opaque_type || !method_opaque_type || !name) return false; assert(ast_context); @@ -821,7 +821,7 @@ assert(identifier_table); - QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type)); + QualType record_qual_type(QualType::getFromOpaquePtr(record_opaque_type)); clang::Type *record_type(record_qual_type.getTypePtr()); if (!record_type) @@ -842,13 +842,48 @@ if (!cxx_record_decl) return false; + QualType method_qual_type(QualType::getFromOpaquePtr(method_opaque_type)); + CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, cxx_record_decl, SourceLocation(), DeclarationName(&identifier_table->get(name)), - QualType::getFromOpaquePtr(method_type), + method_qual_type, NULL); + // Populate the method decl with parameter decls + + clang::Type *method_type(method_qual_type.getTypePtr()); + + if (!method_type) + return false; + + FunctionProtoType *method_funprototy(dyn_cast(method_type)); + + if (!method_funprototy) + return false; + + unsigned int num_params = method_funprototy->getNumArgs(); + + ParmVarDecl *params[num_params]; + + for (int param_index = 0; + param_index < num_params; + ++param_index) + { + params[param_index] = ParmVarDecl::Create(*ast_context, + cxx_method_decl, + SourceLocation(), + NULL, // anonymous + method_funprototy->getArgType(param_index), + NULL, + VarDecl::Auto, + VarDecl::Auto, + NULL); + } + + cxx_method_decl->setParams(params, num_params); + cxx_record_decl->addDecl(cxx_method_decl); return true; Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=114384&r1=114383&r2=114384&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Mon Sep 20 19:44:12 2010 @@ -34,7 +34,8 @@ Address &function, lldb::addr_t arg, bool stop_other_threads, - bool discard_on_error) : + bool discard_on_error, + lldb::addr_t *this_arg) : ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), @@ -43,7 +44,6 @@ m_process (thread.GetProcess()), m_thread (thread) { - SetOkayToDiscard (discard_on_error); Process& process = thread.GetProcess(); @@ -78,7 +78,8 @@ spBelowRedZone, FunctionLoadAddr, StartLoadAddr, - m_arg_addr)) + m_arg_addr, + this_arg)) return; m_valid = true; From johnny.chen at apple.com Tue Sep 21 14:12:39 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 19:12:39 -0000 Subject: [Lldb-commits] [lldb] r114466 - /lldb/trunk/test/persistent_variables/TestPersistentVariables.py Message-ID: <20100921191239.ED51E2A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 14:12:39 2010 New Revision: 114466 URL: http://llvm.org/viewvc/llvm-project?rev=114466&view=rev Log: Decorated PersistentVariablesTestCase.test_persistent_variables() with @expectedFailure as of r114384. Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=114466&r1=114465&r2=114466&view=diff ============================================================================== --- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Tue Sep 21 14:12:39 2010 @@ -11,6 +11,8 @@ mydir = "persistent_variables" + @unittest2.expectedFailure + # Fails as of r114384. def test_persistent_variables(self): """Test that lldb persistent variables works correctly.""" self.buildDefault() From ctice at apple.com Tue Sep 21 14:25:28 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 21 Sep 2010 19:25:28 -0000 Subject: [Lldb-commits] [lldb] r114467 - in /lldb/trunk/source: Commands/CommandObjectBreakpointCommand.cpp Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100921192528.322472A6C12C@llvm.org> Author: ctice Date: Tue Sep 21 14:25:28 2010 New Revision: 114467 URL: http://llvm.org/viewvc/llvm-project?rev=114467&view=rev Log: Re-write/clean up code that generated Python breakpoint commands. Add a warning if no command was attached to the breakpoint. Update the help slightly. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=114467&r1=114466&r2=114467&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Sep 21 14:25:28 2010 @@ -225,6 +225,11 @@ \n\ (lldb) \n\ \n\ + \n\ +Final Note: If you get a warning that no breakpoint command was generated, \n\ +but you did not get any syntax errors, you probably forgot to add a call \n\ +to your functions. \n\ + \n\ Special information about debugger command breakpoint commands \n\ -------------------------------------------------------------- \n\ \n\ Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114467&r1=114466&r2=114467&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 21 14:25:28 2010 @@ -626,6 +626,8 @@ bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); } } + else + ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n"); } else { @@ -714,150 +716,193 @@ ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user_input, StringList &callback_data) { static int num_created_functions = 0; - user_input.RemoveBlankLines (); int num_lines = user_input.GetSize(); - std::string last_function_call; - - // Go through lines of input looking for any function definitions. For each function definition found, - // export the function definition to Python, create a potential function call for the function, and - // mark the lines of the function to be removed from the user input. - for (int i = 0; i < num_lines; ++i) + if (num_lines == 1) { - int function_start = i; - std::string current_str = user_input.GetStringAtIndex (i); - const char *current_line = current_str.c_str(); - int len = 0; - if (current_line) - len = strlen (current_line); + callback_data.AppendString (user_input.GetStringAtIndex (0)); + return true; + } - // Check to see if the current line is the start of a Python function definition. - if (len > 4 && strncmp (current_line, "def ", 4) == 0) - { - // We've found the first line of a function. First, get the function name. + // Traverse user_input exactly once. At each line, either copy line into new, auto-generated function, + // increasing indentation by 5 spaces... ...or copy it exactly as is into the user-written + // currently-to-be-pushed-to-Python function def. At the end of each Python function def, push the function + // to Python, and clear the function string, to start again. At the end of it all, if there is anything in + // the auto-generated function, push it to Python and add the function call to it to the callback data. + + bool inside_user_python_function_def = false; + std::string whitespace = " \t"; - // Skip over the 'def '. - char *start = (char *) current_line + 4; + StringList auto_generated_function; + StringList user_defined_function; - // Skip over white space. - while (start[0] == ' ' || start[0] == '\t') - ++start; - - // Find the end of the function name. - char *end = start; - while (isalnum (end[0]) || end[0] == '_') - ++end; - - int name_len = end - start; - std::string func_name = current_str.substr (4, name_len); - - // Now to find the last line of the function. That will be the first line that does not begin with - // any white space (thanks to Python's indentation rules). - ++i; - bool found = false; - while (i < num_lines && !found) + StringList *current_function_def = &auto_generated_function; + std::string auto_generated_function_name ("lldb_autogen_python_bp_callback_func_"); + + for (int i = 0; i < num_lines; ++i) + { + std::string current_line (user_input.GetStringAtIndex(i)); + size_t idx = current_line.find_first_of (whitespace); + if (idx != std::string::npos) + { + if (idx == 0) // line starts with indentation... { - std::string next_str = user_input.GetStringAtIndex (i); - const char *next_line = next_str.c_str(); - if (next_line[0] != ' ' && next_line[0] != '\t') - found = true; + if (inside_user_python_function_def) + { + // Add this line to the user's python function definition. + current_function_def->AppendString (current_line.c_str()); + } else - ++i; + { + // Add this line to our auto-generated function; increase original indentation by 5. + StreamString tmp_str; + tmp_str.Printf (" %s", current_line.c_str()); + current_function_def->AppendString (tmp_str.GetData()); + } } - if (found) - --i; // Make 'i' correspond to the last line of the function. - int function_end = i; - - // Special case: All of user_input is one big function definition. - if ((function_start == 0) && (function_end == (num_lines - 1))) + else // line does not start with indentation... { - ExportFunctionDefinitionToInterpreter (user_input); - last_function_call = func_name + " ()"; - callback_data.AppendString (last_function_call.c_str()); - return callback_data.GetSize() > 0; - } - else - { - // Make a copy of the function definition: - StringList new_function; - for (int k = function_start; k <= function_end; ++k) + // First, check to see if we just finished a user-written function definition; if so, + // wrap it up and send it to Python. + + if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) { - new_function.AppendString (user_input.GetStringAtIndex (k)); - // Mark the string to be deleted from user_input. - user_input.DeleteStringAtIndex (k); - user_input.InsertStringAtIndex (k, ""); + if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) + { + // User entered incorrect Python syntax. We should not attempt to continue. + // Clear the callback data, and return immediately. + callback_data.Clear(); + return false; + } + + // User defined function was successfully sent to Python. Clean up after it. + user_defined_function.Clear(); + inside_user_python_function_def = false; + current_function_def = &auto_generated_function; } - ExportFunctionDefinitionToInterpreter (new_function); - last_function_call = func_name + " ()"; - } + + // Next, check to see if we are at the start of a user-defined Python function. + std::string first_word = current_line.substr (0, idx); + if (first_word.compare ("def") == 0) + { + // Start the user defined function properly: + inside_user_python_function_def = true; + current_function_def = &user_defined_function; + current_function_def->AppendString (current_line.c_str()); + } + else + { + // We are in "loose" Python code that we need to collect and put into the auto-generated + // function. + StreamString tmp_str; + current_function_def = &auto_generated_function; + if (current_function_def->GetSize() == 0) + { + // Create the function name, and add insert the function def line. + tmp_str.Printf ("%d", num_created_functions); + ++num_created_functions; + auto_generated_function_name.append (tmp_str.GetData()); + + tmp_str.Clear(); + tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); + current_function_def->AppendString (tmp_str.GetData()); + } + tmp_str.Clear(); + + // Indent the line an extra 5 spaces and add it to our auto-generated function. + tmp_str.Printf (" %s", current_line.c_str()); + current_function_def->AppendString (tmp_str.GetData()); + } // else we are in loose Python code + } // else current line does not start with indentatin } - } + else + { + // There was no white space on the line (and therefore no indentation either). - // Now instead of trying to really delete the marked lines from user_input, we will just copy all the - // unmarked lines into a new StringList. + // First, check to see if we just finished a user-written function definition; if so, + // wrap it up and send it to Python. + + if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) + { + if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) + { + // User entered incorrect Python syntax. We should not attempt to continue. + // Clear the callback data, and return immediately. + callback_data.Clear(); + return false; + } + + // User defined function was successfully sent to Python. Clean up after it. + user_defined_function.Clear(); + inside_user_python_function_def = false; + current_function_def = &auto_generated_function; + } + + // We cannot be at the start of a function definition (they contain white space) so we + // must have "loose" python code. + + StreamString tmp_str; + current_function_def = &auto_generated_function; + if (current_function_def->GetSize() == 0) + { + // Create the function name, and add insert the function def line. + tmp_str.Printf ("%d", num_created_functions); + ++num_created_functions; + auto_generated_function_name.append (tmp_str.GetData()); + + tmp_str.Clear(); + tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); + current_function_def->AppendString (tmp_str.GetData()); + } + tmp_str.Clear(); + + // Indent the line an extra 5 spaces and add it to our auto-generated function. + tmp_str.Printf (" %s", current_line.c_str()); + current_function_def->AppendString (tmp_str.GetData()); + + } // else there was no white space on the line. + } - StringList new_user_input; + // Perhaps the last line of input was also the last line of a user-defined function; if so, + // attempt to push the function down to Python. - for (int i = 0; i < num_lines; ++i) + if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) { - std::string current_string = user_input.GetStringAtIndex (i); - if (current_string.compare (0, 13, "") == 0) - continue; - - new_user_input.AppendString (current_string.c_str()); + if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) + { + callback_data.Clear(); + return false; + } } - num_lines = new_user_input.GetSize(); - if (num_lines > 0) + if (auto_generated_function.GetSize() > 0) { - if (num_lines == 1 - && strchr (new_user_input.GetStringAtIndex(0), '\n') == NULL) + // Export the auto-generated function to Python. + if (ExportFunctionDefinitionToInterpreter (auto_generated_function)) { - // If there's only one line of input, and it doesn't contain any newline characters.... - callback_data.AppendString (new_user_input.GetStringAtIndex (0)); + // The export succeeded; the syntax must be ok. Generate the function call and put + // it in the callback data. + StreamString tmp_str; + tmp_str.Printf ("%s ()", auto_generated_function_name.c_str()); + callback_data.AppendString (tmp_str.GetData()); + return true; } else { - // Create the new function name. - StreamString func_name; - func_name.Printf ("lldb_bp_callback_func_%d", num_created_functions); - //std::string func_name = "lldb_bp_callback_func_" + num_created_functions; - ++num_created_functions; - - // Create the function call for the new function. - last_function_call = func_name.GetString() + " ()"; - - // Create the Python function definition line (which will have to be inserted at the beginning of - // the function). - std::string def_line = "def " + func_name.GetString() + " ():"; - - - // Indent all lines an additional four spaces (as they are now being put inside a function definition). - for (int i = 0; i < num_lines; ++i) - { - const char *temp_cstring = new_user_input.GetStringAtIndex(i); - std::string temp2 = " "; - temp2.append(temp_cstring); - new_user_input.DeleteStringAtIndex (i); - new_user_input.InsertStringAtIndex (i, temp2.c_str()); - } - - // Insert the function definition line at the top of the new function. - new_user_input.InsertStringAtIndex (0, def_line.c_str()); - - ExportFunctionDefinitionToInterpreter (new_user_input); - callback_data.AppendString (last_function_call.c_str()); + // Syntax error! + callback_data.Clear(); + return false; } } else { - if (!last_function_call.empty()) - callback_data.AppendString (last_function_call.c_str()); + // If there was any code, it consisted entirely of function defs, without any calls to the functions. + // No actual exectuable code was therefore generated. (Function calls would have looked like "loose" python, + // and would have been collected into the auto-generated function.) + return false; } - - return callback_data.GetSize() > 0; } bool @@ -881,8 +926,8 @@ bool success = context->exe_ctx.target->GetDebugger(). GetCommandInterpreter(). GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, - ScriptInterpreter::eBool, - (void *) &temp_bool); + ScriptInterpreter::eBool, + (void *) &temp_bool); if (success) ret_value = temp_bool; } From johnny.chen at apple.com Tue Sep 21 16:08:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 21:08:54 -0000 Subject: [Lldb-commits] [lldb] r114480 - in /lldb/trunk/test: breakpoint_command/ breakpoint_command/Makefile breakpoint_command/TestBreakpointCommand.py breakpoint_command/main.c lldbtest.py Message-ID: <20100921210854.343922A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 16:08:53 2010 New Revision: 114480 URL: http://llvm.org/viewvc/llvm-project?rev=114480&view=rev Log: Added a more complex test case of breakpoint commands, which executes a sequence of 'breakpoint command add/list/remove' commands to set breakpoint callbacks, list them, and then remove one. Modified the lldbtest.TestBase.expect() method to add two additional keyword arguments: o matching (default to True), which, if set to False, reverses the semantics of 'expect' to 'expect not' o patterns (default to None), which specifies a list of regexp patterns to match against the output from running the command TestBreakpointCommand.py uses the matching=False and the patterns=[...] expect() API. Added: lldb/trunk/test/breakpoint_command/ lldb/trunk/test/breakpoint_command/Makefile lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py lldb/trunk/test/breakpoint_command/main.c Modified: lldb/trunk/test/lldbtest.py Added: lldb/trunk/test/breakpoint_command/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/Makefile?rev=114480&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_command/Makefile (added) +++ lldb/trunk/test/breakpoint_command/Makefile Tue Sep 21 16:08:53 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=114480&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (added) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Tue Sep 21 16:08:53 2010 @@ -0,0 +1,115 @@ +""" +Test lldb breakpoint command add/list/remove. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class BreakpointCommandTestCase(TestBase): + + mydir = "breakpoint_command" + + @classmethod + def classCleanup(cls): + system(["/bin/sh", "-c", "rm output.txt"]) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test a sequence of breakpoint command add, list, and remove.""" + self.buildDsym() + self.breakpoint_command_sequence() + + def test_with_dwarf(self): + """Test a sequence of breakpoint command add, list, and remove.""" + self.buildDwarf() + self.breakpoint_command_sequence() + + def breakpoint_command_sequence(self): + """Test a sequence of breakpoint command add, list, and remove.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Add two breakpoints on the same line. + self.expect("breakpoint set -f main.c -l 12", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = 12, locations = 1") + self.expect("breakpoint set -f main.c -l 12", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: file ='main.c', line = 12, locations = 1") + + # Now add callbacks for the breakpoints just created. + self.runCmd("breakpoint command add -c -o 'frame variable -s' 1") + self.runCmd("breakpoint command add -p -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") + + # Check that the breakpoint commands are correctly set. + + # The breakpoint list now only contains breakpoint 1. + self.expect("breakpoint list", "Breakpoints 1 & 2 created", + substrs = ["1: file ='main.c', line = 12, locations = 1", + "2: file ='main.c', line = 12, locations = 1"], + patterns = ["1.1: .+at main.c:12, .+unresolved, hit count = 0", + "2.1: .+at main.c:12, .+unresolved, hit count = 0"]) + + self.expect("breakpoint command list 1", "Breakpoint 1 command ok", + substrs = ["Breakpoint commands:", + "frame variable -s"]) + self.expect("breakpoint command list 2", "Breakpoint 2 command ok", + substrs = ["Breakpoint commands:", + "here = open", + "print >> here", + "here.close()"]) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # Check that the file 'output.txt' exists and contains the string "lldb". + + # Read the output file produced by running the program. + output = open('output.txt', 'r').read() + + self.assertTrue(output.startswith("lldb"), + "File 'output.txt' and the content matches") + + # Finish the program. + self.runCmd("process continue") + + # Remove the breakpoint command associated with breakpoint 1. + self.runCmd("breakpoint command remove 1") + + # Remove breakpoint 2. + self.runCmd("breakpoint delete 2") + + self.expect("breakpoint command list 1", + startstr = "Breakpoint 1 does not have an associated command.") + self.expect("breakpoint command list 2", error=True, + startstr = "error: '2' is not a currently valid breakpoint id.") + + # The breakpoint list now only contains breakpoint 1. + self.expect("breakpoint list", "Breakpoint 1 exists", + substrs = ["1: file ='main.c', line = 12, locations = 1, resolved = 1", + "hit count = 1"]) + + # Not breakpoint 2. + self.expect("breakpoint list", "No more breakpoint 2", matching=False, + substrs = ["2: file ='main.c', line = 12, locations = 1, resolved = 1"]) + + # Run the program again, with breakpoint 1 remaining. + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped again due to breakpoint 1. + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 2. + self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, + substrs = ['resolved, hit count = 2']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/breakpoint_command/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/main.c?rev=114480&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_command/main.c (added) +++ lldb/trunk/test/breakpoint_command/main.c Tue Sep 21 16:08:53 2010 @@ -0,0 +1,13 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main (int argc, char const *argv[]) +{ + return 0; +} Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114480&r1=114479&r2=114480&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 21 16:08:53 2010 @@ -97,6 +97,7 @@ """ import os, sys +import re from subprocess import * import time import types @@ -399,19 +400,24 @@ self.assertTrue(self.res.Succeeded(), msg if msg else CMD_MSG(cmd)) - def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False, error=False): + def expect(self, cmd, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True): """ Similar to runCmd; with additional expect style output matching ability. Ask the command interpreter to handle the command and then check its return status. The 'msg' parameter specifies an informational assert message. We expect the output from running the command to start with - 'startstr' and matches the substrings contained in 'substrs'. + 'startstr', matches the substrings contained in 'substrs', and regexp + matches the patterns contained in 'patterns'. If the keyword argument error is set to True, it signifies that the API client is expecting the command to fail. In this case, the error stream from running the command is retrieved and compared against the golden input, instead. + + If the keyword argument matching is set to False, it signifies that the API + client is expecting the output of the command not to match the golden + input. """ trace = (True if traceAlways else trace) @@ -426,25 +432,50 @@ self.assertFalse(self.res.Succeeded(), "Command '" + cmd + "' is expected to fail!") - matched = output.startswith(startstr) if startstr else True + # The heading says either "Expecting" or "Not expecting". + if trace: + heading = "Expecting" if matching else "Not expecting" + + # Start from the startstr, if specified. + # If there's no startstr, set the initial state appropriately. + matched = output.startswith(startstr) if startstr else (True if matching else False) if startstr and trace: - print >> sys.stderr, "Expecting start string:", startstr + print >> sys.stderr, "%s start string: %s" % (heading, startstr) print >> sys.stderr, "Matched" if matched else "Not matched" print >> sys.stderr - if substrs and matched: + # Look for sub strings, if specified. + keepgoing = matched if matching else not matched + if substrs and keepgoing: for str in substrs: matched = output.find(str) > 0 if trace: - print >> sys.stderr, "Expecting sub string:", str + print >> sys.stderr, "%s sub string: %s" % (heading, str) + print >> sys.stderr, "Matched" if matched else "Not matched" + keepgoing = matched if matching else not matched + if not keepgoing: + break + if trace: + print >> sys.stderr + + # Search for regular expression patterns, if specified. + keepgoing = matched if matching else not matched + if patterns and keepgoing: + for pattern in patterns: + # Match Objects always have a boolean value of True. + matched = bool(re.search(pattern, output)) + if trace: + print >> sys.stderr, "%s pattern: %s" % (heading, pattern) print >> sys.stderr, "Matched" if matched else "Not matched" - if not matched: + keepgoing = matched if matching else not matched + if not keepgoing: break if trace: print >> sys.stderr - self.assertTrue(matched, msg if msg else CMD_MSG(cmd)) + self.assertTrue(matched if matching else not matched, + msg if msg else CMD_MSG(cmd)) def invoke(self, obj, name, trace=False): """Use reflection to call a method dynamically with no argument.""" From gclayton at apple.com Tue Sep 21 16:22:23 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 21 Sep 2010 21:22:23 -0000 Subject: [Lldb-commits] [lldb] r114484 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20100921212223.93C3D2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 21 16:22:23 2010 New Revision: 114484 URL: http://llvm.org/viewvc/llvm-project?rev=114484&view=rev Log: Fixed an issue with the clang type creation code for C++ classes where we wouldn't set a CXXRecordDecl to be NOT empty if we had base classes that were not empty or had virtual functions. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114484&r1=114483&r2=114484&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 21 16:22:23 2010 @@ -1093,8 +1093,33 @@ CXXRecordDecl *cxx_record_decl = dyn_cast(record_type->getDecl()); if (cxx_record_decl) { - //cxx_record_decl->setEmpty (false); cxx_record_decl->setBases(base_classes, num_base_classes); + + if (cxx_record_decl->isEmpty()) + { + // set empty to false if any bases are virtual, or not empty. + + CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); + base_class != base_class_end; + ++base_class) + { + if (base_class->isVirtual()) + { + cxx_record_decl->setEmpty (false); + break; + } + else + { + const CXXRecordDecl *base_class_decl = cast(base_class->getType()->getAs()->getDecl()); + if (!base_class_decl->isEmpty()) + { + cxx_record_decl->setEmpty (false); + break; + } + } + } + } return true; } } From johnny.chen at apple.com Tue Sep 21 17:34:45 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 22:34:45 -0000 Subject: [Lldb-commits] [lldb] r114493 - in /lldb/trunk/test: conditional_break/TestConditionalBreak.py conditional_break/conditional_break.py lldbtest.py Message-ID: <20100921223445.DA5A92A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 17:34:45 2010 New Revision: 114493 URL: http://llvm.org/viewvc/llvm-project?rev=114493&view=rev Log: Wrapped the subclass-specific cleanup call within a try:except: clause. And removed the informational output from the conditional_break test case. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/conditional_break/conditional_break.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=114493&r1=114492&r2=114493&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Tue Sep 21 17:34:45 2010 @@ -57,7 +57,7 @@ process = target.GetProcess() thread = process.GetThreadAtIndex(0) import lldbutil - lldbutil.PrintStackTrace(thread) + #lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) Modified: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=114493&r1=114492&r2=114493&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (original) +++ lldb/trunk/test/conditional_break/conditional_break.py Tue Sep 21 17:34:45 2010 @@ -24,15 +24,16 @@ # of the leaf function c() is a(). If it's not the right caller, we ask the # command interpreter to continue execution. - print >> sys.stdout, "Checking call frames..." - lldbutil.PrintStackTrace(thread) + #print >> sys.stdout, "Checking call frames..." + #lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: funcs = lldbutil.GetFunctionNames(thread) - print >> sys.stdout, funcs[0], "called from", funcs[1] + #print >> sys.stdout, funcs[0], "called from", funcs[1] if (funcs[0] == 'c' and funcs[1] == 'a'): - print >> sys.stdout, "Stopped at c() with immediate caller as a()." + #print >> sys.stdout, "Stopped at c() with immediate caller as a()." + pass else: - print >> sys.stdout, "Continuing..." + #print >> sys.stdout, "Continuing..." ci.HandleCommand("process continue", res) return True Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114493&r1=114492&r2=114493&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 21 17:34:45 2010 @@ -96,7 +96,7 @@ $ """ -import os, sys +import os, sys, traceback import re from subprocess import * import time @@ -305,7 +305,11 @@ if getattr(cls, "classCleanup", None): if traceAlways: print "Call class-specific cleanup function for class:", cls - cls.classCleanup() + try: + cls.classCleanup() + except: + exc_type, exc_value, exc_tb = sys.exc_info() + traceback.print_exception(exc_type, exc_value, exc_tb) # Restore old working directory. if traceAlways: From ctice at apple.com Tue Sep 21 18:25:40 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 21 Sep 2010 23:25:40 -0000 Subject: [Lldb-commits] [lldb] r114499 - in /lldb/trunk/source: Commands/CommandObjectBreakpointCommand.cpp Commands/CommandObjectCommands.cpp Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100921232540.422762A6C12C@llvm.org> Author: ctice Date: Tue Sep 21 18:25:40 2010 New Revision: 114499 URL: http://llvm.org/viewvc/llvm-project?rev=114499&view=rev Log: Update help text for breakpoint command one-liners. Fix minor bug in 'commands alias'; alias commands can now handle command options and arguments in the same alias. Also fixes problem that disallowed "process launch --" as an alias. Fix typo in comment in Python script interpreter. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=114499&r1=114498&r2=114499&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Sep 21 18:25:40 2010 @@ -49,7 +49,7 @@ CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, 0, "", - "Specify a one-liner inline." }, + "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, { LLDB_OPT_SET_1, true, "script", 's', no_argument, NULL, 0, NULL, "Write the breakpoint command script in the default scripting language."}, Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=114499&r1=114498&r2=114499&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Sep 21 18:25:40 2010 @@ -207,7 +207,7 @@ CommandReturnObject &result ) { - const size_t argc = args.GetArgumentCount(); + size_t argc = args.GetArgumentCount(); if (argc < 2) { @@ -296,15 +296,18 @@ args.Shift (); if (result.Succeeded()) options->VerifyPartialOptions (result); - if (!result.Succeeded()) - return false; - } - else - { - for (size_t i = 0; i < argc; ++i) - option_arg_vector->push_back (OptionArgPair ("", - std::string (args.GetArgumentAtIndex (i)))); + if (!result.Succeeded() && result.GetStatus() != lldb::eReturnStatusStarted) + { + result.AppendError ("Unable to create requested command alias.\n"); + } } + + // Anything remaining in args must be a plain argument. + + argc = args.GetArgumentCount(); + for (size_t i = 0; i < argc; ++i) + option_arg_vector->push_back (OptionArgPair ("", + std::string (args.GetArgumentAtIndex (i)))); } // Create the alias. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114499&r1=114498&r2=114499&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 21 18:25:40 2010 @@ -726,7 +726,7 @@ } // Traverse user_input exactly once. At each line, either copy line into new, auto-generated function, - // increasing indentation by 5 spaces... ...or copy it exactly as is into the user-written + // increasing indentation by 5 spaces or copy it exactly as is into the user-written // currently-to-be-pushed-to-Python function def. At the end of each Python function def, push the function // to Python, and clear the function string, to start again. At the end of it all, if there is anything in // the auto-generated function, push it to Python and add the function call to it to the callback data. From johnny.chen at apple.com Tue Sep 21 18:33:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 23:33:30 -0000 Subject: [Lldb-commits] [lldb] r114501 - in /lldb/trunk/test: array_types/TestArrayTypes.py lldbtest.py Message-ID: <20100921233330.8BC002A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 18:33:30 2010 New Revision: 114501 URL: http://llvm.org/viewvc/llvm-project?rev=114501&view=rev Log: Added a subtest to exercise the capability of lldb Python objects to print themselves. Right now, it tests a breakpoint both before and after it has been resolved. Updated lldbtest.TestBase.expect() with an additional keyword argument 'exe' ( default to True), which if set to False, will treat the mandatory first argument as just the string to be matched/or not-matched against the golden input. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=114501&r1=114500&r2=114501&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Sep 21 18:33:30 2010 @@ -84,6 +84,14 @@ breakpoint = target.BreakpointCreateByLocation("main.c", 42) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + bp = repr(breakpoint) + self.expect(bp, msg="Breakpoint looks good", exe=False, + substrs = ["file ='main.c'", + "line = 42", + "locations = 1"]) + self.expect(bp, msg="Breakpoint is not resolved as yet", exe=False, matching=False, + substrs = ["resolved = 1"]) + self.runCmd("run", RUN_SUCCEEDED, setCookie=False) # This does not work, and results in the process stopped at dyld_start? #process = target.LaunchProcess([''], [''], os.ctermid(), False) @@ -91,17 +99,34 @@ self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + #procRepr = repr(self.process) + #print "procRepr:", procRepr + # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), STOPPED_DUE_TO_BREAKPOINT) + #threadRepr = repr(thread) + #print "threadRepr:", threadRepr + # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + bp = repr(breakpoint) + self.expect(bp, "Breakpoint looks good and is resolved", exe=False, + substrs = ["file ='main.c'", + "line = 42", + "locations = 1", + "resolved = 1"]) + # Lookup the "strings" string array variable. frame = thread.GetFrameAtIndex(0) + #frameRepr = repr(frame) + #print "frameRepr:", frameRepr variable = frame.LookupVar("strings") + #varRepr = repr(variable) + #print "varRepr:", varRepr self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 4, "Variable 'strings' should have 4 children") Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114501&r1=114500&r2=114501&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 21 18:33:30 2010 @@ -152,8 +152,11 @@ # # And a generic "Command '%s' returns successfully" message generator. # -def CMD_MSG(command): - return "Command '%s' returns successfully" % (command) +def CMD_MSG(str, exe): + if exe: + return "Command '%s' returns successfully" % str + else: + return "'%s' compares successfully" % str # # Returns the enum from the input string. @@ -402,9 +405,9 @@ if check: self.assertTrue(self.res.Succeeded(), - msg if msg else CMD_MSG(cmd)) + msg if msg else CMD_MSG(cmd, True)) - def expect(self, cmd, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True): + def expect(self, str, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True, exe=True): """ Similar to runCmd; with additional expect style output matching ability. @@ -422,19 +425,30 @@ If the keyword argument matching is set to False, it signifies that the API client is expecting the output of the command not to match the golden input. + + Finally, the required argument 'str' represents the lldb command to be + sent to the command interpreter. In case the keyword argument 'exe' is + set to False, the 'str' is treated as a string to be matched/not-matched + against the golden input. """ trace = (True if traceAlways else trace) - # First run the command. If we are expecting error, set check=False. - self.runCmd(cmd, trace = (True if trace else False), check = not error) - - # Then compare the output against expected strings. - output = self.res.GetError() if error else self.res.GetOutput() - - # If error is True, the API client expects the command to fail! - if error: - self.assertFalse(self.res.Succeeded(), - "Command '" + cmd + "' is expected to fail!") + if exe: + # First run the command. If we are expecting error, set check=False. + self.runCmd(str, trace = (True if trace else False), check = not error) + + # Then compare the output against expected strings. + output = self.res.GetError() if error else self.res.GetOutput() + + # If error is True, the API client expects the command to fail! + if error: + self.assertFalse(self.res.Succeeded(), + "Command '" + str + "' is expected to fail!") + else: + # No execution required, just compare str against the golden input. + output = str + if trace: + print >> sys.stderr, "look at:", output # The heading says either "Expecting" or "Not expecting". if trace: @@ -479,7 +493,7 @@ print >> sys.stderr self.assertTrue(matched if matching else not matched, - msg if msg else CMD_MSG(cmd)) + msg if msg else CMD_MSG(str, exe)) def invoke(self, obj, name, trace=False): """Use reflection to call a method dynamically with no argument.""" From johnny.chen at apple.com Tue Sep 21 18:47:01 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Sep 2010 23:47:01 -0000 Subject: [Lldb-commits] [lldb] r114505 - /lldb/trunk/test/lldbtest.py Message-ID: <20100921234701.CCCC62A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 18:47:01 2010 New Revision: 114505 URL: http://llvm.org/viewvc/llvm-project?rev=114505&view=rev Log: Trivial change of a trace output string. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114505&r1=114504&r2=114505&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 21 18:47:01 2010 @@ -448,7 +448,7 @@ # No execution required, just compare str against the golden input. output = str if trace: - print >> sys.stderr, "look at:", output + print >> sys.stderr, "looking at:", output # The heading says either "Expecting" or "Not expecting". if trace: From gclayton at apple.com Tue Sep 21 19:24:00 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 22 Sep 2010 00:24:00 -0000 Subject: [Lldb-commits] [lldb] r114511 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20100922002400.21F8A2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 21 19:23:59 2010 New Revision: 114511 URL: http://llvm.org/viewvc/llvm-project?rev=114511&view=rev Log: Fixed a build warning where no return values was being returned. 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=114511&r1=114510&r2=114511&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 21 19:23:59 2010 @@ -940,7 +940,9 @@ StringList &value, Error *err) { - // Currently 'target' does not have any instance settings. + if (err) + err->SetErrorString ("'target' does not have any instance settings"); + return false; } const ConstString From gclayton at apple.com Tue Sep 21 19:24:45 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 22 Sep 2010 00:24:45 -0000 Subject: [Lldb-commits] [lldb] r114512 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20100922002445.C18402A6C12C@llvm.org> Author: gclayton Date: Tue Sep 21 19:24:45 2010 New Revision: 114512 URL: http://llvm.org/viewvc/llvm-project?rev=114512&view=rev Log: Fixed CXXRecordDecl declaration settings for whether a class in a POD type or not. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114512&r1=114511&r2=114512&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 21 19:24:45 2010 @@ -943,7 +943,13 @@ if (field) { record_decl->addDecl(field); - return true; + + if (cxx_record_decl->isPOD()) + { + if (!field->getType()->isPODType()) + cxx_record_decl->setPOD (false); + return true; + } } } else @@ -1095,7 +1101,7 @@ { cxx_record_decl->setBases(base_classes, num_base_classes); - if (cxx_record_decl->isEmpty()) + if (cxx_record_decl->isEmpty() || cxx_record_decl->isPOD()) { // set empty to false if any bases are virtual, or not empty. @@ -1107,16 +1113,22 @@ if (base_class->isVirtual()) { cxx_record_decl->setEmpty (false); + cxx_record_decl->setPOD (false); break; } else { - const CXXRecordDecl *base_class_decl = cast(base_class->getType()->getAs()->getDecl()); - if (!base_class_decl->isEmpty()) - { + QualType base_type (base_class->getType()); + + if (!base_type->isPODType()) + cxx_record_decl->setPOD (false); + + const CXXRecordDecl *base_class_decl = cast(base_type->getAs()->getDecl()); + if (!base_class_decl->isEmpty()) + { cxx_record_decl->setEmpty (false); break; - } + } } } } From johnny.chen at apple.com Tue Sep 21 19:25:33 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Sep 2010 00:25:33 -0000 Subject: [Lldb-commits] [lldb] r114513 - /lldb/trunk/test/array_types/TestArrayTypes.py Message-ID: <20100922002533.3ABE82A6C12C@llvm.org> Author: johnny Date: Tue Sep 21 19:25:33 2010 New Revision: 114513 URL: http://llvm.org/viewvc/llvm-project?rev=114513&view=rev Log: Sanity check the print representation of lldb.SBProcess object. Modified: lldb/trunk/test/array_types/TestArrayTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=114513&r1=114512&r2=114513&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Sep 21 19:25:33 2010 @@ -84,6 +84,7 @@ breakpoint = target.BreakpointCreateByLocation("main.c", 42) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + # Sanity check the print representation of breakpoint. bp = repr(breakpoint) self.expect(bp, msg="Breakpoint looks good", exe=False, substrs = ["file ='main.c'", @@ -99,20 +100,24 @@ self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) - #procRepr = repr(self.process) - #print "procRepr:", procRepr + # Sanity check the print representation of process. + proc = repr(self.process) + self.expect(proc, msg="Process looks good", exe=False, + patterns = ["executable.+array_types.a\.out", + "instance name:.+state: Stopped"]) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), STOPPED_DUE_TO_BREAKPOINT) - #threadRepr = repr(thread) - #print "threadRepr:", threadRepr + #thr = repr(thread) + #print "thr:", thr # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + # The breakpoint should be resolved by now. bp = repr(breakpoint) self.expect(bp, "Breakpoint looks good and is resolved", exe=False, substrs = ["file ='main.c'", @@ -122,11 +127,11 @@ # Lookup the "strings" string array variable. frame = thread.GetFrameAtIndex(0) - #frameRepr = repr(frame) - #print "frameRepr:", frameRepr + #frm = repr(frame) + #print "frm:", frm variable = frame.LookupVar("strings") - #varRepr = repr(variable) - #print "varRepr:", varRepr + #var = repr(variable) + #print "var:", var self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 4, "Variable 'strings' should have 4 children") From scallanan at apple.com Tue Sep 21 19:33:31 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 22 Sep 2010 00:33:31 -0000 Subject: [Lldb-commits] [lldb] r114514 - /lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Message-ID: <20100922003331.2F3E22A6C12C@llvm.org> Author: spyffe Date: Tue Sep 21 19:33:31 2010 New Revision: 114514 URL: http://llvm.org/viewvc/llvm-project?rev=114514&view=rev Log: Improved the logging for ASTs generated on the expression parser's behalf so that now we see the full TranslationUnitDecl instead of just the FunctionDecl. Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=114514&r1=114513&r2=114514&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Tue Sep 21 19:33:31 2010 @@ -118,11 +118,11 @@ std::string s; raw_string_ostream os(s); - function_decl->print(os); + Ctx.getTranslationUnitDecl()->print(os); os.flush(); - log->Printf("Function AST before transforming:\n%s", s.c_str()); + log->Printf("AST context before transforming:\n%s", s.c_str()); } Stmt *function_body = function_decl->getBody(); From gclayton at apple.com Tue Sep 21 19:40:49 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 22 Sep 2010 00:40:49 -0000 Subject: [Lldb-commits] [lldb] r114516 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20100922004049.C212A2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 21 19:40:49 2010 New Revision: 114516 URL: http://llvm.org/viewvc/llvm-project?rev=114516&view=rev Log: Added some comments explaining why we currently have to manually set CXXRecordDecl variables. This is because SEMA is actually calling the accessors that should be built into the CXXRecordDecl class. We have an internal bug tracking this change and will remove the affected work around code when a solution is available. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114516&r1=114515&r2=114516&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 21 19:40:49 2010 @@ -921,7 +921,22 @@ CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); if (cxx_record_decl) + { + // NOTE: we currently have some fixes that should be placed + // into clang that will automatically set if a record is empty + // when each field is added (during the addDecl() method call + // below) so this code should be able to come out when those + // changes make it into llvm/clang, then we can remove this + // code... + // Currently SEMA is using the accessors manually to set + // whether a class is empty, is POD, is aggregate, and more. + // This code will be moved into CXXRecordDecl so everyone + // can benefit. + // This will currently work for everything except zero sized + // bitfields which we currently aren't detecting anyway from the + // DWARF so it should be ok for now. cxx_record_decl->setEmpty (false); + } clang::Expr *bit_width = NULL; if (bitfield_bit_size != 0) @@ -943,7 +958,18 @@ if (field) { record_decl->addDecl(field); - + + // NOTE: we currently have some fixes that should be placed + // into clang that will automatically set if a record is POD + // when each field is added (during the addDecl() method call + // above) so this code should be able to come out when those + // changes make it into llvm/clang, then we can remove this + // code... + // Currently SEMA is using the accessors manually to set + // whether a class is empty, is POD, is aggregate, and more. + // This code will be moved into CXXRecordDecl so everyone + // can benefit. + if (cxx_record_decl->isPOD()) { if (!field->getType()->isPODType()) @@ -1101,6 +1127,15 @@ { cxx_record_decl->setBases(base_classes, num_base_classes); + // NOTE: we currently have some fixes that should be placed + // into clang that will automatically set these things when + // they are added (during the setBases() method call above) + // so this code should be able to come out when those changes + // make it into llvm/clang, then we can remove this code... + // Currently SEMA is using the accessors manually to set + // whether a class is empty, is POD, is aggregate, and more. + // This code will be moved into CXXRecordDecl so everyone + // can benefit. if (cxx_record_decl->isEmpty() || cxx_record_decl->isPOD()) { // set empty to false if any bases are virtual, or not empty. From gclayton at apple.com Tue Sep 21 23:50:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 22 Sep 2010 04:50:38 -0000 Subject: [Lldb-commits] [lldb] r114530 - in /lldb/trunk/test/types: ./ Makefile basic_type.cpp int.cpp Message-ID: <20100922045038.BD4732A6C12E@llvm.org> Author: gclayton Date: Tue Sep 21 23:50:38 2010 New Revision: 114530 URL: http://llvm.org/viewvc/llvm-project?rev=114530&view=rev Log: Added the start of a test case that will test all basic types and all the variety of ways they can be displayed in variable views. Added: lldb/trunk/test/types/ lldb/trunk/test/types/Makefile lldb/trunk/test/types/basic_type.cpp lldb/trunk/test/types/int.cpp Added: lldb/trunk/test/types/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/Makefile?rev=114530&view=auto ============================================================================== --- lldb/trunk/test/types/Makefile (added) +++ lldb/trunk/test/types/Makefile Tue Sep 21 23:50:38 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +CXX_SOURCES := int.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=114530&view=auto ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (added) +++ lldb/trunk/test/types/basic_type.cpp Tue Sep 21 23:50:38 2010 @@ -0,0 +1,173 @@ +// This file must have the following defined before it is included: +// T defined to the type to test (int, float, etc) +// T_CSTR a C string representation of the type T ("int", "float") +// T_VALUE_1 defined to a valid initializer value for TEST_TYPE (7 for int, 2.0 for float) +// T_VALUE_2, T_VALUE_3, T_VALUE_4 defined to a valid initializer value for TEST_TYPE that is different from TEST_VALUE_1 +// T_PRINTF_FORMAT defined if T can be printed with printf +// +// An example for integers is below +#if 0 + +#define T int +#define T_CSTR "int" +#define T_VALUE_1 11001110 +#define T_VALUE_2 22002220 +#define T_VALUE_3 33003330 +#define T_VALUE_4 44044440 +#define T_PRINTF_FORMAT "%i" + +#include "basic_type.cpp" + +#endif + +class a_class +{ +public: + a_class (const T& a, const T& b) : + m_a (a), + m_b (b) + { + } + + ~a_class () + { + } + + const T& + get_a() + { + return m_a; + } + + void + set_a (const T& a) + { + m_a = a; + } + + const T& + get_b() + { + return m_b; + } + + void + set_b (const T& b) + { + m_b = b; + } + +protected: + T m_a; + T m_b; +}; + +typedef struct a_struct_tag { + T a; + T b; +} a_struct_t; + + +typedef union a_union_zero_tag { + T a; + double a_double; +} a_union_zero_t; + +typedef struct a_union_nonzero_tag { + double a_double; + a_union_zero_t u; +} a_union_nonzero_t; + + +#include +#include + +int +main (int argc, char const *argv[]) +{ + T a = T_VALUE_1; + T* a_ptr = &a; + T& a_ref = a; + T a_array_bounded[2] = { T_VALUE_1, T_VALUE_2 }; + T a_array_unbounded[] = { T_VALUE_1, T_VALUE_2 }; + + a_class a_class_instance (T_VALUE_1, T_VALUE_2); + a_class *a_class_ptr = &a_class_instance; + a_class &a_class_ref = a_class_instance; + + a_struct_t a_struct = { T_VALUE_1, T_VALUE_2 }; + a_struct_t *a_struct_ptr = &a_struct; + a_struct_t &a_struct_ref = a_struct; + + // Create a union with type T at offset zero + a_union_zero_t a_union_zero; + a_union_zero.a = T_VALUE_1; + a_union_zero_t *a_union_zero_ptr = &a_union_zero; + a_union_zero_t &a_union_zero_ref = a_union_zero; + + // Create a union with type T at a non-zero offset + a_union_nonzero_t a_union_nonzero; + a_union_nonzero.u.a = T_VALUE_1; + a_union_nonzero_t *a_union_nonzero_ptr = &a_union_nonzero; + a_union_nonzero_t &a_union_nonzero_ref = a_union_nonzero; + + a_struct_t a_struct_array_bounded[2] = {{ T_VALUE_1, T_VALUE_2 }, { T_VALUE_3, T_VALUE_4 }}; + a_struct_t a_struct_array_unbounded[] = {{ T_VALUE_1, T_VALUE_2 }, { T_VALUE_3, T_VALUE_4 }}; + a_union_zero_t a_union_zero_array_bounded[2]; + a_union_zero_array_bounded[0].a = T_VALUE_1; + a_union_zero_array_bounded[1].a = T_VALUE_2; + a_union_zero_t a_union_zero_array_unbounded[] = {{ T_VALUE_1 }, { T_VALUE_2 }}; + +#ifdef T_PRINTF_FORMAT + printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); + printf ("%s*: a = %p => '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); + printf ("%s&: a = %p => '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); + + printf ("%s[2]: a_array_bounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[0]); + printf ("%s[2]: a_array_bounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[1]); + + printf ("%s[]: a_array_unbounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[0]); + printf ("%s[]: a_array_unbounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[1]); + + printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); + printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->b_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.b_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); + + printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); + printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->a = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->a); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->b = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->b); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.a = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.a); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.b = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.b); + + printf ("(a_union_zero_t) a_union_zero.a = '" T_PRINTF_FORMAT "'\n", a_union_zero.a); + printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); + printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); + + printf ("(a_union_nonzero_t) a_union_nonzero.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); + printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); + printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); + + printf ("(a_struct_t[2]) a_struct_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].a); + printf ("(a_struct_t[2]) a_struct_array_bounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].b); + printf ("(a_struct_t[2]) a_struct_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].a); + printf ("(a_struct_t[2]) a_struct_array_bounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].b); + + printf ("(a_struct_t[]) a_struct_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].a); + printf ("(a_struct_t[]) a_struct_array_unbounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].b); + printf ("(a_struct_t[]) a_struct_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].a); + printf ("(a_struct_t[]) a_struct_array_unbounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].b); + + printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[0].a); + printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[1].a); + + printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[0].a); + printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[1].a); + +#endif + puts ("About to exit, break here to check values..."); + return 0; +} Added: lldb/trunk/test/types/int.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/int.cpp?rev=114530&view=auto ============================================================================== --- lldb/trunk/test/types/int.cpp (added) +++ lldb/trunk/test/types/int.cpp Tue Sep 21 23:50:38 2010 @@ -0,0 +1,9 @@ +#define T int +#define T_CSTR "int" +#define T_VALUE_1 11001110 +#define T_VALUE_2 22002220 +#define T_VALUE_3 33003330 +#define T_VALUE_4 44044440 +#define T_PRINTF_FORMAT "%i" + +#include "basic_type.cpp" From jmolenda at apple.com Wed Sep 22 02:37:07 2010 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 22 Sep 2010 07:37:07 -0000 Subject: [Lldb-commits] [lldb] r114537 - in /lldb/trunk: include/lldb/Core/PluginManager.h include/lldb/Utility/ArchVolatileRegs.h include/lldb/lldb-forward.h include/lldb/lldb-private-interfaces.h lldb.xcodeproj/project.pbxproj source/Core/PluginManager.cpp source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp source/Plugins/Process/Utility/ArchVolatileRegs-x86.h source/Utility/ArchVolatileRegs.cpp source/lldb.cpp Message-ID: <20100922073707.A6B892A6C12D@llvm.org> Author: jmolenda Date: Wed Sep 22 02:37:07 2010 New Revision: 114537 URL: http://llvm.org/viewvc/llvm-project?rev=114537&view=rev Log: Add a new ArchVolatileRegs plugin class to identify whether a given register number is treated as volatile or not for a given architecture/platform. approx 450 lines of boilerplate, 50 lines of actual code. :) Added: lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h lldb/trunk/source/Utility/ArchVolatileRegs.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Sep 22 02:37:07 2010 @@ -213,6 +213,23 @@ 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); + }; Added: lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h?rev=114537&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h (added) +++ lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h Wed Sep 22 02:37:07 2010 @@ -0,0 +1,53 @@ +//===---------------------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-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/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Wed Sep 22 02:37:07 2010 @@ -23,6 +23,7 @@ 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=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Wed Sep 22 02:37:07 2010 @@ -30,6 +30,7 @@ typedef ThreadPlan * (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, void *baton); typedef UnwindAssemblyProfiler* (*UnwindAssemblyProfilerCreateInstance) (const ArchSpec &arch); typedef ArchDefaultUnwindPlan* (*ArchDefaultUnwindPlanCreateInstance) (const ArchSpec &arch); + typedef ArchVolatileRegs* (*ArchVolatileRegsCreateInstance) (const ArchSpec &arch); } // namespace lldb_private #endif // #if defined(__cplusplus) Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 22 02:37:07 2010 @@ -369,6 +369,9 @@ 961FAC19123605A200F93A47 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */; }; 961FAC1E12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */; }; 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */ = {isa = PBXBuildFile; fileRef = 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */; }; + 96A6D9C61249D96F00250B38 /* ArchVolatileRegs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */; }; + 96A6D9C91249D98800250B38 /* ArchVolatileRegs-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */; }; + 96A6D9CA1249D98800250B38 /* ArchVolatileRegs-x86.h in Headers */ = {isa = PBXBuildFile; fileRef = 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */; }; 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 */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1024,6 +1027,9 @@ 9654F7B91197DA3F00F72B43 /* RemoteUnwindProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteUnwindProfile.h; sourceTree = ""; }; 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = unw_getcontext.s; sourceTree = ""; }; 9654F7BD1197DA3F00F72B43 /* UnwindCursor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UnwindCursor.hpp; sourceTree = ""; }; + 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchVolatileRegs.cpp; path = source/Utility/ArchVolatileRegs.cpp; sourceTree = ""; }; + 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchVolatileRegs-x86.cpp"; path = "Utility/ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; + 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchVolatileRegs-x86.h"; path = "Utility/ArchVolatileRegs-x86.h"; sourceTree = ""; }; 9A19A6A51163BB7E00E0D453 /* SBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBValue.h; path = include/lldb/API/SBValue.h; sourceTree = ""; }; 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBValue.cpp; path = source/API/SBValue.cpp; sourceTree = ""; }; 9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreterNone.h; path = include/lldb/Interpreter/ScriptInterpreterNone.h; sourceTree = ""; }; @@ -1554,6 +1560,7 @@ 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( + 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */, 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */, 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */, 264723A511FA076E00DE380C /* CleanUp.h */, @@ -1583,6 +1590,8 @@ 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( + 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */, + 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */, 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */, 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */, 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */, @@ -2285,6 +2294,7 @@ 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */, 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */, 26C72C94124322890068DC16 /* SBStream.h in Headers */, + 96A6D9CA1249D98800250B38 /* ArchVolatileRegs-x86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2750,6 +2760,8 @@ 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */, 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */, 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */, + 96A6D9C61249D96F00250B38 /* ArchVolatileRegs.cpp in Sources */, + 96A6D9C91249D98800250B38 /* ArchVolatileRegs-x86.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Wed Sep 22 02:37:07 2010 @@ -1371,4 +1371,123 @@ 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 bool +AccessArchVolatileRegsInstances (PluginAction action, ArchVolatileRegsInstance &instance, uint32_t index) +{ + static ArchVolatileRegsInstances g_plugin_instances; + + switch (action) + { + case ePluginRegisterInstance: + if (instance.create_callback) + { + g_plugin_instances.push_back (instance); + return true; + } + break; + + case ePluginUnregisterInstance: + if (instance.create_callback) + { + ArchVolatileRegsInstances::iterator pos, end = g_plugin_instances.end(); + for (pos = g_plugin_instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == instance.create_callback) + { + g_plugin_instances.erase(pos); + return true; + } + } + } + break; + + case ePluginGetInstanceAtIndex: + if (index < g_plugin_instances.size()) + { + instance = g_plugin_instances[index]; + return true; + } + break; + + default: + break; + } + return false; +} + +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; + return AccessArchVolatileRegsInstances (ePluginRegisterInstance, instance, 0); + } + return false; +} + +bool +PluginManager::UnregisterPlugin (ArchVolatileRegsCreateInstance create_callback) +{ + if (create_callback) + { + ArchVolatileRegsInstance instance; + instance.create_callback = create_callback; + return AccessArchVolatileRegsInstances (ePluginUnregisterInstance, instance, 0); + } + return false; +} + +ArchVolatileRegsCreateInstance +PluginManager::GetArchVolatileRegsCreateCallbackAtIndex (uint32_t idx) +{ + ArchVolatileRegsInstance instance; + if (AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx)) + return instance.create_callback; + return NULL; +} + +ArchVolatileRegsCreateInstance +PluginManager::GetArchVolatileRegsCreateCallbackForPluginName (const char *name) +{ + if (name && name[0]) + { + ArchVolatileRegsInstance instance; + std::string ss_name(name); + for (uint32_t idx = 0; AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + { + if (instance.name == ss_name) + return instance.create_callback; + } + } + return NULL; +} Added: lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp?rev=114537&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp Wed Sep 22 02:37:07 2010 @@ -0,0 +1,168 @@ +//===-- ArchVolatileRegs-x86.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ArchVolatileRegs-x86.h" + +#include "lldb/lldb-private.h" +#include "lldb/Utility/ArchVolatileRegs.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/RegisterContext.h" +#include + +using namespace lldb; +using namespace lldb_private; + +bool +ArchVolatileRegs_x86::RegisterIsVolatile (Thread& thread, uint32_t regnum) +{ + initialize_regset (thread); + if (m_non_volatile_regs.find (regnum) == m_non_volatile_regs.end()) + return true; + else + return false; +} + +lldb_private::ArchVolatileRegs * +ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch) +{ + uint32_t cpu = arch.GetCPUType (); + if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + return NULL; + + return new ArchVolatileRegs_x86 (cpu); +} + +ArchVolatileRegs_x86::ArchVolatileRegs_x86(int cpu) : + lldb_private::ArchVolatileRegs(), + m_cpu(cpu), + m_non_volatile_regs() +{ +} + +void + +ArchVolatileRegs_x86::initialize_regset(Thread& thread) +{ + if (m_non_volatile_regs.size() > 0) + return; + + + RegisterContext *rctx = thread.GetRegisterContext(); + const RegisterInfo *ri; + + const char *x86_64_regnames[] = { "rbx", + "rsp", + "rbp", + "r12", + "r13", + "r14", + "r15", + "rip" }; + + const char *i386_regnames[] = { "ebx", + "ebp", + "esi", + "edi", + "esp", + "eip" }; + + + const char **names; + int namecount; + if (m_cpu == CPU_TYPE_X86_64) + { + names = x86_64_regnames; + namecount = sizeof (x86_64_regnames) / sizeof (char *); + } + else + { + names = i386_regnames; + namecount = sizeof (i386_regnames) / sizeof (char *); + } + + for (int i = 0; i < namecount; i++) + { + ri = rctx->GetRegisterInfoByName (names[i]); + if (ri) + m_non_volatile_regs.insert (ri->kinds[eRegisterKindLLDB]); + } +} + + +//------------------------------------------------------------------ +// PluginInterface protocol in ArchVolatileRegs_x86 +//------------------------------------------------------------------ + +const char * +ArchVolatileRegs_x86::GetPluginName() +{ + return "ArchVolatileRegs_x86"; +} + +const char * +ArchVolatileRegs_x86::GetShortPluginName() +{ + return "archvolatileregs.x86"; +} + + +uint32_t +ArchVolatileRegs_x86::GetPluginVersion() +{ + return 1; +} + +void +ArchVolatileRegs_x86::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +ArchVolatileRegs_x86::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +ArchVolatileRegs_x86::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +void +ArchVolatileRegs_x86::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +ArchVolatileRegs_x86::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +ArchVolatileRegs_x86::GetPluginNameStatic() +{ + return "ArchVolatileRegs_x86"; +} + +const char * +ArchVolatileRegs_x86::GetPluginDescriptionStatic() +{ + return "i386 and x86_64 architecture volatile register information."; +} Added: lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h?rev=114537&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h Wed Sep 22 02:37:07 2010 @@ -0,0 +1,76 @@ +//===-- ArchVolatileRegs-x86.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_ArchVolatileRegs_x86_h_ +#define liblldb_ArchVolatileRegs_x86_h_ + +#include "lldb/lldb-private.h" +#include "lldb/Utility/ArchVolatileRegs.h" +#include + +namespace lldb_private { + +class ArchVolatileRegs_x86 : public lldb_private::ArchVolatileRegs +{ +public: + + ~ArchVolatileRegs_x86 () { } + + bool + RegisterIsVolatile (lldb_private::Thread& thread, uint32_t regnum); + + static lldb_private::ArchVolatileRegs * + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + +private: + ArchVolatileRegs_x86(int cpu); // Call CreateInstance instead. + + void initialize_regset(lldb_private::Thread& thread); + + int m_cpu; + std::set m_non_volatile_regs; +}; + + +} // namespace lldb_private + +#endif // liblldb_ArchVolatileRegs_x86_h_ Added: lldb/trunk/source/Utility/ArchVolatileRegs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchVolatileRegs.cpp?rev=114537&view=auto ============================================================================== --- lldb/trunk/source/Utility/ArchVolatileRegs.cpp (added) +++ lldb/trunk/source/Utility/ArchVolatileRegs.cpp Wed Sep 22 02:37:07 2010 @@ -0,0 +1,40 @@ +//===-- ArchVolatileRegs.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-private.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/PluginInterface.h" +#include "lldb/Utility/ArchVolatileRegs.h" + +using namespace lldb; +using namespace lldb_private; + +ArchVolatileRegs* +ArchVolatileRegs::FindPlugin (const ArchSpec &arch) +{ + ArchVolatileRegsCreateInstance create_callback; + + for (uint32_t idx = 0; + (create_callback = PluginManager::GetArchVolatileRegsCreateCallbackAtIndex(idx)) != NULL; + ++idx) + { + std::auto_ptr default_volatile_regs_ap (create_callback (arch)); + if (default_volatile_regs_ap.get ()) + return default_volatile_regs_ap.release (); + } + return NULL; +} + +ArchVolatileRegs::ArchVolatileRegs () +{ +} + +ArchVolatileRegs::~ArchVolatileRegs () +{ +} Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=114537&r1=114536&r2=114537&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Wed Sep 22 02:37:07 2010 @@ -24,6 +24,7 @@ #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" #include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" #include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" +#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" #ifdef __APPLE__ #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" @@ -66,7 +67,7 @@ SymbolFileDWARFDebugMap::Initialize(); SymbolFileSymtab::Initialize(); UnwindAssemblyProfiler_x86::Initialize(); - ArchDefaultUnwindPlan_x86::Initialize(); + ArchVolatileRegs_x86::Initialize(); #ifdef __APPLE__ ABIMacOSX_i386::Initialize(); @@ -105,7 +106,7 @@ SymbolFileDWARFDebugMap::Terminate(); SymbolFileSymtab::Terminate(); UnwindAssemblyProfiler_x86::Terminate(); - ArchDefaultUnwindPlan_x86::Terminate(); + ArchVolatileRegs_x86::Terminate(); #ifdef __APPLE__ DynamicLoaderMacOSXDYLD::Terminate(); From ctice at apple.com Wed Sep 22 11:41:52 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 22 Sep 2010 16:41:52 -0000 Subject: [Lldb-commits] [lldb] r114549 - in /lldb/trunk: include/lldb/API/SBCommandContext.h scripts/Python/build-swig-Python.sh scripts/lldb.swig source/API/SBCommandContext.cpp Message-ID: <20100922164152.A31C52A6C12E@llvm.org> Author: ctice Date: Wed Sep 22 11:41:52 2010 New Revision: 114549 URL: http://llvm.org/viewvc/llvm-project?rev=114549&view=rev Log: Remove SBCommandContext which was not needed or doing anything. Add SBValueList.h & SBStream.h to build-swig-Python.sh; add SBValueList.h to lldb.swig Removed: lldb/trunk/include/lldb/API/SBCommandContext.h lldb/trunk/source/API/SBCommandContext.cpp Modified: lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/scripts/lldb.swig Removed: lldb/trunk/include/lldb/API/SBCommandContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandContext.h?rev=114548&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandContext.h (original) +++ lldb/trunk/include/lldb/API/SBCommandContext.h (removed) @@ -1,36 +0,0 @@ -//===-- SBCommandContext.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_SBCommandContext_h_ -#define LLDB_SBCommandContext_h_ - - -#include "lldb/API/SBDefines.h" - -namespace lldb { - -class SBCommandContext -{ -public: - - SBCommandContext (lldb_private::Debugger *lldb_object); - - ~SBCommandContext (); - - bool - IsValid () const; - -private: - - lldb_private::Debugger *m_opaque; -}; - -} // namespace lldb - -#endif // LLDB_SBCommandContext_h_ Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=114549&r1=114548&r2=114549&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Wed Sep 22 11:41:52 2010 @@ -35,7 +35,6 @@ " ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ " ${SRC_ROOT}/include/lldb/API/SBBreakpointLocation.h"\ " ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\ -" ${SRC_ROOT}/include/lldb/API/SBCommandContext.h"\ " ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ " ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ " ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\ @@ -50,13 +49,15 @@ " ${SRC_ROOT}/include/lldb/API/SBModule.h"\ " ${SRC_ROOT}/include/lldb/API/SBProcess.h"\ " ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\ +" ${SRC_ROOT}/include/lldb/API/SBStream.h"\ " ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ " ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ " ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ " ${SRC_ROOT}/include/lldb/API/SBThread.h"\ " ${SRC_ROOT}/include/lldb/API/SBType.h"\ -" ${SRC_ROOT}/include/lldb/API/SBValue.h" +" ${SRC_ROOT}/include/lldb/API/SBValue.h"\ +" ${SRC_ROOT}/include/lldb/API/SBValueList.h" if [ $Debug == 1 ] Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114549&r1=114548&r2=114549&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Sep 22 11:41:52 2010 @@ -98,6 +98,7 @@ #include "lldb/API/SBThread.h" #include "lldb/API/SBType.h" #include "lldb/API/SBValue.h" +#include "lldb/API/SBValueList.h" using namespace lldb_private; %} @@ -152,6 +153,7 @@ %include "lldb/API/SBThread.h" %include "lldb/API/SBType.h" %include "lldb/API/SBValue.h" +%include "lldb/API/SBValueList.h" %include "lldb/lldb-types.h" Removed: lldb/trunk/source/API/SBCommandContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandContext.cpp?rev=114548&view=auto ============================================================================== --- lldb/trunk/source/API/SBCommandContext.cpp (original) +++ lldb/trunk/source/API/SBCommandContext.cpp (removed) @@ -1,34 +0,0 @@ -//===-- SBCommandContext.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/Debugger.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -#include "lldb/API/SBCommandContext.h" - - -using namespace lldb; -using namespace lldb_private; - - -SBCommandContext::SBCommandContext (Debugger *lldb_object) : - m_opaque (lldb_object) -{ -} - -SBCommandContext::~SBCommandContext () -{ -} - -bool -SBCommandContext::IsValid () const -{ - return m_opaque != NULL; -} - From johnny.chen at apple.com Wed Sep 22 12:46:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Sep 2010 17:46:07 -0000 Subject: [Lldb-commits] [lldb] r114557 - /lldb/trunk/test/types/basic_type.cpp Message-ID: <20100922174607.EC0562A6C12C@llvm.org> Author: johnny Date: Wed Sep 22 12:46:07 2010 New Revision: 114557 URL: http://llvm.org/viewvc/llvm-project?rev=114557&view=rev Log: Changed to facilitate 'breakpoint set -n Puts', then 'thread step-out' to workaround rdar://problem/8464339 test/types directory: b basic_type.cpp:171 does not work, while gdb does work. Modified: lldb/trunk/test/types/basic_type.cpp Modified: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=114557&r1=114556&r2=114557&view=diff ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (original) +++ lldb/trunk/test/types/basic_type.cpp Wed Sep 22 12:46:07 2010 @@ -82,6 +82,11 @@ #include #include +void Puts(char const *msg) +{ + puts(msg); +} + int main (int argc, char const *argv[]) { @@ -168,6 +173,6 @@ printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[1].a); #endif - puts ("About to exit, break here to check values..."); + Puts("About to exit, break here to check values..."); return 0; } From johnny.chen at apple.com Wed Sep 22 18:00:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Sep 2010 23:00:20 -0000 Subject: [Lldb-commits] [lldb] r114600 - in /lldb/trunk/test: lldbtest.py plugins/darwin.py types/TestBasicTypes.py Message-ID: <20100922230020.73C1D2A6C12C@llvm.org> Author: johnny Date: Wed Sep 22 18:00:20 2010 New Revision: 114600 URL: http://llvm.org/viewvc/llvm-project?rev=114600&view=rev Log: Checked in an initial template for the types directory. Right now, it doesn't actually test-and-compare anything yet. The lldbtest.TestBase has an added method setTearDownCleanup(dictionary=None) to facilitate running the cleanup right after each data type test is run. The test case can pass a dictionary object when registering the test case cleanup. There is currently only int_type test in the repository. Added: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/plugins/darwin.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114600&r1=114599&r2=114600&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Sep 22 18:00:20 2010 @@ -132,6 +132,8 @@ BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1" +STEP_OUT_SUCCEEDED = "Thread step-out succeeded" + STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint" STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in" @@ -354,6 +356,14 @@ # And the result object. self.res = lldb.SBCommandReturnObject() + # These are for customized teardown cleanup. + self.dict = None + self.doTearDownCleanup = False + + def setTearDownCleanup(self, dictionary=None): + self.dict = dictionary + self.doTearDownCleanup = True + def tearDown(self): #import traceback #traceback.print_stack() @@ -367,6 +377,12 @@ del self.dbg + # Perform registered teardown cleanup. + if self.doTearDownCleanup: + module = __import__(sys.platform) + if not module.cleanup(dictionary=self.dict): + raise Exception("Don't know how to do cleanup") + def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True): """ Ask the command interpreter to handle the command and then check its @@ -549,22 +565,22 @@ # End of while loop. - def buildDefault(self, compiler=None): + def buildDefault(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build the default binaries.""" module = __import__(sys.platform) - if not module.buildDefault(compiler): + if not module.buildDefault(architecture, compiler, dictionary): raise Exception("Don't know how to build default binary") - def buildDsym(self, compiler=None): + def buildDsym(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build binaries with dsym info.""" module = __import__(sys.platform) - if not module.buildDsym(compiler): + if not module.buildDsym(architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dsym") - def buildDwarf(self, compiler=None): + def buildDwarf(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build binaries with dwarf maps.""" module = __import__(sys.platform) - if not module.buildDwarf(compiler): + if not module.buildDwarf(architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dwarf") def DebugSBValue(self, frame, val): Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=114600&r1=114599&r2=114600&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Wed Sep 22 18:00:20 2010 @@ -17,6 +17,18 @@ #print "Hello, darwin plugin!" +def getArchSpec(architecture): + """ + Helper function to return the key-value string to specify the architecture + used for the make system. + """ + arch = architecture if architecture else None + if not arch and "LLDB_ARCH" in os.environ: + arch = os.environ["LLDB_ARCH"] + + # Note the leading space character. + return (" ARCH=" + arch) if arch else "" + def getCCSpec(compiler): """ Helper function to return the key-value string to specify the compiler @@ -29,50 +41,57 @@ # Note the leading space character. return (" CC=" + cc) if cc else "" -def getArchSpec(architecture): +def getCmdLine(d): """ - Helper function to return the key-value string to specify the architecture - used for the make system. + Helper function to return a properly formatted command line argument(s) + string used for the make system. """ - arch = architecture if architecture else None - if not arch and "LLDB_ARCH" in os.environ: - arch = os.environ["LLDB_ARCH"] + + # If d is None or an empty mapping, just return an empty string. + if not d: + return "" + + cmdline = " ".join(["%s='%s'" % (k, v) for k, v in d.items()]) # Note the leading space character. - return (" ARCH=" + arch) if arch else "" + return " " + cmdline -def buildDefault(architecture=None, compiler=None): +def buildDefault(architecture=None, compiler=None, dictionary=None): """Build the binaries the default way.""" lldbtest.system(["/bin/sh", "-c", "make clean; make" - + getArchSpec(architecture) + getCCSpec(compiler)]) + + getArchSpec(architecture) + getCCSpec(compiler) + + getCmdLine(dictionary)]) # True signifies that we can handle building default. return True -def buildDsym(architecture=None, compiler=None): +def buildDsym(architecture=None, compiler=None, dictionary=None): """Build the binaries with dsym debug info.""" lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=YES" - + getArchSpec(architecture) + getCCSpec(compiler)]) + + getArchSpec(architecture) + getCCSpec(compiler) + + getCmdLine(dictionary)]) # True signifies that we can handle building dsym. return True -def buildDwarf(architecture=None, compiler=None): +def buildDwarf(architecture=None, compiler=None, dictionary=None): """Build the binaries with dwarf debug info.""" lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=NO" - + getArchSpec(architecture) + getCCSpec(compiler)]) + + getArchSpec(architecture) + getCCSpec(compiler) + + getCmdLine(dictionary)]) # True signifies that we can handle building dsym. return True -def cleanup(): - """Do class-wide cleanup after the test.""" +def cleanup(dictionary=None): + """Perform a platform-specific cleanup after the test.""" if os.path.isfile("Makefile"): - lldbtest.system(["/bin/sh", "-c", "make clean"]) + lldbtest.system(["/bin/sh", "-c", "make clean" + getCmdLine(dictionary)] + ) # True signifies that we can handle building dsym. return True Added: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114600&view=auto ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (added) +++ lldb/trunk/test/types/TestBasicTypes.py Wed Sep 22 18:00:20 2010 @@ -0,0 +1,45 @@ +""" +Test that variables of basic types are displayed correctly. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class BasicTypesTestCase(TestBase): + + mydir = "types" + + def test_int_type_with_dsym(self): + """Test that int-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def test_int_type_with_dwarf(self): + """Test that int-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def int_type(self): + """Test that int-type variables are displayed correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.runCmd("breakpoint set --name Puts") + + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) + + self.runCmd("frame variable a") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From ctice at apple.com Wed Sep 22 18:01:29 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 22 Sep 2010 23:01:29 -0000 Subject: [Lldb-commits] [lldb] r114602 - in /lldb/trunk: include/lldb/API/ lldb.xcodeproj/ scripts/ scripts/Python/ source/API/ Message-ID: <20100922230129.BCE0C2A6C12D@llvm.org> Author: ctice Date: Wed Sep 22 18:01:29 2010 New Revision: 114602 URL: http://llvm.org/viewvc/llvm-project?rev=114602&view=rev Log: Remove all the __repr__ methods from the API/*.h files, and put them into python-extensions.swig, which gets included into lldb.swig, and adds them back into the classes when swig generates it's C++ file. This keeps the Python stuff out of the general API classes. Also fixed a small bug in the copy constructor for SBSymbolContext. Added: lldb/trunk/scripts/Python/python-extensions.swig Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBEvent.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/API/SBLineEntry.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/API/SBType.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/API/SBCommandReturnObject.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBError.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBLineEntry.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBSymbol.cpp lldb/trunk/source/API/SBSymbolContext.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBType.cpp lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Wed Sep 22 18:01:29 2010 @@ -47,13 +47,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBFrame; Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Wed Sep 22 18:01:29 2010 @@ -52,13 +52,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject *, which contains a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Wed Sep 22 18:01:29 2010 @@ -116,13 +116,6 @@ static lldb::SBBreakpointLocation GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBBreakpointLocation; friend class SBTarget; Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Wed Sep 22 18:01:29 2010 @@ -74,13 +74,6 @@ SBBreakpoint GetBreakpoint (); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBBreakpoint; Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Wed Sep 22 18:01:29 2010 @@ -61,13 +61,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBCommandInterpreter; friend class SBOptions; Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Wed Sep 22 18:01:29 2010 @@ -53,13 +53,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Wed Sep 22 18:01:29 2010 @@ -157,13 +157,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - uint32_t GetTerminalWidth () const; Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Wed Sep 22 18:01:29 2010 @@ -10,11 +10,6 @@ #ifndef LLDB_SBDefines_h_ #define LLDB_SBDefines_h_ -// In order to guarantee correct working with Python, Python.h *MUST* be -// the *FIRST* header file included: - -#include - // C Includes // C++ Includes // Other libraries and framework includes Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Wed Sep 22 18:01:29 2010 @@ -68,13 +68,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBArguments; friend class SBDebugger; Modified: lldb/trunk/include/lldb/API/SBEvent.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBEvent.h (original) +++ lldb/trunk/include/lldb/API/SBEvent.h Wed Sep 22 18:01:29 2010 @@ -57,13 +57,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBListener; friend class SBBroadcaster; Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Wed Sep 22 18:01:29 2010 @@ -54,13 +54,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBBlock; friend class SBCompileUnit; Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Wed Sep 22 18:01:29 2010 @@ -115,13 +115,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBValue; Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Wed Sep 22 18:01:29 2010 @@ -42,13 +42,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Wed Sep 22 18:01:29 2010 @@ -49,13 +49,6 @@ //bool //GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - //PyObject * - //__repr__ (); - private: //lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp; Modified: lldb/trunk/include/lldb/API/SBLineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBLineEntry.h (original) +++ lldb/trunk/include/lldb/API/SBLineEntry.h Wed Sep 22 18:01:29 2010 @@ -61,13 +61,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBCompileUnit; friend class SBFrame; Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Wed Sep 22 18:01:29 2010 @@ -52,13 +52,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBSymbolContext; friend class SBTarget; Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Wed Sep 22 18:01:29 2010 @@ -155,13 +155,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It take no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBAddress; friend class SBBreakpoint; Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Wed Sep 22 18:01:29 2010 @@ -43,13 +43,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Wed Sep 22 18:01:29 2010 @@ -44,6 +44,9 @@ SBLineEntry GetLineEntry (); SBSymbol GetSymbol (); + bool + GetDescription (lldb::SBStream &description); + protected: friend class SBFrame; friend class SBModule; @@ -58,6 +61,9 @@ lldb_private::SymbolContext& operator*(); + lldb_private::SymbolContext& + ref(); + const lldb_private::SymbolContext& operator*() const; @@ -71,16 +77,6 @@ void SetSymbolContext (const lldb_private::SymbolContext *sc_ptr); - bool - GetDescription (lldb::SBStream &description); - - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - private: std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Sep 22 18:01:29 2010 @@ -145,13 +145,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBAddress; friend class SBDebugger; Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Wed Sep 22 18:01:29 2010 @@ -91,13 +91,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBBreakpoint; friend class SBBreakpointLocation; Modified: lldb/trunk/include/lldb/API/SBType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBType.h (original) +++ lldb/trunk/include/lldb/API/SBType.h Wed Sep 22 18:01:29 2010 @@ -57,13 +57,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It takes no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: void *m_ast; void *m_type; Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Wed Sep 22 18:01:29 2010 @@ -88,13 +88,6 @@ bool GetDescription (lldb::SBStream &description); - // The following function gets called by Python when a user tries to print - // an object of this class. It take no arguments and returns a - // PyObject * representing a char * (and it must be named "__repr__"); - - PyObject * - __repr__ (); - protected: friend class SBValueList; friend class SBFrame; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 22 18:01:29 2010 @@ -1046,6 +1046,7 @@ 9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpointCommand.cpp; path = source/Commands/CommandObjectBreakpointCommand.cpp; sourceTree = ""; }; 9A4633DA11F65D8600955CE1 /* UserSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserSettingsController.h; path = include/lldb/Core/UserSettingsController.h; sourceTree = ""; }; 9A4633DC11F65D9A00955CE1 /* UserSettingsController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserSettingsController.cpp; path = source/Core/UserSettingsController.cpp; sourceTree = ""; }; + 9A48A3A7124AAA5A00922451 /* python-extensions.swig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "python-extensions.swig"; sourceTree = ""; }; 9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = ""; }; 9A633FE8112DCE3C001A7E43 /* SBFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFrame.h; path = include/lldb/API/SBFrame.h; sourceTree = ""; }; 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = ""; }; @@ -1553,6 +1554,7 @@ 266960601199F4230075C61A /* build-swig-Python.sh */, 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */, 266960621199F4230075C61A /* finish-swig-Python-lldb.sh */, + 9A48A3A7124AAA5A00922451 /* python-extensions.swig */, ); path = Python; sourceTree = ""; @@ -2349,7 +2351,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Added: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=114602&view=auto ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (added) +++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep 22 18:01:29 2010 @@ -0,0 +1,135 @@ + +%extend lldb::SBAddress { + PyObject *lldb::SBAddress::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBBlock { + PyObject *lldb::SBBlock::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBBreakpoint { + PyObject *lldb::SBBreakpoint::__repr__ (){ + lldb::SBStream description; + $self->GetDescription ("full", description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBBreakpointLocation { + PyObject *lldb::SBBreakpointLocation::__repr__ (){ + lldb::SBStream description; + $self->GetDescription ("full", description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBCommandReturnObject { + PyObject *lldb::SBCommandReturnObject::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBCompileUnit { + PyObject *lldb::SBCompileUnit::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBDebugger { + PyObject *lldb::SBDebugger::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBError { + PyObject *lldb::SBError::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBFileSpec { + PyObject *lldb::SBFileSpec::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBFrame { + PyObject *lldb::SBFrame::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBFunction { + PyObject *lldb::SBFunction::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBLineEntry { + PyObject *lldb::SBLineEntry::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBModule { + PyObject *lldb::SBModule::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBProcess { + PyObject *lldb::SBProcess::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBSymbol { + PyObject *lldb::SBSymbol::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBSymbolContext { + PyObject *lldb::SBSymbolContext::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBTarget { + PyObject *lldb::SBTarget::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBThread { + PyObject *lldb::SBThread::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBValue { + PyObject *lldb::SBValue::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} + Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Sep 22 18:01:29 2010 @@ -156,4 +156,4 @@ %include "lldb/API/SBValueList.h" %include "lldb/lldb-types.h" - +%include "./Python/python-extensions.swig" Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Wed Sep 22 18:01:29 2010 @@ -140,6 +140,7 @@ bool SBAddress::GetDescription (SBStream &description) { + description.ref(); if (m_opaque_ap.get()) { m_opaque_ap->DumpDebug (description.get()); @@ -149,12 +150,3 @@ return true; } - -PyObject * -SBAddress::__repr__ () -{ - SBStream description; - description.ref(); // Make sure it contains a valid StreamString. - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Wed Sep 22 18:01:29 2010 @@ -158,12 +158,3 @@ return true; } - -PyObject * -SBBlock::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Sep 22 18:01:29 2010 @@ -337,7 +337,7 @@ else level = eDescriptionLevelBrief; - + description.ref(); m_opaque_sp->GetDescription (description.get(), level); description.get()->EOL(); } @@ -347,15 +347,6 @@ return true; } -PyObject * -SBBreakpoint::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription ("full", description); - return PyString_FromString (description.GetData()); -} - bool SBBreakpoint::PrivateBreakpointHitCallback ( Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Wed Sep 22 18:01:29 2010 @@ -212,6 +212,7 @@ else level = eDescriptionLevelBrief; + description.ref(); m_opaque_sp->GetDescription (description.get(), level); description.get()->EOL(); } @@ -221,15 +222,6 @@ return true; } -PyObject * -SBBreakpointLocation::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription ("full", description); - return PyString_FromString (description.GetData()); -} - SBBreakpoint SBBreakpointLocation::GetBreakpoint () { Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Wed Sep 22 18:01:29 2010 @@ -188,11 +188,3 @@ return true; } - -PyObject * -SBCommandReturnObject::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Wed Sep 22 18:01:29 2010 @@ -125,6 +125,7 @@ { if (m_opaque_ptr) { + description.ref(); m_opaque_ptr->Dump (description.get(), false); } else @@ -132,12 +133,3 @@ return true; } - -PyObject * -SBCompileUnit::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Sep 22 18:01:29 2010 @@ -695,12 +695,3 @@ return true; } - - -PyObject * -SBDebugger::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBError.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBError.cpp (original) +++ lldb/trunk/source/API/SBError.cpp Wed Sep 22 18:01:29 2010 @@ -198,11 +198,3 @@ return true; } - -PyObject * -SBError::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Wed Sep 22 18:01:29 2010 @@ -156,6 +156,7 @@ { if (m_opaque) { + description.ref(); m_opaque->Dump (description.get()); } else @@ -163,12 +164,3 @@ return true; } - -PyObject * -SBEvent::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Wed Sep 22 18:01:29 2010 @@ -158,11 +158,3 @@ return true; } - -PyObject * -SBFileSpec::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Wed Sep 22 18:01:29 2010 @@ -394,6 +394,7 @@ { if (m_opaque_sp) { + description.ref(); m_opaque_sp->Dump (description.get(), true, false); } else @@ -401,12 +402,3 @@ return true; } - -PyObject * -SBFrame::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Wed Sep 22 18:01:29 2010 @@ -69,6 +69,7 @@ { if (m_opaque_ptr) { + description.ref(); m_opaque_ptr->Dump (description.get(), false); } else @@ -76,12 +77,3 @@ return true; } - -PyObject * -SBFunction::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBLineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLineEntry.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBLineEntry.cpp (original) +++ lldb/trunk/source/API/SBLineEntry.cpp Wed Sep 22 18:01:29 2010 @@ -172,11 +172,3 @@ return true; } - -PyObject * -SBLineEntry::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Wed Sep 22 18:01:29 2010 @@ -133,6 +133,7 @@ { if (m_opaque_sp) { + description.ref(); m_opaque_sp->Dump (description.get()); } else @@ -140,12 +141,3 @@ return true; } - -PyObject * -SBModule::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Sep 22 18:01:29 2010 @@ -485,11 +485,3 @@ return true; } - -PyObject * -SBProcess::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Wed Sep 22 18:01:29 2010 @@ -69,19 +69,12 @@ { if (m_opaque_ptr) { - m_opaque_ptr->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL); + description.ref(); + m_opaque_ptr->GetDescription (description.get(), + lldb::eDescriptionLevelFull, NULL); } else description.Printf ("No value"); return true; } - -PyObject * -SBSymbol::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Wed Sep 22 18:01:29 2010 @@ -32,7 +32,12 @@ m_opaque_ap () { if (rhs.IsValid()) - *m_opaque_ap = *rhs.m_opaque_ap; + { + if (m_opaque_ap.get()) + *m_opaque_ap = *rhs.m_opaque_ap; + else + ref() = *rhs.m_opaque_ap; + } } SBSymbolContext::~SBSymbolContext () @@ -141,6 +146,14 @@ return *m_opaque_ap.get(); } +lldb_private::SymbolContext& +SBSymbolContext::ref() +{ + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new SymbolContext); + return *m_opaque_ap.get(); +} + lldb_private::SymbolContext * SBSymbolContext::get() const { @@ -152,6 +165,7 @@ { if (m_opaque_ap.get()) { + description.ref(); m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL); } else @@ -159,12 +173,3 @@ return true; } - -PyObject * -SBSymbolContext::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Sep 22 18:01:29 2010 @@ -507,6 +507,7 @@ { if (m_opaque_sp) { + description.ref(); m_opaque_sp->Dump (description.get()); } else @@ -514,12 +515,3 @@ return true; } - -PyObject * -SBTarget::__repr__ () -{ - SBStream description; - description.ref(); - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Wed Sep 22 18:01:29 2010 @@ -428,11 +428,3 @@ return true; } - -PyObject * -SBThread::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} Modified: lldb/trunk/source/API/SBType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBType.cpp (original) +++ lldb/trunk/source/API/SBType.cpp Wed Sep 22 18:01:29 2010 @@ -185,14 +185,6 @@ return true; } -PyObject * -SBType::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} - SBTypeMember::SBTypeMember () : m_ast (NULL), m_parent_type (NULL), Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=114602&r1=114601&r2=114602&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Wed Sep 22 18:01:29 2010 @@ -293,11 +293,3 @@ return true; } - -PyObject * -SBValue::__repr__ () -{ - SBStream description; - GetDescription (description); - return PyString_FromString (description.GetData()); -} From gclayton at apple.com Wed Sep 22 20:09:22 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 23 Sep 2010 01:09:22 -0000 Subject: [Lldb-commits] [lldb] r114616 - in /lldb/trunk: include/lldb/Core/ClangForward.h include/lldb/Symbol/ClangASTContext.h lldb.xcodeproj/project.pbxproj source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp source/Symbol/UnwindTable.cpp Message-ID: <20100923010922.40C282A6C12C@llvm.org> Author: gclayton Date: Wed Sep 22 20:09:21 2010 New Revision: 114616 URL: http://llvm.org/viewvc/llvm-project?rev=114616&view=rev Log: Added motheds to C++ classes as we parse them to keep clang happy. Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/UnwindTable.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Wed Sep 22 20:09:21 2010 @@ -37,6 +37,7 @@ class CXXBaseSpecifier; class CXXBoolLiteralExpr; class CXXFunctionalCastExpr; + class CXXMethodDecl; class CXXNamedCastExpr; class CXXRecordDecl; class CXXThisExpr; Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Sep 22 20:09:21 2010 @@ -182,22 +182,28 @@ bitfield_bit_size); } - static bool + static clang::CXXMethodDecl * AddMethodToCXXRecordType (clang::ASTContext *ast_context, - void *record_clang_type, + void *record_opaque_type, const char *name, - void *method_type); + void *method_opaque_type, + lldb::AccessType access, + bool is_virtual); - bool - AddMethodToCXXRecordType (void *record_clang_type, + clang::CXXMethodDecl * + AddMethodToCXXRecordType (void *record_opaque_type, const char *name, - void *method_type) + void *method_opaque_type, + lldb::AccessType access, + bool is_virtual) { return ClangASTContext::AddMethodToCXXRecordType(getASTContext(), - record_clang_type, + record_opaque_type, name, - method_type); + method_opaque_type, + access, + is_virtual); } bool Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 22 20:09:21 2010 @@ -584,6 +584,9 @@ 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; 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 = ""; }; + 269FF07D12494F7D00225026 /* FuncUnwinders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FuncUnwinders.h; path = include/lldb/Symbol/FuncUnwinders.h; sourceTree = ""; }; + 269FF07F12494F8E00225026 /* UnwindPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindPlan.h; path = include/lldb/Symbol/UnwindPlan.h; sourceTree = ""; }; + 269FF08112494FC200225026 /* UnwindTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindTable.h; path = include/lldb/Symbol/UnwindTable.h; sourceTree = ""; }; 26A0604711A5BC7A00F75969 /* Baton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Core/Baton.h; sourceTree = ""; }; 26A0604811A5D03C00F75969 /* Baton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Baton.cpp; path = source/Core/Baton.cpp; sourceTree = ""; }; 26A3B4AC1181454800381BC2 /* ObjectContainerBSDArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectContainerBSDArchive.cpp; sourceTree = ""; }; @@ -1741,9 +1744,6 @@ 26BC7C4B10F1B6C100F91463 /* Symbol */ = { isa = PBXGroup; children = ( - 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */, - 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */, - 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */, 26BC7C5510F1B6E900F91463 /* Block.h */, 26BC7F1310F1B8EC00F91463 /* Block.cpp */, 26BC7C5610F1B6E900F91463 /* ClangASTContext.h */, @@ -1758,6 +1758,8 @@ 26BC7F1710F1B8EC00F91463 /* DWARFCallFrameInfo.cpp */, 26BC7C5A10F1B6E900F91463 /* Function.h */, 26BC7F1810F1B8EC00F91463 /* Function.cpp */, + 269FF07D12494F7D00225026 /* FuncUnwinders.h */, + 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */, 26BC7C5B10F1B6E900F91463 /* LineEntry.h */, 26BC7F1910F1B8EC00F91463 /* LineEntry.cpp */, 26BC7C5C10F1B6E900F91463 /* LineTable.h */, @@ -1781,6 +1783,10 @@ 26BC7F2010F1B8EC00F91463 /* Type.cpp */, 26BC7C6610F1B6E900F91463 /* TypeList.h */, 26BC7F2110F1B8EC00F91463 /* TypeList.cpp */, + 269FF07F12494F8E00225026 /* UnwindPlan.h */, + 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */, + 269FF08112494FC200225026 /* UnwindTable.h */, + 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */, 26BC7C6710F1B6E900F91463 /* Variable.h */, 26BC7F2210F1B8EC00F91463 /* Variable.cpp */, 26BC7C6810F1B6E900F91463 /* VariableList.h */, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 22 20:09:21 2010 @@ -1205,10 +1205,12 @@ false, ClangASTContext::GetTypeQualifiers(copied_type)); - ClangASTContext::AddMethodToCXXRecordType(parser_ast_context, - copied_type, - "___clang_expr", - method_type); + ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, + copied_type, + "___clang_expr", + method_type, + lldb::eAccessPublic, + false); } context.AddTypeDecl(copied_type); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 22 20:09:21 2010 @@ -1108,18 +1108,133 @@ case DW_TAG_subprogram: { + DWARFDebugInfoEntry::Attributes attributes; is_a_class = true; if (default_accessibility == eAccessNone) default_accessibility = eAccessPrivate; - // TODO: implement DW_TAG_subprogram type parsing -// UserDefTypeChildInfo method_info(die->GetOffset()); -// -// FunctionSP func_sp (sc.comp_unit->FindFunctionByUID (die->GetOffset())); -// if (func_sp.get() == NULL) -// ParseCompileUnitFunction(sc, dwarf_cu, die); -// -// method_info.SetEncodingTypeUID(die->GetOffset()); -// struct_udt->AddMethod(method_info); + + //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); + // Set a bit that lets us know that we are currently parsing this + const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + + const char *mangled = NULL; + dw_offset_t type_die_offset = DW_INVALID_OFFSET; + Declaration decl; + bool is_variadic = false; + bool is_inline = false; + bool is_virtual = false; + unsigned type_quals = 0; + AccessType accessibility = default_accessibility; + + clang::FunctionDecl::StorageClass storage = clang::FunctionDecl::None;//, Extern, Static, PrivateExtern + const char *type_name_cstr = NULL; + ConstString type_name_dbstr; + + + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); + if (num_attributes > 0) + { + uint32_t i; + for (i=0; iGetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; + case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; + case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; + case DW_AT_name: + type_name_cstr = form_value.AsCString(&get_debug_str_data()); + break; + + case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; + case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; + //case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; + case DW_AT_external: + if (form_value.Unsigned()) + { + if (storage == clang::FunctionDecl::None) + storage = clang::FunctionDecl::Extern; + else + storage = clang::FunctionDecl::PrivateExtern; + } + break; + case DW_AT_inline: + is_inline = form_value.Unsigned() != 0; + break; + + + case DW_AT_virtuality: + is_virtual = form_value.Unsigned() != 0; + break; + + case DW_AT_allocated: + case DW_AT_associated: + case DW_AT_address_class: + case DW_AT_artificial: + case DW_AT_calling_convention: + case DW_AT_data_location: + case DW_AT_elemental: + case DW_AT_entry_pc: + case DW_AT_explicit: + case DW_AT_frame_base: + case DW_AT_high_pc: + case DW_AT_low_pc: + case DW_AT_object_pointer: + case DW_AT_prototyped: + case DW_AT_pure: + case DW_AT_ranges: + case DW_AT_recursive: + case DW_AT_return_addr: + case DW_AT_segment: + case DW_AT_specification: + case DW_AT_start_scope: + case DW_AT_static_link: + case DW_AT_trampoline: + case DW_AT_visibility: + case DW_AT_vtable_elem_location: + case DW_AT_abstract_origin: + case DW_AT_description: + case DW_AT_sibling: + break; + } + } + } + + void *return_clang_type = NULL; + Type *func_type = ResolveTypeUID(type_die_offset); + if (func_type) + return_clang_type = func_type->GetOpaqueClangQualType(); + else + return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); + + std::vector function_param_types; + std::vector function_param_decls; + + // Parse the function children for the parameters + bool skip_artificial = true; + + ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); + + void *method_function_proto = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); + if (type_name_cstr) + { + clang::CXXMethodDecl *method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_clang_type, + type_name_cstr, + method_function_proto, + accessibility, + is_virtual); + assert (method_decl); + //m_die_to_decl_ctx[die] = method_decl; + } + + const_cast(die)->SetUserData(type_sp.get()); + assert(type_sp.get()); + } } break; @@ -1913,6 +2028,7 @@ TypeSP& type_sp, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, + bool skip_artificial, TypeList* type_list, std::vector& function_param_types, std::vector& function_param_decls @@ -1939,6 +2055,7 @@ const char *name = NULL; Declaration decl; dw_offset_t param_type_die_offset = DW_INVALID_OFFSET; + bool is_artificial = false; // one of None, Auto, Register, Extern, Static, PrivateExtern clang::VarDecl::StorageClass storage = clang::VarDecl::None; @@ -1956,6 +2073,7 @@ case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; case DW_AT_type: param_type_die_offset = form_value.Reference(dwarf_cu); break; + case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break; case DW_AT_location: // if (form_value.BlockData()) // { @@ -1967,7 +2085,6 @@ // { // } // break; - case DW_AT_artificial: case DW_AT_const_value: case DW_AT_default_value: case DW_AT_description: @@ -1982,6 +2099,10 @@ } } } + + if (skip_artificial && is_artificial) + continue; + Type *dc_type = ResolveTypeUID(param_type_die_offset); if (dc_type) { @@ -2717,7 +2838,7 @@ const char *mangled = NULL; dw_offset_t type_die_offset = DW_INVALID_OFFSET; Declaration decl; - bool isVariadic = false; + bool is_variadic = false; bool is_inline = false; unsigned type_quals = 0; clang::FunctionDecl::StorageClass storage = clang::FunctionDecl::None;//, Extern, Static, PrivateExtern @@ -2805,9 +2926,10 @@ std::vector function_param_decls; // Parse the function children for the parameters - ParseChildParameters(sc, type_sp, dwarf_cu, die, type_list, function_param_types, function_param_decls); + bool skip_artificial = false; + ParseChildParameters(sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); - clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), isVariadic, type_quals); + clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); if (type_name_cstr) { clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Sep 22 20:09:21 2010 @@ -248,6 +248,7 @@ lldb::TypeSP& type_sp, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, + bool skip_artificial, lldb_private::TypeList* type_list, std::vector& function_args, std::vector& function_param_decls); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 22 20:09:21 2010 @@ -803,14 +803,16 @@ return ast_context->getTagDeclType(decl).getAsOpaquePtr(); } -bool +CXXMethodDecl * ClangASTContext::AddMethodToCXXRecordType ( - clang::ASTContext *ast_context, - void *record_opaque_type, - const char *name, - void *method_opaque_type - ) + clang::ASTContext *ast_context, + void *record_opaque_type, + const char *name, + void *method_opaque_type, + lldb::AccessType access, + bool is_virtual +) { if (!record_opaque_type || !method_opaque_type || !name) return false; @@ -825,22 +827,22 @@ clang::Type *record_type(record_qual_type.getTypePtr()); if (!record_type) - return false; + return NULL; RecordType *record_recty(dyn_cast(record_type)); if (!record_recty) - return false; + return NULL; RecordDecl *record_decl = record_recty->getDecl(); if (!record_decl) - return false; + return NULL; CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); if (!cxx_record_decl) - return false; + return NULL; QualType method_qual_type(QualType::getFromOpaquePtr(method_opaque_type)); @@ -851,17 +853,19 @@ method_qual_type, NULL); + cxx_method_decl->setAccess (ConvertAccessTypeToAccessSpecifier (access)); + cxx_method_decl->setVirtualAsWritten (is_virtual); + // Populate the method decl with parameter decls - clang::Type *method_type(method_qual_type.getTypePtr()); if (!method_type) - return false; + return NULL; FunctionProtoType *method_funprototy(dyn_cast(method_type)); if (!method_funprototy) - return false; + return NULL; unsigned int num_params = method_funprototy->getNumArgs(); @@ -886,7 +890,7 @@ cxx_record_decl->addDecl(cxx_method_decl); - return true; + return cxx_method_decl; } bool Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=114616&r1=114615&r2=114616&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Wed Sep 22 20:09:21 2010 @@ -7,18 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/UnwindTable.h" +#include + +#include "lldb/lldb-forward.h" + +#include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Core/Section.h" -#include "lldb/Core/Module.h" -#include "lldb/lldb-forward.h" -#include "lldb/Utility/UnwindAssemblyProfiler.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" - -#include "lldb/Symbol/UnwindTable.h" -#include +#include "lldb/Utility/UnwindAssemblyProfiler.h" // There is one UnwindTable object per ObjectFile. // It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile. From jingham at apple.com Wed Sep 22 21:01:19 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 23 Sep 2010 02:01:19 -0000 Subject: [Lldb-commits] [lldb] r114620 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ source/ source/Core/ source/Plugins/LanguageRuntime/ source/Plugins/LanguageRuntime/CPlusPlus/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/ Message-ID: <20100923020119.BC15B2A6C12C@llvm.org> Author: jingham Date: Wed Sep 22 21:01:19 2010 New Revision: 114620 URL: http://llvm.org/viewvc/llvm-project?rev=114620&view=rev Log: Committing the skeleton of Language runtime plugin classes. Added: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h lldb/trunk/include/lldb/Target/LanguageRuntime.h lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/source/Plugins/LanguageRuntime/ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h lldb/trunk/source/Target/CPPLanguageRuntime.cpp lldb/trunk/source/Target/LanguageRuntime.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Core/ValueObject.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/source/Core/PluginManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Sep 22 21:01:19 2010 @@ -73,6 +73,24 @@ //------------------------------------------------------------------ + // LanguageRuntime + //------------------------------------------------------------------ + static bool + RegisterPlugin (const char *name, + const char *description, + LanguageRuntimeCreateInstance create_callback); + + static bool + UnregisterPlugin (LanguageRuntimeCreateInstance create_callback); + + static LanguageRuntimeCreateInstance + GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx); + + static LanguageRuntimeCreateInstance + GetLanguageRuntimeCreateCallbackForPluginName (const char *name); + + + //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ static bool Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Wed Sep 22 21:01:19 2010 @@ -175,6 +175,15 @@ lldb::ValueObjectSP GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create); + + lldb::ValueObjectSP + GetDynamicValue () + { + return m_dynamic_value_sp; + } + + bool + SetDynamicValue (); protected: //------------------------------------------------------------------ @@ -198,6 +207,7 @@ // in that the summary is consed up by us, the object_desc_string is builtin. std::vector m_children; std::map m_synthetic_children; + lldb::ValueObjectSP m_dynamic_value_sp; bool m_value_is_valid:1, m_value_did_change:1, m_children_count_valid:1, Added: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=114620&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (added) +++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Wed Sep 22 21:01:19 2010 @@ -0,0 +1,50 @@ +//===-- CPPLanguageRuntime.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_CPPLanguageRuntime_h_ +#define liblldb_CPPLanguageRuntime_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/PluginInterface.h" +#include "lldb/lldb-private.h" +#include "lldb/Target/LanguageRuntime.h" + +namespace lldb_private { + +class CPPLanguageRuntime : + public LanguageRuntime +{ +public: + virtual + ~CPPLanguageRuntime(); + + virtual lldb::LanguageType + GetLanguageType () const + { + return lldb::eLanguageTypeC_plus_plus; + } + + virtual bool + IsVTableName (const char *name) = 0; + +protected: + //------------------------------------------------------------------ + // Classes that inherit from CPPLanguageRuntime can see and modify these + //------------------------------------------------------------------ + CPPLanguageRuntime(Process *process); +private: + DISALLOW_COPY_AND_ASSIGN (CPPLanguageRuntime); +}; + +} // namespace lldb_private + +#endif // liblldb_CPPLanguageRuntime_h_ Added: lldb/trunk/include/lldb/Target/LanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=114620&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/LanguageRuntime.h (added) +++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Wed Sep 22 21:01:19 2010 @@ -0,0 +1,47 @@ +//===-- LanguageRuntime.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_LanguageRuntime_h_ +#define liblldb_LanguageRuntime_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/PluginInterface.h" +#include "lldb/lldb-private.h" + +namespace lldb_private { + +class LanguageRuntime : + public PluginInterface +{ +public: + virtual + ~LanguageRuntime(); + + static LanguageRuntime* + FindPlugin (Process *process, lldb::LanguageType language); + + virtual lldb::LanguageType + GetLanguageType () const = 0; + +protected: + //------------------------------------------------------------------ + // Classes that inherit from LanguageRuntime can see and modify these + //------------------------------------------------------------------ + LanguageRuntime(Process *process); +private: + Process *m_process_ptr; + DISALLOW_COPY_AND_ASSIGN (LanguageRuntime); +}; + +} // namespace lldb_private + +#endif // liblldb_LanguageRuntime_h_ Added: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=114620&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (added) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Wed Sep 22 21:01:19 2010 @@ -0,0 +1,47 @@ +//===-- ObjCLanguageRuntime.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_ObjCLanguageRuntime_h_ +#define liblldb_ObjCLanguageRuntime_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/PluginInterface.h" +#include "lldb/lldb-private.h" +#include "lldb/Target/LanguageRuntime.h" + +namespace lldb_private { + +class ObjCLanguageRuntime : + public LanguageRuntime +{ +public: + virtual + ~ObjCLanguageRuntime(); + + virtual lldb::LanguageType + GetLanguageType () const + { + return lldb::eLanguageTypeObjC; + } + +protected: + //------------------------------------------------------------------ + // Classes that inherit from ObjCLanguageRuntime can see and modify these + //------------------------------------------------------------------ + ObjCLanguageRuntime(Process *process); +private: + DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime); +}; + +} // namespace lldb_private + +#endif // liblldb_ObjCLanguageRuntime_h_ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Sep 22 21:01:19 2010 @@ -1548,6 +1548,15 @@ virtual DynamicLoader * GetDynamicLoader (); + + virtual LanguageRuntime * + GetLanguageRuntime (lldb::LanguageType language); + + virtual CPPLanguageRuntime * + GetCPPLanguageRuntime (); + + virtual ObjCLanguageRuntime * + GetObjCLanguageRuntime (); bool IsRunning () const; @@ -1616,6 +1625,9 @@ ConstString m_target_triple; lldb::ABISP m_abi_sp; ObjCObjectPrinter m_objc_object_printer; + + typedef std::map LanguageRuntimeCollection; + LanguageRuntimeCollection m_language_runtimes; size_t RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const; 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=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Wed Sep 22 21:01:19 2010 @@ -40,6 +40,7 @@ typedef SharedPtr::Type InlineFunctionInfoSP; typedef SharedPtr::Type InputReaderSP; typedef SharedPtr::Type InstanceSettingsSP; + typedef SharedPtr::Type LanguageRuntimeSP; typedef SharedPtr::Type LineTableSP; typedef SharedPtr::Type ListenerSP; typedef SharedPtr::Type LogSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Wed Sep 22 21:01:19 2010 @@ -39,6 +39,7 @@ class BreakpointSite; class BreakpointSiteList; class Broadcaster; +class CPPLanguageRuntime; class ClangASTContext; class ClangExpression; class ClangExpressionDeclMap; @@ -76,6 +77,7 @@ class InlineFunctionInfo; class InputReader; class InstanceSettings; +class LanguageRuntime; class LineTable; class Listener; class Log; @@ -84,6 +86,7 @@ class Module; class ModuleList; class Mutex; +class ObjCLanguageRuntime; class ObjCObjectPrinter; class ObjectContainer; class ObjectFile; 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=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Wed Sep 22 21:01:19 2010 @@ -22,6 +22,7 @@ typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length); typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length); typedef LogChannel* (*LogChannelCreateInstance) (); + typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language); typedef Process* (*ProcessCreateInstance) (Target &target, Listener &listener); typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file); typedef SymbolVendor* (*SymbolVendorCreateInstance) (Module *module); // Module can be NULL for default system symbol vendor Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 22 21:01:19 2010 @@ -351,10 +351,20 @@ 49FB515E121481B000DF8983 /* DWARFExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */; }; 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; }; + 4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */; }; + 4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */; }; 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; }; 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; + 4CB4430B12491DDA00C13DC2 /* LanguageRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CB4430912491DDA00C13DC2 /* LanguageRuntime.h */; }; + 4CB4430C12491DDA00C13DC2 /* LanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */; }; + 4CB4436B124944B000C13DC2 /* ItaniumABILanguageRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CB44369124944B000C13DC2 /* ItaniumABILanguageRuntime.h */; }; + 4CB4436C124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4436A124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp */; }; + 4CB443BD1249920C00C13DC2 /* CPPLanguageRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */; }; + 4CB443BE1249920C00C13DC2 /* CPPLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */; }; + 4CB443F312499B5000C13DC2 /* ObjCLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */; }; + 4CB443F712499B6E00C13DC2 /* ObjCLanguageRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */; }; 69A01E211236C5D400C660B5 /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1B1236C5D400C660B5 /* Condition.cpp */; }; 69A01E221236C5D400C660B5 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; }; 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1E1236C5D400C660B5 /* Mutex.cpp */; }; @@ -961,6 +971,8 @@ 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSpec.h; path = include/lldb/Target/ThreadSpec.h; sourceTree = ""; }; 4C09CB73116BD98B00C7A725 /* CommandCompletions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandCompletions.h; path = include/lldb/Interpreter/CommandCompletions.h; sourceTree = ""; }; 4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandCompletions.cpp; path = source/Commands/CommandCompletions.cpp; sourceTree = ""; }; + 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV2.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp; sourceTree = ""; }; + 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV2.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h; sourceTree = ""; }; 4C43DEF9110641F300E55CBF /* ThreadPlanShouldStopHere.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanShouldStopHere.h; path = include/lldb/Target/ThreadPlanShouldStopHere.h; sourceTree = ""; }; 4C43DEFA110641F300E55CBF /* ThreadPlanShouldStopHere.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanShouldStopHere.cpp; path = source/Target/ThreadPlanShouldStopHere.cpp; sourceTree = ""; }; 4C43DF8511069BFD00E55CBF /* ThreadPlanStepInRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepInRange.h; path = include/lldb/Target/ThreadPlanStepInRange.h; sourceTree = ""; }; @@ -982,6 +994,14 @@ 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectApropos.h; path = source/Commands/CommandObjectApropos.h; sourceTree = ""; }; 4CAFCE001101216B00CA63DB /* ThreadPlanRunToAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanRunToAddress.h; path = include/lldb/Target/ThreadPlanRunToAddress.h; sourceTree = ""; }; 4CAFCE031101218900CA63DB /* ThreadPlanRunToAddress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanRunToAddress.cpp; path = source/Target/ThreadPlanRunToAddress.cpp; sourceTree = ""; }; + 4CB4430912491DDA00C13DC2 /* LanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LanguageRuntime.h; path = include/lldb/Target/LanguageRuntime.h; sourceTree = ""; }; + 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LanguageRuntime.cpp; path = source/Target/LanguageRuntime.cpp; sourceTree = ""; }; + 4CB44369124944B000C13DC2 /* ItaniumABILanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ItaniumABILanguageRuntime.h; path = LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h; sourceTree = ""; }; + 4CB4436A124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ItaniumABILanguageRuntime.cpp; path = LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp; sourceTree = ""; }; + 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CPPLanguageRuntime.h; path = include/lldb/Target/CPPLanguageRuntime.h; sourceTree = ""; }; + 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CPPLanguageRuntime.cpp; path = source/Target/CPPLanguageRuntime.cpp; sourceTree = ""; }; + 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjCLanguageRuntime.cpp; path = source/Target/ObjCLanguageRuntime.cpp; sourceTree = ""; }; + 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCLanguageRuntime.h; path = include/lldb/Target/ObjCLanguageRuntime.h; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; 4CEE62FA1145F2130064CF93 /* ProcessGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProcessGDBRemote.cpp; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp"; sourceTree = ""; }; 4CEE62FB1145F2130064CF93 /* ProcessGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemote.h"; sourceTree = ""; }; @@ -1180,6 +1200,7 @@ 493C63D711891A8000914D5E /* ABI */, 260C897210F57C5600BB2B04 /* Disassembler */, 260C897810F57C5600BB2B04 /* DynamicLoader */, + 4CB443651249446F00C13DC2 /* LanguageRuntime */, 260C897E10F57C5600BB2B04 /* ObjectContainer */, 260C898210F57C5600BB2B04 /* ObjectFile */, 260C898A10F57C5600BB2B04 /* Process */, @@ -1982,10 +2003,16 @@ children = ( 497E7B331188ED300065CCA1 /* ABI.h */, 497E7B9D1188F6690065CCA1 /* ABI.cpp */, + 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */, + 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */, 26BC7DF110F1B81A00F91463 /* DynamicLoader.h */, 26BC7DF210F1B81A00F91463 /* ExecutionContext.h */, 26BC7F3510F1B90C00F91463 /* ExecutionContext.cpp */, 26DAFD9711529BC7005A394E /* ExecutionContextScope.h */, + 4CB4430912491DDA00C13DC2 /* LanguageRuntime.h */, + 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */, + 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */, + 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */, 49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */, 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */, 495BBACF119A0DE700418BEA /* PathMappingList.h */, @@ -2142,6 +2169,49 @@ name = "MacOSX-i386"; sourceTree = ""; }; + 4C139EA0124A8AC7000BFF8D /* CPlusPlus */ = { + isa = PBXGroup; + children = ( + 4CB443661249448300C13DC2 /* ItaniumABI */, + ); + name = CPlusPlus; + sourceTree = ""; + }; + 4C139EA1124A8AD5000BFF8D /* ObjC */ = { + isa = PBXGroup; + children = ( + 4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */, + ); + name = ObjC; + sourceTree = ""; + }; + 4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */ = { + isa = PBXGroup; + children = ( + 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */, + 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */, + ); + name = AppleRuntimeV2; + sourceTree = ""; + }; + 4CB443651249446F00C13DC2 /* LanguageRuntime */ = { + isa = PBXGroup; + children = ( + 4C139EA0124A8AC7000BFF8D /* CPlusPlus */, + 4C139EA1124A8AD5000BFF8D /* ObjC */, + ); + name = LanguageRuntime; + sourceTree = ""; + }; + 4CB443661249448300C13DC2 /* ItaniumABI */ = { + isa = PBXGroup; + children = ( + 4CB44369124944B000C13DC2 /* ItaniumABILanguageRuntime.h */, + 4CB4436A124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp */, + ); + name = ItaniumABI; + sourceTree = ""; + }; 4CEE62F71145F1C70064CF93 /* GDB Remote */ = { isa = PBXGroup; children = ( @@ -2302,7 +2372,12 @@ 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */, 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */, 26C72C94124322890068DC16 /* SBStream.h in Headers */, + 4CB4430B12491DDA00C13DC2 /* LanguageRuntime.h in Headers */, + 4CB4436B124944B000C13DC2 /* ItaniumABILanguageRuntime.h in Headers */, + 4CB443BD1249920C00C13DC2 /* CPPLanguageRuntime.h in Headers */, + 4CB443F712499B6E00C13DC2 /* ObjCLanguageRuntime.h in Headers */, 96A6D9CA1249D98800250B38 /* ArchVolatileRegs-x86.h in Headers */, + 4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2767,8 +2842,13 @@ 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */, 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */, 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */, + 4CB4430C12491DDA00C13DC2 /* LanguageRuntime.cpp in Sources */, + 4CB4436C124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp in Sources */, + 4CB443BE1249920C00C13DC2 /* CPPLanguageRuntime.cpp in Sources */, + 4CB443F312499B5000C13DC2 /* ObjCLanguageRuntime.cpp in Sources */, 96A6D9C61249D96F00250B38 /* ArchVolatileRegs.cpp in Sources */, 96A6D9C91249D98800250B38 /* ArchVolatileRegs-x86.cpp in Sources */, + 4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Wed Sep 22 21:01:19 2010 @@ -392,8 +392,128 @@ } +#pragma mark LanguageRuntime +struct LanguageRuntimeInstance +{ + LanguageRuntimeInstance() : + name(), + description(), + create_callback(NULL) + { + } + + std::string name; + std::string description; + LanguageRuntimeCreateInstance create_callback; +}; + +typedef std::vector LanguageRuntimeInstances; + +static bool +AccessLanguageRuntimeInstances (PluginAction action, LanguageRuntimeInstance &instance, uint32_t index) +{ + static LanguageRuntimeInstances g_plugin_instances; + + switch (action) + { + case ePluginRegisterInstance: + if (instance.create_callback) + { + g_plugin_instances.push_back (instance); + return true; + } + break; + + case ePluginUnregisterInstance: + if (instance.create_callback) + { + LanguageRuntimeInstances::iterator pos, end = g_plugin_instances.end(); + for (pos = g_plugin_instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == instance.create_callback) + { + g_plugin_instances.erase(pos); + return true; + } + } + } + break; + + case ePluginGetInstanceAtIndex: + if (index < g_plugin_instances.size()) + { + instance = g_plugin_instances[index]; + return true; + } + break; + + default: + break; + } + return false; +} + + +bool +PluginManager::RegisterPlugin + ( + const char *name, + const char *description, + LanguageRuntimeCreateInstance create_callback + ) +{ + if (create_callback) + { + LanguageRuntimeInstance instance; + assert (name && name[0]); + instance.name = name; + if (description && description[0]) + instance.description = description; + instance.create_callback = create_callback; + return AccessLanguageRuntimeInstances (ePluginRegisterInstance, instance, 0); + } + return false; +} + +bool +PluginManager::UnregisterPlugin (LanguageRuntimeCreateInstance create_callback) +{ + if (create_callback) + { + LanguageRuntimeInstance instance; + instance.create_callback = create_callback; + return AccessLanguageRuntimeInstances (ePluginUnregisterInstance, instance, 0); + } + return false; +} + +LanguageRuntimeCreateInstance +PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx) +{ + LanguageRuntimeInstance instance; + if (AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx)) + return instance.create_callback; + return NULL; +} + +LanguageRuntimeCreateInstance +PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name) +{ + if (name && name[0]) + { + LanguageRuntimeInstance instance; + std::string ss_name(name); + for (uint32_t idx = 0; AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + { + if (instance.name == ss_name) + return instance.create_callback; + } + } + return NULL; +} + #pragma mark ObjectFile struct ObjectFileInstance Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Sep 22 21:01:19 2010 @@ -823,3 +823,17 @@ } return synthetic_child_sp; } + +bool +ValueObject::SetDynamicValue () +{ + if (!IsPointerOrReferenceType()) + return false; + + // Check that the runtime class is correct for determining the most specific class. + // If it is a C++ class, see if it is dynamic: + //if (!decl->isDynamicClass()) + // return false; + + return true; +} Added: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Wed Sep 22 21:01:19 2010 @@ -0,0 +1,111 @@ +//===-- ItaniumABILanguageRuntime.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ItaniumABILanguageRuntime.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/Symbol/ClangASTContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +static const char *pluginName = "ItaniumABILanguageRuntime"; +static const char *pluginDesc = "Itanium ABI for the C++ language"; +static const char *pluginShort = "language.itanium"; + +//------------------------------------------------------------------ +// Static Functions +//------------------------------------------------------------------ +lldb_private::LanguageRuntime * +ItaniumABILanguageRuntime::CreateInstance (Process *process, lldb::LanguageType language) +{ + // FIXME: We have to check the process and make sure we actually know that this process supports + // the Itanium ABI. + if (language == eLanguageTypeC_plus_plus) + return new ItaniumABILanguageRuntime (process); + else + return NULL; +} + +void +ItaniumABILanguageRuntime::Initialize() +{ + PluginManager::RegisterPlugin (pluginName, + pluginDesc, + CreateInstance); +} + +void +ItaniumABILanguageRuntime::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + +//------------------------------------------------------------------ +// PluginInterface protocol +//------------------------------------------------------------------ +const char * +ItaniumABILanguageRuntime::GetPluginName() +{ + return pluginName; +} + +const char * +ItaniumABILanguageRuntime::GetShortPluginName() +{ + return pluginShort; +} + +uint32_t +ItaniumABILanguageRuntime::GetPluginVersion() +{ + return 1; +} + +void +ItaniumABILanguageRuntime::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +ItaniumABILanguageRuntime::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +ItaniumABILanguageRuntime::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +bool +ItaniumABILanguageRuntime::IsVTableName (const char *name) +{ + if (name == NULL) + return false; + + // Can we maybe ask Clang about this? + if (strstr (name, "_vptr$") == name) + return true; + else + return false; +} Added: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Wed Sep 22 21:01:19 2010 @@ -0,0 +1,72 @@ +//===-- ItaniumABILanguageRuntime.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_ItaniumABILanguageRuntime_h_ +#define liblldb_ItaniumABILanguageRuntime_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/CPPLanguageRuntime.h" +#include "lldb/Core/Value.h" + +namespace lldb_private { + + class ItaniumABILanguageRuntime : + public lldb_private::CPPLanguageRuntime + { + public: + ~ItaniumABILanguageRuntime() { } + + virtual bool + IsVTableName (const char *name); + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb_private::LanguageRuntime * + CreateInstance (Process *process, lldb::LanguageType language); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + protected: + private: + ItaniumABILanguageRuntime(Process *process) : lldb_private::CPPLanguageRuntime(process) { } // Call CreateInstance instead. + }; + +} // namespace lldb_private + +#endif // liblldb_ItaniumABILanguageRuntime_h_ Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Wed Sep 22 21:01:19 2010 @@ -0,0 +1,98 @@ +//===-- AppleObjCRuntimeV2.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "AppleObjCRuntimeV2.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/Symbol/ClangASTContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +static const char *pluginName = "AppleObjCRuntimeV2"; +static const char *pluginDesc = "Apple Objective C Language Runtime - Version 2"; +static const char *pluginShort = "language.apple.objc.v2"; + +//------------------------------------------------------------------ +// Static Functions +//------------------------------------------------------------------ +lldb_private::LanguageRuntime * +AppleObjCRuntimeV2::CreateInstance (Process *process, lldb::LanguageType language) +{ + // FIXME: This should be a MacOS or iOS process, and we need to look for the OBJC section to make + // sure we aren't using the V1 runtime. + if (language == eLanguageTypeObjC) + return new AppleObjCRuntimeV2 (process); + else + return NULL; +} + +void +AppleObjCRuntimeV2::Initialize() +{ + PluginManager::RegisterPlugin (pluginName, + pluginDesc, + CreateInstance); +} + +void +AppleObjCRuntimeV2::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + +//------------------------------------------------------------------ +// PluginInterface protocol +//------------------------------------------------------------------ +const char * +AppleObjCRuntimeV2::GetPluginName() +{ + return pluginName; +} + +const char * +AppleObjCRuntimeV2::GetShortPluginName() +{ + return pluginShort; +} + +uint32_t +AppleObjCRuntimeV2::GetPluginVersion() +{ + return 1; +} + +void +AppleObjCRuntimeV2::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +AppleObjCRuntimeV2::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +AppleObjCRuntimeV2::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h Wed Sep 22 21:01:19 2010 @@ -0,0 +1,70 @@ +//===-- AppleObjCRuntimeV2.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_AppleObjCRuntimeV2_h_ +#define liblldb_AppleObjCRuntimeV2_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Core/Value.h" + +namespace lldb_private { + + class AppleObjCRuntimeV2 : + public lldb_private::ObjCLanguageRuntime + { + public: + ~AppleObjCRuntimeV2() { } + + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb_private::LanguageRuntime * + CreateInstance (Process *process, lldb::LanguageType language); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + protected: + private: + AppleObjCRuntimeV2(Process *process) : lldb_private::ObjCLanguageRuntime(process) { } // Call CreateInstance instead. + }; + +} // namespace lldb_private + +#endif // liblldb_AppleObjCRuntimeV2_h_ Added: lldb/trunk/source/Target/CPPLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (added) +++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Wed Sep 22 21:01:19 2010 @@ -0,0 +1,27 @@ +//===-- CPPLanguageRuntime.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/Target/CPPLanguageRuntime.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +CPPLanguageRuntime::~CPPLanguageRuntime() +{ +} + +CPPLanguageRuntime::CPPLanguageRuntime (Process *process) : + LanguageRuntime (process) +{ + +} \ No newline at end of file Added: lldb/trunk/source/Target/LanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Target/LanguageRuntime.cpp (added) +++ lldb/trunk/source/Target/LanguageRuntime.cpp Wed Sep 22 21:01:19 2010 @@ -0,0 +1,47 @@ +//===-- LanguageRuntime.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/Target/LanguageRuntime.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +LanguageRuntime* +LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language) +{ + std::auto_ptr language_runtime_ap; + LanguageRuntimeCreateInstance create_callback; + + for (uint32_t idx = 0; + (create_callback = PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) != NULL; + ++idx) + { + language_runtime_ap.reset (create_callback(process, language)); + + if (language_runtime_ap.get()) + return language_runtime_ap.release(); + } + + return NULL; +} + +//---------------------------------------------------------------------- +// Constructor +//---------------------------------------------------------------------- +LanguageRuntime::LanguageRuntime(Process *process) +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +LanguageRuntime::~LanguageRuntime() +{ +} Added: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=114620&view=auto ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (added) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Wed Sep 22 21:01:19 2010 @@ -0,0 +1,27 @@ +//===-- CPPLanguageRuntime.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/Target/ObjCLanguageRuntime.h" +#include "lldb/Core/PluginManager.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +ObjCLanguageRuntime::~ObjCLanguageRuntime() +{ +} + +ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) : + LanguageRuntime (process) +{ + +} \ No newline at end of file Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Sep 22 21:01:19 2010 @@ -21,6 +21,9 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Host/Host.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/CPPLanguageRuntime.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" @@ -460,6 +463,41 @@ return m_abi_sp.get(); } +LanguageRuntime * +Process::GetLanguageRuntime(lldb::LanguageType language) +{ + LanguageRuntimeCollection::iterator pos; + pos = m_language_runtimes.find (language); + if (pos == m_language_runtimes.end()) + { + lldb::LanguageRuntimeSP runtime(LanguageRuntime::FindPlugin(this, language)); + + m_language_runtimes[language] + = runtime; + return runtime.get(); + } + else + return (*pos).second.get(); +} + +CPPLanguageRuntime * +Process::GetCPPLanguageRuntime () +{ + LanguageRuntime *runtime = GetLanguageRuntime(eLanguageTypeC_plus_plus); + if (runtime != NULL && runtime->GetLanguageType() == eLanguageTypeC_plus_plus) + return static_cast (runtime); + return NULL; +} + +ObjCLanguageRuntime * +Process::GetObjCLanguageRuntime () +{ + LanguageRuntime *runtime = GetLanguageRuntime(eLanguageTypeObjC); + if (runtime != NULL && runtime->GetLanguageType() == eLanguageTypeObjC) + return static_cast (runtime); + return NULL; +} + BreakpointSiteList & Process::GetBreakpointSiteList() { Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=114620&r1=114619&r2=114620&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Wed Sep 22 21:01:19 2010 @@ -30,6 +30,8 @@ #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.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" +#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h" #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h" @@ -73,6 +75,8 @@ ABIMacOSX_i386::Initialize(); ABISysV_x86_64::Initialize(); DynamicLoaderMacOSXDYLD::Initialize(); + ItaniumABILanguageRuntime::Initialize(); + AppleObjCRuntimeV2::Initialize(); ObjectContainerUniversalMachO::Initialize(); ObjectFileMachO::Initialize(); ProcessGDBRemote::Initialize(); From scallanan at apple.com Wed Sep 22 22:01:22 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 23 Sep 2010 03:01:22 -0000 Subject: [Lldb-commits] [lldb] r114622 - in /lldb/trunk: ./ include/lldb/Expression/ include/lldb/Symbol/ scripts/ source/Expression/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ Message-ID: <20100923030122.EE8432A6C12C@llvm.org> Author: spyffe Date: Wed Sep 22 22:01:22 2010 New Revision: 114622 URL: http://llvm.org/viewvc/llvm-project?rev=114622&view=rev Log: Updated to latest LLVM. Major LLVM changes: - Sema is now exported (and there was much rejoicing.) - Storage classes are now centrally defined. Also fixed some bugs that the new LLVM picked up. Modified: lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Expression/ClangExpressionParser.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Expression/ASTResultSynthesizer.cpp lldb/trunk/source/Expression/ASTStructExtractor.cpp lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Expression/IRToDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h (original) +++ lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h Wed Sep 22 22:01:22 2010 @@ -128,7 +128,6 @@ clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer. clang::SemaConsumer *m_passthrough_sema; ///< The SemaConsumer down the chain, for passthrough. NULL if it's an ASTConsumer. clang::Sema *m_sema; ///< The Sema to use. - clang::Action *m_action; ///< The Sema to use, cast to an Action so it's usable. }; } Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Wed Sep 22 22:01:22 2010 @@ -10,6 +10,7 @@ #ifndef liblldb_ClangASTSource_h_ #define liblldb_ClangASTSource_h_ +#include "clang/Basic/IdentifierTable.h" #include "clang/Sema/ExternalSemaSource.h" namespace lldb_private { @@ -88,8 +89,13 @@ /// @return /// Whatever SetExternalVisibleDeclsForName returns. //------------------------------------------------------------------ - clang::DeclContext::lookup_result FindExternalVisibleDeclsByName(const clang::DeclContext *DC, - clang::DeclarationName Name); + clang::DeclContextLookupResult FindExternalVisibleDeclsByName(const clang::DeclContext *DC, + clang::DeclarationName Name); + + //------------------------------------------------------------------ + /// Interface stub. + //------------------------------------------------------------------ + void MaterializeVisibleDecls(const clang::DeclContext *DC); //------------------------------------------------------------------ /// Interface stub that returns true. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Wed Sep 22 22:01:22 2010 @@ -173,7 +173,6 @@ ClangExpression &m_expr; ///< The expression to be parsed std::string m_target_triple; ///< The target triple used to initialize LLVM - std::auto_ptr m_diagnostic_buffer; ///< The container for errors produced by the compiler std::auto_ptr m_compiler; ///< The Clang compiler used to parse expressions into IR std::auto_ptr m_builtin_context; ///< Context for Clang built-ins std::auto_ptr m_ast_context; ///< The AST context used to hold types and names for the parser Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Sep 22 22:01:22 2010 @@ -186,14 +186,14 @@ AddMethodToCXXRecordType (clang::ASTContext *ast_context, void *record_opaque_type, const char *name, - void *method_opaque_type, + void *method_type, lldb::AccessType access, bool is_virtual); clang::CXXMethodDecl * AddMethodToCXXRecordType (void *record_opaque_type, const char *name, - void *method_opaque_type, + void *method_type, lldb::AccessType access, bool is_virtual) @@ -201,7 +201,7 @@ return ClangASTContext::AddMethodToCXXRecordType(getASTContext(), record_opaque_type, name, - method_opaque_type, + method_type, access, is_virtual); } Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=114622&r1=114621&r2=114622&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=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Wed Sep 22 22:01:22 2010 @@ -25,15 +25,14 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "'{2010-08-02T16:00}'"; +our $llvm_revision = "'{2010-09-22T21:20}'"; our $llvm_source_dir = "$ENV{SRCROOT}"; our $cc = "$ENV{DEVELOPER_BIN_DIR}/gcc-4.2"; our $cxx = "$ENV{DEVELOPER_BIN_DIR}/g++-4.2"; our @archs = split (/\s+/, $ENV{ARCHS}); our @archive_files = ( - "$llvm_configuration/lib/libplugin_llvmc_Base.a", - "$llvm_configuration/lib/libplugin_llvmc_Clang.a", + "$llvm_configuration/lib/libclang.a", "$llvm_configuration/lib/libclangAnalysis.a", "$llvm_configuration/lib/libclangAST.a", "$llvm_configuration/lib/libclangBasic.a", @@ -45,6 +44,7 @@ "$llvm_configuration/lib/libclangRewrite.a", "$llvm_configuration/lib/libclangParse.a", "$llvm_configuration/lib/libclangSema.a", + "$llvm_configuration/lib/libclangSerialization.a", "$llvm_configuration/lib/libCompilerDriver.a", "$llvm_configuration/lib/libEnhancedDisassembly.a", "$llvm_configuration/lib/libLLVMAnalysis.a", @@ -407,6 +407,7 @@ } close (FILES); do_command ("libtool -static -o '$arch_output_file' -filelist '$files'"); + do_command ("ranlib '$arch_output_file'"); foreach $object_dir (@object_dirs) { Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Wed Sep 22 22:01:22 2010 @@ -14,9 +14,7 @@ #include "clang/AST/DeclGroup.h" #include "clang/AST/Expr.h" #include "clang/AST/Stmt.h" -#include "clang/Parse/Action.h" #include "clang/Parse/Parser.h" -#include "clang/Parse/Scope.h" #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" #include "lldb/Core/Log.h" @@ -30,8 +28,7 @@ m_ast_context (NULL), m_passthrough (passthrough), m_passthrough_sema (NULL), - m_sema (NULL), - m_action (NULL) + m_sema (NULL) { if (!m_passthrough) return; @@ -73,8 +70,7 @@ if (m_ast_context && function_decl && - !strcmp(function_decl->getNameAsCString(), - "___clang_expr")) + !function_decl->getNameInfo().getAsString().compare("___clang_expr")) { SynthesizeResult(function_decl); } @@ -176,8 +172,8 @@ &result_id, expr_qual_type, NULL, - VarDecl::Static, - VarDecl::Static); + SC_Static, + SC_Static); if (!result_decl) return false; @@ -187,27 +183,24 @@ /////////////////////////////// // call AddInitializerToDecl // - - Parser::DeclPtrTy result_decl_ptr; - result_decl_ptr.set(result_decl); - - m_action->AddInitializerToDecl(result_decl_ptr, Parser::ExprArg(*m_action, last_expr)); + + m_sema->AddInitializerToDecl(result_decl, last_expr); ///////////////////////////////// // call ConvertDeclToDeclGroup // - Parser::DeclGroupPtrTy result_decl_group_ptr; + Sema::DeclGroupPtrTy result_decl_group_ptr; - result_decl_group_ptr = m_action->ConvertDeclToDeclGroup(result_decl_ptr); + result_decl_group_ptr = m_sema->ConvertDeclToDeclGroup(result_decl); //////////////////////// // call ActOnDeclStmt // - Parser::OwningStmtResult result_initialization_stmt_result(m_action->ActOnDeclStmt(result_decl_group_ptr, - SourceLocation(), - SourceLocation())); + StmtResult result_initialization_stmt_result(m_sema->ActOnDeclStmt(result_decl_group_ptr, + SourceLocation(), + SourceLocation())); //////////////////////////////////////////////// // replace the old statement with the new one @@ -269,7 +262,6 @@ ASTResultSynthesizer::InitializeSema(Sema &S) { m_sema = &S; - m_action = reinterpret_cast(m_sema); if (m_passthrough_sema) m_passthrough_sema->InitializeSema(S); @@ -279,7 +271,6 @@ ASTResultSynthesizer::ForgetSema() { m_sema = NULL; - m_action = NULL; if (m_passthrough_sema) m_passthrough_sema->ForgetSema(); Modified: lldb/trunk/source/Expression/ASTStructExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTStructExtractor.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTStructExtractor.cpp (original) +++ lldb/trunk/source/Expression/ASTStructExtractor.cpp Wed Sep 22 22:01:22 2010 @@ -15,9 +15,8 @@ #include "clang/AST/Expr.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Stmt.h" -#include "clang/Parse/Action.h" #include "clang/Parse/Parser.h" -#include "clang/Parse/Scope.h" +#include "clang/Sema/Sema.h" #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" #include "lldb/Core/Log.h" @@ -111,7 +110,7 @@ if (m_ast_context && function_decl && - !m_function.m_wrapper_function_name.compare(function_decl->getNameAsCString())) + !m_function.m_wrapper_function_name.compare(function_decl->getNameAsString().c_str())) { ExtractFromFunctionDecl(function_decl); } Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Sep 22 22:01:22 2010 @@ -74,6 +74,11 @@ return SetExternalVisibleDeclsForName(DC, Name, Decls); } +void ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC) +{ + return; +} + // This is used to support iterating through an entire lexical context, // which isn't something the debugger should ever need to do. bool ClangASTSource::FindExternalLexicalDecls(const DeclContext *DC, llvm::SmallVectorImpl &Decls) { @@ -94,8 +99,8 @@ ii, QualType::getFromOpaquePtr(type), 0, - VarDecl::Static, - VarDecl::Static); + SC_Static, + SC_Static); Decls.push_back(Decl); return Decl; @@ -108,8 +113,8 @@ Name.getAsIdentifierInfo(), QualType::getFromOpaquePtr(type), NULL, - FunctionDecl::Static, - FunctionDecl::Static, + SC_Static, + SC_Static, false, true); @@ -138,8 +143,8 @@ NULL, ArgQT, NULL, - ParmVarDecl::Static, - ParmVarDecl::Static, + SC_Static, + SC_Static, NULL); } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 22 22:01:22 2010 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "clang/AST/DeclarationName.h" #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Core/Error.h" @@ -1205,12 +1206,12 @@ false, ClangASTContext::GetTypeQualifiers(copied_type)); - ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, - copied_type, - "___clang_expr", - method_type, - lldb::eAccessPublic, - false); + ClangASTContext::AddMethodToCXXRecordType(parser_ast_context, + copied_type, + "___clang_expr", + method_type, + lldb::eAccessPublic, + false); } context.AddTypeDecl(copied_type); Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Sep 22 22:01:22 2010 @@ -43,8 +43,8 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/VerifyDiagnosticsClient.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Parse/ParseAST.h" #include "clang/Rewrite/FrontendActions.h" -#include "clang/Sema/ParseAST.h" #include "clang/Sema/SemaConsumer.h" #include "llvm/ADT/StringRef.h" @@ -239,8 +239,7 @@ // 4. Set up the diagnostic buffer for reporting errors - m_diagnostic_buffer.reset(new clang::TextDiagnosticBuffer); - m_compiler->getDiagnostics().setClient(m_diagnostic_buffer.get()); + m_compiler->getDiagnostics().setClient(new clang::TextDiagnosticBuffer); // 5. Set up the source management objects inside the compiler @@ -288,12 +287,14 @@ unsigned ClangExpressionParser::Parse (Stream &stream) { - m_diagnostic_buffer->FlushDiagnostics (m_compiler->getDiagnostics()); + TextDiagnosticBuffer *diag_buf = static_cast(m_compiler->getDiagnostics().getClient()); + + diag_buf->FlushDiagnostics (m_compiler->getDiagnostics()); MemoryBuffer *memory_buffer = MemoryBuffer::getMemBufferCopy(m_expr.Text(), __FUNCTION__); FileID memory_buffer_file_id = m_compiler->getSourceManager().createMainFileIDForMemBuffer (memory_buffer); - m_diagnostic_buffer->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor()); + diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor()); ASTConsumer *ast_transformer = m_expr.ASTTransformer(m_code_generator.get()); @@ -302,21 +303,21 @@ else ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext()); - m_diagnostic_buffer->EndSourceFile(); + diag_buf->EndSourceFile(); TextDiagnosticBuffer::const_iterator diag_iterator; int num_errors = 0; - for (diag_iterator = m_diagnostic_buffer->warn_begin(); - diag_iterator != m_diagnostic_buffer->warn_end(); + for (diag_iterator = diag_buf->warn_begin(); + diag_iterator != diag_buf->warn_end(); ++diag_iterator) stream.Printf("warning: %s\n", (*diag_iterator).second.c_str()); num_errors = 0; - for (diag_iterator = m_diagnostic_buffer->err_begin(); - diag_iterator != m_diagnostic_buffer->err_end(); + for (diag_iterator = diag_buf->err_begin(); + diag_iterator != diag_buf->err_end(); ++diag_iterator) { num_errors++; Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Sep 22 22:01:22 2010 @@ -478,7 +478,7 @@ IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions, const char *func_name) : - ModulePass(&ID), + ModulePass(ID), m_checker_functions(checker_functions), m_func_name(func_name) { Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Sep 22 22:01:22 2010 @@ -34,7 +34,7 @@ const TargetData *target_data, bool resolve_vars, const char *func_name) : - ModulePass(&ID), + ModulePass(ID), m_decl_map(decl_map), m_target_data(target_data), m_sel_registerName(NULL), @@ -728,12 +728,22 @@ static bool isGuardVariableRef(Value *V) { - ConstantExpr *C = dyn_cast(V); + Constant *C; - if (!C || C->getOpcode() != Instruction::BitCast) + if (!(C = dyn_cast(V))) return false; - GlobalVariable *GV = dyn_cast(C->getOperand(0)); + ConstantExpr *CE; + + if ((CE = dyn_cast(V))) + { + if (CE->getOpcode() != Instruction::BitCast) + return false; + + C = CE->getOperand(0); + } + + GlobalVariable *GV = dyn_cast(C); if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV")) return false; Modified: lldb/trunk/source/Expression/IRToDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRToDWARF.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRToDWARF.cpp (original) +++ lldb/trunk/source/Expression/IRToDWARF.cpp Wed Sep 22 22:01:22 2010 @@ -30,7 +30,7 @@ lldb_private::ClangExpressionDeclMap *decl_map, lldb_private::StreamString &strm, const char *func_name) : - ModulePass(&ID), + ModulePass(ID), m_local_vars(local_vars), m_decl_map(decl_map), m_strm(strm), Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 22 22:01:22 2010 @@ -1126,7 +1126,7 @@ unsigned type_quals = 0; AccessType accessibility = default_accessibility; - clang::FunctionDecl::StorageClass storage = clang::FunctionDecl::None;//, Extern, Static, PrivateExtern + clang::FunctionDecl::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern const char *type_name_cstr = NULL; ConstString type_name_dbstr; @@ -1157,10 +1157,10 @@ case DW_AT_external: if (form_value.Unsigned()) { - if (storage == clang::FunctionDecl::None) - storage = clang::FunctionDecl::Extern; + if (storage == clang::SC_None) + storage = clang::SC_Extern; else - storage = clang::FunctionDecl::PrivateExtern; + storage = clang::SC_PrivateExtern; } break; case DW_AT_inline: @@ -2058,7 +2058,7 @@ bool is_artificial = false; // one of None, Auto, Register, Extern, Static, PrivateExtern - clang::VarDecl::StorageClass storage = clang::VarDecl::None; + clang::StorageClass storage = clang::SC_None; uint32_t i; for (i=0; iGetAttributes(this, dwarf_cu, NULL, attributes); @@ -2871,10 +2871,10 @@ case DW_AT_external: if (form_value.Unsigned()) { - if (storage == clang::FunctionDecl::None) - storage = clang::FunctionDecl::Extern; + if (storage == clang::SC_None) + storage = clang::SC_Extern; else - storage = clang::FunctionDecl::PrivateExtern; + storage = clang::SC_PrivateExtern; } break; case DW_AT_inline: Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 22 22:01:22 2010 @@ -847,15 +847,16 @@ QualType method_qual_type(QualType::getFromOpaquePtr(method_opaque_type)); CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, - cxx_record_decl, - SourceLocation(), - DeclarationName(&identifier_table->get(name)), - method_qual_type, + cxx_record_decl, + DeclarationNameInfo(DeclarationName(&identifier_table->get(name)), SourceLocation()), + method_qual_type, NULL); - cxx_method_decl->setAccess (ConvertAccessTypeToAccessSpecifier (access)); - cxx_method_decl->setVirtualAsWritten (is_virtual); - + clang::AccessSpecifier AS = ConvertAccessTypeToAccessSpecifier(access); + + cxx_method_decl->setAccess(AS); + cxx_method_decl->setVirtualAsWritten(is_virtual); + // Populate the method decl with parameter decls clang::Type *method_type(method_qual_type.getTypePtr()); @@ -881,8 +882,8 @@ NULL, // anonymous method_funprototy->getArgType(param_index), NULL, - VarDecl::Auto, - VarDecl::Auto, + SC_Auto, + SC_Auto, NULL); } @@ -946,7 +947,7 @@ if (bitfield_bit_size != 0) { APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size); - bit_width = new (*ast_context)IntegerLiteral (bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); + bit_width = new (*ast_context)IntegerLiteral (*ast_context, bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); } FieldDecl *field = FieldDecl::Create (*ast_context, record_decl, @@ -1277,7 +1278,7 @@ if (bitfield_bit_size != 0) { APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size); - bit_width = new (*ast_context)IntegerLiteral (bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); + bit_width = new (*ast_context)IntegerLiteral (*ast_context, bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); } ObjCIvarDecl *field = ObjCIvarDecl::Create (*ast_context, Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=114622&r1=114621&r2=114622&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Sep 22 22:01:22 2010 @@ -479,7 +479,7 @@ { if (enum_pos->getInitVal() == enum_value) { - s->Printf("%s", enum_pos->getNameAsCString()); + s->Printf("%s", enum_pos->getNameAsString().c_str()); return; } } @@ -655,7 +655,7 @@ { if (enum_pos->getInitVal() == enum_value) { - s->PutCString (enum_pos->getNameAsCString()); + s->PutCString (enum_pos->getNameAsString().c_str()); return true; } } From johnny.chen at apple.com Thu Sep 23 10:57:32 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Sep 2010 15:57:32 -0000 Subject: [Lldb-commits] [lldb] r114649 - /lldb/trunk/test/global_variables/TestGlobalVariables.py Message-ID: <20100923155732.30A642A6C12C@llvm.org> Author: johnny Date: Thu Sep 23 10:57:32 2010 New Revision: 114649 URL: http://llvm.org/viewvc/llvm-project?rev=114649&view=rev Log: Changed 'frame variable' output to match '(const char *)' instead of '(char const *)'. Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/global_variables/TestGlobalVariables.py?rev=114649&r1=114648&r2=114649&view=diff ============================================================================== --- lldb/trunk/test/global_variables/TestGlobalVariables.py (original) +++ lldb/trunk/test/global_variables/TestGlobalVariables.py Thu Sep 23 10:57:32 2010 @@ -42,11 +42,11 @@ # Check that GLOBAL scopes are indicated for the variables. self.expect("frame variable -s -g -a", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['GLOBAL: (char const *) g_file_static_cstr', - '"g_file_static_cstr"', - 'GLOBAL: (int) g_file_global_int = 42', - 'GLOBAL: (char const *) g_file_global_cstr', - '"g_file_global_cstr"']) + substrs = ['GLOBAL: (int) g_file_global_int = 42', + 'GLOBAL: (const char *) g_file_global_cstr', + '"g_file_global_cstr"', + 'GLOBAL: (const char *) g_file_static_cstr', + '"g_file_static_cstr"']) if __name__ == '__main__': From johnny.chen at apple.com Thu Sep 23 11:04:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Sep 2010 16:04:46 -0000 Subject: [Lldb-commits] [lldb] r114652 - /lldb/trunk/test/function_types/TestFunctionTypes.py Message-ID: <20100923160446.47A242A6C12C@llvm.org> Author: johnny Date: Thu Sep 23 11:04:46 2010 New Revision: 114652 URL: http://llvm.org/viewvc/llvm-project?rev=114652&view=rev Log: Changed 'frame variable' output to match '(const char *)' instead of '(char const *)'. Modified: lldb/trunk/test/function_types/TestFunctionTypes.py Modified: lldb/trunk/test/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/function_types/TestFunctionTypes.py?rev=114652&r1=114651&r2=114652&view=diff ============================================================================== --- lldb/trunk/test/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/function_types/TestFunctionTypes.py Thu Sep 23 11:04:46 2010 @@ -42,7 +42,7 @@ # Check that the 'callback' variable display properly. self.expect("frame variable callback", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int (*)(char const *)) callback =') + startstr = '(int (*)(const char *)) callback =') # And that we can break on the callback function. self.runCmd("breakpoint set -n string_not_empty", BREAKPOINT_CREATED) From johnny.chen at apple.com Thu Sep 23 11:49:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Sep 2010 16:49:40 -0000 Subject: [Lldb-commits] [lldb] r114660 - /lldb/trunk/test/types/basic_type.cpp Message-ID: <20100923164940.E5A602A6C12C@llvm.org> Author: johnny Date: Thu Sep 23 11:49:40 2010 New Revision: 114660 URL: http://llvm.org/viewvc/llvm-project?rev=114660&view=rev Log: Fixed a typo in member name; should be m_b, not b_a. Modified: lldb/trunk/test/types/basic_type.cpp Modified: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=114660&r1=114659&r2=114660&view=diff ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (original) +++ lldb/trunk/test/types/basic_type.cpp Thu Sep 23 11:49:40 2010 @@ -137,9 +137,9 @@ printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); - printf ("(a_class*) a_class_ptr = %p, a_class_ptr->b_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_b = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); - printf ("(a_class&) a_class_ref = %p, a_class_ref.b_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_b = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); From jingham at apple.com Thu Sep 23 12:40:12 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 23 Sep 2010 17:40:12 -0000 Subject: [Lldb-commits] [lldb] r114674 - in /lldb/trunk: include/lldb/Target/StackFrame.h include/lldb/Target/StackFrameList.h include/lldb/Target/Thread.h source/Target/StackFrame.cpp source/Target/StackFrameList.cpp source/Target/Thread.cpp Message-ID: <20100923174012.D7B7F2A6C12C@llvm.org> Author: jingham Date: Thu Sep 23 12:40:12 2010 New Revision: 114674 URL: http://llvm.org/viewvc/llvm-project?rev=114674&view=rev Log: Add GetSP to the StackFrame. Modified: lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/include/lldb/Target/StackFrameList.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/StackFrameList.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Thu Sep 23 12:40:12 2010 @@ -143,6 +143,9 @@ virtual void Calculate (ExecutionContext &exe_ctx); + + lldb::StackFrameSP + GetSP (); protected: friend class StackFrameList; Modified: lldb/trunk/include/lldb/Target/StackFrameList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameList.h?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrameList.h (original) +++ lldb/trunk/include/lldb/Target/StackFrameList.h Thu Sep 23 12:40:12 2010 @@ -58,6 +58,9 @@ void Dump (Stream *s); + + lldb::StackFrameSP + GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); protected: Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Thu Sep 23 12:40:12 2010 @@ -611,6 +611,9 @@ virtual void Calculate (ExecutionContext &exe_ctx); + + lldb::StackFrameSP + GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); protected: Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Thu Sep 23 12:40:12 2010 @@ -679,4 +679,10 @@ if (!m_disassembly.GetString().empty()) return true; return false; +} + +lldb::StackFrameSP +StackFrame::GetSP () +{ + return m_thread.GetStackFrameSPForStackFramePtr (this); } \ No newline at end of file Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Thu Sep 23 12:40:12 2010 @@ -513,3 +513,23 @@ } + +lldb::StackFrameSP +StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) +{ + const_iterator pos; + const_iterator begin = m_frames.begin(); + const_iterator end = m_frames.end(); + lldb::StackFrameSP ret_sp; + + for (pos = begin; pos != end; ++pos) + { + if (pos->get() == stack_frame_ptr) + { + ret_sp = (*pos); + break; + } + } + return ret_sp; +} + Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114674&r1=114673&r2=114674&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Thu Sep 23 12:40:12 2010 @@ -1129,3 +1129,8 @@ { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; +lldb::StackFrameSP +Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) +{ + return GetStackFrameList().GetStackFrameSPForStackFramePtr (stack_frame_ptr); +} From johnny.chen at apple.com Thu Sep 23 18:35:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Sep 2010 23:35:28 -0000 Subject: [Lldb-commits] [lldb] r114708 - in /lldb/trunk/test: lldbtest.py types/TestBasicTypes.py types/basic_type.cpp types/int.cpp types/long.cpp Message-ID: <20100923233528.612B82A6C12C@llvm.org> Author: johnny Date: Thu Sep 23 18:35:28 2010 New Revision: 114708 URL: http://llvm.org/viewvc/llvm-project?rev=114708&view=rev Log: Added a generic_type_tester() to the TestBasicTypes class to be used for testing various combinations of displaying variales of basic types. The generic_type_tester() works by first capturing the golden output produced by the printf stmts of ./a.out, creating a list of (var, value) pairs, and then running the a.out to a stop point, and comparing the 'frame variable var' output against the list of (var, value) pairs. Modified int_type() and added long_type() to use generic_type_tester(). Also modified TestBase.expect() such that substring matching also return ok if the substring starts at the 0-th position. Added: lldb/trunk/test/types/long.cpp Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/types/TestBasicTypes.py lldb/trunk/test/types/basic_type.cpp lldb/trunk/test/types/int.cpp Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114708&r1=114707&r2=114708&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Sep 23 18:35:28 2010 @@ -483,7 +483,7 @@ keepgoing = matched if matching else not matched if substrs and keepgoing: for str in substrs: - matched = output.find(str) > 0 + matched = output.find(str) != -1 if trace: print >> sys.stderr, "%s sub string: %s" % (heading, str) print >> sys.stderr, "Matched" if matched else "Not matched" Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114708&r1=114707&r2=114708&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Thu Sep 23 18:35:28 2010 @@ -3,14 +3,22 @@ """ import os, time +import re import unittest2 import lldb from lldbtest import * +def Msg(var, val): + return "'frame variable %s' matches the compiler's output: %s" % (var, val) + class BasicTypesTestCase(TestBase): mydir = "types" + # This is the pattern by design to match the " var = 'value'" output from + # printf() stmts (see basic_type.cpp). + pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") + def test_int_type_with_dsym(self): """Test that int-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -25,17 +33,82 @@ self.setTearDownCleanup(dictionary=d) self.int_type() + def test_long_type_with_dsym(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + + def test_long_type_with_dwarf(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + def int_type(self): """Test that int-type variables are displayed correctly.""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.generic_type_tester("int") - self.runCmd("breakpoint set --name Puts") + def long_type(self): + """Test that long-type variables are displayed correctly.""" + self.generic_type_tester("long") + + def generic_type_tester(self, type): + """Test that variables with basic types are displayed correctly.""" + + # First, capture the golden output emitted by the oracle, i.e., the + # series of printf statements. + go = system("./a.out") + # This golden list contains a list of (variable, value) pairs extracted + # from the golden output. + gl = [] + + # Scan the golden output line by line, looking for the pattern: + # + # variable = 'value' + # + # Filter out the following lines, for the time being: + # + # 'a_ref = ...' + # 'a_class_ref.m_a = ...' + # 'a_class_ref.m_b = ...' + # 'a_struct_ref.a = ...' + # 'a_struct_ref.b = ...' + # 'a_union_zero_ref.a = ...' + # 'a_union_nonzero_ref.u.a = ...' + # + # rdar://problem/8471016 frame variable a_ref should display the referenced value as well + # rdar://problem/8470987 frame variable a_class_ref.m_a does not work + notnow = set(['a_ref', + 'a_class_ref.m_a', 'a_class_ref.m_b', + 'a_struct_ref.a', 'a_struct_ref.b', + 'a_union_zero_ref.a', 'a_union_nonzero_ref.u.a']) + for line in go.split(os.linesep): + match = self.pattern.search(line) + if match: + var, val = match.group(1), match.group(2) + if var in notnow: + continue + gl.append((var, val)) + #print "golden list:", gl + # Bring the program to the point where we can issue a series of + # 'frame variable' command. + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("breakpoint set --name Puts") self.runCmd("run", RUN_SUCCEEDED) - self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) - self.runCmd("frame variable a") + # Now iterate through the golden list, comparing against the output from + # 'frame variable var'. + for var, val in gl: + self.runCmd("frame variable %s" % var) + output = self.res.GetOutput() + self.expect(output, Msg(var, val), exe=False, + patterns = ["\(%s.*\)" % type], + substrs = [" %s = %s" % (var, val)]) if __name__ == '__main__': Modified: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=114708&r1=114707&r2=114708&view=diff ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (original) +++ lldb/trunk/test/types/basic_type.cpp Thu Sep 23 18:35:28 2010 @@ -125,8 +125,8 @@ #ifdef T_PRINTF_FORMAT printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); - printf ("%s*: a = %p => '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); - printf ("%s&: a = %p => '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); + printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); + printf ("%s&: @%p => a_ref = '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); printf ("%s[2]: a_array_bounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[0]); printf ("%s[2]: a_array_bounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[1]); @@ -152,9 +152,9 @@ printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); - printf ("(a_union_nonzero_t) a_union_nonzero.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); - printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); - printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); + printf ("(a_union_nonzero_t) a_union_nonzero.u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); + printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); + printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.u.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); printf ("(a_struct_t[2]) a_struct_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].a); printf ("(a_struct_t[2]) a_struct_array_bounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].b); Modified: lldb/trunk/test/types/int.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/int.cpp?rev=114708&r1=114707&r2=114708&view=diff ============================================================================== --- lldb/trunk/test/types/int.cpp (original) +++ lldb/trunk/test/types/int.cpp Thu Sep 23 18:35:28 2010 @@ -3,7 +3,7 @@ #define T_VALUE_1 11001110 #define T_VALUE_2 22002220 #define T_VALUE_3 33003330 -#define T_VALUE_4 44044440 +#define T_VALUE_4 44004440 #define T_PRINTF_FORMAT "%i" #include "basic_type.cpp" Added: lldb/trunk/test/types/long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/long.cpp?rev=114708&view=auto ============================================================================== --- lldb/trunk/test/types/long.cpp (added) +++ lldb/trunk/test/types/long.cpp Thu Sep 23 18:35:28 2010 @@ -0,0 +1,9 @@ +#define T long +#define T_CSTR "long" +#define T_VALUE_1 110011101111 +#define T_VALUE_2 220022202222 +#define T_VALUE_3 330033303333 +#define T_VALUE_4 440044404444 +#define T_PRINTF_FORMAT "%ld" + +#include "basic_type.cpp" From gclayton at apple.com Fri Sep 24 00:15:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 24 Sep 2010 05:15:53 -0000 Subject: [Lldb-commits] [lldb] r114722 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h lldb.xcodeproj/project.pbxproj source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp Message-ID: <20100924051554.179222A6C12C@llvm.org> Author: gclayton Date: Fri Sep 24 00:15:53 2010 New Revision: 114722 URL: http://llvm.org/viewvc/llvm-project?rev=114722&view=rev Log: Added the ability to create an objective C method for an objective C interface in ClangASTContext. Also added two bool returning functions that indicated if an opaque clang qual type is a CXX class type, and if it is an ObjC class type. Objective C classes now will get their methods added lazily as they are encountered. The reason for this is currently, unlike C++, the DW_TAG_structure_type and owns the ivars, doesn't not also contain the member functions. This means when we parse the objective C class interface we either need to find all functions whose names start with "+[CLASS_NAME" or "-[CLASS_NAME" and add them all to the class, or when we parse each objective C function, we slowly add it to the class interface definition. Since objective C's class doesn't change internal bits according to whether it has certain types of member functions (like C++ does if it has virtual functions, or if it has user ctors/dtors), I currently chose to lazily populate the class when each functions is parsed. Another issue we run into with ObjC method declarations is the "self" and "_cmd" implicit args are not marked as artificial in the DWARF (DW_AT_artifical), so we currently have to look for the parameters by name if we are trying to omit artificial function args if the language of the compile unit is ObjC or ObjC++. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Sep 24 00:15:53 2010 @@ -174,12 +174,12 @@ lldb::AccessType access, uint32_t bitfield_bit_size) { - return ClangASTContext::AddFieldToRecordType(getASTContext(), - record_qual_type, - name, - field_type, - access, - bitfield_bit_size); + return ClangASTContext::AddFieldToRecordType (getASTContext(), + record_qual_type, + name, + field_type, + access, + bitfield_bit_size); } static clang::CXXMethodDecl * @@ -188,22 +188,28 @@ const char *name, void *method_type, lldb::AccessType access, - bool is_virtual); + bool is_virtual, + bool is_static, + bool is_inline); clang::CXXMethodDecl * AddMethodToCXXRecordType (void *record_opaque_type, const char *name, void *method_type, lldb::AccessType access, - bool is_virtual) + bool is_virtual, + bool is_static, + bool is_inline) { - return ClangASTContext::AddMethodToCXXRecordType(getASTContext(), - record_opaque_type, - name, - method_type, - access, - is_virtual); + return ClangASTContext::AddMethodToCXXRecordType (getASTContext(), + record_opaque_type, + name, + method_type, + access, + is_virtual, + is_static, + is_inline); } bool @@ -267,7 +273,28 @@ ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, bool check_superclass); - + + static clang::ObjCMethodDecl * + AddMethodToObjCObjectType (clang::ASTContext *ast_context, + void *class_opaque_type, + const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") + void *method_opaque_type, + lldb::AccessType access); + + clang::ObjCMethodDecl * + AddMethodToObjCObjectType (void *class_opaque_type, + const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") + void *method_opaque_type, + lldb::AccessType access) + { + return AddMethodToObjCObjectType (getASTContext(), + class_opaque_type, + name, + method_opaque_type, + access); + } + + //------------------------------------------------------------------ // Aggregate Types //------------------------------------------------------------------ @@ -495,6 +522,12 @@ static bool IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex); + static bool + IsCXXClassType (void *clang_type); + + static bool + IsObjCClassType (void *clang_type); + //static bool //ConvertFloatValueToString (clang::ASTContext *ast_context, // void *clang_type, Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 24 00:15:53 2010 @@ -2432,6 +2432,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Sep 24 00:15:53 2010 @@ -1206,12 +1206,18 @@ false, ClangASTContext::GetTypeQualifiers(copied_type)); - ClangASTContext::AddMethodToCXXRecordType(parser_ast_context, - copied_type, - "___clang_expr", - method_type, - lldb::eAccessPublic, - false); + const bool is_virtual = false; + const bool is_static = false; + const bool is_inline = false; + + ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, + copied_type, + "___clang_expr", + method_type, + lldb::eAccessPublic, + is_virtual, + is_static, + is_inline); } context.AddTypeDecl(copied_type); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Sep 24 00:15:53 2010 @@ -476,7 +476,7 @@ } bool -SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp) +SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp) { if (cu != NULL) { @@ -566,7 +566,7 @@ Function * -SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die) +SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die) { DWARFDebugRanges::RangeList func_ranges; const char *name = NULL; @@ -641,7 +641,7 @@ { assert (sc.comp_unit); size_t functions_added = 0; - const DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); + DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); if (dwarf_cu) { DWARFDIECollection function_dies; @@ -894,7 +894,7 @@ ( const SymbolContext& sc, Block *parent_block, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, addr_t subprogram_low_pc, bool parse_siblings, @@ -1011,7 +1011,7 @@ ( const SymbolContext& sc, TypeSP& type_sp, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, void *class_clang_type, const LanguageType class_language, @@ -1107,135 +1107,8 @@ break; case DW_TAG_subprogram: - { - DWARFDebugInfoEntry::Attributes attributes; - is_a_class = true; - if (default_accessibility == eAccessNone) - default_accessibility = eAccessPrivate; - - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); - // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); - - const char *mangled = NULL; - dw_offset_t type_die_offset = DW_INVALID_OFFSET; - Declaration decl; - bool is_variadic = false; - bool is_inline = false; - bool is_virtual = false; - unsigned type_quals = 0; - AccessType accessibility = default_accessibility; - - clang::FunctionDecl::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern - const char *type_name_cstr = NULL; - ConstString type_name_dbstr; - - - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); - if (num_attributes > 0) - { - uint32_t i; - for (i=0; iGetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; - case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; - case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_name: - type_name_cstr = form_value.AsCString(&get_debug_str_data()); - break; - - case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; - case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break; - case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; - //case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; - case DW_AT_external: - if (form_value.Unsigned()) - { - if (storage == clang::SC_None) - storage = clang::SC_Extern; - else - storage = clang::SC_PrivateExtern; - } - break; - case DW_AT_inline: - is_inline = form_value.Unsigned() != 0; - break; - - - case DW_AT_virtuality: - is_virtual = form_value.Unsigned() != 0; - break; - - case DW_AT_allocated: - case DW_AT_associated: - case DW_AT_address_class: - case DW_AT_artificial: - case DW_AT_calling_convention: - case DW_AT_data_location: - case DW_AT_elemental: - case DW_AT_entry_pc: - case DW_AT_explicit: - case DW_AT_frame_base: - case DW_AT_high_pc: - case DW_AT_low_pc: - case DW_AT_object_pointer: - case DW_AT_prototyped: - case DW_AT_pure: - case DW_AT_ranges: - case DW_AT_recursive: - case DW_AT_return_addr: - case DW_AT_segment: - case DW_AT_specification: - case DW_AT_start_scope: - case DW_AT_static_link: - case DW_AT_trampoline: - case DW_AT_visibility: - case DW_AT_vtable_elem_location: - case DW_AT_abstract_origin: - case DW_AT_description: - case DW_AT_sibling: - break; - } - } - } - - void *return_clang_type = NULL; - Type *func_type = ResolveTypeUID(type_die_offset); - if (func_type) - return_clang_type = func_type->GetOpaqueClangQualType(); - else - return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); - - std::vector function_param_types; - std::vector function_param_decls; - - // Parse the function children for the parameters - bool skip_artificial = true; - - ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); - - void *method_function_proto = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); - if (type_name_cstr) - { - clang::CXXMethodDecl *method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_clang_type, - type_name_cstr, - method_function_proto, - accessibility, - is_virtual); - assert (method_decl); - //m_die_to_decl_ctx[die] = method_decl; - } - - const_cast(die)->SetUserData(type_sp.get()); - assert(type_sp.get()); - } - } + // Let the type parsing code handle this one for us... + ResolveType (dwarf_cu, die); break; case DW_TAG_inheritance: @@ -1376,7 +1249,7 @@ } CompileUnit* -SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx) +SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* cu, uint32_t cu_idx) { // Check if the symbol vendor already knows about this compile unit? if (cu->GetUserData() == NULL) @@ -2026,7 +1899,7 @@ ( const SymbolContext& sc, TypeSP& type_sp, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, bool skip_artificial, TypeList* type_list, @@ -2100,17 +1973,36 @@ } } - if (skip_artificial && is_artificial) - continue; + bool skip = false; + if (skip_artificial) + { + if (is_artificial) + skip = true; + else + { + + // HACK: Objective C formal parameters "self" and "_cmd" + // are not marked as artificial in the DWARF... + CompileUnit *cu = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); + if (cu && (cu->GetLanguage() == eLanguageTypeObjC || cu->GetLanguage() == eLanguageTypeObjC_plus_plus)) + { + if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0)) + skip = true; + } + } + } - Type *dc_type = ResolveTypeUID(param_type_die_offset); - if (dc_type) + if (!skip) { - function_param_types.push_back (dc_type->GetOpaqueClangQualType()); + Type *type = ResolveTypeUID(param_type_die_offset); + if (type) + { + function_param_types.push_back (type->GetOpaqueClangQualType()); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, dc_type->GetOpaqueClangQualType(), storage); - assert(param_var_decl); - function_param_decls.push_back(param_var_decl); + clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetOpaqueClangQualType(), storage); + assert(param_var_decl); + function_param_decls.push_back(param_var_decl); + } } } } @@ -2130,7 +2022,7 @@ TypeSP& type_sp, void * enumerator_qual_type, uint32_t enumerator_byte_size, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die ) { @@ -2200,7 +2092,7 @@ SymbolFileDWARF::ParseChildArrayInfo ( const SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, int64_t& first_index, std::vector& element_orders, @@ -2406,7 +2298,7 @@ clang::DeclContext * -SymbolFileDWARF::GetClangDeclContextForDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) +SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) { DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); if (pos != m_die_to_decl_ctx.end()) @@ -2450,14 +2342,14 @@ } TypeSP -SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new) +SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new) { TypeSP type_sp; AccessType accessibility = eAccessNone; if (die != NULL) { - dw_tag_t tag = die->Tag(); + const dw_tag_t tag = die->Tag(); if (die->GetUserData() == NULL) { type_is_new = true; @@ -2840,6 +2732,9 @@ Declaration decl; bool is_variadic = false; bool is_inline = false; + bool is_static = false; + bool is_virtual = false; + unsigned type_quals = 0; clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern @@ -2850,7 +2745,7 @@ uint32_t i; for (i=0; i function_param_decls; // Parse the function children for the parameters - bool skip_artificial = false; - ParseChildParameters(sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); + bool skip_artificial = true; + ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); + // clang_type will get the function prototype clang type after this call clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); if (type_name_cstr) { - clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline); - // Add the decl to our DIE to decl context map - assert (function_decl); - m_die_to_decl_ctx[die] = function_decl; - if (!function_param_decls.empty()) - type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); + bool type_handled = false; + const DWARFDebugInfoEntry *parent_die = die->GetParent(); + if (tag == DW_TAG_subprogram) + { + if (type_name_cstr[1] == '[' && (type_name_cstr[0] == '-' || type_name_cstr[0] == '+')) + { + // We need to find the DW_TAG_class_type or + // DW_TAG_struct_type by name so we can add this + // as a member function of the class. + const char *class_name_start = type_name_cstr + 2; + const char *class_name_end = ::strchr (class_name_start, ' '); + SymbolContext empty_sc; + void *class_opaque_type = NULL; + if (class_name_start < class_name_end) + { + ConstString class_name (class_name_start, class_name_end - class_name_start); + TypeList types; + const uint32_t match_count = FindTypes (empty_sc, class_name, true, UINT32_MAX, types); + if (match_count > 0) + { + for (uint32_t i=0; iGetOpaqueClangQualType())) + { + class_opaque_type = type->GetOpaqueClangQualType(); + break; + } + } + } + } + + if (class_opaque_type) + { + clang::ObjCMethodDecl *objc_method_decl; + objc_method_decl = type_list->GetClangASTContext().AddMethodToObjCObjectType (class_opaque_type, + type_name_cstr, + clang_type, + accessibility); + type_handled = objc_method_decl != NULL; + } + } + else if (parent_die->Tag() == DW_TAG_class_type || + parent_die->Tag() == DW_TAG_structure_type) + { + // Look at the parent of this DIE and see if is is + // a class or struct and see if this is actually a + // C++ method + Type *class_type = ResolveType (dwarf_cu, parent_die); + if (class_type) + { + void *class_opaque_type = class_type->GetOpaqueClangQualType (); + if (ClangASTContext::IsCXXClassType (class_opaque_type)) + { + clang::CXXMethodDecl *cxx_method_decl; + cxx_method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_opaque_type, + type_name_cstr, + clang_type, + accessibility, + is_virtual, + is_static, + is_inline); + type_handled = cxx_method_decl != NULL; + } + } + } + } + + if (!type_handled) + { + // We just have a function that isn't part of a class + clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline); + + // Add the decl to our DIE to decl context map + assert (function_decl); + m_die_to_decl_ctx[die] = function_decl; + if (!function_param_decls.empty()) + type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); + } } type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); @@ -3154,7 +3121,7 @@ } size_t -SymbolFileDWARF::ParseTypes (const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children) +SymbolFileDWARF::ParseTypes (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children) { size_t types_added = 0; while (die != NULL) @@ -3296,7 +3263,7 @@ SymbolFileDWARF::ParseVariableDIE ( const SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, const lldb::addr_t func_low_pc ) @@ -3439,7 +3406,7 @@ SymbolFileDWARF::ParseVariables ( const SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *orig_die, bool parse_siblings, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Sep 24 00:15:53 2010 @@ -162,7 +162,7 @@ SupportedVersion(uint16_t version); clang::DeclContext * - GetClangDeclContextForDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); + GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); clang::DeclContext * GetClangDeclContextForDIEOffset (dw_offset_t die_offset); @@ -200,31 +200,31 @@ }; DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF); - bool ParseCompileUnit(DWARFCompileUnit* cu, lldb::CompUnitSP& compile_unit_sp); + bool ParseCompileUnit (DWARFCompileUnit* cu, lldb::CompUnitSP& compile_unit_sp); DWARFCompileUnit* GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid); DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu); lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT32_MAX); bool GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc); - lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); + lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, lldb_private::Block *parent_block, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, lldb::addr_t subprogram_low_pc, bool parse_siblings, bool parse_children); - size_t ParseTypes (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); - lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new); + size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); + lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new); lldb::VariableSP ParseVariableDIE( const lldb_private::SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, const lldb::addr_t func_low_pc); size_t ParseVariables( const lldb_private::SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *die, bool parse_siblings, @@ -234,7 +234,7 @@ size_t ParseChildMembers( const lldb_private::SymbolContext& sc, lldb::TypeSP& type_sp, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, void *class_clang_type, const lldb::LanguageType class_language, @@ -246,7 +246,7 @@ size_t ParseChildParameters( const lldb_private::SymbolContext& sc, lldb::TypeSP& type_sp, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, bool skip_artificial, lldb_private::TypeList* type_list, @@ -258,12 +258,12 @@ lldb::TypeSP& type_sp, void *enumerator_qual_type, uint32_t enumerator_byte_size, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *enum_die); void ParseChildArrayInfo( const lldb_private::SymbolContext& sc, - const DWARFCompileUnit* dwarf_cu, + DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, int64_t& first_index, std::vector& element_orders, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114722&r1=114721&r2=114722&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Sep 24 00:15:53 2010 @@ -811,7 +811,9 @@ const char *name, void *method_opaque_type, lldb::AccessType access, - bool is_virtual + bool is_virtual, + bool is_static, + bool is_inline ) { if (!record_opaque_type || !method_opaque_type || !name) @@ -824,51 +826,56 @@ assert(identifier_table); QualType record_qual_type(QualType::getFromOpaquePtr(record_opaque_type)); - clang::Type *record_type(record_qual_type.getTypePtr()); + + clang::Type *clang_type(record_qual_type.getTypePtr()); - if (!record_type) + if (clang_type == NULL) return NULL; - RecordType *record_recty(dyn_cast(record_type)); + RecordType *record_clang_type(dyn_cast(clang_type)); - if (!record_recty) + if (record_clang_type == NULL) return NULL; - RecordDecl *record_decl = record_recty->getDecl(); + RecordDecl *record_decl = record_clang_type->getDecl(); - if (!record_decl) + if (record_decl == NULL) return NULL; CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); - if (!cxx_record_decl) + if (cxx_record_decl == NULL) return NULL; - QualType method_qual_type(QualType::getFromOpaquePtr(method_opaque_type)); + QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type)); + + CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create (*ast_context, + cxx_record_decl, + DeclarationNameInfo (DeclarationName (&identifier_table->get(name)), SourceLocation()), + method_qual_type, + NULL, // TypeSourceInfo * + is_static, + SC_None, + is_inline); - CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, - cxx_record_decl, - DeclarationNameInfo(DeclarationName(&identifier_table->get(name)), SourceLocation()), - method_qual_type, - NULL); - clang::AccessSpecifier AS = ConvertAccessTypeToAccessSpecifier(access); + clang::AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); - cxx_method_decl->setAccess(AS); - cxx_method_decl->setVirtualAsWritten(is_virtual); + cxx_method_decl->setAccess (access_specifier); + cxx_method_decl->setVirtualAsWritten (is_virtual); // Populate the method decl with parameter decls clang::Type *method_type(method_qual_type.getTypePtr()); - if (!method_type) + if (method_type == NULL) return NULL; - FunctionProtoType *method_funprototy(dyn_cast(method_type)); + FunctionProtoType *method_function_prototype (dyn_cast(method_type)); - if (!method_funprototy) + if (!method_function_prototype) return NULL; - unsigned int num_params = method_funprototy->getNumArgs(); + unsigned int num_params = method_function_prototype->getNumArgs(); ParmVarDecl *params[num_params]; @@ -876,20 +883,20 @@ param_index < num_params; ++param_index) { - params[param_index] = ParmVarDecl::Create(*ast_context, - cxx_method_decl, - SourceLocation(), - NULL, // anonymous - method_funprototy->getArgType(param_index), - NULL, - SC_Auto, - SC_Auto, - NULL); + params[param_index] = ParmVarDecl::Create (*ast_context, + cxx_method_decl, + SourceLocation(), + NULL, // anonymous + method_function_prototype->getArgType(param_index), + NULL, + SC_None, + SC_None, + NULL); } - cxx_method_decl->setParams(params, num_params); + cxx_method_decl->setParams (params, num_params); - cxx_record_decl->addDecl(cxx_method_decl); + cxx_record_decl->addDecl (cxx_method_decl); return cxx_method_decl; } @@ -988,14 +995,14 @@ ObjCObjectType *objc_class_type = dyn_cast(clang_type); if (objc_class_type) { - bool isSynthesized = false; + bool is_synthesized = false; ClangASTContext::AddObjCClassIVar (ast_context, record_clang_type, name, field_type, access, bitfield_bit_size, - isSynthesized); + is_synthesized); } } } @@ -1250,7 +1257,7 @@ void *ivar_opaque_type, AccessType access, uint32_t bitfield_bit_size, - bool isSynthesized + bool is_synthesized ) { if (class_opaque_type == NULL || ivar_opaque_type == NULL) @@ -1289,7 +1296,7 @@ NULL, // TypeSourceInfo * ConvertAccessTypeToObjCIvarAccessControl (access), bit_width, - isSynthesized); + is_synthesized); if (field) { @@ -1334,7 +1341,132 @@ } return false; } + +clang::ObjCMethodDecl * +ClangASTContext::AddMethodToObjCObjectType +( + clang::ASTContext *ast_context, + void *class_opaque_type, + const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") + void *method_opaque_type, + lldb::AccessType access +) +{ + if (class_opaque_type == NULL || method_opaque_type == NULL) + return NULL; + + IdentifierTable *identifier_table = &ast_context->Idents; + + assert (ast_context != NULL); + assert (identifier_table != NULL); + + QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type)); + + clang::Type *class_type = class_qual_type.getTypePtr(); + if (class_type == NULL) + return NULL; + + ObjCObjectType *objc_class_type = dyn_cast(class_type); + + if (objc_class_type == NULL) + return NULL; + + ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + + if (class_interface_decl == NULL) + return NULL; + + const char *selector_start = ::strchr (name, ' '); + if (selector_start == NULL) + return NULL; + + selector_start++; + if (!(::isalpha (selector_start[0]) || selector_start[0] == '_')) + return NULL; + llvm::SmallVector selector_idents; + + size_t len; + const char *start; + for (start = selector_start, len = ::strcspn(start, ":]"); + start && *start != '\0' && *start != ']'; + start += len + 1) + { + selector_idents.push_back (&identifier_table->get (StringRef (start, len))); + } + + + if (selector_idents.size() == 0) + return 0; + + clang::Selector method_selector = ast_context->Selectors.getSelector (selector_idents.size(), + selector_idents.data()); + + QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type)); + + // Populate the method decl with parameter decls + clang::Type *method_type(method_qual_type.getTypePtr()); + + if (method_type == NULL) + return NULL; + + FunctionProtoType *method_function_prototype (dyn_cast(method_type)); + + if (!method_function_prototype) + return NULL; + + + bool is_variadic = false; + bool is_synthesized = false; + bool is_defined = false; + ObjCMethodDecl::ImplementationControl imp_control = ObjCMethodDecl::None; + + const unsigned num_args = method_function_prototype->getNumArgs(); + + ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*ast_context, + SourceLocation(), // beginLoc, + SourceLocation(), // endLoc, + method_selector, + method_function_prototype->getResultType(), + NULL, // TypeSourceInfo *ResultTInfo, + GetDeclContextForType (class_opaque_type), + name[0] == '-', + is_variadic, + is_synthesized, + is_defined, + imp_control, + num_args); + + + if (objc_method_decl == NULL) + return NULL; + + if (num_args > 0) + { + llvm::SmallVector params; + + for (int param_index = 0; param_index < num_args; ++param_index) + { + params.push_back (ParmVarDecl::Create (*ast_context, + objc_method_decl, + SourceLocation(), + NULL, // anonymous + method_function_prototype->getArgType(param_index), + NULL, + SC_Auto, + SC_Auto, + NULL)); + } + + objc_method_decl->setMethodParams(*ast_context, params.data(), params.size(), num_args); + } + class_interface_decl->addDecl (objc_method_decl); + + + return objc_method_decl; +} + + #pragma mark Aggregate Types @@ -3044,6 +3176,32 @@ return false; } +bool +ClangASTContext::IsCXXClassType (void *clang_type) +{ + if (clang_type) + { + QualType qual_type (QualType::getFromOpaquePtr(clang_type)); + if (qual_type->getAsCXXRecordDecl() != NULL) + return true; + } + return false; +} + +bool +ClangASTContext::IsObjCClassType (void *clang_type) +{ + if (clang_type) + { + QualType qual_type (QualType::getFromOpaquePtr(clang_type)); + if (qual_type->isObjCObjectOrInterfaceType()) + return true; + } + return false; +} + + + bool ClangASTContext::IsCStringType (void *clang_type, uint32_t &length) From johnny.chen at apple.com Fri Sep 24 12:33:29 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 24 Sep 2010 17:33:29 -0000 Subject: [Lldb-commits] [lldb] r114739 - in /lldb/trunk: source/Symbol/ClangASTType.cpp test/bitfields/TestBitfields.py test/set_values/TestSetValues.py test/unsigned_types/TestUnsignedTypes.py Message-ID: <20100924173329.33A9C2A6C12C@llvm.org> Author: johnny Date: Fri Sep 24 12:33:29 2010 New Revision: 114739 URL: http://llvm.org/viewvc/llvm-project?rev=114739&view=rev Log: Made 'frame variable' printing of unsigned types more readable, like gdb. Modified: lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/set_values/TestSetValues.py lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=114739&r1=114738&r2=114739&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Sep 24 12:33:29 2010 @@ -237,15 +237,15 @@ case clang::BuiltinType::WChar: return lldb::eFormatChar; case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; case clang::BuiltinType::Char32: return lldb::eFormatUnicode32; - case clang::BuiltinType::UShort: return lldb::eFormatHex; + case clang::BuiltinType::UShort: return lldb::eFormatUnsigned; case clang::BuiltinType::Short: return lldb::eFormatDecimal; - case clang::BuiltinType::UInt: return lldb::eFormatHex; + case clang::BuiltinType::UInt: return lldb::eFormatUnsigned; case clang::BuiltinType::Int: return lldb::eFormatDecimal; - case clang::BuiltinType::ULong: return lldb::eFormatHex; + case clang::BuiltinType::ULong: return lldb::eFormatUnsigned; case clang::BuiltinType::Long: return lldb::eFormatDecimal; - case clang::BuiltinType::ULongLong: return lldb::eFormatHex; + case clang::BuiltinType::ULongLong: return lldb::eFormatUnsigned; case clang::BuiltinType::LongLong: return lldb::eFormatDecimal; - case clang::BuiltinType::UInt128: return lldb::eFormatHex; + case clang::BuiltinType::UInt128: return lldb::eFormatUnsigned; case clang::BuiltinType::Int128: return lldb::eFormatDecimal; case clang::BuiltinType::Float: return lldb::eFormatFloat; case clang::BuiltinType::Double: return lldb::eFormatFloat; Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=114739&r1=114738&r2=114739&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Fri Sep 24 12:33:29 2010 @@ -53,26 +53,26 @@ # This should display correctly. self.expect("frame variable bits", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(uint32_t:1) b1 = 0x00000001,', - '(uint32_t:2) b2 = 0x00000003,', - '(uint32_t:3) b3 = 0x00000007,', - '(uint32_t:4) b4 = 0x0000000f,', - '(uint32_t:5) b5 = 0x0000001f,', - '(uint32_t:6) b6 = 0x0000003f,', - '(uint32_t:7) b7 = 0x0000007f,', - '(uint32_t:4) four = 0x0000000f']) + substrs = ['(uint32_t:1) b1 = 1,', + '(uint32_t:2) b2 = 3,', + '(uint32_t:3) b3 = 7,', + '(uint32_t:4) b4 = 15,', + '(uint32_t:5) b5 = 31,', + '(uint32_t:6) b6 = 63,', + '(uint32_t:7) b7 = 127,', + '(uint32_t:4) four = 15']) # And so should this. # rdar://problem/8348251 self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(uint32_t:1) b1 = 0x00000001,', - '(uint32_t:2) b2 = 0x00000003,', - '(uint32_t:3) b3 = 0x00000007,', - '(uint32_t:4) b4 = 0x0000000f,', - '(uint32_t:5) b5 = 0x0000001f,', - '(uint32_t:6) b6 = 0x0000003f,', - '(uint32_t:7) b7 = 0x0000007f,', - '(uint32_t:4) four = 0x0000000f']) + substrs = ['(uint32_t:1) b1 = 1,', + '(uint32_t:2) b2 = 3,', + '(uint32_t:3) b3 = 7,', + '(uint32_t:4) b4 = 15,', + '(uint32_t:5) b5 = 31,', + '(uint32_t:6) b6 = 63,', + '(uint32_t:7) b7 = 127,', + '(uint32_t:4) four = 15']) def bitfields_variable_python(self): """Use Python APIs to inspect a bitfields variable.""" @@ -113,24 +113,24 @@ self.assertTrue(b1.GetName() == "b1" and b1.GetTypeName() == "uint32_t:1" and b1.IsInScope(frame) and - int(b1.GetValue(frame), 16) == 0x01, - 'bits.b1 has type uint32_t:1, is in scope, and == 0x01') + int(b1.GetValue(frame), 0) == 1, + 'bits.b1 has type uint32_t:1, is in scope, and == 1') b7 = bits.GetChildAtIndex(6) self.DebugSBValue(frame, b7) self.assertTrue(b7.GetName() == "b7" and b7.GetTypeName() == "uint32_t:7" and b7.IsInScope(frame) and - int(b7.GetValue(frame), 16) == 0x7f, - 'bits.b7 has type uint32_t:7, is in scope, and == 0x7f') + int(b7.GetValue(frame), 0) == 127, + 'bits.b7 has type uint32_t:7, is in scope, and == 127') four = bits.GetChildAtIndex(7) self.DebugSBValue(frame, four) self.assertTrue(four.GetName() == "four" and four.GetTypeName() == "uint32_t:4" and four.IsInScope(frame) and - int(four.GetValue(frame), 16) == 0x0f, - 'bits.four has type uint32_t:4, is in scope, and == 0x0f') + int(four.GetValue(frame), 0) == 15, + 'bits.four has type uint32_t:4, is in scope, and == 15') # Now kill the process, and we are done. rc = target.GetProcess().Kill() Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=114739&r1=114738&r2=114739&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Fri Sep 24 12:33:29 2010 @@ -65,7 +65,7 @@ # main.c:36 # Check that 'frame variable' displays the correct data type and value. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(short unsigned int) i = 0x0021") + startstr = "(short unsigned int) i = 33") # TODO: # Now set variable 'i' and check that it is correctly displayed. Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=114739&r1=114738&r2=114739&view=diff ============================================================================== --- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (original) +++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Fri Sep 24 12:33:29 2010 @@ -45,11 +45,11 @@ # Test that unsigned types display correctly. self.expect("frame variable -a", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(unsigned char) the_unsigned_char = 'c'", - substrs = ["(short unsigned int) the_unsigned_short = 0x0063", - "(unsigned int) the_unsigned_int = 0x00000063", - "(long unsigned int) the_unsigned_long = 0x0000000000000063", - "(long long unsigned int) the_unsigned_long_long = 0x0000000000000063", - "(uint32_t) the_uint32 = 0x00000063"]) + substrs = ["(short unsigned int) the_unsigned_short = 99", + "(unsigned int) the_unsigned_int = 99", + "(long unsigned int) the_unsigned_long = 99", + "(long long unsigned int) the_unsigned_long_long = 99", + "(uint32_t) the_uint32 = 99"]) if __name__ == '__main__': From johnny.chen at apple.com Fri Sep 24 15:41:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 24 Sep 2010 20:41:17 -0000 Subject: [Lldb-commits] [lldb] r114756 - in /lldb/trunk/test/types: TestBasicTypes.py long.cpp unsigned_int.cpp unsigned_long.cpp Message-ID: <20100924204117.B35BA2A6C12C@llvm.org> Author: johnny Date: Fri Sep 24 15:41:17 2010 New Revision: 114756 URL: http://llvm.org/viewvc/llvm-project?rev=114756&view=rev Log: Added two new .cpp files to be tested via TestBasicTypes.py for correct display of various combinations of data structures with unsigned int or unsigned long builtin types. Added: lldb/trunk/test/types/unsigned_int.cpp lldb/trunk/test/types/unsigned_long.cpp Modified: lldb/trunk/test/types/TestBasicTypes.py lldb/trunk/test/types/long.cpp Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114756&r1=114755&r2=114756&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Fri Sep 24 15:41:17 2010 @@ -33,6 +33,20 @@ self.setTearDownCleanup(dictionary=d) self.int_type() + def test_unsigned_int_type_with_dsym(self): + """Test that 'unsigned_int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + + def test_unsigned_int_type_with_dwarf(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + def test_long_type_with_dsym(self): """Test that long-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -47,14 +61,36 @@ self.setTearDownCleanup(dictionary=d) self.long_type() + def test_unsigned_long_type_with_dsym(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + + def test_unsigned_long_type_with_dwarf(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + def int_type(self): """Test that int-type variables are displayed correctly.""" self.generic_type_tester("int") + def unsigned_int_type(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + self.generic_type_tester("unsigned int") + def long_type(self): """Test that long-type variables are displayed correctly.""" self.generic_type_tester("long") + def unsigned_long_type(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + self.generic_type_tester("unsigned long") + def generic_type_tester(self, type): """Test that variables with basic types are displayed correctly.""" @@ -106,8 +142,20 @@ for var, val in gl: self.runCmd("frame variable %s" % var) output = self.res.GetOutput() + + # Extract the display type and canonicalize its atoms into a set. + # Same for the input type string. + dt = re.match("^\((.*)\)", output).group(1) + ds = set(dt.split()) + ts = set(type.split()) + + # The display type set must be a superset of the input type set. + if not ds.issuperset(ts): + self.fail("The display type: %s must match the input type: %s" % + (dt, type)) + + # The (var, val) pair must match, too. self.expect(output, Msg(var, val), exe=False, - patterns = ["\(%s.*\)" % type], substrs = [" %s = %s" % (var, val)]) Modified: lldb/trunk/test/types/long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/long.cpp?rev=114756&r1=114755&r2=114756&view=diff ============================================================================== --- lldb/trunk/test/types/long.cpp (original) +++ lldb/trunk/test/types/long.cpp Fri Sep 24 15:41:17 2010 @@ -1,9 +1,18 @@ #define T long #define T_CSTR "long" + +#ifdef __LP64__ #define T_VALUE_1 110011101111 #define T_VALUE_2 220022202222 #define T_VALUE_3 330033303333 #define T_VALUE_4 440044404444 +#else +#define T_VALUE_1 110011101 +#define T_VALUE_2 220022202 +#define T_VALUE_3 330033303 +#define T_VALUE_4 440044404 +#endif + #define T_PRINTF_FORMAT "%ld" #include "basic_type.cpp" Added: lldb/trunk/test/types/unsigned_int.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_int.cpp?rev=114756&view=auto ============================================================================== --- lldb/trunk/test/types/unsigned_int.cpp (added) +++ lldb/trunk/test/types/unsigned_int.cpp Fri Sep 24 15:41:17 2010 @@ -0,0 +1,9 @@ +#define T unsigned int +#define T_CSTR "unsigned int" +#define T_VALUE_1 11001110 +#define T_VALUE_2 22002220 +#define T_VALUE_3 33003330 +#define T_VALUE_4 44004440 +#define T_PRINTF_FORMAT "%u" + +#include "basic_type.cpp" Added: lldb/trunk/test/types/unsigned_long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_long.cpp?rev=114756&view=auto ============================================================================== --- lldb/trunk/test/types/unsigned_long.cpp (added) +++ lldb/trunk/test/types/unsigned_long.cpp Fri Sep 24 15:41:17 2010 @@ -0,0 +1,18 @@ +#define T unsigned long +#define T_CSTR "unsigned long" + +#ifdef __LP64__ +#define T_VALUE_1 110011101111 +#define T_VALUE_2 220022202222 +#define T_VALUE_3 330033303333 +#define T_VALUE_4 440044404444 +#else +#define T_VALUE_1 110011101 +#define T_VALUE_2 220022202 +#define T_VALUE_3 330033303 +#define T_VALUE_4 440044404 +#endif + +#define T_PRINTF_FORMAT "%ld" + +#include "basic_type.cpp" From johnny.chen at apple.com Fri Sep 24 16:52:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 24 Sep 2010 21:52:37 -0000 Subject: [Lldb-commits] [lldb] r114764 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py Message-ID: <20100924215237.ADCAA2A6C12C@llvm.org> Author: johnny Date: Fri Sep 24 16:52:37 2010 New Revision: 114764 URL: http://llvm.org/viewvc/llvm-project?rev=114764&view=rev Log: Added comments about the usage of int(string, 0) and long(string, 0) which pass a base of 0 so that the radix of the string is determined based on the contents of string. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=114764&r1=114763&r2=114764&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Fri Sep 24 16:52:37 2010 @@ -148,6 +148,9 @@ "Variable 'char_16' should have 16 children") # Lookup the "ushort_matrix" ushort[] array variable. + # Notice the pattern of int(child0_2.GetValue(frame), 0). We pass a + # base of 0 so that the proper radix is determined based on the contents + # of the string. Same applies to long(). variable = frame.LookupVar("ushort_matrix") self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 2, @@ -158,7 +161,7 @@ "Variable 'ushort_matrix[0]' should have 3 children") child0_2 = child0.GetChildAtIndex(2) self.DebugSBValue(frame, child0_2) - self.assertTrue(int(child0_2.GetValue(frame), 16) == 3, + self.assertTrue(int(child0_2.GetValue(frame), 0) == 3, "ushort_matrix[0][2] == 3") # Lookup the "long_6" char array variable. @@ -168,7 +171,7 @@ "Variable 'long_6' should have 6 children") child5 = variable.GetChildAtIndex(5) self.DebugSBValue(frame, child5) - self.assertTrue(long(child5.GetValue(frame)) == 6, + self.assertTrue(long(child5.GetValue(frame), 0) == 6, "long_6[5] == 6") Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=114764&r1=114763&r2=114764&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Fri Sep 24 16:52:37 2010 @@ -108,6 +108,9 @@ bits.GetByteSize() == 4, "(Bits)bits with byte size of 4 and 8 children") + # Notice the pattern of int(b1.GetValue(frame), 0). We pass a base of 0 + # so that the proper radix is determined based on the contents of the + # string. b1 = bits.GetChildAtIndex(0) self.DebugSBValue(frame, b1) self.assertTrue(b1.GetName() == "b1" and From johnny.chen at apple.com Fri Sep 24 17:54:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 24 Sep 2010 22:54:18 -0000 Subject: [Lldb-commits] [lldb] r114769 - in /lldb/trunk/test/types: TestBasicTypes.py char.cpp short.cpp unsigned_char.cpp unsigned_short.cpp Message-ID: <20100924225418.CE33C2A6C12C@llvm.org> Author: johnny Date: Fri Sep 24 17:54:18 2010 New Revision: 114769 URL: http://llvm.org/viewvc/llvm-project?rev=114769&view=rev Log: Added 'char'/'unsigned char'/'short'/'unsigned short' to the test suite. Extended generic_type_tester() method to take an additional keyword argument quoteDisplay (default to False) to facilitate comparison with frame variable display output of character types. Added: lldb/trunk/test/types/char.cpp lldb/trunk/test/types/short.cpp lldb/trunk/test/types/unsigned_char.cpp lldb/trunk/test/types/unsigned_short.cpp Modified: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114769&r1=114768&r2=114769&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Fri Sep 24 17:54:18 2010 @@ -19,6 +19,62 @@ # printf() stmts (see basic_type.cpp). pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") + def test_char_type_with_dsym(self): + """Test that char-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type() + + def test_char_type_with_dwarf(self): + """Test that char-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type() + + def test_unsigned_char_type_with_dsym(self): + """Test that 'unsigned_char'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type() + + def test_unsigned_char_type_with_dwarf(self): + """Test that 'unsigned char'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type() + + def test_short_type_with_dsym(self): + """Test that short-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type() + + def test_short_type_with_dwarf(self): + """Test that short-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type() + + def test_unsigned_short_type_with_dsym(self): + """Test that 'unsigned_short'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type() + + def test_unsigned_short_type_with_dwarf(self): + """Test that 'unsigned short'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type() + def test_int_type_with_dsym(self): """Test that int-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -75,6 +131,22 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_type() + def char_type(self): + """Test that char-type variables are displayed correctly.""" + self.generic_type_tester("char", quotedDisplay=True) + + def unsigned_char_type(self): + """Test that 'unsigned char'-type variables are displayed correctly.""" + self.generic_type_tester("unsigned char", quotedDisplay=True) + + def short_type(self): + """Test that short-type variables are displayed correctly.""" + self.generic_type_tester("short") + + def unsigned_short_type(self): + """Test that 'unsigned short'-type variables are displayed correctly.""" + self.generic_type_tester("unsigned short") + def int_type(self): """Test that int-type variables are displayed correctly.""" self.generic_type_tester("int") @@ -91,7 +163,7 @@ """Test that 'unsigned long'-type variables are displayed correctly.""" self.generic_type_tester("unsigned long") - def generic_type_tester(self, type): + def generic_type_tester(self, type, quotedDisplay=False): """Test that variables with basic types are displayed correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -137,6 +209,8 @@ self.runCmd("run", RUN_SUCCEEDED) self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) + self.runCmd("frame variable") + # Now iterate through the golden list, comparing against the output from # 'frame variable var'. for var, val in gl: @@ -155,8 +229,9 @@ (dt, type)) # The (var, val) pair must match, too. + nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) self.expect(output, Msg(var, val), exe=False, - substrs = [" %s = %s" % (var, val)]) + substrs = [nv]) if __name__ == '__main__': Added: lldb/trunk/test/types/char.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/char.cpp?rev=114769&view=auto ============================================================================== --- lldb/trunk/test/types/char.cpp (added) +++ lldb/trunk/test/types/char.cpp Fri Sep 24 17:54:18 2010 @@ -0,0 +1,9 @@ +#define T char +#define T_CSTR "char" +#define T_VALUE_1 'a' +#define T_VALUE_2 'b' +#define T_VALUE_3 '!' +#define T_VALUE_4 '~' +#define T_PRINTF_FORMAT "%c" + +#include "basic_type.cpp" Added: lldb/trunk/test/types/short.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/short.cpp?rev=114769&view=auto ============================================================================== --- lldb/trunk/test/types/short.cpp (added) +++ lldb/trunk/test/types/short.cpp Fri Sep 24 17:54:18 2010 @@ -0,0 +1,9 @@ +#define T short +#define T_CSTR "short" +#define T_VALUE_1 11001 +#define T_VALUE_2 22002 +#define T_VALUE_3 -32768 +#define T_VALUE_4 32767 +#define T_PRINTF_FORMAT "%hd" + +#include "basic_type.cpp" Added: lldb/trunk/test/types/unsigned_char.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_char.cpp?rev=114769&view=auto ============================================================================== --- lldb/trunk/test/types/unsigned_char.cpp (added) +++ lldb/trunk/test/types/unsigned_char.cpp Fri Sep 24 17:54:18 2010 @@ -0,0 +1,9 @@ +#define T unsigned char +#define T_CSTR "unsigned char" +#define T_VALUE_1 '0' +#define T_VALUE_2 '9' +#define T_VALUE_3 '@' +#define T_VALUE_4 '$' +#define T_PRINTF_FORMAT "%c" + +#include "basic_type.cpp" Added: lldb/trunk/test/types/unsigned_short.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_short.cpp?rev=114769&view=auto ============================================================================== --- lldb/trunk/test/types/unsigned_short.cpp (added) +++ lldb/trunk/test/types/unsigned_short.cpp Fri Sep 24 17:54:18 2010 @@ -0,0 +1,9 @@ +#define T unsigned short +#define T_CSTR "unsigned short" +#define T_VALUE_1 11001 +#define T_VALUE_2 22002 +#define T_VALUE_3 0 +#define T_VALUE_4 65535 +#define T_PRINTF_FORMAT "%hu" + +#include "basic_type.cpp" From johnny.chen at apple.com Fri Sep 24 17:57:32 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 24 Sep 2010 22:57:32 -0000 Subject: [Lldb-commits] [lldb] r114770 - /lldb/trunk/test/types/TestBasicTypes.py Message-ID: <20100924225732.DFE3E2A6C12C@llvm.org> Author: johnny Date: Fri Sep 24 17:57:32 2010 New Revision: 114770 URL: http://llvm.org/viewvc/llvm-project?rev=114770&view=rev Log: Commented out a debug stmt. Modified: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114770&r1=114769&r2=114770&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Fri Sep 24 17:57:32 2010 @@ -209,7 +209,7 @@ self.runCmd("run", RUN_SUCCEEDED) self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) - self.runCmd("frame variable") + #self.runCmd("frame variable") # Now iterate through the golden list, comparing against the output from # 'frame variable var'. From gclayton at apple.com Fri Sep 24 18:07:41 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 24 Sep 2010 23:07:41 -0000 Subject: [Lldb-commits] [lldb] r114771 - in /lldb/trunk: include/lldb/Expression/ClangFunction.h include/lldb/Expression/ClangUserExpression.h include/lldb/Expression/ClangUtilityFunction.h include/lldb/Utility/SharingPtr.h include/lldb/lldb-types.h source/Expression/ClangUtilityFunction.cpp source/Utility/SharingPtr.cpp Message-ID: <20100924230741.567EC2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 24 18:07:41 2010 New Revision: 114771 URL: http://llvm.org/viewvc/llvm-project?rev=114771&view=rev Log: Cleaned a few build related things up: Added a virtual destructor to ClangUtilityFunction with a body to it cleans itself up. Moved our SharingPtr into the lldb_private namespace to keep it easy to make an exports file that exports only what is needed ("lldb::*"). Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h lldb/trunk/include/lldb/Utility/SharingPtr.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Utility/SharingPtr.cpp Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Fri Sep 24 18:07:41 2010 @@ -130,7 +130,8 @@ //------------------------------------------------------------------ /// Destructor //------------------------------------------------------------------ - virtual ~ClangFunction(); + virtual + ~ClangFunction(); //------------------------------------------------------------------ /// Compile the wrapper function Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Fri Sep 24 18:07:41 2010 @@ -50,7 +50,8 @@ //------------------------------------------------------------------ /// Destructor //------------------------------------------------------------------ - virtual ~ClangUserExpression (); + virtual + ~ClangUserExpression (); //------------------------------------------------------------------ /// Parse the expression Modified: lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h Fri Sep 24 18:07:41 2010 @@ -52,6 +52,9 @@ ClangUtilityFunction (const char *text, const char *name); + virtual + ~ClangUtilityFunction (); + //------------------------------------------------------------------ /// Install the utility function into a process /// Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/SharingPtr.h (original) +++ lldb/trunk/include/lldb/Utility/SharingPtr.h Fri Sep 24 18:07:41 2010 @@ -13,7 +13,7 @@ #include #include -namespace lldb { +namespace lldb_private { namespace imp { Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Fri Sep 24 18:07:41 2010 @@ -67,7 +67,7 @@ template struct SharedPtr { - typedef lldb::SharingPtr<_Tp> Type; + typedef lldb_private::SharingPtr<_Tp> Type; }; } // namespace lldb Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Fri Sep 24 18:07:41 2010 @@ -44,6 +44,10 @@ { } +ClangUtilityFunction::~ClangUtilityFunction () +{ +} + //------------------------------------------------------------------ /// Install the utility function into a process /// Modified: lldb/trunk/source/Utility/SharingPtr.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/SharingPtr.cpp?rev=114771&r1=114770&r2=114771&view=diff ============================================================================== --- lldb/trunk/source/Utility/SharingPtr.cpp (original) +++ lldb/trunk/source/Utility/SharingPtr.cpp Fri Sep 24 18:07:41 2010 @@ -9,7 +9,7 @@ #include "lldb/Utility/SharingPtr.h" -namespace lldb { +namespace lldb_private { namespace imp { From gclayton at apple.com Fri Sep 24 18:57:12 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 24 Sep 2010 23:57:12 -0000 Subject: [Lldb-commits] [lldb] r114775 - /lldb/trunk/resources/lldb-framework-exports Message-ID: <20100924235712.65F382A6C12C@llvm.org> Author: gclayton Date: Fri Sep 24 18:57:12 2010 New Revision: 114775 URL: http://llvm.org/viewvc/llvm-project?rev=114775&view=rev Log: Added two needed exports. Modified: lldb/trunk/resources/lldb-framework-exports Modified: lldb/trunk/resources/lldb-framework-exports URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/lldb-framework-exports?rev=114775&r1=114774&r2=114775&view=diff ============================================================================== --- lldb/trunk/resources/lldb-framework-exports (original) +++ lldb/trunk/resources/lldb-framework-exports Fri Sep 24 18:57:12 2010 @@ -1,3 +1,5 @@ __ZN4lldb* __ZNK4lldb* _init_lldb +*add_shared* +*release_shared* From gclayton at apple.com Fri Sep 24 19:31:52 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 25 Sep 2010 00:31:52 -0000 Subject: [Lldb-commits] [lldb] r114777 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20100925003152.D80302A6C12C@llvm.org> Author: gclayton Date: Fri Sep 24 19:31:52 2010 New Revision: 114777 URL: http://llvm.org/viewvc/llvm-project?rev=114777&view=rev Log: Bumped Xcode lldb build number to 25 for lldb-25 and debugserver build to 113 for debugserver-113. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist 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=114777&r1=114776&r2=114777&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 24 19:31:52 2010 @@ -2935,9 +2935,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 24; + DYLIB_CURRENT_VERSION = 25; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2988,11 +2988,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 24; + DYLIB_CURRENT_VERSION = 25; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3063,7 +3063,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3099,11 +3099,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 24; + DYLIB_CURRENT_VERSION = 25; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3153,7 +3153,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3193,7 +3193,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 24; + CURRENT_PROJECT_VERSION = 25; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=114777&r1=114776&r2=114777&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Sep 24 19:31:52 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 24 + 25 CFBundleName ${EXECUTABLE_NAME} 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=114777&r1=114776&r2=114777&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Sep 24 19:31:52 2010 @@ -456,7 +456,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -475,7 +475,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -496,7 +496,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -515,7 +515,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -557,7 +557,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -599,7 +599,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From ctice at apple.com Sun Sep 26 19:30:11 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 27 Sep 2010 00:30:11 -0000 Subject: [Lldb-commits] [lldb] r114808 - in /lldb/trunk: include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/Target/Thread.h source/API/SBDebugger.cpp source/Commands/CommandObjectSettings.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Target.cpp source/Target/TargetList.cpp source/Target/Thread.cpp Message-ID: <20100927003011.390972A6C12C@llvm.org> Author: ctice Date: Sun Sep 26 19:30:10 2010 New Revision: 114808 URL: http://llvm.org/viewvc/llvm-project?rev=114808&view=rev Log: Create more useful instance names for target, process and thread instances. Change default 'set' behavior so that all instance settings for the specified variable will be updated, unless the "-n" ("--no_override") command options is specified. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/TargetList.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sun Sep 26 19:30:10 2010 @@ -365,6 +365,9 @@ static lldb::UserSettingsControllerSP GetSettingsController (bool finish = false); + void + UpdateInstanceName (); + //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Sun Sep 26 19:30:10 2010 @@ -132,6 +132,9 @@ static void SetDefaultArchitecture (ArchSpec new_arch); + void + UpdateInstanceName (); + //------------------------------------------------------------------ /// Broadcaster event bits definitions. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Sun Sep 26 19:30:10 2010 @@ -159,6 +159,9 @@ lldb::DataBufferSP m_data_sp; }; + void + UpdateInstanceName (); + static lldb::UserSettingsControllerSP GetSettingsController (bool finish = false); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Sun Sep 26 19:30:10 2010 @@ -581,7 +581,7 @@ { lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); - Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false, + Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, true, debugger_instance_name); SBError sb_error; sb_error.SetError (err); Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Sun Sep 26 19:30:10 2010 @@ -194,7 +194,7 @@ CommandObjectSettingsSet::CommandOptions::CommandOptions () : Options (), - m_override (false), + m_override (true), m_reset (false) { } @@ -206,7 +206,7 @@ lldb::OptionDefinition CommandObjectSettingsSet::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "override", 'o', no_argument, NULL, NULL, NULL, "Causes already existing instances and pending settings to use this new value. This option only makes sense when setting default values." }, + { LLDB_OPT_SET_1, false, "no_override", 'n', no_argument, NULL, NULL, NULL, "Prevents already existing instances and pending settings from being assigned this new value. Using this option means that only the default or specified instance setting values will be updated." }, { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, NULL, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, }; @@ -224,8 +224,8 @@ switch (short_option) { - case 'o': - m_override = true; + case 'n': + m_override = false; break; case 'r': m_reset = true; @@ -243,7 +243,7 @@ { Options::ResetOptionValues (); - m_override = false; + m_override = true; m_reset = false; } @@ -510,7 +510,7 @@ Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) @@ -622,7 +622,7 @@ Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) @@ -736,7 +736,7 @@ Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) @@ -851,7 +851,7 @@ Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) @@ -911,8 +911,8 @@ } bool -CommandObjectSettingsAppend::Execute ( Args& command, - CommandReturnObject &result) +CommandObjectSettingsAppend::Execute (Args& command, + CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -954,7 +954,7 @@ Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Sun Sep 26 19:30:10 2010 @@ -347,14 +347,14 @@ OverrideAllInstances (const_var_name, value, op, index_value, err); // Update all pending records as well. - std::map::iterator pos, end = m_pending_settings.end(); - for (pos = m_pending_settings.begin(); pos != end; end++) - { - const ConstString instance_name (pos->first.c_str()); - lldb::InstanceSettingsSP setting_sp = pos->second; - setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, - instance_name, *entry, op, err, true); - } +// std::map::iterator pos, end = m_pending_settings.end(); +// for (pos = m_pending_settings.begin(); pos != end; end++) +// { +// const ConstString instance_name (pos->first.c_str()); +// lldb::InstanceSettingsSP setting_sp = pos->second; +// setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, +// instance_name, *entry, op, err, true); +// } } } } @@ -2164,18 +2164,24 @@ // list, then this is not a setting that can be renamed. if ((old_name_key[0] != '[') || (old_name_key[old_name_key.size() -1] != ']')) - { + { StreamString tmp_str; tmp_str.Printf ("[%s]", old_name); old_name_key = tmp_str.GetData(); - } + } if ((new_name_key[0] != '[') || (new_name_key[new_name_key.size() -1] != ']')) - { + { StreamString tmp_str; tmp_str.Printf ("[%s]", new_name); new_name_key = tmp_str.GetData(); - } + } + + if (old_name_key.compare (new_name_key) == 0) + return; + + size_t len = new_name_key.length(); + std::string stripped_new_name = new_name_key.substr (1, len-2); // new name without the '[ ]' std::map::iterator pos; @@ -2185,7 +2191,7 @@ InstanceSettings *live_settings = pos->second; // Rename the settings. - live_settings->ChangeInstanceName (new_name_key); + live_settings->ChangeInstanceName (stripped_new_name); // Now see if there are any pending settings for the new name; if so, copy them into live_settings. std::map::iterator pending_pos; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun Sep 26 19:30:10 2010 @@ -87,6 +87,8 @@ m_objc_object_printer(*this), m_persistent_vars() { + UpdateInstanceName(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT); if (log) log->Printf ("%p Process::Process()", this); @@ -1884,6 +1886,20 @@ return g_settings_controller; } +void +Process::UpdateInstanceName () +{ + ModuleSP module_sp = GetTarget().GetExecutableModule(); + if (module_sp) + { + StreamString sstr; + sstr.Printf ("%s", module_sp->GetFileSpec().GetFilename().AsCString()); + + Process::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), + sstr.GetData()); + } +} + //-------------------------------------------------------------- // class Process::SettingsController //-------------------------------------------------------------- Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Sun Sep 26 19:30:10 2010 @@ -425,6 +425,8 @@ m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString())); } } + + UpdateInstanceName(); } @@ -792,6 +794,21 @@ lldb::eVarSetOperationAssign, false, "[]"); } +void +Target::UpdateInstanceName () +{ + StreamString sstr; + + ModuleSP module_sp = GetExecutableModule(); + if (module_sp) + { + sstr.Printf ("%s_%s", module_sp->GetFileSpec().GetFilename().AsCString(), + module_sp->GetArchitecture().AsCString()); + Target::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), + sstr.GetData()); + } +} + //-------------------------------------------------------------- // class Target::SettingsController //-------------------------------------------------------------- @@ -948,9 +965,9 @@ const ConstString TargetInstanceSettings::CreateInstanceName () { - static int instance_count = 1; StreamString sstr; - + static int instance_count = 1; + sstr.Printf ("target_%d", instance_count); ++instance_count; Modified: lldb/trunk/source/Target/TargetList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Target/TargetList.cpp (original) +++ lldb/trunk/source/Target/TargetList.cpp Sun Sep 26 19:30:10 2010 @@ -101,6 +101,9 @@ target_sp->SetExecutableModule (exe_module_sp, get_dependent_files); } } + + if (target_sp.get()) + target_sp->UpdateInstanceName(); if (target_sp.get()) { Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114808&r1=114807&r2=114808&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Sun Sep 26 19:30:10 2010 @@ -62,6 +62,7 @@ log->Printf ("%p Thread::Thread(tid = 0x%4.4x)", this, GetID()); QueueFundamentalPlan(true); + UpdateInstanceName(); } @@ -938,6 +939,21 @@ return g_settings_controller; } +void +Thread::UpdateInstanceName () +{ + StreamString sstr; + const char *name = GetName(); + + if (name && name[0] != '\0') + sstr.Printf ("%s", name); + else if ((GetIndexID() != 0) || (GetID() != 0)) + sstr.Printf ("0x%4.4x", GetIndexID(), GetID()); + + if (sstr.GetSize() > 0) + Thread::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); +} + //-------------------------------------------------------------- // class Thread::ThreadSettingsController //--------------------------------------------------------------