From gclayton at apple.com Mon Sep 26 02:11:28 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 26 Sep 2011 07:11:28 -0000 Subject: [Lldb-commits] [lldb] r140518 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Symbol/ scripts/Python/interface/ source/API/ source/Core/ source/Plugins/Disassembler/llvm/ source/Symbol/ source/Target/ Message-ID: <20110926071128.46EDA2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 26 02:11:27 2011 New Revision: 140518 URL: http://llvm.org/viewvc/llvm-project?rev=140518&view=rev Log: Added more functionality to the public API to allow for better symbolication. Also improved the SBInstruction API to allow access to the instruction opcode name, mnemonics, comment and instruction data. Added the ability to edit SBLineEntry objects (change the file, line and column), and also allow SBSymbolContext objects to be modified (set module, comp unit, function, block, line entry or symbol). The SymbolContext and SBSymbolContext can now generate inlined call stack infomration for symbolication much easier using the SymbolContext::GetParentInlinedFrameInfo(...) and SBSymbolContext::GetParentInlinedFrameInfo(...) methods. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBData.h lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/API/SBLineEntry.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/include/lldb/Core/Opcode.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/scripts/Python/interface/SBBlock.i lldb/trunk/scripts/Python/interface/SBInstruction.i lldb/trunk/scripts/Python/interface/SBLineEntry.i lldb/trunk/scripts/Python/interface/SBSymbolContext.i lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/API/SBLineEntry.cpp lldb/trunk/source/API/SBSymbolContext.cpp lldb/trunk/source/Core/Opcode.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Mon Sep 26 02:11:27 2011 @@ -97,6 +97,7 @@ protected: + friend class SBBlock; friend class SBBreakpointLocation; friend class SBFrame; friend class SBFunction; Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Mon Sep 26 02:11:27 2011 @@ -56,6 +56,31 @@ lldb::SBBlock GetFirstChild (); + uint32_t + GetNumRanges (); + + lldb::SBAddress + GetRangeStartAddress (uint32_t idx); + + lldb::SBAddress + GetRangeEndAddress (uint32_t idx); + + uint32_t + GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); + + //------------------------------------------------------------------ + /// Get the inlined block that contains this block. + /// + /// @return + /// If this block is inlined, it will return this block, else + /// parent blocks will be searched to see if any contain this + /// block and are themselves inlined. An invalid SBBlock will + /// be returned if this block nor any parent blocks are inlined + /// function blocks. + //------------------------------------------------------------------ + lldb::SBBlock + GetContainingInlinedBlock (); + bool GetDescription (lldb::SBStream &description); @@ -66,8 +91,8 @@ #ifndef SWIG - const lldb_private::Block * - get () const; + lldb_private::Block * + get (); void reset (lldb_private::Block *lldb_object_ptr); Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Mon Sep 26 02:11:27 2011 @@ -81,9 +81,9 @@ const lldb_private::CompileUnit & operator*() const; - const lldb_private::CompileUnit * - get () const; - + lldb_private::CompileUnit * + get (); + void reset (lldb_private::CompileUnit *lldb_object_ptr); Modified: lldb/trunk/include/lldb/API/SBData.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBData.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBData.h (original) +++ lldb/trunk/include/lldb/API/SBData.h Mon Sep 26 02:11:27 2011 @@ -125,8 +125,9 @@ SetOpaque (const lldb::DataExtractorSP &data_sp); private: - friend class SBValue; + friend class SBInstruction; friend class SBSection; + friend class SBValue; lldb::DataExtractorSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Mon Sep 26 02:11:27 2011 @@ -11,6 +11,7 @@ #define LLDB_SBInstruction_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBData.h" #include @@ -39,6 +40,18 @@ SBAddress GetAddress(); + + const char * + GetOpcodeName (lldb::SBTarget target); + + const char * + GetMnemonics (lldb::SBTarget target); + + const char * + GetComment (lldb::SBTarget target); + + lldb::SBData + GetData (lldb::SBTarget target); size_t GetByteSize (); Modified: lldb/trunk/include/lldb/API/SBLineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBLineEntry.h (original) +++ lldb/trunk/include/lldb/API/SBLineEntry.h Mon Sep 26 02:11:27 2011 @@ -49,6 +49,15 @@ uint32_t GetColumn () const; + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + #ifndef SWIG bool operator == (const lldb::SBLineEntry &rhs) const; @@ -77,8 +86,11 @@ const lldb_private::LineEntry * operator->() const; + lldb_private::LineEntry & + ref(); + const lldb_private::LineEntry & - operator*() const; + ref() const; #endif Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Mon Sep 26 02:11:27 2011 @@ -37,12 +37,24 @@ operator = (const lldb::SBSymbolContext &rhs); #endif - SBModule GetModule (); - SBCompileUnit GetCompileUnit (); - SBFunction GetFunction (); - SBBlock GetBlock (); - SBLineEntry GetLineEntry (); - SBSymbol GetSymbol (); + lldb::SBModule GetModule (); + lldb::SBCompileUnit GetCompileUnit (); + lldb::SBFunction GetFunction (); + lldb::SBBlock GetBlock (); + lldb::SBLineEntry GetLineEntry (); + lldb::SBSymbol GetSymbol (); + + void SetModule (lldb::SBModule module); + void SetCompileUnit (lldb::SBCompileUnit compile_unit); + void SetFunction (lldb::SBFunction function); + void SetBlock (lldb::SBBlock block); + void SetLineEntry (lldb::SBLineEntry line_entry); + void SetSymbol (lldb::SBSymbol symbol); + + SBSymbolContext + GetParentInlinedFrameInfo (const SBAddress &curr_frame_pc, + bool is_concrete_frame, + SBAddress &parent_frame_addr) const; bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Mon Sep 26 02:11:27 2011 @@ -476,6 +476,7 @@ friend class SBAddress; friend class SBDebugger; friend class SBFunction; + friend class SBInstruction; friend class SBProcess; friend class SBSymbol; friend class SBModule; Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Mon Sep 26 02:11:27 2011 @@ -40,6 +40,38 @@ { return m_address; } + + const char * + GetOpcodeName (ExecutionContextScope *exe_scope) + { + if (m_opcode_name.empty()) + CalculateOpcodeName(exe_scope); + return m_opcode_name.c_str(); + } + const char * + GetMnemonics (ExecutionContextScope *exe_scope) + { + if (m_mnemocics.empty()) + CalculateMnemonics(exe_scope); + return m_mnemocics.c_str(); + } + + const char * + GetComment (ExecutionContextScope *exe_scope) + { + if (m_comment.empty()) + CalculateComment(exe_scope); + return m_comment.c_str(); + } + + virtual void + CalculateOpcodeName (ExecutionContextScope *exe_scope) = 0; + + virtual void + CalculateMnemonics (ExecutionContextScope *exe_scope) = 0; + + virtual void + CalculateComment (ExecutionContextScope *exe_scope) = 0; AddressClass GetAddressClass (); @@ -109,6 +141,10 @@ // help us to disassemble appropriately. AddressClass m_address_class; Opcode m_opcode; // The opcode for this instruction + std::string m_opcode_name; + std::string m_mnemocics; + std::string m_comment; + }; @@ -161,7 +197,25 @@ virtual bool DoesBranch () const; + + virtual void + CalculateOpcodeName(ExecutionContextScope *exe_scope) + { + // TODO: fill this in and put opcode name into Instruction::m_opcode_name + } + virtual void + CalculateMnemonics(ExecutionContextScope *exe_scope) + { + // TODO: fill this in and put opcode name into Instruction::m_mnemonics + } + + virtual void + CalculateComment(ExecutionContextScope *exe_scope) + { + // TODO: fill this in and put opcode name into Instruction::m_comment + } + virtual size_t Decode (const lldb_private::Disassembler &disassembler, const lldb_private::DataExtractor &data, Modified: lldb/trunk/include/lldb/Core/Opcode.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Opcode.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Opcode.h (original) +++ lldb/trunk/include/lldb/Core/Opcode.h Mon Sep 26 02:11:27 2011 @@ -18,6 +18,11 @@ // Project includes #include "lldb/lldb-public.h" +namespace lldb +{ + class SBInstruction; +} + namespace lldb_private { class Opcode @@ -203,6 +208,26 @@ protected: + friend class lldb::SBInstruction; + + const void * + GetOpcodeDataBytes () const + { + switch (m_type) + { + case Opcode::eTypeInvalid: break; + case Opcode::eType8: return &m_data.inst8; + case Opcode::eType16: return &m_data.inst16; + case Opcode::eType32: return &m_data.inst32; + case Opcode::eType64: return &m_data.inst64; + case Opcode::eTypeBytes: return m_data.inst.bytes; + } + return NULL; + } + + lldb::ByteOrder + GetDataByteOrder () const; + Opcode::Type m_type; union { Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 26 02:11:27 2011 @@ -434,11 +434,17 @@ Block * FindBlockByID (lldb::user_id_t block_id); + uint32_t + GetNumRanges () const + { + return m_ranges.size(); + } + bool GetRangeContainingOffset (const lldb::addr_t offset, VMRange &range); bool - GetRangeContainingAddress (const Address& addr, AddressRange &range); + GetRangeContainingAddress (const Address& addr, AddressRange &range, uint32_t *range_idx_ptr = NULL); //------------------------------------------------------------------ // Since blocks might have multiple discontiguous addresss ranges, Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Mon Sep 26 02:11:27 2011 @@ -266,6 +266,12 @@ // const char *line_number, // const char *symbol); + bool + GetParentInlinedFrameInfo (const Address &curr_frame_pc, + bool is_concrete_frame, + SymbolContext &next_frame_sc, + Address &inlined_frame_addr) const; + //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ Modified: lldb/trunk/scripts/Python/interface/SBBlock.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBlock.i?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBBlock.i (original) +++ lldb/trunk/scripts/Python/interface/SBBlock.i Mon Sep 26 02:11:27 2011 @@ -63,6 +63,10 @@ lldb::SBBlock GetParent (); + %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; + lldb::SBBlock + GetContainingInlinedBlock (); + %feature("docstring", "Get the sibling block for this block.") GetSibling; lldb::SBBlock GetSibling (); @@ -70,6 +74,18 @@ %feature("docstring", "Get the first child block.") GetFirstChild; lldb::SBBlock GetFirstChild (); + + uint32_t + GetNumRanges (); + + lldb::SBAddress + GetRangeStartAddress (uint32_t idx); + + lldb::SBAddress + GetRangeEndAddress (uint32_t idx); + + uint32_t + GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/scripts/Python/interface/SBInstruction.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstruction.i?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBInstruction.i (original) +++ lldb/trunk/scripts/Python/interface/SBInstruction.i Mon Sep 26 02:11:27 2011 @@ -30,6 +30,18 @@ SBAddress GetAddress(); + const char * + GetOpcodeName (lldb::SBTarget target); + + const char * + GetMnemonics (lldb::SBTarget target); + + const char * + GetComment (lldb::SBTarget target); + + lldb::SBData + GetData (lldb::SBTarget target); + size_t GetByteSize (); Modified: lldb/trunk/scripts/Python/interface/SBLineEntry.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBLineEntry.i?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBLineEntry.i (original) +++ lldb/trunk/scripts/Python/interface/SBLineEntry.i Mon Sep 26 02:11:27 2011 @@ -67,6 +67,16 @@ bool GetDescription (lldb::SBStream &description); + + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + }; } // namespace lldb Modified: lldb/trunk/scripts/Python/interface/SBSymbolContext.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbolContext.i?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSymbolContext.i (original) +++ lldb/trunk/scripts/Python/interface/SBSymbolContext.i Mon Sep 26 02:11:27 2011 @@ -58,12 +58,25 @@ bool IsValid () const; - SBModule GetModule (); - SBCompileUnit GetCompileUnit (); - SBFunction GetFunction (); - SBBlock GetBlock (); - SBLineEntry GetLineEntry (); - SBSymbol GetSymbol (); + lldb::SBModule GetModule (); + lldb::SBCompileUnit GetCompileUnit (); + lldb::SBFunction GetFunction (); + lldb::SBBlock GetBlock (); + lldb::SBLineEntry GetLineEntry (); + lldb::SBSymbol GetSymbol (); + + void SetModule (lldb::SBModule module); + void SetCompileUnit (lldb::SBCompileUnit compile_unit); + void SetFunction (lldb::SBFunction function); + void SetBlock (lldb::SBBlock block); + void SetLineEntry (lldb::SBLineEntry line_entry); + void SetSymbol (lldb::SBSymbol symbol); + + lldb::SBSymbolContext + GetParentInlinedFrameInfo (const lldb::SBAddress &curr_frame_pc, + bool is_concrete_frame, + lldb::SBAddress &parent_frame_addr) const; + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Mon Sep 26 02:11:27 2011 @@ -8,8 +8,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBlock.h" +#include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/AddressRange.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" @@ -127,6 +129,15 @@ return sb_block; } +lldb::SBBlock +SBBlock::GetContainingInlinedBlock () +{ + SBBlock sb_block; + if (m_opaque_ptr) + sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock (); + return sb_block; +} + SBBlock SBBlock::GetSibling () { @@ -145,8 +156,8 @@ return sb_block; } -const lldb_private::Block * -SBBlock::get () const +lldb_private::Block * +SBBlock::get () { return m_opaque_ptr; } @@ -181,3 +192,59 @@ return true; } + +uint32_t +SBBlock::GetNumRanges () +{ + if (m_opaque_ptr) + return m_opaque_ptr->GetNumRanges(); + return 0; +} + +lldb::SBAddress +SBBlock::GetRangeStartAddress (uint32_t idx) +{ + lldb::SBAddress sb_addr; + if (m_opaque_ptr) + { + AddressRange range; + if (m_opaque_ptr->GetRangeAtIndex(idx, range)) + { + sb_addr.ref() = range.GetBaseAddress(); + } + } + return sb_addr; +} + +lldb::SBAddress +SBBlock::GetRangeEndAddress (uint32_t idx) +{ + lldb::SBAddress sb_addr; + if (m_opaque_ptr) + { + AddressRange range; + if (m_opaque_ptr->GetRangeAtIndex(idx, range)) + { + sb_addr.ref() = range.GetBaseAddress(); + sb_addr.ref().Slide(range.GetByteSize()); + } + } + return sb_addr; +} + +uint32_t +SBBlock::GetRangeIndexForBlockAddress (lldb::SBAddress block_addr) +{ + if (m_opaque_ptr && block_addr.IsValid()) + { + uint32_t range_idx = UINT32_MAX; + AddressRange range; + if (m_opaque_ptr->GetRangeContainingAddress (block_addr.ref(), range, &range_idx)) + { + return range_idx; + } + } + + return UINT32_MAX; +} + Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Mon Sep 26 02:11:27 2011 @@ -173,8 +173,8 @@ return *m_opaque_ptr; } -const lldb_private::CompileUnit * -SBCompileUnit::get () const +lldb_private::CompileUnit * +SBCompileUnit::get () { return m_opaque_ptr; } Modified: lldb/trunk/source/API/SBInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstruction.cpp (original) +++ lldb/trunk/source/API/SBInstruction.cpp Mon Sep 26 02:11:27 2011 @@ -16,6 +16,7 @@ #include "lldb/API/SBTarget.h" #include "lldb/Core/ArchSpec.h" +#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/StreamFile.h" @@ -67,6 +68,60 @@ return sb_addr; } +const char * +SBInstruction::GetOpcodeName(SBTarget target) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker; + ExecutionContext exe_ctx; + if (target.IsValid()) + { + api_locker.Reset (target->GetAPIMutex().GetMutex()); + target->CalculateExecutionContext (exe_ctx); + exe_ctx.SetProcessSP(target->GetProcessSP()); + } + return m_opaque_sp->GetOpcodeName(exe_ctx.GetBestExecutionContextScope()); + } + return NULL; +} + +const char * +SBInstruction::GetMnemonics(SBTarget target) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker; + ExecutionContext exe_ctx; + if (target.IsValid()) + { + api_locker.Reset (target->GetAPIMutex().GetMutex()); + target->CalculateExecutionContext (exe_ctx); + exe_ctx.SetProcessSP(target->GetProcessSP()); + } + return m_opaque_sp->GetMnemonics(exe_ctx.GetBestExecutionContextScope()); + } + return NULL; +} + +const char * +SBInstruction::GetComment(SBTarget target) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker; + ExecutionContext exe_ctx; + if (target.IsValid()) + { + api_locker.Reset (target->GetAPIMutex().GetMutex()); + target->CalculateExecutionContext (exe_ctx); + exe_ctx.SetProcessSP(target->GetProcessSP()); + } + return m_opaque_sp->GetComment(exe_ctx.GetBestExecutionContextScope()); + } + return NULL; +} + size_t SBInstruction::GetByteSize () { @@ -75,6 +130,32 @@ return 0; } +SBData +SBInstruction::GetData (SBTarget target) +{ + lldb::SBData sb_data; + if (m_opaque_sp) + { + const Opcode &opcode = m_opaque_sp->GetOpcode(); + const void *opcode_data = opcode.GetOpcodeBytes(); + const uint32_t opcode_data_size = opcode.GetByteSize(); + if (opcode_data && opcode_data_size > 0) + { + ByteOrder data_byte_order = opcode.GetDataByteOrder(); + if (data_byte_order == eByteOrderInvalid) + data_byte_order = target->GetArchitecture().GetByteOrder(); + DataBufferSP data_buffer_sp (new DataBufferHeap (opcode_data, opcode_data_size)); + DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp, + data_byte_order, + target.IsValid() ? target->GetArchitecture().GetAddressByteSize() : sizeof(void*))); + sb_data.SetOpaque (data_extractor_sp); + } + } + return sb_data; +} + + + bool SBInstruction::DoesBranch () { Modified: lldb/trunk/source/API/SBLineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLineEntry.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/API/SBLineEntry.cpp (original) +++ lldb/trunk/source/API/SBLineEntry.cpp Mon Sep 26 02:11:27 2011 @@ -28,33 +28,33 @@ m_opaque_ap () { if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::LineEntry (*rhs)); + ref() = rhs.ref(); } - - SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) : m_opaque_ap () { if (lldb_object_ptr) - m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); + ref() = *lldb_object_ptr; } const SBLineEntry & SBLineEntry::operator = (const SBLineEntry &rhs) { - if (this != &rhs && rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::LineEntry(*rhs)); + if (this != &rhs) + { + if (rhs.IsValid()) + ref() = rhs.ref(); + else + m_opaque_ap.reset(); + } return *this; } void SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref) { - if (m_opaque_ap.get()) - (*m_opaque_ap.get()) = lldb_object_ref; - else - m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref)); + ref() = lldb_object_ref; } @@ -156,6 +156,28 @@ return 0; } +void +SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec) +{ + if (filespec.IsValid()) + ref().file = filespec.ref(); + else + ref().file.Clear(); +} +void +SBLineEntry::SetLine (uint32_t line) +{ + ref().line = line; +} + +void +SBLineEntry::SetColumn (uint32_t column) +{ + ref().line = column; +} + + + bool SBLineEntry::operator == (const SBLineEntry &rhs) const { @@ -186,8 +208,16 @@ return m_opaque_ap.get(); } +lldb_private::LineEntry & +SBLineEntry::ref() +{ + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new lldb_private::LineEntry ()); + return *m_opaque_ap; +} + const lldb_private::LineEntry & -SBLineEntry::operator*() const +SBLineEntry::ref() const { return *m_opaque_ap; } Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Mon Sep 26 02:11:27 2011 @@ -10,6 +10,7 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" @@ -173,6 +174,46 @@ return sb_symbol; } +void +SBSymbolContext::SetModule (lldb::SBModule module) +{ + ref().module_sp = module.get_sp(); +} + +void +SBSymbolContext::SetCompileUnit (lldb::SBCompileUnit compile_unit) +{ + ref().comp_unit = compile_unit.get(); +} + +void +SBSymbolContext::SetFunction (lldb::SBFunction function) +{ + ref().function = function.get(); +} + +void +SBSymbolContext::SetBlock (lldb::SBBlock block) +{ + ref().block = block.get(); +} + +void +SBSymbolContext::SetLineEntry (lldb::SBLineEntry line_entry) +{ + if (line_entry.IsValid()) + ref().line_entry = line_entry.ref(); + else + ref().line_entry.Clear(); +} + +void +SBSymbolContext::SetSymbol (lldb::SBSymbol symbol) +{ + ref().symbol = symbol.get(); +} + + lldb_private::SymbolContext* SBSymbolContext::operator->() const { @@ -223,3 +264,18 @@ return true; } + +SBSymbolContext +SBSymbolContext::GetParentInlinedFrameInfo (const SBAddress &curr_frame_pc, + bool is_concrete_frame, + SBAddress &parent_frame_addr) const +{ + SBSymbolContext sb_sc; + if (m_opaque_ap.get() && curr_frame_pc.IsValid()) + { + if (m_opaque_ap->GetParentInlinedFrameInfo (curr_frame_pc.ref(), is_concrete_frame, sb_sc.ref(), parent_frame_addr.ref())) + return sb_sc; + } + return SBSymbolContext(); +} + Modified: lldb/trunk/source/Core/Opcode.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Opcode.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Core/Opcode.cpp (original) +++ lldb/trunk/source/Core/Opcode.cpp Mon Sep 26 02:11:27 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Stream.h" +#include "lldb/Host/Endian.h" using namespace lldb; using namespace lldb_private; @@ -62,3 +63,19 @@ return bytes_written; } +lldb::ByteOrder +Opcode::GetDataByteOrder () const +{ + switch (m_type) + { + case Opcode::eTypeInvalid: break; + case Opcode::eType8: + case Opcode::eType16: + case Opcode::eType32: + case Opcode::eType64: return lldb::endian::InlHostByteOrder(); + case Opcode::eTypeBytes: + break; + } + return eByteOrderInvalid; +} + Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon Sep 26 02:11:27 2011 @@ -99,13 +99,15 @@ s->Printf("%s ", str.c_str()); } static void -AddSymbolicInfo(const ExecutionContext *exe_ctx, ExecutionContextScope *exe_scope, - StreamString &comment, uint64_t operand_value, const Address &inst_addr) +AddSymbolicInfo (ExecutionContextScope *exe_scope, + StreamString &comment, + uint64_t operand_value, + const Address &inst_addr) { Address so_addr; Target *target = NULL; - if (exe_ctx) - target = exe_ctx->GetTargetPtr(); + if (exe_scope) + target = exe_scope->CalculateTarget(); if (target && !target->GetSectionLoadList().IsEmpty()) { if (target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr)) @@ -225,12 +227,16 @@ if (numTokens != -1 && !raw) { addr_t base_addr = LLDB_INVALID_ADDRESS; - + uint32_t addr_nibble_size = 8; Target *target = NULL; if (exe_ctx) target = exe_ctx->GetTargetPtr(); - if (target && !target->GetSectionLoadList().IsEmpty()) - base_addr = GetAddress().GetLoadAddress (target); + if (target) + { + if (!target->GetSectionLoadList().IsEmpty()) + base_addr = GetAddress().GetLoadAddress (target); + addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2; + } if (base_addr == LLDB_INVALID_ADDRESS) base_addr = GetAddress().GetFileAddress (); @@ -314,16 +320,16 @@ { if (EDInstIsBranch(m_inst)) { - operands.Printf("0x%llx ", operand_value); + operands.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value); show_token = false; } else { // Put the address value into the comment - comment.Printf("0x%llx ", operand_value); + comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value); } - AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); + AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress()); } // EDEvaluateOperand } // EDOperandIsMemory } // EDGetOperand @@ -351,8 +357,8 @@ if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { uint64_t operand_value = PC + atoi(++pos); // Put the address value into the operands. - operands.Printf("0x%llx ", operand_value); - AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); + operands.Printf("0x%8.8llx ", operand_value); + AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress()); } } // Yet more workaround for "bl #..." and "blx #...". @@ -369,12 +375,12 @@ } uint64_t operand_value = PC + atoi(++pos); // Put the address value into the comment. - comment.Printf("0x%llx ", operand_value); + comment.Printf("0x%8.8llx ", operand_value); // And the original token string into the operands. llvm::StringRef Str(pos - 1); RStrip(Str, '\n'); operands.PutCString(Str.str().c_str()); - AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); + AddSymbolicInfo(exe_scope, comment, operand_value, GetAddress()); } } // END of workaround. @@ -423,6 +429,144 @@ } } +void +InstructionLLVM::CalculateOpcodeName (ExecutionContextScope *exe_scope) +{ + const int num_tokens = EDNumTokens(m_inst); + if (num_tokens > 0) + { + const char *token_cstr = NULL; + int currentOpIndex = -1; + StreamString comment; + uint32_t addr_nibble_size = 8; + addr_t base_addr = LLDB_INVALID_ADDRESS; + Target *target = NULL; + if (exe_scope) + target = exe_scope->CalculateTarget(); + if (target && !target->GetSectionLoadList().IsEmpty()) + base_addr = GetAddress().GetLoadAddress (target); + if (base_addr == LLDB_INVALID_ADDRESS) + base_addr = GetAddress().GetFileAddress (); + addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2; + + lldb::addr_t PC = base_addr + EDInstByteSize(m_inst); + + // When executing an ARM instruction, PC reads as the address of the + // current instruction plus 8. And for Thumb, it is plus 4. + if (m_arch_type == llvm::Triple::arm) + PC = base_addr + 8; + else if (m_arch_type == llvm::Triple::thumb) + PC = base_addr + 4; + + RegisterReaderArg rra(PC, m_disassembler); + + for (int token_idx = 0; token_idx < num_tokens; ++token_idx) + { + EDTokenRef token; + if (EDGetToken(&token, m_inst, token_idx)) + break; + + if (EDTokenIsOpcode(token) == 1) + { + if (EDGetTokenString(&token_cstr, token) == 0) // 0 on success + { + if (token_cstr) + m_opcode_name.assign(token_cstr); + } + } + else + { + int operandIndex = EDOperandIndexForToken(token); + + if (operandIndex >= 0) + { + if (operandIndex != currentOpIndex) + { + currentOpIndex = operandIndex; + EDOperandRef operand; + + if (!EDGetOperand(&operand, m_inst, currentOpIndex)) + { + if (EDOperandIsMemory(operand)) + { + uint64_t operand_value; + + if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra)) + { + comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value); + AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress()); + } + } + } + } + } + if (m_mnemocics.empty() && EDTokenIsWhitespace (token) == 1) + continue; + if (EDGetTokenString (&token_cstr, token)) + break; + m_mnemocics.append (token_cstr); + } + } + // FIXME!!! + // Workaround for llvm::tB's operands not properly parsed by ARMAsmParser. + if (m_arch_type == llvm::Triple::thumb && m_opcode_name.compare("b") == 0) + { + const char *inst_str; + const char *pos = NULL; + comment.Clear(); + if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) + { + uint64_t operand_value = PC + atoi(++pos); + // Put the address value into the operands. + comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value); + AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress()); + } + } + // Yet more workaround for "bl #..." and "blx #...". + if ((m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb) && + (m_opcode_name.compare("bl") == 0 || m_opcode_name.compare("blx") == 0)) + { + const char *inst_str; + const char *pos = NULL; + comment.Clear(); + if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) + { + if (m_arch_type == llvm::Triple::thumb && m_opcode_name.compare("blx") == 0) + { + // A8.6.23 BLX (immediate) + // Target Address = Align(PC,4) + offset value + PC = AlignPC(PC); + } + uint64_t operand_value = PC + atoi(++pos); + // Put the address value into the comment. + comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value); + // And the original token string into the operands. +// llvm::StringRef Str(pos - 1); +// RStrip(Str, '\n'); +// operands.PutCString(Str.str().c_str()); + AddSymbolicInfo (exe_scope, comment, operand_value, GetAddress()); + } + } + // END of workaround. + + m_comment.swap (comment.GetString()); + } +} + +void +InstructionLLVM::CalculateMnemonics(ExecutionContextScope *exe_scope) +{ + // Do all of the work in CalculateOpcodeName() + CalculateOpcodeName (exe_scope); +} + +void +InstructionLLVM::CalculateComment(ExecutionContextScope *exe_scope) +{ + // Do all of the work in CalculateOpcodeName() + CalculateOpcodeName (exe_scope); +} + bool InstructionLLVM::DoesBranch() const { Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Mon Sep 26 02:11:27 2011 @@ -43,6 +43,15 @@ const lldb_private::DataExtractor &data, uint32_t data_offset); + virtual void + CalculateOpcodeName (lldb_private::ExecutionContextScope *exe_scope); + + virtual void + CalculateMnemonics (lldb_private::ExecutionContextScope *exe_scope); + + virtual void + CalculateComment (lldb_private::ExecutionContextScope *exe_scope); + protected: EDDisassemblerRef m_disassembler; EDInstRef m_inst; Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 26 02:11:27 2011 @@ -367,7 +367,7 @@ bool -Block::GetRangeContainingAddress (const Address& addr, AddressRange &range) +Block::GetRangeContainingAddress (const Address& addr, AddressRange &range, uint32_t *range_idx_ptr) { Function *function = CalculateSymbolContextFunction(); if (function) @@ -387,11 +387,15 @@ range.GetBaseAddress() = func_range.GetBaseAddress(); range.GetBaseAddress().SetOffset(func_offset + m_ranges[range_idx].GetBaseAddress()); range.SetByteSize(m_ranges[range_idx].GetByteSize()); + if (range_idx_ptr) + *range_idx_ptr = range_idx; return true; } } } } + if (range_idx_ptr) + *range_idx_ptr = UINT32_MAX; range.Clear(); return false; } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Mon Sep 26 02:11:27 2011 @@ -487,6 +487,95 @@ return return_value; } +bool +SymbolContext::GetParentInlinedFrameInfo (const Address &curr_frame_pc, + bool is_concrete_frame, + SymbolContext &next_frame_sc, + Address &inlined_frame_addr) const +{ + next_frame_sc.Clear(); + inlined_frame_addr.Clear(); + + if (block) + { + bool concrete_has_inlines = false; + Block *curr_inlined_block = NULL; + Block *next_inlined_block = NULL; + //const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress(); + if (is_concrete_frame) + { + curr_inlined_block = block->GetContainingInlinedBlock(); + if (curr_inlined_block) + { + concrete_has_inlines = true; + next_inlined_block = curr_inlined_block->GetInlinedParent(); + } + } + else + { + curr_inlined_block = block; + next_inlined_block = block->GetInlinedParent(); + } + + if (next_inlined_block) + { + next_inlined_block->CalculateSymbolContext (&next_frame_sc); + + AddressRange range; + bool got_range = curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range); + assert (got_range); + const InlineFunctionInfo* inline_info = next_inlined_block->GetInlinedFunctionInfo(); + if (inline_info) + { + inlined_frame_addr = range.GetBaseAddress(); + next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr; + next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile(); + next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine(); + next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn(); + return true; + } + } + else if (is_concrete_frame && !concrete_has_inlines) + { + // This is the symbol context for the frame that was found using the + // PC value and there are no inlined blocks so there are no inlined + // parent frames. + return false; + } + else + { + // We have had inlined frames before and now we are at the function + // instance that called the inlined frames. + // The SymbolContext object should contain a previous inline symbol + // context which we need to use to get the file, line and column info + const InlineFunctionInfo* inline_info = curr_inlined_block->GetInlinedFunctionInfo(); + if (inline_info) + { + Block *parent_block = curr_inlined_block->GetParent(); + if (parent_block) + { + parent_block->CalculateSymbolContext (&next_frame_sc); + + AddressRange range; + if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range)) + { + inlined_frame_addr = range.GetBaseAddress(); + //const addr_t range_file_file_addr = inlined_frame_addr.GetFileAddress(); + next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr; + next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile(); + next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine(); + next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn(); + return true; + } + } + } + } + } + + return false; +} + + //---------------------------------------------------------------------- // // SymbolContextSpecifier Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=140518&r1=140517&r2=140518&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 26 02:11:27 2011 @@ -39,15 +39,12 @@ #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1) #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1) -StackFrame::StackFrame -( - user_id_t frame_idx, - user_id_t unwind_frame_index, - Thread &thread, - addr_t cfa, - addr_t pc, - const SymbolContext *sc_ptr -) : +StackFrame::StackFrame (user_id_t frame_idx, + user_id_t unwind_frame_index, + Thread &thread, + addr_t cfa, + addr_t pc, + const SymbolContext *sc_ptr) : m_thread (thread), m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), @@ -69,16 +66,13 @@ } } -StackFrame::StackFrame -( - user_id_t frame_idx, - user_id_t unwind_frame_index, - Thread &thread, - const RegisterContextSP ®_context_sp, - addr_t cfa, - addr_t pc, - const SymbolContext *sc_ptr -) : +StackFrame::StackFrame (user_id_t frame_idx, + user_id_t unwind_frame_index, + Thread &thread, + const RegisterContextSP ®_context_sp, + addr_t cfa, + addr_t pc, + const SymbolContext *sc_ptr) : m_thread (thread), m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), @@ -106,16 +100,13 @@ } } -StackFrame::StackFrame -( - user_id_t frame_idx, - user_id_t unwind_frame_index, - Thread &thread, - const RegisterContextSP ®_context_sp, - addr_t cfa, - const Address& pc_addr, - const SymbolContext *sc_ptr -) : +StackFrame::StackFrame (user_id_t frame_idx, + user_id_t unwind_frame_index, + Thread &thread, + const RegisterContextSP ®_context_sp, + addr_t cfa, + const Address& pc_addr, + const SymbolContext *sc_ptr) : m_thread (thread), m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), From johnny.chen at apple.com Mon Sep 26 13:05:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 26 Sep 2011 18:05:16 -0000 Subject: [Lldb-commits] [lldb] r140540 - /lldb/trunk/source/API/SBFrame.cpp Message-ID: <20110926180516.C413A2A6C12C@llvm.org> Author: johnny Date: Mon Sep 26 13:05:16 2011 New Revision: 140540 URL: http://llvm.org/viewvc/llvm-project?rev=140540&view=rev Log: Modify SBFrame::WatchValue() impl so that for the watchpoint location created, it also populates the variable declaration location if possible. Modified: lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=140540&r1=140539&r2=140540&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Sep 26 13:05:16 2011 @@ -440,6 +440,18 @@ WatchpointLocationSP wp_loc_sp = m_opaque_sp->GetThread().GetProcess().GetTarget(). CreateWatchpointLocation(addr, size, watch_type); + if (wp_loc_sp) { + // StackFrame::GetInScopeVariableList(true) to get file globals as well. + VariableListSP var_list_sp(m_opaque_sp->GetInScopeVariableList(true)); + VariableSP var_sp = var_list_sp->FindVariable(ConstString(name)); + if (var_sp && var_sp->GetDeclaration().GetFile()) { + StreamString ss; + // True to show fullpath for declaration file. + var_sp->GetDeclaration().DumpStopContext(&ss, true); + wp_loc_sp->SetDeclInfo(ss.GetString()); + } + } + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::WatchValue (name=\"%s\", value_type=%i, watch_type=%i) => SBValue(%p) & wp_loc(%p)", From gclayton at apple.com Mon Sep 26 13:39:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 26 Sep 2011 18:39:23 -0000 Subject: [Lldb-commits] [lldb] r140544 - /lldb/trunk/examples/python/symbolicate-crash.py Message-ID: <20110926183923.BD6102A6C12C@llvm.org> Author: gclayton Date: Mon Sep 26 13:39:23 2011 New Revision: 140544 URL: http://llvm.org/viewvc/llvm-project?rev=140544&view=rev Log: Added an example that symbolicates symbol information. This file is mostly geared towards darwin crash logs at the moment, though it could be made more generic with a few tweaks. The symbolicate-crash.py script will make a target given a crash log and then symbolicate all frames and expand any frames that had inlined functions in them to show all frames back to the concrete function. It will also disassemble around the crash site. Added: lldb/trunk/examples/python/symbolicate-crash.py (with props) Added: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=140544&view=auto ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (added) +++ lldb/trunk/examples/python/symbolicate-crash.py Mon Sep 26 13:39:23 2011 @@ -0,0 +1,565 @@ +#!/usr/bin/python + +#---------------------------------------------------------------------- +# Be sure to add the python path that points to the LLDB shared library. +# On MacOSX csh, tcsh: +# setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +# On MacOSX sh, bash: +# export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +#---------------------------------------------------------------------- + +import lldb +import optparse +import os +import re +import sys +import time + +PARSE_MODE_NORMAL = 0 +PARSE_MODE_THREAD = 1 +PARSE_MODE_IMAGES = 2 +PARSE_MODE_THREGS = 3 +PARSE_MODE_SYSTEM = 4 + +class CrashLog: + """Class that does parses darwin crash logs""" + thread_state_regex = re.compile('^Thread ([0-9]+) crashed with') + thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)') + frame_regex = re.compile('^([0-9]+).*(0x[0-9a-fA-F]+) +(.*)') + image_regex = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([\.0-9\?]+) \(([^)]+)\) <([-0-9a-fA-F]+)> (.*)'); + empty_line_regex = re.compile('^$') + + class Thread: + """Class that represents a thread in a darwin crash log""" + def __init__(self, index): + self.index = index + self.frames = list() + self.registers = dict() + self.reason = None + self.queue = None + + def dump(self, prefix): + print "%sThread[%u] %s" % (prefix, self.index, self.reason) + if self.frames: + print "%s Frames:" % (prefix) + for frame in self.frames: + frame.dump(prefix + ' ') + if self.registers: + print "%s Registers:" % (prefix) + for reg in self.registers.keys(): + print "%s %-5s = %#16.16x" % (prefix, reg, self.registers[reg]) + + def did_crash(self): + return self.reason != None + + def __str__(self): + s = "Thread[%u]" % self.index + if self.reason: + s += ' %s' % self.reason + return s + + class Frame: + """Class that represents a stack frame in a thread in a darwin crash log""" + def __init__(self, index, pc, details): + self.index = index + self.pc = pc + self.sym_ctx = None + self.details = details + + def __str__(self): + return "[%2u] %#16.16x %s" % (self.index, self.pc, self.details) + + def dump(self, prefix): + print "%s%s" % (prefix, self) + + class Image: + """Class that represents a binary images in a darwin crash log""" + def __init__(self, text_addr_lo, text_addr_hi, ident, version, compatability_version, uuid, path): + self.text_addr_lo = text_addr_lo + self.text_addr_hi = text_addr_hi + self.ident = ident + self.version = version + self.compatability_version = compatability_version + self.uuid = uuid + self.path = path + + def dump(self, prefix): + print "%s%s" % (prefix, self) + + def __str__(self): + return "%#16.16x %s %s" % (self.text_addr_lo, self.uuid, self.path) + + + def __init__(self, path): + """CrashLog constructor that take a path to a darwin crash log file""" + self.path = path; + self.info_lines = list() + self.system_profile = list() + self.threads = list() + self.images = list() + self.crashed_thread_idx = -1 + self.version = -1 + f = open(self.path) + self.file_lines = f.read().splitlines() + parse_mode = PARSE_MODE_NORMAL + thread = None + for line in self.file_lines: + # print line + line_len = len(line) + if line_len == 0: + if thread: + if parse_mode == PARSE_MODE_THREAD: + if thread.index == self.crashed_thread_idx: + thread.reason = '' + if self.thread_exception: + thread.reason += self.thread_exception + if self.thread_exception_data: + thread.reason += " (%s)" % self.thread_exception_data + self.threads.append(thread) + thread = None + else: + # only append an extra empty line if the previous line + # in the info_lines wasn't empty + if len(self.info_lines) > 0 and len(self.info_lines[-1]): + self.info_lines.append(line) + parse_mode = PARSE_MODE_NORMAL + # print 'PARSE_MODE_NORMAL' + elif parse_mode == PARSE_MODE_NORMAL: + if line.startswith ('Process:'): + (self.process_name, pid_with_brackets) = line[8:].strip().split() + self.process_id = pid_with_brackets.strip('[]') + elif line.startswith ('Path:'): + self.process_path = line[5:].strip() + elif line.startswith ('Identifier:'): + self.process_identifier = line[11:].strip() + elif line.startswith ('Version:'): + (self.process_version, compatability_version) = line[8:].strip().split() + self.process_compatability_version = compatability_version.strip('()') + elif line.startswith ('Parent Process:'): + (self.parent_process_name, pid_with_brackets) = line[15:].strip().split() + self.parent_process_id = pid_with_brackets.strip('[]') + elif line.startswith ('Exception Type:'): + self.thread_exception = line[15:].strip() + continue + elif line.startswith ('Exception Codes:'): + self.thread_exception_data = line[16:].strip() + continue + elif line.startswith ('Crashed Thread:'): + self.crashed_thread_idx = int(line[15:].strip().split()[0]) + continue + elif line.startswith ('Report Version:'): + self.version = int(line[15:].strip()) + continue + elif line.startswith ('System Profile:'): + parse_mode = PARSE_MODE_SYSTEM + continue + elif (line.startswith ('Interval Since Last Report:') or + line.startswith ('Crashes Since Last Report:') or + line.startswith ('Per-App Interval Since Last Report:') or + line.startswith ('Per-App Crashes Since Last Report:') or + line.startswith ('Sleep/Wake UUID:') or + line.startswith ('Anonymous UUID:')): + # ignore these + continue + elif line.startswith ('Thread'): + thread_state_match = self.thread_state_regex.search (line) + if thread_state_match: + thread_state_match = self.thread_regex.search (line) + thread_idx = int(thread_state_match.group(1)) + parse_mode = PARSE_MODE_THREGS + thread = self.threads[thread_idx] + else: + thread_match = self.thread_regex.search (line) + if thread_match: + # print 'PARSE_MODE_THREAD' + parse_mode = PARSE_MODE_THREAD + thread_idx = int(thread_match.group(1)) + thread = CrashLog.Thread(thread_idx) + continue + elif line.startswith ('Binary Images:'): + parse_mode = PARSE_MODE_IMAGES + continue + self.info_lines.append(line.strip()) + elif parse_mode == PARSE_MODE_THREAD: + frame_match = self.frame_regex.search(line) + if frame_match: + thread.frames.append (CrashLog.Frame(int(frame_match.group(1)), int(frame_match.group(2), 0), frame_match.group(3))) + else: + print "error: frame regex failed" + elif parse_mode == PARSE_MODE_IMAGES: + image_match = self.image_regex.search (line) + if image_match: + image = CrashLog.Image (int(image_match.group(1),0), + int(image_match.group(2),0), + image_match.group(3), + image_match.group(4), + image_match.group(5), + image_match.group(6), + image_match.group(7)) + self.images.append (image) + else: + print "error: image regex failed" + elif parse_mode == PARSE_MODE_THREGS: + stripped_line = line.strip() + reg_values = stripped_line.split(' ') + for reg_value in reg_values: + (reg, value) = reg_value.split(': ') + thread.registers[reg.strip()] = int(value, 0) + elif parse_mode == PARSE_MODE_SYSTEM: + self.system_profile.append(line) + f.close() + + def dump(self): + print "Crash Log File: %s" % (self.path) + print "\nThreads:" + for thread in self.threads: + thread.dump(' ') + print "\nImages:" + for image in self.images: + image.dump(' ') + +def disassemble_instructions (target, instructions, pc, insts_before_pc, insts_after_pc): + lines = list() + pc_index = -1 + comment_column = 50 + for inst_idx, inst in enumerate(instructions): + inst_pc = inst.GetAddress().GetLoadAddress(target); + if pc == inst_pc: + pc_index = inst_idx + opcode_name = inst.GetOpcodeName(target) + mnemonics = inst.GetMnemonics(target) + comment = inst.GetComment(target) + #data = inst.GetData(target) + lines.append ("%#16.16x: %8s %s" % (inst_pc, opcode_name, mnemonics)) + if comment: + line_len = len(lines[-1]) + if line_len < comment_column: + lines[-1] += ' ' * (comment_column - line_len) + lines[-1] += "; %s" % comment + + if pc_index >= 0: + if pc_index >= insts_before_pc: + start_idx = pc_index - insts_before_pc + else: + start_idx = 0 + end_idx = pc_index + insts_after_pc + if end_idx > inst_idx: + end_idx = inst_idx + for i in range(start_idx, end_idx+1): + if i == pc_index: + print ' -> ', lines[i] + else: + print ' ', lines[i] + +def print_module_section_data (section): + print section + section_data = section.GetSectionData() + if section_data: + ostream = lldb.SBStream() + section_data.GetDescription (ostream, section.GetFileAddress()) + print ostream.GetData() + +def print_module_section (section, depth): + print section + + if depth > 0: + num_sub_sections = section.GetNumSubSections() + for sect_idx in range(num_sub_sections): + print_module_section (section.GetSubSectionAtIndex(sect_idx), depth - 1) + +def print_module_sections (module, depth): + num_sections = module.GetNumSections() + + for sect_idx in range(num_sections): + section = module.GetSectionAtIndex(sect_idx) + print_module_section (section, depth) + +def print_module_symbols (module): + n = module.GetNumSymbols() + + for i in range(n): + print module.GetSymbolAtIndex(i) + +def usage(): + print "Usage: lldb-symbolicate.py [-n name] executable-image" + sys.exit(0) + + +if __name__ == '__main__': + parser = optparse.OptionParser(description='A script that parses skinny and universal mach-o files.') + parser.add_option('--arch', type='string', metavar='arch', dest='triple', help='specify one architecture or target triple') + parser.add_option('--platform', type='string', metavar='platform', dest='platform', help='specify one platform by name') + parser.add_option('--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False) + parser.add_option('--interactive', action='store_true', dest='interactive', help='enable interactive mode', default=False) + parser.add_option('--no-images', action='store_false', dest='show_images', help='don\'t show images in stack frames', default=True) + parser.add_option('--no-dependents', action='store_false', dest='dependents', help='skip loading dependent modules', default=True) + parser.add_option('--sections', action='store_true', dest='dump_sections', help='show module sections', default=False) + parser.add_option('--symbols', action='store_true', dest='dump_symbols', help='show module symbols', default=False) + parser.add_option('--image-list', action='store_true', dest='dump_image_list', help='show image list', default=False) + parser.add_option('--debug-delay', type='int', dest='debug_delay', metavar='NSEC', help='pause for NSEC seconds for debugger', default=0) + parser.add_option('--section-depth', type='int', dest='section_depth', help='set the section depth to use when showing sections', default=0) + parser.add_option('--section-data', type='string', action='append', dest='sect_data_names', help='specify sections by name to display data for') + parser.add_option('--address', type='int', action='append', dest='addresses', help='specify addresses to lookup') + parser.add_option('--crash-log', type='string', action='append', dest='crash_log_files', help='specify crash log files to symbolicate') + parser.add_option('--crashed-only', action='store_true', dest='crashed_only', help='only show the crashed thread', default=False) + loaded_addresses = False + (options, args) = parser.parse_args() + if options.verbose: + print 'options', options + + if options.debug_delay > 0: + print "Waiting %u seconds for debugger to attach..." % options.debug_delay + time.sleep(options.debug_delay) + + # Create a new debugger instance + debugger = lldb.SBDebugger.Create() + + # When we step or continue, don't return from the function until the process + # stops. We do this by setting the async mode to false. + debugger.SetAsync (False) + error = lldb.SBError() + + if options.crash_log_files: + options.dependents = False + for crash_log_file in options.crash_log_files: + triple = "x86_64" + crash_log = CrashLog(crash_log_file) + #crash_log.dump() + target = debugger.CreateTarget (crash_log.process_path, options.triple, options.platform, options.dependents, error); + exe_module = target.GetModuleAtIndex(0) + loaded_images = list() + for image in crash_log.images: + if image.path == crash_log.process_path: + module = exe_module + else: + module = target.AddModule (image.path, options.triple, image.uuid) + if module in loaded_images: + print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo) + else: + loaded_images.append(module) + if image.uuid != module.GetUUIDString(): + print "error: couln't find %s", image.uuid + target.SetSectionLoadAddress (module.FindSection ("__TEXT"), image.text_addr_lo) + for line in crash_log.info_lines: + print line + print "fixing up inlined frames" + # Reconstruct inlined frames for all threads for anything that has debug info + for thread in crash_log.threads: + if options.crashed_only and thread.did_crash() == False: + continue + # start a new frame list that we will fixup for each thread + new_thread_frames = list() + # Iterate through all concrete frames for a thread and resolve + # any parent frames of inlined functions + for frame_idx, frame in enumerate(thread.frames): + # Resolve the frame's pc into a section + offset address 'pc_addr' + pc_addr = target.ResolveLoadAddress (frame.pc) + # Check to see if we were able to resolve the address + if pc_addr: + # We were able to resolve the frame's PC into a section offset + # address. + + # Resolve the frame's PC value into a symbol context. A symbol + # context can resolve a module, compile unit, function, block, + # line table entry and/or symbol. If the frame has a block, then + # we can look for inlined frames, which are represented by blocks + # that have inlined information in them + frame.sym_ctx = target.ResolveSymbolContextForAddress (pc_addr, lldb.eSymbolContextEverything); + + # dump if the verbose option was specified + if options.verbose: + print "frame.pc = %#16.16x (file_addr = %#16.16x)" % (frame.pc, pc_addr.GetFileAddress()) + print "frame.pc_addr = ", pc_addr + print "frame.sym_ctx = " + print frame.sym_ctx + print + + # Append the frame we already had from the crash log to the new + # frames list + new_thread_frames.append(frame) + + new_frame = CrashLog.Frame (frame.index, -1, None) + + # Try and use the current frame's symbol context to calculate a + # parent frame for an inlined function. If the curent frame is + # inlined, it will return a valid symbol context for the parent + # frame of the current inlined function + parent_pc_addr = lldb.SBAddress() + new_frame.sym_ctx = frame.sym_ctx.GetParentInlinedFrameInfo (pc_addr, True, parent_pc_addr) + + # See if we were able to reconstruct anything? + while new_frame.sym_ctx: + # We have a parent frame of an inlined frame, create a new frame + # Convert the section + offset 'parent_pc_addr' to a load address + new_frame.pc = parent_pc_addr.GetLoadAddress(target) + # push the new frame onto the new frame stack + new_thread_frames.append (new_frame) + # dump if the verbose option was specified + if options.verbose: + print "new_frame.pc = %#16.16x (%s)" % (new_frame.pc, parent_pc_addr) + print "new_frame.sym_ctx = " + print new_frame.sym_ctx + print + # Create another new frame in case we have multiple inlined frames + prev_new_frame = new_frame + new_frame = CrashLog.Frame (frame.index, -1, None) + # Swap the addresses so we can try another inlined lookup + pc_addr = parent_pc_addr; + new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentInlinedFrameInfo (pc_addr, False, parent_pc_addr) + # Replace our thread frames with our new list that includes parent + # frames for inlined functions + thread.frames = new_thread_frames + # Now iterate through all threads and display our richer stack backtraces + for thread in crash_log.threads: + this_thread_crashed = thread.did_crash() + if options.crashed_only and this_thread_crashed == False: + continue + print "%s" % thread + prev_frame_index = -1 + for frame_idx, frame in enumerate(thread.frames): + details = "[%u] %s (carp)" % (frame_idx, frame) + module = frame.sym_ctx.GetModule() + instructions = None + if module: + module_basename = module.GetFileSpec().GetFilename(); + function_start_load_addr = -1 + function_name = None + function = frame.sym_ctx.GetFunction() + block = frame.sym_ctx.GetBlock() + line_entry = frame.sym_ctx.GetLineEntry() + symbol = frame.sym_ctx.GetSymbol() + inlined_block = block.GetContainingInlinedBlock(); + if inlined_block: + function_name = inlined_block.GetInlinedName(); + block_range_idx = inlined_block.GetRangeIndexForBlockAddress (target.ResolveLoadAddress (frame.pc)) + if block_range_idx < lldb.UINT32_MAX: + block_range_start_addr = inlined_block.GetRangeStartAddress (block_range_idx) + function_start_load_addr = block_range_start_addr.GetLoadAddress (target) + else: + function_start_load_addr = frame.pc + if this_thread_crashed and frame_idx == 0: + instructions = function.GetInstructions(target) + elif function: + function_name = function.GetName() + function_start_load_addr = function.GetStartAddress().GetLoadAddress (target) + if this_thread_crashed and frame_idx == 0: + instructions = function.GetInstructions(target) + elif symbol: + function_name = symbol.GetName() + function_start_load_addr = symbol.GetStartAddress().GetLoadAddress (target) + if this_thread_crashed and frame_idx == 0: + instructions = symbol.GetInstructions(target) + + if function_name: + # Print the function or symbol name and annotate if it was inlined + inline_suffix = '' + if inlined_block: + inline_suffix = '[inlined] ' + else: + inline_suffix = ' ' + if options.show_images: + details = "%s%s`%s" % (inline_suffix, module_basename, function_name) + else: + details = "%s" % (function_name) + # Dump the offset from the current function or symbol if it is non zero + function_offset = frame.pc - function_start_load_addr + if function_offset > 0: + details += " + %u" % (function_offset) + elif function_offset < 0: + defaults += " %i (invalid negative offset, file a bug) " % function_offset + # Print out any line information if any is available + if line_entry.GetFileSpec(): + details += ' at %s' % line_entry.GetFileSpec().GetFilename() + details += ':%u' % line_entry.GetLine () + column = line_entry.GetColumn() + if column > 0: + details += ':%u' % column + else: + print "error: no function name!" + + + # Only print out the concrete frame index if it changes. + # if prev_frame_index != frame.index: + # print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details) + # else: + # print " %#16.16x %s" % (frame.pc, details) + print "[%2u] %#16.16x %s" % (frame.index, frame.pc, details) + prev_frame_index = frame.index + if instructions: + print + disassemble_instructions (target, instructions, frame.pc, 4, 4) + print + + print + + if options.dump_image_list: + print "Binary Images:" + for image in crash_log.images: + print image + else: + for exe_file in args: + + # Create a target from a file and arch + print "Creating a target for '%s'" % exe_file + + target = debugger.CreateTarget (exe_file, options.triple, options.platform, options.dependents, error); + + if target: + exe_module = None; + module_count = target.GetNumModules(); + for module_idx in range(module_count): + module = target.GetModuleAtIndex (module_idx) + if module_idx == 0: + exe_module = module + print "module[%u] = %s" % (module_idx, module) + + if options.dump_symbols: + print_module_symbols (module) + if options.dump_sections: + print_module_sections (module, options.section_depth) + if options.sect_data_names: + for sect_name in options.sect_data_names: + section = module.FindSection (sect_name) + if section: + print_module_section_data (section) + else: + print "No section was found in '%s' named '%s'" % (module, sect_name) + if options.addresses: + for address in options.addresses: + if loaded_addresses: + so_address = target.ResolveLoadAddress (address) + if so_address: + print so_address + so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything); + print so_address_sc + else: + print "error: 0x%8.8x failed to resolve as a load address" % (address) + else: + so_address = exe_module.ResolveFileAddress (address) + + if so_address: + print so_address + so_address_sc = exe_module.ResolveSymbolContextForAddress (so_address, lldb.eSymbolContextEverything); + print so_address_sc + else: + print "error: 0x%8.8x failed to resolve as a file address in %s" % (address, exe_module) + + # text_base_addr = 0x10000 + # load_addr = 0x10bb0 + # text_segment = exe_module.FindSection ("__TEXT") + # if text_segment: + # target.SetSectionLoadAddress (text_segment, text_base_addr) + # + # load_so_addr = target.ResolveLoadAddress (load_addr) + # + # if load_so_addr: + # sc = target.ResolveSymbolContextForAddress (so_addr, lldb.eSymbolContextEverything); + # print sc + # else: + # print "error: 0x%8.8x failed to resolve as a load address" % (load_addr) + else: + print "error: ", error + + + lldb.SBDebugger.Terminate() + Propchange: lldb/trunk/examples/python/symbolicate-crash.py ------------------------------------------------------------------------------ svn:executable = * From scallanan at apple.com Mon Sep 26 13:45:31 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 26 Sep 2011 18:45:31 -0000 Subject: [Lldb-commits] [lldb] r140545 - in /lldb/trunk: include/lldb/Expression/ExpressionSourceCode.h lldb.xcodeproj/project.pbxproj source/Expression/ClangUserExpression.cpp source/Expression/ExpressionSourceCode.cpp Message-ID: <20110926184531.443E62A6C12C@llvm.org> Author: spyffe Date: Mon Sep 26 13:45:31 2011 New Revision: 140545 URL: http://llvm.org/viewvc/llvm-project?rev=140545&view=rev Log: Factored out handling of the source code for an expression into a separate class. This class encapsulates wrapping the function as needed. I am also moving from using booleans to indicate what the expression's language should be to using lldb::LanguageType instead. Added: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h lldb/trunk/source/Expression/ExpressionSourceCode.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Expression/ClangUserExpression.cpp Added: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h?rev=140545&view=auto ============================================================================== --- lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h (added) +++ lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Mon Sep 26 13:45:31 2011 @@ -0,0 +1,75 @@ +//===-- ExpressionSourceCode.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_ExpressionSourceCode_h +#define liblldb_ExpressionSourceCode_h + +#include "lldb-enumerations.h" + +#include + +namespace lldb_private +{ + +class ExpressionSourceCode +{ +public: + static ExpressionSourceCode *CreateWrapped (const char *prefix, + const char *body) + { + return new ExpressionSourceCode ("$__lldb_expr", + prefix, + body, + true); + } + + static ExpressionSourceCode *CreateUnwrapped (const char *name, + const char *body) + { + return new ExpressionSourceCode (name, + "", + body, + false); + } + + bool NeedsWrapping () const + { + return m_wrap; + } + + const char *GetName () const + { + return m_name.c_str(); + } + + bool GetText (std::string &text, + lldb::LanguageType wrapping_language, + bool const_object) const; + +private: + ExpressionSourceCode (const char *name, + const char *prefix, + const char *body, + bool wrap) : + m_name(name), + m_prefix(prefix), + m_body(body), + m_wrap(wrap) + { + } + + std::string m_name; + std::string m_prefix; + std::string m_body; + bool m_wrap; +}; + +} // namespace lldb_private + +#endif Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140545&r1=140544&r2=140545&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 26 13:45:31 2011 @@ -397,6 +397,7 @@ 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; }; 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 496B015A1406DEB100F830D5 /* IRInterpreter.h */; }; + 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; }; 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; }; 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268ED0A4140FF54200DE830F /* DataEncoder.cpp */; }; 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; @@ -1159,6 +1160,8 @@ 497E7B9D1188F6690065CCA1 /* ABI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ABI.cpp; path = source/Target/ABI.cpp; sourceTree = ""; }; 499F381E11A5B3F300F5CE02 /* CommandObjectArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectArgs.h; path = source/Commands/CommandObjectArgs.h; sourceTree = ""; }; 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectArgs.cpp; path = source/Commands/CommandObjectArgs.cpp; sourceTree = ""; }; + 49A1CAC11430E21D00306AC9 /* ExpressionSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExpressionSourceCode.h; path = include/lldb/Expression/ExpressionSourceCode.h; sourceTree = ""; }; + 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExpressionSourceCode.cpp; path = source/Expression/ExpressionSourceCode.cpp; sourceTree = ""; }; 49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = source/Expression/ASTResultSynthesizer.cpp; sourceTree = ""; }; 49A8A3A311D568BF00AD3B68 /* ASTResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTResultSynthesizer.h; path = include/lldb/Expression/ASTResultSynthesizer.h; sourceTree = ""; }; 49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = ""; }; @@ -2358,6 +2361,8 @@ 26BC7DBE10F1B78200F91463 /* Expression */ = { isa = PBXGroup; children = ( + 49A1CAC11430E21D00306AC9 /* ExpressionSourceCode.h */, + 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */, 49D7072611B5AD03001AD875 /* ClangASTSource.h */, 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */, 26BC7DC010F1B79500F91463 /* ClangExpression.h */, @@ -3481,6 +3486,7 @@ 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */, 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */, B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */, + 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=140545&r1=140544&r2=140545&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Sep 26 13:45:31 2011 @@ -28,6 +28,7 @@ #include "lldb/Expression/ClangExpressionParser.h" #include "lldb/Expression/ClangFunction.h" #include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Expression/ExpressionSourceCode.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" @@ -106,6 +107,7 @@ if (method_decl->isInstance()) { m_cplusplus = true; + m_needs_object_ptr = true; do { clang::QualType this_type = method_decl->getThisType(decl_context->getParentASTContext()); @@ -122,7 +124,10 @@ else if (clang::ObjCMethodDecl *method_decl = llvm::dyn_cast(decl_context)) { if (method_decl->isInstanceMethod()) + { m_objectivec = true; + m_needs_object_ptr = true; + } } } @@ -185,61 +190,23 @@ ApplyObjcCastHack(m_expr_text); //ApplyUnicharHack(m_expr_text); + std::auto_ptr source_code (ExpressionSourceCode::CreateWrapped(m_expr_prefix.c_str(), m_expr_text.c_str())); + + lldb::LanguageType lang_type; + if (m_cplusplus) - { - m_transformed_stream.Printf("%s \n" - "typedef unsigned short unichar; \n" - "void \n" - "$__lldb_class::%s(void *$__lldb_arg) %s\n" - "{ \n" - " %s; \n" - "} \n", - m_expr_prefix.c_str(), - FunctionName(), - (m_const_object ? "const" : ""), - m_expr_text.c_str()); - - m_needs_object_ptr = true; - } - else if (m_objectivec) - { - const char *function_name = FunctionName(); - - m_transformed_stream.Printf("%s \n" - "typedef unsigned short unichar; \n" - "@interface $__lldb_objc_class ($__lldb_category) \n" - "-(void)%s:(void *)$__lldb_arg; \n" - "@end \n" - "@implementation $__lldb_objc_class ($__lldb_category) \n" - "-(void)%s:(void *)$__lldb_arg \n" - "{ \n" - " %s; \n" - "} \n" - "@end \n", - m_expr_prefix.c_str(), - function_name, - function_name, - m_expr_text.c_str()); - - m_needs_object_ptr = true; - } + lang_type = lldb::eLanguageTypeC_plus_plus; + else if(m_objectivec) + lang_type = lldb::eLanguageTypeObjC; else + lang_type = lldb::eLanguageTypeC; + + if (!source_code->GetText(m_transformed_text, lang_type, m_const_object)) { - m_transformed_stream.Printf("%s \n" - "typedef unsigned short unichar;\n" - "void \n" - "%s(void *$__lldb_arg) \n" - "{ \n" - " %s; \n" - "} \n", - m_expr_prefix.c_str(), - FunctionName(), - m_expr_text.c_str()); + error_stream.PutCString ("error: couldn't construct expression body"); + return false; } - m_transformed_text = m_transformed_stream.GetData(); - - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); Added: lldb/trunk/source/Expression/ExpressionSourceCode.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=140545&view=auto ============================================================================== --- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (added) +++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Mon Sep 26 13:45:31 2011 @@ -0,0 +1,88 @@ +//===-- ExpressionSourceCode.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/Expression/ExpressionSourceCode.h" + +#include "lldb/Core/StreamString.h" + +using namespace lldb_private; + +bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrapping_language, bool const_object) const +{ + if (m_wrap) + { + switch (wrapping_language) + { + default: + return false; + case lldb::eLanguageTypeC: + case lldb::eLanguageTypeC_plus_plus: + case lldb::eLanguageTypeObjC: + break; + } + + StreamString wrap_stream; + + switch (wrapping_language) + { + default: + break; + case lldb::eLanguageTypeC: + wrap_stream.Printf("%s \n" + "typedef unsigned short unichar;\n" + "void \n" + "%s(void *$__lldb_arg) \n" + "{ \n" + " %s; \n" + "} \n", + m_prefix.c_str(), + m_name.c_str(), + m_body.c_str()); + break; + case lldb::eLanguageTypeC_plus_plus: + wrap_stream.Printf("%s \n" + "typedef unsigned short unichar; \n" + "void \n" + "$__lldb_class::%s(void *$__lldb_arg) %s\n" + "{ \n" + " %s; \n" + "} \n", + m_prefix.c_str(), + m_name.c_str(), + (const_object ? "const" : ""), + m_body.c_str()); + break; + case lldb::eLanguageTypeObjC: + wrap_stream.Printf("%s \n" + "typedef unsigned short unichar; \n" + "@interface $__lldb_objc_class ($__lldb_category) \n" + "-(void)%s:(void *)$__lldb_arg; \n" + "@end \n" + "@implementation $__lldb_objc_class ($__lldb_category) \n" + "-(void)%s:(void *)$__lldb_arg \n" + "{ \n" + " %s; \n" + "} \n" + "@end \n", + m_prefix.c_str(), + m_name.c_str(), + m_name.c_str(), + m_body.c_str()); + break; + } + + text = wrap_stream.GetString(); + } + else + { + text.append(m_body); + } + + return true; +} From johnny.chen at apple.com Mon Sep 26 14:05:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 26 Sep 2011 19:05:08 -0000 Subject: [Lldb-commits] [lldb] r140550 - /lldb/trunk/test/python_api/thread/TestThreadAPI.py Message-ID: <20110926190508.7704F2A6C12C@llvm.org> Author: johnny Date: Mon Sep 26 14:05:08 2011 New Revision: 140550 URL: http://llvm.org/viewvc/llvm-project?rev=140550&view=rev Log: Remove the @expectedFailureClang custom decorator for indicating clang-specific test failures. It has been fixed on the lldb side to compensate for bad debug info (line table information). Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=140550&r1=140549&r2=140550&view=diff ============================================================================== --- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original) +++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Mon Sep 26 14:05:08 2011 @@ -77,7 +77,6 @@ self.step_out_of_malloc_into_function_b(self.exe_name) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @expectedFailureClang @python_api_test def test_step_over_3_times_with_dsym(self): """Test Python SBThread.StepOver() API.""" @@ -87,7 +86,6 @@ self.setTearDownCleanup(dictionary=d) self.step_over_3_times(self.exe_name) - @expectedFailureClang @python_api_test def test_step_over_3_times_with_dwarf(self): """Test Python SBThread.StepOver() API.""" @@ -225,6 +223,9 @@ self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) # Expected failure with clang as the compiler. # rdar://problem/9223880 + # + # Which has been fixed on the lldb by compensating for inaccurate line + # table information with r140416. self.assertTrue(lineEntry.GetLine() == self.after_3_step_overs) def run_to_address(self, exe_name): From gclayton at apple.com Mon Sep 26 14:17:49 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 26 Sep 2011 19:17:49 -0000 Subject: [Lldb-commits] [lldb] r140554 - /lldb/trunk/examples/python/symbolicate-crash.py Message-ID: <20110926191749.E30CF2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 26 14:17:49 2011 New Revision: 140554 URL: http://llvm.org/viewvc/llvm-project?rev=140554&view=rev Log: Fixes for a few different versions of the darwin crash log. Modified: lldb/trunk/examples/python/symbolicate-crash.py Modified: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=140554&r1=140553&r2=140554&view=diff ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (original) +++ lldb/trunk/examples/python/symbolicate-crash.py Mon Sep 26 14:17:49 2011 @@ -25,8 +25,9 @@ """Class that does parses darwin crash logs""" thread_state_regex = re.compile('^Thread ([0-9]+) crashed with') thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)') - frame_regex = re.compile('^([0-9]+).*(0x[0-9a-fA-F]+) +(.*)') - image_regex = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([\.0-9\?]+) \(([^)]+)\) <([-0-9a-fA-F]+)> (.*)'); + frame_regex = re.compile('^([0-9]+).*\t(0x[0-9a-fA-F]+) +(.*)') + image_regex_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)'); + image_regex_no_uuid = re.compile('(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +([^ ]+) +([^/]+)/(.*)'); empty_line_regex = re.compile('^$') class Thread: @@ -74,12 +75,11 @@ class Image: """Class that represents a binary images in a darwin crash log""" - def __init__(self, text_addr_lo, text_addr_hi, ident, version, compatability_version, uuid, path): + def __init__(self, text_addr_lo, text_addr_hi, ident, version, uuid, path): self.text_addr_lo = text_addr_lo self.text_addr_hi = text_addr_hi self.ident = ident self.version = version - self.compatability_version = compatability_version self.uuid = uuid self.path = path @@ -187,18 +187,28 @@ else: print "error: frame regex failed" elif parse_mode == PARSE_MODE_IMAGES: - image_match = self.image_regex.search (line) + image_match = self.image_regex_uuid.search (line) if image_match: image = CrashLog.Image (int(image_match.group(1),0), int(image_match.group(2),0), - image_match.group(3), - image_match.group(4), + image_match.group(3).strip(), + image_match.group(4).strip(), image_match.group(5), - image_match.group(6), - image_match.group(7)) + image_match.group(6)) self.images.append (image) else: - print "error: image regex failed" + image_match = self.image_regex_no_uuid.search (line) + if image_match: + image = CrashLog.Image (int(image_match.group(1),0), + int(image_match.group(2),0), + image_match.group(3).strip(), + image_match.group(4).strip(), + None, + image_match.group(5)) + self.images.append (image) + else: + print "error: image regex failed for: %s" % line + elif parse_mode == PARSE_MODE_THREGS: stripped_line = line.strip() reg_values = stripped_line.split(' ') @@ -327,22 +337,26 @@ #crash_log.dump() target = debugger.CreateTarget (crash_log.process_path, options.triple, options.platform, options.dependents, error); exe_module = target.GetModuleAtIndex(0) - loaded_images = list() + image_paths = list() for image in crash_log.images: if image.path == crash_log.process_path: module = exe_module else: module = target.AddModule (image.path, options.triple, image.uuid) - if module in loaded_images: + if image.path in image_paths: print "warning: skipping %s loaded at %#16.16x duplicate entry (probably commpage)" % (image.path, image.text_addr_lo) else: - loaded_images.append(module) - if image.uuid != module.GetUUIDString(): - print "error: couln't find %s", image.uuid - target.SetSectionLoadAddress (module.FindSection ("__TEXT"), image.text_addr_lo) + image_paths.append(image.path) + + if not module and image.uuid != module.GetUUIDString(): + if image.uuid: + print "warning: couldn't locate %s %s" % (image.uuid, image.path) + else: + print "warning: couldn't locate %s" % (image.path) + else: + target.SetSectionLoadAddress (module.FindSection ("__TEXT"), image.text_addr_lo) for line in crash_log.info_lines: print line - print "fixing up inlined frames" # Reconstruct inlined frames for all threads for anything that has debug info for thread in crash_log.threads: if options.crashed_only and thread.did_crash() == False: @@ -417,7 +431,7 @@ print "%s" % thread prev_frame_index = -1 for frame_idx, frame in enumerate(thread.frames): - details = "[%u] %s (carp)" % (frame_idx, frame) + details = ' %s' % frame.details module = frame.sym_ctx.GetModule() instructions = None if module: @@ -474,8 +488,6 @@ column = line_entry.GetColumn() if column > 0: details += ':%u' % column - else: - print "error: no function name!" # Only print out the concrete frame index if it changes. From johnny.chen at apple.com Mon Sep 26 17:40:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 26 Sep 2011 22:40:50 -0000 Subject: [Lldb-commits] [lldb] r140575 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ lldb.xcodeproj/ source/API/ source/Breakpoint/ source/Commands/ source/Plugins/Process/Utility/ source/Target/ Message-ID: <20110926224050.DB16A2A6C12C@llvm.org> Author: johnny Date: Mon Sep 26 17:40:50 2011 New Revision: 140575 URL: http://llvm.org/viewvc/llvm-project?rev=140575&view=rev Log: Add SB API class SBWatchpointLocation and some extra methods to the SBTarget class to iterate on the available watchpoint locations and to perform watchpoint manipulations. I still need to export the SBWatchpointLocation class as well as the added watchpoint manipulation methods to the Python interface. And write test cases for them. Added: lldb/trunk/include/lldb/API/SBWatchpointLocation.h lldb/trunk/source/API/SBWatchpointLocation.cpp Modified: lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/WatchpointLocation.cpp lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Mon Sep 26 17:40:50 2011 @@ -63,6 +63,7 @@ class SBTypeList; class SBValue; class SBValueList; +class SBWatchpointLocation; } Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Mon Sep 26 17:40:50 2011 @@ -76,6 +76,7 @@ friend class SBTarget; friend class SBThread; friend class SBValue; + friend class SBWatchpointLocation; friend class SBCommandReturnObject; #ifndef SWIG Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Mon Sep 26 17:40:50 2011 @@ -16,6 +16,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBType.h" +#include "lldb/API/SBWatchpointLocation.h" namespace lldb { @@ -443,6 +444,27 @@ bool DeleteAllBreakpoints (); + uint32_t + GetNumWatchpointLocations () const; + + lldb::SBWatchpointLocation + GetWatchpointLocationAtIndex (uint32_t idx) const; + + bool + WatchpointLocationDelete (watch_id_t watch_id); + + lldb::SBWatchpointLocation + FindWatchpointLocationByID (watch_id_t watch_id); + + bool + EnableAllWatchpointLocations (); + + bool + DisableAllWatchpointLocations (); + + bool + DeleteAllWatchpointLocations (); + lldb::SBBroadcaster GetBroadcaster () const; Added: lldb/trunk/include/lldb/API/SBWatchpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBWatchpointLocation.h?rev=140575&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBWatchpointLocation.h (added) +++ lldb/trunk/include/lldb/API/SBWatchpointLocation.h Mon Sep 26 17:40:50 2011 @@ -0,0 +1,85 @@ +//===-- SBWatchpointLocation.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_SBWatchpointLocation_h_ +#define LLDB_SBWatchpointLocation_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBWatchpointLocation +{ +public: + + SBWatchpointLocation (); + + SBWatchpointLocation (const lldb::SBWatchpointLocation &rhs); + + ~SBWatchpointLocation (); + +#ifndef SWIG + const lldb::SBWatchpointLocation & + operator = (const lldb::SBWatchpointLocation &rhs); +#endif + + bool + IsValid() const; + + lldb::addr_t + GetWatchAddress () const; + + size_t + GetWatchSize() const; + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); + +#ifndef SWIG + SBWatchpointLocation (const lldb::WatchpointLocationSP &watch_loc_sp); +#endif + +private: + friend class SBTarget; + +#ifndef SWIG + + lldb_private::WatchpointLocation * + operator->() const; + + lldb_private::WatchpointLocation * + get() const; + + lldb::WatchpointLocationSP & + operator *(); + + const lldb::WatchpointLocationSP & + operator *() const; + +#endif + + lldb::WatchpointLocationSP m_opaque_sp; + +}; + +} // namespace lldb + +#endif // LLDB_SBWatchpointLocation_h_ Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Mon Sep 26 17:40:50 2011 @@ -20,6 +20,7 @@ // Project includes #include "lldb/lldb-private.h" +#include "lldb/Target/Target.h" #include "lldb/Core/UserID.h" #include "lldb/Breakpoint/StoppointLocation.h" @@ -56,8 +57,14 @@ void GetDescription (Stream *s, lldb::DescriptionLevel level); void Dump (Stream *s) const; void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const; + Target &GetTarget() { return *m_target; } private: + friend class Target; + + void SetTarget(Target *target_ptr) { m_target = target_ptr; } + + Target *m_target; bool m_enabled; // Is this watchpoint enabled bool m_is_hardware; // Is this a hardware watchpoint uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Mon Sep 26 17:40:50 2011 @@ -19,7 +19,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Host/Mutex.h" -#include "lldb/Breakpoint/WatchpointLocation.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Sep 26 17:40:50 2011 @@ -196,6 +196,7 @@ class Variable; class VariableList; class WatchpointLocation; +class WatchpointLocationList; struct LineEntry; } // namespace lldb_private Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 26 17:40:50 2011 @@ -450,6 +450,8 @@ B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; }; B27318421416AC12006039C8 /* WatchpointLocationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointLocationList.cpp */; }; B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; }; + B2A58722143119810092BFBA /* SBWatchpointLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = B2A58721143119810092BFBA /* SBWatchpointLocation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B2A58724143119D50092BFBA /* SBWatchpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A58723143119D50092BFBA /* SBWatchpointLocation.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1362,6 +1364,8 @@ B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMDefines.h; path = Utility/ARMDefines.h; sourceTree = ""; }; B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVersion.cpp; path = source/Commands/CommandObjectVersion.cpp; sourceTree = ""; }; B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVersion.h; path = source/Commands/CommandObjectVersion.h; sourceTree = ""; }; + B2A58721143119810092BFBA /* SBWatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBWatchpointLocation.h; path = include/lldb/API/SBWatchpointLocation.h; sourceTree = ""; }; + B2A58723143119D50092BFBA /* SBWatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBWatchpointLocation.cpp; path = source/API/SBWatchpointLocation.cpp; sourceTree = ""; }; B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstructionUtils.h; path = Utility/InstructionUtils.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1832,6 +1836,8 @@ 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */, 9A357582116CFDEE00E8ED2F /* SBValueList.h */, 9A35758D116CFE0F00E8ED2F /* SBValueList.cpp */, + B2A58723143119D50092BFBA /* SBWatchpointLocation.cpp */, + B2A58721143119810092BFBA /* SBWatchpointLocation.h */, ); name = API; sourceTree = ""; @@ -2865,9 +2871,10 @@ 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, - 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */, 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */, + 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */, 26B8283D142D01E9002DBC64 /* SBSection.h in Headers */, + B2A58722143119810092BFBA /* SBWatchpointLocation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3154,6 +3161,7 @@ 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */, 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */, 26B82840142D020F002DBC64 /* SBSection.cpp in Sources */, + B2A58724143119D50092BFBA /* SBWatchpointLocation.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Sep 26 17:40:50 2011 @@ -766,6 +766,49 @@ return sb_bp; } +uint32_t +SBTarget::GetNumBreakpoints () const +{ + if (m_opaque_sp) + { + // The breakpoint list is thread safe, no need to lock + return m_opaque_sp->GetBreakpointList().GetSize(); + } + return 0; +} + +SBBreakpoint +SBTarget::GetBreakpointAtIndex (uint32_t idx) const +{ + SBBreakpoint sb_breakpoint; + if (m_opaque_sp) + { + // The breakpoint list is thread safe, no need to lock + *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx); + } + return sb_breakpoint; +} + +bool +SBTarget::BreakpointDelete (break_id_t bp_id) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + bool result = false; + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + result = m_opaque_sp->RemoveBreakpointByID (bp_id); + } + + if (log) + { + log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) bp_id, result); + } + + return result; +} + SBBreakpoint SBTarget::FindBreakpointByID (break_id_t bp_id) { @@ -787,31 +830,67 @@ return sb_breakpoint; } +bool +SBTarget::EnableAllBreakpoints () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + m_opaque_sp->EnableAllBreakpoints (); + return true; + } + return false; +} + +bool +SBTarget::DisableAllBreakpoints () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + m_opaque_sp->DisableAllBreakpoints (); + return true; + } + return false; +} + +bool +SBTarget::DeleteAllBreakpoints () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + m_opaque_sp->RemoveAllBreakpoints (); + return true; + } + return false; +} + uint32_t -SBTarget::GetNumBreakpoints () const +SBTarget::GetNumWatchpointLocations () const { if (m_opaque_sp) { // The breakpoint list is thread safe, no need to lock - return m_opaque_sp->GetBreakpointList().GetSize(); + return m_opaque_sp->GetWatchpointLocationList().GetSize(); } return 0; } -SBBreakpoint -SBTarget::GetBreakpointAtIndex (uint32_t idx) const +SBWatchpointLocation +SBTarget::GetWatchpointLocationAtIndex (uint32_t idx) const { - SBBreakpoint sb_breakpoint; + SBWatchpointLocation sb_watchpoint_location; if (m_opaque_sp) { // The breakpoint list is thread safe, no need to lock - *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx); + *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().GetByIndex(idx); } - return sb_breakpoint; + return sb_watchpoint_location; } bool -SBTarget::BreakpointDelete (break_id_t bp_id) +SBTarget::WatchpointLocationDelete (watch_id_t wp_id) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -819,48 +898,69 @@ if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - result = m_opaque_sp->RemoveBreakpointByID (bp_id); + result = m_opaque_sp->RemoveWatchpointLocationByID (wp_id); } if (log) { - log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) bp_id, result); + log->Printf ("SBTarget(%p)::WatchpointLocationDelete (wp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) wp_id, result); } return result; } +SBWatchpointLocation +SBTarget::FindWatchpointLocationByID (watch_id_t wp_id) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBWatchpointLocation sb_watchpoint_location; + if (m_opaque_sp && wp_id != LLDB_INVALID_WATCH_ID) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id); + } + + if (log) + { + log->Printf ("SBTarget(%p)::FindWatchpointLocationByID (bp_id=%d) => SBWatchpointLocation(%p)", + m_opaque_sp.get(), (uint32_t) wp_id, sb_watchpoint_location.get()); + } + + return sb_watchpoint_location; +} + bool -SBTarget::EnableAllBreakpoints () +SBTarget::EnableAllWatchpointLocations () { if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->EnableAllBreakpoints (); + m_opaque_sp->EnableAllWatchpointLocations (); return true; } return false; } bool -SBTarget::DisableAllBreakpoints () +SBTarget::DisableAllWatchpointLocations () { if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->DisableAllBreakpoints (); + m_opaque_sp->DisableAllWatchpointLocations (); return true; } return false; } bool -SBTarget::DeleteAllBreakpoints () +SBTarget::DeleteAllWatchpointLocations () { if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - m_opaque_sp->RemoveAllBreakpoints (); + m_opaque_sp->RemoveAllWatchpointLocations (); return true; } return false; Added: lldb/trunk/source/API/SBWatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBWatchpointLocation.cpp?rev=140575&view=auto ============================================================================== --- lldb/trunk/source/API/SBWatchpointLocation.cpp (added) +++ lldb/trunk/source/API/SBWatchpointLocation.cpp Mon Sep 26 17:40:50 2011 @@ -0,0 +1,183 @@ +//===-- SBWatchpointLocation.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/API/SBWatchpointLocation.h" +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBStream.h" + +#include "lldb/lldb-types.h" +#include "lldb/lldb-defines.h" +#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/WatchpointLocationList.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Stream.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + + +SBWatchpointLocation::SBWatchpointLocation () : + m_opaque_sp () +{ +} + +SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationSP &watch_loc_sp) : + m_opaque_sp (watch_loc_sp) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + if (log) + { + SBStream sstr; + GetDescription (sstr, lldb::eDescriptionLevelBrief); + log->Printf ("SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationsSP &watch_loc_sp" + "=%p) => this.sp = %p (%s)", watch_loc_sp.get(), m_opaque_sp.get(), sstr.GetData()); + } +} + +SBWatchpointLocation::SBWatchpointLocation(const SBWatchpointLocation &rhs) : + m_opaque_sp (rhs.m_opaque_sp) +{ +} + +const SBWatchpointLocation & +SBWatchpointLocation::operator = (const SBWatchpointLocation &rhs) +{ + if (this != &rhs) + m_opaque_sp = rhs.m_opaque_sp; + return *this; +} + + +SBWatchpointLocation::~SBWatchpointLocation () +{ +} + +bool +SBWatchpointLocation::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +addr_t +SBWatchpointLocation::GetWatchAddress () const +{ + addr_t ret_addr = LLDB_INVALID_ADDRESS; + + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + ret_addr = m_opaque_sp->GetLoadAddress(); + } + + return ret_addr; +} + +size_t +SBWatchpointLocation::GetWatchSize () const +{ + size_t watch_size = 0; + + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + watch_size = m_opaque_sp->GetByteSize(); + } + + return watch_size; +} + +void +SBWatchpointLocation::SetEnabled (bool enabled) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + m_opaque_sp->SetEnabled (enabled); + } +} + +bool +SBWatchpointLocation::IsEnabled () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + return m_opaque_sp->IsEnabled(); + } + else + return false; +} + +uint32_t +SBWatchpointLocation::GetIgnoreCount () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + return m_opaque_sp->GetIgnoreCount(); + } + else + return 0; +} + +void +SBWatchpointLocation::SetIgnoreCount (uint32_t n) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + m_opaque_sp->SetIgnoreCount (n); + } +} + +bool +SBWatchpointLocation::GetDescription (SBStream &description, DescriptionLevel level) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + description.ref(); + m_opaque_sp->GetDescription (description.get(), level); + description.get()->EOL(); + } + else + description.Printf ("No value"); + + return true; +} + +lldb_private::WatchpointLocation * +SBWatchpointLocation::operator->() const +{ + return m_opaque_sp.get(); +} + +lldb_private::WatchpointLocation * +SBWatchpointLocation::get() const +{ + return m_opaque_sp.get(); +} + +lldb::WatchpointLocationSP & +SBWatchpointLocation::operator *() +{ + return m_opaque_sp; +} + +const lldb::WatchpointLocationSP & +SBWatchpointLocation::operator *() const +{ + return m_opaque_sp; +} + Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Mon Sep 26 17:40:50 2011 @@ -20,6 +20,7 @@ WatchpointLocation::WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware) : StoppointLocation (GetNextID(), addr, size, hardware), + m_target(NULL), m_enabled(0), m_is_hardware(hardware), m_watch_read(0), Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Mon Sep 26 17:40:50 2011 @@ -14,7 +14,6 @@ // Project includes #include "lldb/Breakpoint/WatchpointLocationList.h" #include "lldb/Breakpoint/WatchpointLocation.h" -#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 26 17:40:50 2011 @@ -14,6 +14,7 @@ #include // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Mon Sep 26 17:40:50 2011 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/StreamString.h" #include "lldb/Target/Process.h" Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Mon Sep 26 17:40:50 2011 @@ -19,6 +19,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" #include "lldb/Expression/ClangUserExpression.h" Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140575&r1=140574&r2=140575&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Sep 26 17:40:50 2011 @@ -18,6 +18,7 @@ #include "lldb/Breakpoint/BreakpointResolverFileLine.h" #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" #include "lldb/Breakpoint/BreakpointResolverName.h" +#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" #include "lldb/Core/Log.h" @@ -439,6 +440,7 @@ return wp_loc_sp; } new_loc->SetWatchpointType(type); + new_loc->SetTarget(this); wp_loc_sp.reset(new_loc); m_watchpoint_location_list.Add(wp_loc_sp); } From scallanan at apple.com Mon Sep 26 18:01:39 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 26 Sep 2011 23:01:39 -0000 Subject: [Lldb-commits] [lldb] r140577 - /lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Message-ID: <20110926230139.6A32B2A6C12C@llvm.org> Author: spyffe Date: Mon Sep 26 18:01:39 2011 New Revision: 140577 URL: http://llvm.org/viewvc/llvm-project?rev=140577&view=rev Log: Fixed an include path that was breaking Linux builds. Modified: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Modified: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h?rev=140577&r1=140576&r2=140577&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h (original) +++ lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Mon Sep 26 18:01:39 2011 @@ -10,7 +10,7 @@ #ifndef liblldb_ExpressionSourceCode_h #define liblldb_ExpressionSourceCode_h -#include "lldb-enumerations.h" +#include "lldb/lldb-enumerations.h" #include From gclayton at apple.com Mon Sep 26 19:58:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 27 Sep 2011 00:58:45 -0000 Subject: [Lldb-commits] [lldb] r140591 - in /lldb/trunk: examples/python/symbolicate-crash.py include/lldb/API/SBInstruction.h include/lldb/Core/Disassembler.h scripts/Python/interface/SBInstruction.i source/API/SBInstruction.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Message-ID: <20110927005845.59E142A6C12C@llvm.org> Author: gclayton Date: Mon Sep 26 19:58:45 2011 New Revision: 140591 URL: http://llvm.org/viewvc/llvm-project?rev=140591&view=rev Log: Fixed the public and internal disassembler API to be named correctly: const char * SBInstruction::GetMnemonic() const char * SBInstruction::GetOperands() const char * SBInstruction::GetComment() Fixed the symbolicate example script and the internals. Modified: lldb/trunk/examples/python/symbolicate-crash.py lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/scripts/Python/interface/SBInstruction.i lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Modified: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (original) +++ lldb/trunk/examples/python/symbolicate-crash.py Mon Sep 26 19:58:45 2011 @@ -236,11 +236,11 @@ inst_pc = inst.GetAddress().GetLoadAddress(target); if pc == inst_pc: pc_index = inst_idx - opcode_name = inst.GetOpcodeName(target) - mnemonics = inst.GetMnemonics(target) - comment = inst.GetComment(target) - #data = inst.GetData(target) - lines.append ("%#16.16x: %8s %s" % (inst_pc, opcode_name, mnemonics)) + mnemonic = inst.GetMnemonic (target) + operands = inst.GetOperands (target) + comment = inst.GetComment (target) + #data = inst.GetData (target) + lines.append ("%#16.16x: %8s %s" % (inst_pc, mnemonic, operands)) if comment: line_len = len(lines[-1]) if line_len < comment_column: Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Mon Sep 26 19:58:45 2011 @@ -42,10 +42,10 @@ GetAddress(); const char * - GetOpcodeName (lldb::SBTarget target); + GetMnemonic (lldb::SBTarget target); const char * - GetMnemonics (lldb::SBTarget target); + GetOperands (lldb::SBTarget target); const char * GetComment (lldb::SBTarget target); Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Mon Sep 26 19:58:45 2011 @@ -42,17 +42,17 @@ } const char * - GetOpcodeName (ExecutionContextScope *exe_scope) + GetMnemonic (ExecutionContextScope *exe_scope) { if (m_opcode_name.empty()) - CalculateOpcodeName(exe_scope); + CalculateMnemonic(exe_scope); return m_opcode_name.c_str(); } const char * - GetMnemonics (ExecutionContextScope *exe_scope) + GetOperands (ExecutionContextScope *exe_scope) { if (m_mnemocics.empty()) - CalculateMnemonics(exe_scope); + CalculateOperands(exe_scope); return m_mnemocics.c_str(); } @@ -65,10 +65,10 @@ } virtual void - CalculateOpcodeName (ExecutionContextScope *exe_scope) = 0; + CalculateMnemonic (ExecutionContextScope *exe_scope) = 0; virtual void - CalculateMnemonics (ExecutionContextScope *exe_scope) = 0; + CalculateOperands (ExecutionContextScope *exe_scope) = 0; virtual void CalculateComment (ExecutionContextScope *exe_scope) = 0; @@ -199,13 +199,13 @@ DoesBranch () const; virtual void - CalculateOpcodeName(ExecutionContextScope *exe_scope) + CalculateMnemonic(ExecutionContextScope *exe_scope) { // TODO: fill this in and put opcode name into Instruction::m_opcode_name } virtual void - CalculateMnemonics(ExecutionContextScope *exe_scope) + CalculateOperands(ExecutionContextScope *exe_scope) { // TODO: fill this in and put opcode name into Instruction::m_mnemonics } Modified: lldb/trunk/scripts/Python/interface/SBInstruction.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstruction.i?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBInstruction.i (original) +++ lldb/trunk/scripts/Python/interface/SBInstruction.i Mon Sep 26 19:58:45 2011 @@ -31,10 +31,10 @@ GetAddress(); const char * - GetOpcodeName (lldb::SBTarget target); + GetMnemonic (lldb::SBTarget target); const char * - GetMnemonics (lldb::SBTarget target); + GetOperands (lldb::SBTarget target); const char * GetComment (lldb::SBTarget target); Modified: lldb/trunk/source/API/SBInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstruction.cpp (original) +++ lldb/trunk/source/API/SBInstruction.cpp Mon Sep 26 19:58:45 2011 @@ -69,7 +69,7 @@ } const char * -SBInstruction::GetOpcodeName(SBTarget target) +SBInstruction::GetMnemonic(SBTarget target) { if (m_opaque_sp) { @@ -81,13 +81,13 @@ target->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target->GetProcessSP()); } - return m_opaque_sp->GetOpcodeName(exe_ctx.GetBestExecutionContextScope()); + return m_opaque_sp->GetMnemonic(exe_ctx.GetBestExecutionContextScope()); } return NULL; } const char * -SBInstruction::GetMnemonics(SBTarget target) +SBInstruction::GetOperands(SBTarget target) { if (m_opaque_sp) { @@ -99,7 +99,7 @@ target->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target->GetProcessSP()); } - return m_opaque_sp->GetMnemonics(exe_ctx.GetBestExecutionContextScope()); + return m_opaque_sp->GetOperands(exe_ctx.GetBestExecutionContextScope()); } return NULL; } Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon Sep 26 19:58:45 2011 @@ -430,7 +430,7 @@ } void -InstructionLLVM::CalculateOpcodeName (ExecutionContextScope *exe_scope) +InstructionLLVM::CalculateMnemonic (ExecutionContextScope *exe_scope) { const int num_tokens = EDNumTokens(m_inst); if (num_tokens > 0) @@ -554,17 +554,17 @@ } void -InstructionLLVM::CalculateMnemonics(ExecutionContextScope *exe_scope) +InstructionLLVM::CalculateOperands(ExecutionContextScope *exe_scope) { - // Do all of the work in CalculateOpcodeName() - CalculateOpcodeName (exe_scope); + // Do all of the work in CalculateMnemonic() + CalculateMnemonic (exe_scope); } void InstructionLLVM::CalculateComment(ExecutionContextScope *exe_scope) { - // Do all of the work in CalculateOpcodeName() - CalculateOpcodeName (exe_scope); + // Do all of the work in CalculateMnemonic() + CalculateMnemonic (exe_scope); } bool Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=140591&r1=140590&r2=140591&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Mon Sep 26 19:58:45 2011 @@ -44,10 +44,10 @@ uint32_t data_offset); virtual void - CalculateOpcodeName (lldb_private::ExecutionContextScope *exe_scope); + CalculateMnemonic (lldb_private::ExecutionContextScope *exe_scope); virtual void - CalculateMnemonics (lldb_private::ExecutionContextScope *exe_scope); + CalculateOperands (lldb_private::ExecutionContextScope *exe_scope); virtual void CalculateComment (lldb_private::ExecutionContextScope *exe_scope); From johnny.chen at apple.com Mon Sep 26 20:19:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 01:19:20 -0000 Subject: [Lldb-commits] [lldb] r140595 - in /lldb/trunk: include/lldb/API/SBWatchpointLocation.h lldb.xcodeproj/project.pbxproj scripts/Python/build-swig-Python.sh scripts/Python/interface/SBTarget.i scripts/Python/interface/SBWatchpointLocation.i scripts/Python/modify-python-lldb.py scripts/Python/python-extensions.swig scripts/lldb.swig source/API/SBWatchpointLocation.cpp source/Breakpoint/WatchpointLocation.cpp test/python_api/watchpoint/TestWatchpointLocationIter.py Message-ID: <20110927011921.0CA0F2A6C12C@llvm.org> Author: johnny Date: Mon Sep 26 20:19:20 2011 New Revision: 140595 URL: http://llvm.org/viewvc/llvm-project?rev=140595&view=rev Log: Export the watchpoint related API (SBWatchpointLocation class and added SBTarget methods) to the Python interface. Implement yet another (threre're 3 now) iterator protocol for SBTarget: watchpoint_location_iter(), to iterate on the available watchpoint locations. And add a print representation for SBWatchpointLocation. Exercise some of these Python API with TestWatchpointLocationIter.py. Added: lldb/trunk/scripts/Python/interface/SBWatchpointLocation.i lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Modified: lldb/trunk/include/lldb/API/SBWatchpointLocation.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/scripts/Python/python-extensions.swig lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBWatchpointLocation.cpp lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Modified: lldb/trunk/include/lldb/API/SBWatchpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBWatchpointLocation.h?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBWatchpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBWatchpointLocation.h Mon Sep 26 20:19:20 2011 @@ -29,9 +29,16 @@ operator = (const lldb::SBWatchpointLocation &rhs); #endif + watch_id_t + GetID () const; + bool IsValid() const; + /// With -1 representing an invalid hardware index. + int32_t + GetHardwareIndex () const; + lldb::addr_t GetWatchAddress () const; @@ -45,6 +52,9 @@ IsEnabled (); uint32_t + GetHitCount () const; + + uint32_t GetIgnoreCount (); void Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 26 20:19:20 2011 @@ -1366,6 +1366,7 @@ B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVersion.h; path = source/Commands/CommandObjectVersion.h; sourceTree = ""; }; B2A58721143119810092BFBA /* SBWatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBWatchpointLocation.h; path = include/lldb/API/SBWatchpointLocation.h; sourceTree = ""; }; B2A58723143119D50092BFBA /* SBWatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBWatchpointLocation.cpp; path = source/API/SBWatchpointLocation.cpp; sourceTree = ""; }; + B2A5872514313B480092BFBA /* SBWatchpointLocation.i */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = SBWatchpointLocation.i; sourceTree = ""; }; B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstructionUtils.h; path = Utility/InstructionUtils.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1727,6 +1728,7 @@ 2611FF11142D83060017FEA3 /* SBType.i */, 2611FF12142D83060017FEA3 /* SBValue.i */, 2611FF13142D83060017FEA3 /* SBValueList.i */, + B2A5872514313B480092BFBA /* SBWatchpointLocation.i */, ); name = interface; path = scripts/Python/interface; 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=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Mon Sep 26 20:19:20 2011 @@ -71,7 +71,8 @@ " ${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/SBValueList.h" +" ${SRC_ROOT}/include/lldb/API/SBValueList.h"\ +" ${SRC_ROOT}/include/lldb/API/SBWatchpointLocation.h"\ INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBBlock.i"\ @@ -106,7 +107,8 @@ " ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBType.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\ -" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i" +" ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBWatchpointLocation.i" if [ $Debug == 1 ] then Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Mon Sep 26 20:19:20 2011 @@ -12,7 +12,8 @@ %feature("docstring", "Represents the target program running under the debugger. -SBTarget supports module and breakpoint iterations. For example, +SBTarget supports module, breakpoint, and watchpoint_location iterations. For +example, for m in target.module_iter(): print m @@ -34,7 +35,18 @@ produces: SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 -SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1" +SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 + +and, + + for wp_loc in target.watchpoint_location_iter(): + print wp_loc + +produces: + +WatchpointLocation 1: addr = 0x1034ca048 size = 4 state = enabled type = rw + declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' + hw_index = 0 hit_count = 2 ignore_count = 0 callback = 0x0 baton = 0x0" ) SBTarget; class SBTarget { @@ -423,6 +435,27 @@ bool DeleteAllBreakpoints (); + uint32_t + GetNumWatchpointLocations () const; + + lldb::SBWatchpointLocation + GetWatchpointLocationAtIndex (uint32_t idx) const; + + bool + WatchpointLocationDelete (watch_id_t watch_id); + + lldb::SBWatchpointLocation + FindWatchpointLocationByID (watch_id_t watch_id); + + bool + EnableAllWatchpointLocations (); + + bool + DisableAllWatchpointLocations (); + + bool + DeleteAllWatchpointLocations (); + lldb::SBBroadcaster GetBroadcaster () const; Added: lldb/trunk/scripts/Python/interface/SBWatchpointLocation.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBWatchpointLocation.i?rev=140595&view=auto ============================================================================== --- lldb/trunk/scripts/Python/interface/SBWatchpointLocation.i (added) +++ lldb/trunk/scripts/Python/interface/SBWatchpointLocation.i Mon Sep 26 20:19:20 2011 @@ -0,0 +1,71 @@ +//===-- SWIG Interface for SBWatchpointLocation -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an instance of watchpoint location for a specific target program. + +A watchpoint location is determined by the address and the byte size that +resulted in this particular instantiation. Each watchpoint location has its +settable options. + +See also SBTarget.watchpoint_location_iter() for for example usage of iterating +through the watchpoint locations of the target." +) SBWatchpointLocation; +class SBWatchpointLocation +{ +public: + + SBWatchpointLocation (); + + SBWatchpointLocation (const lldb::SBWatchpointLocation &rhs); + + ~SBWatchpointLocation (); + + watch_id_t + GetID () const; + + bool + IsValid() const; + + %feature("docstring", " + //------------------------------------------------------------------ + /// With -1 representing an invalid hardware index. + //------------------------------------------------------------------ + ") GetHardwareIndex; + int32_t + GetHardwareIndex () const; + + lldb::addr_t + GetWatchAddress () const; + + size_t + GetWatchSize() const; + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetHitCount () const; + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); +}; + +} // namespace lldb Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Sep 26 20:19:20 2011 @@ -150,6 +150,7 @@ iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" +watchpoint_location_iter = " def watchpoint_location_iter(self): return lldb_iter(self, '%s', '%s')" section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')" # Called to implement the built-in function len(). @@ -187,7 +188,8 @@ # SBTarget needs special processing, see below. 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), - 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex') + 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex'), + 'watchpoint_location': ('GetNumWatchpointLocations', 'GetWatchpointLocationAtIndex') }, # SBModule has an additional section_iter(), see below. @@ -325,10 +327,11 @@ # We found the beginning of the __init__ method definition. # This is a good spot to insert the iter and/or eq-ne support. # - # But note that SBTarget has two types of iterations. + # But note that SBTarget has three types of iterations. if cls == "SBTarget": new_content.add_line(module_iter % (d[cls]['module'])) new_content.add_line(breakpoint_iter % (d[cls]['breakpoint'])) + new_content.add_line(watchpoint_location_iter % (d[cls]['watchpoint_location'])) else: if (state & DEFINING_ITERATOR): new_content.add_line(iter_def % d[cls]) Modified: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (original) +++ lldb/trunk/scripts/Python/python-extensions.swig Mon Sep 26 20:19:20 2011 @@ -160,4 +160,11 @@ return PyString_FromString (description.GetData()); } } +%extend lldb::SBWatchpointLocation { + PyObject *lldb::SBWatchpointLocation::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelVerbose); + return PyString_FromString (description.GetData()); + } +} Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Mon Sep 26 20:19:20 2011 @@ -79,6 +79,7 @@ #include "lldb/API/SBType.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" +#include "lldb/API/SBWatchpointLocation.h" %} /* Various liblldb typedefs that SWIG needs to know about. */ @@ -131,6 +132,7 @@ %include "./Python/interface/SBType.i" %include "./Python/interface/SBValue.i" %include "./Python/interface/SBValueList.i" +%include "./Python/interface/SBWatchpointLocation.i" %include "./Python/python-extensions.swig" Modified: lldb/trunk/source/API/SBWatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBWatchpointLocation.cpp?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/source/API/SBWatchpointLocation.cpp (original) +++ lldb/trunk/source/API/SBWatchpointLocation.cpp Mon Sep 26 20:19:20 2011 @@ -63,12 +63,46 @@ { } +watch_id_t +SBWatchpointLocation::GetID () const +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + watch_id_t watch_id = LLDB_INVALID_WATCH_ID; + if (m_opaque_sp) + watch_id = m_opaque_sp->GetID(); + + if (log) + { + if (watch_id == LLDB_INVALID_WATCH_ID) + log->Printf ("SBWatchpointLocation(%p)::GetID () => LLDB_INVALID_WATCH_ID", m_opaque_sp.get()); + else + log->Printf ("SBWatchpointLocation(%p)::GetID () => %u", m_opaque_sp.get(), watch_id); + } + + return watch_id; +} + bool SBWatchpointLocation::IsValid() const { return m_opaque_sp.get() != NULL; } +int32_t +SBWatchpointLocation::GetHardwareIndex () const +{ + int32_t hw_index = -1; + + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + hw_index = m_opaque_sp->GetHardwareIndex(); + } + + return hw_index; +} + addr_t SBWatchpointLocation::GetWatchAddress () const { @@ -103,7 +137,7 @@ if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); - m_opaque_sp->SetEnabled (enabled); + m_opaque_sp->GetTarget().DisableWatchpointLocationByID(m_opaque_sp->GetID()); } } @@ -120,6 +154,23 @@ } uint32_t +SBWatchpointLocation::GetHitCount () const +{ + uint32_t count = 0; + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + count = m_opaque_sp->GetHitCount(); + } + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBWatchpointLocation(%p)::GetHitCount () => %u", m_opaque_sp.get(), count); + + return count; +} + +uint32_t SBWatchpointLocation::GetIgnoreCount () { if (m_opaque_sp) Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140595&r1=140594&r2=140595&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Mon Sep 26 20:19:20 2011 @@ -95,7 +95,6 @@ void WatchpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) { - s->Printf(" "); DumpWithLevel(s, level); return; } Added: lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py?rev=140595&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py (added) +++ lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Mon Sep 26 20:19:20 2011 @@ -0,0 +1,118 @@ +""" +Use lldb Python SBTarget API to iterate on the watchpoint(s) for the target. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class WatchpointLocationIteratorTestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.c' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_watch_loc_iter_with_dsym(self): + """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations.""" + self.buildDsym() + self.do_watchpoint_location_iter() + + @python_api_test + def test_watch_loc_iter_with_dwarf(self): + """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations.""" + self.buildDwarf() + self.do_watchpoint_location_iter() + + def do_watchpoint_location_iter(self): + """Use SBTarget.watchpoint_location_iter() to do Pythonic iteration on the available watchpoint locations.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create a breakpoint on main.c in order to set our watchpoint later. + breakpoint = target.BreakpointCreateByLocation(self.source, self.line) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # We should be stopped due to the breakpoint. Get frame #0. + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + value = frame0.WatchValue('global', + lldb.eValueTypeVariableGlobal, + lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) + self.assertTrue(value, "Successfully found the variable and set a watchpoint") + self.DebugSBValue(value) + + # There should be only 1 watchpoint location under the target. + self.assertTrue(target.GetNumWatchpointLocations() == 1) + wp_loc = target.GetWatchpointLocationAtIndex(0) + self.assertTrue(wp_loc.IsEnabled()) + watch_id = wp_loc.GetID() + self.assertTrue(watch_id != 0) + + # Continue. Expect the program to stop due to the variable being written to. + process.Continue() + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + # Print the stack traces. + lldbutil.print_stacktraces(process) + + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint) + self.assertTrue(thread, "The thread stopped due to watchpoint") + self.DebugSBValue(value) + + # We currently only support hardware watchpoint. Verify that we have a + # meaningful hardware index at this point. Exercise the printed repr of + # SBWatchpointLocation. + print wp_loc + self.assertTrue(wp_loc.GetHardwareIndex() != -1) + + # Now disable the 'rw' watchpoint. The program won't stop when it reads + # 'global' next. + wp_loc.SetEnabled(False) + self.assertTrue(wp_loc.GetHardwareIndex() == -1) + self.assertFalse(wp_loc.IsEnabled()) + + # Continue. The program does not stop again when the variable is being + # read from because the watchpoint location has been disabled. + process.Continue() + + # At this point, the inferior process should have exited. + self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + + # Verify some vital statistics and exercise the iterator API. + for wp_loc in target.watchpoint_location_iter(): + self.assertTrue(wp_loc) + self.assertTrue(wp_loc.GetWatchSize() == 4) + self.assertTrue(wp_loc.GetHitCount() == 1) + print wp_loc + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From gclayton at apple.com Tue Sep 27 12:26:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 27 Sep 2011 17:26:03 -0000 Subject: [Lldb-commits] [lldb] r140611 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110927172603.432A52A6C12E@llvm.org> Author: gclayton Date: Tue Sep 27 12:26:03 2011 New Revision: 140611 URL: http://llvm.org/viewvc/llvm-project?rev=140611&view=rev Log: Enable the following CFLAGS in the Xcode project build: -flimit-debug-info -feliminate-unused-debug-types -Wparentheses This helps to trim down the debug information size a bit by omitting types that aren't used. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140611&r1=140610&r2=140611&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 27 12:26:03 2011 @@ -3592,6 +3592,11 @@ LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ( + "-flimit-debug-info", + "-feliminate-unused-debug-types", + "-Wparentheses", + ); VALID_ARCHS = "x86_64 i386"; }; name = Debug; @@ -3622,6 +3627,11 @@ LLVM_BUILD_DIR_ARCH = ""; LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; + OTHER_CFLAGS = ( + "-flimit-debug-info", + "-feliminate-unused-debug-types", + "-Wparentheses", + ); VALID_ARCHS = "x86_64 i386"; }; name = Release; @@ -3696,7 +3706,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -3748,7 +3757,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -3794,7 +3802,6 @@ ); MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -3834,7 +3841,6 @@ ); MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -3874,7 +3880,6 @@ ); MACH_O_TYPE = staticlib; MACOSX_DEPLOYMENT_TARGET = 10.6; - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -3914,6 +3919,11 @@ LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/"; LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; + OTHER_CFLAGS = ( + "-flimit-debug-info", + "-feliminate-unused-debug-types", + "-Wparentheses", + ); VALID_ARCHS = "x86_64 i386"; }; name = BuildAndIntegration; @@ -3934,7 +3944,6 @@ INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_CFLAGS = "-Wparentheses"; OTHER_LDFLAGS = ( "-sectcreate", __TEXT, @@ -3979,7 +3988,6 @@ "$(inherited)", "$(LLVM_BUILD_DIR)", ); - OTHER_CFLAGS = "-Wparentheses"; OTHER_CPLUSPLUSFLAGS = ( "-fno-rtti", "-Wglobal-constructors", @@ -4096,7 +4104,6 @@ INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_CFLAGS = "-Wparentheses"; OTHER_LDFLAGS = ( "-sectcreate", __TEXT, @@ -4126,7 +4133,6 @@ INFOPLIST_FILE = "lldb-Info.plist"; INSTALL_PATH = /Developer/usr/bin; LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_CFLAGS = "-Wparentheses"; OTHER_LDFLAGS = ( "-sectcreate", __TEXT, From jingham at apple.com Tue Sep 27 14:48:21 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 27 Sep 2011 19:48:21 -0000 Subject: [Lldb-commits] [lldb] r140628 - in /lldb/trunk: include/lldb/Symbol/SymbolContext.h source/Commands/CommandCompletions.cpp source/Symbol/SymbolContext.cpp Message-ID: <20110927194821.337E62A6C12C@llvm.org> Author: jingham Date: Tue Sep 27 14:48:20 2011 New Revision: 140628 URL: http://llvm.org/viewvc/llvm-project?rev=140628&view=rev Log: Added an API to SymbolContext to hide the complexity of getting the function name from a symbol context. Use that in CommandCompletions to get the right name. Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=140628&r1=140627&r2=140628&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Tue Sep 27 14:48:20 2011 @@ -15,6 +15,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" +#include "lldb/Core/Mangled.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/LineEntry.h" @@ -266,6 +267,23 @@ // const char *line_number, // const char *symbol); + //------------------------------------------------------------------ + /// Find a name of the innermost function for the symbol context. + /// + /// For instance, if the symbol context contains an inlined block, + /// it will return the inlined function name. + /// + /// @param[in] prefer_mangled + /// if \btrue, then the mangled name will be returned if there + /// is one. Otherwise the unmangled name will be returned if it + /// is available. + /// + /// @return + /// The name of the function represented by this symbol context. + //------------------------------------------------------------------ + ConstString + GetFunctionName (Mangled::NamePreference preference = Mangled::ePreferDemangled); + bool GetParentInlinedFrameInfo (const Address &curr_frame_pc, bool is_concrete_frame, Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=140628&r1=140627&r2=140628&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Tue Sep 27 14:48:20 2011 @@ -627,14 +627,9 @@ { if (sc_list.GetContextAtIndex(i, sc)) { - if (sc.function) - { - m_match_set.insert (sc.function->GetMangled().GetDemangledName()); - } - else if (sc.symbol && sc.symbol->GetAddressRangePtr()) - { - m_match_set.insert (sc.symbol->GetMangled().GetName()); - } + ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); + if (!func_name.IsEmpty()) + m_match_set.insert (func_name); } } } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140628&r1=140627&r2=140628&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Sep 27 14:48:20 2011 @@ -575,6 +575,29 @@ return false; } +ConstString +SymbolContext::GetFunctionName (Mangled::NamePreference preference) +{ + if (function) + { + if (block) + { + const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo(); + if (inline_info) + return inline_info->GetName(); + } + return function->GetMangled().GetName(preference); + } + else if (symbol && symbol->GetAddressRangePtr()) + { + return symbol->GetMangled().GetName(preference); + } + else + { + // No function, return an empty string. + return ConstString(); + } +} //---------------------------------------------------------------------- // From johnny.chen at apple.com Tue Sep 27 15:23:43 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 20:23:43 -0000 Subject: [Lldb-commits] [lldb] r140632 - in /lldb/trunk/test/python_api/default-constructor: TestDefaultConstructorForAPIObjects.py sb_watchpointlocation.py Message-ID: <20110927202343.B4E3C2A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 15:23:43 2011 New Revision: 140632 URL: http://llvm.org/viewvc/llvm-project?rev=140632&view=rev Log: Add fuzz testing for newly added SBWatchpointLocation API. Added: lldb/trunk/test/python_api/default-constructor/sb_watchpointlocation.py Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py?rev=140632&r1=140631&r2=140632&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py (original) +++ lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Tue Sep 27 15:23:43 2011 @@ -339,6 +339,16 @@ import sb_valuelist sb_valuelist.fuzz_obj(obj) + @python_api_test + def test_SBWatchpointLocation(self): + obj = lldb.SBWatchpointLocation() + if self.TraceOn(): + print obj + self.assertFalse(obj) + # Do fuzz testing on the invalid obj, it should not crash lldb. + import sb_watchpointlocation + sb_watchpointlocation.fuzz_obj(obj) + if __name__ == '__main__': import atexit Added: lldb/trunk/test/python_api/default-constructor/sb_watchpointlocation.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_watchpointlocation.py?rev=140632&view=auto ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_watchpointlocation.py (added) +++ lldb/trunk/test/python_api/default-constructor/sb_watchpointlocation.py Tue Sep 27 15:23:43 2011 @@ -0,0 +1,18 @@ +""" +Fuzz tests an object after the default construction to make sure it does not crash lldb. +""" + +import sys +import lldb + +def fuzz_obj(obj): + obj.GetID() + obj.GetHardwareIndex() + obj.GetWatchAddress() + obj.GetWatchSize() + obj.SetEnabled(True) + obj.IsEnabled() + obj.GetHitCount() + obj.GetIgnoreCount() + obj.SetIgnoreCount(5) + obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelVerbose) From johnny.chen at apple.com Tue Sep 27 15:29:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 20:29:45 -0000 Subject: [Lldb-commits] [lldb] r140633 - in /lldb/trunk: include/lldb/API/SBTarget.h include/lldb/Breakpoint/WatchpointLocationList.h include/lldb/Target/Target.h scripts/Python/interface/SBTarget.i scripts/Python/modify-python-lldb.py source/API/SBTarget.cpp source/Target/Target.cpp test/python_api/default-constructor/sb_target.py test/python_api/watchpoint/TestWatchpointLocationIter.py Message-ID: <20110927202945.741322A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 15:29:45 2011 New Revision: 140633 URL: http://llvm.org/viewvc/llvm-project?rev=140633&view=rev Log: Add SBTarget::GetLastCreatedWatchpointLocation() API and export to the Python interface. Also add rich comparison methods (__eq__ and __ne__) for SBWatchpointLocation. Modify TestWatchpointLocationIter.py to exercise the new APIs. Add fuzz testings for the recently added SBTarget APIs related to watchpoint manipulations. Modified: lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/python_api/default-constructor/sb_target.py lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Sep 27 15:29:45 2011 @@ -448,6 +448,9 @@ GetNumWatchpointLocations () const; lldb::SBWatchpointLocation + GetLastCreatedWatchpointLocation (); + + lldb::SBWatchpointLocation GetWatchpointLocationAtIndex (uint32_t idx) const; bool Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Tue Sep 27 15:29:45 2011 @@ -187,6 +187,7 @@ size_t GetSize() const { + Mutex::Locker locker(m_mutex); return m_address_to_location.size(); } Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 27 15:29:45 2011 @@ -298,6 +298,12 @@ size_t size, uint32_t type); + lldb::WatchpointLocationSP + GetLastCreatedWatchpointLocation () + { + return m_last_created_watchpoint_location; + } + WatchpointLocationList & GetWatchpointLocationList() { @@ -866,6 +872,7 @@ BreakpointList m_internal_breakpoint_list; lldb::BreakpointSP m_last_created_breakpoint; WatchpointLocationList m_watchpoint_location_list; + lldb::WatchpointLocationSP m_last_created_watchpoint_location; // We want to tightly control the process destruction process so // we can correctly tear down everything that we need to, so the only // class that knows about the process lifespan is this target class. Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Tue Sep 27 15:29:45 2011 @@ -439,6 +439,9 @@ GetNumWatchpointLocations () const; lldb::SBWatchpointLocation + GetLastCreatedWatchpointLocation (); + + lldb::SBWatchpointLocation GetWatchpointLocationAtIndex (uint32_t idx) const; bool Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Sep 27 15:29:45 2011 @@ -199,11 +199,12 @@ # # This dictionary defines a mapping from classname to equality method name(s). # -e = { 'SBAddress': ['GetFileAddress', 'GetModule'], - 'SBBreakpoint': ['GetID'], - 'SBFileSpec': ['GetFilename', 'GetDirectory'], - 'SBModule': ['GetFileSpec', 'GetUUIDString'], - 'SBType': ['GetByteSize', 'GetName'] +e = { 'SBAddress': ['GetFileAddress', 'GetModule'], + 'SBBreakpoint': ['GetID'], + 'SBWatchpointLocation': ['GetID'], + 'SBFileSpec': ['GetFilename', 'GetDirectory'], + 'SBModule': ['GetFileSpec', 'GetUUIDString'], + 'SBType': ['GetByteSize', 'GetName'] } def list_to_frag(list): Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 27 15:29:45 2011 @@ -871,19 +871,40 @@ { if (m_opaque_sp) { - // The breakpoint list is thread safe, no need to lock + // The watchpoint location list is thread safe, no need to lock return m_opaque_sp->GetWatchpointLocationList().GetSize(); } return 0; } SBWatchpointLocation +SBTarget::GetLastCreatedWatchpointLocation () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBWatchpointLocation sb_watchpoint_location; + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + sb_watchpoint_location = m_opaque_sp->GetLastCreatedWatchpointLocation(); + } + + if (log) + { + log->Printf ("SBTarget(%p)::GetLastCreateWatchpointLocation () => SBWatchpointLocation(%p)", + m_opaque_sp.get(), sb_watchpoint_location.get()); + } + + return sb_watchpoint_location; +} + +SBWatchpointLocation SBTarget::GetWatchpointLocationAtIndex (uint32_t idx) const { SBWatchpointLocation sb_watchpoint_location; if (m_opaque_sp) { - // The breakpoint list is thread safe, no need to lock + // The watchpoint location list is thread safe, no need to lock *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().GetByIndex(idx); } return sb_watchpoint_location; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 27 15:29:45 2011 @@ -167,6 +167,7 @@ m_breakpoint_list.RemoveAll(notify); m_internal_breakpoint_list.RemoveAll(notify); m_last_created_breakpoint.reset(); + m_last_created_watchpoint_location.reset(); m_search_filter_sp.reset(); m_image_search_paths.Clear(notify); m_scratch_ast_context_ap.reset(); @@ -452,7 +453,10 @@ rc.Success() ? "succeeded" : "failed", wp_loc_sp->GetID()); - if (rc.Fail()) wp_loc_sp.reset(); + if (rc.Fail()) + wp_loc_sp.reset(); + else + m_last_created_watchpoint_location = wp_loc_sp; return wp_loc_sp; } Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_target.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_target.py Tue Sep 27 15:29:45 2011 @@ -40,6 +40,14 @@ obj.EnableAllBreakpoints() obj.DisableAllBreakpoints() obj.DeleteAllBreakpoints() + obj.GetNumWatchpointLocations() + obj.GetLastCreatedWatchpointLocation() + obj.GetWatchpointLocationAtIndex(0) + obj.WatchpointLocationDelete(0) + obj.FindWatchpointLocationByID(0) + obj.EnableAllWatchpointLocations() + obj.DisableAllWatchpointLocations() + obj.DeleteAllWatchpointLocations() obj.GetBroadcaster() obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) obj.Clear() Modified: lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py?rev=140633&r1=140632&r2=140633&view=diff ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py (original) +++ lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Tue Sep 27 15:29:45 2011 @@ -65,7 +65,9 @@ # There should be only 1 watchpoint location under the target. self.assertTrue(target.GetNumWatchpointLocations() == 1) - wp_loc = target.GetWatchpointLocationAtIndex(0) + wp_loc = target.GetWatchpointLocationAtIndex(0) + last_created = target.GetLastCreatedWatchpointLocation() + self.assertTrue(wp_loc == last_created) self.assertTrue(wp_loc.IsEnabled()) watch_id = wp_loc.GetID() self.assertTrue(watch_id != 0) From johnny.chen at apple.com Tue Sep 27 16:27:19 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 21:27:19 -0000 Subject: [Lldb-commits] [lldb] r140638 - in /lldb/trunk/test: lldbutil.py python_api/watchpoint/TestWatchpointLocationIter.py Message-ID: <20110927212719.BFD9D2A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 16:27:19 2011 New Revision: 140638 URL: http://llvm.org/viewvc/llvm-project?rev=140638&view=rev Log: SBWatchpointLocation.GetDescription() takes an additional description level arg. Modify get_description() utility function in lldbutil.py to handle that. Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=140638&r1=140637&r2=140638&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue Sep 27 16:27:19 2011 @@ -115,7 +115,8 @@ method = getattr(obj, 'GetDescription') if not method: return None - if isinstance(obj, lldb.SBTarget) or isinstance(obj, lldb.SBBreakpointLocation): + tuple = (lldb.SBTarget, lldb.SBBreakpointLocation, lldb.SBWatchpointLocation) + if isinstance(obj, tuple): if option is None: option = lldb.eDescriptionLevelBrief Modified: lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py?rev=140638&r1=140637&r2=140638&view=diff ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py (original) +++ lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Tue Sep 27 16:27:19 2011 @@ -92,6 +92,9 @@ print wp_loc self.assertTrue(wp_loc.GetHardwareIndex() != -1) + # SBWatchpointLocation.GetDescription() takes a description level arg. + print lldbutil.get_description(wp_loc, lldb.eDescriptionLevelFull) + # Now disable the 'rw' watchpoint. The program won't stop when it reads # 'global' next. wp_loc.SetEnabled(False) From johnny.chen at apple.com Tue Sep 27 16:49:34 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 21:49:34 -0000 Subject: [Lldb-commits] [lldb] r140640 - in /lldb/trunk/test/python_api/lldbutil: frame/TestFrameUtils.py iter/TestLLDBIterator.py iter/TestRegistersIterator.py Message-ID: <20110927214934.E997D2A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 16:49:34 2011 New Revision: 140640 URL: http://llvm.org/viewvc/llvm-project?rev=140640&view=rev Log: Make the assignment of TestBase.mydir more portable. Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=140640&r1=140639&r2=140640&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Tue Sep 27 16:49:34 2011 @@ -9,7 +9,7 @@ class FrameUtilsTestCase(TestBase): - mydir = "python_api/lldbutil/frame" + mydir = os.path.join("python_api", "lldbutil", "frame") def setUp(self): # Call super's setUp(). Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?rev=140640&r1=140639&r2=140640&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Tue Sep 27 16:49:34 2011 @@ -10,7 +10,7 @@ class LLDBIteratorTestCase(TestBase): - mydir = "python_api/lldbutil/iter" + mydir = os.path.join("python_api", "lldbutil", "iter") def setUp(self): # Call super's setUp(). Modified: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?rev=140640&r1=140639&r2=140640&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Tue Sep 27 16:49:34 2011 @@ -10,7 +10,7 @@ class RegistersIteratorTestCase(TestBase): - mydir = "python_api/lldbutil/iter" + mydir = os.path.join("python_api", "lldbutil", "iter") def setUp(self): # Call super's setUp(). From johnny.chen at apple.com Tue Sep 27 18:15:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 27 Sep 2011 23:15:58 -0000 Subject: [Lldb-commits] [lldb] r140654 - in /lldb/trunk/test/python_api/module_section: ./ Makefile TestModuleAndSection.py main.cpp Message-ID: <20110927231558.D9B842A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 18:15:58 2011 New Revision: 140654 URL: http://llvm.org/viewvc/llvm-project?rev=140654&view=rev Log: Add a simple test TestModuleAndSection.py to exercise some module/section-related APIs. In particular, it iterates through the executable module's SBSections, looking for the '__TEXT' section and further iterates on its subsections (of SBSection type, too). Added: lldb/trunk/test/python_api/module_section/ lldb/trunk/test/python_api/module_section/Makefile lldb/trunk/test/python_api/module_section/TestModuleAndSection.py lldb/trunk/test/python_api/module_section/main.cpp Added: lldb/trunk/test/python_api/module_section/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/Makefile?rev=140654&view=auto ============================================================================== --- lldb/trunk/test/python_api/module_section/Makefile (added) +++ lldb/trunk/test/python_api/module_section/Makefile Tue Sep 27 18:15:58 2011 @@ -0,0 +1,6 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp +MAKE_DSYM :=NO + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=140654&view=auto ============================================================================== --- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (added) +++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Tue Sep 27 18:15:58 2011 @@ -0,0 +1,54 @@ +""" +Test some SBModule and SBSection APIs. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class ModuleAndSectionAPIsTestCase(TestBase): + + mydir = os.path.join("python_api", "module_section") + + @python_api_test + def test_module_and_section(self): + """Test module and section APIs.""" + self.buildDefault() + self.module_and_section() + + def module_and_section(self): + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + self.assertTrue(target.GetNumModules() > 0) + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + print "Number of modules for the target: %d" % target.GetNumModules() + for module in target.module_iter(): + print module + + # Get the executable module at index 0. + exe_module = target.GetModuleAtIndex(0) + + print "Exe module: %s" % repr(exe_module) + print "Number of sections: %d" % exe_module.GetNumSections() + INDENT = ' ' * 4 + for sec in exe_module.section_iter(): + print sec + if sec.GetName() == "__TEXT": + print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() + for subsec in sec: + print INDENT + repr(subsec) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/module_section/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/main.cpp?rev=140654&view=auto ============================================================================== --- lldb/trunk/test/python_api/module_section/main.cpp (added) +++ lldb/trunk/test/python_api/module_section/main.cpp Tue Sep 27 18:15:58 2011 @@ -0,0 +1,128 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C includes +#include +#include +#include +#include +#include + +pthread_t g_thread_1 = NULL; +pthread_t g_thread_2 = NULL; +pthread_t g_thread_3 = NULL; + +typedef enum { + eGet, + eAssign, + eClearBits +} MaskAction; + +uint32_t mask_access (MaskAction action, uint32_t mask = 0); + +uint32_t +mask_access (MaskAction action, uint32_t mask) +{ + static pthread_mutex_t g_mask_mutex = PTHREAD_MUTEX_INITIALIZER; + static uint32_t g_mask = 0; + ::pthread_mutex_lock (&g_mask_mutex); + switch (action) + { + case eGet: + break; + + case eAssign: + g_mask |= mask; + break; + + case eClearBits: + g_mask &= ~mask; + break; + } + uint32_t new_mask = g_mask; + ::pthread_mutex_unlock (&g_mask_mutex); + return new_mask; +} + +void * +thread_func (void *arg) +{ + uint32_t thread_index = *((uint32_t *)arg); + uint32_t thread_mask = (1u << (thread_index)); + printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); + + while (mask_access(eGet) & thread_mask) + { + // random micro second sleep from zero to 3 seconds + int usec = ::rand() % 3000000; + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); + ::usleep (usec); + printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line. + } + printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); + return NULL; +} + + +int main (int argc, char const *argv[]) +{ + int err; + void *thread_result = NULL; + uint32_t thread_index_1 = 1; + uint32_t thread_index_2 = 2; + uint32_t thread_index_3 = 3; + uint32_t thread_mask_1 = (1u << thread_index_1); + uint32_t thread_mask_2 = (1u << thread_index_2); + uint32_t thread_mask_3 = (1u << thread_index_3); + + // Make a mask that will keep all threads alive + mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line. + + // Create 3 threads + err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); + err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); + err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); + + char line[64]; + while (mask_access(eGet) != 0) + { + printf ("Enter thread index to kill or ENTER for all:\n"); + fflush (stdout); + // Kill threads by index, or ENTER for all threads + + if (fgets (line, sizeof(line), stdin)) + { + if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') + { + printf ("Exiting all threads...\n"); + break; + } + int32_t index = strtoul (line, NULL, 0); + switch (index) + { + case 1: mask_access (eClearBits, thread_mask_1); break; + case 2: mask_access (eClearBits, thread_mask_2); break; + case 3: mask_access (eClearBits, thread_mask_3); break; + } + continue; + } + + break; + } + + // Clear all thread bits to they all exit + mask_access (eClearBits, UINT32_MAX); + + // Join all of our threads + err = ::pthread_join (g_thread_1, &thread_result); + err = ::pthread_join (g_thread_2, &thread_result); + err = ::pthread_join (g_thread_3, &thread_result); + + return 0; +} From jingham at apple.com Tue Sep 27 18:59:35 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 27 Sep 2011 23:59:35 -0000 Subject: [Lldb-commits] [lldb] r140662 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20110927235935.E241A2A6C12C@llvm.org> Author: jingham Date: Tue Sep 27 18:59:35 2011 New Revision: 140662 URL: http://llvm.org/viewvc/llvm-project?rev=140662&view=rev Log: Need to go to the containing inline block to get the inline name right. Modified: lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140662&r1=140661&r2=140662&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Sep 27 18:59:35 2011 @@ -582,9 +582,14 @@ { if (block) { - const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo(); - if (inline_info) - return inline_info->GetName(); + Block *inlined_block = block->GetContainingInlinedBlock(); + + if (inlined_block) + { + const InlineFunctionInfo *inline_info = inlined_block->GetInlinedFunctionInfo(); + if (inline_info) + return inline_info->GetName(); + } } return function->GetMangled().GetName(preference); } From johnny.chen at apple.com Tue Sep 27 19:51:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 28 Sep 2011 00:51:00 -0000 Subject: [Lldb-commits] [lldb] r140669 - in /lldb/trunk/test: lldbutil.py python_api/module_section/TestModuleAndSection.py Message-ID: <20110928005100.8B1DE2A6C12C@llvm.org> Author: johnny Date: Tue Sep 27 19:51:00 2011 New Revision: 140669 URL: http://llvm.org/viewvc/llvm-project?rev=140669&view=rev Log: Add a test sequence of iterating through a module's symbols belonging to a section. Add the relevant utility functions to the lldbutil.py file. Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=140669&r1=140668&r2=140669&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Tue Sep 27 19:51:00 2011 @@ -44,6 +44,26 @@ print >> buf, i return buf.getvalue() +# ====================================================== +# Utilities for iterating a module's section for symbols +# ====================================================== + +def in_range(symbol, section): + symSA = symbol.GetStartAddress().GetFileAddress() + symEA = symbol.GetEndAddress().GetFileAddress() + secSA = section.GetFileAddress() + secEA = secSA + section.GetByteSize() + if (secSA <= symSA and symEA < secEA): + return True + else: + return False + +def symbol_iter(module, section): + """Given a module and its contained section, returns an iterator on the + symbols within the section.""" + for sym in module: + if in_range(sym, section): + yield sym # ========================================================== # Integer (byte size 1, 2, 4, and 8) to bytearray conversion @@ -184,6 +204,59 @@ else: raise Exception("Unknown StopReason enum") +def symbol_type_to_str(enum): + """Returns the symbolType string given an enum.""" + if enum == lldb.eSymbolTypeInvalid: + return "invalid" + elif enum == lldb.eSymbolTypeAbsolute: + return "absolute" + elif enum == lldb.eSymbolTypeExtern: + return "extern" + elif enum == lldb.eSymbolTypeCode: + return "code" + elif enum == lldb.eSymbolTypeData: + return "data" + elif enum == lldb.eSymbolTypeTrampoline: + return "trampoline" + elif enum == lldb.eSymbolTypeRuntime: + return "runtime" + elif enum == lldb.eSymbolTypeException: + return "exception" + elif enum == lldb.eSymbolTypeSourceFile: + return "sourcefile" + elif enum == lldb.eSymbolTypeHeaderFile: + return "headerfile" + elif enum == lldb.eSymbolTypeObjectFile: + return "objectfile" + elif enum == lldb.eSymbolTypeCommonBlock: + return "commonblock" + elif enum == lldb.eSymbolTypeBlock: + return "block" + elif enum == lldb.eSymbolTypeLocal: + return "local" + elif enum == lldb.eSymbolTypeParam: + return "param" + elif enum == lldb.eSymbolTypeVariable: + return "variable" + elif enum == lldb.eSymbolTypeVariableType: + return "variabletype" + elif enum == lldb.eSymbolTypeLineEntry: + return "lineentry" + elif enum == lldb.eSymbolTypeLineHeader: + return "lineheader" + elif enum == lldb.eSymbolTypeScopeBegin: + return "scopebegin" + elif enum == lldb.eSymbolTypeScopeEnd: + return "scopeend" + elif enum == lldb.eSymbolTypeAdditional: + return "additional" + elif enum == lldb.eSymbolTypeCompiler: + return "compiler" + elif enum == lldb.eSymbolTypeInstrumentation: + return "instrumentation" + elif enum == lldb.eSymbolTypeUndefined: + return "undefined" + def value_type_to_str(enum): """Returns the valueType string given an enum.""" if enum == lldb.eValueTypeInvalid: Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=140669&r1=140668&r2=140669&view=diff ============================================================================== --- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (original) +++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Tue Sep 27 19:51:00 2011 @@ -7,6 +7,7 @@ import unittest2 import lldb from lldbtest import * +from lldbutil import symbol_iter, symbol_type_to_str class ModuleAndSectionAPIsTestCase(TestBase): @@ -39,12 +40,17 @@ print "Exe module: %s" % repr(exe_module) print "Number of sections: %d" % exe_module.GetNumSections() INDENT = ' ' * 4 + INDENT2 = INDENT * 2 for sec in exe_module.section_iter(): print sec if sec.GetName() == "__TEXT": print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() for subsec in sec: print INDENT + repr(subsec) + # Now print the symbols belonging to the subsection.... + for sym in symbol_iter(exe_module, subsec): + print INDENT2 + repr(sym) + print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType()) if __name__ == '__main__': From gclayton at apple.com Wed Sep 28 12:06:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 28 Sep 2011 17:06:41 -0000 Subject: [Lldb-commits] [lldb] r140702 - in /lldb/trunk: include/lldb/lldb-enumerations.h lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ObjectFile.cpp source/lldb.cpp Message-ID: <20110928170641.236752A6C12C@llvm.org> Author: gclayton Date: Wed Sep 28 12:06:40 2011 New Revision: 140702 URL: http://llvm.org/viewvc/llvm-project?rev=140702&view=rev Log: Convert over to the latest and greatest on disc accelerator hash tables. Renamed the DWARF sections to ".apple_names" and ".apple_types" until we get more buy in from other vendors. Modified: lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ObjectFile.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Sep 28 12:06:40 2011 @@ -475,8 +475,8 @@ eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugStr, - eSectionTypeDWARFDebugNames, - eSectionTypeDWARFDebugTypes, + eSectionTypeDWARFAppleNames, + eSectionTypeDWARFAppleTypes, eSectionTypeEHFrame, eSectionTypeOther Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed Sep 28 12:06:40 2011 @@ -99,6 +99,12 @@ ReferencedContainer = "container:lldb.xcodeproj"> + + + + get_debug_str_data ()), + m_is_apple_names (is_apple_names), + m_header () +{ +} - // Extract the bucket entry. - const uint32_t bucket_entry = m_data.GetU32 (&offset); - if (bucket_entry) +bool +HashedNameToDIE::MemoryTable::Initialize () +{ + uint32_t offset = 0; + offset = m_header.Read (m_data, offset); + return m_header.version == 1; +} + + +size_t +HashedNameToDIE::MemoryTable::Find (const char *name_cstr, DIEArray &die_ofsets) const +{ + if (m_header.version == 1) + { + const size_t initial_size = die_ofsets.size(); + if (name_cstr && name_cstr[0]) { - // The bucket entry is non-zero which means it isn't empty. - // The bucket entry is made up of a hash index whose bit width - // is m_header.hash_index_bitsize, and a hash count whose value - // is the remaining bits in the 32 bit value. Below we extract - // the hash index and the hash count - const uint32_t hash_idx = bucket_entry & GetHashIndexMask(); - const uint32_t hash_count = bucket_entry >> m_header.hash_index_bitsize; - const uint32_t hash_end_idx = hash_idx + hash_count; - // Figure out the offset to the hash value by index - uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); - for (uint32_t idx = hash_idx; idx < hash_end_idx; ++idx) + // Hash the C string + const uint32_t name_hash = dl_new_hash (name_cstr); + + // Find the correct bucket for the using the hash value + const uint32_t bucket_idx = name_hash % m_header.bucket_count; + + // Calculate the offset for the bucket entry for the bucket index + uint32_t offset = GetOffsetOfBucketEntry (bucket_idx); + + // Extract the bucket entry. + const uint32_t bucket_entry = m_data.GetU32 (&offset); + if (bucket_entry) { - // Extract the hash value and see if it matches our string - const uint32_t hash = m_data.GetU32 (&hash_offset); - if (hash == name_hash) + // The bucket entry is non-zero which means it isn't empty. + // The bucket entry is made up of a hash index whose bit width + // is m_header.hash_index_bitsize, and a hash count whose value + // is the remaining bits in the 32 bit value. Below we extract + // the hash index and the hash count + const uint32_t hash_idx = bucket_entry & GetHashIndexMask(); + const uint32_t hash_count = bucket_entry >> m_header.hash_index_bitsize; + const uint32_t hash_end_idx = hash_idx + hash_count; + // Figure out the offset to the hash value by index + uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); + for (uint32_t idx = hash_idx; idx < hash_end_idx; ++idx) { - // The hash matches, but we still need to verify that the - // C string matches in case we have a hash collision. Figure - // out the offset for the data associated with this hash entry - offset = GetOffsetOfHashDataOffset (idx); - // Extract the first 32 bit value which is the .debug_str offset - // of the string we need - uint32_t hash_data_offset = m_data.GetU32 (&offset); - const uint32_t str_offset = m_data.GetU32 (&hash_data_offset); - // Extract the C string and comapare it - const char *cstr_name = m_dwarf->get_debug_str_data().PeekCStr(str_offset); - if (cstr_name) + // Extract the hash value and see if it matches our string + const uint32_t hash = m_data.GetU32 (&hash_offset); + if (hash == name_hash) { - if (strcmp(name_cstr, cstr_name) == 0) + // The hash matches, but we still need to verify that the + // C string matches in case we have a hash collision. Figure + // out the offset for the data associated with this hash entry + offset = GetOffsetOfHashDataOffset (idx); + uint32_t hash_data_offset = m_data.GetU32 (&offset); + uint32_t str_offset; + // Now we have the offset to the data for all strings that match + // our 32 bit hash. The format of the hash bucket is: + // + // uint32_t stroff; // string offset in .debug_str table + // uint32_t num_dies; // Number of DIEs in debug info that match the string that follow this + // uint32_t die_offsets[num_dies]; // An array of DIE offsets + // + // When a "stroff" is read and it is zero, then the data for this + // hash is terminated. + while ((str_offset = m_data.GetU32 (&hash_data_offset)) != 0) { - // We have a match, now extract the DIE count - const uint32_t die_count = m_data.GetU32 (&hash_data_offset); - // Now extract "die_count" DIE offsets and put them into the - // results - for (uint32_t die_idx = 0; die_idx < die_count; ++die_idx) - die_ofsets.push_back(m_data.GetU32 (&hash_data_offset)); + // Extract the C string and comapare it + const char *cstr_name = m_string_table.PeekCStr(str_offset); + if (cstr_name) + { + if (strcmp(name_cstr, cstr_name) == 0) + { + // We have a match, now extract the DIE count + const uint32_t die_count = m_data.GetU32 (&hash_data_offset); + // Now extract "die_count" DIE offsets and put them into the + // results + for (uint32_t die_idx = 0; die_idx < die_count; ++die_idx) + die_ofsets.push_back(m_data.GetU32 (&hash_data_offset)); + } + } } } } } } + return die_ofsets.size() - initial_size; } - return die_ofsets.size() - initial_size; -} - -size_t -HashedNameToDIE::Find (const RegularExpression& regex, DIEArray &die_ofsets) const -{ -// const size_t initial_info_array_size = info_array.size(); -// collection::const_iterator pos, end = m_collection.end(); -// for (pos = m_collection.begin(); pos != end; ++pos) -// { -// if (regex.Execute(pos->first)) -// info_array.push_back (pos->second); -// } -// return info_array.size() - initial_info_array_size; return 0; } void -HashedNameToDIE::Dump (Stream *s) +HashedNameToDIE::MemoryTable::Dump (Stream &s) { -// collection::const_iterator pos, end = m_collection.end(); -// for (pos = m_collection.begin(); pos != end; ++pos) -// { -// s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first); -// } + if (m_header.version == 1) + { + + bool verbose = s.GetVerbose(); + + if (m_is_apple_names) + s.PutCString (".apple_names contents:\n"); + else + s.PutCString (".apple_types contents:\n"); + + m_header.Dump (s); + uint32_t i,j,k; + uint32_t empty_bucket_count = 0; + uint32_t hash_collisions = 0; + uint32_t bucket_entry_offset = GetOffsetOfBucketEntry (0); + for (i=0; i> m_header.hash_index_bitsize; + + s.Printf(" (hash_idx = %u, hash_count = %u)\n", hash_idx, hash_count); + + const uint32_t hash_end_idx = hash_idx + hash_count; + uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); + uint32_t data_offset = GetOffsetOfHashDataOffset (hash_idx); + + for (j=hash_idx; j 1) + ++hash_collisions; + } + } + else + { + s.PutCString(" (empty)\n"); + ++empty_bucket_count; + } + } + + s.Printf ("%u of %u buckets empty (%2.1f%%)\n", empty_bucket_count, m_header.bucket_count, (((float)empty_bucket_count/(float)m_header.bucket_count)*100.0f)); + s.Printf ("Average hashes/non-empty bucket = %2.1f%%\n", ((float)m_header.hashes_count/(float)(m_header.bucket_count - empty_bucket_count))); + s.Printf ("Hash collisions = %u\n", hash_collisions); + } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Wed Sep 28 12:06:40 2011 @@ -21,95 +21,269 @@ class HashedNameToDIE { public: + enum NameFlags + { + eNameFlagIsExternal = (1u << 0), + eNameFlagIsClassCXX = (1u << 1), + eNameFlagIsClassObjC = (1u << 2), + eNameFlagIsClassObjCMaster = (1u << 3) + }; + + enum TypeFlags + { + eTypeFlagIsExternal = (1u << 0) + }; + + enum HashFunctionType + { + eHashFunctionDJB = 0u, // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections + }; + + static const uint32_t HASH_MAGIC = 0x48415348u; + struct Header { - uint16_t version; - uint8_t hash_type; - uint8_t hash_index_bitsize; - uint32_t num_buckets; - uint32_t num_hashes; - uint32_t die_offset_base; - - Header() : - version(0), - hash_type (0), - hash_index_bitsize (0), - num_buckets(0), - num_hashes (0), - die_offset_base(0) + uint32_t magic; // 'HASH' magic value to allow endian detection + uint16_t version; // Version number + uint8_t addr_bytesize; // Size in bytes of an address + uint8_t hash_function; // The hash function enumeration that was used + uint8_t hash_count_bitsize; // Size in bits of the hash count in each bucket entry + uint8_t hash_index_bitsize; // Size in bits of the hash index in each bucket entry + uint8_t hash_bytesize; // Size in bytes of the hash that is stored in the hashes which must be <= 4 + uint8_t offset_bytesize; // Size in bytes of the hash data offsets + + uint32_t bucket_count; // The number of buckets in this hash table + uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table + uint32_t prologue_length; // The length of the prologue + + Header (uint32_t _prologue_length) : + magic (HASH_MAGIC), + version (1), + addr_bytesize (4), + hash_count_bitsize (8), + hash_index_bitsize (24), + hash_function (eHashFunctionDJB), + hash_bytesize (4), // Store the entire 32 bit hash by default + offset_bytesize (4), // Store a 4 byte offset for every hash value + bucket_count (0), + hashes_count (0), + prologue_length (_prologue_length) { } + + virtual + ~Header () + { + } + + virtual size_t + GetByteSize() const + { + return sizeof(magic) + + sizeof(version) + + sizeof(addr_bytesize) + + sizeof(hash_function) + + sizeof(hash_count_bitsize) + + sizeof(hash_index_bitsize) + + sizeof(hash_bytesize) + + sizeof(offset_bytesize) + + sizeof(bucket_count) + + sizeof(hashes_count) + + sizeof(prologue_length) + + prologue_length; + } + + virtual void + Dump (lldb_private::Stream &s); + + virtual uint32_t + Read (const lldb_private::DataExtractor &data, uint32_t offset); }; - - HashedNameToDIE (SymbolFileDWARF *dwarf, - const lldb_private::DataExtractor &data); - - ~HashedNameToDIE () + struct DWARF { - } - - bool - IsValid () const - { - return m_header.version > 0; - } + enum AtomType + { + eAtomTypeNULL = 0u, + eAtomTypeHashString = 1u, // String value for hash, use DW_FORM_strp (preferred) or DW_FORM_string + eAtomTypeHashLength = 2u, // Length of data for the previous string refered by the last eAtomTypeHashString atom + eAtomTypeArraySize = 3u, // A count that specifies a number of atoms that follow this entry, the next atom defines what the atom type for the array is + eAtomTypeDIEOffset = 4u, // DIE offset, check form for encoding. If DW_FORM_ref1,2,4,8 or DW_FORM_ref_udata, then this value is added to the prologue + eAtomTypeTag = 5u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2 + eAtomTypeNameFlags = 6u, // Flags from enum NameFlags + eAtomTypeTypeFlags = 7u, // Flags from enum TypeFlags + }; + + struct Atom + { + uint16_t type; + dw_form_t form; + + Atom (uint16_t t = eAtomTypeNULL, dw_form_t f = 0) : + type (t), + form (f) + { + } + }; + + typedef std::vector AtomArray; + + + static const char * + GetAtomTypeName (uint16_t atom) + { + switch (atom) + { + case eAtomTypeNULL: return "NULL"; + case eAtomTypeHashString: return "hash-string"; + case eAtomTypeHashLength: return "hash-data-length"; + case eAtomTypeArraySize: return "array-size"; + case eAtomTypeDIEOffset: return "die-offset"; + case eAtomTypeTag: return "die-tag"; + case eAtomTypeNameFlags: return "name-flags"; + case eAtomTypeTypeFlags: return "type-flags"; + } + return ""; + } + struct Prologue + { + // DIE offset base so die offsets in hash_data can be CU relative + dw_offset_t die_base_offset; + AtomArray atoms; + + Prologue (dw_offset_t _die_base_offset = 0) : + die_base_offset (_die_base_offset) + { + // Define an array of DIE offsets by first defining an array, + // and then define the atom type for the array, in this case + // we have an array of DIE offsets + atoms.push_back (Atom(eAtomTypeArraySize, DW_FORM_data4)); + atoms.push_back (Atom(eAtomTypeDIEOffset, DW_FORM_data4)); + } - uint32_t - GetHashIndexMask () const - { - return (1u << m_header.hash_index_bitsize) - 1u; - } - - uint32_t - GetOffsetOfBucketEntry (uint32_t idx) const - { - if (idx < m_header.num_buckets) - return sizeof(Header) + 4 * idx; - return UINT32_MAX; - } + virtual + ~Prologue () + { + } + + + virtual void + Clear () + { + die_base_offset = 0; + atoms.clear(); + } + + virtual void + Dump (lldb_private::Stream &s); + + virtual uint32_t + Read (const lldb_private::DataExtractor &data, uint32_t offset); + + size_t + GetByteSize () const + { + // Add an extra count to the atoms size for the zero termination Atom that gets + // written to disk + return sizeof(die_base_offset) + ((atoms.size() + 1) * sizeof(Atom)); + } + }; + + struct Header : public HashedNameToDIE::Header + { + Header (dw_offset_t _die_base_offset = 0) : + HashedNameToDIE::Header (sizeof(Prologue)), + dwarf_prologue (_die_base_offset) + { + } - uint32_t - GetOffsetOfHashValue (uint32_t idx) const - { - if (idx < m_header.num_hashes) - return sizeof(Header) + - 4 * m_header.num_buckets + - 4 * idx; - return UINT32_MAX; - } + virtual + ~Header () + { + } + + Prologue dwarf_prologue; + + virtual void + Dump (lldb_private::Stream &s); + + virtual uint32_t + Read (const lldb_private::DataExtractor &data, uint32_t offset); + }; + + }; + - uint32_t - GetOffsetOfHashDataOffset (uint32_t idx) const + class MemoryTable { - if (idx < m_header.num_hashes) + public: + + MemoryTable (SymbolFileDWARF *dwarf, + const lldb_private::DataExtractor &data, + bool is_apple_names); + + ~MemoryTable () { - return sizeof(Header) + - 4 * m_header.num_buckets + - 4 * m_header.num_hashes + - 4 * idx; - } - return UINT32_MAX; - } - - void - Dump (lldb_private::Stream *s); - - size_t - Find (const lldb_private::ConstString &name, - DIEArray &die_ofsets) const; - - size_t - Find (const lldb_private::RegularExpression& regex, - DIEArray &die_ofsets) const; + } - void - Initialize(); - -protected: - SymbolFileDWARF *m_dwarf; - const lldb_private::DataExtractor &m_data; - Header m_header; + bool + Initialize (); + + bool + IsValid () const + { + return m_header.version > 0; + } + + uint32_t + GetHashIndexMask () const + { + return (1u << m_header.hash_index_bitsize) - 1u; + } + + uint32_t + GetOffsetOfBucketEntry (uint32_t idx) const + { + if (idx < m_header.bucket_count) + return m_header.GetByteSize() + 4 * idx; + return UINT32_MAX; + } + + uint32_t + GetOffsetOfHashValue (uint32_t idx) const + { + if (idx < m_header.hashes_count) + return m_header.GetByteSize() + + 4 * m_header.bucket_count + + 4 * idx; + return UINT32_MAX; + } + + uint32_t + GetOffsetOfHashDataOffset (uint32_t idx) const + { + if (idx < m_header.hashes_count) + { + return m_header.GetByteSize() + + 4 * m_header.bucket_count + + 4 * m_header.hashes_count + + 4 * idx; + } + return UINT32_MAX; + } + + void + Dump (lldb_private::Stream &s); + + size_t + Find (const char *name, DIEArray &die_ofsets) const; + + protected: + const lldb_private::DataExtractor &m_data; + const lldb_private::DataExtractor &m_string_table; + bool m_is_apple_names; // true => .apple_names, false => .apple_types + DWARF::Header m_header; + }; }; #endif // SymbolFileDWARF_HashedNameToDIE_h_ 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=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 28 12:06:40 2011 @@ -171,12 +171,12 @@ m_data_debug_loc (), m_data_debug_ranges (), m_data_debug_str (), - m_data_debug_names (), - m_data_debug_types (), + m_data_apple_names (), + m_data_apple_types (), m_abbr(), m_info(), m_line(), - m_debug_names (this, m_data_debug_names), + m_apple_names (this, m_data_apple_names, true), m_function_basename_index(), m_function_fullname_index(), m_function_method_index(), @@ -190,8 +190,8 @@ m_ranges(), m_unique_ast_type_map () { - get_debug_names_data(); - m_debug_names.Initialize(); + get_apple_names_data(); + m_apple_names.Initialize(); } SymbolFileDWARF::~SymbolFileDWARF() @@ -455,15 +455,15 @@ } const DataExtractor& -SymbolFileDWARF::get_debug_names_data() +SymbolFileDWARF::get_apple_names_data() { - return GetCachedSectionData (flagsGotDebugNamesData, eSectionTypeDWARFDebugNames, m_data_debug_names); + return GetCachedSectionData (flagsGotDebugNamesData, eSectionTypeDWARFAppleNames, m_data_apple_names); } const DataExtractor& -SymbolFileDWARF::get_debug_types_data() +SymbolFileDWARF::get_apple_types_data() { - return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFDebugTypes, m_data_debug_types); + return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFAppleTypes, m_data_apple_types); } @@ -2293,10 +2293,10 @@ // Remember how many sc_list are in the list before we search in case // we are appending the results to a variable list. - if (m_debug_names.IsValid()) + if (m_apple_names.IsValid()) { DIEArray die_offsets; - const uint32_t num_matches = m_debug_names.Find(name, die_offsets); + const uint32_t num_matches = m_apple_names.Find(name.GetCString(), die_offsets); if (num_matches > 0) { return ResolveFunctions (die_offsets, sc_list); 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=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Sep 28 12:06:40 2011 @@ -164,8 +164,8 @@ const lldb_private::DataExtractor& get_debug_loc_data (); const lldb_private::DataExtractor& get_debug_ranges_data (); const lldb_private::DataExtractor& get_debug_str_data (); - const lldb_private::DataExtractor& get_debug_names_data (); - const lldb_private::DataExtractor& get_debug_types_data (); + const lldb_private::DataExtractor& get_apple_names_data (); + const lldb_private::DataExtractor& get_apple_types_data (); DWARFDebugAbbrev* DebugAbbrev(); const DWARFDebugAbbrev* DebugAbbrev() const; @@ -379,15 +379,15 @@ lldb_private::DataExtractor m_data_debug_loc; lldb_private::DataExtractor m_data_debug_ranges; lldb_private::DataExtractor m_data_debug_str; - lldb_private::DataExtractor m_data_debug_names; - lldb_private::DataExtractor m_data_debug_types; + lldb_private::DataExtractor m_data_apple_names; + lldb_private::DataExtractor m_data_apple_types; // The auto_ptr items below are generated on demand if and when someone accesses // them through a non const version of this class. std::auto_ptr m_abbr; std::auto_ptr m_info; std::auto_ptr m_line; - HashedNameToDIE m_debug_names; + HashedNameToDIE::MemoryTable m_apple_names; NameToDIE m_function_basename_index; // All concrete functions NameToDIE m_function_fullname_index; // All concrete functions NameToDIE m_function_method_index; // All inlined functions Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Wed Sep 28 12:06:40 2011 @@ -221,8 +221,8 @@ case eSectionTypeDWARFDebugPubTypes: return eAddressClassDebug; case eSectionTypeDWARFDebugRanges: return eAddressClassDebug; case eSectionTypeDWARFDebugStr: return eAddressClassDebug; - case eSectionTypeDWARFDebugNames: return eAddressClassDebug; - case eSectionTypeDWARFDebugTypes: return eAddressClassDebug; + case eSectionTypeDWARFAppleNames: return eAddressClassDebug; + case eSectionTypeDWARFAppleTypes: return eAddressClassDebug; case eSectionTypeEHFrame: return eAddressClassRuntime; case eSectionTypeOther: return eAddressClassUnknown; } Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=140702&r1=140701&r2=140702&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Wed Sep 28 12:06:40 2011 @@ -259,8 +259,8 @@ case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; case eSectionTypeDWARFDebugStr: return "dwarf-str"; - case eSectionTypeDWARFDebugNames: return "dwarf-names"; - case eSectionTypeDWARFDebugTypes: return "dwarf-types"; + case eSectionTypeDWARFAppleNames: return "apple-names"; + case eSectionTypeDWARFAppleTypes: return "apple-types"; case eSectionTypeEHFrame: return "eh-frame"; case eSectionTypeOther: return "regular"; } From johnny.chen at apple.com Wed Sep 28 13:33:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 28 Sep 2011 18:33:50 -0000 Subject: [Lldb-commits] [lldb] r140710 - in /lldb/trunk/test: lldbutil.py python_api/module_section/TestModuleAndSection.py Message-ID: <20110928183350.CC0052A6C12C@llvm.org> Author: johnny Date: Wed Sep 28 13:33:50 2011 New Revision: 140710 URL: http://llvm.org/viewvc/llvm-project?rev=140710&view=rev Log: Modify lldbutil.in_range(symbol, section) to deal with the symbol whose end address is an LLDB_INVALID_ADDRESS. Modify the test case to dump all the symbols in all the sections. Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=140710&r1=140709&r2=140710&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed Sep 28 13:33:50 2011 @@ -53,10 +53,17 @@ symEA = symbol.GetEndAddress().GetFileAddress() secSA = section.GetFileAddress() secEA = secSA + section.GetByteSize() - if (secSA <= symSA and symEA < secEA): - return True + + if symEA != lldb.LLDB_INVALID_ADDRESS: + if secSA <= symSA and symEA <= secEA: + return True + else: + return False else: - return False + if secSA <= symSA and symSA < secEA: + return True + else: + return False def symbol_iter(module, section): """Given a module and its contained section, returns an iterator on the Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=140710&r1=140709&r2=140710&view=diff ============================================================================== --- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (original) +++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Wed Sep 28 13:33:50 2011 @@ -43,8 +43,12 @@ INDENT2 = INDENT * 2 for sec in exe_module.section_iter(): print sec - if sec.GetName() == "__TEXT": - print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() + print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() + if sec.GetNumSubSections() == 0: + for sym in symbol_iter(exe_module, sec): + print INDENT + repr(sym) + print INDENT + "symbol type: %s" % symbol_type_to_str(sym.GetType()) + else: for subsec in sec: print INDENT + repr(subsec) # Now print the symbols belonging to the subsection.... From johnny.chen at apple.com Wed Sep 28 14:41:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 28 Sep 2011 19:41:18 -0000 Subject: [Lldb-commits] [lldb] r140714 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20110928194118.BDDE62A6C130@llvm.org> Author: johnny Date: Wed Sep 28 14:41:18 2011 New Revision: 140714 URL: http://llvm.org/viewvc/llvm-project?rev=140714&view=rev Log: Fix help string for "frame variable". Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140714&r1=140713&r2=140714&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Sep 28 14:41:18 2011 @@ -322,7 +322,6 @@ "argument, local, file static and file global variables. " "Children of aggregate variables can be specified such as " "'var->child.x'. " - "NOTE that '-w' option is not working yet!!! " "You can choose to watch a variable with the '-w' option. " "Note that hardware resources for watching are often limited.", NULL, From gclayton at apple.com Wed Sep 28 19:58:12 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 29 Sep 2011 00:58:12 -0000 Subject: [Lldb-commits] [lldb] r140750 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: HashedNameToDIE.cpp HashedNameToDIE.h Message-ID: <20110929005812.E47502A6C12C@llvm.org> Author: gclayton Date: Wed Sep 28 19:58:11 2011 New Revision: 140750 URL: http://llvm.org/viewvc/llvm-project?rev=140750&view=rev Log: Found a great optimization after speaking with Sean Callanan which cleans up the implementation details of the on disk hash, these changed implement the changes in the on disk table format. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=140750&r1=140749&r2=140750&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Wed Sep 28 19:58:11 2011 @@ -42,10 +42,6 @@ s.Printf ("header.version = 0x%4.4x", version); s.Printf ("header.addr_bytesize = 0x%2.2x", addr_bytesize); s.Printf ("header.hash_function = 0x%2.2x", hash_function); - s.Printf ("header.hash_count_bitsize = 0x%2.2x", hash_count_bitsize); - s.Printf ("header.hash_index_bitsize = 0x%2.2x", hash_index_bitsize); - s.Printf ("header.hash_bytesize = 0x%2.2x", hash_bytesize); - s.Printf ("header.offset_bytesize = 0x%2.2x", offset_bytesize); s.Printf ("header.bucket_count = 0x%8.8x %u", bucket_count, bucket_count); s.Printf ("header.hashes_count = 0x%8.8x %u", hashes_count, hashes_count); s.Printf ("header.prologue_length = 0x%8.8x %u", prologue_length, prologue_length); @@ -70,10 +66,6 @@ } addr_bytesize = data.GetU8 (&offset); hash_function = data.GetU8 (&offset); - hash_count_bitsize = data.GetU8 (&offset); - hash_index_bitsize = data.GetU8 (&offset); - hash_bytesize = data.GetU8 (&offset); - offset_bytesize = data.GetU8 (&offset); bucket_count = data.GetU32 (&offset); hashes_count = data.GetU32 (&offset); prologue_length = data.GetU32 (&offset); @@ -154,42 +146,38 @@ { if (m_header.version == 1) { - const size_t initial_size = die_ofsets.size(); if (name_cstr && name_cstr[0]) { // Hash the C string const uint32_t name_hash = dl_new_hash (name_cstr); + const uint32_t bucket_count = m_header.bucket_count; // Find the correct bucket for the using the hash value - const uint32_t bucket_idx = name_hash % m_header.bucket_count; + const uint32_t bucket_idx = name_hash % bucket_count; // Calculate the offset for the bucket entry for the bucket index uint32_t offset = GetOffsetOfBucketEntry (bucket_idx); - // Extract the bucket entry. - const uint32_t bucket_entry = m_data.GetU32 (&offset); - if (bucket_entry) + // Extract the bucket entry which is a hash index. If the hash index + // is UINT32_MAX, then the bucket is empty. If it isn't, it is the + // index of the hash in the hashes array. We will then iterate through + // all hashes as long as they match "bucket_idx" which was calculated + // above + uint32_t hash_idx = m_data.GetU32 (&offset); + if (hash_idx != UINT32_MAX) { - // The bucket entry is non-zero which means it isn't empty. - // The bucket entry is made up of a hash index whose bit width - // is m_header.hash_index_bitsize, and a hash count whose value - // is the remaining bits in the 32 bit value. Below we extract - // the hash index and the hash count - const uint32_t hash_idx = bucket_entry & GetHashIndexMask(); - const uint32_t hash_count = bucket_entry >> m_header.hash_index_bitsize; - const uint32_t hash_end_idx = hash_idx + hash_count; - // Figure out the offset to the hash value by index uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); - for (uint32_t idx = hash_idx; idx < hash_end_idx; ++idx) + + const size_t initial_size = die_ofsets.size(); + uint32_t hash; + while (((hash = m_data.GetU32 (&hash_offset)) % bucket_count) == bucket_idx) { - // Extract the hash value and see if it matches our string - const uint32_t hash = m_data.GetU32 (&hash_offset); if (hash == name_hash) { // The hash matches, but we still need to verify that the // C string matches in case we have a hash collision. Figure // out the offset for the data associated with this hash entry - offset = GetOffsetOfHashDataOffset (idx); + offset = GetOffsetOfHashDataOffset (hash_idx); uint32_t hash_data_offset = m_data.GetU32 (&offset); uint32_t str_offset; // Now we have the offset to the data for all strings that match @@ -219,10 +207,12 @@ } } } + ++hash_idx; } + + return die_ofsets.size() - initial_size; } } - return die_ofsets.size() - initial_size; } return 0; } @@ -231,75 +221,67 @@ HashedNameToDIE::MemoryTable::Dump (Stream &s) { if (m_header.version == 1) - { - - bool verbose = s.GetVerbose(); - + { if (m_is_apple_names) s.PutCString (".apple_names contents:\n"); else s.PutCString (".apple_types contents:\n"); m_header.Dump (s); - uint32_t i,j,k; uint32_t empty_bucket_count = 0; uint32_t hash_collisions = 0; - uint32_t bucket_entry_offset = GetOffsetOfBucketEntry (0); - for (i=0; i> m_header.hash_index_bitsize; - - s.Printf(" (hash_idx = %u, hash_count = %u)\n", hash_idx, hash_count); + uint32_t hash_idx = m_data.GetU32 (&hash_idx_offset); + s.Printf("bucket[%u] ", bucket_idx); + + if (hash_idx != UINT32_MAX) + { + s.Printf(" => hash[%u]\n", hash_idx); - const uint32_t hash_end_idx = hash_idx + hash_count; uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); uint32_t data_offset = GetOffsetOfHashDataOffset (hash_idx); - for (j=hash_idx; j 1) + if (string_count > 1) ++hash_collisions; } } else { - s.PutCString(" (empty)\n"); + s.PutCString(" EMPTY\n"); ++empty_bucket_count; } + s.EOL(); } - - s.Printf ("%u of %u buckets empty (%2.1f%%)\n", empty_bucket_count, m_header.bucket_count, (((float)empty_bucket_count/(float)m_header.bucket_count)*100.0f)); + s.EOL(); + s.Printf ("%u of %u buckets empty (%2.1f%%)\n", empty_bucket_count, bucket_count, (((float)empty_bucket_count/(float)m_header.bucket_count)*100.0f)); s.Printf ("Average hashes/non-empty bucket = %2.1f%%\n", ((float)m_header.hashes_count/(float)(m_header.bucket_count - empty_bucket_count))); s.Printf ("Hash collisions = %u\n", hash_collisions); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=140750&r1=140749&r2=140750&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Wed Sep 28 19:58:11 2011 @@ -47,11 +47,6 @@ uint16_t version; // Version number uint8_t addr_bytesize; // Size in bytes of an address uint8_t hash_function; // The hash function enumeration that was used - uint8_t hash_count_bitsize; // Size in bits of the hash count in each bucket entry - uint8_t hash_index_bitsize; // Size in bits of the hash index in each bucket entry - uint8_t hash_bytesize; // Size in bytes of the hash that is stored in the hashes which must be <= 4 - uint8_t offset_bytesize; // Size in bytes of the hash data offsets - uint32_t bucket_count; // The number of buckets in this hash table uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table uint32_t prologue_length; // The length of the prologue @@ -60,11 +55,7 @@ magic (HASH_MAGIC), version (1), addr_bytesize (4), - hash_count_bitsize (8), - hash_index_bitsize (24), hash_function (eHashFunctionDJB), - hash_bytesize (4), // Store the entire 32 bit hash by default - offset_bytesize (4), // Store a 4 byte offset for every hash value bucket_count (0), hashes_count (0), prologue_length (_prologue_length) @@ -83,10 +74,6 @@ sizeof(version) + sizeof(addr_bytesize) + sizeof(hash_function) + - sizeof(hash_count_bitsize) + - sizeof(hash_index_bitsize) + - sizeof(hash_bytesize) + - sizeof(offset_bytesize) + sizeof(bucket_count) + sizeof(hashes_count) + sizeof(prologue_length) + @@ -236,12 +223,6 @@ } uint32_t - GetHashIndexMask () const - { - return (1u << m_header.hash_index_bitsize) - 1u; - } - - uint32_t GetOffsetOfBucketEntry (uint32_t idx) const { if (idx < m_header.bucket_count) From johnny.chen at apple.com Wed Sep 28 20:20:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 29 Sep 2011 01:20:42 -0000 Subject: [Lldb-commits] [lldb] r140757 - in /lldb/trunk: test/functionalities/watchpoint/multiple_threads/ test/functionalities/watchpoint/multiple_threads/Makefile test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py test/functionalities/watchpoint/multiple_threads/main.cpp tools/debugserver/source/MacOSX/MachThreadList.cpp Message-ID: <20110929012042.8E7082A6C12C@llvm.org> Author: johnny Date: Wed Sep 28 20:20:42 2011 New Revision: 140757 URL: http://llvm.org/viewvc/llvm-project?rev=140757&view=rev Log: Fix a bug in the current MacOSX MachThreadList::EnableHardwareWatchpoint() impl so that it enables the hardware watchpoint for all existing threads. Add a test file for that. Also fix MachThreadList::DisableHardwareWatchpoint(). Added: lldb/trunk/test/functionalities/watchpoint/multiple_threads/ lldb/trunk/test/functionalities/watchpoint/multiple_threads/Makefile lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Added: lldb/trunk/test/functionalities/watchpoint/multiple_threads/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/Makefile?rev=140757&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/Makefile (added) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/Makefile Wed Sep 28 20:20:42 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py?rev=140757&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py (added) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py Wed Sep 28 20:20:42 2011 @@ -0,0 +1,90 @@ +""" +Test that lldb watchpoint works for multiple threads. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class WatchpointForMultipleThreadsTestCase(TestBase): + + mydir = os.path.join("functionalities", "watchpoint", "multiple_threads") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_watchpoint_multiple_threads_with_dsym(self): + """Test that lldb watchpoint works for multiple threads.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.hello_multiple_threads() + + def test_watchpoint_multiple_threads_with_dwarf(self): + """Test that lldb watchpoint works for multiple threads.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.hello_multiple_threads() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + # Build dictionary to have unique executable names for each test method. + self.exe_name = self.testMethodName + self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} + + def hello_multiple_threads(self): + """Test that lldb watchpoint works for multiple threads.""" + exe = os.path.join(os.getcwd(), self.exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Add a breakpoint to set a watchpoint when stopped on the breakpoint. + self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.source, self.line)) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped again due to the breakpoint. + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # Now let's set a write-type watchpoint for variable 'g_val'. + # The main.cpp, by design, misbehaves by not following the agreed upon + # protocol of using a mutex while accessing the global pool and by not + # writing to the variable. + self.expect("frame variable -w write -g g_val", WATCHPOINT_CREATED, + substrs = ['Watchpoint created', 'size = 4', 'type = w']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 0 initially. + self.expect("watchpoint list -v", + substrs = ['hit_count = 0']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (write type) in a + # different work thread. And the stop reason of the thread should be + # watchpoint. + self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stopped', + 'stop reason = watchpoint']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should now be 1. + self.expect("watchpoint list -v", + substrs = ['hit_count = 1']) + + self.runCmd("thread backtrace all") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp?rev=140757&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp (added) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp Wed Sep 28 20:20:42 2011 @@ -0,0 +1,89 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C includes +#include +#include +#include +#include +#include + +pthread_t g_thread_1 = NULL; +pthread_t g_thread_2 = NULL; +pthread_t g_thread_3 = NULL; + +uint32_t g_val = 0; + +uint32_t access_pool (uint32_t flag = 0); + +uint32_t +access_pool (uint32_t flag) +{ + static pthread_mutex_t g_access_mutex = PTHREAD_MUTEX_INITIALIZER; + if (flag == 0) + ::pthread_mutex_lock (&g_access_mutex); + + uint32_t old_val = g_val; + if (flag != 0) + g_val = old_val + 1; + + if (flag == 0) + ::pthread_mutex_unlock (&g_access_mutex); + return g_val; +} + +void * +thread_func (void *arg) +{ + uint32_t thread_index = *((uint32_t *)arg); + printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); + + uint32_t count = 0; + uint32_t val; + while (count++ < 15) + { + // random micro second sleep from zero to 3 seconds + int usec = ::rand() % 3000000; + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); + ::usleep (usec); + + if (count < 7) + val = access_pool (); + else + val = access_pool (1); + + printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count); + } + printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); + return NULL; +} + + +int main (int argc, char const *argv[]) +{ + int err; + void *thread_result = NULL; + uint32_t thread_index_1 = 1; + uint32_t thread_index_2 = 2; + uint32_t thread_index_3 = 3; + + // Create 3 threads + err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); + err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); + err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); + + printf ("Before turning all three threads loose...\n"); // Set break point at this line. + + // Join all of our threads + err = ::pthread_join (g_thread_1, &thread_result); + err = ::pthread_join (g_thread_2, &thread_result); + err = ::pthread_join (g_thread_3, &thread_result); + + return 0; +} Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=140757&r1=140756&r2=140757&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Wed Sep 28 20:20:42 2011 @@ -99,26 +99,14 @@ PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); MachThreadSP thread_sp; const size_t num_threads = m_threads.size(); - if (MachThread::ThreadIDIsValid(tid)) + for (size_t idx = 0; idx < num_threads; ++idx) { - for (size_t idx = 0; idx < num_threads; ++idx) + if (m_threads[idx]->ThreadID() == tid) { - if (m_threads[idx]->ThreadID() == tid) - { - thread_sp = m_threads[idx]; - break; - } + thread_sp = m_threads[idx]; + break; } } - else if (num_threads > 0) - { - // See DNBWatchpointSet() -> MachProcess::CreateWatchpoint() -> MachProcess::EnableWatchpoint() - // -> MachThreadList::EnableHardwareWatchpoint() for a use case of this branch. - if (m_current_thread) - thread_sp = m_current_thread; - else - thread_sp = m_threads[0]; - } return thread_sp; } @@ -477,14 +465,22 @@ return false; } +// DNBWatchpointSet() -> MachProcess::CreateWatchpoint() -> MachProcess::EnableWatchpoint() +// -> MachThreadList::EnableHardwareWatchpoint(). uint32_t MachThreadList::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const { if (wp != NULL) { - MachThreadSP thread_sp (GetThreadByID (wp->ThreadID())); - if (thread_sp) - return thread_sp->EnableHardwareWatchpoint(wp); + uint32_t hw_index; + PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); + const uint32_t num_threads = m_threads.size(); + for (uint32_t idx = 0; idx < num_threads; ++idx) + { + if ((hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp)) == INVALID_NUB_HW_INDEX) + return INVALID_NUB_HW_INDEX; + } + return hw_index; } return INVALID_NUB_HW_INDEX; } @@ -494,9 +490,14 @@ { if (wp != NULL) { - MachThreadSP thread_sp (GetThreadByID (wp->ThreadID())); - if (thread_sp) - return thread_sp->DisableHardwareWatchpoint(wp); + PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex); + const uint32_t num_threads = m_threads.size(); + for (uint32_t idx = 0; idx < num_threads; ++idx) + { + if (!m_threads[idx]->DisableHardwareWatchpoint(wp)) + return false; + } + return true; } return false; } From gclayton at apple.com Thu Sep 29 11:58:16 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 29 Sep 2011 16:58:16 -0000 Subject: [Lldb-commits] [lldb] r140788 - in /lldb/trunk: include/lldb/Symbol/SymbolContext.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/SymbolContext.cpp Message-ID: <20110929165818.4C8EF2A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 11:58:15 2011 New Revision: 140788 URL: http://llvm.org/viewvc/llvm-project?rev=140788&view=rev Log: If the new .apple_names and .apple_types DWARF accelerator tables are available, we currently will still index the DWARF ourselves and assert if the name lookups differ. This will help us transition to the new accelerator tables and make sure they are workng before we switch over entirely. Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=140788&r1=140787&r2=140788&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Thu Sep 29 11:58:15 2011 @@ -458,6 +458,9 @@ bool operator== (const SymbolContext& lhs, const SymbolContext& rhs); bool operator!= (const SymbolContext& lhs, const SymbolContext& rhs); +bool operator== (const SymbolContextList& lhs, const SymbolContextList& rhs); +bool operator!= (const SymbolContextList& lhs, const SymbolContextList& rhs); + } // namespace lldb_private #endif // liblldb_SymbolContext_h_ 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=140788&r1=140787&r2=140788&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 29 11:58:15 2011 @@ -177,6 +177,7 @@ m_info(), m_line(), m_apple_names (this, m_data_apple_names, true), + m_apple_types (this, m_data_apple_types, true), m_function_basename_index(), m_function_fullname_index(), m_function_method_index(), @@ -190,8 +191,6 @@ m_ranges(), m_unique_ast_type_map () { - get_apple_names_data(); - m_apple_names.Initialize(); } SymbolFileDWARF::~SymbolFileDWARF() @@ -252,6 +251,11 @@ if (section) section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data); } + get_apple_names_data(); + get_apple_types_data(); + m_apple_names.Initialize(); + m_apple_types.Initialize(); + } bool @@ -2293,17 +2297,6 @@ // Remember how many sc_list are in the list before we search in case // we are appending the results to a variable list. - if (m_apple_names.IsValid()) - { - DIEArray die_offsets; - const uint32_t num_matches = m_apple_names.Find(name.GetCString(), die_offsets); - if (num_matches > 0) - { - return ResolveFunctions (die_offsets, sc_list); - } - return 0; - } - const uint32_t original_size = sc_list.GetSize(); // Index the DWARF if we haven't already @@ -2322,6 +2315,17 @@ if (name_type_mask & eFunctionNameTypeSelector) FindFunctions (name, m_function_selector_index, sc_list); + if (m_apple_names.IsValid()) + { + SymbolContextList sc_list_apple; + DIEArray die_offsets; + const uint32_t num_matches = m_apple_names.Find(name.GetCString(), die_offsets); + if (num_matches > 0) + ResolveFunctions (die_offsets, sc_list_apple); + if (sc_list != sc_list_apple) + assert (!"__apple_names results differ from DWARF index results"); + } + // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; } 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=140788&r1=140787&r2=140788&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Sep 29 11:58:15 2011 @@ -388,6 +388,7 @@ std::auto_ptr m_info; std::auto_ptr m_line; HashedNameToDIE::MemoryTable m_apple_names; + HashedNameToDIE::MemoryTable m_apple_types; NameToDIE m_function_basename_index; // All concrete functions NameToDIE m_function_fullname_index; // All concrete functions NameToDIE m_function_method_index; // All inlined functions Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140788&r1=140787&r2=140788&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Sep 29 11:58:15 2011 @@ -1044,3 +1044,28 @@ return match_count; } +bool +lldb_private::operator== (const SymbolContextList& lhs, const SymbolContextList& rhs) +{ + const uint32_t size = lhs.GetSize(); + if (size != rhs.GetSize()) + return false; + + SymbolContext lhs_sc; + SymbolContext rhs_sc; + for (uint32_t i=0; i Author: jingham Date: Thu Sep 29 15:22:33 2011 New Revision: 140804 URL: http://llvm.org/viewvc/llvm-project?rev=140804&view=rev Log: Missed one place where we should use the target's SourceManager, not the debugger's. Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=140804&r1=140803&r2=140804&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Thu Sep 29 15:22:33 2011 @@ -452,7 +452,7 @@ // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (m_interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream(), + if (target->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream(), GetBreakpointLocations ())) { result.SetStatus (eReturnStatusSuccessFinishResult); From gclayton at apple.com Thu Sep 29 16:19:26 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 29 Sep 2011 21:19:26 -0000 Subject: [Lldb-commits] [lldb] r140808 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Symbol/Block.cpp Message-ID: <20110929211926.753312A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 16:19:25 2011 New Revision: 140808 URL: http://llvm.org/viewvc/llvm-project?rev=140808&view=rev Log: Free up some space in lldb_private::Block by not requiring a sibling pointer. The old way of storing blocks used to use the sibling pointer, but now all blocks contain a collection of shared pointers to blocks so this isn't required anymore and a parent can be asked to find the sibling block for a child block. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Symbol/Block.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=140808&r1=140807&r2=140808&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Thu Sep 29 16:19:25 2011 @@ -247,10 +247,7 @@ /// sibling. //------------------------------------------------------------------ Block * - GetSibling () const - { - return m_sibling; - } + GetSibling () const; //------------------------------------------------------------------ /// Get the first child block. @@ -398,12 +395,6 @@ m_parent_scope = parent_scope; } - void - SetSibling (Block *block) - { - m_sibling = block; - } - //------------------------------------------------------------------ /// Set accessor for the variable list. /// @@ -466,7 +457,6 @@ // Member variables. //------------------------------------------------------------------ SymbolContextScope *m_parent_scope; - Block *m_sibling; collection m_children; VMRange::collection m_ranges; ///< A list of address offset ranges relative to the function's section/offset address. lldb::InlineFunctionInfoSP m_inlineInfoSP; ///< Inlined function information. @@ -475,6 +465,11 @@ m_parsed_block_variables:1, m_parsed_child_blocks:1; + // A parent of child blocks can be asked to find a sibling block given + // one of its child blocks + Block * + GetSiblingForChild (const Block *child_block) const; + private: DISALLOW_COPY_AND_ASSIGN (Block); }; Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=140808&r1=140807&r2=140808&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Thu Sep 29 16:19:25 2011 @@ -21,7 +21,6 @@ Block::Block(lldb::user_id_t uid) : UserID(uid), m_parent_scope (NULL), - m_sibling (NULL), m_children (), m_ranges (), m_inlineInfoSP (), @@ -117,10 +116,9 @@ m_variable_list_sp->Dump(s, show_context); } - for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling()) - { - child_block->Dump(s, base_addr, depth - 1, show_context); - } + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) + (*pos)->Dump(s, base_addr, depth - 1, show_context); s->IndentLess(); } @@ -135,9 +133,10 @@ return this; Block *matching_block = NULL; - for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling()) + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) { - matching_block = child_block->FindBlockByID (block_id); + matching_block = (*pos)->FindBlockByID (block_id); if (matching_block) break; } @@ -458,16 +457,8 @@ { if (child_block_sp) { - Block *block_needs_sibling = NULL; - - if (!m_children.empty()) - block_needs_sibling = m_children.back().get(); - child_block_sp->SetParentScope (this); m_children.push_back (child_block_sp); - - if (block_needs_sibling) - block_needs_sibling->SetSibling (child_block_sp.get()); } } @@ -512,10 +503,10 @@ if (get_child_block_variables) { - for (Block *child_block = GetFirstChild(); - child_block != NULL; - child_block = child_block->GetSibling()) - { + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) + { + Block *child_block = pos->get(); if (stop_if_child_block_is_inlined_function == false || child_block->GetInlinedFunctionInfo() == NULL) { @@ -590,8 +581,9 @@ if (set_children) { m_parsed_child_blocks = true; - for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling()) - child_block->SetBlockInfoHasBeenParsed (b, true); + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) + (*pos)->SetBlockInfoHasBeenParsed (b, true); } } @@ -601,8 +593,42 @@ m_parsed_block_variables = b; if (set_children) { - for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling()) - child_block->SetDidParseVariables (b, true); + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) + (*pos)->SetDidParseVariables (b, true); + } +} + + +Block * +Block::GetSibling() const +{ + if (m_parent_scope) + { + Block *parent_block = m_parent_scope->CalculateSymbolContextBlock(); + if (parent_block) + return parent_block->GetSiblingForChild (this); } + return NULL; +} +// A parent of child blocks can be asked to find a sibling block given +// one of its child blocks +Block * +Block::GetSiblingForChild (const Block *child_block) const +{ + if (!m_children.empty()) + { + collection::const_iterator pos, end = m_children.end(); + for (pos = m_children.begin(); pos != end; ++pos) + { + if (pos->get() == child_block) + { + if (++pos != end) + return pos->get(); + break; + } + } + } + return NULL; } From johnny.chen at apple.com Thu Sep 29 16:48:53 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 29 Sep 2011 21:48:53 -0000 Subject: [Lldb-commits] [lldb] r140811 - in /lldb/trunk: test/functionalities/watchpoint/multiple_threads/ tools/debugserver/source/ tools/debugserver/source/MacOSX/ tools/debugserver/source/MacOSX/i386/ tools/debugserver/source/MacOSX/x86_64/ Message-ID: <20110929214853.A91692A6C12C@llvm.org> Author: johnny Date: Thu Sep 29 16:48:52 2011 New Revision: 140811 URL: http://llvm.org/viewvc/llvm-project?rev=140811&view=rev Log: Modify the delegation chain from MachThreadList -> MachThread -> DNBArchProtocol so that when the watchpoint state is changed, not only does the change propagate to all the thread instances, it also updates a global debug state, if chosen by the DNBArchProtocol derivative. Once implemented, the DNBArchProtocol derivative, also makes sure that when new thread comes along, it tries to inherit from the global debug state, if it is valid. Modify TestWatchpointMultipleThreads.py to test this functionality. Modified: lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp lldb/trunk/tools/debugserver/source/DNBArch.h lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Modified: lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py (original) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py Thu Sep 29 16:48:52 2011 @@ -30,7 +30,8 @@ # Our simple source filename. self.source = 'main.cpp' # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') + self.first_stop = line_number(self.source, '// Set break point at this line') + self.thread_function = line_number(self.source, '// Break here in order to allow the thread') # Build dictionary to have unique executable names for each test method. self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} @@ -41,9 +42,14 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, + self.expect("breakpoint set -l %d" % self.first_stop, BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % - (self.source, self.line)) + (self.source, self.first_stop)) + + # Set this breakpoint to allow newly created thread to inherit the global watchpoint state. + self.expect("breakpoint set -l %d" % self.thread_function, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: file ='%s', line = %d, locations = 1" % + (self.source, self.thread_function)) # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -66,22 +72,28 @@ self.expect("watchpoint list -v", substrs = ['hit_count = 0']) - self.runCmd("process continue") - - # We should be stopped again due to the watchpoint (write type) in a - # different work thread. And the stop reason of the thread should be - # watchpoint. - self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stopped', - 'stop reason = watchpoint']) + breakpoint_stops = 0 + while True: + self.runCmd("process continue") + + self.runCmd("thread list") + if "stop reason = breakpoint" in self.res.GetOutput(): + breakpoint_stops += 1 + if breakpoint_stops > 3: + self.fail("Do not expect to break more than 3 times") + continue + elif "stop reason = watchpoint" in self.res.GetOutput(): + # Good, we verified that the watchpoint works! + self.runCmd("thread backtrace all") + break + else: + self.fail("The stop reason should be either break or watchpoint") # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", substrs = ['hit_count = 1']) - self.runCmd("thread backtrace all") - if __name__ == '__main__': import atexit Modified: lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp (original) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp Thu Sep 29 16:48:52 2011 @@ -41,7 +41,8 @@ void * thread_func (void *arg) { - uint32_t thread_index = *((uint32_t *)arg); + uint32_t thread_index = *((uint32_t *)arg); // Break here in order to allow the thread + // to inherit the global watchpoint state. printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); uint32_t count = 0; @@ -73,13 +74,13 @@ uint32_t thread_index_2 = 2; uint32_t thread_index_3 = 3; + printf ("Before turning all three threads loose...\n"); // Set break point at this line, + // in order to set our watchpoint. // Create 3 threads err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); - printf ("Before turning all three threads loose...\n"); // Set break point at this line. - // Join all of our threads err = ::pthread_join (g_thread_1, &thread_result); err = ::pthread_join (g_thread_2, &thread_result); Modified: lldb/trunk/tools/debugserver/source/DNBArch.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.h?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBArch.h (original) +++ lldb/trunk/tools/debugserver/source/DNBArch.h Thu Sep 29 16:48:52 2011 @@ -77,6 +77,7 @@ virtual uint32_t NumSupportedHardwareWatchpoints() { return 0; } virtual uint32_t EnableHardwareBreakpoint (nub_addr_t addr, nub_size_t size) { return INVALID_NUB_HW_INDEX; } virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write) { return INVALID_NUB_HW_INDEX; } + virtual void HardwareWatchpointStateChanged () { ; } virtual bool DisableHardwareBreakpoint (uint32_t hw_index) { return false; } virtual bool DisableHardwareWatchpoint (uint32_t hw_index) { return false; } virtual uint32_t GetHardwareWatchpointHit() { return INVALID_NUB_HW_INDEX; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Thu Sep 29 16:48:52 2011 @@ -687,6 +687,13 @@ return INVALID_NUB_HW_INDEX; } +// Provide a chance to update the global view of the hardware watchpoint state. +void +MachThread::HardwareWatchpointStateChanged () +{ + m_arch_ap->HardwareWatchpointStateChanged(); +} + bool MachThread::DisableHardwareBreakpoint (const DNBBreakpoint *bp) { Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Thu Sep 29 16:48:52 2011 @@ -31,6 +31,7 @@ class DNBBreakpoint; class MachProcess; +class MachThreadList; class MachThread { @@ -131,6 +132,9 @@ std::string m_dispatch_queue_name; #endif +private: + friend class MachThreadList; + void HardwareWatchpointStateChanged(); // Provide a chance to update the global view of the hardware watchpoint state }; typedef std::tr1::shared_ptr MachThreadSP; Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Thu Sep 29 16:48:52 2011 @@ -480,6 +480,9 @@ if ((hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp)) == INVALID_NUB_HW_INDEX) return INVALID_NUB_HW_INDEX; } + // Use an arbitrary thread to signal the completion of our transaction. + if (num_threads) + m_threads[0]->HardwareWatchpointStateChanged(); return hw_index; } return INVALID_NUB_HW_INDEX; @@ -497,6 +500,9 @@ if (!m_threads[idx]->DisableHardwareWatchpoint(wp)) return false; } + // Use an arbitrary thread to signal the completion of our transaction. + if (num_threads) + m_threads[0]->HardwareWatchpointStateChanged(); return true; } return false; Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Thu Sep 29 16:48:52 2011 @@ -555,7 +555,7 @@ // Reset the debug status register, if necessary, before we resume. kern_return_t kret = GetDBGState(false); - DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret); + DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret); if (kret != KERN_SUCCESS) return; @@ -570,7 +570,7 @@ { ClearWatchpointHits(debug_state); kret = SetDBGState(); - DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret); + DNBLogThreadedIf(LOG_WATCHPOINTS,"DNBArchImplI386::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret); } } @@ -894,6 +894,19 @@ return false; } +DNBArchImplI386::DBG DNBArchImplI386::Global_Debug_State = {0,0,0,0,0,0,0,0}; +bool DNBArchImplI386::Valid_Global_Debug_State = false; + +// Use this callback from MachThread, which in turn was called from MachThreadList, to update +// the global view of the hardware watchpoint state, so that when new thread comes along, they +// get to inherit the existing hardware watchpoint state. +void +DNBArchImplI386::HardwareWatchpointStateChanged () +{ + Global_Debug_State = m_state.context.dbg; + Valid_Global_Debug_State = true; +} + // Iterate through the debug status register; return the index of the first hit. uint32_t DNBArchImplI386::GetHardwareWatchpointHit(nub_addr_t &addr) @@ -1109,7 +1122,17 @@ DNBArchProtocol * DNBArchImplI386::Create (MachThread *thread) { - return new DNBArchImplI386 (thread); + DNBArchImplI386 *obj = new DNBArchImplI386 (thread); + + // When new thread comes along, it tries to inherit from the global debug state, if it is valid. + if (Valid_Global_Debug_State) + { + obj->m_state.context.dbg = Global_Debug_State; + kern_return_t kret = obj->SetDBGState(); + DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchImplX86_64::Create() Inherit and SetDBGState() => 0x%8.8x.", kret); + } + return obj; } const uint8_t * const Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Thu Sep 29 16:48:52 2011 @@ -54,6 +54,7 @@ virtual uint32_t NumSupportedHardwareWatchpoints(); virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write); virtual bool DisableHardwareWatchpoint (uint32_t hw_break_index); + virtual void HardwareWatchpointStateChanged (); virtual uint32_t GetHardwareWatchpointHit(nub_addr_t &addr); protected: @@ -116,6 +117,10 @@ DBG dbg; }; + // See also HardwareWatchpointStateChanged() which updates this class-wide variable. + static DBG Global_Debug_State; + static bool Valid_Global_Debug_State; + struct State { Context context; Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Thu Sep 29 16:48:52 2011 @@ -821,6 +821,19 @@ return false; } +DNBArchImplX86_64::DBG DNBArchImplX86_64::Global_Debug_State = {0,0,0,0,0,0,0,0}; +bool DNBArchImplX86_64::Valid_Global_Debug_State = false; + +// Use this callback from MachThread, which in turn was called from MachThreadList, to update +// the global view of the hardware watchpoint state, so that when new thread comes along, they +// get to inherit the existing hardware watchpoint state. +void +DNBArchImplX86_64::HardwareWatchpointStateChanged () +{ + Global_Debug_State = m_state.context.dbg; + Valid_Global_Debug_State = true; +} + // Iterate through the debug status register; return the index of the first hit. uint32_t DNBArchImplX86_64::GetHardwareWatchpointHit(nub_addr_t &addr) @@ -1306,7 +1319,17 @@ DNBArchProtocol * DNBArchImplX86_64::Create (MachThread *thread) { - return new DNBArchImplX86_64 (thread); + DNBArchImplX86_64 *obj = new DNBArchImplX86_64 (thread); + + // When new thread comes along, it tries to inherit from the global debug state, if it is valid. + if (Valid_Global_Debug_State) + { + obj->m_state.context.dbg = Global_Debug_State; + kern_return_t kret = obj->SetDBGState(); + DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchImplX86_64::Create() Inherit and SetDBGState() => 0x%8.8x.", kret); + } + return obj; } const uint8_t * const Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=140811&r1=140810&r2=140811&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Thu Sep 29 16:48:52 2011 @@ -53,6 +53,7 @@ virtual uint32_t NumSupportedHardwareWatchpoints(); virtual uint32_t EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, bool read, bool write); virtual bool DisableHardwareWatchpoint (uint32_t hw_break_index); + virtual void HardwareWatchpointStateChanged (); virtual uint32_t GetHardwareWatchpointHit(nub_addr_t &addr); protected: @@ -115,6 +116,10 @@ DBG dbg; }; + // See also HardwareWatchpointStateChanged() which updates this class-wide variable. + static DBG Global_Debug_State; + static bool Valid_Global_Debug_State; + struct State { Context context; From jingham at apple.com Thu Sep 29 17:12:36 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 29 Sep 2011 22:12:36 -0000 Subject: [Lldb-commits] [lldb] r140813 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: SymbolFileDWARF.cpp SymbolFileDWARF.h Message-ID: <20110929221236.415492A6C12C@llvm.org> Author: jingham Date: Thu Sep 29 17:12:35 2011 New Revision: 140813 URL: http://llvm.org/viewvc/llvm-project?rev=140813&view=rev Log: Centralize the warning reporting and use ReportWarning & ReportError everywhere we were using fprintf(stderr directly. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 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=140813&r1=140812&r2=140813&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 29 17:12:35 2011 @@ -2372,6 +2372,20 @@ va_end (args); } +void +SymbolFileDWARF::ReportWarning (const char *format, ...) +{ + ::fprintf (stderr, + "warning: %s/%s ", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString()); + + va_list args; + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); +} + uint32_t SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { @@ -2414,7 +2428,7 @@ } else { - fprintf (stderr, "error: can't find shared pointer for type 0x%8.8x.\n", matching_type->GetID()); + ReportError ("error: can't find shared pointer for type 0x%8.8x.\n", matching_type->GetID()); } } } @@ -3812,7 +3826,11 @@ DWARFCompileUnitSP spec_cu_sp; const DWARFDebugInfoEntry* spec_die = DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp); if (m_die_to_decl_ctx[spec_die] == NULL) - fprintf (stderr,"warning: 0x%8.8x: DW_AT_specification(0x%8.8x) has no decl\n", die->GetOffset(), specification_die_offset); + { + ReportWarning ("0x%8.8x: DW_AT_specification(0x%8.8x) has no decl\n", + die->GetOffset(), + specification_die_offset); + } type_handled = true; } else if (abstract_origin_die_offset != DW_INVALID_OFFSET) @@ -3820,7 +3838,11 @@ DWARFCompileUnitSP abs_cu_sp; const DWARFDebugInfoEntry* abs_die = DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); if (m_die_to_decl_ctx[abs_die] == NULL) - fprintf (stderr,"warning: 0x%8.8x: DW_AT_abstract_origin(0x%8.8x) has no decl\n", die->GetOffset(), abstract_origin_die_offset); + { + ReportWarning ("0x%8.8x: DW_AT_abstract_origin(0x%8.8x) has no decl\n", + die->GetOffset(), + abstract_origin_die_offset); + } type_handled = true; } else @@ -4508,8 +4530,7 @@ } else { - fprintf (stderr, - "error: parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", + ReportError ("parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", sc_parent_die->GetOffset(), DW_TAG_value_to_name (parent_tag), orig_die->GetOffset(), @@ -4553,8 +4574,7 @@ break; default: - fprintf (stderr, - "error: didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", + ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", orig_die->GetOffset(), DW_TAG_value_to_name (orig_die->Tag())); break; 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=140813&r1=140812&r2=140813&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Sep 29 17:12:35 2011 @@ -365,7 +365,9 @@ } void - ReportError (const char *format, ...); + ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + void + ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3))); SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; From jmolenda at apple.com Thu Sep 29 17:34:41 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 29 Sep 2011 22:34:41 -0000 Subject: [Lldb-commits] [lldb] r140817 - in /lldb/trunk/source/Plugins: Process/Utility/RegisterContextLLDB.cpp UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Message-ID: <20110929223442.49FD62A6C12C@llvm.org> Author: jmolenda Date: Thu Sep 29 17:34:41 2011 New Revision: 140817 URL: http://llvm.org/viewvc/llvm-project?rev=140817&view=rev Log: Fix verbose logging of unwinders. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=140817&r1=140816&r2=140817&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Sep 29 17:34:41 2011 @@ -500,7 +500,7 @@ if (unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose()) + if (log && log->GetVerbose()) { const char *has_fast = ""; if (m_fast_unwind_plan_sp) @@ -603,7 +603,7 @@ unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - if (log && IsLogVerbose()) + if (log && log->GetVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -617,7 +617,7 @@ unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - if (log && IsLogVerbose()) + if (log && log->GetVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -631,7 +631,7 @@ unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - if (log && IsLogVerbose()) + if (log && log->GetVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -641,7 +641,7 @@ } // If nothing else, use the architectural default UnwindPlan and hope that does the job. - if (log && IsLogVerbose()) + if (log && log->GetVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -906,7 +906,7 @@ const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum); if (reg_info && abi->RegisterIsVolatile (reg_info)) { - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { log->Printf("%*sFrame %u did not supply reg location for %d because it is volatile", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -1126,7 +1126,7 @@ return false; const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB]; - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { log->Printf("%*sFrame %u looking for register saved location for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -1136,7 +1136,7 @@ // If this is the 0th frame, hand this over to the live register context if (IsFrameZero ()) { - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { log->Printf("%*sFrame %u passing along to the live register context for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -1161,7 +1161,7 @@ return false; const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB]; - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { log->Printf("%*sFrame %u looking for register saved location for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, @@ -1171,7 +1171,7 @@ // If this is the 0th frame, hand this over to the live register context if (IsFrameZero ()) { - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { log->Printf("%*sFrame %u passing along to the live register context for reg %d", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=140817&r1=140816&r2=140817&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Thu Sep 29 17:34:41 2011 @@ -104,7 +104,7 @@ if (inst) { - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw); @@ -130,7 +130,7 @@ } } - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; lldb::addr_t base_addr = range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget()); @@ -264,7 +264,7 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; strm.Printf ("UnwindAssemblyInstEmulation::ReadMemory (addr = 0x%16.16llx, dst = %p, dst_len = %zu, context = ", @@ -304,7 +304,7 @@ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; @@ -407,7 +407,7 @@ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; @@ -437,7 +437,7 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose ()) + if (log && log->GetVerbose ()) { StreamString strm; From jmolenda at apple.com Thu Sep 29 18:02:42 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 29 Sep 2011 23:02:42 -0000 Subject: [Lldb-commits] [lldb] r140819 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20110929230242.F322E2A6C12C@llvm.org> Author: jmolenda Date: Thu Sep 29 18:02:41 2011 New Revision: 140819 URL: http://llvm.org/viewvc/llvm-project?rev=140819&view=rev Log: Add an additional "frame select" usage where it will re-select the current frame if no frame is specified. This is useful to get the source context lines re-displayed when you need a reminder of where you are in the source currently. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140819&r1=140818&r2=140819&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Sep 29 18:02:41 2011 @@ -248,6 +248,12 @@ const char *frame_idx_cstr = command.GetArgumentAtIndex(0); frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0); } + if (command.GetArgumentCount() == 0) + { + frame_idx = thread->GetSelectedFrameIndex (); + if (frame_idx == UINT32_MAX) + frame_idx = 0; + } else { result.AppendError ("invalid arguments.\n"); From gclayton at apple.com Thu Sep 29 18:41:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 29 Sep 2011 23:41:34 -0000 Subject: [Lldb-commits] [lldb] r140822 - in /lldb/trunk: include/lldb/Symbol/Block.h include/lldb/lldb-private-log.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Block.cpp source/lldb-log.cpp Message-ID: <20110929234134.D30EA2A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 18:41:34 2011 New Revision: 140822 URL: http://llvm.org/viewvc/llvm-project?rev=140822&view=rev Log: Fixed an issue where a lexical block or inlined function might have bad debug information generated for it. Say we have a concrete function "foo" which has inlined function "a" which calls another inlined function "b": foo 1 { 2 { a () 3 { b () 4 { } } } } Sometimes we see the compiler generate an address range in the DWARF for "foo" (block 1 above) as say [0x1000-0x1100). Then the range for "a" is something like [0x1050-0x1060) (note that it is correctly scoped within the "foo" address range). And then we get "b" which is a child of "a", yet the debug info says it has a range of [0x1060-0x1080) (not contained within "a"). We now detect this issue when making our blocks and add an extra range to "a". Also added a new "lldb" logging category named "symbol" where we can find out about symbol file errors and warnings. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/lldb-private-log.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/lldb-log.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=140822&r1=140821&r2=140822&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Thu Sep 29 18:41:34 2011 @@ -97,7 +97,7 @@ /// describes the end address of a range for this block. //------------------------------------------------------------------ void - AddRange(lldb::addr_t start_offset, lldb::addr_t end_offset); + AddRange (const VMRange& range); //------------------------------------------------------------------ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) Modified: lldb/trunk/include/lldb/lldb-private-log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-log.h?rev=140822&r1=140821&r2=140822&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-log.h (original) +++ lldb/trunk/include/lldb/lldb-private-log.h Thu Sep 29 18:41:34 2011 @@ -39,6 +39,7 @@ #define LIBLLDB_LOG_SCRIPT (1u << 17) #define LIBLLDB_LOG_COMMANDS (1U << 18) #define LIBLLDB_LOG_TYPES (1u << 19) +#define LIBLLDB_LOG_SYMBOLS (1u << 20) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ @@ -47,6 +48,7 @@ LIBLLDB_LOG_WATCHPOINTS |\ LIBLLDB_LOG_STEP |\ LIBLLDB_LOG_STATE |\ + LIBLLDB_LOG_SYMBOLS |\ LIBLLDB_LOG_COMMANDS) namespace lldb_private { 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=140822&r1=140821&r2=140822&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 29 18:41:34 2011 @@ -635,7 +635,7 @@ const DWARFDebugRanges::Range *debug_range; for (range_idx = 0; (debug_range = ranges.RangeAtIndex(range_idx)) != NULL; range_idx++) { - block.AddRange(debug_range->begin_offset, debug_range->end_offset); + block.AddRange(VMRange (debug_range->begin_offset, debug_range->end_offset)); } } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=140822&r1=140821&r2=140822&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Thu Sep 29 18:41:34 2011 @@ -8,9 +8,13 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Function.h" + +#include "lldb/lldb-private-log.h" + +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" +#include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/VariableList.h" @@ -433,10 +437,53 @@ } void -Block::AddRange(addr_t start_offset, addr_t end_offset) +Block::AddRange (const VMRange& new_range) { - m_ranges.resize(m_ranges.size()+1); - m_ranges.back().Reset(start_offset, end_offset); + Block *parent_block = GetParent (); + if (parent_block && !parent_block->Contains(new_range)) + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS)); + if (log) + { + Module *module = m_parent_scope->CalculateSymbolContextModule(); + Function *function = m_parent_scope->CalculateSymbolContextFunction(); + const addr_t function_file_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress(); + const addr_t block_start_addr = function_file_addr + new_range.GetBaseAddress (); + const addr_t block_end_addr = function_file_addr + new_range.GetEndAddress (); + Type *func_type = function->GetType(); + + const Declaration &func_decl = func_type->GetDeclaration(); + if (func_decl.GetLine()) + { + log->Printf ("warning: %s/%s:%u block {0x%8.8x} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8x} in function {0x%8.8x} from %s/%s", + func_decl.GetFile().GetDirectory().GetCString(), + func_decl.GetFile().GetFilename().GetCString(), + func_decl.GetLine(), + GetID(), + (uint32_t)m_ranges.size(), + block_start_addr, + block_end_addr, + parent_block->GetID(), + function->GetID(), + module->GetFileSpec().GetDirectory().GetCString(), + module->GetFileSpec().GetFilename().GetCString()); + } + else + { + log->Printf ("warning: block {0x%8.8x} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8x} in function {0x%8.8x} from %s/%s", + GetID(), + (uint32_t)m_ranges.size(), + block_start_addr, + block_end_addr, + parent_block->GetID(), + function->GetID(), + module->GetFileSpec().GetDirectory().GetCString(), + module->GetFileSpec().GetFilename().GetCString()); + } + } + parent_block->AddRange (new_range); + } + m_ranges.push_back(new_range); } // Return the current number of bytes that this object occupies in memory @@ -605,7 +652,7 @@ { if (m_parent_scope) { - Block *parent_block = m_parent_scope->CalculateSymbolContextBlock(); + Block *parent_block = GetParent(); if (parent_block) return parent_block->GetSiblingForChild (this); } Modified: lldb/trunk/source/lldb-log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=140822&r1=140821&r2=140822&view=diff ============================================================================== --- lldb/trunk/source/lldb-log.cpp (original) +++ lldb/trunk/source/lldb-log.cpp Thu Sep 29 18:41:34 2011 @@ -135,6 +135,7 @@ else if (0 == ::strncasecmp(arg, "host", 4)) flag_bits &= ~LIBLLDB_LOG_HOST; else if (0 == ::strncasecmp(arg, "unwind", 6)) flag_bits &= ~LIBLLDB_LOG_UNWIND; else if (0 == ::strncasecmp(arg, "types", 5)) flag_bits &= ~LIBLLDB_LOG_TYPES; + else if (0 == ::strncasecmp(arg, "symbol", 6)) flag_bits &= ~LIBLLDB_LOG_SYMBOLS; else { feedback_strm->Printf ("error: unrecognized log category '%s'\n", arg); @@ -202,6 +203,7 @@ else if (0 == ::strncasecmp(arg, "host", 4)) flag_bits |= LIBLLDB_LOG_HOST; else if (0 == ::strncasecmp(arg, "unwind", 6)) flag_bits |= LIBLLDB_LOG_UNWIND; else if (0 == ::strncasecmp(arg, "types", 5)) flag_bits |= LIBLLDB_LOG_TYPES; + else if (0 == ::strncasecmp(arg, "symbol", 6)) flag_bits |= LIBLLDB_LOG_SYMBOLS; else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); @@ -241,6 +243,7 @@ " step - log step related activities\n" " unwind - log stack unwind activities\n" " verbose - enable verbose logging\n" + " symbol - log symbol related issues and warnings\n" " watch - log watchpoint related activities\n" " types - log type system related activities\n"); } From johnny.chen at apple.com Thu Sep 29 19:42:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 30 Sep 2011 00:42:49 -0000 Subject: [Lldb-commits] [lldb] r140830 - in /lldb/trunk: scripts/Python/interface/SBModule.i scripts/Python/modify-python-lldb.py test/lldbutil.py test/python_api/module_section/TestModuleAndSection.py Message-ID: <20110930004249.B378C2A6C12C@llvm.org> Author: johnny Date: Thu Sep 29 19:42:49 2011 New Revision: 140830 URL: http://llvm.org/viewvc/llvm-project?rev=140830&view=rev Log: Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions from lldbutil.py to the lldb.py proper. The in_range() function becomes a function in the lldb module. And the symbol_iter() function becomes a method within the SBModule called symbol_in_section_iter(). Example: # Iterates the text section and prints each symbols within each sub-section. for subsec in text_sec: print INDENT + repr(subsec) for sym in exe_module.symbol_in_section_iter(subsec): print INDENT2 + repr(sym) print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) might produce this following output: [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) symbol type: code id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) symbol type: code id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) symbol type: code id = {0x00000023}, name = 'start', address = 0x0000000100001780 symbol type: code [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) symbol type: trampoline id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) symbol type: trampoline id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) symbol type: trampoline id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) symbol type: trampoline id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) symbol type: trampoline id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) symbol type: trampoline id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) symbol type: trampoline id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) symbol type: trampoline id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) symbol type: trampoline id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) symbol type: trampoline id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) symbol type: trampoline id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) symbol type: trampoline [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame Modified: lldb/trunk/scripts/Python/interface/SBModule.i lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Modified: lldb/trunk/scripts/Python/interface/SBModule.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=140830&r1=140829&r2=140830&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i (original) +++ lldb/trunk/scripts/Python/interface/SBModule.i Thu Sep 29 19:42:49 2011 @@ -32,7 +32,63 @@ print 'This module is the same as that module' to test module equality. A module also contains object file sections, namely -SBSection. SBModule supports section iteration through section_iter()." +SBSection. SBModule supports section iteration through section_iter(), for +example, + + print 'Number of sections: %d' % module.GetNumSections() + for sec in module.section_iter(): + print sec + +And to iterate the symbols within a SBSection, use symbol_in_section_iter(), + + # Iterates the text section and prints each symbols within each sub-section. + for subsec in text_sec: + print INDENT + repr(subsec) + for sym in exe_module.symbol_in_section_iter(subsec): + print INDENT2 + repr(sym) + print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) + +might produce this following output: + + [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text + id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) + symbol type: code + id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0) + symbol type: code + id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c) + symbol type: code + id = {0x00000023}, name = 'start', address = 0x0000000100001780 + symbol type: code + [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs + id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62) + symbol type: trampoline + id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68) + symbol type: trampoline + id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e) + symbol type: trampoline + id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74) + symbol type: trampoline + id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a) + symbol type: trampoline + id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80) + symbol type: trampoline + id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86) + symbol type: trampoline + id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c) + symbol type: trampoline + id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92) + symbol type: trampoline + id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98) + symbol type: trampoline + id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e) + symbol type: trampoline + id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4) + symbol type: trampoline + [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper + [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring + [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info + [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame +" ) SBModule; class SBModule { Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140830&r1=140829&r2=140830&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Thu Sep 29 19:42:49 2011 @@ -59,8 +59,27 @@ one_liner_docstring_pattern = re.compile('^(%s|%s)""".*"""$' % (TWO_SPACES, EIGHT_SPACES)) # -# lldb_iter() should appear before our first SB* class definition. +# lldb_helpers and lldb_iter() should appear before our first SB* class definition. # +lldb_helpers = ''' +def in_range(symbol, section): + symSA = symbol.GetStartAddress().GetFileAddress() + symEA = symbol.GetEndAddress().GetFileAddress() + secSA = section.GetFileAddress() + secEA = secSA + section.GetByteSize() + + if symEA != LLDB_INVALID_ADDRESS: + if secSA <= symSA and symEA <= secEA: + return True + else: + return False + else: + if secSA <= symSA and symSA < secEA: + return True + else: + return False +''' + lldb_iter_def = ''' # =================================== # Iterator for lldb container objects @@ -166,6 +185,16 @@ # Delegate to self.IsValid() if it is defined for the current lldb object. nonzero_def = " def __nonzero__(self): return self.IsValid()" +# A convenience iterator for SBSymbol! +symbol_in_section_iter_def = ''' + def symbol_in_section_iter(self, section): + """Given a module and its contained section, returns an iterator on the + symbols within the section.""" + for sym in self: + if in_range(sym, section): + yield sym +''' + # # This dictionary defines a mapping from classname to (getsize, getelem) tuple. # @@ -193,7 +222,9 @@ }, # SBModule has an additional section_iter(), see below. - 'SBModule-extra': ('GetNumSections', 'GetSectionAtIndex') + 'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'), + # As well as symbol_in_section_iter(). + 'SBModule-symbol-in-section': symbol_in_section_iter_def } # @@ -305,8 +336,10 @@ if state == NORMAL: match = class_pattern.search(line) - # Inserts the lldb_iter() definition before the first class definition. + # Inserts lldb_helpers and the lldb_iter() definition before the first + # class definition. if not lldb_iter_defined and match: + new_content.add_line(lldb_helpers) new_content.add_line(lldb_iter_def) lldb_iter_defined = True @@ -341,9 +374,11 @@ new_content.add_line(eq_def % (cls, list_to_frag(e[cls]))) new_content.add_line(ne_def) - # SBModule has an extra SBSection iterator! + # SBModule has an extra SBSection iterator and symbol_in_section_iter()! if cls == "SBModule": - new_content.add_line(section_iter % d[cls+'-extra']) + new_content.add_line(section_iter % d[cls+'-section']) + new_content.add_line(d[cls+'-symbol-in-section']) + # This special purpose iterator is for SBValue only!!! if cls == "SBValue": new_content.add_line(linked_list_iter_def) Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=140830&r1=140829&r2=140830&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Sep 29 19:42:49 2011 @@ -44,34 +44,6 @@ print >> buf, i return buf.getvalue() -# ====================================================== -# Utilities for iterating a module's section for symbols -# ====================================================== - -def in_range(symbol, section): - symSA = symbol.GetStartAddress().GetFileAddress() - symEA = symbol.GetEndAddress().GetFileAddress() - secSA = section.GetFileAddress() - secEA = secSA + section.GetByteSize() - - if symEA != lldb.LLDB_INVALID_ADDRESS: - if secSA <= symSA and symEA <= secEA: - return True - else: - return False - else: - if secSA <= symSA and symSA < secEA: - return True - else: - return False - -def symbol_iter(module, section): - """Given a module and its contained section, returns an iterator on the - symbols within the section.""" - for sym in module: - if in_range(sym, section): - yield sym - # ========================================================== # Integer (byte size 1, 2, 4, and 8) to bytearray conversion # ========================================================== Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=140830&r1=140829&r2=140830&view=diff ============================================================================== --- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (original) +++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Thu Sep 29 19:42:49 2011 @@ -45,14 +45,14 @@ print sec print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() if sec.GetNumSubSections() == 0: - for sym in symbol_iter(exe_module, sec): + for sym in exe_module.symbol_in_section_iter(sec): print INDENT + repr(sym) print INDENT + "symbol type: %s" % symbol_type_to_str(sym.GetType()) else: for subsec in sec: print INDENT + repr(subsec) # Now print the symbols belonging to the subsection.... - for sym in symbol_iter(exe_module, subsec): + for sym in exe_module.symbol_in_section_iter(subsec): print INDENT2 + repr(sym) print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType()) From johnny.chen at apple.com Thu Sep 29 19:46:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 30 Sep 2011 00:46:24 -0000 Subject: [Lldb-commits] [lldb] r140832 - /lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Message-ID: <20110930004624.C3AF52A6C12C@llvm.org> Author: johnny Date: Thu Sep 29 19:46:24 2011 New Revision: 140832 URL: http://llvm.org/viewvc/llvm-project?rev=140832&view=rev Log: Fix extraneous import as a result of the last change. Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=140832&r1=140831&r2=140832&view=diff ============================================================================== --- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (original) +++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Thu Sep 29 19:46:24 2011 @@ -7,7 +7,7 @@ import unittest2 import lldb from lldbtest import * -from lldbutil import symbol_iter, symbol_type_to_str +from lldbutil import symbol_type_to_str class ModuleAndSectionAPIsTestCase(TestBase): From johnny.chen at apple.com Thu Sep 29 19:49:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 30 Sep 2011 00:49:02 -0000 Subject: [Lldb-commits] [lldb] r140833 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110930004902.A01DA2A6C12C@llvm.org> Author: johnny Date: Thu Sep 29 19:49:02 2011 New Revision: 140833 URL: http://llvm.org/viewvc/llvm-project?rev=140833&view=rev Log: Add docstring to in_range() function residing in the lldb module. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140833&r1=140832&r2=140833&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Thu Sep 29 19:49:02 2011 @@ -63,6 +63,7 @@ # lldb_helpers = ''' def in_range(symbol, section): + """Test whether a symbol is within the range of a section.""" symSA = symbol.GetStartAddress().GetFileAddress() symEA = symbol.GetEndAddress().GetFileAddress() secSA = section.GetFileAddress() From jingham at apple.com Thu Sep 29 20:05:25 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 30 Sep 2011 01:05:25 -0000 Subject: [Lldb-commits] [lldb] r140835 - /lldb/trunk/source/Interpreter/OptionGroupUUID.cpp Message-ID: <20110930010525.DFDF62A6C12C@llvm.org> Author: jingham Date: Thu Sep 29 20:05:23 2011 New Revision: 140835 URL: http://llvm.org/viewvc/llvm-project?rev=140835&view=rev Log: Remember to mark the OptionValueUUID as set in SetOptionValue. Modified: lldb/trunk/source/Interpreter/OptionGroupUUID.cpp Modified: lldb/trunk/source/Interpreter/OptionGroupUUID.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupUUID.cpp?rev=140835&r1=140834&r2=140835&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupUUID.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupUUID.cpp Thu Sep 29 20:05:23 2011 @@ -57,6 +57,8 @@ { case 'u': error = m_uuid.SetValueFromCString (option_arg); + if (error.Success()) + m_uuid.SetOptionWasSet(); break; default: From johnny.chen at apple.com Thu Sep 29 20:08:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 30 Sep 2011 01:08:48 -0000 Subject: [Lldb-commits] [lldb] r140836 - in /lldb/trunk: include/lldb/Interpreter/OptionGroupWatchpoint.h source/Commands/CommandObjectFrame.cpp source/Interpreter/OptionGroupWatchpoint.cpp test/functionalities/watchpoint/hello_watchlocation/ test/functionalities/watchpoint/hello_watchlocation/Makefile test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py test/functionalities/watchpoint/hello_watchlocation/main.cpp Message-ID: <20110930010849.0548D2A6C12C@llvm.org> Author: johnny Date: Thu Sep 29 20:08:48 2011 New Revision: 140836 URL: http://llvm.org/viewvc/llvm-project?rev=140836&view=rev Log: Add an accompanying option to the 'frame variable -w' command to, instead of watching the variable, watch the location pointed to by the variable. An example, (lldb) frame variable -w write -x 1 -g g_char_ptr (char *) g_char_ptr = 0x0000000100100860 ""... Watchpoint created: WatchpointLocation 1: addr = 0x100100860 size = 1 state = enabled type = w declare @ '/Volumes/data/lldb/svn/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp:21' ... (lldb) c Process 3936 resuming ... rocess 3936 stopped * thread #2: tid = 0x3403, 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27, stop reason = watchpoint 1 frame #0: 0x00000001000009b7 a.out`do_bad_thing_with_location(char*, char) + 23 at main.cpp:27 24 do_bad_thing_with_location(char *char_ptr, char new_val) 25 { 26 *char_ptr = new_val; -> 27 } 28 29 uint32_t access_pool (uint32_t flag = 0); 30 (lldb) Also add TestWatchLocation.py test to exercise this functionality. Added: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/Makefile lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h?rev=140836&r1=140835&r2=140836&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h Thu Sep 29 20:08:48 2011 @@ -55,8 +55,9 @@ eWatchReadWrite } WatchType; - bool watch_variable; WatchType watch_type; + uint32_t watch_size; + bool watch_variable; private: DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint); Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140836&r1=140835&r2=140836&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Sep 29 20:08:48 2011 @@ -436,7 +436,7 @@ } // Things have checked out ok... - // m_option_watchpoint.watch_mode specifies the mode for watching. + // m_option_watchpoint.watch_type specifies the type of watching. } if (command.GetArgumentCount() > 0) { @@ -532,12 +532,20 @@ if (m_option_watchpoint.watch_variable) { AddressType addr_type; - lldb::addr_t addr = valobj_sp->GetAddressOf(false, &addr_type); + lldb::addr_t addr = 0; size_t size = 0; - if (addr_type == eAddressTypeLoad) { - // We're in business. - // Find out the size of this variable. - size = valobj_sp->GetByteSize(); + if (m_option_watchpoint.watch_size == 0) { + addr = valobj_sp->GetAddressOf(false, &addr_type); + if (addr_type == eAddressTypeLoad) { + // We're in business. + // Find out the size of this variable. + size = valobj_sp->GetByteSize(); + } + } else { + // The '-xsize'/'-x' option means to treat the value object as + // a pointer and to watch the pointee with the specified size. + addr = valobj_sp->GetValueAsUnsigned(0); + size = m_option_watchpoint.watch_size; } uint32_t watch_type = m_option_watchpoint.watch_type; WatchpointLocation *wp_loc = exe_ctx.GetTargetRef().CreateWatchpointLocation(addr, size, watch_type).get(); Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=140836&r1=140835&r2=140836&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Thu Sep 29 20:08:48 2011 @@ -28,11 +28,21 @@ { 0, NULL, NULL } }; +static OptionEnumValueElement g_watch_size[] = +{ + { 1, "1", "Watch for byte size of 1"}, + { 2, "2", "Watch for byte size of 2"}, + { 4, "4", "Watch for byte size of 4"}, + { 8, "8", "Watch for byte size of 8"}, + { 0, NULL, NULL } +}; + // if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions() static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a memory location (read, write, or read/write)."} + { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a variable (read, write, or read/write)."}, + { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a location (1, 2, 4, or 8)."} }; @@ -61,6 +71,14 @@ error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg); break; } + case 'x': { + bool success = false; + OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; + watch_size = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid option arg for '-x': '%s'.\n", option_arg); + break; + } default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); break; @@ -74,6 +92,7 @@ { watch_variable = false; watch_type = eWatchInvalid; + watch_size = 0; } Added: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/Makefile?rev=140836&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/Makefile (added) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/Makefile Thu Sep 29 20:08:48 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py?rev=140836&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py (added) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py Thu Sep 29 20:08:48 2011 @@ -0,0 +1,92 @@ +""" +Test lldb watchpoint that uses '-x size' to watch a pointed location with size. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class HelloWatchLocationTestCase(TestBase): + + mydir = os.path.join("functionalities", "watchpoint", "hello_watchlocation") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_hello_watchlocation_with_dsym(self): + """Test watching a location with '-x size' option.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.hello_watchlocation() + + def test_hello_watchlocation_with_dwarf(self): + """Test watching a location with '-x size' option.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.hello_watchlocation() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + # This is for verifying that watch location works. + self.violating_func = "do_bad_thing_with_location"; + # Build dictionary to have unique executable names for each test method. + self.exe_name = self.testMethodName + self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} + + def hello_watchlocation(self): + """Test watching a location with '-x size' option.""" + exe = os.path.join(os.getcwd(), self.exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Add a breakpoint to set a watchpoint when stopped on the breakpoint. + self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.source, self.line)) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped again due to the breakpoint. + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # Now let's set a write-type watchpoint pointed to by 'g_char_ptr'. + # The main.cpp, by design, misbehaves by not following the agreed upon + # protocol of using a mutex while accessing the global pool and by not + # incrmenting the global pool by 2. + self.expect("frame variable -w write -x 1 -g g_char_ptr", WATCHPOINT_CREATED, + substrs = ['Watchpoint created', 'size = 1', 'type = w']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 0 initially. + self.expect("watchpoint list -v", + substrs = ['hit_count = 0']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (write type), but + # only once. The stop reason of the thread should be watchpoint. + self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stopped', + 'stop reason = watchpoint', + self.violating_func]) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should now be 1. + self.expect("watchpoint list -v", + substrs = ['hit_count = 1']) + + self.runCmd("thread backtrace all") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp?rev=140836&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp (added) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp Thu Sep 29 20:08:48 2011 @@ -0,0 +1,98 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C includes +#include +#include +#include +#include +#include + +pthread_t g_thread_1 = NULL; +pthread_t g_thread_2 = NULL; +pthread_t g_thread_3 = NULL; + +char *g_char_ptr = NULL; + +void +do_bad_thing_with_location(char *char_ptr, char new_val) +{ + *char_ptr = new_val; +} + +uint32_t access_pool (uint32_t flag = 0); + +uint32_t +access_pool (uint32_t flag) +{ + static pthread_mutex_t g_access_mutex = PTHREAD_MUTEX_INITIALIZER; + if (flag == 0) + ::pthread_mutex_lock (&g_access_mutex); + + char old_val = *g_char_ptr; + if (flag != 0) + do_bad_thing_with_location(g_char_ptr, old_val + 1); + + if (flag == 0) + ::pthread_mutex_unlock (&g_access_mutex); + return *g_char_ptr; +} + +void * +thread_func (void *arg) +{ + uint32_t thread_index = *((uint32_t *)arg); + printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); + + uint32_t count = 0; + uint32_t val; + while (count++ < 15) + { + // random micro second sleep from zero to 3 seconds + int usec = ::rand() % 3000000; + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); + ::usleep (usec); + + if (count < 7) + val = access_pool (); + else + val = access_pool (1); + + printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count); + } + printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); + return NULL; +} + + +int main (int argc, char const *argv[]) +{ + int err; + void *thread_result = NULL; + uint32_t thread_index_1 = 1; + uint32_t thread_index_2 = 2; + uint32_t thread_index_3 = 3; + + g_char_ptr = (char *)malloc (1); + *g_char_ptr = 0; + + // Create 3 threads + err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); + err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); + err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); + + printf ("Before turning all three threads loose...\n"); // Set break point at this line. + + // Join all of our threads + err = ::pthread_join (g_thread_1, &thread_result); + err = ::pthread_join (g_thread_2, &thread_result); + err = ::pthread_join (g_thread_3, &thread_result); + + return 0; +} From gclayton at apple.com Thu Sep 29 22:20:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 30 Sep 2011 03:20:47 -0000 Subject: [Lldb-commits] [lldb] r140842 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/Function.cpp Message-ID: <20110930032047.E25042A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 22:20:47 2011 New Revision: 140842 URL: http://llvm.org/viewvc/llvm-project?rev=140842&view=rev Log: Don't parse function types all the time, only parse them lazily. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/Function.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=140842&r1=140841&r2=140842&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Thu Sep 29 22:20:47 2011 @@ -73,7 +73,7 @@ //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ - ~Block (); + virtual ~Block (); //------------------------------------------------------------------ /// Add a child to this object. 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=140842&r1=140841&r2=140842&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 29 22:20:47 2011 @@ -659,36 +659,36 @@ if (die->Tag() != DW_TAG_subprogram) return NULL; - clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die); - const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); - - switch (containing_decl_kind) - { - case clang::Decl::Record: - case clang::Decl::CXXRecord: - case clang::Decl::ObjCClass: - case clang::Decl::ObjCImplementation: - case clang::Decl::ObjCInterface: - // We have methods of a class or struct - { - const DWARFDebugInfoEntry *containing_decl_die = m_decl_ctx_to_die[containing_decl_ctx]; - assert (containing_decl_die); - Type *class_type = ResolveType (dwarf_cu, containing_decl_die); - if (class_type) - class_type->GetClangFullType(); - // Make sure the class definition contains the funciton DIE - // we wanted to parse. If it does, we are done. Else, we need - // to fall through and parse the function DIE stil... - if (containing_decl_die->Contains (die)) - break; // DIE has been parsed, we are done - } - // Fall through... - - default: - // Parse the function prototype as a type that can then be added to concrete function instance - ParseTypes (sc, dwarf_cu, die, false, false); - break; - } +// clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die); +// const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); +// +// switch (containing_decl_kind) +// { +// case clang::Decl::Record: +// case clang::Decl::CXXRecord: +// case clang::Decl::ObjCClass: +// case clang::Decl::ObjCImplementation: +// case clang::Decl::ObjCInterface: +// // We have methods of a class or struct +// { +// const DWARFDebugInfoEntry *containing_decl_die = m_decl_ctx_to_die[containing_decl_ctx]; +// assert (containing_decl_die); +// Type *class_type = ResolveType (dwarf_cu, containing_decl_die); +// if (class_type) +// class_type->GetClangFullType(); +// // Make sure the class definition contains the funciton DIE +// // we wanted to parse. If it does, we are done. Else, we need +// // to fall through and parse the function DIE stil... +// if (containing_decl_die->Contains (die)) +// break; // DIE has been parsed, we are done +// } +// // Fall through... +// +// default: +// // Parse the function prototype as a type that can then be added to concrete function instance +// //ParseTypes (sc, dwarf_cu, die, false, false); +// break; +// } //FixupTypes(); @@ -2053,7 +2053,9 @@ uint32_t SymbolFileDWARF::ResolveFunctions (const DIEArray &die_offsets, - SymbolContextList& sc_list) + SymbolContextList& sc_list, + const ConstString &name, + uint32_t name_type_mask) { DWARFDebugInfo* info = DebugInfo(); if (info == NULL) @@ -2071,9 +2073,22 @@ const dw_offset_t die_offset = die_offsets[i]; const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + // If we aren't doing full names, + if ((name_type_mask & eFunctionNameTypeFull) == 0) + { + const char *name_cstr = name.GetCString(); + if (ObjCLanguageRuntime::IsPossibleObjCMethodName(name_cstr)) + continue; + } + + const DWARFDebugInfoEntry* inlined_die = NULL; if (die->Tag() == DW_TAG_inlined_subroutine) { + // We only are looking for selectors, which disallows anything inlined + if (name_type_mask == eFunctionNameTypeSelector) + continue; + inlined_die = die; while ((die = die->GetParent()) != NULL) @@ -2278,13 +2293,10 @@ } uint32_t -SymbolFileDWARF::FindFunctions -( - const ConstString &name, - uint32_t name_type_mask, - bool append, - SymbolContextList& sc_list -) +SymbolFileDWARF::FindFunctions (const ConstString &name, + uint32_t name_type_mask, + bool append, + SymbolContextList& sc_list) { Timer scoped_timer (__PRETTY_FUNCTION__, "SymbolFileDWARF::FindFunctions (name = '%s')", @@ -2321,7 +2333,7 @@ DIEArray die_offsets; const uint32_t num_matches = m_apple_names.Find(name.GetCString(), die_offsets); if (num_matches > 0) - ResolveFunctions (die_offsets, sc_list_apple); + ResolveFunctions (die_offsets, sc_list_apple, name, name_type_mask); if (sc_list != sc_list_apple) assert (!"__apple_names results differ from DWARF index results"); } @@ -2975,104 +2987,120 @@ } clang::DeclContext * -SymbolFileDWARF::GetClangDeclContextContainingDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die) +SymbolFileDWARF::GetClangDeclContextContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) { if (m_clang_tu_decl == NULL) m_clang_tu_decl = GetClangASTContext().getASTContext()->getTranslationUnitDecl(); - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x )\n", die->GetOffset()); - const DWARFDebugInfoEntry * const decl_die = die; - clang::DeclContext *decl_ctx = NULL; - - while (die != NULL) + const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu, die); + + if (decl_ctx_die) { - // If this is the original DIE that we are searching for a declaration - // for, then don't look in the cache as we don't want our own decl - // context to be our decl context... - if (decl_die != die) - { - DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); - if (pos != m_die_to_decl_ctx.end()) - { - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) => 0x%8.8x\n", decl_die->GetOffset(), die->GetOffset()); - return pos->second; - } + DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find (decl_ctx_die); + if (pos != m_die_to_decl_ctx.end()) + return pos->second; - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) checking parent 0x%8.8x\n", decl_die->GetOffset(), die->GetOffset()); + switch (decl_ctx_die->Tag()) + { + case DW_TAG_compile_unit: + return m_clang_tu_decl; - switch (die->Tag()) + case DW_TAG_namespace: { - case DW_TAG_namespace: + const char *namespace_name = decl_ctx_die->GetAttributeValueAsString(this, cu, DW_AT_name, NULL); + if (namespace_name) { - const char *namespace_name = die->GetAttributeValueAsString(this, curr_cu, DW_AT_name, NULL); - if (namespace_name) - { - Declaration decl; // TODO: fill in the decl object - clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (curr_cu, die)); - if (namespace_decl) - { - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) => 0x%8.8x\n", decl_die->GetOffset(), die->GetOffset()); - LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die); - } - return namespace_decl; - } + Declaration decl; // TODO: fill in the decl object + clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextContainingDIE (cu, decl_ctx_die)); + if (namespace_decl) + LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, decl_ctx_die); + return namespace_decl; } - break; + } + break; - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: - { - Type* type = ResolveType (curr_cu, die); - pos = m_die_to_decl_ctx.find(die); - if (pos != m_die_to_decl_ctx.end()) - { - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) => 0x%8.8x\n", decl_die->GetOffset(), die->GetOffset()); - return pos->second; - } - else - { - if (type) - { - decl_ctx = ClangASTContext::GetDeclContextForType (type->GetClangForwardType ()); - LinkDeclContextToDIE (decl_ctx, die); - if (decl_ctx) - return decl_ctx; - } + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + { + Type* type = ResolveType (cu, decl_ctx_die); + if (type) + { + clang::DeclContext *decl_ctx = ClangASTContext::GetDeclContextForType (type->GetClangForwardType ()); + if (decl_ctx) + { + LinkDeclContextToDIE (decl_ctx, decl_ctx_die); + if (decl_ctx) + return decl_ctx; } } - break; - - default: - break; } - } + break; - dw_offset_t die_offset = die->GetAttributeValueAsReference(this, curr_cu, DW_AT_specification, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) - { - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) check DW_AT_specification 0x%8.8x\n", decl_die->GetOffset(), die_offset); - decl_ctx = GetClangDeclContextContainingDIEOffset (die_offset); - if (decl_ctx != m_clang_tu_decl) - return decl_ctx; + default: + break; } + } + return m_clang_tu_decl; +} + - die_offset = die->GetAttributeValueAsReference(this, curr_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET); - if (die_offset != DW_INVALID_OFFSET) +const DWARFDebugInfoEntry * +SymbolFileDWARF::GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) +{ + if (cu && die) + { + const DWARFDebugInfoEntry * const decl_die = die; + + while (die != NULL) { - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) check DW_AT_abstract_origin 0x%8.8x\n", decl_die->GetOffset(), die_offset); - decl_ctx = GetClangDeclContextContainingDIEOffset (die_offset); - if (decl_ctx != m_clang_tu_decl) - return decl_ctx; + // If this is the original DIE that we are searching for a declaration + // for, then don't look in the cache as we don't want our own decl + // context to be our decl context... + if (decl_die != die) + { + switch (die->Tag()) + { + case DW_TAG_compile_unit: + case DW_TAG_namespace: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + return die; + + default: + break; + } + } + + dw_offset_t die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_specification, DW_INVALID_OFFSET); + if (die_offset != DW_INVALID_OFFSET) + { + DWARFCompileUnit *spec_cu = cu; + const DWARFDebugInfoEntry *spec_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &spec_cu); + const DWARFDebugInfoEntry *spec_die_decl_ctx_die = GetDeclContextDIEContainingDIE (spec_cu, spec_die); + if (spec_die_decl_ctx_die) + return spec_die_decl_ctx_die; + } + + die_offset = die->GetAttributeValueAsReference(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET); + if (die_offset != DW_INVALID_OFFSET) + { + DWARFCompileUnit *abs_cu = cu; + const DWARFDebugInfoEntry *abs_die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &abs_cu); + const DWARFDebugInfoEntry *abs_die_decl_ctx_die = GetDeclContextDIEContainingDIE (abs_cu, abs_die); + if (abs_die_decl_ctx_die) + return abs_die_decl_ctx_die; + } + + die = die->GetParent(); } - - die = die->GetParent(); } - // Right now we have only one translation unit per module... - //printf ("SymbolFileDWARF::GetClangDeclContextContainingDIE ( die = 0x%8.8x ) => 0x%8.8x\n", decl_die->GetOffset(), curr_cu->GetFirstDIEOffset()); - return m_clang_tu_decl; + return NULL; } + + // This function can be used when a DIE is found that is a forward declaration // DIE and we want to try and find a type that has the complete definition. TypeSP 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=140842&r1=140841&r2=140842&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Sep 29 22:20:47 2011 @@ -195,7 +195,10 @@ clang::DeclContext * GetClangDeclContextContainingDIEOffset (dw_offset_t die_offset); - + + const DWARFDebugInfoEntry * + GetDeclContextDIEContainingDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); + void SearchDeclContext (const clang::DeclContext *decl_context, const char *name, @@ -309,7 +312,9 @@ uint32_t ResolveFunctions ( const DIEArray &die_offsets, - lldb_private::SymbolContextList& sc_list); + lldb_private::SymbolContextList& sc_list, + const lldb_private::ConstString &name, + uint32_t name_type_mask); void FindFunctions( const lldb_private::ConstString &name, Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=140842&r1=140841&r2=140842&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Thu Sep 29 22:20:47 2011 @@ -449,6 +449,27 @@ Type* Function::GetType() { + if (m_type == NULL) + { + SymbolContext sc; + + CalculateSymbolContext (&sc); + + if (!sc.module_sp) + return NULL; + + SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor(); + + if (sym_vendor == NULL) + return NULL; + + SymbolFile *sym_file = sym_vendor->GetSymbolFile(); + + if (sym_file == NULL) + return NULL; + + return sym_file->ResolveTypeUID(m_type_uid); + } return m_type; } From gclayton at apple.com Thu Sep 29 22:29:05 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 30 Sep 2011 03:29:05 -0000 Subject: [Lldb-commits] [lldb] r140843 - /lldb/trunk/source/API/SBDebugger.cpp Message-ID: <20110930032906.83CCE2A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 22:29:05 2011 New Revision: 140843 URL: http://llvm.org/viewvc/llvm-project?rev=140843&view=rev Log: After deleting a target, clear the target object and remove orphaned modules. Modified: lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=140843&r1=140842&r2=140843&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep 29 22:29:05 2011 @@ -614,6 +614,8 @@ { // No need to lock, the target list is thread safe result = m_opaque_sp->GetTargetList().DeleteTarget (target.m_opaque_sp); + target.Clear(); + ModuleList::RemoveOrphanSharedModules(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); From gclayton at apple.com Thu Sep 29 23:14:54 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 30 Sep 2011 04:14:54 -0000 Subject: [Lldb-commits] [lldb] r140845 - /lldb/trunk/source/API/SBDebugger.cpp Message-ID: <20110930041456.0C09B2A6C12C@llvm.org> Author: gclayton Date: Thu Sep 29 23:14:52 2011 New Revision: 140845 URL: http://llvm.org/viewvc/llvm-project?rev=140845&view=rev Log: Destroy a target when it is deleted. Modified: lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=140845&r1=140844&r2=140845&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep 29 23:14:52 2011 @@ -614,6 +614,7 @@ { // No need to lock, the target list is thread safe result = m_opaque_sp->GetTargetList().DeleteTarget (target.m_opaque_sp); + target->Destroy(); target.Clear(); ModuleList::RemoveOrphanSharedModules(); } From gclayton at apple.com Fri Sep 30 15:52:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 30 Sep 2011 20:52:25 -0000 Subject: [Lldb-commits] [lldb] r140881 - in /lldb/trunk: include/lldb/Symbol/Symbol.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Symbol.cpp Message-ID: <20110930205225.BE1FA2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 15:52:25 2011 New Revision: 140881 URL: http://llvm.org/viewvc/llvm-project?rev=140881&view=rev Log: Removed some commented out code from the DWARF parser. Also reduce the size of the lldb_private::Symbol objects by removing the lldb_private::Function pointer that was in each symbol. Running Instruments has shown that when debugging large applications with DWARF in .o files that lldb_private::Symbol objects are one of the highest users of memory. No one was using the Symbol::GetFunction() call anyway. Modified: lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Symbol.cpp Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=140881&r1=140880&r2=140881&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Fri Sep 30 15:52:25 2011 @@ -114,9 +114,6 @@ void GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const; - Function * - GetFunction (); - Address & GetValue () { return m_addr_range.GetBaseAddress(); } @@ -203,7 +200,6 @@ m_searched_for_function:1;// non-zero if we have looked for the function associated with this symbol already. AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any) uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these - Function * m_function; }; } // namespace lldb_private 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=140881&r1=140880&r2=140881&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Sep 30 15:52:25 2011 @@ -659,39 +659,6 @@ if (die->Tag() != DW_TAG_subprogram) return NULL; -// clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die); -// const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); -// -// switch (containing_decl_kind) -// { -// case clang::Decl::Record: -// case clang::Decl::CXXRecord: -// case clang::Decl::ObjCClass: -// case clang::Decl::ObjCImplementation: -// case clang::Decl::ObjCInterface: -// // We have methods of a class or struct -// { -// const DWARFDebugInfoEntry *containing_decl_die = m_decl_ctx_to_die[containing_decl_ctx]; -// assert (containing_decl_die); -// Type *class_type = ResolveType (dwarf_cu, containing_decl_die); -// if (class_type) -// class_type->GetClangFullType(); -// // Make sure the class definition contains the funciton DIE -// // we wanted to parse. If it does, we are done. Else, we need -// // to fall through and parse the function DIE stil... -// if (containing_decl_die->Contains (die)) -// break; // DIE has been parsed, we are done -// } -// // Fall through... -// -// default: -// // Parse the function prototype as a type that can then be added to concrete function instance -// //ParseTypes (sc, dwarf_cu, die, false, false); -// break; -// } - - //FixupTypes(); - if (die->GetDIENamesAndRanges(this, dwarf_cu, name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column, &frame_base)) { // Union of all ranges in the function DIE (if the function is discontiguous) @@ -720,6 +687,7 @@ decl_line, decl_column)); + // Supply the type _only_ if it has already been parsed Type *func_type = m_die_to_type.lookup (die); assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED); @@ -735,7 +703,8 @@ if (func_sp.get() != NULL) { - func_sp->GetFrameBaseExpression() = frame_base; + if (frame_base.IsValid()) + func_sp->GetFrameBaseExpression() = frame_base; sc.comp_unit->AddFunction(func_sp); return func_sp.get(); } Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=140881&r1=140880&r2=140881&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Fri Sep 30 15:52:25 2011 @@ -33,8 +33,7 @@ m_size_is_synthesized (false), m_searched_for_function (false), m_addr_range (), - m_flags (), - m_function (NULL) + m_flags () { } @@ -66,8 +65,7 @@ m_size_is_synthesized (false), m_searched_for_function (false), m_addr_range (section, offset, size), - m_flags (flags), - m_function (NULL) + m_flags (flags) { } @@ -97,8 +95,7 @@ m_size_is_synthesized (false), m_searched_for_function (false), m_addr_range (range), - m_flags (flags), - m_function (NULL) + m_flags (flags) { } @@ -116,8 +113,7 @@ m_size_is_synthesized (false), m_searched_for_function (false), m_addr_range (rhs.m_addr_range), - m_flags (rhs.m_flags), - m_function (NULL) + m_flags (rhs.m_flags) { } @@ -140,7 +136,6 @@ m_searched_for_function = rhs.m_searched_for_function; m_addr_range = rhs.m_addr_range; m_flags = rhs.m_flags; - m_function = rhs.m_function; } return *this; } @@ -252,23 +247,6 @@ } } -Function * -Symbol::GetFunction () -{ - if (m_function == NULL && !m_searched_for_function) - { - m_searched_for_function = true; - Module *module = m_addr_range.GetBaseAddress().GetModule(); - if (module) - { - SymbolContext sc; - if (module->ResolveSymbolContextForAddress(m_addr_range.GetBaseAddress(), eSymbolContextFunction, sc)) - m_function = sc.function; - } - } - return m_function; -} - uint32_t Symbol::GetPrologueByteSize () { From johnny.chen at apple.com Fri Sep 30 16:48:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 30 Sep 2011 21:48:36 -0000 Subject: [Lldb-commits] [lldb] r140890 - in /lldb/trunk/test: functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py functionalities/watchpoint/hello_watchlocation/main.cpp lldbtest.py Message-ID: <20110930214837.94ADF2A6C12C@llvm.org> Author: johnny Date: Fri Sep 30 16:48:35 2011 New Revision: 140890 URL: http://llvm.org/viewvc/llvm-project?rev=140890&view=rev Log: o lldbtest.py: Add a keyword argument 'endstr' to TestBase.expect() method to assert that the output will end with 'endstr'. Add TestBase.switch_to_thread_with_stop_reason(stop_reason) to select the thread with the stop reason = 'stop_reason' as the current thread. o TestWatchLocation.py: Modified to switch to the stopped thread with stop reason = watchpoint and to evaluate an expression with expected output for stronger assertion. Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py?rev=140890&r1=140889&r2=140890&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py (original) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py Fri Sep 30 16:48:35 2011 @@ -62,6 +62,9 @@ # incrmenting the global pool by 2. self.expect("frame variable -w write -x 1 -g g_char_ptr", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 1', 'type = w']) + self.runCmd("expr unsigned val = *g_char_ptr; val") + self.expect(self.res.GetOutput().splitlines()[0], exe=False, + endstr = ' = 0') # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. @@ -77,6 +80,13 @@ 'stop reason = watchpoint', self.violating_func]) + # Switch to the thread stopped due to watchpoint and issue some commands. + self.switch_to_thread_with_stop_reason(lldb.eStopReasonWatchpoint) + self.runCmd("thread backtrace") + self.runCmd("expr unsigned val = *g_char_ptr; val") + self.expect(self.res.GetOutput().splitlines()[0], exe=False, + endstr = ' = 1') + # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp?rev=140890&r1=140889&r2=140890&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp (original) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchlocation/main.cpp Fri Sep 30 16:48:35 2011 @@ -23,6 +23,8 @@ void do_bad_thing_with_location(char *char_ptr, char new_val) { + unsigned what = new_val; + printf("new value written to location(%p) = %u\n", char_ptr, what); *char_ptr = new_val; } Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=140890&r1=140889&r2=140890&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Sep 30 16:48:35 2011 @@ -962,6 +962,21 @@ del self.dbg + def switch_to_thread_with_stop_reason(self, stop_reason): + """ + Run the 'thread list' command, and select the thread with stop reason as + 'stop_reason'. If no such thread exists, no select action is done. + """ + from lldbutil import stop_reason_to_str + self.runCmd('thread list') + output = self.res.GetOutput() + thread_line_pattern = re.compile("^[ *] thread #([0-9]+):.*stop reason = %s" % + stop_reason_to_str(stop_reason)) + for line in output.splitlines(): + matched = thread_line_pattern.match(line) + if matched: + self.runCmd('thread select %s' % matched.group(1)) + def runCmd(self, cmd, msg=None, check=True, trace=False): """ Ask the command interpreter to handle the command and then check its @@ -1000,7 +1015,7 @@ self.assertTrue(self.res.Succeeded(), msg if msg else CMD_MSG(cmd)) - def expect(self, str, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True, exe=True): + def expect(self, str, msg=None, patterns=None, startstr=None, endstr=None, substrs=None, trace=False, error=False, matching=True, exe=True): """ Similar to runCmd; with additional expect style output matching ability. @@ -1056,6 +1071,14 @@ print >> sbuf, "%s start string: %s" % (heading, startstr) print >> sbuf, "Matched" if matched else "Not matched" + # Look for endstr, if specified. + keepgoing = matched if matching else not matched + if endstr: + matched = output.endswith(endstr) + with recording(self, trace) as sbuf: + print >> sbuf, "%s end string: %s" % (heading, endstr) + print >> sbuf, "Matched" if matched else "Not matched" + # Look for sub strings, if specified. keepgoing = matched if matching else not matched if substrs and keepgoing: @@ -1110,14 +1133,15 @@ err = sys.stderr err.write(val.GetName() + ":\n") - err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n') - err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n') - err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n') - err.write('\t' + "Value -> " + str(val.GetValue()) + '\n') - err.write('\t' + "ValueType -> " + value_type_to_str(val.GetValueType()) + '\n') - err.write('\t' + "Summary -> " + str(val.GetSummary()) + '\n') - err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n') - err.write('\t' + "Location -> " + val.GetLocation() + '\n') + err.write('\t' + "TypeName -> " + val.GetTypeName() + '\n') + err.write('\t' + "ByteSize -> " + str(val.GetByteSize()) + '\n') + err.write('\t' + "NumChildren -> " + str(val.GetNumChildren()) + '\n') + err.write('\t' + "Value -> " + str(val.GetValue()) + '\n') + err.write('\t' + "ValueAsUnsigned -> " + str(val.GetValueAsUnsigned())+ '\n') + err.write('\t' + "ValueType -> " + value_type_to_str(val.GetValueType()) + '\n') + err.write('\t' + "Summary -> " + str(val.GetSummary()) + '\n') + err.write('\t' + "IsPointerType -> " + str(val.TypeIsPointerType()) + '\n') + err.write('\t' + "Location -> " + val.GetLocation() + '\n') def DebugSBType(self, type): """Debug print a SBType object, if traceAlways is True.""" From gclayton at apple.com Fri Sep 30 17:08:48 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 30 Sep 2011 22:08:48 -0000 Subject: [Lldb-commits] [lldb] r140893 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110930220848.E5CDD2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 17:08:47 2011 New Revision: 140893 URL: http://llvm.org/viewvc/llvm-project?rev=140893&view=rev Log: Remove the "-feliminate-unused-debug-types" OTHER_CFLAGS. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140893&r1=140892&r2=140893&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 30 17:08:47 2011 @@ -3594,7 +3594,6 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-flimit-debug-info", - "-feliminate-unused-debug-types", "-Wparentheses", ); VALID_ARCHS = "x86_64 i386"; @@ -3629,7 +3628,6 @@ LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; OTHER_CFLAGS = ( "-flimit-debug-info", - "-feliminate-unused-debug-types", "-Wparentheses", ); VALID_ARCHS = "x86_64 i386"; @@ -3921,7 +3919,6 @@ LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; OTHER_CFLAGS = ( "-flimit-debug-info", - "-feliminate-unused-debug-types", "-Wparentheses", ); VALID_ARCHS = "x86_64 i386"; From jmolenda at apple.com Fri Sep 30 18:12:15 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 30 Sep 2011 23:12:15 -0000 Subject: [Lldb-commits] [lldb] r140901 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20110930231215.5342A2A6C12C@llvm.org> Author: jmolenda Date: Fri Sep 30 18:12:14 2011 New Revision: 140901 URL: http://llvm.org/viewvc/llvm-project?rev=140901&view=rev Log: Small fix to "frame select" sans frame # feature added yesterday. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140901&r1=140900&r2=140901&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 30 18:12:14 2011 @@ -248,11 +248,13 @@ const char *frame_idx_cstr = command.GetArgumentAtIndex(0); frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0); } - if (command.GetArgumentCount() == 0) + else if (command.GetArgumentCount() == 0) { frame_idx = thread->GetSelectedFrameIndex (); if (frame_idx == UINT32_MAX) + { frame_idx = 0; + } } else { From gclayton at apple.com Fri Sep 30 19:45:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 00:45:15 -0000 Subject: [Lldb-commits] [lldb] r140910 - in /lldb/trunk: examples/python/ include/lldb/API/ include/lldb/Core/ include/lldb/Symbol/ scripts/Python/interface/ source/API/ source/Commands/ source/Core/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/ Message-ID: <20111001004515.BF92B2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 19:45:15 2011 New Revision: 140910 URL: http://llvm.org/viewvc/llvm-project?rev=140910&view=rev Log: Cleaned up the the code that figures out the inlined stack frames given a symbol context that represents an inlined function. This function has been renamed internally to: bool SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &next_frame_pc) const; And externally to: SBSymbolContext SBSymbolContext::GetParentOfInlinedScope (const SBAddress &curr_frame_pc, SBAddress &parent_frame_addr) const; The correct blocks are now correctly calculated. Switched the stack backtracing engine (in StackFrameList) and the address context printing over to using the internal SymbolContext::GetParentOfInlinedScope(...) so all inlined callstacks will match exactly. Modified: lldb/trunk/examples/python/symbolicate-crash.py lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/Core/Broadcaster.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/scripts/Python/interface/SBSymbolContext.i lldb/trunk/source/API/SBSymbolContext.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/Broadcaster.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Listener.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrameList.cpp Modified: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (original) +++ lldb/trunk/examples/python/symbolicate-crash.py Fri Sep 30 19:45:15 2011 @@ -399,7 +399,7 @@ # inlined, it will return a valid symbol context for the parent # frame of the current inlined function parent_pc_addr = lldb.SBAddress() - new_frame.sym_ctx = frame.sym_ctx.GetParentInlinedFrameInfo (pc_addr, True, parent_pc_addr) + new_frame.sym_ctx = frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr) # See if we were able to reconstruct anything? while new_frame.sym_ctx: @@ -419,7 +419,7 @@ new_frame = CrashLog.Frame (frame.index, -1, None) # Swap the addresses so we can try another inlined lookup pc_addr = parent_pc_addr; - new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentInlinedFrameInfo (pc_addr, False, parent_pc_addr) + new_frame.sym_ctx = prev_new_frame.sym_ctx.GetParentOfInlinedScope (pc_addr, parent_pc_addr) # Replace our thread frames with our new list that includes parent # frames for inlined functions thread.frames = new_thread_frames Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Fri Sep 30 19:45:15 2011 @@ -52,9 +52,8 @@ void SetSymbol (lldb::SBSymbol symbol); SBSymbolContext - GetParentInlinedFrameInfo (const SBAddress &curr_frame_pc, - bool is_concrete_frame, - SBAddress &parent_frame_addr) const; + GetParentOfInlinedScope (const SBAddress &curr_frame_pc, + SBAddress &parent_frame_addr) const; bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/include/lldb/Core/Broadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Broadcaster.h?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Broadcaster.h (original) +++ lldb/trunk/include/lldb/Core/Broadcaster.h Fri Sep 30 19:45:15 2011 @@ -104,6 +104,9 @@ void BroadcastEventIfUnique (uint32_t event_type, EventData *event_data = NULL); + void + Clear(); + virtual void AddInitialEventsToListener (Listener *listener, uint32_t requested_events); Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Fri Sep 30 19:45:15 2011 @@ -181,13 +181,6 @@ void Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const; - void - DumpStopContext (Stream *s, - const SymbolContext *sc, - const Declaration *child_inline_call_site, - bool show_fullpaths, - bool show_inline_blocks); - //------------------------------------------------------------------ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Fri Sep 30 19:45:15 2011 @@ -284,11 +284,30 @@ ConstString GetFunctionName (Mangled::NamePreference preference = Mangled::ePreferDemangled); + //------------------------------------------------------------------ + /// Find the block containing the inlined block that contains this block. + /// + /// For instance, if the symbol context contains an inlined block, + /// it will return the inlined function name. + /// + /// @param[in] curr_frame_pc + /// The address within the block of this object. + /// + /// @param[out] next_frame_sc + /// A new symbol context that does what the title says it does. + /// + /// @param[out] next_frame_addr + /// This is what you should report as the PC in \a next_frame_sc. + /// + /// @return + /// \b true if this SymbolContext specifies a block contained in an + /// inlined block. If this returns \b true, \a next_frame_sc and + /// \a next_frame_addr will be filled in correctly. + //------------------------------------------------------------------ bool - GetParentInlinedFrameInfo (const Address &curr_frame_pc, - bool is_concrete_frame, - SymbolContext &next_frame_sc, - Address &inlined_frame_addr) const; + GetParentOfInlinedScope (const Address &curr_frame_pc, + SymbolContext &next_frame_sc, + Address &inlined_frame_addr) const; //------------------------------------------------------------------ // Member variables Modified: lldb/trunk/scripts/Python/interface/SBSymbolContext.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbolContext.i?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSymbolContext.i (original) +++ lldb/trunk/scripts/Python/interface/SBSymbolContext.i Fri Sep 30 19:45:15 2011 @@ -73,9 +73,8 @@ void SetSymbol (lldb::SBSymbol symbol); lldb::SBSymbolContext - GetParentInlinedFrameInfo (const lldb::SBAddress &curr_frame_pc, - bool is_concrete_frame, - lldb::SBAddress &parent_frame_addr) const; + GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc, + lldb::SBAddress &parent_frame_addr) const; bool Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Fri Sep 30 19:45:15 2011 @@ -266,14 +266,13 @@ } SBSymbolContext -SBSymbolContext::GetParentInlinedFrameInfo (const SBAddress &curr_frame_pc, - bool is_concrete_frame, - SBAddress &parent_frame_addr) const +SBSymbolContext::GetParentOfInlinedScope (const SBAddress &curr_frame_pc, + SBAddress &parent_frame_addr) const { SBSymbolContext sb_sc; if (m_opaque_ap.get() && curr_frame_pc.IsValid()) { - if (m_opaque_ap->GetParentInlinedFrameInfo (curr_frame_pc.ref(), is_concrete_frame, sb_sc.ref(), parent_frame_addr.ref())) + if (m_opaque_ap->GetParentOfInlinedScope (curr_frame_pc.ref(), sb_sc.ref(), parent_frame_addr.ref())) return sb_sc; } return SBSymbolContext(); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Sep 30 19:45:15 2011 @@ -1304,12 +1304,13 @@ strm.EOL(); strm.Indent (" Summary: "); const uint32_t save_indent = strm.GetIndentLevel (); - strm.SetIndentLevel (save_indent + 11); + strm.SetIndentLevel (save_indent + 13); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); strm.SetIndentLevel (save_indent); // Print out detailed address information when verbose is enabled if (verbose) { + strm.EOL(); so_addr.Dump (&strm, exe_scope, Address::DumpStyleDetailedSymbolContext); } strm.IndentLess(); Modified: lldb/trunk/source/Core/Broadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Broadcaster.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Core/Broadcaster.cpp (original) +++ lldb/trunk/source/Core/Broadcaster.cpp Fri Sep 30 19:45:15 2011 @@ -40,22 +40,24 @@ if (log) log->Printf ("%p Broadcaster::~Broadcaster(\"%s\")", this, m_broadcaster_name.AsCString()); - // Scope for "listeners_locker" - { - Mutex::Locker listeners_locker(m_listeners_mutex); - - // Make sure the listener forgets about this broadcaster. We do - // this in the broadcaster in case the broadcaster object initiates - // the removal. - - collection::iterator pos, end = m_listeners.end(); - for (pos = m_listeners.begin(); pos != end; ++pos) - pos->first->BroadcasterWillDestruct (this); - - m_listeners.clear(); - } + Clear(); } +void +Broadcaster::Clear() +{ + Mutex::Locker listeners_locker(m_listeners_mutex); + + // Make sure the listener forgets about this broadcaster. We do + // this in the broadcaster in case the broadcaster object initiates + // the removal. + + collection::iterator pos, end = m_listeners.end(); + for (pos = m_listeners.begin(); pos != end; ++pos) + pos->first->BroadcasterWillDestruct (this); + + m_listeners.clear(); +} const ConstString & Broadcaster::GetBroadcasterName () { Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Sep 30 19:45:15 2011 @@ -249,6 +249,7 @@ Debugger::Clear() { CleanUpInputReaders(); + m_listener.Clear(); int num_targets = m_target_list.GetNumTargets(); for (int i = 0; i < num_targets; i++) { Modified: lldb/trunk/source/Core/Listener.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Listener.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Core/Listener.cpp (original) +++ lldb/trunk/source/Core/Listener.cpp Fri Sep 30 19:45:15 2011 @@ -55,6 +55,8 @@ m_broadcasters.clear(); m_cond_wait.SetValue (false, eBroadcastNever); m_broadcasters.clear(); + Mutex::Locker event_locker(m_events_mutex); + m_events.clear(); } uint32_t Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Sep 30 19:45:15 2011 @@ -152,6 +152,11 @@ } // m_mach_process.UnregisterNotificationCallbacks (this); Clear(); + // We need to call finalize on the process before destroying ourselves + // to make sure all of the broadcaster cleanup goes as planned. If we + // destruct this class, then Process::~Process() might have problems + // trying to fully destroy the broadcaster. + Finalize(); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Fri Sep 30 19:45:15 2011 @@ -186,95 +186,6 @@ } void -Block::DumpStopContext -( - Stream *s, - const SymbolContext *sc_ptr, - const Declaration *child_inline_call_site, - bool show_fullpaths, - bool show_inline_blocks) -{ - const InlineFunctionInfo* inline_info = NULL; - Block* inlined_block; - if (sc_ptr) - inlined_block = GetContainingInlinedBlock (); - else - inlined_block = GetInlinedParent(); - - if (inlined_block) - inline_info = inlined_block->GetInlinedFunctionInfo(); - const Declaration *inline_call_site = child_inline_call_site; - if (inline_info) - { - inline_call_site = &inline_info->GetCallSite(); - if (sc_ptr) - { - // First frame in a frame with inlined functions - s->PutCString (" [inlined]"); - } - if (show_inline_blocks && child_inline_call_site) - s->EOL(); - else - s->PutChar(' '); - - if (sc_ptr == NULL) - s->Indent(); - - s->PutCString(inline_info->GetName ().AsCString()); - - if (child_inline_call_site && child_inline_call_site->IsValid()) - { - s->PutCString(" at "); - child_inline_call_site->DumpStopContext (s, show_fullpaths); - } - } - - // The first call to this function from something that has a symbol - // context will pass in a valid sc_ptr. Subsequent calls to this function - // from this function for inline purposes will NULL out sc_ptr. So on the - // first time through we dump the line table entry (which is always at the - // deepest inline code block). And subsequent calls to this function we - // will use hte inline call site information to print line numbers. - if (sc_ptr) - { - // If we have any inlined functions, this will be the deepest most - // inlined location - if (sc_ptr->line_entry.IsValid()) - { - s->PutCString(" at "); - sc_ptr->line_entry.DumpStopContext (s, show_fullpaths); - } - } - - if (show_inline_blocks) - { - if (inlined_block) - { - inlined_block->Block::DumpStopContext (s, - NULL, - inline_call_site, - show_fullpaths, - show_inline_blocks); - } - else if (child_inline_call_site) - { - Function *function = CalculateSymbolContextFunction(); - if (function) - { - s->EOL(); - s->Indent (function->GetMangled().GetName().AsCString()); - if (child_inline_call_site && child_inline_call_site->IsValid()) - { - s->PutCString(" at "); - child_inline_call_site->DumpStopContext (s, show_fullpaths); - } - } - } - } -} - - -void Block::DumpSymbolContext(Stream *s) { Function *function = CalculateSymbolContextFunction(); Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Sep 30 19:45:15 2011 @@ -138,12 +138,14 @@ if (function != NULL) { + SymbolContext inline_parent_sc; + Address inline_parent_addr; if (function->GetMangled().GetName()) { dumped_something = true; function->GetMangled().GetName().Dump(s); } - + if (addr.IsValid()) { const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); @@ -154,12 +156,34 @@ } } - if (block != NULL) + if (GetParentOfInlinedScope (addr, inline_parent_sc, inline_parent_addr)) { - s->IndentMore(); - block->DumpStopContext (s, this, NULL, show_fullpaths, show_inlined_frames); - s->IndentLess(); dumped_something = true; + Block *inlined_block = block->GetContainingInlinedBlock(); + const InlineFunctionInfo* inlined_block_info = inlined_block->GetInlinedFunctionInfo(); + s->Printf (" [inlined] %s", inlined_block_info->GetName().GetCString()); + + lldb_private::AddressRange block_range; + if (inlined_block->GetRangeContainingAddress(addr, block_range)) + { + const addr_t inlined_function_offset = addr.GetOffset() - block_range.GetBaseAddress().GetOffset(); + if (inlined_function_offset) + { + s->Printf(" + %llu", inlined_function_offset); + } + } + const Declaration &call_site = inlined_block_info->GetCallSite(); + if (call_site.IsValid()) + { + s->PutCString(" at "); + call_site.DumpStopContext (s, show_fullpaths); + } + if (show_inlined_frames) + { + s->EOL(); + s->Indent(); + return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames); + } } else { @@ -488,87 +512,46 @@ } bool -SymbolContext::GetParentInlinedFrameInfo (const Address &curr_frame_pc, - bool is_concrete_frame, - SymbolContext &next_frame_sc, - Address &inlined_frame_addr) const +SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc, + SymbolContext &next_frame_sc, + Address &next_frame_pc) const { next_frame_sc.Clear(); - inlined_frame_addr.Clear(); + next_frame_pc.Clear(); if (block) { - bool concrete_has_inlines = false; - Block *curr_inlined_block = NULL; - Block *next_inlined_block = NULL; //const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress(); - if (is_concrete_frame) - { - curr_inlined_block = block->GetContainingInlinedBlock(); - if (curr_inlined_block) - { - concrete_has_inlines = true; - next_inlined_block = curr_inlined_block->GetInlinedParent(); - } - } - else - { - curr_inlined_block = block; - next_inlined_block = block->GetInlinedParent(); - } - - if (next_inlined_block) - { - next_inlined_block->CalculateSymbolContext (&next_frame_sc); - + + // In order to get the parent of an inlined function we first need to + // see if we are in an inlined block as "this->block" could be an + // inlined block, or a parent of "block" could be. So lets check if + // this block or one of this blocks parents is an inlined function. + Block *curr_inlined_block = block->GetContainingInlinedBlock(); + if (curr_inlined_block) + { + // "this->block" is contained in an inline function block, so to + // get the scope above the inlined block, we get the parent of the + // inlined block itself + Block *next_frame_block = curr_inlined_block->GetParent(); + // Now calculate the symbol context of the containing block + next_frame_block->CalculateSymbolContext (&next_frame_sc); + + // If we get here we weren't able to find the return line entry using the nesting of the blocks and + // the line table. So just use the call site info from our inlined block. + AddressRange range; bool got_range = curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range); assert (got_range); - const InlineFunctionInfo* inline_info = next_inlined_block->GetInlinedFunctionInfo(); - if (inline_info) - { - inlined_frame_addr = range.GetBaseAddress(); - next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr; - next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile(); - next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine(); - next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn(); - return true; - } - } - else if (is_concrete_frame && !concrete_has_inlines) - { - // This is the symbol context for the frame that was found using the - // PC value and there are no inlined blocks so there are no inlined - // parent frames. - return false; - } - else - { - // We have had inlined frames before and now we are at the function - // instance that called the inlined frames. - // The SymbolContext object should contain a previous inline symbol - // context which we need to use to get the file, line and column info - const InlineFunctionInfo* inline_info = curr_inlined_block->GetInlinedFunctionInfo(); - if (inline_info) - { - Block *parent_block = curr_inlined_block->GetParent(); - if (parent_block) - { - parent_block->CalculateSymbolContext (&next_frame_sc); - - AddressRange range; - if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range)) - { - inlined_frame_addr = range.GetBaseAddress(); - //const addr_t range_file_file_addr = inlined_frame_addr.GetFileAddress(); - next_frame_sc.line_entry.range.GetBaseAddress() = inlined_frame_addr; - next_frame_sc.line_entry.file = inline_info->GetCallSite().GetFile(); - next_frame_sc.line_entry.line = inline_info->GetCallSite().GetLine(); - next_frame_sc.line_entry.column = inline_info->GetCallSite().GetColumn(); - return true; - } - } - } + // To see there this new frame block it, we need to look at the + // call site information from + const InlineFunctionInfo* curr_inlined_block_inlined_info = curr_inlined_block->GetInlinedFunctionInfo(); + next_frame_pc = range.GetBaseAddress(); + next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc; + next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile(); + next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine(); + next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn(); + return true; } } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Sep 30 19:45:15 2011 @@ -644,6 +644,9 @@ void Process::Finalize() { + // Clear our broadcaster before we proceed with destroying + Broadcaster::Clear(); + // Do any cleanup needed prior to being destructed... Subclasses // that override this method should call this superclass method as well. Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=140910&r1=140909&r2=140910&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Fri Sep 30 19:45:15 2011 @@ -112,64 +112,28 @@ m_frames.push_back (unwind_frame_sp); } - Block *unwind_block = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock).block; - + SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction); + Block *unwind_block = unwind_sc.block; if (unwind_block) { - Block *inlined_block = unwind_block->GetContainingInlinedBlock(); - if (inlined_block) + Address curr_frame_address = unwind_frame_sp->GetFrameCodeAddress(); + SymbolContext next_frame_sc; + Address next_frame_address; + + while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address)) { - for (; inlined_block != NULL; inlined_block = inlined_block->GetInlinedParent ()) - { - SymbolContext inline_sc; - Block *parent_block = inlined_block->GetInlinedParent(); - - const bool is_inlined_frame = parent_block != NULL; - - if (parent_block == NULL) - parent_block = inlined_block->GetParent(); - - parent_block->CalculateSymbolContext (&inline_sc); - - Address previous_frame_lookup_addr (m_frames.back()->GetFrameCodeAddress()); - if (unwind_frame_sp->GetFrameIndex() > 0 && m_frames.back().get() == unwind_frame_sp.get()) - previous_frame_lookup_addr.Slide (-1); - - AddressRange range; - inlined_block->GetRangeContainingAddress (previous_frame_lookup_addr, range); - - const InlineFunctionInfo* inline_info = inlined_block->GetInlinedFunctionInfo(); - assert (inline_info); - inline_sc.line_entry.range.GetBaseAddress() = m_frames.back()->GetFrameCodeAddress(); - inline_sc.line_entry.file = inline_info->GetCallSite().GetFile(); - inline_sc.line_entry.line = inline_info->GetCallSite().GetLine(); - inline_sc.line_entry.column = inline_info->GetCallSite().GetColumn(); - StackFrameSP frame_sp(new StackFrame (m_frames.size(), idx, m_thread, unwind_frame_sp->GetRegisterContextSP (), cfa, - range.GetBaseAddress(), - &inline_sc)); // The symbol context for this inline frame - - if (is_inlined_frame) - { - // Use the block with the inlined function info - // as the symbol context since we want this frame - // to have only the variables for the inlined function - frame_sp->SetSymbolContextScope (parent_block); - } - else - { - // This block is not inlined with means it has no - // inlined parents either, so we want to use the top - // most function block. - frame_sp->SetSymbolContextScope (&unwind_frame_sp->GetSymbolContext (eSymbolContextFunction).function->GetBlock(false)); - } - + next_frame_address, + &next_frame_sc)); + m_frames.push_back (frame_sp); - } + unwind_sc = next_frame_sc; + curr_frame_address = next_frame_address; + } } } From johnny.chen at apple.com Fri Sep 30 20:19:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 01 Oct 2011 01:19:46 -0000 Subject: [Lldb-commits] [lldb] r140914 - in /lldb/trunk: include/lldb/API/SBFrame.h scripts/Python/interface/SBFrame.i scripts/Python/interface/SBModule.i scripts/Python/interface/SBType.i source/API/SBFrame.cpp test/python_api/watchpoint/TestSetWatchpoint.py test/python_api/watchpoint/watchlocation/ test/python_api/watchpoint/watchlocation/Makefile test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py test/python_api/watchpoint/watchlocation/main.cpp Message-ID: <20111001011946.D126D2A6C12C@llvm.org> Author: johnny Date: Fri Sep 30 20:19:45 2011 New Revision: 140914 URL: http://llvm.org/viewvc/llvm-project?rev=140914&view=rev Log: Add SBFrame.WatchLocation() to find and watch the location pointed to by a variable usng the frame as the scope. Add TestSetWatchpoint.py to exercise this API. Also fix some SWIG Python docstrings. Added: lldb/trunk/test/python_api/watchpoint/watchlocation/ lldb/trunk/test/python_api/watchpoint/watchlocation/Makefile lldb/trunk/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py lldb/trunk/test/python_api/watchpoint/watchlocation/main.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/scripts/Python/interface/SBFrame.i lldb/trunk/scripts/Python/interface/SBModule.i lldb/trunk/scripts/Python/interface/SBType.i lldb/trunk/source/API/SBFrame.cpp lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Fri Sep 30 20:19:45 2011 @@ -183,6 +183,14 @@ lldb::SBValue WatchValue (const char *name, ValueType value_type, uint32_t watch_type); + /// Find and watch the location pointed to by a variable using the frame as + /// the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + lldb::SBValue + WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/scripts/Python/interface/SBFrame.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBFrame.i (original) +++ lldb/trunk/scripts/Python/interface/SBFrame.i Fri Sep 30 20:19:45 2011 @@ -220,10 +220,20 @@ /// It returns an SBValue, similar to FindValue() method, if find-and-watch /// operation succeeds. Otherwise, an invalid SBValue is returned. /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. - ") FindValue; + ") WatchValue; lldb::SBValue WatchValue (const char *name, ValueType value_type, uint32_t watch_type); + %feature("docstring", " + /// Find and watch the location pointed to by a variable using the frame as + /// the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + ") WatchLocation; + lldb::SBValue + WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/scripts/Python/interface/SBModule.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i (original) +++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Sep 30 20:19:45 2011 @@ -48,7 +48,7 @@ print INDENT2 + repr(sym) print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()) -might produce this following output: +produces this following output: [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870) Modified: lldb/trunk/scripts/Python/interface/SBType.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBType.i (original) +++ lldb/trunk/scripts/Python/interface/SBType.i Fri Sep 30 20:19:45 2011 @@ -77,7 +77,7 @@ ++total; t = t->next; } - printf('We have a total number of %d tasks\n', total); + printf('We have a total number of %d tasks\\n', total); // This corresponds to an empty task list. Task *empty_task_head = new Task(-1, NULL); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Fri Sep 30 20:19:45 2011 @@ -460,6 +460,65 @@ return wp_loc_sp ? sb_value : sb_value_empty; } +/// Find and watch the location pointed to by a variable using the frame as +/// the scope. +/// It returns an SBValue, similar to FindValue() method, if find-and-watch +/// operation succeeds. Otherwise, an invalid SBValue is returned. +/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. +SBValue +SBFrame::WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size) +{ + SBValue sb_value_empty; + + if (!IsValid()) + return sb_value_empty; + + // Acquire the API locker, to be released at the end of the method call. + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); + + switch (value_type) { + case eValueTypeVariableGlobal: // global variable + case eValueTypeVariableStatic: // static variable + case eValueTypeVariableArgument: // function argument variables + case eValueTypeVariableLocal: // function local variables + break; + default: + return sb_value_empty; // these are not eligible for watching + } + + SBValue sb_pointer = FindValue(name, value_type); + // If the sb_pointer is not valid, there's no point in even trying to watch it. + if (!sb_pointer.IsValid() || !sb_pointer.GetType().IsPointerType()) + return sb_value_empty; + + addr_t addr = sb_pointer.GetValueAsUnsigned(0); + if (!addr) + return sb_value_empty; + + SBValue sb_value = sb_pointer.CreateValueFromAddress("pointee", addr, sb_pointer.GetType().GetPointeeType()); + WatchpointLocationSP wp_loc_sp = m_opaque_sp->GetThread().GetProcess().GetTarget(). + CreateWatchpointLocation(addr, size, watch_type); + + if (wp_loc_sp) { + // StackFrame::GetInScopeVariableList(true) to get file globals as well. + VariableListSP var_list_sp(m_opaque_sp->GetInScopeVariableList(true)); + VariableSP var_sp = var_list_sp->FindVariable(ConstString(name)); + if (var_sp && var_sp->GetDeclaration().GetFile()) { + StreamString ss; + // True to show fullpath for declaration file. + var_sp->GetDeclaration().DumpStopContext(&ss, true); + wp_loc_sp->SetDeclInfo(ss.GetString()); + } + } + + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBFrame(%p)::WatchLocation (name=\"%s\", value_type=%i, watch_type=%i, size=%lu) => SBValue(%p) & wp_loc(%p)", + m_opaque_sp.get(), name, value_type, watch_type, size, sb_value.get(), wp_loc_sp.get()); + + return wp_loc_sp ? sb_value : sb_value_empty; +} + SBValue SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { Modified: lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py?rev=140914&r1=140913&r2=140914&view=diff ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py (original) +++ lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py Fri Sep 30 20:19:45 2011 @@ -1,5 +1,5 @@ """ -Use lldb Python SBFrame API to create a watchpoint for read_write of 'globl' var +Use lldb Python SBFrame API to create a watchpoint for read_write of 'globl' var. """ import os, time Added: lldb/trunk/test/python_api/watchpoint/watchlocation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/watchlocation/Makefile?rev=140914&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/watchlocation/Makefile (added) +++ lldb/trunk/test/python_api/watchpoint/watchlocation/Makefile Fri Sep 30 20:19:45 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py?rev=140914&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py (added) +++ lldb/trunk/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py Fri Sep 30 20:19:45 2011 @@ -0,0 +1,89 @@ +""" +Use lldb Python SBFrame.WatchLocation() API to create a watchpoint for write of '*g_char_ptr'. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class SetWatchlocationAPITestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint", "watchlocation") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + # This is for verifying that watch location works. + self.violating_func = "do_bad_thing_with_location"; + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_watch_val_with_dsym(self): + """Exercise SBFrame.WatchLocation() API to set a watchpoint.""" + self.buildDsym() + self.do_set_watchlocation() + + @python_api_test + def test_watch_val_with_dwarf(self): + """Exercise SBFrame.WatchLocation() API to set a watchpoint.""" + self.buildDwarf() + self.do_set_watchlocation() + + def do_set_watchlocation(self): + """Use SBFrame.WatchLocation() to set a watchpoint and verify that the program stops later due to the watchpoint.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c. + breakpoint = target.BreakpointCreateByLocation(self.source, self.line) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # We should be stopped due to the breakpoint. Get frame #0. + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + value = frame0.WatchLocation('g_char_ptr', + lldb.eValueTypeVariableGlobal, + lldb.LLDB_WATCH_TYPE_WRITE, + 1) + self.assertTrue(value, "Successfully found the location and set a watchpoint") + self.DebugSBValue(value) + + # Continue. Expect the program to stop due to the variable being written to. + process.Continue() + + if (self.TraceOn()): + lldbutil.print_stacktraces(process) + + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint) + self.assertTrue(thread, "The thread stopped due to watchpoint") + self.DebugSBValue(value) + + self.expect(lldbutil.print_stacktrace(thread, string_buffer=True), exe=False, + substrs = [self.violating_func]) + + # This finishes our test. + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/watchpoint/watchlocation/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/watchlocation/main.cpp?rev=140914&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/watchlocation/main.cpp (added) +++ lldb/trunk/test/python_api/watchpoint/watchlocation/main.cpp Fri Sep 30 20:19:45 2011 @@ -0,0 +1,98 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C includes +#include +#include +#include +#include +#include + +pthread_t g_thread_1 = NULL; +pthread_t g_thread_2 = NULL; +pthread_t g_thread_3 = NULL; + +char *g_char_ptr = NULL; + +void +do_bad_thing_with_location(char *char_ptr, char new_val) +{ + *char_ptr = new_val; +} + +uint32_t access_pool (uint32_t flag = 0); + +uint32_t +access_pool (uint32_t flag) +{ + static pthread_mutex_t g_access_mutex = PTHREAD_MUTEX_INITIALIZER; + if (flag == 0) + ::pthread_mutex_lock (&g_access_mutex); + + char old_val = *g_char_ptr; + if (flag != 0) + do_bad_thing_with_location(g_char_ptr, old_val + 1); + + if (flag == 0) + ::pthread_mutex_unlock (&g_access_mutex); + return *g_char_ptr; +} + +void * +thread_func (void *arg) +{ + uint32_t thread_index = *((uint32_t *)arg); + printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); + + uint32_t count = 0; + uint32_t val; + while (count++ < 15) + { + // random micro second sleep from zero to 3 seconds + int usec = ::rand() % 3000000; + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); + ::usleep (usec); + + if (count < 7) + val = access_pool (); + else + val = access_pool (1); + + printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count); + } + printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); + return NULL; +} + + +int main (int argc, char const *argv[]) +{ + int err; + void *thread_result = NULL; + uint32_t thread_index_1 = 1; + uint32_t thread_index_2 = 2; + uint32_t thread_index_3 = 3; + + g_char_ptr = (char *)malloc (1); + *g_char_ptr = 0; + + // Create 3 threads + err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); + err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); + err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); + + printf ("Before turning all three threads loose...\n"); // Set break point at this line. + + // Join all of our threads + err = ::pthread_join (g_thread_1, &thread_result); + err = ::pthread_join (g_thread_2, &thread_result); + err = ::pthread_join (g_thread_3, &thread_result); + + return 0; +} From jmolenda at apple.com Fri Sep 30 20:28:37 2011 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 01 Oct 2011 01:28:37 -0000 Subject: [Lldb-commits] [lldb] r140917 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Message-ID: <20111001012841.7DB392A6C12C@llvm.org> Author: jmolenda Date: Fri Sep 30 20:28:37 2011 New Revision: 140917 URL: http://llvm.org/viewvc/llvm-project?rev=140917&view=rev Log: Fix segfault in UniqueDWARFASTTypeList::Find if we are comparing an anonymous struct type (which lacks any name). Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp?rev=140917&r1=140916&r2=140917&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Fri Sep 30 20:28:37 2011 @@ -59,9 +59,16 @@ case DW_TAG_namespace: { const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu); - const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu); - if (strcmp (parent_arg_die_name, parent_pos_die_name)) + if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct + { match = false; + } + else + { + const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu); + if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name)) + match = false; + } } break; From gclayton at apple.com Fri Sep 30 20:37:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 01:37:21 -0000 Subject: [Lldb-commits] [lldb] r140918 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111001013721.35E112A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 20:37:20 2011 New Revision: 140918 URL: http://llvm.org/viewvc/llvm-project?rev=140918&view=rev Log: Print object names in case we have a .o file in a static archive when logging DWARF errors and warnings. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 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=140918&r1=140917&r2=140918&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Sep 30 20:37:20 2011 @@ -2347,6 +2347,9 @@ m_obj_file->GetFileSpec().GetDirectory().GetCString(), m_obj_file->GetFileSpec().GetFilename().GetCString()); + if (m_obj_file->GetModule()->GetObjectName()) + ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString()); + va_list args; va_start (args, format); vfprintf (stderr, format, args); @@ -2361,6 +2364,9 @@ m_obj_file->GetFileSpec().GetDirectory().GetCString(), m_obj_file->GetFileSpec().GetFilename().GetCString()); + if (m_obj_file->GetModule()->GetObjectName()) + ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString()); + va_list args; va_start (args, format); vfprintf (stderr, format, args); From gclayton at apple.com Fri Sep 30 20:53:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 01:53:21 -0000 Subject: [Lldb-commits] [lldb] r140921 - /lldb/trunk/source/Core/ValueObjectVariable.cpp Message-ID: <20111001015321.1F4382A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 20:53:20 2011 New Revision: 140921 URL: http://llvm.org/viewvc/llvm-project?rev=140921&view=rev Log: Fixed an issue where a variable whose value is in a register might end up not saying that its children are load addresses. Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=140921&r1=140920&r2=140921&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Fri Sep 30 20:53:20 2011 @@ -156,11 +156,8 @@ SetAddressTypeOfChildren(eAddressTypeHost); break; case Value::eValueTypeLoadAddress: - SetAddressTypeOfChildren(eAddressTypeLoad); - break; case Value::eValueTypeScalar: - // TODO: is this the right thing to do? - SetAddressTypeOfChildren(eAddressTypeInvalid); + SetAddressTypeOfChildren(eAddressTypeLoad); break; } From gclayton at apple.com Fri Sep 30 21:01:37 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 02:01:37 -0000 Subject: [Lldb-commits] [lldb] r140922 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111001020137.58D062A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 21:01:36 2011 New Revision: 140922 URL: http://llvm.org/viewvc/llvm-project?rev=140922&view=rev Log: Bumped Xcode project version for lldb-80 and debugserver-145. 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=140922&r1=140921&r2=140922&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 30 21:01:36 2011 @@ -3678,10 +3678,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 80; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3729,11 +3729,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 80; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3779,8 +3779,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; - DYLIB_CURRENT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; + DYLIB_CURRENT_VERSION = 80; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3817,9 +3817,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 80; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3856,9 +3856,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 80; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3929,7 +3929,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3959,11 +3959,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 80; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4087,7 +4087,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4118,7 +4118,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 80; 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=140922&r1=140921&r2=140922&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Sep 30 21:01:36 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - ${CURRENT_PROJECT_VERSION} + 80 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=140922&r1=140921&r2=140922&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Sep 30 21:01:36 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -496,7 +496,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -517,7 +517,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -535,7 +535,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -575,7 +575,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -615,7 +615,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Fri Sep 30 21:02:20 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 02:02:20 -0000 Subject: [Lldb-commits] [lldb] r140923 - /lldb/tags/lldb-80/ Message-ID: <20111001020220.EBD542A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 21:02:20 2011 New Revision: 140923 URL: http://llvm.org/viewvc/llvm-project?rev=140923&view=rev Log: lldb-80 Added: lldb/tags/lldb-80/ - copied from r140922, lldb/trunk/ From gclayton at apple.com Fri Sep 30 21:51:51 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 02:51:51 -0000 Subject: [Lldb-commits] [lldb] r140929 - in /lldb/tags/lldb-80: include/lldb/API/SBDebugger.h include/lldb/API/SBFileSpec.h include/lldb/API/SBSourceManager.h include/lldb/API/SBStream.h include/lldb/API/SBTarget.h include/lldb/lldb-forward.h source/API/SBDebugger.cpp source/API/SBSourceManager.cpp source/API/SBTarget.cpp Message-ID: <20111001025151.D621E2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 21:51:51 2011 New Revision: 140929 URL: http://llvm.org/viewvc/llvm-project?rev=140929&view=rev Log: Removed lldb::SBSourceManager_impl. We export everything in the lldb namespace and this implemenation that backs our lldb::SBSourceManager should not be exported. Modified: lldb/tags/lldb-80/include/lldb/API/SBDebugger.h lldb/tags/lldb-80/include/lldb/API/SBFileSpec.h lldb/tags/lldb-80/include/lldb/API/SBSourceManager.h lldb/tags/lldb-80/include/lldb/API/SBStream.h lldb/tags/lldb-80/include/lldb/API/SBTarget.h lldb/tags/lldb-80/include/lldb/lldb-forward.h lldb/tags/lldb-80/source/API/SBDebugger.cpp lldb/tags/lldb-80/source/API/SBSourceManager.cpp lldb/tags/lldb-80/source/API/SBTarget.cpp Modified: lldb/tags/lldb-80/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/API/SBDebugger.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/API/SBDebugger.h (original) +++ lldb/tags/lldb-80/include/lldb/API/SBDebugger.h Fri Sep 30 21:51:51 2011 @@ -246,8 +246,8 @@ friend class SBInputReader; friend class SBProcess; + friend class SBSourceManager; friend class SBTarget; - friend class SBSourceManager_impl; lldb::SBTarget FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP); @@ -261,6 +261,8 @@ lldb_private::Debugger & ref () const; + const lldb::DebuggerSP & + get_sp () const; #endif lldb::DebuggerSP m_opaque_sp; Modified: lldb/tags/lldb-80/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/API/SBFileSpec.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/API/SBFileSpec.h (original) +++ lldb/tags/lldb-80/include/lldb/API/SBFileSpec.h Fri Sep 30 21:51:51 2011 @@ -64,7 +64,7 @@ friend class SBLineEntry; friend class SBModule; friend class SBProcess; - friend class SBSourceManager_impl; + friend class SBSourceManager; friend class SBThread; friend class SBTarget; Modified: lldb/tags/lldb-80/include/lldb/API/SBSourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/API/SBSourceManager.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/API/SBSourceManager.h (original) +++ lldb/tags/lldb-80/include/lldb/API/SBSourceManager.h Fri Sep 30 21:51:51 2011 @@ -16,8 +16,6 @@ namespace lldb { -class SBSourceManager_impl; - class SBSourceManager { public: @@ -49,7 +47,7 @@ private: - std::auto_ptr m_opaque_ap; + std::auto_ptr m_opaque_ap; }; } // namespace lldb Modified: lldb/tags/lldb-80/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/API/SBStream.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/API/SBStream.h (original) +++ lldb/tags/lldb-80/include/lldb/API/SBStream.h Fri Sep 30 21:51:51 2011 @@ -61,6 +61,7 @@ friend class SBBlock; friend class SBBreakpoint; friend class SBBreakpointLocation; + friend class SBCommandReturnObject; friend class SBCompileUnit; friend class SBData; friend class SBEvent; @@ -70,14 +71,13 @@ friend class SBInstructionList; friend class SBModule; friend class SBSection; - friend class SBSourceManager_impl; + friend class SBSourceManager; friend class SBSymbol; friend class SBSymbolContext; friend class SBTarget; friend class SBThread; friend class SBValue; friend class SBWatchpointLocation; - friend class SBCommandReturnObject; #ifndef SWIG Modified: lldb/tags/lldb-80/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/API/SBTarget.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/API/SBTarget.h (original) +++ lldb/tags/lldb-80/include/lldb/API/SBTarget.h Fri Sep 30 21:51:51 2011 @@ -502,11 +502,11 @@ friend class SBDebugger; friend class SBFunction; friend class SBInstruction; + friend class SBModule; friend class SBProcess; + friend class SBSourceManager; friend class SBSymbol; - friend class SBModule; friend class SBValue; - friend class SBSourceManager_impl; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to @@ -524,6 +524,9 @@ lldb_private::Target * get() const; + const lldb::TargetSP & + get_sp () const; + private: //------------------------------------------------------------------ // For Target only Modified: lldb/tags/lldb-80/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/include/lldb/lldb-forward.h?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/include/lldb/lldb-forward.h (original) +++ lldb/tags/lldb-80/include/lldb/lldb-forward.h Fri Sep 30 21:51:51 2011 @@ -131,6 +131,7 @@ class SectionImpl; class SectionList; class SourceManager; +class SourceManagerImpl; class StackFrame; class StackFrameList; class StackID; Modified: lldb/tags/lldb-80/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/source/API/SBDebugger.cpp?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/source/API/SBDebugger.cpp (original) +++ lldb/tags/lldb-80/source/API/SBDebugger.cpp Fri Sep 30 21:51:51 2011 @@ -825,6 +825,11 @@ return *m_opaque_sp; } +const lldb::DebuggerSP & +SBDebugger::get_sp () const +{ + return m_opaque_sp; +} SBDebugger SBDebugger::FindDebuggerWithID (int id) Modified: lldb/tags/lldb-80/source/API/SBSourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/source/API/SBSourceManager.cpp?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/source/API/SBSourceManager.cpp (original) +++ lldb/tags/lldb-80/source/API/SBSourceManager.cpp Fri Sep 30 21:51:51 2011 @@ -20,76 +20,76 @@ #include "lldb/Target/Target.h" -using namespace lldb; -using namespace lldb_private; - -class lldb::SBSourceManager_impl +namespace lldb_private { -public: - SBSourceManager_impl (const SBDebugger &debugger) - { - m_debugger_sp = debugger.m_opaque_sp; - } - - SBSourceManager_impl (const SBTarget &target) + class SourceManagerImpl { - m_target_sp = target.m_opaque_sp; - } - - SBSourceManager_impl (const SBSourceManager_impl &rhs) - { - if (&rhs == this) - return; - m_debugger_sp = rhs.m_debugger_sp; - m_target_sp = rhs.m_target_sp; - } - - size_t - DisplaySourceLinesWithLineNumbers - ( - const SBFileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - SBStream &s - ) - { - if (!file.IsValid()) - return 0; + public: + SourceManagerImpl (const lldb::DebuggerSP &debugger_sp) + { + m_debugger_sp = debugger_sp; + } + + SourceManagerImpl (const lldb::TargetSP &target_sp) + { + m_target_sp = target_sp; + } + + SourceManagerImpl (const SourceManagerImpl &rhs) + { + if (&rhs == this) + return; + m_debugger_sp = rhs.m_debugger_sp; + m_target_sp = rhs.m_target_sp; + } + + size_t + DisplaySourceLinesWithLineNumbers (const lldb_private::FileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + lldb_private::Stream *s) + { + if (file) + return 0; - if (m_debugger_sp) - return m_debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - s.m_opaque_ap.get()); - else if (m_target_sp) - return m_target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - s.m_opaque_ap.get()); - else - return 0; - } - -private: - lldb::DebuggerSP m_debugger_sp; - lldb::TargetSP m_target_sp; - -}; + if (m_debugger_sp) + return m_debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file, + line, + context_before, + context_after, + current_line_cstr, + s); + else if (m_target_sp) + return m_target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file, + line, + context_before, + context_after, + current_line_cstr, + s); + else + return 0; + } + + private: + lldb::DebuggerSP m_debugger_sp; + lldb::TargetSP m_target_sp; + + }; +} + +using namespace lldb; +using namespace lldb_private; SBSourceManager::SBSourceManager (const SBDebugger &debugger) { - m_opaque_ap.reset(new SBSourceManager_impl (debugger)); + m_opaque_ap.reset(new SourceManagerImpl (debugger.get_sp())); } SBSourceManager::SBSourceManager (const SBTarget &target) { - m_opaque_ap.reset(new SBSourceManager_impl (target)); + m_opaque_ap.reset(new SourceManagerImpl (target.get_sp())); } SBSourceManager::SBSourceManager (const SBSourceManager &rhs) @@ -97,13 +97,13 @@ if (&rhs == this) return; - m_opaque_ap.reset(new SBSourceManager_impl (*(rhs.m_opaque_ap.get()))); + m_opaque_ap.reset(new SourceManagerImpl (*(rhs.m_opaque_ap.get()))); } const lldb::SBSourceManager & SBSourceManager::operator = (const lldb::SBSourceManager &rhs) { - m_opaque_ap.reset (new SBSourceManager_impl (*(rhs.m_opaque_ap.get()))); + m_opaque_ap.reset (new SourceManagerImpl (*(rhs.m_opaque_ap.get()))); return *this; } @@ -125,10 +125,10 @@ if (m_opaque_ap.get() == NULL) return 0; - return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file, + return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file.ref(), line, context_before, context_after, current_line_cstr, - s); + s.get()); } Modified: lldb/tags/lldb-80/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/source/API/SBTarget.cpp?rev=140929&r1=140928&r2=140929&view=diff ============================================================================== --- lldb/tags/lldb-80/source/API/SBTarget.cpp (original) +++ lldb/tags/lldb-80/source/API/SBTarget.cpp Fri Sep 30 21:51:51 2011 @@ -499,6 +499,12 @@ return m_opaque_sp.get(); } +const lldb::TargetSP & +SBTarget::get_sp () const +{ + return m_opaque_sp; +} + void SBTarget::reset (const lldb::TargetSP& target_sp) { From gclayton at apple.com Fri Sep 30 21:59:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 01 Oct 2011 02:59:24 -0000 Subject: [Lldb-commits] [lldb] r140930 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/API/SBFileSpec.h include/lldb/API/SBSourceManager.h include/lldb/API/SBStream.h include/lldb/API/SBTarget.h include/lldb/lldb-forward.h source/API/SBDebugger.cpp source/API/SBSourceManager.cpp source/API/SBTarget.cpp Message-ID: <20111001025925.4D9772A6C12C@llvm.org> Author: gclayton Date: Fri Sep 30 21:59:24 2011 New Revision: 140930 URL: http://llvm.org/viewvc/llvm-project?rev=140930&view=rev Log: Removed lldb::SBSourceManager_impl. We export everything in the lldb namespace and this implemenation that backs our lldb::SBSourceManager should not be exported. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBSourceManager.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBSourceManager.cpp lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Sep 30 21:59:24 2011 @@ -246,8 +246,8 @@ friend class SBInputReader; friend class SBProcess; + friend class SBSourceManager; friend class SBTarget; - friend class SBSourceManager_impl; lldb::SBTarget FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP); @@ -261,6 +261,8 @@ lldb_private::Debugger & ref () const; + const lldb::DebuggerSP & + get_sp () const; #endif lldb::DebuggerSP m_opaque_sp; Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Fri Sep 30 21:59:24 2011 @@ -64,7 +64,7 @@ friend class SBLineEntry; friend class SBModule; friend class SBProcess; - friend class SBSourceManager_impl; + friend class SBSourceManager; friend class SBThread; friend class SBTarget; Modified: lldb/trunk/include/lldb/API/SBSourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSourceManager.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSourceManager.h (original) +++ lldb/trunk/include/lldb/API/SBSourceManager.h Fri Sep 30 21:59:24 2011 @@ -16,8 +16,6 @@ namespace lldb { -class SBSourceManager_impl; - class SBSourceManager { public: @@ -49,7 +47,7 @@ private: - std::auto_ptr m_opaque_ap; + std::auto_ptr m_opaque_ap; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Fri Sep 30 21:59:24 2011 @@ -61,6 +61,7 @@ friend class SBBlock; friend class SBBreakpoint; friend class SBBreakpointLocation; + friend class SBCommandReturnObject; friend class SBCompileUnit; friend class SBData; friend class SBEvent; @@ -70,14 +71,13 @@ friend class SBInstructionList; friend class SBModule; friend class SBSection; - friend class SBSourceManager_impl; + friend class SBSourceManager; friend class SBSymbol; friend class SBSymbolContext; friend class SBTarget; friend class SBThread; friend class SBValue; friend class SBWatchpointLocation; - friend class SBCommandReturnObject; #ifndef SWIG Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Fri Sep 30 21:59:24 2011 @@ -502,11 +502,11 @@ friend class SBDebugger; friend class SBFunction; friend class SBInstruction; + friend class SBModule; friend class SBProcess; + friend class SBSourceManager; friend class SBSymbol; - friend class SBModule; friend class SBValue; - friend class SBSourceManager_impl; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to @@ -524,6 +524,9 @@ lldb_private::Target * get() const; + const lldb::TargetSP & + get_sp () const; + private: //------------------------------------------------------------------ // For Target only Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Fri Sep 30 21:59:24 2011 @@ -131,6 +131,7 @@ class SectionImpl; class SectionList; class SourceManager; +class SourceManagerImpl; class StackFrame; class StackFrameList; class StackID; Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Sep 30 21:59:24 2011 @@ -825,6 +825,11 @@ return *m_opaque_sp; } +const lldb::DebuggerSP & +SBDebugger::get_sp () const +{ + return m_opaque_sp; +} SBDebugger SBDebugger::FindDebuggerWithID (int id) Modified: lldb/trunk/source/API/SBSourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSourceManager.cpp?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/source/API/SBSourceManager.cpp (original) +++ lldb/trunk/source/API/SBSourceManager.cpp Fri Sep 30 21:59:24 2011 @@ -20,76 +20,76 @@ #include "lldb/Target/Target.h" -using namespace lldb; -using namespace lldb_private; - -class lldb::SBSourceManager_impl +namespace lldb_private { -public: - SBSourceManager_impl (const SBDebugger &debugger) - { - m_debugger_sp = debugger.m_opaque_sp; - } - - SBSourceManager_impl (const SBTarget &target) + class SourceManagerImpl { - m_target_sp = target.m_opaque_sp; - } - - SBSourceManager_impl (const SBSourceManager_impl &rhs) - { - if (&rhs == this) - return; - m_debugger_sp = rhs.m_debugger_sp; - m_target_sp = rhs.m_target_sp; - } - - size_t - DisplaySourceLinesWithLineNumbers - ( - const SBFileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - SBStream &s - ) - { - if (!file.IsValid()) - return 0; + public: + SourceManagerImpl (const lldb::DebuggerSP &debugger_sp) + { + m_debugger_sp = debugger_sp; + } + + SourceManagerImpl (const lldb::TargetSP &target_sp) + { + m_target_sp = target_sp; + } + + SourceManagerImpl (const SourceManagerImpl &rhs) + { + if (&rhs == this) + return; + m_debugger_sp = rhs.m_debugger_sp; + m_target_sp = rhs.m_target_sp; + } + + size_t + DisplaySourceLinesWithLineNumbers (const lldb_private::FileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + lldb_private::Stream *s) + { + if (file) + return 0; - if (m_debugger_sp) - return m_debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - s.m_opaque_ap.get()); - else if (m_target_sp) - return m_target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - s.m_opaque_ap.get()); - else - return 0; - } - -private: - lldb::DebuggerSP m_debugger_sp; - lldb::TargetSP m_target_sp; - -}; + if (m_debugger_sp) + return m_debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file, + line, + context_before, + context_after, + current_line_cstr, + s); + else if (m_target_sp) + return m_target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file, + line, + context_before, + context_after, + current_line_cstr, + s); + else + return 0; + } + + private: + lldb::DebuggerSP m_debugger_sp; + lldb::TargetSP m_target_sp; + + }; +} + +using namespace lldb; +using namespace lldb_private; SBSourceManager::SBSourceManager (const SBDebugger &debugger) { - m_opaque_ap.reset(new SBSourceManager_impl (debugger)); + m_opaque_ap.reset(new SourceManagerImpl (debugger.get_sp())); } SBSourceManager::SBSourceManager (const SBTarget &target) { - m_opaque_ap.reset(new SBSourceManager_impl (target)); + m_opaque_ap.reset(new SourceManagerImpl (target.get_sp())); } SBSourceManager::SBSourceManager (const SBSourceManager &rhs) @@ -97,13 +97,13 @@ if (&rhs == this) return; - m_opaque_ap.reset(new SBSourceManager_impl (*(rhs.m_opaque_ap.get()))); + m_opaque_ap.reset(new SourceManagerImpl (*(rhs.m_opaque_ap.get()))); } const lldb::SBSourceManager & SBSourceManager::operator = (const lldb::SBSourceManager &rhs) { - m_opaque_ap.reset (new SBSourceManager_impl (*(rhs.m_opaque_ap.get()))); + m_opaque_ap.reset (new SourceManagerImpl (*(rhs.m_opaque_ap.get()))); return *this; } @@ -125,10 +125,10 @@ if (m_opaque_ap.get() == NULL) return 0; - return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file, + return m_opaque_ap->DisplaySourceLinesWithLineNumbers (file.ref(), line, context_before, context_after, current_line_cstr, - s); + s.get()); } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140930&r1=140929&r2=140930&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Sep 30 21:59:24 2011 @@ -499,6 +499,12 @@ return m_opaque_sp.get(); } +const lldb::TargetSP & +SBTarget::get_sp () const +{ + return m_opaque_sp; +} + void SBTarget::reset (const lldb::TargetSP& target_sp) {