From gclayton at apple.com Mon Sep 6 18:01:25 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Sep 2010 23:01:25 -0000 Subject: [Lldb-commits] [lldb] r113179 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20100906230125.834CE2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 6 18:01:25 2010 New Revision: 113179 URL: http://llvm.org/viewvc/llvm-project?rev=113179&view=rev Log: Fixed an error where a random string would get executed after a recent fix that checked if the window column size was zero was added on the lldb driver startup. Modified: lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113179&r1=113178&r2=113179&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon Sep 6 18:01:25 2010 @@ -1088,8 +1088,10 @@ char buffer[25]; if (window_size.ws_col > 0) + { sprintf (buffer, "settings set term-width %d", window_size.ws_col); - m_debugger.HandleCommand ((const char *) buffer); + m_debugger.HandleCommand ((const char *) buffer); + } } // Since input can be redirected by the debugger, we must insert our editline From gclayton at apple.com Mon Sep 6 18:04:12 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Sep 2010 23:04:12 -0000 Subject: [Lldb-commits] [lldb] r113180 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20100906230412.16CCF2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 6 18:04:11 2010 New Revision: 113180 URL: http://llvm.org/viewvc/llvm-project?rev=113180&view=rev Log: Fixed a buffer overrun error that could occur every time the program was run due to a "sprintf" with a destination string that was too short. Modified: lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113180&r1=113179&r2=113180&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon Sep 6 18:04:11 2010 @@ -1085,11 +1085,11 @@ if (isatty (STDIN_FILENO) && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) { - char buffer[25]; + char buffer[256]; if (window_size.ws_col > 0) { - sprintf (buffer, "settings set term-width %d", window_size.ws_col); + ::snprintf (buffer, sizeof(buffer), "settings set term-width %d", window_size.ws_col); m_debugger.HandleCommand ((const char *) buffer); } } From gclayton at apple.com Mon Sep 6 18:11:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Sep 2010 23:11:46 -0000 Subject: [Lldb-commits] [lldb] r113181 - /lldb/trunk/source/Core/Disassembler.cpp Message-ID: <20100906231146.2817A2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 6 18:11:45 2010 New Revision: 113181 URL: http://llvm.org/viewvc/llvm-project?rev=113181&view=rev Log: Fixed an error that could occur during disassembly that could cause a function name to be printed before the first _and_ the second instruction of disassembly when there are two symbols -- one debug symbol and one linker symbol. Modified: lldb/trunk/source/Core/Disassembler.cpp Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=113181&r1=113180&r2=113181&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Mon Sep 6 18:11:45 2010 @@ -215,7 +215,7 @@ uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc); if (resolved_mask) { - if (prev_sc.function != sc.function || prev_sc.symbol != sc.symbol) + if (!(prev_sc.function == sc.function || prev_sc.symbol == sc.symbol)) { if (prev_sc.function || prev_sc.symbol) strm.EOL(); From gclayton at apple.com Mon Sep 6 23:20:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 04:20:48 -0000 Subject: [Lldb-commits] [lldb] r113195 - in /lldb/trunk: include/lldb/API/SBBlock.h include/lldb/API/SBFileSpec.h include/lldb/API/SBFrame.h include/lldb/Symbol/Block.h include/lldb/Target/StackFrame.h lldb.xcodeproj/project.pbxproj source/API/SBBlock.cpp source/API/SBFrame.cpp source/Symbol/Block.cpp source/Symbol/SymbolContext.cpp source/Target/StackFrame.cpp source/Target/StackFrameList.cpp Message-ID: <20100907042048.496362A6C12D@llvm.org> Author: gclayton Date: Mon Sep 6 23:20:48 2010 New Revision: 113195 URL: http://llvm.org/viewvc/llvm-project?rev=113195&view=rev Log: Added more API to lldb::SBBlock to allow getting the block parent, sibling and first child block, and access to the inline function information. Added an accessor the StackFrame: Block * lldb_private::StackFrame::GetFrameBlock(); LLDB represents inline functions as lexical blocks that have inlined function information in them. The function above allows us to easily get the top most lexical block that defines a stack frame. When there are no inline functions in function, the block returned ends up being the top most block for the function. When the PC is in an inlined funciton for a frame, this will return the first parent block that has inlined function information. The other accessor: StackFrame::GetBlock() will return the deepest block that matches the frame's PC value. Since most debuggers want to display all variables in the current frame, the Block returned by StackFrame::GetFrameBlock can be used to retrieve all variables for the current frame. Fixed the lldb_private::Block::DumpStopContext(...) to properly display inline frames a block should display all of its inlined functions. Prior to this fix, one of the call sites was being skipped. This is a separate code path from the current default where inlined functions get their own frames. Fixed an issue where a block would always grab variables for any child inline function blocks. Modified: lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/StackFrameList.cpp Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Mon Sep 6 23:20:48 2010 @@ -23,17 +23,44 @@ ~SBBlock (); bool + IsInlined () const; + + bool IsValid () const; - void - AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list); + const char * + GetInlinedName () const; + + lldb::SBFileSpec + GetInlinedCallSiteFile () const; + + uint32_t + GetInlinedCallSiteLine () const; + + uint32_t + GetInlinedCallSiteColumn () const; + + lldb::SBBlock + GetParent (); + + lldb::SBBlock + GetSibling (); + + lldb::SBBlock + GetFirstChild (); private: friend class SBFrame; friend class SBSymbolContext; +#ifndef SWIG + SBBlock (lldb_private::Block *lldb_object_ptr); + void + AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list); + +#endif lldb_private::Block *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Mon Sep 6 23:20:48 2010 @@ -49,9 +49,10 @@ ResolvePath (const char *src_path, char *dst_path, size_t dst_len); private: - friend class SBLineEntry; + friend class SBBlock; friend class SBCompileUnit; friend class SBHostOS; + friend class SBLineEntry; friend class SBModule; friend class SBSourceManager; friend class SBThread; Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 6 23:20:48 2010 @@ -57,9 +57,25 @@ lldb::SBFunction GetFunction () const; + // Gets the deepest block that contains the frame PC lldb::SBBlock GetBlock () const; + // Gets the lexical block that defines the stack frame. Another way to think + // of this is it will return the block that contains all of the variables + // for a stack frame. Inlined functions are represented as SBBlock objects + // that have inlined function information: the name of the inlined function, + // where it was called from. The block that is returned will be the first + // block at or above the block for the PC (SBFrame::GetBlock()) that defines + // the scope of the frame. When a function contains no inlined functions, + // this will be the top most lexical block that defines the function. + // When a function has inlined functions and the PC is currently + // in one of those inlined functions, this method will return the inlined + // block that defines this frame. If the PC isn't currently in an inlined + // function, the lexical block that defines the function is returned. + lldb::SBBlock + GetFrameBlock () const; + lldb::SBLineEntry GetLineEntry () const; Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 6 23:20:48 2010 @@ -159,7 +159,11 @@ Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const; void - DumpStopContext (Stream *s, const SymbolContext *sc, bool show_fullpaths); + DumpStopContext (Stream *s, + const SymbolContext *sc, + const Declaration *child_inline_call_site, + bool show_fullpaths, + bool show_inline_blocks); //------------------------------------------------------------------ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) @@ -251,12 +255,19 @@ /// to see the current state of what has been parsed up to this /// point. /// + /// @param[in] add_inline_child_block_variables + /// If this is \b false, no child variables of child blocks + /// that are inlined functions will be gotten. If \b true then + /// all child variables will be added regardless of wether they + /// come from inlined functions or not. + /// /// @return /// A variable list shared pointer that contains all variables /// for this block. //------------------------------------------------------------------ lldb::VariableListSP - GetVariableList (bool get_child_variables, bool can_create); + GetVariableList (bool get_child_variables, + bool can_create); //------------------------------------------------------------------ @@ -301,7 +312,7 @@ /// if this is a regular block. //------------------------------------------------------------------ const InlineFunctionInfo* - InlinedFunctionInfo () const + GetInlinedFunctionInfo () const { return m_inlineInfoSP.get(); } Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Mon Sep 6 23:20:48 2010 @@ -81,6 +81,9 @@ bool GetFrameBaseValue(Scalar &value, Error *error_ptr); + Block * + GetFrameBlock (); + RegisterContext * GetRegisterContext (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 6 23:20:48 2010 @@ -2282,7 +2282,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Mon Sep 6 23:20:48 2010 @@ -8,9 +8,12 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBlock.h" +#include "lldb/API/SBFileSpec.h" #include "lldb/Symbol/Block.h" +#include "lldb/Symbol/Function.h" using namespace lldb; +using namespace lldb_private; SBBlock::SBBlock () : @@ -34,6 +37,63 @@ return m_opaque_ptr != NULL; } +bool +SBBlock::IsInlined () const +{ + if (m_opaque_ptr) + return m_opaque_ptr->GetInlinedFunctionInfo () != NULL; + return false; +} + +const char * +SBBlock::GetInlinedName () const +{ + if (m_opaque_ptr) + { + const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); + if (inlined_info) + return inlined_info->GetName().AsCString (NULL); + } + return NULL; +} + +SBFileSpec +SBBlock::GetInlinedCallSiteFile () const +{ + SBFileSpec sb_file; + if (m_opaque_ptr) + { + const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); + if (inlined_info) + sb_file.SetFileSpec (inlined_info->GetCallSite().GetFile()); + } + return sb_file; +} + +uint32_t +SBBlock::GetInlinedCallSiteLine () const +{ + if (m_opaque_ptr) + { + const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); + if (inlined_info) + return inlined_info->GetCallSite().GetLine(); + } + return 0; +} + +uint32_t +SBBlock::GetInlinedCallSiteColumn () const +{ + if (m_opaque_ptr) + { + const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); + if (inlined_info) + return inlined_info->GetCallSite().GetColumn(); + } + return 0; +} + void SBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list) { @@ -44,5 +104,32 @@ } } +SBBlock +SBBlock::GetParent () +{ + SBBlock sb_block; + if (m_opaque_ptr) + sb_block.m_opaque_ptr = m_opaque_ptr->GetParent(); + return sb_block; +} + +SBBlock +SBBlock::GetSibling () +{ + SBBlock sb_block; + if (m_opaque_ptr) + sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling(); + return sb_block; +} + +SBBlock +SBBlock::GetFirstChild () +{ + SBBlock sb_block; + if (m_opaque_ptr) + sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild(); + return sb_block; +} + Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Sep 6 23:20:48 2010 @@ -105,6 +105,13 @@ return sb_block; } +SBBlock +SBFrame::GetFrameBlock () const +{ + SBBlock sb_block(m_opaque_sp->GetFrameBlock ()); + return sb_block; +} + SBLineEntry SBFrame::GetLineEntry () const { Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 6 23:20:48 2010 @@ -145,48 +145,77 @@ } void -Block::DumpStopContext (Stream *s, const SymbolContext *sc, bool show_fullpaths) +Block::DumpStopContext +( + Stream *s, + const SymbolContext *sc_ptr, + const Declaration *child_inline_call_site, + bool show_fullpaths, + bool show_inline_blocks) { Block* parent_block = GetParent(); - const InlineFunctionInfo* inline_info = InlinedFunctionInfo (); + const InlineFunctionInfo* inline_info = GetInlinedFunctionInfo (); + const Declaration *inline_call_site = child_inline_call_site; if (inline_info) { - const Declaration &call_site = inline_info->GetCallSite(); - if (sc) + inline_call_site = &inline_info->GetCallSite(); + if (sc_ptr) { - // First frame, dump the first inline call site -// if (call_site.IsValid()) -// { -// s->PutCString(" at "); -// call_site.DumpStopContext (s); -// } + // First frame in a frame with inlined functions s->PutCString (" [inlined]"); } - s->EOL(); - inline_info->DumpStopContext (s); - if (sc == NULL) + if (show_inline_blocks) + s->EOL(); + else + s->PutChar(' '); + + s->PutCString(inline_info->GetName ().AsCString()); + + if (child_inline_call_site && child_inline_call_site->IsValid()) { - if (call_site.IsValid()) - { - s->PutCString(" at "); - call_site.DumpStopContext (s, show_fullpaths); - } + s->PutCString(" at "); + child_inline_call_site->DumpStopContext (s, show_fullpaths); } } - if (sc) + if (sc_ptr) { // If we have any inlined functions, this will be the deepest most // inlined location - if (sc->line_entry.IsValid()) + if (sc_ptr->line_entry.IsValid()) { s->PutCString(" at "); - sc->line_entry.DumpStopContext (s, show_fullpaths); + sc_ptr->line_entry.DumpStopContext (s, show_fullpaths); + } + } + + if (show_inline_blocks) + { + if (parent_block) + { + parent_block->Block::DumpStopContext (s, + NULL, + inline_call_site, + show_fullpaths, + show_inline_blocks); + } + else if (child_inline_call_site) + { + SymbolContext sc; + CalculateSymbolContext(&sc); + if (sc.function) + { + s->EOL(); + s->Indent (sc.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); + } + } } } - if (parent_block) - parent_block->Block::DumpStopContext (s, NULL, show_fullpaths); } @@ -246,7 +275,7 @@ Block * Block::GetContainingInlinedBlock () { - if (InlinedFunctionInfo()) + if (GetInlinedFunctionInfo()) return this; return GetInlinedParent (); } @@ -257,7 +286,7 @@ Block *parent_block = GetParent (); if (parent_block) { - if (parent_block->InlinedFunctionInfo()) + if (parent_block->GetInlinedFunctionInfo()) return parent_block; else return parent_block->GetInlinedParent(); @@ -381,13 +410,17 @@ if (get_child_variables) { - Block *child_block = GetFirstChild(); - while (child_block) - { - VariableListSP child_block_variable_list(child_block->GetVariableList(get_child_variables, can_create)); - if (child_block_variable_list.get()) - variable_list_sp->AddVariables(child_block_variable_list.get()); - child_block = child_block->GetSibling(); + for (Block *child_block = GetFirstChild(); + child_block != NULL; + child_block = child_block->GetSibling()) + { + if (child_block->GetInlinedFunctionInfo() == NULL) + { + VariableListSP child_block_variable_list(child_block->GetVariableList(get_child_variables, can_create)); + if (child_block_variable_list.get()) + variable_list_sp->AddVariables(child_block_variable_list.get()); + } + } } } @@ -407,7 +440,7 @@ uint32_t num_variables_added = 0; VariableListSP variable_list_sp(GetVariableList(false, can_create)); - bool is_inlined_function = InlinedFunctionInfo() != NULL; + bool is_inlined_function = GetInlinedFunctionInfo() != NULL; if (variable_list_sp.get()) { num_variables_added = variable_list_sp->GetSize(); Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Mon Sep 6 23:20:48 2010 @@ -135,12 +135,12 @@ if (show_inlined_frames && block) { - const InlineFunctionInfo *inline_info = block->InlinedFunctionInfo(); + const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo(); if (inline_info == NULL) { const Block *parent_inline_block = block->GetInlinedParent(); if (parent_inline_block) - inline_info = parent_inline_block->InlinedFunctionInfo(); + inline_info = parent_inline_block->GetInlinedFunctionInfo(); } if (inline_info) @@ -163,7 +163,7 @@ if (block != NULL) { s->IndentMore(); - block->DumpStopContext(s, this, show_fullpaths); + block->DumpStopContext (s, this, NULL, show_fullpaths, show_inlined_frames); s->IndentLess(); } else Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 6 23:20:48 2010 @@ -165,40 +165,27 @@ { if (m_id.GetSymbolContextScope ()) { + // We already have a symbol context scope, we just don't have our + // flag bit set. m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); } else { - GetSymbolContext (eSymbolContextFunction | eSymbolContextBlock); - - if (m_sc.block) - { - Block *inline_block = m_sc.block->GetContainingInlinedBlock(); - if (inline_block) - { - // 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 - SetSymbolContextScope (inline_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. - SetSymbolContextScope (&m_sc.function->GetBlock(false)); - } - } - else + // Calculate the frame block and use this for the stack ID symbol + // context scope if we have one. + SymbolContextScope *scope = GetFrameBlock (); + if (scope == NULL) { - // The current stack frame doesn't have a block. Check to see - // if it has a symbol. If it does we will use this as the - // symbol scope. It is ok if "m_sc.symbol" is NULL below as - // it will set the symbol context to NULL and set the - // RESOLVED_FRAME_ID_SYMBOL_SCOPE flag bit. - GetSymbolContext (eSymbolContextSymbol); - SetSymbolContextScope (m_sc.symbol); - } + // We don't have a block, so use the symbol + if (m_flags.IsClear (eSymbolContextSymbol)) + GetSymbolContext (eSymbolContextSymbol); + + // It is ok if m_sc.symbol is NULL here + scope = m_sc.symbol; + } + // Set the symbol context scope (the accessor will set the + // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags). + SetSymbolContextScope (scope); } } return m_id; @@ -270,6 +257,32 @@ return m_disassembly.GetData(); } +Block * +StackFrame::GetFrameBlock () +{ + if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock)) + GetSymbolContext (eSymbolContextBlock); + + if (m_sc.block) + { + Block *inline_block = m_sc.block->GetContainingInlinedBlock(); + if (inline_block) + { + // Use the block with the inlined function info + // as the frame block we want this frame to have only the variables + // for the inlined function and its non-inlined block child blocks. + return inline_block; + } + else + { + // This block is not contained withing any inlined function blocks + // with so we want to use the top most function block. + return &m_sc.function->GetBlock (false); + } + } + return NULL; +} + //---------------------------------------------------------------------- // Get the symbol context if we already haven't done so by resolving the // PC address as much as possible. This way when we pass around a @@ -427,24 +440,28 @@ { m_flags.Set(RESOLVED_VARIABLES); - GetSymbolContext (eSymbolContextCompUnit | - eSymbolContextFunction | - eSymbolContextBlock); - - if (m_sc.block) - { - bool get_child_variables = true; - bool can_create = true; - m_variable_list_sp = m_sc.function->GetBlock (can_create).GetVariableList (get_child_variables, can_create); + Block *frame_block = GetFrameBlock(); + + if (frame_block) + { + const bool get_child_variables = true; + const bool can_create = true; + m_variable_list_sp = frame_block->GetVariableList (get_child_variables, can_create); } - if (get_file_globals && m_sc.comp_unit) + if (get_file_globals) { - VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); - if (m_variable_list_sp) - m_variable_list_sp->AddVariables (global_variable_list_sp.get()); - else - m_variable_list_sp = global_variable_list_sp; + if (m_flags.IsClear (eSymbolContextCompUnit)) + GetSymbolContext (eSymbolContextCompUnit); + + if (m_sc.comp_unit) + { + VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); + if (m_variable_list_sp) + m_variable_list_sp->AddVariables (global_variable_list_sp.get()); + else + m_variable_list_sp = global_variable_list_sp; + } } } return m_variable_list_sp.get(); Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=113195&r1=113194&r2=113195&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Mon Sep 6 23:20:48 2010 @@ -135,7 +135,7 @@ AddressRange range; inlined_block->GetRangeContainingAddress (previous_frame_lookup_addr, range); - const InlineFunctionInfo* inline_info = inlined_block->InlinedFunctionInfo(); + 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(); From johnny.chen at apple.com Tue Sep 7 11:19:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 16:19:35 -0000 Subject: [Lldb-commits] [lldb] r113206 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20100907161935.46B1C2A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 11:19:35 2010 New Revision: 113206 URL: http://llvm.org/viewvc/llvm-project?rev=113206&view=rev Log: LLDB command "set term-width 0" needs to be changed to "settings set term-width 0" after the recent checkin. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=113206&r1=113205&r2=113206&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Tue Sep 7 11:19:35 2010 @@ -19,8 +19,8 @@ startstr = 'The following is a list of built-in, permanent debugger commands') def test_help_should_not_hang_emacsshell(self): - """Command 'set term-width 0' should not hang the help command.""" - self.runCmd("set term-width 0") + """Command 'settings set term-width 0' should not hang the help command.""" + self.runCmd("settings set term-width 0") self.expect("help", startstr = 'The following is a list of built-in, permanent debugger commands') From johnny.chen at apple.com Tue Sep 7 12:06:13 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 17:06:13 -0000 Subject: [Lldb-commits] [lldb] r113211 - in /lldb/trunk/test/settings: ./ TestSettings.py Message-ID: <20100907170614.07E892A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 12:06:13 2010 New Revision: 113211 URL: http://llvm.org/viewvc/llvm-project?rev=113211&view=rev Log: Added a simple test case for the "settings set" command for instance variable 'prompt'. Added: lldb/trunk/test/settings/ lldb/trunk/test/settings/TestSettings.py Added: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=113211&view=auto ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (added) +++ lldb/trunk/test/settings/TestSettings.py Tue Sep 7 12:06:13 2010 @@ -0,0 +1,27 @@ +""" +Test lldb settings command. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class SettingsCommandTestCase(TestBase): + + mydir = "settings" + + def test_set_prompt(self): + """Test that 'set prompt' actually changes the prompt.""" + self.runCmd("settings set -o prompt 'lldb2'") + self.expect("settings show prompt", + startstr = "prompt (string) = 'lldb2'") + self.expect("settings show", + substrs = ["prompt (string) = 'lldb2'"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From johnny.chen at apple.com Tue Sep 7 12:12:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 17:12:10 -0000 Subject: [Lldb-commits] [lldb] r113214 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20100907171210.36F512A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 12:12:10 2010 New Revision: 113214 URL: http://llvm.org/viewvc/llvm-project?rev=113214&view=rev Log: Added comments. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=113214&r1=113213&r2=113214&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Sep 7 12:12:10 2010 @@ -13,9 +13,15 @@ def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" + + # Use '-o' option to override the existing instance setting. self.runCmd("settings set -o prompt 'lldb2'") + + # Immediately test the setting. self.expect("settings show prompt", startstr = "prompt (string) = 'lldb2'") + + # The overall display should also reflect the new setting. self.expect("settings show", substrs = ["prompt (string) = 'lldb2'"]) From johnny.chen at apple.com Tue Sep 7 12:31:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 17:31:06 -0000 Subject: [Lldb-commits] [lldb] r113219 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20100907173106.0BC8A2A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 12:31:05 2010 New Revision: 113219 URL: http://llvm.org/viewvc/llvm-project?rev=113219&view=rev Log: Added a test case for setting term-width, too. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=113219&r1=113218&r2=113219&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Sep 7 12:31:05 2010 @@ -25,6 +25,20 @@ self.expect("settings show", substrs = ["prompt (string) = 'lldb2'"]) + def test_set_term_width(self): + """Test that 'set term-width' actually changes the term-width.""" + + # No '-o' option is needed for static setting. + self.runCmd("settings set term-width 70") + + # Immediately test the setting. + self.expect("settings show term-width", + startstr = "term-width (int) = '70'") + + # The overall display should also reflect the new setting. + self.expect("settings show", + startstr = "term-width (int) = 70") + if __name__ == '__main__': import atexit From gclayton at apple.com Tue Sep 7 12:36:17 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 17:36:17 -0000 Subject: [Lldb-commits] [lldb] r113223 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp Message-ID: <20100907173617.64A032A6C12D@llvm.org> Author: gclayton Date: Tue Sep 7 12:36:17 2010 New Revision: 113223 URL: http://llvm.org/viewvc/llvm-project?rev=113223&view=rev Log: Added Symtab::FindSymbolByID() in preparation for enabling the minimal symbol tables. Minimal symbol tables enable us to merge two symbols, one debug symbol and one linker symbol, into a single symbol that can carry just as much information and will avoid duplicate symbols in the symbol table. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=113223&r1=113222&r2=113223&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Sep 7 12:36:17 2010 @@ -32,6 +32,7 @@ void Dump(Stream *s, Process *process) const; void Dump(Stream *s, Process *process, std::vector& indexes) const; + Symbol * FindSymbolByID (lldb::user_id_t uid) const; Symbol * SymbolAtIndex (uint32_t idx); const Symbol * SymbolAtIndex (uint32_t idx) const; Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx); @@ -55,7 +56,7 @@ static void DumpSymbolHeader (Stream *s); protected: - typedef std::vector collection; + typedef std::vector collection; typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113223&r1=113222&r2=113223&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Sep 7 12:36:17 2010 @@ -878,6 +878,10 @@ case StabIncludeFileName: // N_SOL - #included file name: name,,n_sect,0,address type = eSymbolTypeHeaderFile; + + // We currently don't use the header files on darwin + if (minimize) + add_nlist = false; break; case StabCompilerParameters: @@ -1175,7 +1179,13 @@ { const uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); - Symbol *stub_symbol = symtab->SymbolAtIndex(symbol_index); + Symbol *stub_symbol; + if (minimize) + stub_symbol = symtab->FindSymbolByID (symbol_index); + else + stub_symbol = symtab->SymbolAtIndex (symbol_index); + + assert (stub_symbol); if (stub_symbol) { Address so_addr(symbol_stub_addr, section_list); Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113223&r1=113222&r2=113223&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Tue Sep 7 12:36:17 2010 @@ -136,6 +136,31 @@ s->Indent("------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ----------------------------------\n"); } + +static int +CompareSymbolID (const void *key, const void *p) +{ + const user_id_t match_uid = *(user_id_t*) key; + const user_id_t symbol_uid = ((Symbol *)p)->GetID(); + if (match_uid < symbol_uid) + return -1; + if (match_uid > symbol_uid) + return 1; + return 0; +} + +Symbol * +Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const +{ + Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, + &m_symbols[0], + m_symbols.size(), + sizeof(Symbol), + CompareSymbolID); + return symbol; +} + + Symbol * Symtab::SymbolAtIndex(uint32_t idx) { From johnny.chen at apple.com Tue Sep 7 13:19:13 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 18:19:13 -0000 Subject: [Lldb-commits] [lldb] r113238 - /lldb/trunk/test/set_values/TestSetValues.py Message-ID: <20100907181913.3FA592A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 13:19:13 2010 New Revision: 113238 URL: http://llvm.org/viewvc/llvm-project?rev=113238&view=rev Log: Converted TestSetValues.py to Dsym/Dwarf combination. Modified: lldb/trunk/test/set_values/TestSetValues.py Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=113238&r1=113237&r2=113238&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Tue Sep 7 13:19:13 2010 @@ -9,7 +9,18 @@ mydir = "set_values" - def test_set_values(self): + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test settings and readings of program variables.""" + self.buildDsym() + self.set_values() + + def test_with_dwarf(self): + """Test settings and readings of program variables.""" + self.buildDwarf() + self.set_values() + + def set_values(self): """Test settings and readings of program variables.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) From johnny.chen at apple.com Tue Sep 7 13:27:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 18:27:35 -0000 Subject: [Lldb-commits] [lldb] r113241 - /lldb/trunk/test/stl/TestSTL.py Message-ID: <20100907182735.B802C2A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 13:27:35 2010 New Revision: 113241 URL: http://llvm.org/viewvc/llvm-project?rev=113241&view=rev Log: Converted TestSTL.py to Dsym/Dwarf combination. Modified: lldb/trunk/test/stl/TestSTL.py Modified: lldb/trunk/test/stl/TestSTL.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestSTL.py?rev=113241&r1=113240&r2=113241&view=diff ============================================================================== --- lldb/trunk/test/stl/TestSTL.py (original) +++ lldb/trunk/test/stl/TestSTL.py Tue Sep 7 13:27:35 2010 @@ -11,8 +11,20 @@ mydir = "stl" + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @unittest2.expectedFailure - def test_step_into_stl(self): + def test_with_dsym(self): + """Test that we can successfully step into an STL function.""" + self.buildDsym() + self.step_into_stl() + + @unittest2.expectedFailure + def test_with_dwarf(self): + """Test that we can successfully step into an STL function.""" + self.buildDwarf() + self.step_into_stl() + + def step_into_stl(self): """Test that we can successfully step into an STL function.""" exe = os.path.join(os.getcwd(), "a.out") From johnny.chen at apple.com Tue Sep 7 13:32:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 18:32:58 -0000 Subject: [Lldb-commits] [lldb] r113244 - in /lldb/trunk/test: struct_types/TestStructTypes.py unsigned_types/TestUnsignedTypes.py Message-ID: <20100907183258.25FFE2A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 13:32:57 2010 New Revision: 113244 URL: http://llvm.org/viewvc/llvm-project?rev=113244&view=rev Log: Converted TestUnsignedTypespy and TestStructTypes.py to Dsym/Dwarf combination. Modified: lldb/trunk/test/struct_types/TestStructTypes.py lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Modified: lldb/trunk/test/struct_types/TestStructTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/struct_types/TestStructTypes.py?rev=113244&r1=113243&r2=113244&view=diff ============================================================================== --- lldb/trunk/test/struct_types/TestStructTypes.py (original) +++ lldb/trunk/test/struct_types/TestStructTypes.py Tue Sep 7 13:32:57 2010 @@ -13,7 +13,18 @@ mydir = "struct_types" - def test_struct_types(self): + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test that break on a struct declaration has no effect.""" + self.buildDsym() + self.struct_types() + + def test_with_dwarf(self): + """Test that break on a struct declaration has no effect.""" + self.buildDwarf() + self.struct_types() + + def struct_types(self): """Test that break on a struct declaration has no effect.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=113244&r1=113243&r2=113244&view=diff ============================================================================== --- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (original) +++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Tue Sep 7 13:32:57 2010 @@ -12,7 +12,18 @@ mydir = "unsigned_types" - def test_unsigned_types(self): + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test that variables with unsigned types display correctly.""" + self.buildDsym() + self.unsigned_types() + + def test_with_dwarf(self): + """Test that variables with unsigned types display correctly.""" + self.buildDwarf() + self.unsigned_types() + + def unsigned_types(self): """Test that variables with unsigned types display correctly.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) From ctice at apple.com Tue Sep 7 13:35:40 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 07 Sep 2010 18:35:40 -0000 Subject: [Lldb-commits] [lldb] r113245 - in /lldb/trunk/source: Commands/CommandObjectSettings.cpp Core/Debugger.cpp Core/UserSettingsController.cpp Target/Process.cpp Message-ID: <20100907183540.910EA2A6C12C@llvm.org> Author: ctice Date: Tue Sep 7 13:35:40 2010 New Revision: 113245 URL: http://llvm.org/viewvc/llvm-project?rev=113245&view=rev Log: Fix various minor bugs in the Settings stuff. Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113245&r1=113244&r2=113245&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Tue Sep 7 13:35:40 2010 @@ -82,7 +82,7 @@ const int argc = command.GetArgumentCount (); - if (argc < 2) + if ((argc < 2) && (!m_options.m_reset)) { result.AppendError ("'settings set' takes more arguments"); result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113245&r1=113244&r2=113245&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Sep 7 13:35:40 2010 @@ -689,7 +689,16 @@ UserSettingsController::UpdateStringVariable (op, m_prompt, value, err); if (!pending) { - BroadcastPromptChange (instance_name, m_prompt.c_str()); + // 'instance_name' is actually (probably) in the form '[]'; if so, we need to + // strip off the brackets before passing it to BroadcastPromptChange. + + std::string tmp_instance_name (instance_name.AsCString()); + if ((tmp_instance_name[0] == '[') + && (tmp_instance_name[instance_name.GetLength() - 1] == ']')) + tmp_instance_name = tmp_instance_name.substr (1, instance_name.GetLength() - 2); + ConstString new_name (tmp_instance_name.c_str()); + + BroadcastPromptChange (new_name, m_prompt.c_str()); } } else if (var_name == ScriptLangVarName()) @@ -746,7 +755,18 @@ m_prompt = new_debugger_settings->m_prompt; if (!pending) - BroadcastPromptChange (m_instance_name, m_prompt.c_str()); + { + // 'instance_name' is actually (probably) in the form '[]'; if so, we need to + // strip off the brackets before passing it to BroadcastPromptChange. + + std::string tmp_instance_name (m_instance_name.AsCString()); + if ((tmp_instance_name[0] == '[') + && (tmp_instance_name[m_instance_name.GetLength() - 1] == ']')) + tmp_instance_name = tmp_instance_name.substr (1, m_instance_name.GetLength() - 2); + ConstString new_name (tmp_instance_name.c_str()); + + BroadcastPromptChange (new_name, m_prompt.c_str()); + } m_script_lang = new_debugger_settings->m_script_lang; } Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113245&r1=113244&r2=113245&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Tue Sep 7 13:35:40 2010 @@ -1042,13 +1042,14 @@ StringList value = root->GetVariable (full_var_name.GetData(), var_type); description.Clear(); if (value.GetSize() == 1) - description.Printf ("%s (%s) = %s", full_var_name.GetData(), GetTypeString (entry.var_type), + description.Printf ("%s (%s) = '%s'", full_var_name.GetData(), GetTypeString (entry.var_type), value.GetStringAtIndex (0)); else { - description.Printf ("%s (%s) = ", full_var_name.GetData(), GetTypeString (entry.var_type)); + description.Printf ("%s (%s) = '", full_var_name.GetData(), GetTypeString (entry.var_type)); for (int j = 0; j < value.GetSize(); ++j) description.Printf ("%s ", value.GetStringAtIndex (j)); + description.Printf ("'"); } result_stream.Printf ("%s\n", description.GetData()); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113245&r1=113244&r2=113245&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Sep 7 13:35:40 2010 @@ -2196,7 +2196,7 @@ const ConstString & ProcessInstanceSettings::OutputPathVarName () { - static ConstString output_path_var_name ("output_path"); + static ConstString output_path_var_name ("output-path"); return output_path_var_name; } @@ -2204,7 +2204,7 @@ const ConstString & ProcessInstanceSettings::ErrorPathVarName () { - static ConstString error_path_var_name ("error_path"); + static ConstString error_path_var_name ("error-path"); return error_path_var_name; } From johnny.chen at apple.com Tue Sep 7 13:55:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 07 Sep 2010 18:55:50 -0000 Subject: [Lldb-commits] [lldb] r113251 - in /lldb/trunk/test: lldbtest.py settings/TestSettings.py Message-ID: <20100907185550.C5A052A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 13:55:50 2010 New Revision: 113251 URL: http://llvm.org/viewvc/llvm-project?rev=113251&view=rev Log: The output for term-width setting has single quotes around the (int) value. And added a trace output for the stop function name to breakAfterLaunch() method. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113251&r1=113250&r2=113251&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 7 13:55:50 2010 @@ -438,6 +438,8 @@ if SR == StopReasonEnum("Breakpoint"): frame = thread.GetFrameAtIndex(0) name = frame.GetFunction().GetName() + if trace: + print >> sys.stderr, "function =", name if (name == func): # We got what we want; now break out of the loop. return True Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=113251&r1=113250&r2=113251&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Sep 7 13:55:50 2010 @@ -37,7 +37,7 @@ # The overall display should also reflect the new setting. self.expect("settings show", - startstr = "term-width (int) = 70") + startstr = "term-width (int) = '70'") if __name__ == '__main__': From gclayton at apple.com Tue Sep 7 15:11:56 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 20:11:56 -0000 Subject: [Lldb-commits] [lldb] r113263 - in /lldb/trunk: include/lldb/Host/Host.h lib/Makefile lldb.xcodeproj/project.pbxproj source/Host/Makefile source/Host/common/ source/Host/common/Condition.cpp source/Host/common/Host.cpp source/Host/common/Makefile source/Host/common/Mutex.cpp source/Host/common/Symbols.cpp source/Host/common/TimeValue.cpp source/Host/linux/ source/Host/macosx/Host.mm source/Host/macosx/TimeValue.cpp source/Host/posix/ Message-ID: <20100907201156.AA6542A6C12C@llvm.org> Author: gclayton Date: Tue Sep 7 15:11:56 2010 New Revision: 113263 URL: http://llvm.org/viewvc/llvm-project?rev=113263&view=rev Log: Patch from Jay Cornwall that modifies the LLDB "Host" layer to reuse more code between linux, darwin and BSD. Added: lldb/trunk/source/Host/common/ lldb/trunk/source/Host/common/Condition.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/common/Makefile lldb/trunk/source/Host/common/Mutex.cpp lldb/trunk/source/Host/common/Symbols.cpp lldb/trunk/source/Host/common/TimeValue.cpp Removed: lldb/trunk/source/Host/linux/ lldb/trunk/source/Host/macosx/TimeValue.cpp lldb/trunk/source/Host/posix/ Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/lib/Makefile lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Host/Makefile lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113263&r1=113262&r2=113263&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Sep 7 15:11:56 2010 @@ -148,7 +148,7 @@ /// @return /// The thread ID for the calling thread in the current process. //------------------------------------------------------------------ - static lldb::pid_t + static lldb::tid_t GetCurrentThreadID (); static const char * Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=113263&r1=113262&r2=113263&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Tue Sep 7 15:11:56 2010 @@ -23,7 +23,7 @@ lldbCommands.a \ lldbCore.a \ lldbExpression.a \ - lldbHostPosix.a \ + lldbHostCommon.a \ lldbInitAndLog.a \ lldbInterpreter.a \ lldbPluginABIMacOSX_i386.a \ @@ -69,8 +69,7 @@ endif ifeq ($(HOST_OS),Linux) - USEDLIBS += lldbHostLinux.a \ - lldbPluginProcessLinux.a + USEDLIBS += lldbPluginProcessLinux.a endif include $(LEVEL)/Makefile.common Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113263&r1=113262&r2=113263&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 7 15:11:56 2010 @@ -147,9 +147,7 @@ 26D5B0BC11B07550009A862E /* VMRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9E10F1B85900F91463 /* VMRange.cpp */; }; 26D5B0BD11B07550009A862E /* ClangUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED510F1B86700F91463 /* ClangUserExpression.cpp */; }; 26D5B0BE11B07550009A862E /* ClangExpressionVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */; }; - 26D5B0C111B07550009A862E /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE710F1B88F00F91463 /* Condition.cpp */; }; 26D5B0C211B07550009A862E /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; }; - 26D5B0C311B07550009A862E /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE910F1B88F00F91463 /* Mutex.cpp */; }; 26D5B0C411B07550009A862E /* CFCBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */; }; 26D5B0C511B07550009A862E /* CFCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */; }; 26D5B0C611B07550009A862E /* CFCMutableArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF110F1B8AD00F91463 /* CFCMutableArray.cpp */; }; @@ -246,7 +244,6 @@ 26D5B12611B07550009A862E /* ThreadPlanStepOverRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */; }; 26D5B12711B07550009A862E /* CommandObjectLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264AD83711095BA600E0B039 /* CommandObjectLog.cpp */; }; 26D5B12811B07550009A862E /* ValueObjectRegister.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */; }; - 26D5B12911B07550009A862E /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */; }; 26D5B12A11B07550009A862E /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C81CA511335651004BDC5A /* UUID.cpp */; }; 26D5B12B11B07550009A862E /* ScriptInterpreterNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */; }; 26D5B12C11B07550009A862E /* CommandObjectCrossref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DFBC57113B48F300DD817F /* CommandObjectCrossref.cpp */; }; @@ -352,6 +349,11 @@ 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; + 69A01E211236C5D400C660B5 /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1B1236C5D400C660B5 /* Condition.cpp */; }; + 69A01E221236C5D400C660B5 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; }; + 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1E1236C5D400C660B5 /* Mutex.cpp */; }; + 69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1F1236C5D400C660B5 /* Symbols.cpp */; }; + 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E201236C5D400C660B5 /* TimeValue.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -569,7 +571,6 @@ 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibUnwindRegisterContext.cpp; path = Utility/LibUnwindRegisterContext.cpp; sourceTree = ""; }; 26B4667011A2091600CF6220 /* LibUnwindRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibUnwindRegisterContext.h; path = Utility/LibUnwindRegisterContext.h; sourceTree = ""; }; 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = ""; }; - 26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TimeValue.cpp; path = source/Host/macosx/TimeValue.cpp; sourceTree = ""; }; 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-defines.h"; path = "include/lldb/lldb-defines.h"; sourceTree = ""; }; 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-enumerations.h"; path = "include/lldb/lldb-enumerations.h"; sourceTree = ""; }; 26BC7C2810F1B3BC00F91463 /* lldb-private-interfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-private-interfaces.h"; path = "include/lldb/lldb-private-interfaces.h"; sourceTree = ""; }; @@ -783,9 +784,7 @@ 26BC7ED510F1B86700F91463 /* ClangUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUserExpression.cpp; path = source/Expression/ClangUserExpression.cpp; sourceTree = ""; }; 26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionVariable.cpp; path = source/Expression/ClangExpressionVariable.cpp; sourceTree = ""; }; 26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DWARFExpression.cpp; path = source/Expression/DWARFExpression.cpp; sourceTree = ""; }; - 26BC7EE710F1B88F00F91463 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Condition.cpp; path = source/Host/posix/Condition.cpp; sourceTree = ""; }; 26BC7EE810F1B88F00F91463 /* Host.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Host.mm; path = source/Host/macosx/Host.mm; sourceTree = ""; }; - 26BC7EE910F1B88F00F91463 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mutex.cpp; path = source/Host/posix/Mutex.cpp; sourceTree = ""; }; 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCBundle.cpp; path = source/Host/macosx/cfcpp/CFCBundle.cpp; sourceTree = ""; }; 26BC7EEE10F1B8AD00F91463 /* CFCBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCBundle.h; path = source/Host/macosx/cfcpp/CFCBundle.h; sourceTree = ""; }; 26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCData.cpp; path = source/Host/macosx/cfcpp/CFCData.cpp; sourceTree = ""; }; @@ -963,6 +962,11 @@ 4CEE62FF1145F2130064CF93 /* ThreadGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.h"; sourceTree = ""; }; 4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadPlanStepThroughObjCTrampoline.h; sourceTree = ""; }; 4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = ""; }; + 69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = ""; }; + 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; + 69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = ""; }; + 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = ""; }; + 69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = ""; }; 9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSXLibunwindCallbacks.cpp; path = Utility/MacOSXLibunwindCallbacks.cpp; sourceTree = ""; }; 9654F79D1197DA1300F72B43 /* MacOSXLibunwindCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSXLibunwindCallbacks.h; path = Utility/MacOSXLibunwindCallbacks.h; sourceTree = ""; }; 9654F7A11197DA3F00F72B43 /* libunwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libunwind.h; sourceTree = ""; }; @@ -1868,8 +1872,8 @@ 26BC7DD010F1B7C100F91463 /* Host */ = { isa = PBXGroup; children = ( + 69A01E1A1236C5D400C660B5 /* common */, 26BC7EE510F1B88100F91463 /* MacOSX */, - 26F62BB211C5E6C300358180 /* posix */, 26BC7DD210F1B7D500F91463 /* Condition.h */, 26BC7DD310F1B7D500F91463 /* Endian.h */, 26BC7DD410F1B7D500F91463 /* Host.h */, @@ -1999,7 +2003,6 @@ 26BC7EF910F1B8AD00F91463 /* CFCString.h */, 26BC7EE810F1B88F00F91463 /* Host.mm */, 2689B0B5113EE47E00A4AEDB /* Symbols.cpp */, - 26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */, ); name = MacOSX; sourceTree = ""; @@ -2050,15 +2053,6 @@ sourceTree = ""; usesTabs = 0; }; - 26F62BB211C5E6C300358180 /* posix */ = { - isa = PBXGroup; - children = ( - 26BC7EE710F1B88F00F91463 /* Condition.cpp */, - 26BC7EE910F1B88F00F91463 /* Mutex.cpp */, - ); - name = posix; - sourceTree = ""; - }; 493C63D711891A8000914D5E /* ABI */ = { isa = PBXGroup; children = ( @@ -2104,6 +2098,19 @@ path = ../../..; sourceTree = ""; }; + 69A01E1A1236C5D400C660B5 /* common */ = { + isa = PBXGroup; + children = ( + 69A01E1B1236C5D400C660B5 /* Condition.cpp */, + 69A01E1C1236C5D400C660B5 /* Host.cpp */, + 69A01E1E1236C5D400C660B5 /* Mutex.cpp */, + 69A01E1F1236C5D400C660B5 /* Symbols.cpp */, + 69A01E201236C5D400C660B5 /* TimeValue.cpp */, + ); + name = common; + path = source/Host/common; + sourceTree = ""; + }; 9654F79F1197DA3F00F72B43 /* libunwind */ = { isa = PBXGroup; children = ( @@ -2282,6 +2289,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2477,9 +2485,7 @@ 26D5B0BC11B07550009A862E /* VMRange.cpp in Sources */, 26D5B0BD11B07550009A862E /* ClangUserExpression.cpp in Sources */, 26D5B0BE11B07550009A862E /* ClangExpressionVariable.cpp in Sources */, - 26D5B0C111B07550009A862E /* Condition.cpp in Sources */, 26D5B0C211B07550009A862E /* Host.mm in Sources */, - 26D5B0C311B07550009A862E /* Mutex.cpp in Sources */, 26D5B0C411B07550009A862E /* CFCBundle.cpp in Sources */, 26D5B0C511B07550009A862E /* CFCData.cpp in Sources */, 26D5B0C611B07550009A862E /* CFCMutableArray.cpp in Sources */, @@ -2576,7 +2582,6 @@ 26D5B12611B07550009A862E /* ThreadPlanStepOverRange.cpp in Sources */, 26D5B12711B07550009A862E /* CommandObjectLog.cpp in Sources */, 26D5B12811B07550009A862E /* ValueObjectRegister.cpp in Sources */, - 26D5B12911B07550009A862E /* TimeValue.cpp in Sources */, 26D5B12A11B07550009A862E /* UUID.cpp in Sources */, 26D5B12B11B07550009A862E /* ScriptInterpreterNone.cpp in Sources */, 26D5B12C11B07550009A862E /* CommandObjectCrossref.cpp in Sources */, @@ -2680,6 +2685,11 @@ 491193521226386000578B7F /* ASTStructExtractor.cpp in Sources */, 497C86BE122823D800B54702 /* ClangUtilityFunction.cpp in Sources */, 49CF982A122C70BD007A0B96 /* IRDynamicChecks.cpp in Sources */, + 69A01E211236C5D400C660B5 /* Condition.cpp in Sources */, + 69A01E221236C5D400C660B5 /* Host.cpp in Sources */, + 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */, + 69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */, + 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Host/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/Makefile?rev=113263&r1=113262&r2=113263&view=diff ============================================================================== --- lldb/trunk/source/Host/Makefile (original) +++ lldb/trunk/source/Host/Makefile Tue Sep 7 15:11:56 2010 @@ -11,10 +11,10 @@ include $(LLDB_LEVEL)/../../Makefile.config +DIRS := common + ifeq ($(HOST_OS),Darwin) -DIRS := macosx posix -else -DIRS := linux posix +DIRS += macosx endif include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Host/common/Condition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Condition.cpp?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Condition.cpp (added) +++ lldb/trunk/source/Host/common/Condition.cpp Tue Sep 7 15:11:56 2010 @@ -0,0 +1,106 @@ +//===-- Condition.cpp -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +#include "lldb/Host/Condition.h" +#include "lldb/Host/TimeValue.h" + + +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Default constructor +// +// The default constructor will initialize a new pthread condition +// and maintain the condition in the object state. +//---------------------------------------------------------------------- +Condition::Condition () : + m_condition() +{ + ::pthread_cond_init (&m_condition, NULL); +} + +//---------------------------------------------------------------------- +// Destructor +// +// Destroys the pthread condition that the object owns. +//---------------------------------------------------------------------- +Condition::~Condition () +{ + ::pthread_cond_destroy (&m_condition); +} + +//---------------------------------------------------------------------- +// Unblock all threads waiting for a condition variable +//---------------------------------------------------------------------- +int +Condition::Broadcast () +{ + return ::pthread_cond_broadcast (&m_condition); +} + +//---------------------------------------------------------------------- +// Get accessor to the pthread condition object +//---------------------------------------------------------------------- +pthread_cond_t * +Condition::GetCondition () +{ + return &m_condition; +} + +//---------------------------------------------------------------------- +// Unblocks one thread waiting for the condition variable +//---------------------------------------------------------------------- +int +Condition::Signal () +{ + return ::pthread_cond_signal (&m_condition); +} + +//---------------------------------------------------------------------- +// The Wait() function atomically blocks the current thread +// waiting on the owend condition variable, and unblocks the mutex +// specified by "mutex". The waiting thread unblocks only after +// another thread calls Signal(), or Broadcast() with the same +// condition variable, or if "abstime" is valid (non-NULL) this +// function will return when the system time reaches the time +// specified in "abstime". If "abstime" is NULL this function will +// wait for an infinite amount of time for the condition variable +// to be signaled or broadcasted. +// +// The current thread re-acquires the lock on "mutex". +//---------------------------------------------------------------------- +int +Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_out) +{ + int err = 0; + do + { + if (abstime && abstime->IsValid()) + { + struct timespec abstime_ts = abstime->GetAsTimeSpec(); + err = ::pthread_cond_timedwait (&m_condition, mutex, &abstime_ts); + } + else + err = ::pthread_cond_wait (&m_condition, mutex); + } while (err == EINTR); + + if (timed_out != NULL) + { + if (err == ETIMEDOUT) + *timed_out = true; + else + *timed_out = false; + } + + + return err; +} + Added: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (added) +++ lldb/trunk/source/Host/common/Host.cpp Tue Sep 7 15:11:56 2010 @@ -0,0 +1,729 @@ +//===-- Host.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/Host/Host.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/ConstString.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/FileSpec.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Host/Mutex.h" + +#include +#include +#include +#include + +#if defined (__APPLE__) +#include +#include +#endif + +using namespace lldb; +using namespace lldb_private; + +struct MonitorInfo +{ + lldb::pid_t pid; // The process ID to monitor + Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals + void *callback_baton; // The callback baton for the callback function + bool monitor_signals; // If true, call the callback when "pid" gets signaled. +}; + +static void * +MonitorChildProcessThreadFunction (void *arg); + +lldb::thread_t +Host::StartMonitoringChildProcess +( + Host::MonitorChildProcessCallback callback, + void *callback_baton, + lldb::pid_t pid, + bool monitor_signals +) +{ + lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; + if (callback) + { + std::auto_ptr info_ap(new MonitorInfo); + + info_ap->pid = pid; + info_ap->callback = callback; + info_ap->callback_baton = callback_baton; + info_ap->monitor_signals = monitor_signals; + + char thread_name[256]; + ::snprintf (thread_name, sizeof(thread_name), "", pid); + thread = ThreadCreate (thread_name, + MonitorChildProcessThreadFunction, + info_ap.get(), + NULL); + + if (thread != LLDB_INVALID_HOST_THREAD) + info_ap.release(); + } + return thread; +} + +//------------------------------------------------------------------ +// Scoped class that will disable thread canceling when it is +// constructed, and exception safely restore the previous value it +// when it goes out of scope. +//------------------------------------------------------------------ +class ScopedPThreadCancelDisabler +{ +public: + ScopedPThreadCancelDisabler() + { + // Disable the ability for this thread to be cancelled + int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state); + if (err != 0) + m_old_state = -1; + + } + + ~ScopedPThreadCancelDisabler() + { + // Restore the ability for this thread to be cancelled to what it + // previously was. + if (m_old_state != -1) + ::pthread_setcancelstate (m_old_state, 0); + } +private: + int m_old_state; // Save the old cancelability state. +}; + +static void * +MonitorChildProcessThreadFunction (void *arg) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS); + const char *function = __FUNCTION__; + if (log) + log->Printf ("%s (arg = %p) thread starting...", function, arg); + + MonitorInfo *info = (MonitorInfo *)arg; + + const Host::MonitorChildProcessCallback callback = info->callback; + void * const callback_baton = info->callback_baton; + const lldb::pid_t pid = info->pid; + const bool monitor_signals = info->monitor_signals; + + delete info; + + int status = -1; + const int options = 0; + struct rusage *rusage = NULL; + while (1) + { + if (log) + log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage); + + // Wait for all child processes + ::pthread_testcancel (); + const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage); + ::pthread_testcancel (); + + if (wait_pid == -1) + { + if (errno == EINTR) + continue; + else + break; + } + else if (wait_pid == pid) + { + bool exited = false; + int signal = 0; + int exit_status = 0; + const char *status_cstr = NULL; + if (WIFSTOPPED(status)) + { + signal = WSTOPSIG(status); + status_cstr = "STOPPED"; + } + else if (WIFEXITED(status)) + { + exit_status = WEXITSTATUS(status); + status_cstr = "EXITED"; + exited = true; + } + else if (WIFSIGNALED(status)) + { + signal = WTERMSIG(status); + status_cstr = "SIGNALED"; + exited = true; + exit_status = -1; + } + else + { + status_cstr = "(???)"; + } + + // Scope for pthread_cancel_disabler + { + ScopedPThreadCancelDisabler pthread_cancel_disabler; + + if (log) + log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i", + function, + wait_pid, + options, + rusage, + pid, + status, + status_cstr, + signal, + exit_status); + + if (exited || (signal != 0 && monitor_signals)) + { + bool callback_return = callback (callback_baton, pid, signal, exit_status); + + // If our process exited, then this thread should exit + if (exited) + break; + // If the callback returns true, it means this process should + // exit + if (callback_return) + break; + } + } + } + } + + if (log) + log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg); + + return NULL; +} + +size_t +Host::GetPageSize() +{ + return ::getpagesize(); +} + +//------------------------------------------------------------------ +// Returns true if the host system is Big Endian. +//------------------------------------------------------------------ +ByteOrder +Host::GetByteOrder () +{ + union EndianTest + { + uint32_t num; + uint8_t bytes[sizeof(uint32_t)]; + } endian = { (uint16_t)0x11223344 }; + switch (endian.bytes[0]) + { + case 0x11: return eByteOrderLittle; + case 0x44: return eByteOrderBig; + case 0x33: return eByteOrderPDP; + } + return eByteOrderInvalid; +} + +const ArchSpec & +Host::GetArchitecture () +{ + static ArchSpec g_host_arch; + if (!g_host_arch.IsValid()) + { +#if defined (__APPLE__) + uint32_t cputype, cpusubtype; + uint32_t is_64_bit_capable; + size_t len = sizeof(cputype); + if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) + { + len = sizeof(cpusubtype); + if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) + g_host_arch.SetArch(cputype, cpusubtype); + + len = sizeof (is_64_bit_capable); + if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0) + { + if (is_64_bit_capable) + { + if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486) + cpusubtype = CPU_SUBTYPE_I386_ALL; + + cputype |= CPU_ARCH_ABI64; + } + } + } +#elif defined (__linux__) + g_host_arch.SetArch(7u, 144u); +#endif + } + return g_host_arch; +} + +const ConstString & +Host::GetVendorString() +{ + static ConstString g_vendor; + if (!g_vendor) + { +#if defined (__APPLE__) + char ostype[64]; + size_t len = sizeof(ostype); + if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0) + g_vendor.SetCString (ostype); + else + g_vendor.SetCString("apple"); +#elif defined (__linux__) + g_vendor.SetCString("gnu"); +#endif + } + return g_vendor; +} + +const ConstString & +Host::GetOSString() +{ + static ConstString g_os_string; + if (!g_os_string) + { +#if defined (__APPLE__) + g_os_string.SetCString("darwin"); +#elif defined (__linux__) + g_os_string.SetCString("linux"); +#endif + } + return g_os_string; +} + +const ConstString & +Host::GetTargetTriple() +{ + static ConstString g_host_triple; + if (!(g_host_triple)) + { + StreamString triple; + triple.Printf("%s-%s-%s", + GetArchitecture().AsCString(), + GetVendorString().AsCString(), + GetOSString().AsCString()); + + std::transform (triple.GetString().begin(), + triple.GetString().end(), + triple.GetString().begin(), + ::tolower); + + g_host_triple.SetCString(triple.GetString().c_str()); + } + return g_host_triple; +} + +lldb::pid_t +Host::GetCurrentProcessID() +{ + return ::getpid(); +} + +lldb::tid_t +Host::GetCurrentThreadID() +{ +#if defined (__APPLE__) + return ::mach_thread_self(); +#else + return lldb::tid_t(pthread_self()); +#endif +} + +const char * +Host::GetSignalAsCString (int signo) +{ + switch (signo) + { + case SIGHUP: return "SIGHUP"; // 1 hangup + case SIGINT: return "SIGINT"; // 2 interrupt + case SIGQUIT: return "SIGQUIT"; // 3 quit + case SIGILL: return "SIGILL"; // 4 illegal instruction (not reset when caught) + case SIGTRAP: return "SIGTRAP"; // 5 trace trap (not reset when caught) + case SIGABRT: return "SIGABRT"; // 6 abort() +#if defined(_POSIX_C_SOURCE) + case SIGPOLL: return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported) +#else // !_POSIX_C_SOURCE + case SIGEMT: return "SIGEMT"; // 7 EMT instruction +#endif // !_POSIX_C_SOURCE + case SIGFPE: return "SIGFPE"; // 8 floating point exception + case SIGKILL: return "SIGKILL"; // 9 kill (cannot be caught or ignored) + case SIGBUS: return "SIGBUS"; // 10 bus error + case SIGSEGV: return "SIGSEGV"; // 11 segmentation violation + case SIGSYS: return "SIGSYS"; // 12 bad argument to system call + case SIGPIPE: return "SIGPIPE"; // 13 write on a pipe with no one to read it + case SIGALRM: return "SIGALRM"; // 14 alarm clock + case SIGTERM: return "SIGTERM"; // 15 software termination signal from kill + case SIGURG: return "SIGURG"; // 16 urgent condition on IO channel + case SIGSTOP: return "SIGSTOP"; // 17 sendable stop signal not from tty + case SIGTSTP: return "SIGTSTP"; // 18 stop signal from tty + case SIGCONT: return "SIGCONT"; // 19 continue a stopped process + case SIGCHLD: return "SIGCHLD"; // 20 to parent on child stop or exit + case SIGTTIN: return "SIGTTIN"; // 21 to readers pgrp upon background tty read + case SIGTTOU: return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local<OSTOP) +#if !defined(_POSIX_C_SOURCE) + case SIGIO: return "SIGIO"; // 23 input/output possible signal +#endif + case SIGXCPU: return "SIGXCPU"; // 24 exceeded CPU time limit + case SIGXFSZ: return "SIGXFSZ"; // 25 exceeded file size limit + case SIGVTALRM: return "SIGVTALRM"; // 26 virtual time alarm + case SIGPROF: return "SIGPROF"; // 27 profiling time alarm +#if !defined(_POSIX_C_SOURCE) + case SIGWINCH: return "SIGWINCH"; // 28 window size changes + case SIGINFO: return "SIGINFO"; // 29 information request +#endif + case SIGUSR1: return "SIGUSR1"; // 30 user defined signal 1 + case SIGUSR2: return "SIGUSR2"; // 31 user defined signal 2 + default: + break; + } + return NULL; +} + +void +Host::WillTerminate () +{ +} + +#if !defined (__APPLE__) // see macosx/Host.mm +void +Host::ThreadCreated (const char *thread_name) +{ +} +#endif + +struct HostThreadCreateInfo +{ + std::string thread_name; + thread_func_t thread_fptr; + thread_arg_t thread_arg; + + HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) : + thread_name (name ? name : ""), + thread_fptr (fptr), + thread_arg (arg) + { + } +}; + +static thread_result_t +ThreadCreateTrampoline (thread_arg_t arg) +{ + HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg; + Host::ThreadCreated (info->thread_name.c_str()); + thread_func_t thread_fptr = info->thread_fptr; + thread_arg_t thread_arg = info->thread_arg; + + Log * log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD); + if (log) + log->Printf("thread created"); + + delete info; + return thread_fptr (thread_arg); +} + +lldb::thread_t +Host::ThreadCreate +( + const char *thread_name, + thread_func_t thread_fptr, + thread_arg_t thread_arg, + Error *error +) +{ + lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; + + // Host::ThreadCreateTrampoline will delete this pointer for us. + HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg); + + int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr); + if (err == 0) + { + if (error) + error->Clear(); + return thread; + } + + if (error) + error->SetError (err, eErrorTypePOSIX); + + return LLDB_INVALID_HOST_THREAD; +} + +bool +Host::ThreadCancel (lldb::thread_t thread, Error *error) +{ + int err = ::pthread_cancel (thread); + if (error) + error->SetError(err, eErrorTypePOSIX); + return err == 0; +} + +bool +Host::ThreadDetach (lldb::thread_t thread, Error *error) +{ + int err = ::pthread_detach (thread); + if (error) + error->SetError(err, eErrorTypePOSIX); + return err == 0; +} + +bool +Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error) +{ + int err = ::pthread_join (thread, thread_result_ptr); + if (error) + error->SetError(err, eErrorTypePOSIX); + return err == 0; +} + +//------------------------------------------------------------------ +// Control access to a static file thread name map using a single +// static function to avoid a static constructor. +//------------------------------------------------------------------ +static const char * +ThreadNameAccessor (bool get, lldb::pid_t pid, lldb::tid_t tid, const char *name) +{ + uint64_t pid_tid = ((uint64_t)pid << 32) | (uint64_t)tid; + + static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; + Mutex::Locker locker(&g_mutex); + + typedef std::map thread_name_map; + // rdar://problem/8153284 + // Fixed a crasher where during shutdown, loggings attempted to access the + // thread name but the static map instance had already been destructed. + // Another approach is to introduce a static guard object which monitors its + // own destruction and raises a flag, but this incurs more overhead. + static thread_name_map *g_thread_names_ptr = new thread_name_map(); + thread_name_map &g_thread_names = *g_thread_names_ptr; + + if (get) + { + // See if the thread name exists in our thread name pool + thread_name_map::iterator pos = g_thread_names.find(pid_tid); + if (pos != g_thread_names.end()) + return pos->second.c_str(); + } + else + { + // Set the thread name + g_thread_names[pid_tid] = name; + } + return NULL; +} + +const char * +Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid) +{ + const char *name = ThreadNameAccessor (true, pid, tid, NULL); + if (name == NULL) + { +#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 + // We currently can only get the name of a thread in the current process. + if (pid == Host::GetCurrentProcessID()) + { + char pthread_name[1024]; + if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0) + { + if (pthread_name[0]) + { + // Set the thread in our string pool + ThreadNameAccessor (false, pid, tid, pthread_name); + // Get our copy of the thread name string + name = ThreadNameAccessor (true, pid, tid, NULL); + } + } + } +#endif + } + return name; +} + +void +Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name) +{ + lldb::pid_t curr_pid = Host::GetCurrentProcessID(); + lldb::tid_t curr_tid = Host::GetCurrentThreadID(); + if (pid == LLDB_INVALID_PROCESS_ID) + pid = curr_pid; + + if (tid == LLDB_INVALID_THREAD_ID) + tid = curr_tid; + +#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 + // Set the pthread name if possible + if (pid == curr_pid && tid == curr_tid) + { + ::pthread_setname_np (name); + } +#endif + ThreadNameAccessor (false, pid, tid, name); +} + +FileSpec +Host::GetProgramFileSpec () +{ + static FileSpec g_program_filespec; + if (!g_program_filespec) + { +#if defined (__APPLE__) + char program_fullpath[PATH_MAX]; + // If DST is NULL, then return the number of bytes needed. + uint32_t len = sizeof(program_fullpath); + int err = _NSGetExecutablePath (program_fullpath, &len); + if (err == 0) + g_program_filespec.SetFile (program_fullpath); + else if (err == -1) + { + char *large_program_fullpath = (char *)::malloc (len + 1); + + err = _NSGetExecutablePath (large_program_fullpath, &len); + if (err == 0) + g_program_filespec.SetFile (large_program_fullpath); + + ::free (large_program_fullpath); + } +#elif defined (__linux__) + char exe_path[PATH_MAX]; + ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path)); + if (len >= 0) + g_program_filespec = FileSpec(exe_path); +#elif defined (__FreeBSD__) + int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() }; + size_t exe_path_size; + if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0) + { + char *exe_path = new char[exe_path_size]; + if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0) + g_program_filespec = FileSpec(exe_path); + } +#endif + } + return g_program_filespec; +} + +FileSpec +Host::GetModuleFileSpecForHostAddress (const void *host_addr) +{ + FileSpec module_filespec; + Dl_info info; + if (::dladdr (host_addr, &info)) + { + if (info.dli_fname) + module_filespec.SetFile(info.dli_fname); + } + return module_filespec; +} + +#if !defined (__APPLE__) // see Host.mm +bool +Host::ResolveExecutableInBundle (FileSpec *file) +{ + return false; +} +#endif + +uint32_t +Host::ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids) +{ + uint32_t num_matches = 0; + +#if defined (__APPLE__) + int num_pids; + int size_of_pids; + int *pid_list; + + size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); + if (size_of_pids == -1) + return 0; + + num_pids = size_of_pids/sizeof(int); + pid_list = (int *) malloc(size_of_pids); + size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, pid_list, size_of_pids); + if (size_of_pids == -1) + return 0; + + lldb::pid_t our_pid = getpid(); + + for (int i = 0; i < num_pids; i++) + { + struct proc_bsdinfo bsd_info; + int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); + if (error == 0) + continue; + + // Don't offer to attach to zombie processes, already traced or exiting + // processes, and of course, ourselves... It looks like passing the second arg of + // 0 to proc_listpids will exclude zombies anyway, but that's not documented so... + if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0) + || (bsd_info.pbi_status == SZOMB) + || (bsd_info.pbi_pid == our_pid)) + continue; + char pid_name[MAXCOMLEN * 2 + 1]; + int name_len; + name_len = proc_name(bsd_info.pbi_pid, pid_name, MAXCOMLEN * 2); + if (name_len == 0) + continue; + + if (strstr(pid_name, name) != pid_name) + continue; + matches.AppendString (pid_name); + pids.push_back (bsd_info.pbi_pid); + num_matches++; + } +#endif + + return num_matches; +} + +ArchSpec +Host::GetArchSpecForExistingProcess (lldb::pid_t pid) +{ + ArchSpec return_spec; + +#if defined (__APPLE__) + struct proc_bsdinfo bsd_info; + int error = proc_pidinfo (pid, PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); + if (error == 0) + return return_spec; + if (bsd_info.pbi_flags & PROC_FLAG_LP64) + return_spec.SetArch(LLDB_ARCH_DEFAULT_64BIT); + else + return_spec.SetArch(LLDB_ARCH_DEFAULT_32BIT); +#endif + + return return_spec; +} + +ArchSpec +Host::GetArchSpecForExistingProcess (const char *process_name) +{ + ArchSpec returnSpec; + StringList matches; + std::vector pids; + if (ListProcessesMatchingName(process_name, matches, pids)) + { + if (matches.GetSize() == 1) + { + return GetArchSpecForExistingProcess(pids[0]); + } + } + return returnSpec; +} + +#if !defined (__APPLE__) // see macosx/Host.mm +bool +Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) +{ + return false; +} +#endif Added: lldb/trunk/source/Host/common/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Makefile?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Makefile (added) +++ lldb/trunk/source/Host/common/Makefile Tue Sep 7 15:11:56 2010 @@ -0,0 +1,14 @@ +##===- source/Host/common/Makefile -------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../.. +LIBRARYNAME := lldbHostCommon +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Host/common/Mutex.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Mutex.cpp?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Mutex.cpp (added) +++ lldb/trunk/source/Host/common/Mutex.cpp Tue Sep 7 15:11:56 2010 @@ -0,0 +1,252 @@ +//===-- Mutex.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/Host/Mutex.h" + +#if 0 +// This logging is way too verbose to enable even for a log channel. +// This logging can be enabled by changing the "#if 0", but should be +// reverted prior to checking in. +#include +#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__) +#else +#define DEBUG_LOG(fmt, ...) +#endif + +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Default constructor. +// +// This will create a scoped mutex locking object that doesn't have +// a mutex to lock. One will need to be provided using the Reset() +// method. +//---------------------------------------------------------------------- +Mutex::Locker::Locker () : + m_mutex_ptr(NULL) +{ +} + +//---------------------------------------------------------------------- +// Constructor with a Mutex object. +// +// This will create a scoped mutex locking object that extracts the +// mutex owned by "m" and locks it. +//---------------------------------------------------------------------- +Mutex::Locker::Locker (Mutex& m) : + m_mutex_ptr(m.GetMutex()) +{ + if (m_mutex_ptr) + Mutex::Lock (m_mutex_ptr); +} + +//---------------------------------------------------------------------- +// Constructor with a Mutex object pointer. +// +// This will create a scoped mutex locking object that extracts the +// mutex owned by "m" and locks it. +//---------------------------------------------------------------------- +Mutex::Locker::Locker (Mutex* m) : + m_mutex_ptr(m ? m->GetMutex() : NULL) +{ + if (m_mutex_ptr) + Mutex::Lock (m_mutex_ptr); +} + +//---------------------------------------------------------------------- +// Constructor with a raw pthread mutex object pointer. +// +// This will create a scoped mutex locking object that locks "mutex" +//---------------------------------------------------------------------- +Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) : + m_mutex_ptr(mutex_ptr) +{ + if (m_mutex_ptr) + Mutex::Lock (m_mutex_ptr); +} + +//---------------------------------------------------------------------- +// Desstructor +// +// Unlocks any owned mutex object (if it is valid). +//---------------------------------------------------------------------- +Mutex::Locker::~Locker () +{ + Reset(); +} + +//---------------------------------------------------------------------- +// Unlock the current mutex in this object (if this owns a valid +// mutex) and lock the new "mutex" object if it is non-NULL. +//---------------------------------------------------------------------- +void +Mutex::Locker::Reset (pthread_mutex_t *mutex_ptr) +{ + // We already have this mutex locked or both are NULL... + if (m_mutex_ptr == mutex_ptr) + return; + + if (m_mutex_ptr) + Mutex::Unlock (m_mutex_ptr); + + m_mutex_ptr = mutex_ptr; + if (m_mutex_ptr) + Mutex::Lock (m_mutex_ptr); +} + +bool +Mutex::Locker::TryLock (pthread_mutex_t *mutex_ptr) +{ + // We already have this mutex locked! + if (m_mutex_ptr == mutex_ptr) + return true; + + Reset (); + + if (mutex_ptr) + { + if (Mutex::TryLock (mutex_ptr) == 0) + m_mutex_ptr = mutex_ptr; + } + return m_mutex_ptr != NULL; +} + +//---------------------------------------------------------------------- +// Default constructor. +// +// Creates a pthread mutex with no attributes. +//---------------------------------------------------------------------- +Mutex::Mutex () : + m_mutex() +{ + int err; + err = ::pthread_mutex_init (&m_mutex, NULL); + assert(err == 0); +} + +//---------------------------------------------------------------------- +// Default constructor. +// +// Creates a pthread mutex with "type" as the mutex type. +//---------------------------------------------------------------------- +Mutex::Mutex (Mutex::Type type) : + m_mutex() +{ + int err; + ::pthread_mutexattr_t attr; + err = ::pthread_mutexattr_init (&attr); + assert(err == 0); + switch (type) + { + case eMutexTypeNormal: + err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL); + break; + + case eMutexTypeRecursive: + err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + break; + + default: + err = -1; + break; + } + assert(err == 0); + err = ::pthread_mutex_init (&m_mutex, &attr); + assert(err == 0); + err = ::pthread_mutexattr_destroy (&attr); + assert(err == 0); +} + +//---------------------------------------------------------------------- +// Destructor. +// +// Destroys the mutex owned by this object. +//---------------------------------------------------------------------- +Mutex::~Mutex() +{ + int err; + err = ::pthread_mutex_destroy (&m_mutex); +} + +//---------------------------------------------------------------------- +// Mutex get accessor. +//---------------------------------------------------------------------- +pthread_mutex_t * +Mutex::GetMutex() +{ + return &m_mutex; +} + +int +Mutex::Lock (pthread_mutex_t *mutex_ptr) +{ + DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr); + int err = ::pthread_mutex_lock (mutex_ptr); + DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err); + return err; +} + +int +Mutex::TryLock (pthread_mutex_t *mutex_ptr) +{ + int err = ::pthread_mutex_trylock (mutex_ptr); + DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_trylock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err); + return err; +} + +int +Mutex::Unlock (pthread_mutex_t *mutex_ptr) +{ + int err = ::pthread_mutex_unlock (mutex_ptr); + DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_unlock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err); + return err; +} + +//---------------------------------------------------------------------- +// Locks the mutex owned by this object, if the mutex is already +// locked, the calling thread will block until the mutex becomes +// available. +// +// RETURNS +// The error code from the pthread_mutex_lock() function call. +//---------------------------------------------------------------------- +int +Mutex::Lock() +{ + return Mutex::Lock (&m_mutex); +} + +//---------------------------------------------------------------------- +// Attempts to lock the mutex owned by this object without blocking. +// If the mutex is already locked, TryLock() will not block waiting +// for the mutex, but will return an error condition. +// +// RETURNS +// The error code from the pthread_mutex_trylock() function call. +//---------------------------------------------------------------------- +int +Mutex::TryLock() +{ + return Mutex::TryLock (&m_mutex); +} + +//---------------------------------------------------------------------- +// If the current thread holds the lock on the owned mutex, then +// Unlock() will unlock the mutex. Calling Unlock() on this object +// that the calling thread does not hold will result in undefined +// behavior. +// +// RETURNS +// The error code from the pthread_mutex_unlock() function call. +//---------------------------------------------------------------------- +int +Mutex::Unlock() +{ + return Mutex::Unlock (&m_mutex); +} Added: lldb/trunk/source/Host/common/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Symbols.cpp (added) +++ lldb/trunk/source/Host/common/Symbols.cpp Tue Sep 7 15:11:56 2010 @@ -0,0 +1,31 @@ +//===-- Symbols.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/Host/Symbols.h" + +using namespace lldb; +using namespace lldb_private; + +#if !defined (__APPLE__) + +FileSpec +Symbols::LocateExecutableObjectFile (const FileSpec *exec_fspec, const ArchSpec* arch, const UUID *uuid) +{ + // FIXME + return FileSpec(); +} + +FileSpec +Symbols::LocateExecutableSymbolFile (const FileSpec *exec_fspec, const ArchSpec* arch, const UUID *uuid) +{ + // FIXME + return FileSpec(); +} + +#endif Added: lldb/trunk/source/Host/common/TimeValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=113263&view=auto ============================================================================== --- lldb/trunk/source/Host/common/TimeValue.cpp (added) +++ lldb/trunk/source/Host/common/TimeValue.cpp Tue Sep 7 15:11:56 2010 @@ -0,0 +1,180 @@ +//===-- TimeValue.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/Host/TimeValue.h" +#include + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +#define NSEC_PER_USEC 1000ull +#define USEC_PER_SEC 1000000ull +#define NSEC_PER_SEC 1000000000ull + +using namespace lldb_private; + +//---------------------------------------------------------------------- +// TimeValue constructor +//---------------------------------------------------------------------- +TimeValue::TimeValue() : + m_nano_seconds (0) +{ +} + +//---------------------------------------------------------------------- +// TimeValue copy constructor +//---------------------------------------------------------------------- +TimeValue::TimeValue(const TimeValue& rhs) : + m_nano_seconds (rhs.m_nano_seconds) +{ +} + +TimeValue::TimeValue(const struct timespec& ts) : + m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec) +{ +} + +TimeValue::TimeValue(const struct timeval& tv) : + m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC) +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +TimeValue::~TimeValue() +{ +} + + +uint64_t +TimeValue::GetAsNanoSecondsSinceJan1_1970() const +{ + return m_nano_seconds; +} + +uint64_t +TimeValue::GetAsMicroSecondsSinceJan1_1970() const +{ + return m_nano_seconds / NSEC_PER_USEC; +} + +struct timespec +TimeValue::GetAsTimeSpec () const +{ + struct timespec ts; + ts.tv_sec = m_nano_seconds / NSEC_PER_SEC; + ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC; + return ts; +} + +struct timeval +TimeValue::GetAsTimeVal () const +{ + struct timeval tv; + tv.tv_sec = m_nano_seconds / NSEC_PER_SEC; + tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC; + return tv; +} + +void +TimeValue::Clear () +{ + m_nano_seconds = 0; +} + +bool +TimeValue::IsValid () const +{ + return m_nano_seconds != 0; +} + +void +TimeValue::OffsetWithSeconds (uint64_t sec) +{ + m_nano_seconds += sec * NSEC_PER_SEC; +} + +void +TimeValue::OffsetWithMicroSeconds (uint64_t usec) +{ + m_nano_seconds += usec * NSEC_PER_USEC; +} + +void +TimeValue::OffsetWithNanoSeconds (uint64_t nsec) +{ + m_nano_seconds += nsec; +} + +TimeValue +TimeValue::Now() +{ + struct timeval tv; + gettimeofday(&tv, NULL); + TimeValue now(tv); + return now; +} + +//---------------------------------------------------------------------- +// TimeValue assignment operator +//---------------------------------------------------------------------- +const TimeValue& +TimeValue::operator=(const TimeValue& rhs) +{ + m_nano_seconds = rhs.m_nano_seconds; + return *this; +} + + +bool +lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +bool +lldb_private::operator != (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() != rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +bool +lldb_private::operator < (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() < rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +bool +lldb_private::operator <= (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() <= rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +bool +lldb_private::operator > (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() > rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +bool +lldb_private::operator >= (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() >= rhs.GetAsNanoSecondsSinceJan1_1970(); +} + +uint64_t +lldb_private::operator - (const TimeValue &lhs, const TimeValue &rhs) +{ + return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970(); +} + + Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=113263&r1=113262&r2=113263&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Sep 7 15:11:56 2010 @@ -7,163 +7,22 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include +#include "lldb/Host/Host.h" +#include "lldb/Core/FileSpec.h" +#include "lldb/Core/Log.h" #include "cfcpp/CFCBundle.h" #include "cfcpp/CFCReleaser.h" #include "cfcpp/CFCString.h" -#include "lldb/Host/Host.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Error.h" -#include "lldb/Core/FileSpec.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Host/Mutex.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/TargetList.h" -#include "lldb/lldb-private-log.h" +#include + +#include +#include using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------ -// Return the size in bytes of a page on the host system -//------------------------------------------------------------------ -size_t -Host::GetPageSize() -{ - return ::getpagesize(); -} - - -//------------------------------------------------------------------ -// Returns true if the host system is Big Endian. -//------------------------------------------------------------------ -ByteOrder -Host::GetByteOrder() -{ - union EndianTest - { - uint32_t num; - uint8_t bytes[sizeof(uint32_t)]; - } endian = { (uint16_t)0x11223344 }; - switch (endian.bytes[0]) - { - case 0x11: return eByteOrderLittle; - case 0x44: return eByteOrderBig; - case 0x33: return eByteOrderPDP; - } - return eByteOrderInvalid; -} - -lldb::pid_t -Host::GetCurrentProcessID() -{ - return ::getpid(); -} - -lldb::pid_t -Host::GetCurrentThreadID() -{ - return ::mach_thread_self(); -} - - -const ArchSpec & -Host::GetArchitecture () -{ - static ArchSpec g_host_arch; - if (!g_host_arch.IsValid()) - { - uint32_t cputype, cpusubtype; - uint32_t is_64_bit_capable; - size_t len = sizeof(cputype); - if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) - { - len = sizeof(cpusubtype); - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - g_host_arch.SetArch(cputype, cpusubtype); - - len = sizeof (is_64_bit_capable); - if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0) - { - if (is_64_bit_capable) - { - if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486) - cpusubtype = CPU_SUBTYPE_I386_ALL; - - cputype |= CPU_ARCH_ABI64; - } - } - } - } - return g_host_arch; -} - -const ConstString & -Host::GetVendorString() -{ - static ConstString g_vendor; - if (!g_vendor) - { - char ostype[64]; - size_t len = sizeof(ostype); - if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0) - g_vendor.SetCString (ostype); - } - return g_vendor; -} - -const ConstString & -Host::GetOSString() -{ - static ConstString g_os_string("apple"); - return g_os_string; -} - -const ConstString & -Host::GetTargetTriple() -{ - static ConstString g_host_triple; - if (!(g_host_triple)) - { - StreamString triple; - triple.Printf("%s-%s-%s", - GetArchitecture ().AsCString(), - GetVendorString().AsCString("apple"), - GetOSString().AsCString("darwin")); - - std::transform (triple.GetString().begin(), - triple.GetString().end(), - triple.GetString().begin(), - ::tolower); - - g_host_triple.SetCString(triple.GetString().c_str()); - } - return g_host_triple; -} - class MacOSXDarwinThread { public: @@ -217,92 +76,6 @@ ::pthread_key_create (&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor); } -struct HostThreadCreateInfo -{ - std::string thread_name; - thread_func_t thread_fptr; - thread_arg_t thread_arg; - - HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) : - thread_name (name ? name : ""), - thread_fptr (fptr), - thread_arg (arg) - { - } -}; - -static thread_result_t -ThreadCreateTrampoline (thread_arg_t arg) -{ - HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg; - Host::ThreadCreated (info->thread_name.c_str()); - thread_func_t thread_fptr = info->thread_fptr; - thread_arg_t thread_arg = info->thread_arg; - - Log * log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD); - if (log) - log->Printf("thread created"); - - delete info; - return thread_fptr (thread_arg); -} - -lldb::thread_t -Host::ThreadCreate -( - const char *thread_name, - thread_func_t thread_fptr, - thread_arg_t thread_arg, - Error *error -) -{ - lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; - - // Host::ThreadCreateTrampoline will delete this pointer for us. - HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg); - - int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr); - if (err == 0) - { - if (error) - error->Clear(); - return thread; - } - - if (error) - error->SetError (err, eErrorTypePOSIX); - - return LLDB_INVALID_HOST_THREAD; -} - -bool -Host::ThreadCancel (lldb::thread_t thread, Error *error) -{ - - int err = ::pthread_cancel (thread); - if (error) - error->SetError(err, eErrorTypePOSIX); - return err == 0; -} - -bool -Host::ThreadDetach (lldb::thread_t thread, Error *error) -{ - int err = ::pthread_detach (thread); - if (error) - error->SetError(err, eErrorTypePOSIX); - return err == 0; -} - -bool -Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error) -{ - int err = ::pthread_join (thread, thread_result_ptr); - if (error) - error->SetError(err, eErrorTypePOSIX); - return err == 0; -} - void Host::ThreadCreated (const char *thread_name) { @@ -313,473 +86,30 @@ } } -//------------------------------------------------------------------ -// Control access to a static file thread name map using a single -// static function to avoid a static constructor. -//------------------------------------------------------------------ -static const char * -ThreadNameAccessor (bool get, lldb::pid_t pid, lldb::tid_t tid, const char *name) -{ - - uint64_t pid_tid = ((uint64_t)pid << 32) | (uint64_t)tid; - - static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; - Mutex::Locker locker(&g_mutex); - - typedef std::map thread_name_map; - // rdar://problem/8153284 - // Fixed a crasher where during shutdown, loggings attempted to access the - // thread name but the static map instance had already been destructed. - // Another approach is to introduce a static guard object which monitors its - // own destruction and raises a flag, but this incurs more overhead. - static thread_name_map *g_thread_names_ptr = new thread_name_map(); - thread_name_map &g_thread_names = *g_thread_names_ptr; - - if (get) - { - // See if the thread name exists in our thread name pool - thread_name_map::iterator pos = g_thread_names.find(pid_tid); - if (pos != g_thread_names.end()) - return pos->second.c_str(); - } - else - { - // Set the thread name - g_thread_names[pid_tid] = name; - } - return NULL; -} - - - -const char * -Host::GetSignalAsCString (int signo) -{ - switch (signo) - { - case SIGHUP: return "SIGHUP"; // 1 hangup - case SIGINT: return "SIGINT"; // 2 interrupt - case SIGQUIT: return "SIGQUIT"; // 3 quit - case SIGILL: return "SIGILL"; // 4 illegal instruction (not reset when caught) - case SIGTRAP: return "SIGTRAP"; // 5 trace trap (not reset when caught) - case SIGABRT: return "SIGABRT"; // 6 abort() -#if defined(_POSIX_C_SOURCE) - case SIGPOLL: return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported) -#else // !_POSIX_C_SOURCE - case SIGEMT: return "SIGEMT"; // 7 EMT instruction -#endif // !_POSIX_C_SOURCE - case SIGFPE: return "SIGFPE"; // 8 floating point exception - case SIGKILL: return "SIGKILL"; // 9 kill (cannot be caught or ignored) - case SIGBUS: return "SIGBUS"; // 10 bus error - case SIGSEGV: return "SIGSEGV"; // 11 segmentation violation - case SIGSYS: return "SIGSYS"; // 12 bad argument to system call - case SIGPIPE: return "SIGPIPE"; // 13 write on a pipe with no one to read it - case SIGALRM: return "SIGALRM"; // 14 alarm clock - case SIGTERM: return "SIGTERM"; // 15 software termination signal from kill - case SIGURG: return "SIGURG"; // 16 urgent condition on IO channel - case SIGSTOP: return "SIGSTOP"; // 17 sendable stop signal not from tty - case SIGTSTP: return "SIGTSTP"; // 18 stop signal from tty - case SIGCONT: return "SIGCONT"; // 19 continue a stopped process - case SIGCHLD: return "SIGCHLD"; // 20 to parent on child stop or exit - case SIGTTIN: return "SIGTTIN"; // 21 to readers pgrp upon background tty read - case SIGTTOU: return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local<OSTOP) -#if !defined(_POSIX_C_SOURCE) - case SIGIO: return "SIGIO"; // 23 input/output possible signal -#endif - case SIGXCPU: return "SIGXCPU"; // 24 exceeded CPU time limit - case SIGXFSZ: return "SIGXFSZ"; // 25 exceeded file size limit - case SIGVTALRM: return "SIGVTALRM"; // 26 virtual time alarm - case SIGPROF: return "SIGPROF"; // 27 profiling time alarm -#if !defined(_POSIX_C_SOURCE) - case SIGWINCH: return "SIGWINCH"; // 28 window size changes - case SIGINFO: return "SIGINFO"; // 29 information request -#endif - case SIGUSR1: return "SIGUSR1"; // 30 user defined signal 1 - case SIGUSR2: return "SIGUSR2"; // 31 user defined signal 2 - default: - break; - } - return NULL; -} - -const char * -Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid) -{ - const char *name = ThreadNameAccessor (true, pid, tid, NULL); - if (name == NULL) - { - // We currently can only get the name of a thread in the current process. -#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 - if (pid == Host::GetCurrentProcessID()) - { - char pthread_name[1024]; - if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0) - { - if (pthread_name[0]) - { - // Set the thread in our string pool - ThreadNameAccessor (false, pid, tid, pthread_name); - // Get our copy of the thread name string - name = ThreadNameAccessor (true, pid, tid, NULL); - } - } - } -#endif - } - return name; -} - -void -Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name) -{ - lldb::pid_t curr_pid = Host::GetCurrentProcessID(); - lldb::tid_t curr_tid = Host::GetCurrentThreadID(); - if (pid == LLDB_INVALID_PROCESS_ID) - pid = curr_pid; - - if (tid == LLDB_INVALID_THREAD_ID) - tid = curr_tid; - -#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 - // Set the pthread name if possible - if (pid == curr_pid && tid == curr_tid) - { - ::pthread_setname_np (name); - } -#endif - ThreadNameAccessor (false, pid, tid, name); -} - -FileSpec -Host::GetProgramFileSpec () -{ - static FileSpec g_program_filepsec; - if (!g_program_filepsec) - { - char program_fullpath[PATH_MAX]; - // If DST is NULL, then return the number of bytes needed. - uint32_t len = sizeof(program_fullpath); - int err = _NSGetExecutablePath (program_fullpath, &len); - if (err == 0) - g_program_filepsec.SetFile (program_fullpath); - else if (err == -1) - { - char *large_program_fullpath = (char *)::malloc (len + 1); - - err = _NSGetExecutablePath (large_program_fullpath, &len); - if (err == 0) - g_program_filepsec.SetFile (large_program_fullpath); - - ::free (large_program_fullpath); - } - } - return g_program_filepsec; -} - - -FileSpec -Host::GetModuleFileSpecForHostAddress (const void *host_addr) -{ - FileSpec module_filespec; - Dl_info info; - if (::dladdr (host_addr, &info)) - { - if (info.dli_fname) - module_filespec.SetFile(info.dli_fname); - } - return module_filespec; -} - bool Host::ResolveExecutableInBundle (FileSpec *file) { - if (file->GetFileType () == FileSpec::eFileTypeDirectory) - { - char path[PATH_MAX]; - if (file->GetPath(path, sizeof(path))) - { - CFCBundle bundle (path); - CFCReleaser url(bundle.CopyExecutableURL ()); - if (url.get()) - { - if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path))) - { - file->SetFile(path); - return true; - } - } - } - } - return false; -} - -struct MonitorInfo -{ - lldb::pid_t pid; // The process ID to monitor - Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals - void *callback_baton; // The callback baton for the callback function - bool monitor_signals; // If true, call the callback when "pid" gets signaled. -}; - -static void * -MonitorChildProcessThreadFunction (void *arg); - -lldb::thread_t -Host::StartMonitoringChildProcess -( - Host::MonitorChildProcessCallback callback, - void *callback_baton, - lldb::pid_t pid, - bool monitor_signals -) -{ - - lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; - if (callback) - { - std::auto_ptr info_ap(new MonitorInfo); - - info_ap->pid = pid; - info_ap->callback = callback; - info_ap->callback_baton = callback_baton; - info_ap->monitor_signals = monitor_signals; - - char thread_name[256]; - ::snprintf (thread_name, sizeof(thread_name), "", pid); - thread = ThreadCreate (thread_name, - MonitorChildProcessThreadFunction, - info_ap.get(), - NULL); - - if (thread != LLDB_INVALID_HOST_THREAD) - info_ap.release(); - } - return thread; -} - -//------------------------------------------------------------------ -// Scoped class that will disable thread canceling when it is -// constructed, and exception safely restore the previous value it -// when it goes out of scope. -//------------------------------------------------------------------ -class ScopedPThreadCancelDisabler -{ -public: - - ScopedPThreadCancelDisabler() - { - // Disable the ability for this thread to be cancelled - int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state); - if (err != 0) - m_old_state = -1; - - } - - ~ScopedPThreadCancelDisabler() - { - // Restore the ability for this thread to be cancelled to what it - // previously was. - if (m_old_state != -1) - ::pthread_setcancelstate (m_old_state, 0); - } -private: - int m_old_state; // Save the old cancelability state. -}; - - - -static void * -MonitorChildProcessThreadFunction (void *arg) -{ - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS); - const char *function = __FUNCTION__; - if (log) - log->Printf ("%s (arg = %p) thread starting...", function, arg); - - MonitorInfo *info = (MonitorInfo *)arg; - - const Host::MonitorChildProcessCallback callback = info->callback; - void * const callback_baton = info->callback_baton; - const lldb::pid_t pid = info->pid; - const bool monitor_signals = info->monitor_signals; - - delete info; - - int status = -1; - const int options = 0; - struct rusage *rusage = NULL; - while (1) - { - if (log) - log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage); - - // Wait for all child processes - ::pthread_testcancel (); - const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage); - ::pthread_testcancel (); - - if (wait_pid == -1) - { - if (errno == EINTR) - continue; - else - break; - } - else if (wait_pid == pid) - { - bool exited = false; - int signal = 0; - int exit_status = 0; - const char *status_cstr = NULL; - if (WIFSTOPPED(status)) - { - signal = WSTOPSIG(status); - status_cstr = "STOPPED"; - } - else if (WIFEXITED(status)) - { - exit_status = WEXITSTATUS(status); - status_cstr = "EXITED"; - exited = true; - } - else if (WIFSIGNALED(status)) - { - signal = WTERMSIG(status); - status_cstr = "SIGNALED"; - exited = true; - exit_status = -1; - } - else - { - status_cstr = "(???)"; - } - - // Scope for pthread_cancel_disabler - { - ScopedPThreadCancelDisabler pthread_cancel_disabler; - - if (log) - log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i", - function, - wait_pid, - options, - rusage, - pid, - status, - status_cstr, - signal, - exit_status); - - if (exited || (signal != 0 && monitor_signals)) - { - bool callback_return = callback (callback_baton, pid, signal, exit_status); - - // If our process exited, then this thread should exit - if (exited) - break; - // If the callback returns true, it means this process should - // exit - if (callback_return) - break; - } - } - } - } - - if (log) - log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg); - - return NULL; -} - -void -Host::WillTerminate () -{ -} - -uint32_t -Host::ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids) -{ - - int num_pids; - int size_of_pids; - int *pid_list; - uint32_t num_matches = 0; - - size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); - if (size_of_pids == -1) - return 0; - - num_pids = size_of_pids/sizeof(int); - pid_list = (int *) malloc(size_of_pids); - size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, pid_list, size_of_pids); - if (size_of_pids == -1) - return 0; - - lldb::pid_t our_pid = getpid(); - - for (int i = 0; i < num_pids; i++) - { - struct proc_bsdinfo bsd_info; - int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); - if (error == 0) - continue; - - // Don't offer to attach to zombie processes, already traced or exiting - // processes, and of course, ourselves... It looks like passing the second arg of - // 0 to proc_listpids will exclude zombies anyway, but that's not documented so... - if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0) - || (bsd_info.pbi_status == SZOMB) - || (bsd_info.pbi_pid == our_pid)) - continue; - char pid_name[MAXCOMLEN * 2 + 1]; - int name_len; - name_len = proc_name(bsd_info.pbi_pid, pid_name, MAXCOMLEN * 2); - if (name_len == 0) - continue; - - if (strstr(pid_name, name) != pid_name) - continue; - matches.AppendString (pid_name); - pids.push_back (bsd_info.pbi_pid); - num_matches++; - } - - return num_matches; -} - -ArchSpec -Host::GetArchSpecForExistingProcess (lldb::pid_t pid) -{ - ArchSpec return_spec; - - struct proc_bsdinfo bsd_info; - int error = proc_pidinfo (pid, PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE); - if (error == 0) - return return_spec; - if (bsd_info.pbi_flags & PROC_FLAG_LP64) - return_spec.SetArch(LLDB_ARCH_DEFAULT_64BIT); - else - return_spec.SetArch(LLDB_ARCH_DEFAULT_32BIT); - - return return_spec; -} - -ArchSpec -Host::GetArchSpecForExistingProcess (const char *process_name) -{ - ArchSpec returnSpec; - StringList matches; - std::vector pids; - if (ListProcessesMatchingName(process_name, matches, pids)) - { - if (matches.GetSize() == 1) +#if defined (__APPLE__) + if (file->GetFileType () == FileSpec::eFileTypeDirectory) + { + char path[PATH_MAX]; + if (file->GetPath(path, sizeof(path))) + { + CFCBundle bundle (path); + CFCReleaser url(bundle.CopyExecutableURL ()); + if (url.get()) + { + if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path))) { - return GetArchSpecForExistingProcess(pids[0]); + file->SetFile(path); + return true; } + } } - return returnSpec; + } +#endif + return false; } bool Removed: lldb/trunk/source/Host/macosx/TimeValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/TimeValue.cpp?rev=113262&view=auto ============================================================================== --- lldb/trunk/source/Host/macosx/TimeValue.cpp (original) +++ lldb/trunk/source/Host/macosx/TimeValue.cpp (removed) @@ -1,180 +0,0 @@ -//===-- TimeValue.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/Host/TimeValue.h" -#include - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes - -#define NSEC_PER_USEC 1000ull -#define USEC_PER_SEC 1000000ull -#define NSEC_PER_SEC 1000000000ull - -using namespace lldb_private; - -//---------------------------------------------------------------------- -// TimeValue constructor -//---------------------------------------------------------------------- -TimeValue::TimeValue() : - m_nano_seconds (0) -{ -} - -//---------------------------------------------------------------------- -// TimeValue copy constructor -//---------------------------------------------------------------------- -TimeValue::TimeValue(const TimeValue& rhs) : - m_nano_seconds (rhs.m_nano_seconds) -{ -} - -TimeValue::TimeValue(const struct timespec& ts) : - m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec) -{ -} - -TimeValue::TimeValue(const struct timeval& tv) : - m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -TimeValue::~TimeValue() -{ -} - - -uint64_t -TimeValue::GetAsNanoSecondsSinceJan1_1970() const -{ - return m_nano_seconds; -} - -uint64_t -TimeValue::GetAsMicroSecondsSinceJan1_1970() const -{ - return m_nano_seconds / NSEC_PER_USEC; -} - -struct timespec -TimeValue::GetAsTimeSpec () const -{ - struct timespec ts; - ts.tv_sec = m_nano_seconds / NSEC_PER_SEC; - ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC; - return ts; -} - -struct timeval -TimeValue::GetAsTimeVal () const -{ - struct timeval tv; - tv.tv_sec = m_nano_seconds / NSEC_PER_SEC; - tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC; - return tv; -} - -void -TimeValue::Clear () -{ - m_nano_seconds = 0; -} - -bool -TimeValue::IsValid () const -{ - return m_nano_seconds != 0; -} - -void -TimeValue::OffsetWithSeconds (uint64_t sec) -{ - m_nano_seconds += sec * NSEC_PER_SEC; -} - -void -TimeValue::OffsetWithMicroSeconds (uint64_t usec) -{ - m_nano_seconds += usec * NSEC_PER_USEC; -} - -void -TimeValue::OffsetWithNanoSeconds (uint64_t nsec) -{ - m_nano_seconds += nsec; -} - -TimeValue -TimeValue::Now() -{ - struct timeval tv; - gettimeofday(&tv, NULL); - TimeValue now(tv); - return now; -} - -//---------------------------------------------------------------------- -// TimeValue assignment operator -//---------------------------------------------------------------------- -const TimeValue& -TimeValue::operator=(const TimeValue& rhs) -{ - m_nano_seconds = rhs.m_nano_seconds; - return *this; -} - - -bool -lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -bool -lldb_private::operator != (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() != rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -bool -lldb_private::operator < (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() < rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -bool -lldb_private::operator <= (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() <= rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -bool -lldb_private::operator > (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() > rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -bool -lldb_private::operator >= (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() >= rhs.GetAsNanoSecondsSinceJan1_1970(); -} - -uint64_t -lldb_private::operator - (const TimeValue &lhs, const TimeValue &rhs) -{ - return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970(); -} - - From jingham at apple.com Tue Sep 7 15:27:09 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 07 Sep 2010 20:27:09 -0000 Subject: [Lldb-commits] [lldb] r113268 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp Message-ID: <20100907202709.49BDF2A6C12C@llvm.org> Author: jingham Date: Tue Sep 7 15:27:09 2010 New Revision: 113268 URL: http://llvm.org/viewvc/llvm-project?rev=113268&view=rev Log: Move common code from GetSettingsController in Process & Debugger into static functions in UserSettingsController.cpp. Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113268&r1=113267&r2=113268&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Tue Sep 7 15:27:09 2010 @@ -196,6 +196,15 @@ const char *new_value, Error &err); + static bool + InitializeSettingsController (lldb::UserSettingsControllerSP &controller_sp, + SettingEntry *global_settings, + SettingEntry *instance_settings); + + static void + FinalizeSettingsController (lldb::UserSettingsControllerSP &controller_sp); + + protected: // ------------------------------------------------------------------------- Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113268&r1=113267&r2=113268&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Sep 7 15:27:09 2010 @@ -542,18 +542,9 @@ if (!initialized) { - UserSettingsControllerSP parent = g_settings_controller->GetParent(); - if (parent) - parent->RegisterChild (g_settings_controller); - - g_settings_controller->CreateSettingsVector (Debugger::DebuggerSettingsController::global_settings_table, - true); - g_settings_controller->CreateSettingsVector (Debugger::DebuggerSettingsController::instance_settings_table, - false); - - g_settings_controller->InitializeGlobalVariables (); - g_settings_controller->CreateDefaultInstanceSettings (); - initialized = true; + initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, + Debugger::DebuggerSettingsController::global_settings_table, + Debugger::DebuggerSettingsController::instance_settings_table); } if (finish) Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113268&r1=113267&r2=113268&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Tue Sep 7 15:27:09 2010 @@ -38,6 +38,32 @@ m_live_settings.clear(); } +bool +UserSettingsController::InitializeSettingsController (lldb::UserSettingsControllerSP &controller_sp, + SettingEntry *global_settings, + SettingEntry *instance_settings) +{ + const lldb::UserSettingsControllerSP &parent = controller_sp->GetParent (); + if (parent) + parent->RegisterChild (controller_sp); + + controller_sp->CreateSettingsVector (global_settings, true); + controller_sp->CreateSettingsVector (instance_settings, false); + + controller_sp->InitializeGlobalVariables (); + controller_sp->CreateDefaultInstanceSettings (); + + return true; +} + +void +UserSettingsController::FinalizeSettingsController (lldb::UserSettingsControllerSP &controller_sp) +{ + const lldb::UserSettingsControllerSP &parent = controller_sp->GetParent (); + if (parent) + parent->RemoveChild (controller_sp); +} + void UserSettingsController::InitializeGlobalVariables () { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113268&r1=113267&r2=113268&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Sep 7 15:27:09 2010 @@ -1929,26 +1929,16 @@ if (!initialized) { - const lldb::UserSettingsControllerSP &parent = g_settings_controller->GetParent (); - if (parent) - parent->RegisterChild (g_settings_controller); - - g_settings_controller->CreateSettingsVector (Process::ProcessSettingsController::global_settings_table, - true); - g_settings_controller->CreateSettingsVector (Process::ProcessSettingsController::instance_settings_table, - false); - - g_settings_controller->InitializeGlobalVariables (); - g_settings_controller->CreateDefaultInstanceSettings (); - initialized = true; + initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, + Process::ProcessSettingsController::global_settings_table, + Process::ProcessSettingsController::instance_settings_table); } if (finish) { - const lldb::UserSettingsControllerSP &parent = g_settings_controller->GetParent (); - if (parent) - parent->RemoveChild (g_settings_controller); + UserSettingsController::FinalizeSettingsController (g_settings_controller); g_settings_controller.reset(); + initialized = false; } return g_settings_controller; From scallanan at apple.com Tue Sep 7 16:23:34 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 07 Sep 2010 21:23:34 -0000 Subject: [Lldb-commits] [lldb] r113288 - in /lldb/trunk/source/Plugins/ABI: MacOSX-i386/ABIMacOSX_i386.cpp SysV-x86_64/ABISysV_x86_64.cpp Message-ID: <20100907212334.768EE2A6C12C@llvm.org> Author: spyffe Date: Tue Sep 7 16:23:34 2010 New Revision: 113288 URL: http://llvm.org/viewvc/llvm-project?rev=113288&view=rev Log: Updated the x86_64 and i386 ABIs to chain RBP (i.e., leave the value the same, so that a new stack frame will be linked to the previous stack) rather than zeroing out RBP. This fixes calls to dlopen(), for example, which does a backtrace to see which image is calling it. Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=113288&r1=113287&r2=113288&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Sep 7 16:23:34 2010 @@ -61,9 +61,12 @@ { RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) - return false; - + return false; +#define CHAIN_EBP + +#ifndef CHAIN_EBP uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); +#endif uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); @@ -94,10 +97,12 @@ if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp)) return false; +#ifndef CHAIN_EBP // %ebp is set to a fake value, in our case 0x0x00000000 if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000)) return false; +#endif // %eip is set to the address of the called function. Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=113288&r1=113287&r2=113288&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Sep 7 16:23:34 2010 @@ -64,7 +64,12 @@ return false; uint32_t rdiID = reg_ctx->GetRegisterInfoByName("rdi", 0)->reg; +#define CHAIN_RBP + +#ifndef CHAIN_RBP uint32_t rbpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); +#endif + uint32_t ripID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); uint32_t rspID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); @@ -90,10 +95,12 @@ if (!reg_ctx->WriteRegisterFromUnsigned(rspID, sp)) return false; +#ifndef CHAIN_RBP // %rbp is set to a fake value, in our case 0x0000000000000000. if (!reg_ctx->WriteRegisterFromUnsigned(rbpID, 0x000000000000000)) return false; +#endif // %rip is set to the address of the called function. From scallanan at apple.com Tue Sep 7 16:49:41 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 07 Sep 2010 21:49:41 -0000 Subject: [Lldb-commits] [lldb] r113290 - in /lldb/trunk/source/Expression: ClangExpressionDeclMap.cpp IRForTarget.cpp Message-ID: <20100907214941.399802A6C12C@llvm.org> Author: spyffe Date: Tue Sep 7 16:49:41 2010 New Revision: 113290 URL: http://llvm.org/viewvc/llvm-project?rev=113290&view=rev Log: Improved function lookup to avoid conflicts between symbols with the same name and no debug information. Also improved the way functions are called so we don't automatically define them as variadic functions in the IR. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113290&r1=113289&r2=113290&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep 7 16:49:41 2010 @@ -734,6 +734,9 @@ m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); + bool found_generic = false; + bool found_specific = false; + for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); index < num_indices; ++index) @@ -742,9 +745,21 @@ sym_ctxs.GetContextAtIndex(index, sym_ctx); if (sym_ctx.function) - AddOneFunction(context, sym_ctx.function, NULL); + { + // TODO only do this if it's a C function; C++ functions may be + // overloaded + if (!found_specific) + AddOneFunction(context, sym_ctx.function, NULL); + found_specific = true; + } else if(sym_ctx.symbol) - AddOneFunction(context, NULL, sym_ctx.symbol); + { + if (!found_generic && !found_specific) + { + AddOneFunction(context, NULL, sym_ctx.symbol); + found_generic = true; + } + } } Variable *var = FindVariableInScope(*m_sym_ctx, name); @@ -993,7 +1008,7 @@ entity.m_parser_vars->m_lldb_value = fun_location.release(); if (log) - log->Printf("Found function %s, returned (NamedDecl)%p", context.Name.getAsString().c_str(), fun_decl); + log->Printf("Found %s function %s, returned (NamedDecl)%p", (fun ? "specific" : "generic"), context.Name.getAsString().c_str(), fun_decl); } void Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=113290&r1=113289&r2=113290&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 7 16:49:41 2010 @@ -558,9 +558,15 @@ { if (!m_decl_map->GetFunctionInfo(fun_decl, fun_value_ptr, fun_addr)) { - if (log) - log->Printf("Function %s had no address", fun_decl->getNameAsCString()); - return false; + fun_value_ptr = NULL; + + if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) + { + if (log) + log->Printf("Function %s had no address", fun->getName().str().c_str()); + + return false; + } } } else @@ -580,12 +586,9 @@ if (!fun_value_ptr || !*fun_value_ptr) { - std::vector params; - const IntegerType *intptr_ty = Type::getIntNTy(M.getContext(), (M.getPointerSize() == Module::Pointer64) ? 64 : 32); - - FunctionType *fun_ty = FunctionType::get(intptr_ty, params, true); + const FunctionType *fun_ty = fun->getFunctionType(); PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); Constant *fun_addr_int = ConstantInt::get(intptr_ty, fun_addr, false); fun_addr_ptr = ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty); From gclayton at apple.com Tue Sep 7 16:56:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 21:56:53 -0000 Subject: [Lldb-commits] [lldb] r113292 - /lldb/trunk/source/Core/Address.cpp Message-ID: <20100907215653.8670E2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 7 16:56:53 2010 New Revision: 113292 URL: http://llvm.org/viewvc/llvm-project?rev=113292&view=rev Log: Stop line entries from dumping full paths when addresses dump themselves as symbol contexts. Modified: lldb/trunk/source/Core/Address.cpp Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=113292&r1=113291&r2=113292&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue Sep 7 16:56:53 2010 @@ -608,7 +608,9 @@ if (sc.function || sc.symbol) { bool show_stop_context = true; - bool show_module = (style == DumpStyleResolvedDescription); + const bool show_module = (style == DumpStyleResolvedDescription); + const bool show_fullpaths = false; + const bool show_inlined_frames = false; if (sc.function == NULL && sc.symbol != NULL) { // If we have just a symbol make sure it is in the right section @@ -625,7 +627,12 @@ { // We have a function or a symbol from the same // sections as this address. - sc.DumpStopContext(s, exe_scope, *this, true, show_module, false); + sc.DumpStopContext (s, + exe_scope, + *this, + show_fullpaths, + show_module, + show_inlined_frames); } else { From ctice at apple.com Tue Sep 7 17:38:08 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 07 Sep 2010 22:38:08 -0000 Subject: [Lldb-commits] [lldb] r113298 - in /lldb/trunk/source: Commands/ Interpreter/ Message-ID: <20100907223808.AAEC82A6C12C@llvm.org> Author: ctice Date: Tue Sep 7 17:38:08 2010 New Revision: 113298 URL: http://llvm.org/viewvc/llvm-project?rev=113298&view=rev Log: Small help text fixes, to make it more consistent and accurate. Temporarily remove -l option from 'expr' command (at Sean's request). Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectQuit.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Tue Sep 7 17:38:08 2010 @@ -28,7 +28,7 @@ CommandObjectApropos::CommandObjectApropos () : CommandObject ("apropos", - "Finds a list of debugger commands related to a particular word/subject.", + "Find a list of debugger commands related to a particular word/subject.", "apropos ") { } Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Sep 7 17:38:08 2010 @@ -504,7 +504,7 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : CommandObjectMultiword ("breakpoint", - "A set of commands for operating on breakpoints.", + "A set of commands for operating on breakpoints. Also see regexp-break.", "breakpoint []") { bool status; Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Sep 7 17:38:08 2010 @@ -424,7 +424,7 @@ CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) : CommandObjectMultiword ("commands", - "Commands for managing the command interpreters commands", + "A set of commands for managing or customizing the debugger commands.", "commands []") { LoadSubCommand (interpreter, "source", CommandObjectSP (new CommandObjectCommandsSource ())); Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Sep 7 17:38:08 2010 @@ -143,7 +143,7 @@ CommandObjectDisassemble::CommandObjectDisassemble () : CommandObject ("disassemble", - "Disassemble bytes in the current function or anywhere in the inferior program.", + "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.", "disassemble []") { } Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Sep 7 17:38:08 2010 @@ -55,12 +55,12 @@ switch (short_option) { - case 'l': - if (language.SetLanguageFromCString (option_arg) == false) - { - error.SetErrorStringWithFormat("Invalid language option argument '%s'.\n", option_arg); - } - break; + //case 'l': + //if (language.SetLanguageFromCString (option_arg) == false) + //{ + // error.SetErrorStringWithFormat("Invalid language option argument '%s'.\n", option_arg); + //} + //break; case 'g': debug = true; @@ -82,7 +82,7 @@ CommandObjectExpression::CommandOptions::ResetOptionValues () { Options::ResetOptionValues(); - language.Clear(); + //language.Clear(); debug = false; format = eFormatDefault; show_types = true; @@ -98,7 +98,7 @@ CommandObjectExpression::CommandObjectExpression () : CommandObject ( "expression", - "Evaluate a C expression in the current program context, using variables currently in scope.", + "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", "expression [] "), m_expr_line_count (0), m_expr_lines () @@ -347,7 +347,7 @@ lldb::OptionDefinition CommandObjectExpression::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, + //{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, { LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, { LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, { LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, NULL, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Tue Sep 7 17:38:08 2010 @@ -46,7 +46,7 @@ // Options table: Required for subclasses of Options. static lldb::OptionDefinition g_option_table[]; - Language language; + //Language language; lldb::Encoding encoding; lldb::Format format; bool debug; Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Tue Sep 7 17:38:08 2010 @@ -87,7 +87,7 @@ CommandObjectFile::CommandObjectFile() : CommandObject ("file", - "Sets the file to be used as the main executable by the debugger.", + "Set the file to be used as the main executable by the debugger.", "file [] ") { } @@ -175,4 +175,4 @@ matches); return matches.GetSize(); -} \ No newline at end of file +} Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Sep 7 17:38:08 2010 @@ -27,7 +27,7 @@ CommandObjectHelp::CommandObjectHelp () : CommandObject ("help", - "Shows a list of all debugger commands, or give details about specific commands.", + "Show a list of all debugger commands, or give details about specific commands.", "help []") { } Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Sep 7 17:38:08 2010 @@ -1554,8 +1554,8 @@ //---------------------------------------------------------------------- CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : CommandObjectMultiword ("image", - "Access information for one or more executable images.", - "image [dump|list] ...") + "A set of commands for accessing information for one or more executable images.", + "image ...") { LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Sep 7 17:38:08 2010 @@ -678,7 +678,7 @@ CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : CommandObjectMultiword ("memory", - "A set of commands for operating on a memory.", + "A set of commands for operating on memory.", "memory []") { LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Tue Sep 7 17:38:08 2010 @@ -24,7 +24,7 @@ //------------------------------------------------------------------------- CommandObjectQuit::CommandObjectQuit () : - CommandObject ("quit", "Quits out of the LLDB debugger.", "quit") + CommandObject ("quit", "Quit out of the LLDB debugger.", "quit") { } Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Sep 7 17:38:08 2010 @@ -220,7 +220,7 @@ //---------------------------------------------------------------------- CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : CommandObjectMultiword ("register", - "Access thread registers.", + "A set of commands to access thread registers.", "register [read|write] ...") { LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Sep 7 17:38:08 2010 @@ -575,7 +575,7 @@ CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) : CommandObjectMultiword ("source", - "Commands for accessing source file information", + "A set of commands for accessing source file information", "source []") { LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectSourceInfo ())); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Sep 7 17:38:08 2010 @@ -332,7 +332,7 @@ CommandObjectThreadBacktrace () : CommandObject ("thread backtrace", - "Shows the stack for one or more threads. If no threads are specified, shows the currently selected thread. \nUse the thread-index \"all\" to see all threads.", + "Shows the stack for one or more threads. If no threads are specified, shows the currently selected thread. Use the thread-index \"all\" to see all threads.", "thread backtrace [] ...", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options() @@ -1378,7 +1378,7 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : CommandObjectMultiword ("thread", - "A set of commands for operating on one or more thread within a running process.", + "A set of commands for operating on one or more threads within a running process.", "thread []") { LoadSubCommand (interpreter, "backtrace", CommandObjectSP (new CommandObjectThreadBacktrace ())); Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Sep 7 17:38:08 2010 @@ -167,7 +167,7 @@ std::auto_ptr break_regex_cmd_ap(new CommandObjectRegexCommand ("regexp-break", - "Smart breakpoint command (using regular expressions).", + "Set a breakpoint using a regular expression to specify the location.", "regexp-break [:]\nregexp-break [
]\nregexp-break <...>", 2)); if (break_regex_cmd_ap.get()) { Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=113298&r1=113297&r2=113298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Tue Sep 7 17:38:08 2010 @@ -29,8 +29,8 @@ CommandObjectScript::CommandObjectScript (ScriptLanguage script_lang) : CommandObject ("script", - "Passes an expression to the script interpreter for evaluation and returns the results. Drops user into the interactive interpreter if no expressions are given.", - "script []"), + "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.", + "script []"), m_script_lang (script_lang), m_interpreter_ap () { From scallanan at apple.com Tue Sep 7 17:43:20 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 07 Sep 2010 22:43:20 -0000 Subject: [Lldb-commits] [lldb] r113300 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20100907224320.157E12A6C12C@llvm.org> Author: spyffe Date: Tue Sep 7 17:43:19 2010 New Revision: 113300 URL: http://llvm.org/viewvc/llvm-project?rev=113300&view=rev Log: Fixed a bug where we did not handle constant expressions correctly. These produced a result variable with an initializer but no store instruction, and the store instruction was as a result never rewritten to become a store to a persistent variable. Now if the result variable has an initializer but is never used, we generate a (redundant) store instruction for it, which is then later rewritten into a (useful) store to the persistent result variable. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=113300&r1=113299&r2=113300&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 7 17:43:19 2010 @@ -172,11 +172,42 @@ named_metadata->addOperand(persistent_global_md); if (log) - log->Printf("Replacing %s with %s", - PrintValue(result_global).c_str(), + log->Printf("Replacing %s with %s", + PrintValue(result_global).c_str(), PrintValue(new_result_global).c_str()); + + if (result_global->hasNUses(0)) + { + // We need to synthesize a store for this variable, because otherwise + // there's nothing to put into its equivalent persistent variable. + + BasicBlock &entry_block(F.getEntryBlock()); + Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg()); + + if (!first_entry_instruction) + return false; + + if (!result_global->hasInitializer()) + { + if (log) + log->Printf("Couldn't find initializer for unused variable"); + return false; + } + + Constant *initializer = result_global->getInitializer(); + + StoreInst *synthesized_store = new StoreInst::StoreInst(initializer, + new_result_global, + first_entry_instruction); + + if (log) + log->Printf("Synthesized result store %s\n", PrintValue(synthesized_store).c_str()); + } + else + { + result_global->replaceAllUsesWith(new_result_global); + } - result_global->replaceAllUsesWith(new_result_global); result_global->eraseFromParent(); return true; From jingham at apple.com Tue Sep 7 18:31:30 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 07 Sep 2010 23:31:30 -0000 Subject: [Lldb-commits] [lldb] r113309 - /lldb/trunk/source/Core/UserSettingsController.cpp Message-ID: <20100907233130.70A562A6C12C@llvm.org> Author: jingham Date: Tue Sep 7 18:31:30 2010 New Revision: 113309 URL: http://llvm.org/viewvc/llvm-project?rev=113309&view=rev Log: The settings mutexes get used recursively, and deadlock if they are normal mutexes. Modified: lldb/trunk/source/Core/UserSettingsController.cpp Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113309&r1=113308&r2=113309&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Tue Sep 7 18:31:30 2010 @@ -26,8 +26,8 @@ m_pending_settings (), m_live_settings (), m_children_mutex (Mutex::eMutexTypeNormal), - m_pending_settings_mutex (Mutex::eMutexTypeNormal), - m_live_settings_mutex (Mutex::eMutexTypeNormal) + m_pending_settings_mutex (Mutex::eMutexTypeRecursive), + m_live_settings_mutex (Mutex::eMutexTypeRecursive) { m_settings.parent = parent; m_settings.level_name.SetCString (level_name); From gclayton at apple.com Tue Sep 7 18:40:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 23:40:05 -0000 Subject: [Lldb-commits] [lldb] r113313 - in /lldb/trunk: include/lldb/Core/Module.h source/Core/Module.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Message-ID: <20100907234006.036D22A6C12C@llvm.org> Author: gclayton Date: Tue Sep 7 18:40:05 2010 New Revision: 113313 URL: http://llvm.org/viewvc/llvm-project?rev=113313&view=rev Log: Remove the Flags member in lldb_private::Module in favor of bitfield boolean member variables. Modified lldb_private::Module to have an accessor that can be used to tell if a module is a dynamic link editor (dyld) as there are functions in dyld on darwin that mirror functions in libc (malloc, free, etc) that should not be used when doing function lookups by name in expressions if there are more than one match when looking up functions by name. Modified: lldb/trunk/include/lldb/Core/Module.h lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=113313&r1=113312&r2=113313&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Tue Sep 7 18:40:05 2010 @@ -49,13 +49,6 @@ friend class ModuleList; friend bool ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch); - enum - { - flagsSearchedForObjParser = (1 << 0), - flagsSearchedForSymVendor = (1 << 1), - flagsParsedUUID = (1 << 2) - }; - //------------------------------------------------------------------ /// Construct with file specification and architecture. /// @@ -553,6 +546,18 @@ SetFileSpecAndObjectName (const FileSpec &file, const ConstString &object_name); + bool + GetIsDynamicLinkEditor () const + { + return m_is_dynamic_loader_module; + } + + void + SetIsDynamicLinkEditor (bool b) + { + m_is_dynamic_loader_module = b; + } + protected: //------------------------------------------------------------------ // Member Variables @@ -562,10 +567,14 @@ ArchSpec m_arch; ///< The architecture for this module. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols. FileSpec m_file; ///< The file representation on disk for this module (if there is one). - Flags m_flags; ///< Flags for this module to track what has been parsed already. ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file. std::auto_ptr m_objfile_ap; ///< A pointer to the object file parser for this module. std::auto_ptr m_symfile_ap; ///< A pointer to the symbol vendor for this module. + bool m_did_load_objfile:1, + m_did_load_symbol_vendor:1, + m_did_parse_uuid:1, + m_is_dynamic_loader_module:1; + //------------------------------------------------------------------ /// Resolve a file or load virtual address. /// @@ -601,14 +610,21 @@ /// @see SymbolContext::Scope //------------------------------------------------------------------ uint32_t - ResolveSymbolContextForAddress (lldb::addr_t vm_addr, bool vm_addr_is_file_addr, uint32_t resolve_scope, Address& so_addr, SymbolContext& sc); - - void SymbolIndicesToSymbolContextList (Symtab *symtab, std::vector &symbol_indexes, SymbolContextList &sc_list); + ResolveSymbolContextForAddress (lldb::addr_t vm_addr, + bool vm_addr_is_file_addr, + uint32_t resolve_scope, + Address& so_addr, + SymbolContext& sc); - bool SetArchitecture (const ArchSpec &new_arch); + void + SymbolIndicesToSymbolContextList (Symtab *symtab, + std::vector &symbol_indexes, + SymbolContextList &sc_list); + + bool + SetArchitecture (const ArchSpec &new_arch); private: - DISALLOW_COPY_AND_ASSIGN (Module); }; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=113313&r1=113312&r2=113313&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Sep 7 18:40:05 2010 @@ -26,10 +26,13 @@ m_arch (arch), m_uuid (), m_file (file_spec), - m_flags (), m_object_name (), m_objfile_ap (), - m_symfile_ap () + m_symfile_ap (), + m_did_load_objfile (false), + m_did_load_symbol_vendor (false), + m_did_parse_uuid (false), + m_is_dynamic_loader_module (false) { if (object_name) m_object_name = *object_name; @@ -70,14 +73,14 @@ Module::GetUUID() { Mutex::Locker locker (m_mutex); - if (m_flags.IsClear(flagsParsedUUID)) + if (m_did_parse_uuid == false) { ObjectFile * obj_file = GetObjectFile (); if (obj_file != NULL) { obj_file->GetUUID(&m_uuid); - m_flags.Set(flagsParsedUUID); + m_did_parse_uuid = true; } } return m_uuid; @@ -330,14 +333,14 @@ Module::GetSymbolVendor (bool can_create) { Mutex::Locker locker (m_mutex); - if (m_flags.IsClear(flagsSearchedForSymVendor) && can_create) + if (m_did_load_symbol_vendor == false && can_create) { ObjectFile *obj_file = GetObjectFile (); if (obj_file != NULL) { Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); m_symfile_ap.reset(SymbolVendor::FindPlugin(this)); - m_flags.Set (flagsSearchedForSymVendor); + m_did_load_symbol_vendor = true; } } return m_symfile_ap.get(); @@ -412,9 +415,9 @@ Module::GetObjectFile() { Mutex::Locker locker (m_mutex); - if (m_flags.IsClear(flagsSearchedForObjParser)) + if (m_did_load_objfile == false) { - m_flags.Set (flagsSearchedForObjParser); + m_did_load_objfile = true; Timer scoped_timer(__PRETTY_FUNCTION__, "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString("")); m_objfile_ap.reset(ObjectFile::FindPlugin(this, &m_file, 0, m_file.GetByteSize())); Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=113313&r1=113312&r2=113313&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Sep 7 18:40:05 2010 @@ -601,6 +601,9 @@ if (image_module_sp) { + if (m_dyld_image_infos[idx].header.filetype == HeaderFileTypeDynamicLinkEditor) + image_module_sp->SetIsDynamicLinkEditor (true); + ObjectFile *objfile = image_module_sp->GetObjectFile (); if (objfile) { From gclayton at apple.com Tue Sep 7 18:55:31 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 07 Sep 2010 23:55:31 -0000 Subject: [Lldb-commits] [lldb] r113314 - in /lldb/trunk/test/objc: ./ Makefile main.m Message-ID: <20100907235531.47E2D2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 7 18:55:31 2010 New Revision: 113314 URL: http://llvm.org/viewvc/llvm-project?rev=113314&view=rev Log: Added an objective C test that creates some NSString, NSArray and NSDictionary objects and populates them so we can test making expression calls with these objects. We will need to make this test case more complete as time goes on to make sure we can evaluate all functions. Added: lldb/trunk/test/objc/ lldb/trunk/test/objc/Makefile lldb/trunk/test/objc/main.m Added: lldb/trunk/test/objc/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc/Makefile?rev=113314&view=auto ============================================================================== --- lldb/trunk/test/objc/Makefile (added) +++ lldb/trunk/test/objc/Makefile Tue Sep 7 18:55:31 2010 @@ -0,0 +1,125 @@ +#---------------------------------------------------------------------- +# Fill in the source files to build +#---------------------------------------------------------------------- +C_SOURCES := +CXX_SOURCES := +OBJC_SOURCES :=main.m +OBJCXX_SOURCES := + +# Uncomment line below for debugging shell commands +# SHELL = /bin/sh -x + +#---------------------------------------------------------------------- +# Change any build/tool options needed +#---------------------------------------------------------------------- +DS := /usr/bin/dsymutil +DSFLAGS = +CFLAGS ?=-arch x86_64 -g -O0 +CPLUSPLUSFLAGS +=$(CFLAGS) +CPPFLAGS +=$(CFLAGS) +LD = gcc +LDFLAGS = $(CFLAGS) -lobjc -framework Foundation +OBJECTS = +EXE=a.out +DSYM=$(EXE).dSYM + +#---------------------------------------------------------------------- +# Check if we have any C source files +#---------------------------------------------------------------------- +ifneq "$(strip $(C_SOURCES))" "" + OBJECTS +=$(strip $(C_SOURCES:.c=.o)) +endif + +#---------------------------------------------------------------------- +# Check if we have any C++ source files +#---------------------------------------------------------------------- +ifneq "$(strip $(CXX_SOURCES))" "" + OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) + LD = g++ +endif + +#---------------------------------------------------------------------- +# Check if we have any ObjC source files +#---------------------------------------------------------------------- +ifneq "$(strip $(OBJC_SOURCES))" "" + OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) + LDFLAGS +=-lobjc +endif + +#---------------------------------------------------------------------- +# Check if we have any ObjC++ source files +#---------------------------------------------------------------------- +ifneq "$(strip $(OBJCXX_SOURCES))" "" + OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) + LD = g++ + ifeq $(findstring lobjc,$(LDFLAGS)) "" + LDFLAGS +=-lobjc + endif +endif + + +#---------------------------------------------------------------------- +# Make the dSYM file from the executable +#---------------------------------------------------------------------- +$(DSYM) : $(EXE) + $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)" + +#---------------------------------------------------------------------- +# Compile the executable from all the objects (default rule) with no +# dsym file. +#---------------------------------------------------------------------- +$(EXE) : $(OBJECTS) + $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" + + +#---------------------------------------------------------------------- +# Automatic variables based on items already entered. Below we create +# an objects lists from the list of sources by replacing all entries +# that end with .c with .o, and we also create a list of prerequisite +# files by replacing all .c files with .d. +#---------------------------------------------------------------------- +PREREQS := $(OBJECTS:.o=.d) + +#---------------------------------------------------------------------- +# Rule for Generating Prerequisites Automatically using .d files and +# the compiler -MM option. The -M option will list all system headers, +# and the -MM option will list all non-system dependencies. +#---------------------------------------------------------------------- +%.d: %.c + @set -e; rm -f $@; \ + $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +%.d: %.cpp + @set -e; rm -f $@; \ + $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +%.d: %.m + @set -e; rm -f $@; \ + $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +%.d: %.mm + @set -e; rm -f $@; \ + $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +#---------------------------------------------------------------------- +# Include all of the makefiles for each source file so we don't have +# to manually track all of the prerequisites for each source file. +#---------------------------------------------------------------------- +sinclude $(PREREQS) + +.PHONY: clean +dsym: $(DSYM) +all: $(EXE) $(DSYM) +clean: + rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) + + + Added: lldb/trunk/test/objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc/main.m?rev=113314&view=auto ============================================================================== --- lldb/trunk/test/objc/main.m (added) +++ lldb/trunk/test/objc/main.m Tue Sep 7 18:55:31 2010 @@ -0,0 +1,22 @@ +#import + + +int main (int argc, char const *argv[]) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + static NSString *g_global_nsstr = @"Howdy"; + NSString *str1 = [NSString stringWithFormat:@"string %i", 1]; + NSString *str2 = [NSString stringWithFormat:@"string %i", 2]; + NSString *str3 = [NSString stringWithFormat:@"string %i", 3]; + NSArray *array = [NSArray arrayWithObjects: str1, str2, str3, nil]; + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + str1, @"1", + str2, @"2", + str3, @"3", + nil]; + + id str_id = str1; + SEL sel = @selector(length); + [pool release]; + return 0; +} From johnny.chen at apple.com Tue Sep 7 19:46:08 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 08 Sep 2010 00:46:08 -0000 Subject: [Lldb-commits] [lldb] r113325 - in /lldb/trunk/test/conditional_break: ./ Makefile TestConditionalBreak.py main.c Message-ID: <20100908004608.9E55F2A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 19:46:08 2010 New Revision: 113325 URL: http://llvm.org/viewvc/llvm-project?rev=113325&view=rev Log: Added a test case which exercises some thread and frame APIs to break only when the call site of c() is a(). Added: lldb/trunk/test/conditional_break/ lldb/trunk/test/conditional_break/Makefile lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/conditional_break/main.c Added: lldb/trunk/test/conditional_break/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/Makefile?rev=113325&view=auto ============================================================================== --- lldb/trunk/test/conditional_break/Makefile (added) +++ lldb/trunk/test/conditional_break/Makefile Tue Sep 7 19:46:08 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113325&view=auto ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (added) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Tue Sep 7 19:46:08 2010 @@ -0,0 +1,74 @@ +""" +Test conditionally break on a function and inspect its variables. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class ConditionalBreakTestCase(TestBase): + + mydir = "conditional_break" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Exercise some thread and frame APIs to break if c() is called by a().""" + self.buildDsym() + self.do_conditional_break() + + def test_with_dwarf(self): + """Exercise some thread and frame APIs to break if c() is called by a().""" + self.buildDwarf() + self.do_conditional_break() + + def do_conditional_break(self): + """Exercise some thread and frame APIs to break if c() is called by a().""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break on c(). + self.expect("breakpoint set -n c", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = 'c', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', 'stop reason = breakpoint']) + + # Suppose we are only interested in the call scenario where c()'s + # immediate caller is a() and we want to find out the value passed + # from a(). + for j in range(3): + target = self.dbg.GetSelectedTarget() + process = target.GetProcess() + thread = process.GetThreadAtIndex(0) + + if thread.GetNumFrames() >= 2: + frame0 = thread.GetFrameAtIndex(0) + name0 = frame0.GetFunction().GetName() + frame1 = thread.GetFrameAtIndex(1) + name1 = frame1.GetFunction().GetName() + self.assertTrue(name0 == "c", "Break on function c()") + if (name1 == "a"): + line = frame1.GetLineEntry().GetLine() + # By design, we know that a() calls c() only from main.c:27. + # In reality, similar logic can be used to find out the call + # site. + self.assertTrue(line == 27, "Immediate caller a() at main.c:27") + self.runCmd("thread backtrace") + self.runCmd("frame variable") + break + + # This doesn't work? + #process.Continue() + self.runCmd("process continue") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/conditional_break/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/main.c?rev=113325&view=auto ============================================================================== --- lldb/trunk/test/conditional_break/main.c (added) +++ lldb/trunk/test/conditional_break/main.c Tue Sep 7 19:46:08 2010 @@ -0,0 +1,54 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// This simple program is to demonstrate the capability of the lldb command +// "breakpoint command add" to add a set of commands to a breakpoint to be +// executed when the breakpoint is hit. +// +// In particular, we want to break within c(), but only if the immediate caller +// is a(). + +int a(int); +int b(int); +int c(int); + +int a(int val) +{ + if (val <= 1) + return b(val); + else if (val >= 3) + return c(val); + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) + printf("a(3) returns %d\n", A3); + + return 0; +} From johnny.chen at apple.com Tue Sep 7 19:55:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 08 Sep 2010 00:55:12 -0000 Subject: [Lldb-commits] [lldb] r113327 - /lldb/trunk/test/conditional_break/TestConditionalBreak.py Message-ID: <20100908005512.E10C92A6C12C@llvm.org> Author: johnny Date: Tue Sep 7 19:55:12 2010 New Revision: 113327 URL: http://llvm.org/viewvc/llvm-project?rev=113327&view=rev Log: Minor tweak to add expected matching strings. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113327&r1=113326&r2=113327&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Tue Sep 7 19:55:12 2010 @@ -58,8 +58,10 @@ # In reality, similar logic can be used to find out the call # site. self.assertTrue(line == 27, "Immediate caller a() at main.c:27") - self.runCmd("thread backtrace") - self.runCmd("frame variable") + self.expect("thread backtrace", "Call site at a()", + substrs = ["main.c:27"]) + self.expect("frame variable", "Passed in arg val of (int) 3", + startstr = "val = (int) 3") break # This doesn't work? From jingham at apple.com Tue Sep 7 20:17:37 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 08 Sep 2010 01:17:37 -0000 Subject: [Lldb-commits] [lldb] r113328 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Message-ID: <20100908011737.2C84F2A6C12C@llvm.org> Author: jingham Date: Tue Sep 7 20:17:36 2010 New Revision: 113328 URL: http://llvm.org/viewvc/llvm-project?rev=113328&view=rev Log: The functions that return the static ConstString names of the settings should be static as well. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Target/Process.h Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=113328&r1=113327&r2=113328&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Tue Sep 7 20:17:36 2010 @@ -77,10 +77,10 @@ const ConstString CreateInstanceName (); - const ConstString & + static const ConstString & PromptVarName (); - const ConstString & + static const ConstString & ScriptLangVarName (); private: Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=113328&r1=113327&r2=113328&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Sep 7 20:17:36 2010 @@ -77,25 +77,25 @@ const ConstString CreateInstanceName (); - const ConstString & + static const ConstString & RunArgsVarName (); - const ConstString & + static const ConstString & EnvVarsVarName (); - const ConstString & + static const ConstString & InputPathVarName (); - const ConstString & + static const ConstString & OutputPathVarName (); - const ConstString & + static const ConstString & ErrorPathVarName (); - const ConstString & + static const ConstString & PluginVarName (); - const ConstString & + static const ConstString & DisableASLRVarName(); From jingham at apple.com Tue Sep 7 22:14:33 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 08 Sep 2010 03:14:33 -0000 Subject: [Lldb-commits] [lldb] r113335 - in /lldb/trunk: include/lldb/Target/Thread.h source/Target/Thread.cpp source/Target/ThreadPlanStepInRange.cpp source/lldb.cpp Message-ID: <20100908031433.88B962A6C12C@llvm.org> Author: jingham Date: Tue Sep 7 22:14:33 2010 New Revision: 113335 URL: http://llvm.org/viewvc/llvm-project?rev=113335&view=rev Log: Add a user settings controller to Thread. Then added a step-avoid-regexp setting which controls whether to stop in a function matching the regexp. Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=113335&r1=113334&r2=113335&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Tue Sep 7 22:14:33 2010 @@ -13,6 +13,7 @@ #include "lldb/lldb-private.h" #include "lldb/Host/Mutex.h" #include "lldb/Core/UserID.h" +#include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackFrameList.h" #include "libunwind/include/libunwind.h" @@ -24,12 +25,102 @@ namespace lldb_private { +class ThreadInstanceSettings : public InstanceSettings +{ +public: + + ThreadInstanceSettings (UserSettingsController &owner, const char *name = NULL); + + ThreadInstanceSettings (const ThreadInstanceSettings &rhs); + + virtual + ~ThreadInstanceSettings (); + + ThreadInstanceSettings& + operator= (const ThreadInstanceSettings &rhs); + + + void + UpdateInstanceSettingsVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const ConstString &instance_name, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error &err, + bool pending); + + void + GetInstanceSettingsValue (const SettingEntry &entry, + const ConstString &var_name, + StringList &value); + + RegularExpression * + GetSymbolsToAvoidRegexp() + { + return m_avoid_regexp_ap.get(); + } + + static const ConstString & + StepAvoidRegexpVarName (); + +protected: + + void + CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, + bool pending); + + const ConstString + CreateInstanceName (); + +private: + + std::auto_ptr m_avoid_regexp_ap; +}; + class Thread : public UserID, - public ExecutionContextScope + public ExecutionContextScope, + public ThreadInstanceSettings { public: + class ThreadSettingsController : public UserSettingsController + { + public: + + ThreadSettingsController (); + + virtual + ~ThreadSettingsController (); + + void + UpdateGlobalVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error&err); + + void + GetGlobalSettingsValue (const ConstString &var_name, + StringList &value); + + static SettingEntry global_settings_table[]; + static SettingEntry instance_settings_table[]; + + protected: + + lldb::InstanceSettingsSP + CreateNewInstanceSettings (); + + private: + + // Class-wide settings. + + DISALLOW_COPY_AND_ASSIGN (ThreadSettingsController); + }; + class RegisterCheckpoint { public: @@ -79,6 +170,9 @@ lldb::DataBufferSP m_data_sp; }; + static lldb::UserSettingsControllerSP + GetSettingsController (bool finish = false); + Thread (Process &process, lldb::tid_t tid); virtual ~Thread(); @@ -488,6 +582,21 @@ //------------------------------------------------------------------ void DumpThreadPlans (Stream *s) const; + + //------------------------------------------------------------------ + /// The regular expression returned determines symbols that this + /// thread won't stop in during "step-in" operations. + /// + /// @return + /// A pointer to a regular expression to compare against symbols, + /// or NULL if all symbols are allowed. + /// + //------------------------------------------------------------------ + RegularExpression * + GetSymbolsToAvoidRegexp() + { + return ThreadInstanceSettings::GetSymbolsToAvoidRegexp(); + } // Get the thread index ID. The index ID that is guaranteed to not be // re-used by a process. They start at 1 and increase with each new thread. Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=113335&r1=113334&r2=113335&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Tue Sep 7 22:14:33 2010 @@ -12,6 +12,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/RegularExpression.h" #include "lldb/Host/Host.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" @@ -39,6 +40,7 @@ Thread::Thread (Process &process, lldb::tid_t tid) : UserID (tid), + ThreadInstanceSettings (*(Thread::GetSettingsController().get())), m_process (process), m_public_stop_info_sp (), m_actual_stop_info_sp (), @@ -912,3 +914,220 @@ { return m_process.GetThreadList().GetThreadSPForThreadPtr(this); } + +lldb::UserSettingsControllerSP +Thread::GetSettingsController (bool finish) +{ + static UserSettingsControllerSP g_settings_controller (new ThreadSettingsController); + static bool initialized = false; + + if (!initialized) + { + initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, + Thread::ThreadSettingsController::global_settings_table, + Thread::ThreadSettingsController::instance_settings_table); + } + + if (finish) + { + UserSettingsController::FinalizeSettingsController (g_settings_controller); + g_settings_controller.reset(); + initialized = false; + } + + return g_settings_controller; +} + +//-------------------------------------------------------------- +// class Thread::ThreadSettingsController +//-------------------------------------------------------------- + +Thread::ThreadSettingsController::ThreadSettingsController () : + UserSettingsController ("thread", Process::GetSettingsController()) +{ + m_default_settings.reset (new ThreadInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString())); +} + +Thread::ThreadSettingsController::~ThreadSettingsController () +{ +} + +lldb::InstanceSettingsSP +Thread::ThreadSettingsController::CreateNewInstanceSettings () +{ + ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get())); + lldb::InstanceSettingsSP new_settings_sp (new_settings); + return new_settings_sp; +} + +//-------------------------------------------------------------- +// class ThreadInstanceSettings +//-------------------------------------------------------------- + +ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, const char *name) : + InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name)), + m_avoid_regexp_ap () +{ + // FIXME: This seems like generic code, why was it duplicated (with the slight difference that + // DebuggerInstanceSettings checks name, not m_instance_name below) in Process & Debugger? + if (m_instance_name != InstanceSettings::GetDefaultName()) + { + const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); + CopyInstanceSettings (pending_settings,false); + m_owner.RemovePendingSettings (m_instance_name); + } +} + +ThreadInstanceSettings::ThreadInstanceSettings (const ThreadInstanceSettings &rhs) : + InstanceSettings (*(Thread::GetSettingsController().get()), CreateInstanceName().AsCString()), + m_avoid_regexp_ap () +{ + if (m_instance_name != InstanceSettings::GetDefaultName()) + { + const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); + CopyInstanceSettings (pending_settings,false); + m_owner.RemovePendingSettings (m_instance_name); + } + if (rhs.m_avoid_regexp_ap.get() != NULL) + m_avoid_regexp_ap.reset(new RegularExpression(rhs.m_avoid_regexp_ap->GetText())); +} + +ThreadInstanceSettings::~ThreadInstanceSettings () +{ +} + +ThreadInstanceSettings& +ThreadInstanceSettings::operator= (const ThreadInstanceSettings &rhs) +{ + if (this != &rhs) + { + if (rhs.m_avoid_regexp_ap.get() != NULL) + m_avoid_regexp_ap.reset(new RegularExpression(rhs.m_avoid_regexp_ap->GetText())); + else + m_avoid_regexp_ap.reset(NULL); + } + + return *this; +} + + +void +ThreadInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const ConstString &instance_name, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error &err, + bool pending) +{ + if (var_name == StepAvoidRegexpVarName()) + { + std::string regexp_text; + if (m_avoid_regexp_ap.get() != NULL) + regexp_text.append (m_avoid_regexp_ap->GetText()); + UserSettingsController::UpdateStringVariable (op, regexp_text, value, err); + if (regexp_text.empty()) + m_avoid_regexp_ap.reset(); + else + { + m_avoid_regexp_ap.reset(new RegularExpression(regexp_text.c_str())); + + } + } +} + +void +ThreadInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, + bool pending) +{ + if (new_settings.get() == NULL) + return; + + ThreadInstanceSettings *new_process_settings = (ThreadInstanceSettings *) new_settings.get(); + if (new_process_settings->GetSymbolsToAvoidRegexp() != NULL) + m_avoid_regexp_ap.reset (new RegularExpression (new_process_settings->GetSymbolsToAvoidRegexp()->GetText())); + else + m_avoid_regexp_ap.reset (); +} + +void +Thread::ThreadSettingsController::UpdateGlobalVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + lldb::VarSetOperationType op, + Error&err) +{ + // Currently 'thread' does not have any global settings. +} + + +void +ThreadInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, + const ConstString &var_name, + StringList &value) +{ + if (var_name == StepAvoidRegexpVarName()) + { + if (m_avoid_regexp_ap.get() != NULL) + { + std::string regexp_text("\""); + regexp_text.append(m_avoid_regexp_ap->GetText()); + regexp_text.append ("\""); + value.AppendString (regexp_text.c_str()); + } + + } + else + value.AppendString ("unrecognized variable name"); +} + +void +Thread::ThreadSettingsController::GetGlobalSettingsValue (const ConstString &var_name, + StringList &value) +{ + // Currently 'thread' does not have any global settings. +} + +const ConstString +ThreadInstanceSettings::CreateInstanceName () +{ + static int instance_count = 1; + StreamString sstr; + + sstr.Printf ("thread_%d", instance_count); + ++instance_count; + + const ConstString ret_val (sstr.GetData()); + return ret_val; +} + +const ConstString & +ThreadInstanceSettings::StepAvoidRegexpVarName () +{ + static ConstString run_args_var_name ("step-avoid-regexp"); + + return run_args_var_name; +} + +//-------------------------------------------------- +// ThreadSettingsController Variable Tables +//-------------------------------------------------- + +SettingEntry +Thread::ThreadSettingsController::global_settings_table[] = +{ + //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, + { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } +}; + + +SettingEntry +Thread::ThreadSettingsController::instance_settings_table[] = +{ + //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, + { "step-avoid-regexp", eSetVarTypeString, "", NULL, false, false, "A regular expression defining functions step-in won't stop in." }, + { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } +}; + Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=113335&r1=113334&r2=113335&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep 7 22:14:33 2010 @@ -156,7 +156,13 @@ { StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get(); - if (m_avoid_regexp_ap.get() != NULL) + RegularExpression *avoid_regexp_to_use; + + avoid_regexp_to_use = m_avoid_regexp_ap.get(); + if (avoid_regexp_to_use == NULL) + avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp(); + + if (avoid_regexp_to_use != NULL) { SymbolContext sc = frame->GetSymbolContext(eSymbolContextSymbol); if (sc.symbol != NULL) @@ -164,7 +170,7 @@ const char *unnamed_symbol = ""; const char *sym_name = sc.symbol->GetMangled().GetName().AsCString(unnamed_symbol); if (strcmp (sym_name, unnamed_symbol) != 0) - return m_avoid_regexp_ap->Execute(sym_name); + return avoid_regexp_to_use->Execute(sym_name); } } return false; Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=113335&r1=113334&r2=113335&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Tue Sep 7 22:14:33 2010 @@ -76,7 +76,7 @@ #endif Debugger::GetSettingsController (false); Process::GetSettingsController (false); - + Thread::GetSettingsController (false); #ifdef __linux__ ProcessLinux::Initialize(); #endif @@ -111,7 +111,8 @@ Process::GetSettingsController (true); Debugger::GetSettingsController (true); - + Thread::GetSettingsController (true); + #ifdef __linux__ ProcessLinux::Terminate(); #endif From gclayton at apple.com Wed Sep 8 11:38:07 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 08 Sep 2010 16:38:07 -0000 Subject: [Lldb-commits] [lldb] r113363 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20100908163807.2A9BD2A6C12C@llvm.org> Author: gclayton Date: Wed Sep 8 11:38:06 2010 New Revision: 113363 URL: http://llvm.org/viewvc/llvm-project?rev=113363&view=rev Log: Enable minimized symbol tables when parsing mach-o files. This new change will omit unneeded symbol table entries and coalesce function entries (N_FUN stab entries) with their linker code symbol (N_SECT symbols) into only the function symbol to avoid duplicate symbol table entries. It will also coalesce N_STSYM and the data linker symbol into just one static data symbol. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113363&r1=113362&r2=113363&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 8 11:38:06 2010 @@ -2289,7 +2289,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113363&r1=113362&r2=113363&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Sep 8 11:38:06 2010 @@ -206,7 +206,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); - ParseSymtab(false); + ParseSymtab (true); } return m_symtab_ap.get(); } @@ -646,6 +646,9 @@ std::vector N_INCL_indexes; std::vector N_BRAC_indexes; std::vector N_COMM_indexes; + typedef std::map ValueToSymbolIndexMap; + ValueToSymbolIndexMap N_FUN_addr_to_sym_idx; + ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx; uint32_t nlist_idx = 0; Symbol *symbol_ptr = NULL; @@ -706,6 +709,8 @@ { type = eSymbolTypeFunction; symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); + + N_FUN_addr_to_sym_idx[nlist.n_value] = sym_idx; // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out N_FUN_indexes.push_back(sym_idx); @@ -731,6 +736,7 @@ case StabStaticSymbol: // N_STSYM -- static symbol: name,,n_sect,type,address + N_STSYM_addr_to_sym_idx[nlist.n_value] = sym_idx; symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeStatic; break; @@ -1082,7 +1088,7 @@ } } break; - } + } } } @@ -1095,13 +1101,58 @@ symbol_name++; // Skip the leading underscore } uint64_t symbol_value = nlist.n_value; + + if (symbol_name) + sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); + + if (type == eSymbolTypeCode) + { + // See if we can find a N_FUN entry for any code symbols. + // If we do find a match, and the name matches, then we + // can merge the two into just the function symbol to avoid + // duplicate entries in the symbol table + ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value); + if (pos != N_FUN_addr_to_sym_idx.end()) + { + if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || + (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + { + + // We just need the flags from the linker symbol, so put these flags + // into the N_FUN flags to avoid duplicate symbols in the symbol table + sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + sym[sym_idx].GetMangled().Clear(); + continue; + } + } + } + else if (type == eSymbolTypeData) + { + // See if we can find a N_STSYM entry for any data symbols. + // If we do find a match, and the name matches, then we + // can merge the two into just the Static symbol to avoid + // duplicate entries in the symbol table + ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value); + if (pos != N_STSYM_addr_to_sym_idx.end()) + { + if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || + (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + { + + // We just need the flags from the linker symbol, so put these flags + // into the N_STSYM flags to avoid duplicate symbols in the symbol table + sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + sym[sym_idx].GetMangled().Clear(); + continue; + } + } + } + if (symbol_section != NULL) symbol_value -= symbol_section->GetFileAddress(); sym[sym_idx].SetID (nlist_idx); sym[sym_idx].SetType (type); - if (symbol_name) - sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); sym[sym_idx].GetAddressRangeRef().GetBaseAddress().SetSection (symbol_section); sym[sym_idx].GetAddressRangeRef().GetBaseAddress().SetOffset (symbol_value); sym[sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc); From ctice at apple.com Wed Sep 8 12:48:55 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 08 Sep 2010 17:48:55 -0000 Subject: [Lldb-commits] [lldb] r113370 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/UserSettingsController.h include/lldb/Target/Process.h include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Thread.cpp Message-ID: <20100908174855.AE2E32A6C12C@llvm.org> Author: ctice Date: Wed Sep 8 12:48:55 2010 New Revision: 113370 URL: http://llvm.org/viewvc/llvm-project?rev=113370&view=rev Log: Make sure creating a pending instance doesn't also trigger creating a live instance; also make sure creating a pending instance uses the specified instance name rather than creating a new one; add brackets to instance names when searching for and removing pending instances. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Sep 8 12:48:55 2010 @@ -40,7 +40,7 @@ { public: - DebuggerInstanceSettings (UserSettingsController &owner, const char *name = NULL); + DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs); @@ -124,7 +124,7 @@ protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (); + CreateNewInstanceSettings (const char *instance_name); bool ValidTermWidthValue (const char *value, Error err); Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Wed Sep 8 12:48:55 2010 @@ -61,7 +61,7 @@ // Pure virtual functions, which all sub-classes must implement. virtual lldb::InstanceSettingsSP - CreateNewInstanceSettings () = 0; + CreateNewInstanceSettings (const char *instance_name) = 0; virtual void UpdateGlobalVariable (const ConstString &var_name, @@ -334,7 +334,7 @@ { public: - InstanceSettings (UserSettingsController &owner, const char *instance_name); + InstanceSettings (UserSettingsController &owner, const char *instance_name, bool live_instance = true); InstanceSettings (const InstanceSettings &rhs); Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Sep 8 12:48:55 2010 @@ -41,7 +41,7 @@ { public: - ProcessInstanceSettings (UserSettingsController &owner, const char *name = NULL); + ProcessInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); ProcessInstanceSettings (const ProcessInstanceSettings &rhs); @@ -251,7 +251,7 @@ protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (); + CreateNewInstanceSettings (const char *instance_name); static lldb::OptionEnumValueElement g_plugins[]; Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Wed Sep 8 12:48:55 2010 @@ -29,7 +29,7 @@ { public: - ThreadInstanceSettings (UserSettingsController &owner, const char *name = NULL); + ThreadInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); ThreadInstanceSettings (const ThreadInstanceSettings &rhs); @@ -112,7 +112,7 @@ protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (); + CreateNewInstanceSettings (const char *instance_name); private: Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Sep 8 12:48:55 2010 @@ -565,7 +565,8 @@ UserSettingsController ("", lldb::UserSettingsControllerSP()), m_term_width (80) { - m_default_settings.reset (new DebuggerInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString())); + m_default_settings.reset (new DebuggerInstanceSettings (*this, false, + InstanceSettings::GetDefaultName().AsCString())); } Debugger::DebuggerSettingsController::~DebuggerSettingsController () @@ -574,9 +575,10 @@ lldb::InstanceSettingsSP -Debugger::DebuggerSettingsController::CreateNewInstanceSettings () +Debugger::DebuggerSettingsController::CreateNewInstanceSettings (const char *instance_name) { - DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get())); + DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get()), + false, instance_name); lldb::InstanceSettingsSP new_settings_sp (new_settings); return new_settings_sp; } @@ -626,12 +628,13 @@ // class DebuggerInstanceSettings //-------------------------------------------------- -DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName ().AsCString() : name)), +DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance, + const char *name) : + InstanceSettings (owner, (name == NULL ? CreateInstanceName ().AsCString() : name), live_instance), m_prompt (), m_script_lang () { - if (name == NULL) + if (name == NULL && live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings, false); Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Wed Sep 8 12:48:55 2010 @@ -47,10 +47,10 @@ if (parent) parent->RegisterChild (controller_sp); - controller_sp->CreateSettingsVector (global_settings, true); - controller_sp->CreateSettingsVector (instance_settings, false); + controller_sp->CreateSettingsVector (global_settings, true); + controller_sp->CreateSettingsVector (instance_settings, false); - controller_sp->InitializeGlobalVariables (); + controller_sp->InitializeGlobalVariables (); controller_sp->CreateDefaultInstanceSettings (); return true; @@ -565,8 +565,17 @@ void UserSettingsController::RemovePendingSettings (const ConstString &instance_name) { + StreamString tmp_name; + + // Add surrounding brackets to instance name if not already present. + + if (instance_name.AsCString()[0] != '[') + tmp_name.Printf ("[%s]", instance_name.AsCString()); + else + tmp_name.Printf ("%s", instance_name.AsCString()); + + std::string instance_name_str (tmp_name.GetData()); std::map::iterator pos; - std::string instance_name_str (instance_name.AsCString()); Mutex::Locker locker (m_pending_settings_mutex); m_pending_settings.erase (instance_name_str); @@ -576,7 +585,16 @@ UserSettingsController::FindPendingSettings (const ConstString &instance_name) { std::map::iterator pos; - std::string instance_name_str (instance_name.AsCString()); + StreamString tmp_name; + + // Add surrounding brackets to instance name if not already present. + + if (instance_name.AsCString()[0] != '[') + tmp_name.Printf ("[%s]", instance_name.AsCString()); + else + tmp_name.Printf ("%s", instance_name.AsCString()); + + std::string instance_name_str (tmp_name.GetData()); // Need std::string for std::map look-up { // Scope for mutex. Mutex::Locker locker (m_pending_settings_mutex); @@ -655,9 +673,7 @@ } else { - lldb::InstanceSettingsSP default_settings_sp = - m_pending_settings[InstanceSettings::GetDefaultName().AsCString()]; - lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings (); + lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings (instance_name.AsCString()); CopyDefaultSettings (new_settings_sp, instance_name, true); m_pending_settings[name_str] = new_settings_sp; return new_settings_sp; @@ -1861,11 +1877,12 @@ // class InstanceSettings //---------------------------------------------------------------------- -InstanceSettings::InstanceSettings (UserSettingsController &owner, const char *instance_name) : +InstanceSettings::InstanceSettings (UserSettingsController &owner, const char *instance_name, bool live_instance) : m_owner (owner), m_instance_name (instance_name) { - if (m_instance_name != InstanceSettings::GetDefaultName()) + if ((m_instance_name != InstanceSettings::GetDefaultName()) + && live_instance) m_owner.RegisterInstanceSettings (this); } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Sep 8 12:48:55 2010 @@ -1951,7 +1951,8 @@ Process::ProcessSettingsController::ProcessSettingsController () : UserSettingsController ("process", Debugger::GetSettingsController()) { - m_default_settings.reset (new ProcessInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString())); + m_default_settings.reset (new ProcessInstanceSettings (*this, false, + InstanceSettings::GetDefaultName().AsCString())); } Process::ProcessSettingsController::~ProcessSettingsController () @@ -1959,9 +1960,10 @@ } lldb::InstanceSettingsSP -Process::ProcessSettingsController::CreateNewInstanceSettings () +Process::ProcessSettingsController::CreateNewInstanceSettings (const char *instance_name) { - ProcessInstanceSettings *new_settings = new ProcessInstanceSettings (*(Process::GetSettingsController().get())); + ProcessInstanceSettings *new_settings = new ProcessInstanceSettings (*(Process::GetSettingsController().get()), + false, instance_name); lldb::InstanceSettingsSP new_settings_sp (new_settings); return new_settings_sp; } @@ -1970,8 +1972,9 @@ // class ProcessInstanceSettings //-------------------------------------------------------------- -ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name)), +ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, bool live_instance, + const char *name) : + InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), m_run_args (), m_env_vars (), m_input_path (), @@ -1980,7 +1983,7 @@ m_plugin (), m_disable_aslr (true) { - if (m_instance_name != InstanceSettings::GetDefaultName()) + if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings,false); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=113370&r1=113369&r2=113370&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Wed Sep 8 12:48:55 2010 @@ -945,7 +945,8 @@ Thread::ThreadSettingsController::ThreadSettingsController () : UserSettingsController ("thread", Process::GetSettingsController()) { - m_default_settings.reset (new ThreadInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString())); + m_default_settings.reset (new ThreadInstanceSettings (*this, false, + InstanceSettings::GetDefaultName().AsCString())); } Thread::ThreadSettingsController::~ThreadSettingsController () @@ -953,9 +954,10 @@ } lldb::InstanceSettingsSP -Thread::ThreadSettingsController::CreateNewInstanceSettings () +Thread::ThreadSettingsController::CreateNewInstanceSettings (const char *instance_name) { - ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get())); + ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()), + false, instance_name); lldb::InstanceSettingsSP new_settings_sp (new_settings); return new_settings_sp; } @@ -964,13 +966,13 @@ // class ThreadInstanceSettings //-------------------------------------------------------------- -ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name)), +ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : + InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), m_avoid_regexp_ap () { // FIXME: This seems like generic code, why was it duplicated (with the slight difference that // DebuggerInstanceSettings checks name, not m_instance_name below) in Process & Debugger? - if (m_instance_name != InstanceSettings::GetDefaultName()) + if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings,false); From jingham at apple.com Wed Sep 8 12:52:03 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 08 Sep 2010 17:52:03 -0000 Subject: [Lldb-commits] [lldb] r113371 - /lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Message-ID: <20100908175203.7698B2A6C12C@llvm.org> Author: jingham Date: Wed Sep 8 12:52:03 2010 New Revision: 113371 URL: http://llvm.org/viewvc/llvm-project?rev=113371&view=rev Log: "break set -F" should also use the full symbol name completer. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=113371&r1=113370&r2=113371&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 8 12:52:03 2010 @@ -106,7 +106,7 @@ { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", "Set the breakpoint by function name - for C++ this means namespaces and arguments will be ignored." }, - { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, 0, "", + { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguemnts, and " "for Objective C this means a full function prototype with class and selector." }, From gclayton at apple.com Wed Sep 8 12:53:19 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 08 Sep 2010 17:53:19 -0000 Subject: [Lldb-commits] [lldb] r113372 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20100908175319.B0A4C2A6C12C@llvm.org> Author: gclayton Date: Wed Sep 8 12:53:19 2010 New Revision: 113372 URL: http://llvm.org/viewvc/llvm-project?rev=113372&view=rev Log: Disable minimized symbol tables for now as this was causing test suite failures. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113372&r1=113371&r2=113372&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Sep 8 12:53:19 2010 @@ -206,7 +206,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); - ParseSymtab (true); + ParseSymtab (false); } return m_symtab_ap.get(); } From clattner at apple.com Wed Sep 8 13:46:56 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Sep 2010 11:46:56 -0700 Subject: [Lldb-commits] Patch to fix build Message-ID: <0C7EC5A5-E0FC-4055-965A-B4EC4C3DD01F@apple.com> The build fails for me, building with xcode 3 + gcc 4.2 + the xcode project with these errors: /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp: In function 'bool UniversalMachOFileContainsArchAndUUID(const lldb_private::FileSpec&, const lldb_private::ArchSpec*, const lldb_private::UUID*, off_t, lldb_private::DataExtractor&, uint32_t, uint32_t)': /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:148: error: 'cpu_type_t' was not declared in this scope /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:148: error: expected `;' before 'arch_cputype' /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:149: error: 'cpu_subtype_t' was not declared in this scope /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:149: error: expected `;' before 'arch_cpusubtype' /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:157: error: 'arch_cputype' was not declared in this scope /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:157: error: 'arch_cpusubtype' was not declared in this scope Is this the right fix? -------------- next part -------------- A non-text attachment was scrubbed... Name: symbols.patch Type: application/octet-stream Size: 385 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100908/580f6a71/attachment.obj -------------- next part -------------- -Chris From scallanan at apple.com Wed Sep 8 15:04:08 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 08 Sep 2010 20:04:08 -0000 Subject: [Lldb-commits] [lldb] r113396 - in /lldb/trunk/source/Expression: ClangFunction.cpp IRDynamicChecks.cpp IRForTarget.cpp Message-ID: <20100908200408.348682A6C12C@llvm.org> Author: spyffe Date: Wed Sep 8 15:04:08 2010 New Revision: 113396 URL: http://llvm.org/viewvc/llvm-project?rev=113396&view=rev Log: Fixed an expression parser bug that prevented certain functions from being resolved correctly. Some functions (particularly varargs functions) are BitCast before being called, and the problem was that a CallInst where getCalledValue() returned a BitCast ConstantExpr was not being relocated at all. This problem should now be resolved for the case of BitCast. Modified: lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=113396&r1=113395&r2=113396&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Sep 8 15:04:08 2010 @@ -460,8 +460,14 @@ if (call_plan_sp == NULL) return eExecutionSetupError; +//#define SINGLE_STEP_EXPRESSIONS + +#ifdef SINGLE_STEP_EXPRESSIONS + return eExecutionInterrupted; +#else call_plan_sp->SetPrivate(true); exe_ctx.thread->QueueThreadPlan(call_plan_sp, true); +#endif // We need to call the function synchronously, so spin waiting for it to return. // If we get interrupted while executing, we're going to lose our context, and Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=113396&r1=113395&r2=113396&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Sep 8 15:04:08 2010 @@ -343,6 +343,18 @@ if (!vpc.Instrument()) return false; + if (log) + { + std::string s; + raw_string_ostream oss(s); + + M.print(oss, NULL); + + oss.flush(); + + log->Printf("Module after dynamic checks: \n%s", s.c_str()); + } + return true; } Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=113396&r1=113395&r2=113396&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Sep 8 15:04:08 2010 @@ -579,7 +579,23 @@ Function *fun = C->getCalledFunction(); if (fun == NULL) - return true; + { + Value *val = C->getCalledValue(); + + ConstantExpr *const_expr = dyn_cast(val); + + if (const_expr && const_expr->getOpcode() == Instruction::BitCast) + { + fun = dyn_cast(const_expr->getOperand(0)); + + if (!fun) + return true; + } + else + { + return true; + } + } clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); uint64_t fun_addr; From johnny.chen at apple.com Wed Sep 8 15:56:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 08 Sep 2010 20:56:17 -0000 Subject: [Lldb-commits] [lldb] r113407 - /lldb/trunk/test/dotest.py Message-ID: <20100908205617.18BD62A6C12C@llvm.org> Author: johnny Date: Wed Sep 8 15:56:16 2010 New Revision: 113407 URL: http://llvm.org/viewvc/llvm-project?rev=113407&view=rev Log: Added '-d' option to the test driver to spit out the process id and do a delay of 10 seconds in order for the debugger to attach. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=113407&r1=113406&r2=113407&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Sep 8 15:56:16 2010 @@ -14,9 +14,7 @@ working directory is searched if nothing is specified on the command line. """ -import os -import sys -import time +import os, signal, sys, time import unittest2 class _WritelnDecorator(object): @@ -41,6 +39,9 @@ # The test suite. suite = unittest2.TestSuite() +# Delay startup in order for the debugger to attach. +delay = False + # Default verbosity is 0. verbose = 0 @@ -59,6 +60,7 @@ Usage: dotest.py [option] [args] where options: -h : print this help message and exit (also --help) +-d : delay startup for 10 seconds (in order for the debugger to attach) -t : trace lldb command execution and result -v : do verbose mode of unittest framework @@ -111,6 +113,7 @@ '-h/--help as the first option prints out usage info and exit the program. """ + global delay global verbose global testdirs @@ -124,6 +127,9 @@ # Process possible trace and/or verbose flag. index = 1 for i in range(1, len(sys.argv) - 1): + if sys.argv[index].startswith('-d'): + delay = True + index += 1 if sys.argv[index].startswith('-t'): os.environ["LLDB_COMMAND_TRACE"] = "YES" index += 1 @@ -160,6 +166,27 @@ # setupSysPath() initTestdirs() + +# +# If '-d' is specified, do a delay of 10 seconds for the debugger to attach. +# +if delay: + def alarm_handler(*args): + raise Exception("timeout") + + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(10) + sys.stdout.write("pid=" + str(os.getpid()) + '\n') + sys.stdout.write("Enter RET to proceed (or timeout after 10 seconds):") + sys.stdout.flush() + try: + text = sys.stdin.readline() + except: + text = "" + signal.alarm(0) + sys.stdout.write("proceeding...\n") + pass + for testdir in testdirs: os.path.walk(testdir, visit, 'Test') From ctice at apple.com Wed Sep 8 16:06:11 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 08 Sep 2010 21:06:11 -0000 Subject: [Lldb-commits] [lldb] r113408 - in /lldb/trunk/source/Commands: CommandObjectBreakpoint.cpp CommandObjectBreakpointCommand.cpp CommandObjectCommands.cpp CommandObjectFrame.cpp CommandObjectHelp.cpp CommandObjectImage.cpp CommandObjectLog.cpp CommandObjectMemory.cpp CommandObjectProcess.cpp CommandObjectSettings.cpp CommandObjectSource.cpp CommandObjectTarget.cpp CommandObjectThread.cpp Message-ID: <20100908210611.872962A6C12C@llvm.org> Author: ctice Date: Wed Sep 8 16:06:11 2010 New Revision: 113408 URL: http://llvm.org/viewvc/llvm-project?rev=113408&view=rev Log: Clean up, clarify and standardize help text, and fix a few help text formatting problems. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 8 16:06:11 2010 @@ -771,7 +771,7 @@ CommandObjectBreakpointEnable::CommandObjectBreakpointEnable () : CommandObject ("enable", - "Enables the specified disabled breakpoint(s). If no breakpoints are specified, enables all of them.", + "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", "breakpoint enable [ | ]") { // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different @@ -873,7 +873,7 @@ CommandObjectBreakpointDisable::CommandObjectBreakpointDisable () : CommandObject ("disable", - "Disables the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disables them all.", + "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", "disable [ | ]") { // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different @@ -973,7 +973,7 @@ CommandObjectBreakpointDelete::CommandObjectBreakpointDelete() : CommandObject ("breakpoint delete", - "Delete the specified breakpoint(s). If no breakpoints are specified, deletes them all.", + "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", "breakpoint delete [ | ]") { } @@ -1208,7 +1208,7 @@ #pragma mark Modify CommandObjectBreakpointModify::CommandObjectBreakpointModify () : - CommandObject ("breakpoint modify", "Modifys the options on a breakpoint or set of breakpoints in the executable.", + CommandObject ("breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable.", "breakpoint modify break-id [break-id ...]") { } Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Wed Sep 8 16:06:11 2010 @@ -50,7 +50,7 @@ "Write the breakpoint command script in the Python scripting language."}, { LLDB_OPT_SET_3, true, "commands", 'c', no_argument, NULL, 0, NULL, - "Write the breakpoint command script using the command line commands."}, + "Write the breakpoint command script using standard debugger commands."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -112,7 +112,7 @@ CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd () : CommandObject ("add", - "Adds a set of commands to a breakpoint to be executed whenever a breakpoint is hit.", + "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.", "breakpoint command add ") { SetHelpLong ( @@ -193,8 +193,8 @@ \n\ (lldb) \n\ \n\ -Special information debugger command breakpoint commands \n\ ---------------------------------------------------------- \n\ +Special information about debugger command breakpoint commands \n\ +-------------------------------------------------------------- \n\ \n\ You may enter any debugger command, exactly as you would at the \n\ debugger prompt. You may enter as many debugger commands as you like, \n\ Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Sep 8 16:06:11 2010 @@ -33,7 +33,7 @@ public: CommandObjectCommandsSource() : CommandObject ("commands source", - "Reads in debugger commands from the file and executes them.", + "Read in debugger commands from the file and execute them.", "command source ") { } @@ -139,8 +139,8 @@ public: CommandObjectCommandsAlias () : CommandObject ("commands alias", - "Allows users to define their own debugger command abbreviations.", - "commands alias []") + "Allow users to define their own debugger command abbreviations.", + "commands alias []") { SetHelpLong( "'alias' allows the user to create a short-cut or abbreviation for long \n\ Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Sep 8 16:06:11 2010 @@ -53,7 +53,7 @@ CommandObjectFrameInfo () : CommandObject ("frame info", - "Lists information about the currently selected frame in the current thread.", + "List information about the currently selected frame in the current thread.", "frame info", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -96,7 +96,8 @@ CommandObjectFrameSelect () : CommandObject ("frame select", - "Select the current frame by index in the current thread.", + //"Select the current frame by index in the current thread.", + "Select a frame by index from within the current thread and make it the current frame.", "frame select ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -362,12 +363,13 @@ } if (addr == LLDB_INVALID_ADDRESS) { - result.GetErrorStream().Printf ("error: %s is not loaded", var_sc.module_sp->GetFileSpec().GetFilename().AsCString()); + result.GetErrorStream().Printf ("error: %s is not loaded\n", + var_sc.module_sp->GetFileSpec().GetFilename().AsCString()); } } else { - result.GetErrorStream().Printf ("error: unable to resolve the variable address 0x%llx", file_addr); + result.GetErrorStream().Printf ("error: unable to resolve the variable address 0x%llx\n", file_addr); } } else Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Wed Sep 8 16:06:11 2010 @@ -112,7 +112,7 @@ const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelpLong(), 1); + output_strm.Printf ("\n%s", long_help); else interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Wed Sep 8 16:06:11 2010 @@ -887,7 +887,7 @@ CommandObjectImageDumpLineTable () : CommandObjectImageDumpSourceFileList ("image dump line-table", "Dump the debug symbol file for one or more executable images.", - "image dump line-table [ ...]") + "image dump line-table [ ...]") { } @@ -974,7 +974,7 @@ //------------------------------------------------------------------ CommandObjectImageDump(CommandInterpreter &interpreter) : CommandObjectMultiword ("image dump", - "Dumps information in one or more executable images; 'line-table' expects a source file name", + "A set of commands for dumping information about one or more executable images; 'line-table' expects a source file name", "image dump [symtab|sections|symfile|line-table] [ ...]") { LoadSubCommand (interpreter, "symtab", CommandObjectSP (new CommandObjectImageDumpSymtab ())); Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Wed Sep 8 16:06:11 2010 @@ -83,7 +83,7 @@ { if (args.GetArgumentCount() < 1) { - result.GetErrorStream() << m_cmd_syntax.c_str(); + result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str()); } else { @@ -254,7 +254,7 @@ const size_t argc = args.GetArgumentCount(); if (argc == 0) { - result.GetErrorStream() << m_cmd_syntax.c_str(); + result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str()); } else { Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Sep 8 16:06:11 2010 @@ -178,7 +178,7 @@ CommandObjectMemoryRead () : CommandObject ("memory read", - "Read memory from the process being debugged.", + "Read from the memory of the process being debugged.", "memory read [] []", eFlagProcessMustBeLaunched) { @@ -396,7 +396,7 @@ CommandObjectMemoryWrite () : CommandObject ("memory write", - "Write memory to the process being debugged.", + "Write to the memory of the process being debugged.", "memory write [] [value1 value2 ...]", eFlagProcessMustBeLaunched) { Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Sep 8 16:06:11 2010 @@ -103,7 +103,7 @@ CommandObjectProcessLaunch () : CommandObject ("process launch", - "Launches the executable in the debugger.", + "Launch the executable in the debugger.", "process launch [] []") { } @@ -454,7 +454,7 @@ CommandObjectProcessAttach () : CommandObject ("process attach", - "Attaches to a process.", + "Attach to a process.", "process attach ") { SetHelpLong("Currently, you must set the executable file before you can attach " @@ -683,7 +683,7 @@ CommandObjectProcessContinue () : CommandObject ("process continue", - "Continues execution all threads in the current process.", + "Continue execution of all threads in the current process.", "process continue", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -770,7 +770,7 @@ CommandObjectProcessDetach () : CommandObject ("process detach", - "Detaches from the current process being debugged.", + "Detach from the current process being debugged.", "process detach", eFlagProcessMustBeLaunched) { @@ -818,7 +818,7 @@ CommandObjectProcessSignal () : CommandObject ("process signal", - "Sends a UNIX signal to the current process being debugged.", + "Send a UNIX signal to the current process being debugged.", "process signal ") { } @@ -884,7 +884,7 @@ CommandObjectProcessInterrupt () : CommandObject ("process interrupt", - "Interrupts the current process being debugged.", + "Interrupt the current process being debugged.", "process interrupt", eFlagProcessMustBeLaunched) { @@ -945,7 +945,7 @@ CommandObjectProcessKill () : CommandObject ("process kill", - "Terminates the current process being debugged.", + "Terminate the current process being debugged.", "process kill", eFlagProcessMustBeLaunched) { @@ -999,9 +999,9 @@ { public: CommandObjectProcessStatus () : - CommandObject ("status", - "Shows the current status and location of executing process.", - "status", + CommandObject ("process status", + "Show the current status and location of executing process.", + "process status", 0) { } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Sep 8 16:06:11 2010 @@ -62,7 +62,7 @@ CommandObjectSettingsSet::CommandObjectSettingsSet () : CommandObject ("settings set", - "Allows the user to set or change the value of a single debugger setting variable.", + "Set or change the value of a single debugger setting variable.", "settings set [] "), m_options () { @@ -259,7 +259,7 @@ CommandObjectSettingsShow::CommandObjectSettingsShow () : CommandObject ("settings show", - "Allows the user to see a single internal debugger setting variable and its value, or lists them all.", + "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", "settings show []") { } @@ -365,7 +365,7 @@ CommandObjectSettingsList::CommandObjectSettingsList () : CommandObject ("settings list", - "Lists the internal debugger settings variables available to the user to 'set' or 'show'.", + "List all the internal debugger settings variables that are available to the user to 'set' or 'show'.", "settings list") { } @@ -407,7 +407,7 @@ CommandObjectSettingsRemove::CommandObjectSettingsRemove () : CommandObject ("settings remove", - "Removes the specified element from an internal debugger settings array or dictionary variable.", + "Remove the specified element from an internal debugger settings array or dictionary variable.", "settings remove [|\"key\"]") { } @@ -502,7 +502,7 @@ CommandObjectSettingsReplace::CommandObjectSettingsReplace () : CommandObject ("settings replace", - "Replaces the specified element from an internal debugger settings array or dictionary variable.", + "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", "settings replace [|\"\"] ") { } @@ -612,7 +612,7 @@ CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore () : CommandObject ("settings insert-before", - "Inserts value(s) into an internal debugger settings array variable, immediately before the specified element.", + "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", "settings insert-before [] ") { } @@ -724,7 +724,7 @@ CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter () : CommandObject ("settings insert-after", - "Inserts value(s) into an internal debugger settings array variable, immediately after the specified element.", + "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", "settings insert-after [] ") { } @@ -836,7 +836,7 @@ CommandObjectSettingsAppend::CommandObjectSettingsAppend () : CommandObject ("settings append", - "Appends new value to the end of an internal debugger settings array, dictionary or string variable.", + "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", "settings append ") { } @@ -936,7 +936,7 @@ CommandObjectSettingsClear::CommandObjectSettingsClear () : CommandObject ("settings clear", - "Erases all the contents of an internal debugger settings variables; only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", + "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", "settings clear") { } Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed Sep 8 16:06:11 2010 @@ -98,7 +98,7 @@ public: CommandObjectSourceInfo() : CommandObject ("source info", - "Display info on the source lines from the current executable's debug info.", + "Display information about the source lines from the current executable's debug info.", "source info []") { } @@ -229,7 +229,7 @@ public: CommandObjectSourceList() : CommandObject ("source list", - "Display source files from the current executable's debug info.", + "Display source code (as specified) based on the current executable's debug info.", "source list [] []") { } Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Sep 8 16:06:11 2010 @@ -99,7 +99,7 @@ CommandObjectTargetImageSearchPathsClear () : CommandObject ("target image-search-paths clear", - "Clears all current image search paths substitution pairs from the current target.", + "Clear all current image search path substitution pairs from the current target.", "target image-search-paths clear") { } @@ -134,7 +134,7 @@ CommandObjectTargetImageSearchPathsInsert () : CommandObject ("target image-search-paths insert", - "Inserts a new image search paths substitution pair to the current target at the specified index.", + "Insert a new image search path substitution pair into the current target at the specified index.", "target image-search-paths insert [ ] ...") { } @@ -217,7 +217,7 @@ CommandObjectTargetImageSearchPathsList () : CommandObject ("target image-search-paths list", - "Lists all current image search paths substitution pairs in the current target.", + "List all current image search path substitution pairs in the current target.", "target image-search-paths list") { } @@ -258,7 +258,7 @@ CommandObjectTargetImageSearchPathsQuery () : CommandObject ("target image-search-paths query", - "Transforms a path using the first applicable image search path.", + "Transform a path using the first applicable image search path.", "target image-search-paths query ") { } Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=113408&r1=113407&r2=113408&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Wed Sep 8 16:06:11 2010 @@ -332,7 +332,7 @@ CommandObjectThreadBacktrace () : CommandObject ("thread backtrace", - "Shows the stack for one or more threads. If no threads are specified, shows the currently selected thread. Use the thread-index \"all\" to see all threads.", + "Show the stack for one or more threads. If no threads are specified, shows the currently selected thread. Use the thread-index \"all\" to see all threads.", "thread backtrace [] ...", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options() @@ -793,7 +793,7 @@ CommandObjectThreadContinue () : CommandObject ("thread continue", - "Continues execution of one or more threads in an active process.", + "Continue execution of one or more threads in an active process.", "thread continue [ ...]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -1037,7 +1037,7 @@ CommandObjectThreadUntil () : CommandObject ("thread until", - "Runs the current or specified thread until it reaches a given line number or leaves the current function.", + "Run the current or specified thread until it reaches a given line number or leaves the current function.", "thread until [] ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options () @@ -1235,7 +1235,7 @@ CommandObjectThreadSelect () : CommandObject ("thread select", - "Selects a threads as the currently active thread.", + "Select a threads as the currently active thread.", "thread select ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -1304,7 +1304,7 @@ CommandObjectThreadList (): CommandObject ("thread list", - "Shows a summary of all current threads in a process.", + "Show a summary of all current threads in a process.", "thread list", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { From ctice at apple.com Wed Sep 8 17:08:58 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 08 Sep 2010 22:08:58 -0000 Subject: [Lldb-commits] [lldb] r113421 - in /lldb/trunk/source/Commands: CommandObjectBreakpoint.cpp CommandObjectCommands.cpp CommandObjectFile.cpp CommandObjectRegister.cpp CommandObjectThread.cpp Message-ID: <20100908220858.8B4AC2A6C12C@llvm.org> Author: ctice Date: Wed Sep 8 17:08:58 2010 New Revision: 113421 URL: http://llvm.org/viewvc/llvm-project?rev=113421&view=rev Log: More help text fixes. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=113421&r1=113420&r2=113421&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 8 17:08:58 2010 @@ -1209,7 +1209,7 @@ CommandObjectBreakpointModify::CommandObjectBreakpointModify () : CommandObject ("breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable.", - "breakpoint modify break-id [break-id ...]") + "breakpoint modify [ ...]") { } Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=113421&r1=113420&r2=113421&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Sep 8 17:08:58 2010 @@ -146,21 +146,21 @@ "'alias' allows the user to create a short-cut or abbreviation for long \n\ commands, multi-word commands, and commands that take particular options. \n\ Below are some simple examples of how one might use the 'alias' command: \n\ - \n 'command alias sc script' // Creates the abbreviation 'sc' for the 'script' \n\ - // command. \n\ - 'command alias bp breakpoint' // Creates the abbreviation 'bp' for the 'breakpoint' \n\ - // command. Since breakpoint commands are two-word \n\ - // commands, the user will still need to enter the \n\ - // second word after 'bp', e.g. 'bp enable' or \n\ - // 'bp delete'. \n\ - 'command alias bpi breakpoint list' // Creates the abbreviation 'bpi' for the \n\ - // two-word command 'breakpoint list'. \n\ + \n 'commands alias sc script' // Creates the abbreviation 'sc' for the 'script' \n\ + // command. \n\ + 'commands alias bp breakpoint' // Creates the abbreviation 'bp' for the 'breakpoint' \n\ + // command. Since breakpoint commands are two-word \n\ + // commands, the user will still need to enter the \n\ + // second word after 'bp', e.g. 'bp enable' or \n\ + // 'bp delete'. \n\ + 'commands alias bpl breakpoint list' // Creates the abbreviation 'bpl' for the \n\ + // two-word command 'breakpoint list'. \n\ \nAn alias can include some options for the command, with the values either \n\ filled in at the time the alias is created, or specified as positional \n\ arguments, to be filled in when the alias is invoked. The following example \n\ shows how to create aliases with options: \n\ \n\ - 'command alias bfl breakpoint set -f %1 -l %2' \n\ + 'commands alias bfl breakpoint set -f %1 -l %2' \n\ \nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\ options already part of the alias. So if the user wants to set a breakpoint \n\ by file and line without explicitly having to use the -f and -l options, the \n\ @@ -175,14 +175,14 @@ filled in with the first argument following 'bfl' and the actual line number \n\ value will be filled in with the second argument. The user would use this \n\ alias as follows: \n\ - \n (dbg) commands alias bfl breakpoint set -f %1 -l %2 \n\ + \n (lldb) commands alias bfl breakpoint set -f %1 -l %2 \n\ <... some time later ...> \n\ - (dbg) bfl my-file.c 137 \n\ + (lldb) bfl my-file.c 137 \n\ \nThis would be the same as if the user had entered \n\ 'breakpoint set -f my-file.c -l 137'. \n\ \nAnother example: \n\ - \n (dbg) commands alias pltty process launch -s -o %1 -e %1 \n\ - (dbg) pltty /dev/tty0 \n\ + \n (lldb) commands alias pltty process launch -s -o %1 -e %1 \n\ + (lldb) pltty /dev/tty0 \n\ // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\ \nIf the user always wanted to pass the same value to a particular option, the \n\ alias could be defined with that value directly in the alias as a constant, \n\ Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113421&r1=113420&r2=113421&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Wed Sep 8 17:08:58 2010 @@ -38,7 +38,7 @@ lldb::OptionDefinition CommandObjectFile::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, "", "Specify the architecture to launch."}, + { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, "", "Specify the architecture to be used when the process is launched."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -111,7 +111,7 @@ ) { const char *file_path = command.GetArgumentAtIndex(0); - Timer scoped_timer(__PRETTY_FUNCTION__, "(dbg) file '%s'", file_path); + Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) file '%s'", file_path); const int argc = command.GetArgumentCount(); if (argc == 1) { Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=113421&r1=113420&r2=113421&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Wed Sep 8 17:08:58 2010 @@ -33,7 +33,7 @@ public: CommandObjectRegisterRead () : CommandObject ("register read", - "Dump the one or more register values from the current frame.", + "Dump the contents of one or more register values from the current frame.", "register read [ [ [...]]]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=113421&r1=113420&r2=113421&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Wed Sep 8 17:08:58 2010 @@ -332,7 +332,7 @@ CommandObjectThreadBacktrace () : CommandObject ("thread backtrace", - "Show the stack for one or more threads. If no threads are specified, shows the currently selected thread. Use the thread-index \"all\" to see all threads.", + "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", "thread backtrace [] ...", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options() @@ -472,7 +472,7 @@ CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, "", "How many frames to display (-1 for all)"}, -{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, "", "Where to start the backtrace"}, +{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, "", "Frame in which to start the backtrace"}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -1235,7 +1235,7 @@ CommandObjectThreadSelect () : CommandObject ("thread select", - "Select a threads as the currently active thread.", + "Select a thread as the currently active thread.", "thread select ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { @@ -1388,21 +1388,21 @@ LoadSubCommand (interpreter, "until", CommandObjectSP (new CommandObjectThreadUntil ())); LoadSubCommand (interpreter, "step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( "thread step-in", - "Source level single step in in specified thread (current thread, if none specified).", + "Source level single step in specified thread (current thread, if none specified).", "thread step-in []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeInto, eStepScopeSource))); LoadSubCommand (interpreter, "step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", - "Source level single step out in specified thread (current thread, if none specified).", + "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", "thread step-out []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, eStepScopeSource))); LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", - "Source level single step over in specified thread (current thread, if none specified).", + "Source level single step in specified thread (current thread, if none specified), stepping over calls.", "thread step-over []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOver, From scallanan at apple.com Wed Sep 8 17:38:54 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 08 Sep 2010 22:38:54 -0000 Subject: [Lldb-commits] [lldb] r113429 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20100908223854.58EAE2A6C12C@llvm.org> Author: spyffe Date: Wed Sep 8 17:38:54 2010 New Revision: 113429 URL: http://llvm.org/viewvc/llvm-project?rev=113429&view=rev Log: There is currently a problem with our interaction with the Clang parser that prevents us from passing Objective-C types to functions that expect C types. This quick hack keeps us in business until that interaction is fixed. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113429&r1=113428&r2=113429&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 8 17:38:54 2010 @@ -955,6 +955,9 @@ if (fun) { +#define BROKEN_OVERLOADING + // Awaiting a fix on the Clang side +#ifndef BROKEN_OVERLOADING Type *fun_type = fun->GetType(); if (!fun_type) @@ -980,6 +983,11 @@ void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type); fun_decl = context.AddFunDecl(copied_type); +#else + fun_address = &fun->GetAddressRange().GetBaseAddress(); + + fun_decl = context.AddGenericFunDecl(); +#endif } else if (symbol) { From johnny.chen at apple.com Wed Sep 8 17:54:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 08 Sep 2010 22:54:46 -0000 Subject: [Lldb-commits] [lldb] r113432 - in /lldb/trunk/test: conditional_break/TestConditionalBreak.py lldbutil.py Message-ID: <20100908225446.47CF12A6C12C@llvm.org> Author: johnny Date: Wed Sep 8 17:54:46 2010 New Revision: 113432 URL: http://llvm.org/viewvc/llvm-project?rev=113432&view=rev Log: Added a lldbutil.py module, which contains utility functions which can be used from scripting applications. An example usage from TestConditionalBreak.py is: import lldbutil lldbutil.PrintStackTrace(thread) ./dotest.py -v conditional_break ---------------------------------------------------------------------- Collected 2 tests test_with_dsym (TestConditionalBreak.ConditionalBreakTestCase) Exercise some thread and frame APIs to break if c() is called by a(). ... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`a at main.c:25 frame #3: a.out`main at main.c:44 frame #4: a.out`start Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`main at main.c:47 frame #3: a.out`start Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`a at main.c:27 frame #2: a.out`main at main.c:50 frame #3: a.out`start ok test_with_dwarf (TestConditionalBreak.ConditionalBreakTestCase) Exercise some thread and frame APIs to break if c() is called by a(). ... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`a at main.c:25 frame #3: a.out`main at main.c:44 frame #4: a.out`start Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`main at main.c:47 frame #3: a.out`start Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`a at main.c:27 frame #2: a.out`main at main.c:50 frame #3: a.out`start ok ---------------------------------------------------------------------- Ran 2 tests in 7.803s OK Added: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113432&r1=113431&r2=113432&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Wed Sep 8 17:54:46 2010 @@ -45,6 +45,8 @@ target = self.dbg.GetSelectedTarget() process = target.GetProcess() thread = process.GetThreadAtIndex(0) + import lldbutil + lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) Added: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=113432&view=auto ============================================================================== --- lldb/trunk/test/lldbutil.py (added) +++ lldb/trunk/test/lldbutil.py Wed Sep 8 17:54:46 2010 @@ -0,0 +1,63 @@ +""" +LLDB modules which contains miscellaneous utilities. +""" + +import lldb + +def GetFunctionNames(thread): + """ + Returns a sequence of function names from the stack frames of this thread. + """ + def GetFuncName(i): + return thread.GetFrameAtIndex(i).GetFunction().GetName() + + return map(GetFuncName, range(thread.GetNumFrames())) + + +def GetFilenames(thread): + """ + Returns a sequence of file names from the stack frames of this thread. + """ + def GetFilename(i): + return thread.GetFrameAtIndex(i).GetLineEntry().GetFileSpec().GetFilename() + + return map(GetFilename, range(thread.GetNumFrames())) + + +def GetLineNumbers(thread): + """ + Returns a sequence of line numbers from the stack frames of this thread. + """ + def GetLineNumber(i): + return thread.GetFrameAtIndex(i).GetLineEntry().GetLine() + + return map(GetLineNumber, range(thread.GetNumFrames())) + + +def GetModuleNames(thread): + """ + Returns a sequence of module names from the stack frames of this thread. + """ + def GetModuleName(i): + return thread.GetFrameAtIndex(i).GetModule().GetFileSpec().GetFilename() + + return map(GetModuleName, range(thread.GetNumFrames())) + + +def PrintStackTrace(thread): + """Prints a simple stack trace of this thread.""" + depth = thread.GetNumFrames() + + mods = GetModuleNames(thread) + funcs = GetFunctionNames(thread) + files = GetFilenames(thread) + lines = GetLineNumbers(thread) + + print "Stack trace for thread id={0:#x} name={1} queue={2}:".format( + thread.GetThreadID(), thread.GetName(), thread.GetQueueName()) + + for i in range(depth - 1): + print " frame #{num}: {mod}`{func} at {file}:{line}".format( + num=i, mod=mods[i], func=funcs[i], file=files[i], line=lines[i]) + + print " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1]) From sabre at nondot.org Wed Sep 8 17:55:31 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Sep 2010 22:55:31 -0000 Subject: [Lldb-commits] [lldb] r113433 - in /lldb/trunk/source/Commands: CommandObjectProcess.cpp CommandObjectSettings.cpp CommandObjectSource.cpp Message-ID: <20100908225531.F20BC2A6C12C@llvm.org> Author: lattner Date: Wed Sep 8 17:55:31 2010 New Revision: 113433 URL: http://llvm.org/viewvc/llvm-project?rev=113433&view=rev Log: fix a bunch of signed/unsigned comparison warnings, stop evaluating "getsize" every time through the loop. Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113433&r1=113432&r2=113433&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Sep 8 17:55:31 2010 @@ -174,8 +174,8 @@ if (run_args_value.GetSize() > 0) { run_args = new Args; - for (int i = 0; i < run_args_value.GetSize(); ++i) - run_args->AppendArgument (run_args_value.GetStringAtIndex (i)); + for (unsigned i = 0, e = run_args_value.GetSize(); i != e; ++i) + run_args->AppendArgument(run_args_value.GetStringAtIndex(i)); } Args *environment = NULL; @@ -185,7 +185,7 @@ if (env_vars_value.GetSize() > 0) { environment = new Args; - for (int i = 0; i < env_vars_value.GetSize(); ++i) + for (unsigned i = 0, e = env_vars_value.GetSize(); i != e; ++i) environment->AppendArgument (env_vars_value.GetStringAtIndex (i)); } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113433&r1=113432&r2=113433&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Sep 8 17:55:31 2010 @@ -308,7 +308,7 @@ else { result.AppendMessageWithFormat ("%s%s:\n", variable_name, type_name); - for (int i = 0; i < value.GetSize(); ++i) + for (unsigned i = 0, e = value.GetSize(); i != e; ++i) { result.AppendMessageWithFormat (" [%d]: '%s'\n", i, value.GetStringAtIndex (i)); } Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=113433&r1=113432&r2=113433&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed Sep 8 17:55:31 2010 @@ -283,7 +283,7 @@ if (m_options.m_modules.size() > 0) { ModuleList matching_modules; - for (int i = 0; i < m_options.m_modules.size(); i++) + for (unsigned i = 0, e = m_options.m_modules.size(); i != e; i++) { FileSpec module_spec(m_options.m_modules[i].c_str()); if (module_spec) @@ -457,7 +457,7 @@ if (m_options.m_modules.size() > 0) { ModuleList matching_modules; - for (int i = 0; i < m_options.m_modules.size(); i++) + for (unsigned i = 0, e = m_options.m_modules.size(); i != e; i++) { FileSpec module_spec(m_options.m_modules[i].c_str()); if (module_spec) @@ -495,7 +495,7 @@ bool got_multiple = false; FileSpec *test_cu_spec = NULL; - for (int i = 0; i < num_matches; i++) + for (unsigned i = 0; i < num_matches; i++) { sc_list.GetContextAtIndex(i, sc); if (sc.comp_unit) From sabre at nondot.org Wed Sep 8 18:01:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Sep 2010 23:01:02 -0000 Subject: [Lldb-commits] [lldb] r113437 - /lldb/trunk/source/Expression/ClangFunction.cpp Message-ID: <20100908230102.B6D172A6C12C@llvm.org> Author: lattner Date: Wed Sep 8 18:01:02 2010 New Revision: 113437 URL: http://llvm.org/viewvc/llvm-project?rev=113437&view=rev Log: remove unneeded #include, reducing # static ctors. Modified: lldb/trunk/source/Expression/ClangFunction.cpp Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=113437&r1=113436&r2=113437&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Sep 8 18:01:02 2010 @@ -18,7 +18,6 @@ #include "clang/Frontend/CompilerInstance.h" #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/ExecutionEngine/JIT.h" #include "llvm/Module.h" // Project includes From sabre at nondot.org Wed Sep 8 18:01:14 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 08 Sep 2010 23:01:14 -0000 Subject: [Lldb-commits] [lldb] r113438 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointOptions.h include/lldb/Interpreter/Options.h source/API/SBDebugger.cpp source/Host/macosx/Symbols.cpp Message-ID: <20100908230114.EAA422A6C12C@llvm.org> Author: lattner Date: Wed Sep 8 18:01:14 2010 New Revision: 113438 URL: http://llvm.org/viewvc/llvm-project?rev=113438&view=rev Log: eliminate some clang warnings. Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Host/macosx/Symbols.cpp Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=113438&r1=113437&r2=113438&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Wed Sep 8 18:01:14 2010 @@ -84,7 +84,7 @@ bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); bool IsCallbackSynchronous () { return m_callback_is_synchronous; - }; + } Baton *GetBaton (); const Baton *GetBaton () const; void ClearCallback (); Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=113438&r1=113437&r2=113438&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Wed Sep 8 18:01:14 2010 @@ -165,7 +165,7 @@ // this class. virtual const lldb::OptionDefinition* - GetDefinitions () { return NULL; }; + GetDefinitions () { return NULL; } virtual void ResetOptionValues (); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=113438&r1=113437&r2=113438&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Sep 8 18:01:14 2010 @@ -585,7 +585,7 @@ lldb::SettableVariableType var_type; StringList value = root_settings_controller->GetVariable (var_name, var_type); - for (int i = 0; i < value.GetSize(); ++i) + for (unsigned i = 0; i != value.GetSize(); ++i) ret_value.AppendString (value.GetStringAtIndex(i)); return ret_value; Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=113438&r1=113437&r2=113438&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Wed Sep 8 18:01:14 2010 @@ -25,6 +25,7 @@ #include "lldb/Core/UUID.h" #include "Host/macosx/cfcpp/CFCReleaser.h" +#include "mach/machine.h" using namespace lldb; using namespace lldb_private; From clattner at apple.com Wed Sep 8 18:03:03 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 8 Sep 2010 16:03:03 -0700 Subject: [Lldb-commits] Patch to fix build In-Reply-To: <0C7EC5A5-E0FC-4055-965A-B4EC4C3DD01F@apple.com> References: <0C7EC5A5-E0FC-4055-965A-B4EC4C3DD01F@apple.com> Message-ID: I accidentally committed this with r113438. If this is the "wrong thing", please let me know and I'll be happy to revert it. -Chris On Sep 8, 2010, at 11:46 AM, Chris Lattner wrote: > The build fails for me, building with xcode 3 + gcc 4.2 + the xcode project with these errors: > > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp: In function 'bool UniversalMachOFileContainsArchAndUUID(const lldb_private::FileSpec&, const lldb_private::ArchSpec*, const lldb_private::UUID*, off_t, lldb_private::DataExtractor&, uint32_t, uint32_t)': > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:148: error: 'cpu_type_t' was not declared in this scope > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:148: error: expected `;' before 'arch_cputype' > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:149: error: 'cpu_subtype_t' was not declared in this scope > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:149: error: expected `;' before 'arch_cpusubtype' > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:157: error: 'arch_cputype' was not declared in this scope > /Volumes/Projects/cvs/llvm/tools/lldb/source/Host/macosx/Symbols.cpp:157: error: 'arch_cpusubtype' was not declared in this scope > > > Is this the right fix? > > > > -Chris_______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Wed Sep 8 19:55:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 09 Sep 2010 00:55:07 -0000 Subject: [Lldb-commits] [lldb] r113460 - /lldb/trunk/test/lldbutil.py Message-ID: <20100909005507.D65ED2A6C12C@llvm.org> Author: johnny Date: Wed Sep 8 19:55:07 2010 New Revision: 113460 URL: http://llvm.org/viewvc/llvm-project?rev=113460&view=rev Log: Added GetStackFrames(thread) utility function. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=113460&r1=113459&r2=113460&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed Sep 8 19:55:07 2010 @@ -44,6 +44,16 @@ return map(GetModuleName, range(thread.GetNumFrames())) +def GetStackFrames(thread): + """ + Returns a sequence of stack frames for this thread. + """ + def GetStackFrame(i): + return thread.GetFrameAtIndex(i) + + return map(GetStackFrame, range(thread.GetNumFrames())) + + def PrintStackTrace(thread): """Prints a simple stack trace of this thread.""" depth = thread.GetNumFrames() From ctice at apple.com Thu Sep 9 01:25:08 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 09 Sep 2010 06:25:08 -0000 Subject: [Lldb-commits] [lldb] r113474 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ source/API/ source/Commands/ source/Core/ source/Interpreter/ Message-ID: <20100909062508.EE5662A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 01:25:08 2010 New Revision: 113474 URL: http://llvm.org/viewvc/llvm-project?rev=113474&view=rev Log: Make all debugger-level user settable variables into instance variables. Make get/set variable at the debugger level always set the particular debugger's instance variables rather than the default variables. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSyntax.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 9 01:25:08 2010 @@ -74,6 +74,9 @@ bool BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt); + bool + ValidTermWidthValue (const char *value, Error err); + const ConstString CreateInstanceName (); @@ -83,8 +86,12 @@ static const ConstString & ScriptLangVarName (); + static const ConstString & + TermWidthVarName (); + private: + int m_term_width; std::string m_prompt; lldb::ScriptLanguage m_script_lang; }; @@ -126,13 +133,9 @@ lldb::InstanceSettingsSP CreateNewInstanceSettings (const char *instance_name); - bool - ValidTermWidthValue (const char *value, Error err); - private: // Class-wide settings. - int m_term_width; DISALLOW_COPY_AND_ASSIGN (DebuggerSettingsController); }; Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Thu Sep 9 01:25:08 2010 @@ -82,11 +82,13 @@ const char *value, const lldb::VarSetOperationType op, const bool override, + const char *debugger_instance_name, const char *index_value = NULL); StringList GetVariable (const char *full_dot_name, - lldb::SettableVariableType &var_type); + lldb::SettableVariableType &var_type, + const char *debugger_instance_name); const lldb::UserSettingsControllerSP & GetParent (); Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Thu Sep 9 01:25:08 2010 @@ -233,7 +233,7 @@ } bool - HelpTextContainsWord (const char *search_word); + HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter); //------------------------------------------------------------------ /// The flags accessor. Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Thu Sep 9 01:25:08 2010 @@ -159,6 +159,7 @@ void GenerateOptionUsage (Stream &strm, CommandObject *cmd, + const char *debugger_instance_name, const char *program_name = NULL); // The following two pure virtual functions must be defined by every class that inherits from Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep 9 01:25:08 2010 @@ -569,8 +569,16 @@ SBDebugger::SetInternalVariable (const char *var_name, const char *value) { lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); + + const char *debugger_instance_name; - Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false); + if (m_opaque_sp) + debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString(); + else + debugger_instance_name = ""; + + Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false, + debugger_instance_name); SBError sb_error; sb_error.SetError (err); @@ -581,10 +589,17 @@ SBDebugger::GetInternalVariableValue (const char *var_name) { SBStringList ret_value; + lldb::SettableVariableType var_type; + const char *debugger_instance_name; + lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); - lldb::SettableVariableType var_type; - StringList value = root_settings_controller->GetVariable (var_name, var_type); + if (m_opaque_sp) + debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString(); + else + debugger_instance_name = ""; + + StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name); for (unsigned i = 0; i != value.GetSize(); ++i) ret_value.AppendString (value.GetStringAtIndex(i)); Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Thu Sep 9 01:25:08 2010 @@ -96,7 +96,8 @@ { interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj); + sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj, + interpreter.GetDebugger().GetInstanceName().AsCString()); const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Sep 9 01:25:08 2010 @@ -1424,7 +1424,7 @@ break; default: - m_options.GenerateOptionUsage (result.GetErrorStream(), this); + m_options.GenerateOptionUsage (result.GetErrorStream(), this, interpreter.GetDebugger().GetInstanceName().AsCString()); syntax_error = true; break; } Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Sep 9 01:25:08 2010 @@ -162,6 +162,7 @@ process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); const char *process_name = process->GetInstanceName().AsCString(); + const char *debugger_instance_name = interpreter.GetDebugger().GetInstanceName().AsCString(); StreamString run_args_var_name; StreamString env_vars_var_name; StreamString disable_aslr_var_name; @@ -170,7 +171,8 @@ Args *run_args = NULL; run_args_var_name.Printf ("process.[%s].run-args", process_name); StringList run_args_value = Debugger::GetSettingsController()->GetVariable (run_args_var_name.GetData(), - var_type); + var_type, debugger_instance_name); + if (run_args_value.GetSize() > 0) { run_args = new Args; @@ -181,7 +183,8 @@ Args *environment = NULL; env_vars_var_name.Printf ("process.[%s].env-vars", process_name); StringList env_vars_value = Debugger::GetSettingsController()->GetVariable (env_vars_var_name.GetData(), - var_type); + var_type, debugger_instance_name); + if (env_vars_value.GetSize() > 0) { environment = new Args; @@ -192,7 +195,9 @@ uint32_t launch_flags = eLaunchFlagNone; disable_aslr_var_name.Printf ("process.[%s].disable-aslr", process_name); StringList disable_aslr_value = Debugger::GetSettingsController()->GetVariable(disable_aslr_var_name.GetData(), - var_type); + var_type, + debugger_instance_name); + if (disable_aslr_value.GetSize() > 0) { if (strcmp (disable_aslr_value.GetStringAtIndex(0), "true") == 0) @@ -214,7 +219,9 @@ // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. std::string new_run_args; launch_args.GetCommandString (new_run_args); - Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), lldb::eVarSetOperationAssign, false); + Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), + lldb::eVarSetOperationAssign, false, + interpreter.GetDebugger().GetInstanceName().AsCString()); } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Thu Sep 9 01:25:08 2010 @@ -117,7 +117,8 @@ else { Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAssign, - m_options.m_override); + m_options.m_override, + interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -284,7 +285,8 @@ // The user requested to see the value of a particular variable. lldb::SettableVariableType var_type; const char *variable_name = command.GetArgumentAtIndex (0); - StringList value = root_settings->GetVariable (variable_name, var_type); + StringList value = root_settings->GetVariable (variable_name, var_type, + interpreter.GetDebugger().GetInstanceName().AsCString()); if (value.GetSize() == 0) { @@ -456,7 +458,8 @@ index_value_string = index_value; Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove, - false, index_value_string.c_str()); + false, interpreter.GetDebugger().GetInstanceName().AsCString(), + index_value_string.c_str()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -565,7 +568,8 @@ else { Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, - false, index_value_string.c_str()); + false, interpreter.GetDebugger().GetInstanceName().AsCString(), + index_value_string.c_str()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -676,7 +680,8 @@ else { Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore, - false, index_value_string.c_str()); + false, interpreter.GetDebugger().GetInstanceName().AsCString(), + index_value_string.c_str()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -788,7 +793,8 @@ else { Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter, - false, index_value_string.c_str()); + false, interpreter.GetDebugger().GetInstanceName().AsCString(), + index_value_string.c_str()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -888,7 +894,7 @@ else { Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, - false); + false, interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -969,7 +975,8 @@ return false; } - Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false); + Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false, + interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Thu Sep 9 01:25:08 2010 @@ -76,7 +76,6 @@ if (cmd_obj->GetOptions() != NULL) { output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - //cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, cmd_obj); output_strm.Printf ("(Try 'help %s' for more information on command options syntax.)\n", cmd_obj->GetCommandName()); result.SetStatus (eReturnStatusSuccessFinishNoResult); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 9 01:25:08 2010 @@ -562,8 +562,7 @@ //-------------------------------------------------- Debugger::DebuggerSettingsController::DebuggerSettingsController () : - UserSettingsController ("", lldb::UserSettingsControllerSP()), - m_term_width (80) + UserSettingsController ("", lldb::UserSettingsControllerSP()) { m_default_settings.reset (new DebuggerInstanceSettings (*this, false, InstanceSettings::GetDefaultName().AsCString())); @@ -584,7 +583,7 @@ } bool -Debugger::DebuggerSettingsController::ValidTermWidthValue (const char *value, Error err) +Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) { bool valid = true; @@ -604,7 +603,7 @@ if (! isdigit (value[i])) { valid = false; - err.SetErrorStringWithFormat ("'%s' is not a valid representation of an integer.\n", value); + err.SetErrorStringWithFormat ("'%s' is not a valid representation of an unsigned integer.\n", value); } } @@ -680,7 +679,7 @@ { if (var_name == PromptVarName()) { - UserSettingsController::UpdateStringVariable (op, m_prompt, value, err); + UserSettingsController::UpdateStringVariable (op, m_prompt, value, err); if (!pending) { // 'instance_name' is actually (probably) in the form '[]'; if so, we need to @@ -701,6 +700,13 @@ m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault, &success); } + else if (var_name == TermWidthVarName()) + { + if (ValidTermWidthValue (value, err)) + { + m_term_width = atoi (value); + } + } } void @@ -711,15 +717,7 @@ lldb::VarSetOperationType op, Error &err) { - static ConstString term_width_name ("term-width"); - - if (var_name == term_width_name) - { - if (ValidTermWidthValue (value, err)) - { - m_term_width = atoi (value); - } - } + // There should not be any global variables at the Debugger level. } void @@ -736,6 +734,12 @@ { value.AppendString (ScriptInterpreter::LanguageToString (m_script_lang).c_str()); } + else if (var_name == TermWidthVarName()) + { + StreamString width_str; + width_str.Printf ("%d", m_term_width); + value.AppendString (width_str.GetData()); + } } void @@ -769,14 +773,7 @@ Debugger::DebuggerSettingsController::GetGlobalSettingsValue (const ConstString &var_name, StringList &value) { - static ConstString term_width_name ("term-width"); - - if (var_name == term_width_name) - { - StreamString width_str; - width_str.Printf ("%d", m_term_width); - value.AppendString (width_str.GetData()); - } + // There should not be any global variables at the Debugger level. } bool @@ -845,6 +842,14 @@ return script_lang_var_name; } +const ConstString & +DebuggerInstanceSettings::TermWidthVarName () +{ + static ConstString term_width_var_name ("term-width"); + + return term_width_var_name; +} + //-------------------------------------------------- // DebuggerSettingsController Variable Tables //-------------------------------------------------- @@ -854,7 +859,8 @@ Debugger::DebuggerSettingsController::global_settings_table[] = { //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, - { "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." }, + // The Debugger level global table should always be empty; all Debugger settable variables should be instance + // variables. { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; @@ -864,6 +870,7 @@ Debugger::DebuggerSettingsController::instance_settings_table[] = { //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, + { "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." }, { "script-lang" , eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, { "prompt" , eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Sep 9 01:25:08 2010 @@ -84,7 +84,7 @@ full_name.Printf ("%s.%s", prefix, entry.var_name); else full_name.Printf ("%s", entry.var_name); - SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false); + SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false, ""); } else if ((entry.var_type == lldb::eSetVarTypeEnum) && (entry.enum_values != NULL)) @@ -95,7 +95,7 @@ else full_name.Printf ("%s", entry.var_name); SetVariable (full_name.GetData(), entry.enum_values[0].string_value, lldb::eVarSetOperationAssign, - false); + false, ""); } } global_initialized = true; @@ -215,6 +215,7 @@ const char *value, const lldb::VarSetOperationType op, const bool override, + const char *debugger_instance_name, const char *index_value) { Error err; @@ -298,8 +299,28 @@ value = entry->enum_values[0].string_value; } - m_default_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, - default_name, *entry, op, err, true); + if ((m_settings.level_name.GetLength() > 0) + || strlen (debugger_instance_name) == 0) + { + // Set the default settings + m_default_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, + default_name, *entry, op, err, true); + } + else + { + // We're at the Debugger level; find the correct debugger instance and set those settings + StreamString tmp_name; + if (debugger_instance_name[0] != '[') + tmp_name.Printf ("[%s]", debugger_instance_name); + else + tmp_name.Printf ("%s", debugger_instance_name); + ConstString dbg_name (tmp_name.GetData()); + InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); + if (dbg_settings) + dbg_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, dbg_name, + *entry, op, err, false); + } + if (override) { OverrideAllInstances (const_var_name, value, op, index_value, err); @@ -428,7 +449,8 @@ new_name += '.'; new_name += names.GetArgumentAtIndex (j); } - return child->SetVariable (new_name.c_str(), value, op, override, index_value); + return child->SetVariable (new_name.c_str(), value, op, override, debugger_instance_name, + index_value); } } if (!found) @@ -450,7 +472,8 @@ } StringList -UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type) +UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type, + const char *debugger_instance_name) { Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name); ConstString const_var_name; @@ -496,7 +519,7 @@ new_name += '.'; new_name += names.GetArgumentAtIndex (j); } - return child->GetVariable (new_name.c_str(), var_type); + return child->GetVariable (new_name.c_str(), var_type, debugger_instance_name); } } @@ -530,8 +553,24 @@ } else { - // No valid instance name; assume they want the default settings. - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + if (m_settings.level_name.GetLength() > 0) + { + // No valid instance name; assume they want the default settings. + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + } + else + { + // We're at the Debugger level; use the debugger's instance settings. + StreamString tmp_name; + if (debugger_instance_name[0] != '[') + tmp_name.Printf ("[%s]", debugger_instance_name); + else + tmp_name.Printf ("%s", debugger_instance_name); + ConstString dbg_name (debugger_instance_name); + InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); + if (dbg_settings) + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + } } } } @@ -555,7 +594,21 @@ else if (instance_entry) { var_type = instance_entry->var_type; - m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + if (m_settings.level_name.GetLength() > 0) + m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + else + { + // We're at the Debugger level; use the debugger's instance settings. + StreamString tmp_name; + if (debugger_instance_name[0] != '[') + tmp_name.Printf ("[%s]", debugger_instance_name); + else + tmp_name.Printf ("%s", debugger_instance_name); + ConstString dbg_name (tmp_name.GetData()); + InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name); + if (dbg_settings) + dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value); + } } } @@ -1081,7 +1134,8 @@ full_var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name); else full_var_name.Printf ("%s", entry.var_name); - StringList value = root->GetVariable (full_var_name.GetData(), var_type); + StringList value = root->GetVariable (full_var_name.GetData(), var_type, + interpreter.GetDebugger().GetInstanceName().AsCString()); description.Clear(); if (value.GetSize() == 1) description.Printf ("%s (%s) = '%s'", full_var_name.GetData(), GetTypeString (entry.var_type), @@ -1099,7 +1153,8 @@ root->GetAllInstanceVariableValues (interpreter, result_stream); root->GetAllPendingSettingValues (result_stream); - root->GetAllDefaultSettingValues (result_stream); + if (root->GetLevelName().GetLength() > 0) // Don't bother with default values for Debugger level. + root->GetAllDefaultSettingValues (result_stream); // Now, recurse across all children. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Sep 9 01:25:08 2010 @@ -64,7 +64,9 @@ std::string lang_name = ScriptInterpreter::LanguageToString (script_language); StreamString var_name; var_name.Printf ("[%s].script-lang", dbg_name); - debugger.GetSettingsController()->SetVariable (var_name.GetData(), lang_name.c_str(), lldb::eVarSetOperationAssign, false); + debugger.GetSettingsController()->SetVariable (var_name.GetData(), lang_name.c_str(), + lldb::eVarSetOperationAssign, false, + m_debugger.GetInstanceName().AsCString()); } void @@ -140,7 +142,8 @@ const char *dbg_name = GetDebugger().GetInstanceName().AsCString(); StreamString var_name; var_name.Printf ("[%s].script-lang", dbg_name); - value = Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type); + value = Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, + m_debugger.GetInstanceName().AsCString()); bool success; script_language = Args::StringToScriptLanguage (value.GetStringAtIndex(0), lldb::eScriptLanguageDefault, &success); @@ -777,7 +780,7 @@ const char *instance_name = GetDebugger().GetInstanceName().AsCString(); StreamString var_name; var_name.Printf ("[%s].prompt", instance_name); - return Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type).GetStringAtIndex(0); + return Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, instance_name).GetStringAtIndex(0); } void @@ -786,7 +789,8 @@ const char *instance_name = GetDebugger().GetInstanceName().AsCString(); StreamString name_str; name_str.Printf ("[%s].prompt", instance_name); - Debugger::GetSettingsController()->SetVariable (name_str.GetData(), new_prompt, lldb::eVarSetOperationAssign, false); + Debugger::GetSettingsController()->SetVariable (name_str.GetData(), new_prompt, lldb::eVarSetOperationAssign, + false, m_debugger.GetInstanceName().AsCString()); } void @@ -1037,7 +1041,8 @@ { lldb::SettableVariableType var_type; const char *width_value = - Debugger::GetSettingsController()->GetVariable ("term-width", var_type).GetStringAtIndex(0); + Debugger::GetSettingsController()->GetVariable ("term-width", var_type, + m_debugger.GetInstanceName().AsCString()).GetStringAtIndex(0); int max_columns = atoi (width_value); // Sanity check max_columns, to cope with emacs shell mode with TERM=dumb // (0 rows; 0 columns;). @@ -1128,7 +1133,7 @@ complete_command_name.Printf ("%s %s", prefix, command_name); - if (sub_cmd_obj->HelpTextContainsWord (search_word)) + if (sub_cmd_obj->HelpTextContainsWord (search_word, *this)) { commands_found.AppendString (complete_command_name.GetData()); commands_help.AppendString (sub_cmd_obj->GetHelp()); @@ -1152,7 +1157,7 @@ const char *command_name = pos->first.c_str(); CommandObject *cmd_obj = pos->second.get(); - if (cmd_obj->HelpTextContainsWord (search_word)) + if (cmd_obj->HelpTextContainsWord (search_word, *this)) { commands_found.AppendString (command_name); commands_help.AppendString (cmd_obj->GetHelp()); Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Thu Sep 9 01:25:08 2010 @@ -177,7 +177,8 @@ else { // No error string, output the usage information into result - options->GenerateOptionUsage (result.GetErrorStream(), this); + options->GenerateOptionUsage (result.GetErrorStream(), this, + interpreter.GetDebugger().GetInstanceName().AsCString()); } // Set the return status to failed (this was an error). result.SetStatus (eReturnStatusFailed); @@ -396,7 +397,7 @@ } bool -CommandObject::HelpTextContainsWord (const char *search_word) +CommandObject::HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter) { const char *short_help; const char *long_help; @@ -421,7 +422,7 @@ && GetOptions() != NULL) { StreamString usage_help; - GetOptions()->GenerateOptionUsage (usage_help, this); + GetOptions()->GenerateOptionUsage (usage_help, this, interpreter.GetDebugger().GetInstanceName().AsCString()); if (usage_help.GetSize() > 0) { const char *usage_text = usage_help.GetData(); Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=113474&r1=113473&r2=113474&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Thu Sep 9 01:25:08 2010 @@ -362,11 +362,13 @@ ( Stream &strm, CommandObject *cmd, + const char *debugger_instance_name, const char *program_name) { lldb::SettableVariableType var_type; const char *screen_width_str = - Debugger::GetSettingsController()->GetVariable ("term-width", var_type).GetStringAtIndex(0); + Debugger::GetSettingsController()->GetVariable ("term-width", var_type, + debugger_instance_name).GetStringAtIndex(0); uint32_t screen_width = atoi (screen_width_str); if (screen_width == 0) screen_width = 80; From gclayton at apple.com Thu Sep 9 01:32:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 09 Sep 2010 06:32:46 -0000 Subject: [Lldb-commits] [lldb] r113475 - in /lldb/trunk: lldb.xcodeproj/ source/Plugins/Process/gdb-remote/ tools/debugserver/debugserver.xcodeproj/ tools/debugserver/source/ tools/debugserver/source/MacOSX/ tools/debugserver/source/MacOSX/arm/ Message-ID: <20100909063246.B1C872A6C12C@llvm.org> Author: gclayton Date: Thu Sep 9 01:32:46 2010 New Revision: 113475 URL: http://llvm.org/viewvc/llvm-project?rev=113475&view=rev Log: Got the ARM version of debugserver up to date. Renamed the "dispatchqaddr" setting that was coming back for stop reply packets to be named "qaddr" so that gdb doesn't thing it is a register number. gdb was checking the first character and assuming "di" was a hex register number because 'd' is a hex digit. It has been shortened so gdb can safely ignore it. Added: lldb/trunk/tools/debugserver/source/ARM_DWARF_Registers.h - copied unchanged from r113363, lldb/trunk/source/Utility/ARM_DWARF_Registers.h lldb/trunk/tools/debugserver/source/ARM_GCC_Registers.h - copied unchanged from r113363, lldb/trunk/source/Utility/ARM_GCC_Registers.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h lldb/trunk/tools/debugserver/source/RNBRemote.cpp lldb/trunk/tools/debugserver/source/RNBRemote.h lldb/trunk/tools/debugserver/source/RNBServices.cpp lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Sep 9 01:32:46 2010 @@ -2289,6 +2289,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Sep 9 01:32:46 2010 @@ -1042,7 +1042,7 @@ { thread_name.swap (value); } - else if (name.compare("dispatchqaddr") == 0) + else if (name.compare("qaddr") == 0) { thread_dispatch_qaddr = Args::StringToUInt64 (value.c_str(), 0, 16); } 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=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Sep 9 01:32:46 2010 @@ -450,13 +450,18 @@ 1DEB914F08733D8E0010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + "ARCHS[sdk=iphoneos*]" = armv6; + "ARCHS[sdk=macosx*]" = ( + x86_64, + i386, + ); COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 112; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; + VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_BUILDER = "$(USER)"; }; @@ -465,7 +470,11 @@ 1DEB915008733D8E0010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + "ARCHS[sdk=iphoneos*]" = armv6; + "ARCHS[sdk=macosx*]" = ( + x86_64, + i386, + ); CURRENT_PROJECT_VERSION = 112; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -473,6 +482,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; STRIPFLAGS = "-x"; STRIP_STYLE = debugging; + VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_BUILDER = "$(USER)"; }; @@ -481,7 +491,11 @@ 262419A11198A93E00067686 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + "ARCHS[sdk=iphoneos*]" = armv6; + "ARCHS[sdk=macosx*]" = ( + x86_64, + i386, + ); CURRENT_PROJECT_VERSION = 112; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -489,6 +503,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; STRIPFLAGS = "-x"; STRIP_STYLE = debugging; + VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_BUILDER = "$(USER)"; }; @@ -498,13 +513,16 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = ( - x86_64, - i386, - ); + "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 112; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; + "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( + "$(SDKROOT)/System/Library/PrivateFrameworks", + "$(SDKROOT)$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks", + ); + "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders; INSTALL_PATH = /Developer/usr/bin; @@ -516,6 +534,13 @@ __info_plist, "$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist", ); + "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( + "-framework", + SpringBoardServices, + "-framework", + ARMDisassembler, + "-llockdown", + ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PREBINDING = NO; PRODUCT_NAME = debugserver; @@ -529,17 +554,19 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = ( - x86_64, - i386, - ); - CODE_SIGN_IDENTITY = lldb_codesign; + "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 112; + FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; + "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( + "$(SDKROOT)/System/Library/PrivateFrameworks", + "$(SDKROOT)$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks", + ); + "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; - HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders; INSTALL_PATH = /Developer/usr/bin; LLDB_DEBUGSERVER = 1; OTHER_CFLAGS = "-Wparentheses"; @@ -549,9 +576,17 @@ __info_plist, "$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist", ); + "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( + "-framework", + SpringBoardServices, + "-framework", + ARMDisassembler, + "-llockdown", + ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PREBINDING = NO; PRODUCT_NAME = debugserver; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -561,14 +596,17 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = ( - x86_64, - i386, - ); - CODE_SIGN_IDENTITY = lldb_codesign; + "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 112; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; + "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( + "$(SDKROOT)/System/Library/PrivateFrameworks", + "$(SDKROOT)$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks", + ); + "FRAMEWORK_SEARCH_PATHS[sdk=macosx*][arch=*]" = "$(SDKROOT)/System/Library/PrivateFrameworks"; GCC_PREPROCESSOR_DEFINITIONS = LLDB_DEBUGSERVER; HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders; INSTALL_PATH = /Developer/usr/bin; @@ -580,9 +618,17 @@ __info_plist, "$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist", ); + "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( + "-framework", + SpringBoardServices, + "-framework", + ARMDisassembler, + "-llockdown", + ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PREBINDING = NO; PRODUCT_NAME = debugserver; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Thu Sep 9 01:32:46 2010 @@ -1778,7 +1778,17 @@ char const *arg; for (i=0; (arg = argv[i]) != NULL; i++) m_args.push_back(arg); - m_task.StartExceptionThread(); + m_task.StartExceptionThread(launch_err); + + if (launch_err.Fail()) + { + if (launch_err.AsString() == NULL) + launch_err.SetErrorString("unable to start the exception thread"); + ::ptrace (PT_KILL, m_pid, 0, 0); + m_pid = INVALID_NUB_PROCESS; + return INVALID_NUB_PROCESS; + } + StartSTDIOThread(); SetState (eStateAttaching); int err = ptrace (PT_ATTACHEXC, m_pid, 0, 0); Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Thu Sep 9 01:32:46 2010 @@ -20,6 +20,8 @@ #include "DNBLog.h" #include "DNBRegisterInfo.h" #include "DNB.h" +#include "ARM_GCC_Registers.h" +#include "ARM_DWARF_Registers.h" #include @@ -113,7 +115,7 @@ { // Get program counter if (GetGPRState(false) == KERN_SUCCESS) - return m_state.gpr.__pc; + return m_state.context.gpr.__pc; return failValue; } @@ -124,7 +126,7 @@ kern_return_t err = GetGPRState(false); if (err == KERN_SUCCESS) { - m_state.gpr.__pc = value; + m_state.context.gpr.__pc = value; err = SetGPRState(); } return err == KERN_SUCCESS; @@ -135,7 +137,7 @@ { // Get stack pointer if (GetGPRState(false) == KERN_SUCCESS) - return m_state.gpr.__sp; + return m_state.context.gpr.__sp; return failValue; } @@ -149,8 +151,8 @@ // Read the registers from our thread mach_msg_type_number_t count = ARM_THREAD_STATE_COUNT; - kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.gpr, &count); - uint32_t *r = &m_state.gpr.__r[0]; + kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, &count); + uint32_t *r = &m_state.context.gpr.__r[0]; DNBLogThreadedIf(LOG_THREAD, "thread_get_state(0x%4.4x, %u, &gpr, %u) => 0x%8.8x regs r0=%8.8x r1=%8.8x r2=%8.8x r3=%8.8x r4=%8.8x r5=%8.8x r6=%8.8x r7=%8.8x r8=%8.8x r9=%8.8x r10=%8.8x r11=%8.8x s12=%8.8x sp=%8.8x lr=%8.8x pc=%8.8x cpsr=%8.8x", m_thread->ThreadID(), ARM_THREAD_STATE, ARM_THREAD_STATE_COUNT, kret, r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15], r[16]); m_state.SetError(set, Read, kret); @@ -167,7 +169,7 @@ // Read the registers from our thread mach_msg_type_number_t count = ARM_VFP_STATE_COUNT; - kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.vfp, &count); + kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, &count); m_state.SetError(set, Read, kret); return kret; } @@ -182,7 +184,7 @@ // Read the registers from our thread mach_msg_type_number_t count = ARM_EXCEPTION_STATE_COUNT; - kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.exc, &count); + kern_return_t kret = ::thread_get_state(m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, &count); m_state.SetError(set, Read, kret); return kret; } @@ -217,7 +219,7 @@ DNBArchMachARM::SetGPRState() { int set = e_regSetGPR; - kern_return_t kret = ::thread_set_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.gpr, ARM_THREAD_STATE_COUNT); + kern_return_t kret = ::thread_set_state(m_thread->ThreadID(), ARM_THREAD_STATE, (thread_state_t)&m_state.context.gpr, ARM_THREAD_STATE_COUNT); m_state.SetError(set, Write, kret); // Set the current write error for this register set m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently return kret; // Return the error code @@ -227,7 +229,7 @@ DNBArchMachARM::SetVFPState() { int set = e_regSetVFP; - kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.vfp, ARM_VFP_STATE_COUNT); + kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_VFP_STATE, (thread_state_t)&m_state.context.vfp, ARM_VFP_STATE_COUNT); m_state.SetError(set, Write, kret); // Set the current write error for this register set m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently return kret; // Return the error code @@ -237,7 +239,7 @@ DNBArchMachARM::SetEXCState() { int set = e_regSetEXC; - kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.exc, ARM_EXCEPTION_STATE_COUNT); + kern_return_t kret = ::thread_set_state (m_thread->ThreadID(), ARM_EXCEPTION_STATE, (thread_state_t)&m_state.context.exc, ARM_EXCEPTION_STATE_COUNT); m_state.SetError(set, Write, kret); // Set the current write error for this register set m_state.InvalidateRegisterSetState(set); // Invalidate the current register state in case registers are read back differently return kret; // Return the error code @@ -302,16 +304,16 @@ { uint32_t sw_step_next_pc = m_sw_single_step_next_pc & 0xFFFFFFFEu; bool sw_step_next_pc_is_thumb = (m_sw_single_step_next_pc & 1) != 0; - bool actual_next_pc_is_thumb = (m_state.gpr.__cpsr & 0x20) != 0; - if (m_state.gpr.__pc != sw_step_next_pc) + bool actual_next_pc_is_thumb = (m_state.context.gpr.__cpsr & 0x20) != 0; + if (m_state.context.gpr.__pc != sw_step_next_pc) { - DNBLogError("curr pc = 0x%8.8x - calculated single step target PC was incorrect: 0x%8.8x != 0x%8.8x", m_state.gpr.__pc, sw_step_next_pc, m_state.gpr.__pc); + DNBLogError("curr pc = 0x%8.8x - calculated single step target PC was incorrect: 0x%8.8x != 0x%8.8x", m_state.context.gpr.__pc, sw_step_next_pc, m_state.context.gpr.__pc); exit(1); } if (actual_next_pc_is_thumb != sw_step_next_pc_is_thumb) { DNBLogError("curr pc = 0x%8.8x - calculated single step calculated mode mismatch: sw single mode = %s != %s", - m_state.gpr.__pc, + m_state.context.gpr.__pc, actual_next_pc_is_thumb ? "Thumb" : "ARM", sw_step_next_pc_is_thumb ? "Thumb" : "ARM"); exit(1); @@ -336,7 +338,7 @@ if (m_sw_single_step_itblock_break_count > 0) { // See if we hit one of our Thumb IT breakpoints? - DNBBreakpoint *step_bp = m_thread->Process()->Breakpoints().FindByAddress(m_state.gpr.__pc); + DNBBreakpoint *step_bp = m_thread->Process()->Breakpoints().FindByAddress(m_state.context.gpr.__pc); if (step_bp) { @@ -362,7 +364,7 @@ // Decode instructions up to the current PC to ensure the internal decoder state is valid for the IT block // The decoder has to decode each instruction in the IT block even if it is not executed so that // the fields are correctly updated - DecodeITBlockInstructions(m_state.gpr.__pc); + DecodeITBlockInstructions(m_state.context.gpr.__pc); } } @@ -389,7 +391,7 @@ kret = GetGPRState(false); if (kret == KERN_SUCCESS) { - if (m_state.gpr.__pc == m_hw_single_chained_step_addr) + if (m_state.context.gpr.__pc == m_hw_single_chained_step_addr) { DNBLogThreadedIf(LOG_STEP, "Need to step some more at 0x%8.8x", m_hw_single_chained_step_addr); return true; @@ -450,7 +452,7 @@ arm_error_t decodeError; m_last_decode_pc = pc_in_itblock; - decodeError = DecodeInstructionUsingDisassembler(pc_in_itblock, m_state.gpr.__cpsr, &m_last_decode_arm, &m_last_decode_thumb, &next_pc_in_itblock); + decodeError = DecodeInstructionUsingDisassembler(pc_in_itblock, m_state.context.gpr.__cpsr, &m_last_decode_arm, &m_last_decode_thumb, &next_pc_in_itblock); pc_in_itblock = next_pc_in_itblock; DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s: next_pc_in_itblock=0x%8.8x", __FUNCTION__, next_pc_in_itblock); @@ -489,30 +491,30 @@ // Save our previous state m_dbg_save = m_state.dbg; // Set a breakpoint that will stop when the PC doesn't match the current one! - m_state.dbg.__bvr[i] = m_state.gpr.__pc & 0xFFFFFFFCu; // Set the current PC as the breakpoint address + m_state.dbg.__bvr[i] = m_state.context.gpr.__pc & 0xFFFFFFFCu; // Set the current PC as the breakpoint address m_state.dbg.__bcr[i] = BCR_M_IMVA_MISMATCH | // Stop on address mismatch S_USER | // Stop only in user mode BCR_ENABLE; // Enable this breakpoint - if (m_state.gpr.__cpsr & 0x20) + if (m_state.context.gpr.__cpsr & 0x20) { // Thumb breakpoint - if (m_state.gpr.__pc & 2) + if (m_state.context.gpr.__pc & 2) m_state.dbg.__bcr[i] |= BAS_IMVA_2_3; else m_state.dbg.__bcr[i] |= BAS_IMVA_0_1; uint16_t opcode; - if (sizeof(opcode) == m_thread->Process()->Task().ReadMemory(m_state.gpr.__pc, sizeof(opcode), &opcode)) + if (sizeof(opcode) == m_thread->Process()->Task().ReadMemory(m_state.context.gpr.__pc, sizeof(opcode), &opcode)) { if (((opcode & 0xE000) == 0xE000) && opcode & 0x1800) { // 32 bit thumb opcode... - if (m_state.gpr.__pc & 2) + if (m_state.context.gpr.__pc & 2) { // We can't take care of a 32 bit thumb instruction single step // with just IVA mismatching. We will need to chain an extra // hardware single step in order to complete this single step... - m_hw_single_chained_step_addr = m_state.gpr.__pc + 2; + m_hw_single_chained_step_addr = m_state.context.gpr.__pc + 2; } else { @@ -627,7 +629,7 @@ nub_addr_t myTargetPC, addressWherePCLives; pid_t mypid; - uint32_t cpsr_c = bit(m_state.gpr.__cpsr, 29); // Carry condition code flag + uint32_t cpsr_c = bit(m_state.context.gpr.__cpsr, 29); // Carry condition code flag uint32_t firstOperand=0, secondOperand=0, shiftAmount=0, secondOperandAfterShift=0, immediateValue=0; uint32_t halfwords=0, baseAddress=0, immediateOffset=0, addressOffsetFromRegister=0, addressOffsetFromRegisterAfterShift; @@ -688,7 +690,7 @@ // Get firstOperand register value (at index=1) firstOperandIndex = decodedInstruction.op[1].value; // first operand register index - firstOperand = m_state.gpr.__r[firstOperandIndex]; + firstOperand = m_state.context.gpr.__r[firstOperandIndex]; // Get immediateValue (at index=2) immediateValue = decodedInstruction.op[2].value; @@ -710,11 +712,11 @@ // Get firstOperand register value (at index=1) firstOperandIndex = decodedInstruction.op[1].value; // first operand register index - firstOperand = m_state.gpr.__r[firstOperandIndex]; + firstOperand = m_state.context.gpr.__r[firstOperandIndex]; // Get secondOperand register value (at index=2) secondOperandIndex = decodedInstruction.op[2].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; break; @@ -733,11 +735,11 @@ // Get firstOperand register value (at index=1) firstOperandIndex = decodedInstruction.op[1].value; // first operand register index - firstOperand = m_state.gpr.__r[firstOperandIndex]; + firstOperand = m_state.context.gpr.__r[firstOperandIndex]; // Get secondOperand register value (at index=2) secondOperandIndex = decodedInstruction.op[2].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; // Get shiftAmount as immediate value (at index=3) shiftAmount = decodedInstruction.op[3].value; @@ -760,15 +762,15 @@ // Get firstOperand register value (at index=1) firstOperandIndex = decodedInstruction.op[1].value; // first operand register index - firstOperand = m_state.gpr.__r[firstOperandIndex]; + firstOperand = m_state.context.gpr.__r[firstOperandIndex]; // Get secondOperand register value (at index=2) secondOperandIndex = decodedInstruction.op[2].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; // Get shiftAmount from register (at index=3) shiftRegisterIndex = decodedInstruction.op[3].value; // second operand register index - shiftAmount = m_state.gpr.__r[shiftRegisterIndex]; + shiftAmount = m_state.context.gpr.__r[shiftRegisterIndex]; break; @@ -787,11 +789,11 @@ // Get firstOperand register value (at index=0) firstOperandIndex = decodedInstruction.op[0].value; // first operand register index - firstOperand = m_state.gpr.__r[firstOperandIndex]; + firstOperand = m_state.context.gpr.__r[firstOperandIndex]; // Get secondOperand register value (at index=1) secondOperandIndex = decodedInstruction.op[1].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; break; @@ -849,7 +851,7 @@ // Get secondOperand register value (at index=1) secondOperandIndex = decodedInstruction.op[1].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; break; @@ -868,7 +870,7 @@ // Get secondOperand register value (at index=1) secondOperandIndex = decodedInstruction.op[2].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; // Get shiftAmount as immediate value (at index=2) shiftAmount = decodedInstruction.op[2].value; @@ -891,11 +893,11 @@ // Get secondOperand register value (at index=1) secondOperandIndex = decodedInstruction.op[1].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; // Get shiftAmount from register (at index=2) shiftRegisterIndex = decodedInstruction.op[2].value; // second operand register index - shiftAmount = m_state.gpr.__r[shiftRegisterIndex]; + shiftAmount = m_state.context.gpr.__r[shiftRegisterIndex]; break; @@ -914,7 +916,7 @@ // Get secondOperand register value (at index=1) secondOperandIndex = decodedInstruction.op[1].value; // second operand register index - secondOperand = m_state.gpr.__r[secondOperandIndex]; + secondOperand = m_state.context.gpr.__r[secondOperandIndex]; break; @@ -963,7 +965,7 @@ } // Get branch address in register (at index=0) - *targetPC = m_state.gpr.__r[decodedInstruction.op[0].value]; + *targetPC = m_state.context.gpr.__r[decodedInstruction.op[0].value]; return true; } break; @@ -992,7 +994,7 @@ } // Get branch address in register (at index=0) - *targetPC = m_state.gpr.__r[decodedInstruction.op[0].value]; + *targetPC = m_state.context.gpr.__r[decodedInstruction.op[0].value]; return true; break; @@ -1033,7 +1035,7 @@ // Get baseAddress from register (at index=1) baseAddressIndex = decodedInstruction.op[1].value; - baseAddress = m_state.gpr.__r[baseAddressIndex]; + baseAddress = m_state.context.gpr.__r[baseAddressIndex]; // Get immediateOffset (at index=2) immediateOffset = decodedInstruction.op[2].value; @@ -1050,11 +1052,11 @@ // Get baseAddress from register (at index=1) baseAddressIndex = decodedInstruction.op[1].value; - baseAddress = m_state.gpr.__r[baseAddressIndex]; + baseAddress = m_state.context.gpr.__r[baseAddressIndex]; // Get immediateOffset from register (at index=2) addressOffsetFromRegisterIndex = decodedInstruction.op[2].value; - addressOffsetFromRegister = m_state.gpr.__r[addressOffsetFromRegisterIndex]; + addressOffsetFromRegister = m_state.context.gpr.__r[addressOffsetFromRegisterIndex]; break; @@ -1069,11 +1071,11 @@ // Get baseAddress from register (at index=1) baseAddressIndex = decodedInstruction.op[1].value; - baseAddress = m_state.gpr.__r[baseAddressIndex]; + baseAddress = m_state.context.gpr.__r[baseAddressIndex]; // Get immediateOffset from register (at index=2) addressOffsetFromRegisterIndex = decodedInstruction.op[2].value; - addressOffsetFromRegister = m_state.gpr.__r[addressOffsetFromRegisterIndex]; + addressOffsetFromRegister = m_state.context.gpr.__r[addressOffsetFromRegisterIndex]; // Get shiftAmount (at index=3) shiftAmount = decodedInstruction.op[3].value; @@ -1101,7 +1103,7 @@ // Get baseAddress from register (at index=0) baseAddressIndex = decodedInstruction.op[0].value; - baseAddress = m_state.gpr.__r[baseAddressIndex]; + baseAddress = m_state.context.gpr.__r[baseAddressIndex]; // Get registerList from register (at index=1) registerList16 = (uint16_t)decodedInstruction.op[1].value; @@ -1125,7 +1127,7 @@ // Normal 16-bit LD multiple can't touch R15, but POP can case ARM_INST_POP: // Can also get the PC & updates SP // Get baseAddress from SP (at index=0) - baseAddress = m_state.gpr.__sp; + baseAddress = m_state.context.gpr.__sp; if (decodedInstruction.thumb16b) { @@ -1161,11 +1163,11 @@ case ARM_INST_TBH: // Get baseAddress from register (at index=0) baseAddressIndex = decodedInstruction.op[0].value; - baseAddress = m_state.gpr.__r[baseAddressIndex]; + baseAddress = m_state.context.gpr.__r[baseAddressIndex]; // Get immediateOffset from register (at index=1) addressOffsetFromRegisterIndex = decodedInstruction.op[1].value; - addressOffsetFromRegister = m_state.gpr.__r[addressOffsetFromRegisterIndex]; + addressOffsetFromRegister = m_state.context.gpr.__r[addressOffsetFromRegisterIndex]; break; // ThumbEE branch-to-handler instructions: Jump to handlers at some offset @@ -1625,7 +1627,7 @@ { // Compare and branch on zero/non-zero (Thumb-16 only) // Unusual condition check built into the instruction - registerValue = m_state.gpr.__r[m_last_decode_arm.op[REG_RD].value]; + registerValue = m_state.context.gpr.__r[m_last_decode_arm.op[REG_RD].value]; if (m_last_decode_arm.instruction->code == ARM_INST_CBZ) { @@ -1767,11 +1769,15 @@ } nub_bool_t -DNBArchMachARM::BreakpointHit(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton) +DNBArchMachARM::BreakpointHit (nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton) { nub_addr_t bkpt_pc = (nub_addr_t)baton; DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s(pid = %i, tid = %4.4x, breakID = %u, baton = %p): Setting PC to 0x%8.8x", __FUNCTION__, pid, tid, breakID, baton, bkpt_pc); - return DNBThreadSetRegisterValueByID(pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_PC, bkpt_pc); + + DNBRegisterValue pc_value; + DNBThreadGetRegisterValueByID (pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_PC, &pc_value); + pc_value.value.uint32 = bkpt_pc; + return DNBThreadSetRegisterValueByID (pid, tid, REGISTER_SET_GENERIC, GENERIC_REGNUM_PC, &pc_value); } // Set the single step bit in the processor status register. @@ -1787,11 +1793,11 @@ return err.Error(); } - nub_addr_t curr_pc = m_state.gpr.__pc; - uint32_t curr_cpsr = m_state.gpr.__cpsr; + nub_addr_t curr_pc = m_state.context.gpr.__pc; + uint32_t curr_cpsr = m_state.context.gpr.__cpsr; nub_addr_t next_pc = curr_pc; - bool curr_pc_is_thumb = (m_state.gpr.__cpsr & 0x20) != 0; + bool curr_pc_is_thumb = (m_state.context.gpr.__cpsr & 0x20) != 0; bool next_pc_is_thumb = curr_pc_is_thumb; uint32_t curr_itstate = ((curr_cpsr & 0x6000000) >> 25) | ((curr_cpsr & 0xFC00) >> 8); @@ -1822,17 +1828,17 @@ if (!inITBlock) { DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s: normal instruction", __FUNCTION__); - EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); + EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.context.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); } else if (inITBlock && !m_last_decode_arm.setsFlags) { DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s: IT instruction that doesn't set flags", __FUNCTION__); - EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); + EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.context.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); } else if (lastInITBlock && m_last_decode_arm.branch) { DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s: IT instruction which last in the IT block and is a branch", __FUNCTION__); - EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); + EvaluateNextInstructionForSoftwareBreakpointSetup(curr_pc, m_state.context.gpr.__cpsr, curr_pc_is_thumb, &next_pc, &next_pc_is_thumb); } else { @@ -2279,119 +2285,294 @@ //---------------------------------------------------------------------- enum gpr_regnums { - e_regNumGPR_r0 = 0, - e_regNumGPR_r1, - e_regNumGPR_r2, - e_regNumGPR_r3, - e_regNumGPR_r4, - e_regNumGPR_r5, - e_regNumGPR_r6, - e_regNumGPR_r7, - e_regNumGPR_r8, - e_regNumGPR_r9, - e_regNumGPR_r10, - e_regNumGPR_r11, - e_regNumGPR_r12, - e_regNumGPR_sp, - e_regNumGPR_lr, - e_regNumGPR_pc, - e_regNumGPR_cpsr + gpr_r0 = 0, + gpr_r1, + gpr_r2, + gpr_r3, + gpr_r4, + gpr_r5, + gpr_r6, + gpr_r7, + gpr_r8, + gpr_r9, + gpr_r10, + gpr_r11, + gpr_r12, + gpr_sp, + gpr_lr, + gpr_pc, + gpr_cpsr }; +enum +{ + vfp_s0 = 0, + vfp_s1, + vfp_s2, + vfp_s3, + vfp_s4, + vfp_s5, + vfp_s6, + vfp_s7, + vfp_s8, + vfp_s9, + vfp_s10, + vfp_s11, + vfp_s12, + vfp_s13, + vfp_s14, + vfp_s15, + vfp_s16, + vfp_s17, + vfp_s18, + vfp_s19, + vfp_s20, + vfp_s21, + vfp_s22, + vfp_s23, + vfp_s24, + vfp_s25, + vfp_s26, + vfp_s27, + vfp_s28, + vfp_s29, + vfp_s30, + vfp_s31, + vfp_d16, + vfp_d17, + vfp_d18, + vfp_d19, + vfp_d20, + vfp_d21, + vfp_d22, + vfp_d23, + vfp_d24, + vfp_d25, + vfp_d26, + vfp_d27, + vfp_d28, + vfp_d29, + vfp_d30, + vfp_d31, + vfp_fpscr +}; + +enum +{ + exc_exception, + exc_fsr, + exc_far, +}; + +enum +{ + gdb_r0 = 0, + gdb_r1, + gdb_r2, + gdb_r3, + gdb_r4, + gdb_r5, + gdb_r6, + gdb_r7, + gdb_r8, + gdb_r9, + gdb_r10, + gdb_r11, + gdb_r12, + gdb_sp, + gdb_lr, + gdb_pc, + gdb_f0, + gdb_f1, + gdb_f2, + gdb_f3, + gdb_f4, + gdb_f5, + gdb_f6, + gdb_f7, + gdb_f8, + gdb_cpsr, + gdb_s0, + gdb_s1, + gdb_s2, + gdb_s3, + gdb_s4, + gdb_s5, + gdb_s6, + gdb_s7, + gdb_s8, + gdb_s9, + gdb_s10, + gdb_s11, + gdb_s12, + gdb_s13, + gdb_s14, + gdb_s15, + gdb_s16, + gdb_s17, + gdb_s18, + gdb_s19, + gdb_s20, + gdb_s21, + gdb_s22, + gdb_s23, + gdb_s24, + gdb_s25, + gdb_s26, + gdb_s27, + gdb_s28, + gdb_s29, + gdb_s30, + gdb_s31, + gdb_fpscr, + gdb_d0, + gdb_d1, + gdb_d2, + gdb_d3, + gdb_d4, + gdb_d5, + gdb_d6, + gdb_d7, + gdb_d8, + gdb_d9, + gdb_d10, + gdb_d11, + gdb_d12, + gdb_d13, + gdb_d14, + gdb_d15 +}; + +#define GPR_OFFSET_IDX(idx) (offsetof (DNBArchMachARM::GPR, __r[idx])) +#define GPR_OFFSET_NAME(reg) (offsetof (DNBArchMachARM::GPR, __##reg)) +#define VFP_S_OFFSET_IDX(idx) (offsetof (DNBArchMachARM::FPU, __r[idx]) + offsetof (DNBArchMachARM::Context, vfp)) +#define VFP_D_OFFSET_IDX(idx) (VFP_S_OFFSET_IDX (32) + (((idx) - 16) * 8)) +#define VFP_OFFSET_NAME(reg) (offsetof (DNBArchMachARM::FPU, __##reg) + offsetof (DNBArchMachARM::Context, vfp)) +#define EXC_OFFSET(reg) (offsetof (DNBArchMachARM::EXC, __##reg) + offsetof (DNBArchMachARM::Context, exc)) + +// These macros will auto define the register name, alt name, register size, +// register offset, encoding, format and native register. This ensures that +// the register state structures are defined correctly and have the correct +// sizes and offsets. +#define DEFINE_GPR_IDX(idx, reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, 4, GPR_OFFSET_IDX(idx), gcc_##reg, dwarf_##reg, gen, gdb_##reg } +#define DEFINE_GPR_NAME(reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, 4, GPR_OFFSET_NAME(reg), gcc_##reg, dwarf_##reg, gen, gdb_##reg } + +#define DEFINE_VFP_S_IDX(idx) { e_regSetVFP, vfp_s##idx, "s" #idx, NULL, IEEE754, 4, Float, VFP_S_OFFSET_IDX(idx), INVALID_NUB_REGNUM, dwarf_s##idx, INVALID_NUB_REGNUM, gdb_s##idx } +#define DEFINE_VFP_D_IDX(idx) { e_regSetVFP, vfp_d##idx, "d" #idx, NULL, IEEE754, 8, Float, VFP_D_OFFSET_IDX(idx), INVALID_NUB_REGNUM, dwarf_s##idx, INVALID_NUB_REGNUM, gdb_s##idx } + // General purpose registers -static DNBRegisterInfo g_gpr_registers[] = +const DNBRegisterInfo +DNBArchMachARM::g_gpr_registers[] = { - { "r0" , Uint, 4, Hex }, - { "r1" , Uint, 4, Hex }, - { "r2" , Uint, 4, Hex }, - { "r3" , Uint, 4, Hex }, - { "r4" , Uint, 4, Hex }, - { "r5" , Uint, 4, Hex }, - { "r6" , Uint, 4, Hex }, - { "r7" , Uint, 4, Hex }, - { "r8" , Uint, 4, Hex }, - { "r9" , Uint, 4, Hex }, - { "r10" , Uint, 4, Hex }, - { "r11" , Uint, 4, Hex }, - { "r12" , Uint, 4, Hex }, - { "sp" , Uint, 4, Hex }, - { "lr" , Uint, 4, Hex }, - { "pc" , Uint, 4, Hex }, - { "cpsr" , Uint, 4, Hex }, + DEFINE_GPR_IDX ( 0, r0, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 1, r1, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 2, r2, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 3, r3, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 4, r4, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 5, r5, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 6, r6, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 7, r7, NULL, GENERIC_REGNUM_FP ), + DEFINE_GPR_IDX ( 8, r8, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX ( 9, r9, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX (10, r10, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX (11, r11, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_IDX (12, r12, NULL, INVALID_NUB_REGNUM ), + DEFINE_GPR_NAME (sp, "r13", GENERIC_REGNUM_SP ), + DEFINE_GPR_NAME (lr, "r14", GENERIC_REGNUM_RA ), + DEFINE_GPR_NAME (pc, "r15", GENERIC_REGNUM_PC ), + DEFINE_GPR_NAME (cpsr, NULL, GENERIC_REGNUM_FLAGS ) }; // Floating point registers -static DNBRegisterInfo g_vfp_registers[] = +const DNBRegisterInfo +DNBArchMachARM::g_vfp_registers[] = { - { "s0" , IEEE754, 4, Float }, - { "s1" , IEEE754, 4, Float }, - { "s2" , IEEE754, 4, Float }, - { "s3" , IEEE754, 4, Float }, - { "s4" , IEEE754, 4, Float }, - { "s5" , IEEE754, 4, Float }, - { "s6" , IEEE754, 4, Float }, - { "s7" , IEEE754, 4, Float }, - { "s8" , IEEE754, 4, Float }, - { "s9" , IEEE754, 4, Float }, - { "s10" , IEEE754, 4, Float }, - { "s11" , IEEE754, 4, Float }, - { "s12" , IEEE754, 4, Float }, - { "s13" , IEEE754, 4, Float }, - { "s14" , IEEE754, 4, Float }, - { "s15" , IEEE754, 4, Float }, - { "s16" , IEEE754, 4, Float }, - { "s17" , IEEE754, 4, Float }, - { "s18" , IEEE754, 4, Float }, - { "s19" , IEEE754, 4, Float }, - { "s20" , IEEE754, 4, Float }, - { "s21" , IEEE754, 4, Float }, - { "s22" , IEEE754, 4, Float }, - { "s23" , IEEE754, 4, Float }, - { "s24" , IEEE754, 4, Float }, - { "s25" , IEEE754, 4, Float }, - { "s26" , IEEE754, 4, Float }, - { "s27" , IEEE754, 4, Float }, - { "s28" , IEEE754, 4, Float }, - { "s29" , IEEE754, 4, Float }, - { "s30" , IEEE754, 4, Float }, - { "s31" , IEEE754, 4, Float }, - { "fpscr" , Uint, 4, Hex } + DEFINE_VFP_S_IDX ( 0), + DEFINE_VFP_S_IDX ( 1), + DEFINE_VFP_S_IDX ( 2), + DEFINE_VFP_S_IDX ( 3), + DEFINE_VFP_S_IDX ( 4), + DEFINE_VFP_S_IDX ( 5), + DEFINE_VFP_S_IDX ( 6), + DEFINE_VFP_S_IDX ( 7), + DEFINE_VFP_S_IDX ( 8), + DEFINE_VFP_S_IDX ( 9), + DEFINE_VFP_S_IDX (10), + DEFINE_VFP_S_IDX (11), + DEFINE_VFP_S_IDX (12), + DEFINE_VFP_S_IDX (13), + DEFINE_VFP_S_IDX (14), + DEFINE_VFP_S_IDX (15), + DEFINE_VFP_S_IDX (16), + DEFINE_VFP_S_IDX (17), + DEFINE_VFP_S_IDX (18), + DEFINE_VFP_S_IDX (19), + DEFINE_VFP_S_IDX (20), + DEFINE_VFP_S_IDX (21), + DEFINE_VFP_S_IDX (22), + DEFINE_VFP_S_IDX (23), + DEFINE_VFP_S_IDX (24), + DEFINE_VFP_S_IDX (25), + DEFINE_VFP_S_IDX (26), + DEFINE_VFP_S_IDX (27), + DEFINE_VFP_S_IDX (28), + DEFINE_VFP_S_IDX (29), + DEFINE_VFP_S_IDX (30), + DEFINE_VFP_S_IDX (31), + DEFINE_VFP_D_IDX (16), + DEFINE_VFP_D_IDX (17), + DEFINE_VFP_D_IDX (18), + DEFINE_VFP_D_IDX (19), + DEFINE_VFP_D_IDX (20), + DEFINE_VFP_D_IDX (21), + DEFINE_VFP_D_IDX (22), + DEFINE_VFP_D_IDX (23), + DEFINE_VFP_D_IDX (24), + DEFINE_VFP_D_IDX (25), + DEFINE_VFP_D_IDX (26), + DEFINE_VFP_D_IDX (27), + DEFINE_VFP_D_IDX (28), + DEFINE_VFP_D_IDX (29), + DEFINE_VFP_D_IDX (30), + DEFINE_VFP_D_IDX (31), + { e_regSetVFP, vfp_fpscr, "fpscr", NULL, Uint, 4, Hex, VFP_OFFSET_NAME(fpscr), INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, gdb_fpscr } }; // Exception registers -static DNBRegisterInfo g_exc_registers[] = +const DNBRegisterInfo +DNBArchMachARM::g_exc_registers[] = { - { "dar" , Uint, 4, Hex }, - { "dsisr" , Uint, 4, Hex }, - { "exception" , Uint, 4, Hex } + { e_regSetVFP, exc_exception , "exception" , NULL, Uint, 4, Hex, EXC_OFFSET(exception) , INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM }, + { e_regSetVFP, exc_fsr , "fsr" , NULL, Uint, 4, Hex, EXC_OFFSET(fsr) , INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM }, + { e_regSetVFP, exc_far , "far" , NULL, Uint, 4, Hex, EXC_OFFSET(far) , INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM } }; // Number of registers in each register set -const size_t k_num_gpr_registers = sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo); -const size_t k_num_vfp_registers = sizeof(g_vfp_registers)/sizeof(DNBRegisterInfo); -const size_t k_num_exc_registers = sizeof(g_exc_registers)/sizeof(DNBRegisterInfo); -// Total number of registers for this architecture -const size_t k_num_armv6_registers = k_num_gpr_registers + k_num_vfp_registers + k_num_exc_registers; +const size_t DNBArchMachARM::k_num_gpr_registers = sizeof(g_gpr_registers)/sizeof(DNBRegisterInfo); +const size_t DNBArchMachARM::k_num_vfp_registers = sizeof(g_vfp_registers)/sizeof(DNBRegisterInfo); +const size_t DNBArchMachARM::k_num_exc_registers = sizeof(g_exc_registers)/sizeof(DNBRegisterInfo); +const size_t DNBArchMachARM::k_num_all_registers = k_num_gpr_registers + k_num_vfp_registers + k_num_exc_registers; //---------------------------------------------------------------------- // Register set definitions. The first definitions at register set index // of zero is for all registers, followed by other registers sets. The // register information for the all register set need not be filled in. //---------------------------------------------------------------------- -static const DNBRegisterSetInfo g_reg_sets[] = +const DNBRegisterSetInfo +DNBArchMachARM::g_reg_sets[] = { - { "ARMV6 Registers", NULL, k_num_armv6_registers }, + { "ARM Registers", NULL, k_num_all_registers }, { "General Purpose Registers", g_gpr_registers, k_num_gpr_registers }, { "Floating Point Registers", g_vfp_registers, k_num_vfp_registers }, { "Exception State Registers", g_exc_registers, k_num_exc_registers } }; // Total number of register sets for this architecture -const size_t k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo); +const size_t DNBArchMachARM::k_num_register_sets = sizeof(g_reg_sets)/sizeof(DNBRegisterSetInfo); const DNBRegisterSetInfo * -DNBArchMachARM::GetRegisterSetInfo(nub_size_t *num_reg_sets) const +DNBArchMachARM::GetRegisterSetInfo(nub_size_t *num_reg_sets) { *num_reg_sets = k_num_register_sets; return g_reg_sets; @@ -2406,27 +2587,27 @@ { case GENERIC_REGNUM_PC: // Program Counter set = e_regSetGPR; - reg = e_regNumGPR_pc; + reg = gpr_pc; break; case GENERIC_REGNUM_SP: // Stack Pointer set = e_regSetGPR; - reg = e_regNumGPR_sp; + reg = gpr_sp; break; case GENERIC_REGNUM_FP: // Frame Pointer set = e_regSetGPR; - reg = e_regNumGPR_r7; // is this the right reg? + reg = gpr_r7; // is this the right reg? break; case GENERIC_REGNUM_RA: // Return Address set = e_regSetGPR; - reg = e_regNumGPR_lr; + reg = gpr_lr; break; case GENERIC_REGNUM_FLAGS: // Processor flags register set = e_regSetGPR; - reg = e_regNumGPR_cpsr; + reg = gpr_cpsr; break; default: @@ -2446,7 +2627,7 @@ case e_regSetGPR: if (reg < k_num_gpr_registers) { - value->value.uint32 = m_state.gpr.__r[reg]; + value->value.uint32 = m_state.context.gpr.__r[reg]; return true; } break; @@ -2454,12 +2635,12 @@ case e_regSetVFP: if (reg < 32) { - value->value.uint32 = m_state.vfp.__r[reg]; + value->value.uint32 = m_state.context.vfp.__r[reg]; return true; } else if (reg == 32) { - value->value.uint32 = m_state.vfp.__fpscr; + value->value.uint32 = m_state.context.vfp.__fpscr; return true; } break; @@ -2467,7 +2648,7 @@ case e_regSetEXC: if (reg < k_num_exc_registers) { - value->value.uint32 = (&m_state.exc.__exception)[reg]; + value->value.uint32 = (&m_state.context.exc.__exception)[reg]; return true; } break; @@ -2485,27 +2666,27 @@ { case GENERIC_REGNUM_PC: // Program Counter set = e_regSetGPR; - reg = e_regNumGPR_pc; + reg = gpr_pc; break; case GENERIC_REGNUM_SP: // Stack Pointer set = e_regSetGPR; - reg = e_regNumGPR_sp; + reg = gpr_sp; break; case GENERIC_REGNUM_FP: // Frame Pointer set = e_regSetGPR; - reg = e_regNumGPR_r7; + reg = gpr_r7; break; case GENERIC_REGNUM_RA: // Return Address set = e_regSetGPR; - reg = e_regNumGPR_lr; + reg = gpr_lr; break; case GENERIC_REGNUM_FLAGS: // Processor flags register set = e_regSetGPR; - reg = e_regNumGPR_cpsr; + reg = gpr_cpsr; break; default: @@ -2525,7 +2706,7 @@ case e_regSetGPR: if (reg < k_num_gpr_registers) { - m_state.gpr.__r[reg] = value->value.uint32; + m_state.context.gpr.__r[reg] = value->value.uint32; success = true; } break; @@ -2533,12 +2714,12 @@ case e_regSetVFP: if (reg < 32) { - m_state.vfp.__r[reg] = value->value.float64; + m_state.context.vfp.__r[reg] = value->value.float64; success = true; } else if (reg == 32) { - m_state.vfp.__fpscr = value->value.uint32; + m_state.context.vfp.__fpscr = value->value.uint32; success = true; } break; @@ -2546,7 +2727,7 @@ case e_regSetEXC: if (reg < k_num_exc_registers) { - (&m_state.exc.__exception)[reg] = value->value.uint32; + (&m_state.context.exc.__exception)[reg] = value->value.uint32; success = true; } break; @@ -2606,5 +2787,47 @@ } +nub_size_t +DNBArchMachARM::GetRegisterContext (void *buf, nub_size_t buf_len) +{ + nub_size_t size = sizeof (m_state.context); + + if (buf && buf_len) + { + if (size > buf_len) + size = buf_len; + + bool force = false; + if (GetGPRState(force) | GetVFPState(force) | GetEXCState(force)) + return 0; + ::memcpy (buf, &m_state.context, size); + } + DNBLogThreadedIf (LOG_THREAD, "DNBArchMachARM::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); + // Return the size of the register context even if NULL was passed in + return size; +} + +nub_size_t +DNBArchMachARM::SetRegisterContext (const void *buf, nub_size_t buf_len) +{ + nub_size_t size = sizeof (m_state.context); + if (buf == NULL || buf_len == 0) + size = 0; + + if (size) + { + if (size > buf_len) + size = buf_len; + + ::memcpy (&m_state.context, buf, size); + SetGPRState(); + SetVFPState(); + SetEXCState(); + } + DNBLogThreadedIf (LOG_THREAD, "DNBArchMachARM::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); + return size; +} + + #endif // #if defined (__arm__) Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h Thu Sep 9 01:32:46 2010 @@ -45,10 +45,13 @@ { } - virtual const DNBRegisterSetInfo * - GetRegisterSetInfo(nub_size_t *num_reg_sets) const; + static const DNBRegisterSetInfo * + GetRegisterSetInfo(nub_size_t *num_reg_sets); + virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); + virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); + virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual kern_return_t GetRegisterState (int set, bool force); virtual kern_return_t SetRegisterState (int set); @@ -100,12 +103,32 @@ Write = 1, kNumErrors = 2 }; + + typedef arm_thread_state_t GPR; + typedef arm_vfp_state_t FPU; + typedef arm_exception_state_t EXC; + + static const DNBRegisterInfo g_gpr_registers[]; + static const DNBRegisterInfo g_vfp_registers[]; + static const DNBRegisterInfo g_exc_registers[]; + static const DNBRegisterSetInfo g_reg_sets[]; + + static const size_t k_num_gpr_registers; + static const size_t k_num_vfp_registers; + static const size_t k_num_exc_registers; + static const size_t k_num_all_registers; + static const size_t k_num_register_sets; + + struct Context + { + GPR gpr; + FPU vfp; + EXC exc; + }; struct State { - arm_thread_state_t gpr; - arm_vfp_state_t vfp; - arm_exception_state_t exc; + Context context; arm_debug_state_t dbg; kern_return_t gpr_errs[2]; // Read/Write errors kern_return_t vfp_errs[2]; // Read/Write errors Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Thu Sep 9 01:32:46 2010 @@ -171,6 +171,7 @@ t.push_back (Packet (set_max_packet_size, &RNBRemote::HandlePacket_Q , NULL, "QSetMaxPacketSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized packet gdb can handle")); t.push_back (Packet (set_max_payload_size, &RNBRemote::HandlePacket_Q , NULL, "QSetMaxPayloadSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized payload gdb can handle")); t.push_back (Packet (set_environment_variable, &RNBRemote::HandlePacket_Q , NULL, "QEnvironment:", "Add an environment variable to the inferior's environment")); + t.push_back (Packet (set_disable_aslr, &RNBRemote::HandlePacket_Q , NULL, "QSetDisableASLR:", "Set wether to disable ASLR when launching the process with the set argv ('A') packet")); // t.push_back (Packet (pass_signals_to_inferior, &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "QPassSignals:", "Specify which signals are passed to the inferior")); t.push_back (Packet (allocate_memory, &RNBRemote::HandlePacket_AllocateMemory, NULL, "_M", "Allocate memory in the inferior process.")); t.push_back (Packet (deallocate_memory, &RNBRemote::HandlePacket_DeallocateMemory, NULL, "_m", "Deallocate memory in the inferior process.")); @@ -826,14 +827,14 @@ { 13, 4, "sp", {0}, NULL, 1}, { 14, 4, "lr", {0}, NULL, 1}, { 15, 4, "pc", {0}, NULL, 1}, - { 16, 12, "f0", NULL, k_zero_bytes, 0}, - { 17, 12, "f1", NULL, k_zero_bytes, 0}, - { 18, 12, "f2", NULL, k_zero_bytes, 0}, - { 19, 12, "f3", NULL, k_zero_bytes, 0}, - { 20, 12, "f4", NULL, k_zero_bytes, 0}, - { 21, 12, "f5", NULL, k_zero_bytes, 0}, - { 22, 12, "f6", NULL, k_zero_bytes, 0}, - { 23, 12, "f7", NULL, k_zero_bytes, 0}, + { 16, 12, "f0", {0}, k_zero_bytes, 0}, + { 17, 12, "f1", {0}, k_zero_bytes, 0}, + { 18, 12, "f2", {0}, k_zero_bytes, 0}, + { 19, 12, "f3", {0}, k_zero_bytes, 0}, + { 20, 12, "f4", {0}, k_zero_bytes, 0}, + { 21, 12, "f5", {0}, k_zero_bytes, 0}, + { 22, 12, "f6", {0}, k_zero_bytes, 0}, + { 23, 12, "f7", {0}, k_zero_bytes, 0}, { 24, 4, "fps", {0}, NULL, 0}, { 25, 4,"cpsr", {0}, NULL, 1}, { 26, 4, "s0", {0}, NULL, 0}, @@ -1751,6 +1752,20 @@ return SendPacket ("E35"); } + if (strncmp (p, "QSetDisableASLR:", sizeof ("QSetDisableASLR:") - 1) == 0) + { + extern int g_disable_aslr; + p += sizeof ("QSetDisableASLR:") - 1; + switch (*p) + { + case '0': g_disable_aslr = 0; break; + case '1': g_disable_aslr = 1; break; + default: + return SendPacket ("E56"); + } + return SendPacket ("OK"); + } + /* The number of characters in a packet payload that gdb is prepared to accept. The packet-start char, packet-end char, 2 checksum chars and terminating null character are not included @@ -1933,7 +1948,7 @@ if (DNBThreadGetIdentifierInfo (pid, tid, &thread_ident_info)) { if (thread_ident_info.dispatch_qaddr != 0) - ostrm << std::hex << "dispatchqaddr:" << thread_ident_info.dispatch_qaddr << ';'; + ostrm << std::hex << "qaddr:" << thread_ident_info.dispatch_qaddr << ';'; } DNBRegisterValue reg_value; for (uint32_t reg = 0; reg < g_num_reg_entries; reg++) Modified: lldb/trunk/tools/debugserver/source/RNBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.h?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.h (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.h Thu Sep 9 01:32:46 2010 @@ -96,6 +96,7 @@ set_max_packet_size, // 'QSetMaxPacketSize:' set_max_payload_size, // 'QSetMaxPayloadSize:' set_environment_variable, // 'QEnvironment:' + set_disable_aslr, // 'QSetDisableASLR:' allocate_memory, // '_M' deallocate_memory, // '_m' Modified: lldb/trunk/tools/debugserver/source/RNBServices.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBServices.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBServices.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBServices.cpp Thu Sep 9 01:32:46 2010 @@ -16,6 +16,7 @@ #import #import #import "DNBLog.h" +#include "MacOSX/CFUtils.h" #if defined (__arm__) #import Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=113475&r1=113474&r2=113475&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Thu Sep 9 01:32:46 2010 @@ -53,7 +53,7 @@ static int g_lockdown_opt = 0; static int g_applist_opt = 0; static nub_launch_flavor_t g_launch_flavor = eLaunchFlavorDefault; -static int g_disable_aslr = 0; +int g_disable_aslr = 0; int g_isatty = 0; From ctice at apple.com Thu Sep 9 11:44:14 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 09 Sep 2010 16:44:14 -0000 Subject: [Lldb-commits] [lldb] r113496 - /lldb/trunk/source/Interpreter/Options.cpp Message-ID: <20100909164414.DAA522A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 11:44:14 2010 New Revision: 113496 URL: http://llvm.org/viewvc/llvm-project?rev=113496&view=rev Log: Modify the command options help generation so that required options are always printed immediately after the command, before optional options; also so that in the detailed descriptions of each command option, the options and their help are output in alphabetical order (sorted by the short option) rather in whatever order they happened to be in the table. Modified: lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=113496&r1=113495&r2=113496&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Thu Sep 9 11:44:14 2010 @@ -12,6 +12,7 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes @@ -406,6 +407,8 @@ if (opt_set > 0) strm.Printf ("\n"); strm.Indent (name); + + // First go through and print the required options (list them up front). for (i = 0; i < num_options; ++i) { @@ -430,7 +433,18 @@ else strm.Printf (" -%c", full_options_table[i].short_option); } - else + } + } + + // Now go through again, and this time only print the optional options. + + for (i = 0; i < num_options; ++i) + { + if (full_options_table[i].usage_mask & opt_set_mask) + { + // Add current option to the end of out_stream. + + if (! full_options_table[i].required) { if (full_options_table[i].option_has_arg == required_argument) strm.Printf (" [-%c %s]", full_options_table[i].short_option, @@ -458,51 +472,78 @@ OptionSet::iterator pos; strm.IndentMore (5); - int first_option_printed = 1; + std::vector sorted_options; + + + // Put the unique command options in a vector & sort it, so we can output them alphabetically (by short_option) + // when writing out detailed help for each option. + for (i = 0; i < num_options; ++i) { - // Only print out this option if we haven't already seen it. pos = options_seen.find (full_options_table[i].short_option); if (pos == options_seen.end()) { - // Put a newline separation between arguments - if (first_option_printed) - first_option_printed = 0; - else - strm.EOL(); - options_seen.insert (full_options_table[i].short_option); - strm.Indent (); - strm.Printf ("-%c ", full_options_table[i].short_option); - if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); - strm.Indent (); - strm.Printf ("--%s ", full_options_table[i].long_option); - if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); - - strm.IndentMore (5); - - if (full_options_table[i].usage_text) + sorted_options.push_back (full_options_table[i].short_option); + } + } + + std::sort (sorted_options.begin(), sorted_options.end()); + + // Go through the unique'd and alphabetically sorted vector of options, find the table entry for each option + // and write out the detailed help information for that option. + + int first_option_printed = 1; + size_t end = sorted_options.size(); + for (size_t j = 0; j < end; ++j) + { + char option = sorted_options[j]; + bool found = false; + for (i = 0; i < num_options && !found; ++i) + { + if (full_options_table[i].short_option == option) + { + found = true; + //Print out the help information for this option. + + // Put a newline separation between arguments + if (first_option_printed) + first_option_printed = 0; + else + strm.EOL(); + + strm.Indent (); + strm.Printf ("-%c ", full_options_table[i].short_option); + if (full_options_table[i].argument_name != NULL) + strm.PutCString(full_options_table[i].argument_name); + strm.EOL(); + strm.Indent (); + strm.Printf ("--%s ", full_options_table[i].long_option); + if (full_options_table[i].argument_name != NULL) + strm.PutCString(full_options_table[i].argument_name); + strm.EOL(); + + strm.IndentMore (5); + + if (full_options_table[i].usage_text) OutputFormattedUsageText (strm, full_options_table[i].usage_text, screen_width); - if (full_options_table[i].enum_values != NULL) - { - strm.Indent (); - strm.Printf("Values: "); - for (int j = 0; full_options_table[i].enum_values[j].string_value != NULL; j++) + if (full_options_table[i].enum_values != NULL) { - if (j == 0) - strm.Printf("%s", full_options_table[i].enum_values[j].string_value); - else - strm.Printf(" | %s", full_options_table[i].enum_values[j].string_value); + strm.Indent (); + strm.Printf("Values: "); + for (int k = 0; full_options_table[i].enum_values[k].string_value != NULL; k++) + { + if (k == 0) + strm.Printf("%s", full_options_table[i].enum_values[k].string_value); + else + strm.Printf(" | %s", full_options_table[i].enum_values[k].string_value); + } + strm.EOL(); } - strm.EOL(); + strm.IndentLess (5); } - strm.IndentLess (5); } } From ctice at apple.com Thu Sep 9 12:45:09 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 09 Sep 2010 17:45:09 -0000 Subject: [Lldb-commits] [lldb] r113506 - in /lldb/trunk: include/lldb/API/SBDebugger.h source/API/SBDebugger.cpp tools/driver/Driver.cpp Message-ID: <20100909174509.87FDA2A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 12:45:09 2010 New Revision: 113506 URL: http://llvm.org/viewvc/llvm-project?rev=113506&view=rev Log: Make API calls for setting/getting user settable variables static. Modify Driver to handle SIGWINCH signals and automatically re-set the term-width variable. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=113506&r1=113505&r2=113506&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Thu Sep 9 12:45:09 2010 @@ -142,14 +142,17 @@ void PushInputReader (lldb::SBInputReader &reader); + const char * + GetInstanceName (); + static SBDebugger FindDebuggerWithID (int id); - lldb::SBError - SetInternalVariable (const char *var_name, const char *value); + static lldb::SBError + SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); - lldb::SBStringList - GetInternalVariableValue (const char *var_name); + static lldb::SBStringList + GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); private: Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=113506&r1=113505&r2=113506&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep 9 12:45:09 2010 @@ -565,17 +565,19 @@ return sb_debugger; } -SBError -SBDebugger::SetInternalVariable (const char *var_name, const char *value) +const char * +SBDebugger::GetInstanceName() { - lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); - - const char *debugger_instance_name; - if (m_opaque_sp) - debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString(); + return m_opaque_sp->GetInstanceName().AsCString(); else - debugger_instance_name = ""; + return NULL; +} + +SBError +SBDebugger::SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name) +{ + lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false, debugger_instance_name); @@ -586,19 +588,13 @@ } lldb::SBStringList -SBDebugger::GetInternalVariableValue (const char *var_name) +SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger_instance_name) { SBStringList ret_value; lldb::SettableVariableType var_type; - const char *debugger_instance_name; lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); - if (m_opaque_sp) - debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString(); - else - debugger_instance_name = ""; - StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name); for (unsigned i = 0; i != value.GetSize(); ++i) ret_value.AppendString (value.GetStringAtIndex(i)); Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113506&r1=113505&r2=113506&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 9 12:45:09 2010 @@ -39,6 +39,8 @@ static void reset_stdin_termios (); static struct termios g_old_stdin_termios; +static char *g_debugger_name = (char *) ""; + // In the Driver::MainLoop, we change the terminal settings. This function is // added as an atexit handler to make sure we clean them up. static void @@ -90,6 +92,9 @@ m_option_data (), m_waiting_for_command (false) { + g_debugger_name = (char *) m_debugger.GetInstanceName(); + if (g_debugger_name == NULL) + g_debugger_name = (char *) ""; } Driver::~Driver () @@ -1263,6 +1268,22 @@ } +void +sigwinch_handler (int signo) +{ + struct winsize window_size; + if (isatty (STDIN_FILENO) + && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) + { + if ((window_size.ws_col > 0) && (strlen (g_debugger_name) > 0)) + { + char width_str_buffer[25]; + ::sprintf (width_str_buffer, "%d", window_size.ws_col); + SBDebugger::SetInternalVariable ("term-width", width_str_buffer, g_debugger_name); + } + } +} + int main (int argc, char const *argv[]) { @@ -1270,6 +1291,8 @@ SBHostOS::ThreadCreated ("[main]"); + signal (SIGWINCH, sigwinch_handler); + // Create a scope for driver so that the driver object will destroy itself // before SBDebugger::Terminate() is called. { From ctice at apple.com Thu Sep 9 13:01:59 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 09 Sep 2010 18:01:59 -0000 Subject: [Lldb-commits] [lldb] r113510 - in /lldb/trunk: include/lldb/Target/Process.h include/lldb/lldb-enumerations.h source/Target/Process.cpp Message-ID: <20100909180159.7FDA22A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 13:01:59 2010 New Revision: 113510 URL: http://llvm.org/viewvc/llvm-project?rev=113510&view=rev Log: Move the ProcessPlugins enum definition from lldb-enumerations.h to Process.h; modify the process.plugins settings variable to use the correct plugin names. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=113510&r1=113509&r2=113510&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Sep 9 13:01:59 2010 @@ -37,6 +37,14 @@ namespace lldb_private { + +typedef enum ProcessPlugins +{ + eMacosx, + eRemoteDebugger +} ProcessPlugins; + + class ProcessInstanceSettings : public InstanceSettings { public: @@ -106,7 +114,7 @@ std::string m_input_path; std::string m_output_path; std::string m_error_path; - lldb::ProcessPlugins m_plugin; + ProcessPlugins m_plugin; bool m_disable_aslr; }; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=113510&r1=113509&r2=113510&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Sep 9 13:01:59 2010 @@ -506,12 +506,6 @@ eVarSetOperationInvalid } VarSetOperationType; -typedef enum ProcessPlugins -{ - eMacosx, - eRemoteDebugger -} ProcessPlugins; - } // namespace lldb Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113510&r1=113509&r2=113510&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Sep 9 13:01:59 2010 @@ -2235,9 +2235,9 @@ lldb::OptionEnumValueElement Process::ProcessSettingsController::g_plugins[] = { - { eMacosx, "macosx", "Use the Mac OS X plugin" }, - { eRemoteDebugger, "remote_debugger" , "Use the remote debugger plugin" }, - { 0, NULL, NULL } + { eMacosx, "process.macosx", "Use the native MacOSX debugger plugin" }, + { eRemoteDebugger, "process.gdb-remote" , "Use the GDB Remote protocol based debugger plugin" }, + { 0, NULL, NULL } }; SettingEntry From ctice at apple.com Thu Sep 9 13:26:37 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 09 Sep 2010 18:26:37 -0000 Subject: [Lldb-commits] [lldb] r113519 - in /lldb/trunk/source: Core/Debugger.cpp Target/Process.cpp Target/Thread.cpp Message-ID: <20100909182637.CE3982A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 13:26:37 2010 New Revision: 113519 URL: http://llvm.org/viewvc/llvm-project?rev=113519&view=rev Log: Add comments to InstanceSettings constructors explaining why they have to be set up the way they are. Comment out code that removes pending settings for live instances (after the settings are copied over). Modified: lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113519&r1=113518&r2=113519&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 9 13:26:37 2010 @@ -633,11 +633,15 @@ m_prompt (), m_script_lang () { - if (name == NULL && live_instance) + // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called + // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers. + // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + + if (live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings, false); - m_owner.RemovePendingSettings (m_instance_name); + //m_owner.RemovePendingSettings (m_instance_name); } } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113519&r1=113518&r2=113519&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Sep 9 13:26:37 2010 @@ -1974,7 +1974,7 @@ ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), + InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), m_run_args (), m_env_vars (), m_input_path (), @@ -1983,11 +1983,15 @@ m_plugin (), m_disable_aslr (true) { - if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance) + // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called + // until the vtables for ProcessInstanceSettings are properly set up, i.e. AFTER all the initializers. + // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + + if (live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings,false); - m_owner.RemovePendingSettings (m_instance_name); + //m_owner.RemovePendingSettings (m_instance_name); } } Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=113519&r1=113518&r2=113519&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Thu Sep 9 13:26:37 2010 @@ -970,13 +970,15 @@ InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), m_avoid_regexp_ap () { - // FIXME: This seems like generic code, why was it duplicated (with the slight difference that - // DebuggerInstanceSettings checks name, not m_instance_name below) in Process & Debugger? - if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance) + // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called + // until the vtables for ThreadInstanceSettings are properly set up, i.e. AFTER all the initializers. + // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + + if (live_instance) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings,false); - m_owner.RemovePendingSettings (m_instance_name); + //m_owner.RemovePendingSettings (m_instance_name); } } From gclayton at apple.com Thu Sep 9 20:30:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Sep 2010 01:30:46 -0000 Subject: [Lldb-commits] [lldb] r113571 - in /lldb/trunk/source: Core/Address.cpp Core/AddressRange.cpp Symbol/Block.cpp Symbol/CompileUnit.cpp Symbol/Function.cpp Symbol/LineEntry.cpp Symbol/Symbol.cpp Symbol/SymbolContext.cpp Symbol/Type.cpp Message-ID: <20100910013047.15A632A6C12C@llvm.org> Author: gclayton Date: Thu Sep 9 20:30:46 2010 New Revision: 113571 URL: http://llvm.org/viewvc/llvm-project?rev=113571&view=rev Log: Cleaned up the output of "image lookup --address " which involved cleaning up the output of many GetDescription objects that are part of a symbol context. This fixes an issue where no ranges were being printed out for functions, blocks and symbols. Modified: lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/LineEntry.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Thu Sep 9 20:30:46 2010 @@ -381,7 +381,7 @@ addr_size = sizeof(addr_t); } - lldb_private::Address so_addr; + Address so_addr; switch (style) { case DumpStyleInvalid: @@ -448,7 +448,7 @@ } uint32_t pointer_size = 4; - lldb_private::Module *module = GetModule(); + Module *module = GetModule(); if (process) pointer_size = process->GetAddressByteSize(); else if (module) @@ -488,7 +488,7 @@ { if (target && so_addr.IsSectionOffset()) { - lldb_private::SymbolContext func_sc; + SymbolContext func_sc; target->GetImages().ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, func_sc); @@ -577,7 +577,7 @@ showed_info = true; if (so_addr.IsSectionOffset()) { - lldb_private::SymbolContext pointer_sc; + SymbolContext pointer_sc; if (target) { target->GetImages().ResolveSymbolContextForAddress (so_addr, @@ -603,7 +603,7 @@ { if (module) { - lldb_private::SymbolContext sc; + SymbolContext sc; module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc); if (sc.function || sc.symbol) { @@ -656,18 +656,10 @@ case DumpStyleDetailedSymbolContext: if (IsSectionOffset()) { - lldb::AddressType addr_type = eAddressTypeLoad; - addr_t addr = GetLoadAddress (process); - if (addr == LLDB_INVALID_ADDRESS) - { - addr = GetFileAddress(); - addr_type = eAddressTypeFile; - } - - lldb_private::Module *module = GetModule(); + Module *module = GetModule(); if (module) { - lldb_private::SymbolContext sc; + SymbolContext sc; module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc); if (sc.symbol) { Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Thu Sep 9 20:30:46 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/AddressRange.h" +#include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" @@ -144,11 +145,11 @@ if (process) addr_size = process->GetAddressByteSize (); + bool show_module = false; switch (style) { default: break; - case Address::DumpStyleSectionNameOffset: case Address::DumpStyleSectionPointerOffset: s->PutChar ('['); @@ -159,6 +160,9 @@ return true; break; + case Address::DumpStyleModuleWithFileAddress: + show_module = true; + // fall through case Address::DumpStyleFileAddress: vmaddr = m_base_addr.GetFileAddress(); break; @@ -170,9 +174,19 @@ if (vmaddr != LLDB_INVALID_ADDRESS) { + if (show_module) + { + Module *module = GetBaseAddress().GetModule(); + if (module) + s->Printf("%s", module->GetFileSpec().GetFilename().AsCString()); + } s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size); return true; } + else if (fallback_style != Address::DumpStyleInvalid) + { + return Dump(s, process, fallback_style, Address::DumpStyleInvalid); + } return false; } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Thu Sep 9 20:30:46 2010 @@ -38,6 +38,8 @@ void Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Process *process) const { + *s << "id = " << ((const UserID&)*this); + size_t num_ranges = m_ranges.size(); if (num_ranges) { @@ -48,12 +50,11 @@ if (base_addr == LLDB_INVALID_ADDRESS) base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress(); - s->Printf("range%s = ", num_ranges > 1 ? "s" : ""); + s->Printf(", range%s = ", num_ranges > 1 ? "s" : ""); std::vector::const_iterator pos, end = m_ranges.end(); for (pos = m_ranges.begin(); pos != end; ++pos) pos->Dump(s, base_addr, 4); } - *s << ", id = " << ((const UserID&)*this); if (m_inlineInfoSP.get() != NULL) m_inlineInfoSP->Dump(s); Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Thu Sep 9 20:30:46 2010 @@ -68,8 +68,7 @@ void CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const { - *s << '"' << (const FileSpec&)*this << "\", id = " << (const UserID&)*this - << ", language = " << (const Language&)*this; + *s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << (const Language&)*this << '"'; } @@ -85,8 +84,8 @@ s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); *s << "CompileUnit" << (const UserID&)*this - << ", language = " << (const Language&)*this - << ", file='" << (const FileSpec&)*this << "'\n"; + << ", language = \"" << (const Language&)*this + << "\", file = '" << (const FileSpec&)*this << "'\n"; // m_types.Dump(s); Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Thu Sep 9 20:30:46 2010 @@ -18,6 +18,7 @@ #include "clang/AST/Type.h" #include "clang/AST/CanonicalType.h" +using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- @@ -328,9 +329,14 @@ Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Process *process) { Type* func_type = GetType(); - *s << '"' << func_type->GetName() << "\", id = " << (const UserID&)*this; - *s << ", range = "; - GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); + *s << "id = " << (const UserID&)*this << ", name = \"" << func_type->GetName() << "\", range = "; + + Address::DumpStyle fallback_style; + if (level == eDescriptionLevelVerbose) + fallback_style = Address::DumpStyleModuleWithFileAddress; + else + fallback_style = Address::DumpStyleFileAddress; + GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, fallback_style); } void Modified: lldb/trunk/source/Symbol/LineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineEntry.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineEntry.cpp (original) +++ lldb/trunk/source/Symbol/LineEntry.cpp Thu Sep 9 20:30:46 2010 @@ -151,20 +151,16 @@ if (level == lldb::eDescriptionLevelBrief || level == lldb::eDescriptionLevelFull) { - // Show address only if (show_address_only) { - s->PutCString ("address = "); range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } else { - s->PutCString ("range = "); range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } - if (file) - *s << ' ' << file; + *s << ": " << file; if (line) { @@ -173,6 +169,7 @@ s->Printf(":%u", column); } + if (level == lldb::eDescriptionLevelFull) { if (is_start_of_statement) Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Thu Sep 9 20:30:46 2010 @@ -175,19 +175,29 @@ void Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Process *process) const { - *s << '"' << m_mangled.GetName() << "\", id = " << (const UserID&)*this; + *s << "id = " << (const UserID&)*this << ", name = \"" << m_mangled.GetName() << '"'; const Section *section = m_addr_range.GetBaseAddress().GetSection(); if (section != NULL) { - if (m_addr_range.GetByteSize() > 0) + if (m_addr_range.GetBaseAddress().IsSectionOffset()) { - s->PutCString(", range = "); - m_addr_range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); + if (m_addr_range.GetByteSize() > 0) + { + s->PutCString (", range = "); + m_addr_range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + } + else + { + s->PutCString (", address = "); + m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + } } else { - s->PutCString(", address = "); - m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); + if (m_size_is_sibling) + s->Printf (", sibling = %5llu", m_addr_range.GetBaseAddress().GetOffset()); + else + s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset()); } } } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Sep 9 20:30:46 2010 @@ -198,9 +198,11 @@ { if (module_sp) { - s->Indent(" Module: \""); + s->Indent(" Module: file = \""); module_sp->GetFileSpec().Dump(s); - s->PutChar('"'); + *s << '"'; + if (module_sp->GetArchitecture().IsValid()) + s->Printf (", arch = \"%s\"", module_sp->GetArchitecture().AsCString()); s->EOL(); } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=113571&r1=113570&r2=113571&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Thu Sep 9 20:30:46 2010 @@ -85,14 +85,11 @@ void lldb_private::Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name) { - if (show_name) - { - if (m_name) - *s << '\"' << m_name << "\", "; - } - *s << "id = " << (const UserID&)*this; + if (show_name && m_name) + *s << ", name = \"" << m_name << '"'; + if (m_byte_size != 0) s->Printf(", byte-size = %zu", m_byte_size); @@ -100,9 +97,9 @@ if (m_clang_qual_type) { - *s << ", clang_type = " << m_clang_qual_type << ' '; - + *s << ", clang_type = \""; ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s); + *s << '"'; } else if (m_encoding_uid != LLDB_INVALID_UID) { @@ -118,7 +115,7 @@ case eLValueReferenceToTypeWithUID: s->PutCString(" (unresolved L value reference)"); break; case eRValueReferenceToTypeWithUID: s->PutCString(" (unresolved R value reference)"); break; } - } + } } From ctice at apple.com Thu Sep 9 23:48:56 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 10 Sep 2010 04:48:56 -0000 Subject: [Lldb-commits] [lldb] r113575 - in /lldb/trunk: include/lldb/API/SBFileSpec.h include/lldb/Core/FileSpec.h include/lldb/Host/Host.h source/API/SBFileSpec.cpp source/Commands/CommandObjectFile.cpp source/Core/FileSpec.cpp source/Host/common/Host.cpp source/Target/TargetList.cpp tools/driver/Driver.cpp Message-ID: <20100910044856.275C02A6C12C@llvm.org> Author: ctice Date: Thu Sep 9 23:48:55 2010 New Revision: 113575 URL: http://llvm.org/viewvc/llvm-project?rev=113575&view=rev Log: If the file the user specifies can't be found in the current directory, and the user didn't specify a particular directory, search for the file using the $PATH environment variable. Modified: lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Target/TargetList.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Thu Sep 9 23:48:55 2010 @@ -36,6 +36,9 @@ bool Exists () const; + bool + ResolveExecutableLocation (); + const char * GetFilename() const; Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Thu Sep 9 23:48:55 2010 @@ -261,6 +261,21 @@ bool Exists () const; + + //------------------------------------------------------------------ + /// Expanded existence test. + /// + /// Call into the Host to see if it can help find the file (e.g. by + /// searching paths set in the environment, etc.). + /// + /// If found, sets the value of m_directory to the directory where the file was found. + /// + /// @return + /// \b true if was able to find the file using expanded search methods, \b false otherwise. + //------------------------------------------------------------------ + bool + ResolveExecutableLocation (); + uint64_t GetByteSize() const; Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Thu Sep 9 23:48:55 2010 @@ -258,6 +258,9 @@ static bool ResolveExecutableInBundle (FileSpec *file); + + static bool + ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename); static uint32_t ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Thu Sep 9 23:48:55 2010 @@ -61,6 +61,13 @@ return false; } +bool +SBFileSpec::ResolveExecutableLocation () +{ + if (m_opaque_ap.get()) + return m_opaque_ap->ResolveExecutableLocation (); + return false; +} int SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len) Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Thu Sep 9 23:48:55 2010 @@ -117,7 +117,7 @@ { FileSpec file_spec (file_path); - if (! file_spec.Exists()) + if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) { result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Thu Sep 9 23:48:55 2010 @@ -22,6 +22,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/Stream.h" +#include "lldb/Host/Host.h" using namespace lldb; using namespace lldb_private; @@ -414,6 +415,12 @@ return GetFileStats (this, &file_stats); } +bool +FileSpec::ResolveExecutableLocation () +{ + return Host::ResolveExecutableLocation (m_directory, m_filename); +} + uint64_t FileSpec::GetByteSize() const { Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Thu Sep 9 23:48:55 2010 @@ -727,3 +727,59 @@ return false; } #endif + +bool +Host::ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename) +{ + // If the user specified just a plain filename, there may be additional ways to find the + // file, such as searching the PATH environment variable on UNIX systems. This is the location + // to implement such additional searches. + + // For now the only search we are implementing is search $PATH, which makes no sense if + // the user already specified a directory. + + if (directory_name.GetLength() > 0) + return false; + + std::string search_path (getenv ("PATH")); + char dir_separator = ':'; + + bool done = false; + bool found = false; + size_t start = 0; + while (!done && !found) + { + size_t end = search_path.find (dir_separator, start); + size_t length; + if (end == std::string::npos) + { + done = true; + length = search_path.length() - start; + } + else + length = end - start; + + std::string directory_str = search_path.substr (start, length); + + if (directory_str.length() > 0) + { + StreamString tmp_full_path_name; + if (directory_str[directory_str.length()-1] == '/') + tmp_full_path_name.Printf ("%s%s", directory_str.c_str(), filename.AsCString()); + else + tmp_full_path_name.Printf ("%s/%s", directory_str.c_str(), filename.AsCString()); + + struct stat sb; + + if (::stat (tmp_full_path_name.GetData(), &sb) == 0) + { + found = true; + directory_name.SetCString (directory_str.c_str()); + } + } + + if (!done) + start = end + 1; + } + return found; +} Modified: lldb/trunk/source/Target/TargetList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/source/Target/TargetList.cpp (original) +++ lldb/trunk/source/Target/TargetList.cpp Thu Sep 9 23:48:55 2010 @@ -71,6 +71,10 @@ { ModuleSP exe_module_sp; FileSpec resolved_file(file); + + if (!resolved_file.Exists()) + resolved_file.ResolveExecutableLocation (); + if (!Host::ResolveExecutableInBundle (&resolved_file)) resolved_file = file; Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113575&r1=113574&r2=113575&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 9 23:48:55 2010 @@ -527,6 +527,13 @@ SBFileSpec file(optarg); if (file.Exists()) m_option_data.m_filename = optarg; + else if (file.ResolveExecutableLocation()) + { + char path[PATH_MAX]; + int path_len; + file.GetPath (path, path_len); + m_option_data.m_filename = path; + } else error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); } @@ -550,6 +557,14 @@ SBFileSpec file(optarg); if (file.Exists()) m_option_data.m_source_command_files.push_back (optarg); + else if (file.ResolveExecutableLocation()) + { + char final_path[PATH_MAX]; + size_t path_len; + file.GetPath (final_path, path_len); + std::string path_str (final_path); + m_option_data.m_source_command_files.push_back (path_str); + } else error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); } From clattner at apple.com Fri Sep 10 00:28:05 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 9 Sep 2010 22:28:05 -0700 Subject: [Lldb-commits] [lldb] r113575 - in /lldb/trunk: include/lldb/API/SBFileSpec.h include/lldb/Core/FileSpec.h include/lldb/Host/Host.h source/API/SBFileSpec.cpp source/Commands/CommandObjectFile.cpp source/Core/FileSpec.cpp source/Host/common/Host.cpp source/Target/TargetList.cpp tools/driver/Driver.cpp In-Reply-To: <20100910044856.275C02A6C12C@llvm.org> References: <20100910044856.275C02A6C12C@llvm.org> Message-ID: On Sep 9, 2010, at 9:48 PM, Caroline Tice wrote: > Author: ctice > Date: Thu Sep 9 23:48:55 2010 > New Revision: 113575 > > URL: http://llvm.org/viewvc/llvm-project?rev=113575&view=rev > Log: > If the file the user specifies can't be found in the current directory, > and the user didn't specify a particular directory, search for the file > using the $PATH environment variable. Cool, thanks for doing this Caroline. Did you consider using llvm::sys::Program::FindProgramByName? It already handles this, as well as handling the other annoying cases on windows. In general, we should aim to reuse existing support stuff that LLVM provides rather than reinvent it. The corresponding header is "llvm/System/Program.h". -Chris > > > Modified: > lldb/trunk/include/lldb/API/SBFileSpec.h > lldb/trunk/include/lldb/Core/FileSpec.h > lldb/trunk/include/lldb/Host/Host.h > lldb/trunk/source/API/SBFileSpec.cpp > lldb/trunk/source/Commands/CommandObjectFile.cpp > lldb/trunk/source/Core/FileSpec.cpp > lldb/trunk/source/Host/common/Host.cpp > lldb/trunk/source/Target/TargetList.cpp > lldb/trunk/tools/driver/Driver.cpp > > Modified: lldb/trunk/include/lldb/API/SBFileSpec.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) > +++ lldb/trunk/include/lldb/API/SBFileSpec.h Thu Sep 9 23:48:55 2010 > @@ -36,6 +36,9 @@ > bool > Exists () const; > > + bool > + ResolveExecutableLocation (); > + > const char * > GetFilename() const; > > > Modified: lldb/trunk/include/lldb/Core/FileSpec.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Core/FileSpec.h (original) > +++ lldb/trunk/include/lldb/Core/FileSpec.h Thu Sep 9 23:48:55 2010 > @@ -261,6 +261,21 @@ > bool > Exists () const; > > + > + //------------------------------------------------------------------ > + /// Expanded existence test. > + /// > + /// Call into the Host to see if it can help find the file (e.g. by > + /// searching paths set in the environment, etc.). > + /// > + /// If found, sets the value of m_directory to the directory where the file was found. > + /// > + /// @return > + /// \b true if was able to find the file using expanded search methods, \b false otherwise. > + //------------------------------------------------------------------ > + bool > + ResolveExecutableLocation (); > + > uint64_t > GetByteSize() const; > > > Modified: lldb/trunk/include/lldb/Host/Host.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Host/Host.h (original) > +++ lldb/trunk/include/lldb/Host/Host.h Thu Sep 9 23:48:55 2010 > @@ -258,6 +258,9 @@ > > static bool > ResolveExecutableInBundle (FileSpec *file); > + > + static bool > + ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename); > > static uint32_t > ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); > > Modified: lldb/trunk/source/API/SBFileSpec.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/source/API/SBFileSpec.cpp (original) > +++ lldb/trunk/source/API/SBFileSpec.cpp Thu Sep 9 23:48:55 2010 > @@ -61,6 +61,13 @@ > return false; > } > > +bool > +SBFileSpec::ResolveExecutableLocation () > +{ > + if (m_opaque_ap.get()) > + return m_opaque_ap->ResolveExecutableLocation (); > + return false; > +} > > int > SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len) > > Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) > +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Thu Sep 9 23:48:55 2010 > @@ -117,7 +117,7 @@ > { > FileSpec file_spec (file_path); > > - if (! file_spec.Exists()) > + if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) > { > result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); > result.SetStatus (eReturnStatusFailed); > > Modified: lldb/trunk/source/Core/FileSpec.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/source/Core/FileSpec.cpp (original) > +++ lldb/trunk/source/Core/FileSpec.cpp Thu Sep 9 23:48:55 2010 > @@ -22,6 +22,7 @@ > #include "lldb/Core/DataBufferHeap.h" > #include "lldb/Core/DataBufferMemoryMap.h" > #include "lldb/Core/Stream.h" > +#include "lldb/Host/Host.h" > > using namespace lldb; > using namespace lldb_private; > @@ -414,6 +415,12 @@ > return GetFileStats (this, &file_stats); > } > > +bool > +FileSpec::ResolveExecutableLocation () > +{ > + return Host::ResolveExecutableLocation (m_directory, m_filename); > +} > + > uint64_t > FileSpec::GetByteSize() const > { > > Modified: lldb/trunk/source/Host/common/Host.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/source/Host/common/Host.cpp (original) > +++ lldb/trunk/source/Host/common/Host.cpp Thu Sep 9 23:48:55 2010 > @@ -727,3 +727,59 @@ > return false; > } > #endif > + > +bool > +Host::ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename) > +{ > + // If the user specified just a plain filename, there may be additional ways to find the > + // file, such as searching the PATH environment variable on UNIX systems. This is the location > + // to implement such additional searches. > + > + // For now the only search we are implementing is search $PATH, which makes no sense if > + // the user already specified a directory. > + > + if (directory_name.GetLength() > 0) > + return false; > + > + std::string search_path (getenv ("PATH")); > + char dir_separator = ':'; > + > + bool done = false; > + bool found = false; > + size_t start = 0; > + while (!done && !found) > + { > + size_t end = search_path.find (dir_separator, start); > + size_t length; > + if (end == std::string::npos) > + { > + done = true; > + length = search_path.length() - start; > + } > + else > + length = end - start; > + > + std::string directory_str = search_path.substr (start, length); > + > + if (directory_str.length() > 0) > + { > + StreamString tmp_full_path_name; > + if (directory_str[directory_str.length()-1] == '/') > + tmp_full_path_name.Printf ("%s%s", directory_str.c_str(), filename.AsCString()); > + else > + tmp_full_path_name.Printf ("%s/%s", directory_str.c_str(), filename.AsCString()); > + > + struct stat sb; > + > + if (::stat (tmp_full_path_name.GetData(), &sb) == 0) > + { > + found = true; > + directory_name.SetCString (directory_str.c_str()); > + } > + } > + > + if (!done) > + start = end + 1; > + } > + return found; > +} > > Modified: lldb/trunk/source/Target/TargetList.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/source/Target/TargetList.cpp (original) > +++ lldb/trunk/source/Target/TargetList.cpp Thu Sep 9 23:48:55 2010 > @@ -71,6 +71,10 @@ > { > ModuleSP exe_module_sp; > FileSpec resolved_file(file); > + > + if (!resolved_file.Exists()) > + resolved_file.ResolveExecutableLocation (); > + > if (!Host::ResolveExecutableInBundle (&resolved_file)) > resolved_file = file; > > > Modified: lldb/trunk/tools/driver/Driver.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113575&r1=113574&r2=113575&view=diff > ============================================================================== > --- lldb/trunk/tools/driver/Driver.cpp (original) > +++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 9 23:48:55 2010 > @@ -527,6 +527,13 @@ > SBFileSpec file(optarg); > if (file.Exists()) > m_option_data.m_filename = optarg; > + else if (file.ResolveExecutableLocation()) > + { > + char path[PATH_MAX]; > + int path_len; > + file.GetPath (path, path_len); > + m_option_data.m_filename = path; > + } > else > error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); > } > @@ -550,6 +557,14 @@ > SBFileSpec file(optarg); > if (file.Exists()) > m_option_data.m_source_command_files.push_back (optarg); > + else if (file.ResolveExecutableLocation()) > + { > + char final_path[PATH_MAX]; > + size_t path_len; > + file.GetPath (final_path, path_len); > + std::string path_str (final_path); > + m_option_data.m_source_command_files.push_back (path_str); > + } > else > error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); > } > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From jmolenda at apple.com Fri Sep 10 02:49:17 2010 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 10 Sep 2010 07:49:17 -0000 Subject: [Lldb-commits] [lldb] r113581 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ include/lldb/Utility/ lldb.xcodeproj/ source/ source/Commands/ source/Core/ source/Host/macosx/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/Process/Linux/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/MacOSX-User/source/MacOSX/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/ source/Utility/ Message-ID: <20100910074917.712382A6C12D@llvm.org> Author: jmolenda Date: Fri Sep 10 02:49:16 2010 New Revision: 113581 URL: http://llvm.org/viewvc/llvm-project?rev=113581&view=rev Log: The first part of an lldb native stack unwinder. The Unwind and RegisterContext subclasses still need to be finished; none of this code is used by lldb at this point (unless you call into it by hand). The ObjectFile class now has an UnwindTable object. The UnwindTable object has a series of FuncUnwinders objects (Function Unwinders) -- one for each function in that ObjectFile we've backtraced through during this debug session. The FuncUnwinders object has a few different UnwindPlans. UnwindPlans are a generic way of describing how to find the canonical address of a given function's stack frame (the CFA idea from DWARF/eh_frame) and how to restore the caller frame's register values, if they have been saved by this function. UnwindPlans are created from different sources. One source is the eh_frame exception handling information generated by the compiler for unwinding an exception throw. Another source is an assembly language inspection class (UnwindAssemblyProfiler, uses the Plugin architecture) which looks at the instructions in the funciton prologue and describes the stack movements/register saves that are done. Two additional types of UnwindPlans that are worth noting are the "fast" stack UnwindPlan which is useful for making a first pass over a thread's stack, determining how many stack frames there are and retrieving the pc and CFA values for each frame (enough to create StackFrameIDs). Only a minimal set of registers is recovered during a fast stack walk. The final UnwindPlan is an architectural default unwind plan. These are provided by the ArchDefaultUnwindPlan class (which uses the plugin architecture). When no symbol/function address range can be found for a given pc value -- when we have no eh_frame information and when we don't have a start address so we can't examine the assembly language instrucitons -- we have to make a best guess about how to unwind. That's when we use the architectural default UnwindPlan. On x86_64, this would be to assume that rbp is used as a stack pointer and we can use that to find the caller's frame pointer and pc value. It's a last-ditch best guess about how to unwind out of a frame. There are heuristics about when to use one UnwindPlan versues the other -- this will all happen in the still-begin-written UnwindLLDB subclass of Unwind which runs the UnwindPlans. Added: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h lldb/trunk/include/lldb/Symbol/UnwindPlan.h lldb/trunk/include/lldb/Symbol/UnwindTable.h lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h lldb/trunk/source/Symbol/FuncUnwinders.cpp lldb/trunk/source/Symbol/UnwindPlan.cpp lldb/trunk/source/Symbol/UnwindTable.cpp lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Modified: lldb/trunk/include/lldb/Core/Address.h lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/trunk/include/lldb/Symbol/ObjectFile.h lldb/trunk/include/lldb/Target/RegisterContext.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp lldb/trunk/source/Target/RegisterContext.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Fri Sep 10 02:49:16 2010 @@ -429,7 +429,7 @@ SetSection (const Section* section) { m_section = section; } //------------------------------------------------------------------ - /// Reconstruct a symbol context from ad address. + /// Reconstruct a symbol context from an address. /// /// This class doesn't inherit from SymbolContextScope because many /// address objects have short lifespans. Address objects that are Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Fri Sep 10 02:49:16 2010 @@ -178,6 +178,41 @@ static SymbolVendorCreateInstance GetSymbolVendorCreateCallbackForPluginName (const char *name); + + //------------------------------------------------------------------ + // UnwindAssemblyProfiler + //------------------------------------------------------------------ + static bool + RegisterPlugin (const char *name, + const char *description, + UnwindAssemblyProfilerCreateInstance create_callback); + + static bool + UnregisterPlugin (UnwindAssemblyProfilerCreateInstance create_callback); + + static UnwindAssemblyProfilerCreateInstance + GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx); + + static UnwindAssemblyProfilerCreateInstance + GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name); + + //------------------------------------------------------------------ + // ArchDefaultUnwindPlan + //------------------------------------------------------------------ + static bool + RegisterPlugin (const char *name, + const char *description, + ArchDefaultUnwindPlanCreateInstance create_callback); + + static bool + UnregisterPlugin (ArchDefaultUnwindPlanCreateInstance create_callback); + + static ArchDefaultUnwindPlanCreateInstance + GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx); + + static ArchDefaultUnwindPlanCreateInstance + GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name); + }; Modified: lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h (original) +++ lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h Fri Sep 10 02:49:16 2010 @@ -10,301 +10,120 @@ #ifndef liblldb_DWARFCallFrameInfo_h_ #define liblldb_DWARFCallFrameInfo_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Flags.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/VMRange.h" #include "lldb/Core/dwarf.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Symbol/ObjectFile.h" namespace lldb_private { -//---------------------------------------------------------------------- -// DWARFCallFrameInfo -// -// State that describes all register locations for a given address -// range. -//---------------------------------------------------------------------- + +// DWARFCallFrameInfo is a class which can read eh_frame and DWARF +// Call Frame Information FDEs. It stores little information internally. +// Only two APIs are exported - one to find the high/low pc values +// of a function given a text address via the information in the +// eh_frame / debug_frame, and one to generate an UnwindPlan based +// on the FDE in the eh_frame / debug_frame section. class DWARFCallFrameInfo { public: - enum - { - CFI_AUG_MAX_SIZE = 8, - CFI_HEADER_SIZE = 8 - }; - - class Row; - - class RegisterLocation - { - public: - - enum Type - { - unspecified, // not specified, we may be able to assume this is the same register. - // gcc doesn't specify all initial values so we really don't know... - isUndefined, // reg is not available - isSame, // reg is unchanged - atCFAPlusOffset,// reg = deref(CFA + offset) - isCFAPlusOffset,// reg = CFA + offset - inOtherRegister,// reg = other reg - atDWARFExpression, // reg = deref(eval(dwarf_expr)) - isDWARFExpression // reg = eval(dwarf_expr) - }; - RegisterLocation(); + DWARFCallFrameInfo (ObjectFile& objfile, lldb::SectionSP& section, uint32_t reg_kind, bool is_eh_frame); - bool - operator == (const RegisterLocation& rhs) const; - - void - Dump(Stream *s, const DWARFCallFrameInfo &cfi, Thread *thread, const Row *row, uint32_t reg_num) const; - - void - SetUnspecified(); - - void - SetUndefined(); - - void - SetSame() ; - - void - SetAtCFAPlusOffset (int64_t offset); - - void - SetIsCFAPlusOffset (int64_t offset); + ~DWARFCallFrameInfo(); - void - SetInRegister (uint32_t reg_num); + // Locate an AddressRange that includes the provided Address in this + // object's eh_frame/debug_info + // Returns true if a range is found to cover that address. + bool + GetAddressRange (Address addr, AddressRange &range); - void - SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len); + // Return an UnwindPlan based on the call frame information encoded + // in the FDE of this DWARFCallFrameInfo section. + bool + GetUnwindPlan (Address addr, UnwindPlan& unwind_plan); - void - SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len); - protected: - Type m_type; // How do we locate this register? - union - { - // For m_type == atCFAPlusOffset or m_type == isCFAPlusOffset - int32_t offset; - // For m_type == inOtherRegister - uint32_t reg_num; // The register number - // For m_type == atDWARFExpression or m_type == isDWARFExpression - struct { - const uint8_t *opcodes; - uint32_t length; - } expr; - } m_location; - }; - - class Row +private: + enum { - public: - - Row (); - - ~Row (); - - void - Clear(); - - void - Dump(Stream* s, const DWARFCallFrameInfo &cfi, Thread *thread, lldb::addr_t base_addr) const; - - bool - GetRegisterInfo (uint32_t reg_num, RegisterLocation& register_location) const; - - void - SetRegisterInfo (uint32_t reg_num, const RegisterLocation& register_location); - - lldb::addr_t - GetOffset() const - { - return m_offset; - } - - void - SetOffset(lldb::addr_t offset) - { - m_offset = offset; - } - - void - SlideOffset (lldb::addr_t slide) - { - m_offset += slide; - } - - uint32_t - GetCFARegister () const - { - return m_cfa_reg_num; - } - - void - SetCFARegister (uint32_t reg_num) - { - m_cfa_reg_num = reg_num; - } - - int32_t - GetCFAOffset () const - { - return m_cfa_offset; - } - - void - SetCFAOffset (int32_t offset) - { - m_cfa_offset = offset; - } - - protected: - typedef std::map collection; - lldb::addr_t m_offset; // The an offset into the DBAddressRange that owns this row. - uint32_t m_cfa_reg_num; // The Call Frame Address register number - int32_t m_cfa_offset; // The offset from the CFA for this row - collection m_register_locations; + CFI_AUG_MAX_SIZE = 8, + CFI_HEADER_SIZE = 8 }; - //------------------------------------------------------------------ - // Common Information Entry (CIE) - //------------------------------------------------------------------ -protected: - struct CIE { - typedef lldb::SharedPtr::Type shared_ptr; dw_offset_t cie_offset; uint8_t version; - char augmentation[CFI_AUG_MAX_SIZE]; // This is typically empty or very short. If we ever run into the limit, make this a NSData pointer + char augmentation[CFI_AUG_MAX_SIZE]; // This is typically empty or very short. uint32_t code_align; int32_t data_align; uint32_t return_addr_reg_num; dw_offset_t inst_offset; // offset of CIE instructions in mCFIData uint32_t inst_length; // length of CIE instructions in mCFIData uint8_t ptr_encoding; + lldb_private::UnwindPlan::Row initial_row; - CIE(dw_offset_t offset); - ~CIE(); - - void - Dump(Stream *s, Thread* threadState, const ArchSpec *arch, uint32_t reg_kind) const; + CIE(dw_offset_t offset) : cie_offset(offset), initial_row() {} }; - //------------------------------------------------------------------ - // Frame Description Entry (FDE) - //------------------------------------------------------------------ -public: + typedef lldb::SharedPtr::Type CIESP; - class FDE + struct FDEEntry { - public: - typedef lldb::SharedPtr::Type shared_ptr; - - FDE (uint32_t offset, const AddressRange &range); - ~FDE(); + AddressRange bounds; // function bounds + dw_offset_t offset; // offset to this FDE within the Section - const AddressRange & - GetAddressRange() const; - - void - AppendRow (const Row &row); - - bool - IsValidRowIndex (uint32_t idx) const; - - void - Dump (Stream *s, const DWARFCallFrameInfo &cfi, Thread* thread) const; - - const Row& - GetRowAtIndex (uint32_t idx); - - protected: - typedef std::vector collection; - uint32_t m_fde_offset; - AddressRange m_range; - collection m_row_list; - private: - DISALLOW_COPY_AND_ASSIGN (FDE); + inline bool + operator<(const DWARFCallFrameInfo::FDEEntry& b) const + { + if (bounds.GetBaseAddress().GetOffset() < b.bounds.GetBaseAddress().GetOffset()) + return true; + else + return false; + } }; - DWARFCallFrameInfo(ObjectFile *objfile, lldb_private::Section *section, uint32_t reg_kind); - - ~DWARFCallFrameInfo(); + typedef std::map cie_map_t; bool IsEHFrame() const; - const ArchSpec * - GetArchitecture() const; - - uint32_t - GetRegisterKind () const; - - void - SetRegisterKind (uint32_t reg_kind); - - void - Index (); - -// bool UnwindRegister (const uint32_t reg_num, const Thread* currState, const Row* row, Thread* unwindState); -// uint32_t UnwindThreadState(const Thread* curr_state, bool is_first_frame, Thread* unwound_state); - const FDE * - FindFDE(const Address &addr); - - void - Dump(Stream *s, Thread *thread) const; + bool + GetFDEEntryByAddress (Address addr, FDEEntry& fde_entry); void - ParseAll(); -protected: + GetFDEIndex (); - enum - { - eFlagParsedIndex = (1 << 0) - }; + bool + FDEToUnwindPlan (uint32_t offset, Address startaddr, UnwindPlan& unwind_plan); - typedef std::map cie_map_t; - struct FDEInfo - { - off_t fde_offset; - FDE::shared_ptr fde_sp; - FDEInfo (off_t offset); - FDEInfo (); + const CIE* + GetCIE(dw_offset_t cie_offset); - }; - typedef std::map fde_map_t; + ObjectFile& m_objfile; + lldb::SectionSP m_section; + uint32_t m_reg_kind; + Flags m_flags; + cie_map_t m_cie_map; - ObjectFile * m_objfile; - lldb_private::Section * m_section; - uint32_t m_reg_kind; - Flags m_flags; - DataExtractor m_cfi_data; - cie_map_t m_cie_map; - fde_map_t m_fde_map; + DataExtractor m_cfi_data; + bool m_cfi_data_initialized; // only copy the section into the DE once - const CIE* - GetCIE (uint32_t offset); + std::vector m_fde_index; + bool m_fde_index_initialized; // only scan the section for FDEs once - void - ParseInstructions(const CIE *cie, FDE *fde, uint32_t instr_offset, uint32_t instr_length); + bool m_is_eh_frame; - CIE::shared_ptr + CIESP ParseCIE (const uint32_t cie_offset); - FDE::shared_ptr - ParseFDE (const uint32_t fde_offset); }; } // namespace lldb_private Added: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (added) +++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,91 @@ +#ifndef liblldb_FuncUnwinders_h +#define liblldb_FuncUnwinders_h + +#include "lldb/lldb-private.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-forward-rtti.h" +#include "lldb/Core/AddressRange.h" +#include "lldb/Core/ArchSpec.h" +#include + +namespace lldb_private { + +class UnwindTable; + +class FuncUnwinders +{ +public: + // FuncUnwinders objects are used to track UnwindPlans for a function + // (named or not - really just an address range) + + // We'll record three different UnwindPlans for each address range: + // 1. Unwinding from a call site (a valid exception throw location) + // This is often sourced from the eh_frame exception handling info + // 2. Unwinding from a non-call site (any location in the function) + // This is often done by analyzing the function prologue assembly + // langauge instructions + // 3. A fast unwind method for this function which only retrieves a + // limited set of registers necessary to walk the stack + // 4. An architectural default unwind plan when none of the above are + // available for some reason. + + // Additionally, FuncUnwinds object can be asked where the prologue + // instructions are finished for migrating breakpoints past the + // stack frame setup instructions when we don't have line table information. + + FuncUnwinders (lldb_private::UnwindTable& unwind_table, lldb_private::UnwindAssemblyProfiler *assembly_profiler, AddressRange range); + + ~FuncUnwinders (); + + UnwindPlan* + GetUnwindPlanAtCallSite (); + + UnwindPlan* + GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread); + + UnwindPlan* + GetUnwindPlanFastUnwind (lldb_private::Thread& Thread); + + UnwindPlan* + GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread); + + Address& + GetFirstNonPrologueInsn (Target& target); + + const Address& + GetFunctionStartAddress () const; + + bool + ContainsAddress (const Address& addr) const + { + return m_range.ContainsFileAddress (addr); + } + +protected: + + UnwindTable& m_unwind_table; + UnwindAssemblyProfiler *m_assembly_profiler; + AddressRange m_range; + + UnwindPlan* m_unwind_at_call_site; + UnwindPlan* m_unwind_at_non_call_site; + UnwindPlan* m_fast_unwind; + UnwindPlan* m_arch_default_unwind; + + Address m_first_non_prologue_insn; + +}; // class FuncUnwinders + +inline bool +operator<(const FuncUnwinders& a, const FuncUnwinders& b) +{ + if (a.GetFunctionStartAddress().GetOffset() < b.GetFunctionStartAddress().GetOffset()) + return true; + else + return false; +} + +} // namespace lldb_private + + +#endif //liblldb_FuncUnwinders_h Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Sep 10 02:49:16 2010 @@ -16,6 +16,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/Symtab.h" +#include "lldb/Symbol/UnwindTable.h" namespace lldb_private { @@ -66,7 +67,8 @@ m_file (), // This file could be different from the original module's file m_offset (offset), m_length (length), - m_data (headerDataSP, lldb::eByteOrderHost, 4) + m_data (headerDataSP, lldb::eByteOrderHost, 4), + m_unwind_table (*this) { if (file_spec_ptr) m_file = *file_spec_ptr; @@ -294,6 +296,21 @@ virtual bool ParseHeader () = 0; + //------------------------------------------------------------------ + /// Returns a reference to the UnwindTable for this ObjectFile + /// + /// The UnwindTable contains FuncUnwinders objects for any function in + /// this ObjectFile. If a FuncUnwinders object hasn't been created yet + /// (i.e. the function has yet to be unwound in a stack walk), it + /// will be created when requested. Specifically, we do not create + /// FuncUnwinders objects for functions until they are needed. + /// + /// @return + /// Returns the unwind table for this object file. + //------------------------------------------------------------------ + virtual lldb_private::UnwindTable& + GetUnwindTable () { return m_unwind_table; } + protected: //------------------------------------------------------------------ // Member variables. @@ -302,6 +319,7 @@ lldb::addr_t m_offset; ///< The offset in bytes into the file, or the address in memory lldb::addr_t m_length; ///< The length of this object file if it is known (can be zero if length is unknown or can't be determined). DataExtractor m_data; ///< The data for this object file so things can be parsed lazily. + lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects created for this ObjectFile's functions //------------------------------------------------------------------ /// Sets the architecture for a module. At present the architecture Added: lldb/trunk/include/lldb/Symbol/UnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (added) +++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,224 @@ +#ifndef liblldb_UnwindPlan_h +#define liblldb_UnwindPlan_h + +#include "lldb/lldb-private.h" +#include "lldb/Core/AddressRange.h" +#include "lldb/Core/Stream.h" + +#include +#include + +namespace lldb_private { + +// The UnwindPlan object specifies how to unwind out of a function - where +// this function saves the caller's register values before modifying them +// (for non-volatile aka saved registers) and how to find this frame's +// Canonical Frame Address (CFA). + +// Most commonly, registers are saved on the stack, offset some bytes from +// the Canonical Frame Address, or CFA, which is the starting address of +// this function's stack frame (the CFA is same as the eh_frame's CFA, +// whatever that may be on a given architecture). +// The CFA address for the stack frame does not change during +// the lifetime of the function. + +// Internally, the UnwindPlan is structured as a vector of register locations +// organized by code address in the function, showing which registers have been +// saved at that point and where they are saved. +// It can be thought of as the expanded table form of the DWARF CFI +// encoded information. + +// Other unwind information sources will be converted into UnwindPlans before +// being added to a FuncUnwinders object. The unwind source may be +// an eh_frame FDE, a DWARF debug_frame FDE, or assembly language based +// prologue analysis. +// The UnwindPlan is the canonical form of this information that the unwinder +// code will use when walking the stack. + +class UnwindPlan { +public: + + class Row { + public: + class RegisterLocation + { + public: + + typedef enum RestoreType + { + unspecified, // not specified, we may be able to assume this + // is the same register. gcc doesn't specify all + // initial values so we really don't know... + isUndefined, // reg is not available, e.g. volatile reg + isSame, // reg is unchanged + atCFAPlusOffset, // reg = deref(CFA + offset) + isCFAPlusOffset, // reg = CFA + offset + inOtherRegister, // reg = other reg + atDWARFExpression, // reg = deref(eval(dwarf_expr)) + isDWARFExpression // reg = eval(dwarf_expr) + }; + + RegisterLocation() : m_type(unspecified) { } + + bool + operator == (const RegisterLocation& rhs) const; + + void SetUnspecified(); + + void SetUndefined(); + + void SetSame(); + + void SetAtCFAPlusOffset (int32_t offset); + + void SetIsCFAPlusOffset (int32_t offset); + + void SetInRegister (uint32_t reg_num); + + RestoreType GetLocationType () const { return m_type; } + + int32_t GetOffset () const { return m_location.offset; } + + uint32_t GetRegNum () const { return m_location.reg_num; } + + void GetDWARFExpr (const uint8_t **opcodes, uint16_t& len) const { *opcodes = m_location.expr.opcodes; len = m_location.expr.length; } + + void + SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len); + + void + SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len); + + void + Dump (Stream &s) const; + + private: + RestoreType m_type; // How do we locate this register? + union + { + // For m_type == atCFAPlusOffset or m_type == isCFAPlusOffset + int32_t offset; + // For m_type == inOtherRegister + uint32_t reg_num; // The register number + // For m_type == atDWARFExpression or m_type == isDWARFExpression + struct { + const uint8_t *opcodes; + uint16_t length; + } expr; + } m_location; + }; + + public: + Row (); + + bool + GetRegisterInfo (uint32_t reg_num, RegisterLocation& register_location) const; + + void + SetRegisterInfo (uint32_t reg_num, const RegisterLocation register_location); + + lldb::addr_t + GetOffset() const + { + return m_offset; + } + + void + SetOffset(lldb::addr_t offset) + { + m_offset = offset; + } + + void + SlideOffset(lldb::addr_t offset) + { + m_offset += offset; + } + + uint32_t + GetCFARegister () const + { + return m_cfa_reg_num; + } + + void + SetCFARegister (uint32_t reg_num) + { + m_cfa_reg_num = reg_num; + } + + int32_t + GetCFAOffset () const + { + return m_cfa_offset; + } + + void + SetCFAOffset (int32_t offset) + { + m_cfa_offset = offset; + } + + void + Clear (); + + void + Dump (Stream& s, int register_kind, Thread* thread) const; + + protected: + typedef std::map collection; + lldb::addr_t m_offset; // Offset into the function for this row + uint32_t m_cfa_reg_num; // The Call Frame Address register number + int32_t m_cfa_offset; // The offset from the CFA for this row + collection m_register_locations; + + }; // class Row + +public: + + UnwindPlan () : m_register_kind(-1), m_row_list(), m_plan_valid_address_range() { } + + void Dump (Stream& s, Process* process, Thread* thread) const; + + void + AppendRow (const Row& row); + + const Row* + GetRowForFunctionOffset (int offset) const; + + void + SetRegisterKind (uint32_t rk); + + uint32_t + GetRegisterKind (void) const; + + // This UnwindPlan may not be valid at every address of the function span. + // For instance, a FastUnwindPlan will not be valid at the prologue setup + // instructions - only in the body of the function. + void + SetPlanValidAddressRange (const AddressRange& range); + + bool + PlanValidAtAddress (Address addr); + + bool + IsValidRowIndex (uint32_t idx) const; + + const UnwindPlan::Row& + GetRowAtIndex (uint32_t idx) const; + + int + GetRowCount () const; + +private: + + typedef std::vector collection; + collection m_row_list; + AddressRange m_plan_valid_address_range; + uint32_t m_register_kind; // The RegisterKind these register numbers are in terms of - will need to be + // translated to lldb native reg nums at unwind time +}; // class UnwindPlan + +} // namespace lldb_private + +#endif //liblldb_UnwindPlan_h Added: lldb/trunk/include/lldb/Symbol/UnwindTable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindTable.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindTable.h (added) +++ lldb/trunk/include/lldb/Symbol/UnwindTable.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,55 @@ +//===-- Symtab.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_UnwindTable_h +#define liblldb_UnwindTable_h + +#include + +#include "lldb/lldb-private.h" + +namespace lldb_private { + +// A class which holds all the FuncUnwinders objects for a given ObjectFile. +// The UnwindTable is populated with FuncUnwinders objects lazily during +// the debug session. + +class UnwindTable +{ +public: + UnwindTable(ObjectFile& objfile); + ~UnwindTable(); + + lldb_private::DWARFCallFrameInfo * + GetEHFrameInfo (); + + lldb::FuncUnwindersSP + GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc); + +private: + void initialize (); + + typedef std::vector collection; + typedef collection::iterator iterator; + typedef collection::const_iterator const_iterator; + + ObjectFile& m_object_file; + collection m_unwinds; + + bool m_initialized; // delay some initialization until ObjectFile is set up + + UnwindAssemblyProfiler* m_assembly_profiler; + + DWARFCallFrameInfo* m_eh_frame; +}; + +} // namespace lldb_private + +#endif // liblldb_UnwindTable_h Modified: lldb/trunk/include/lldb/Target/RegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/RegisterContext.h (original) +++ lldb/trunk/include/lldb/Target/RegisterContext.h Fri Sep 10 02:49:16 2010 @@ -142,6 +142,9 @@ bool WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval); + bool + ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t target_regnum); + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ Added: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (added) +++ lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,42 @@ +//===---------------------ArchDefaultUnwindPlan.h ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef utility_ArchDefaultUnwindPlan_h_ +#define utility_ArchDefaultUnwindPlan_h_ + +#include "lldb-private.h" +#include "lldb/Core/PluginInterface.h" + +namespace lldb_private { + +class ArchDefaultUnwindPlan : + public PluginInterface +{ +public: + + virtual + ~ArchDefaultUnwindPlan(); + + virtual lldb_private::UnwindPlan* + GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) = 0; + + static ArchDefaultUnwindPlan* + FindPlugin (const ArchSpec &arch); + +protected: + ArchDefaultUnwindPlan(); +private: + DISALLOW_COPY_AND_ASSIGN (ArchDefaultUnwindPlan); +}; + +} // namespace lldb_private + +#endif //utility_ArchDefaultUnwindPlan_h_ + + Added: lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h (added) +++ lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,49 @@ +//===---------------------UnwindAssemblyProfiler.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef utility_UnwindAssemblyProfiler_h_ +#define utility_UnwindAssemblyProfiler_h_ + +#include "lldb-private.h" +#include "lldb/Core/PluginInterface.h" + +namespace lldb_private { + +class UnwindAssemblyProfiler : + public PluginInterface +{ +public: + + virtual + ~UnwindAssemblyProfiler(); + + virtual bool + GetNonCallSiteUnwindPlanFromAssembly (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan& unwind_plan) = 0; + + virtual bool + GetFastUnwindPlan (lldb_private::AddressRange& func, Thread& thread, lldb_private::UnwindPlan &unwind_plan) = 0; + + // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). + virtual bool + FirstNonPrologueInsn (lldb_private::AddressRange& func, Target& target, Thread* thread, lldb_private::Address& first_non_prologue_insn) = 0; + + static UnwindAssemblyProfiler* + FindPlugin (const ArchSpec &arch); + +protected: + UnwindAssemblyProfiler(); +private: + DISALLOW_COPY_AND_ASSIGN (UnwindAssemblyProfiler); +}; + +} // namespace lldb_private + +#endif //utility_UnwindAssemblyProfiler_h_ + + Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep 10 02:49:16 2010 @@ -198,10 +198,11 @@ //---------------------------------------------------------------------- typedef enum RegisterKind { - eRegisterKindGCC = 0, - eRegisterKindDWARF, - eRegisterKindGeneric, - eRegisterKindGDB, + eRegisterKindGCC = 0, // the register numbers seen in eh_frame + eRegisterKindDWARF, // the register numbers seen DWARF + eRegisterKindGeneric, // insn ptr reg, stack ptr reg, etc not specific to any particular target + eRegisterKindGDB, // the register numbers gdb uses (matches stabs numbers?) + eRegisterKindLLDB, // lldb's internal register numbers kNumRegisterKinds } RegisterKind; Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Fri Sep 10 02:49:16 2010 @@ -59,6 +59,7 @@ typedef SharedPtr::Type ThreadSP; typedef SharedPtr::Type ThreadPlanSP; typedef SharedPtr::Type TypeSP; + typedef SharedPtr::Type FuncUnwindersSP; typedef SharedPtr::Type UserSettingsControllerSP; typedef SharedPtr::Type ValueObjectSP; typedef SharedPtr::Type VariableSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Fri Sep 10 02:49:16 2010 @@ -22,33 +22,33 @@ class AddressRange; class AddressResolver; class ArchSpec; +class ArchDefaultUnwindPlan; class Args; class Baton; class Block; class Breakpoint; class BreakpointID; class BreakpointIDList; -class BreakpointSite; -class BreakpointSiteList; class BreakpointList; class BreakpointLocation; class BreakpointLocationCollection; class BreakpointLocationList; class BreakpointOptions; class BreakpointResolver; +class BreakpointSite; +class BreakpointSiteList; class Broadcaster; class ClangASTContext; class ClangExpression; class ClangExpressionDeclMap; class ClangExpressionVariableList; class ClangExpressionVariableStore; -class Debugger; class CommandInterpreter; class CommandObject; class CommandReturnObject; class Communication; -class Condition; class CompileUnit; +class Condition; class Connection; class ConnectionFileDescriptor; class ConstString; @@ -57,6 +57,7 @@ class DataBuffer; class DataExtractor; class Debugger; +class Debugger; class Declaration; class Disassembler; class DynamicLoader; @@ -68,12 +69,12 @@ class FileSpec; class FileSpecList; class Flags; +class FuncUnwinders; class Function; class FunctionInfo; class InlineFunctionInfo; class InputReader; class InstanceSettings; -struct LineEntry; class LineTable; class Listener; class Log; @@ -123,19 +124,22 @@ class ThreadList; class ThreadPlan; class ThreadPlanBase; +class ThreadPlanRunToAddress; class ThreadPlanStepInstruction; class ThreadPlanStepOut; class ThreadPlanStepOverBreakpoint; -class ThreadPlanStepThrough; class ThreadPlanStepRange; -class ThreadPlanRunToAddress; +class ThreadPlanStepThrough; class ThreadSpec; class TimeValue; class Type; class TypeList; +class UUID; class Unwind; +class UnwindAssemblyProfiler; +class UnwindPlan; +class UnwindTable; class UserSettingsController; -class UUID; class VMRange; class Value; class ValueList; @@ -144,6 +148,7 @@ class Variable; class VariableList; class WatchpointLocation; +struct LineEntry; } // namespace lldb_private Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Fri Sep 10 02:49:16 2010 @@ -28,6 +28,8 @@ typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id, uint32_t type); typedef ThreadPlan * (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, void *baton); + typedef UnwindAssemblyProfiler* (*UnwindAssemblyProfilerCreateInstance) (const ArchSpec &arch); + typedef ArchDefaultUnwindPlan* (*ArchDefaultUnwindPlanCreateInstance) (const ArchSpec &arch); } // namespace lldb_private #endif // #if defined(__cplusplus) Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Fri Sep 10 02:49:16 2010 @@ -107,7 +107,6 @@ uint32_t byte_offset; // The byte offset in the register context data where this register's value is found lldb::Encoding encoding; // Encoding of the register bits lldb::Format format; // Default display format - uint32_t reg; // The native register number for this register uint32_t kinds[kNumRegisterKinds]; // Holds all of the various register numbers for all register kinds } RegisterInfo; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 10 02:49:16 2010 @@ -354,6 +354,15 @@ 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1E1236C5D400C660B5 /* Mutex.cpp */; }; 69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1F1236C5D400C660B5 /* Symbols.cpp */; }; 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E201236C5D400C660B5 /* TimeValue.cpp */; }; + 961FABBB1235DE1600F93A47 /* FuncUnwinders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */; }; + 961FABBC1235DE1600F93A47 /* UnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */; }; + 961FABBD1235DE1600F93A47 /* UnwindTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */; }; + 961FABE51235F15900F93A47 /* UnwindAssemblyProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */; }; + 961FABEA1235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */; }; + 961FABEB1235F26800F93A47 /* UnwindAssemblyProfiler-x86.h in Headers */ = {isa = PBXBuildFile; fileRef = 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */; }; + 961FAC19123605A200F93A47 /* ArchDefaultUnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */; }; + 961FAC1E12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */; }; + 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */ = {isa = PBXBuildFile; fileRef = 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -967,6 +976,15 @@ 69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = ""; }; 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = ""; }; 69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = ""; }; + 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FuncUnwinders.cpp; path = source/Symbol/FuncUnwinders.cpp; sourceTree = ""; }; + 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; }; + 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; }; + 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindAssemblyProfiler.cpp; path = source/Utility/UnwindAssemblyProfiler.cpp; sourceTree = ""; }; + 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "UnwindAssemblyProfiler-x86.cpp"; path = "Utility/UnwindAssemblyProfiler-x86.cpp"; sourceTree = ""; }; + 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UnwindAssemblyProfiler-x86.h"; path = "Utility/UnwindAssemblyProfiler-x86.h"; sourceTree = ""; }; + 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Utility/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; + 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchDefaultUnwindPlan-x86.cpp"; path = "Utility/ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; + 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchDefaultUnwindPlan-x86.h"; path = "Utility/ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; 9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSXLibunwindCallbacks.cpp; path = Utility/MacOSXLibunwindCallbacks.cpp; sourceTree = ""; }; 9654F79D1197DA1300F72B43 /* MacOSXLibunwindCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSXLibunwindCallbacks.h; path = Utility/MacOSXLibunwindCallbacks.h; sourceTree = ""; }; 9654F7A11197DA3F00F72B43 /* libunwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libunwind.h; sourceTree = ""; }; @@ -1520,6 +1538,8 @@ 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( + 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */, + 961FABE41235F15900F93A47 /* UnwindAssemblyProfiler.cpp */, 264723A511FA076E00DE380C /* CleanUp.h */, 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, @@ -1547,6 +1567,10 @@ 26B4666E11A2080F00CF6220 /* Utility */ = { isa = PBXGroup; children = ( + 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */, + 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */, + 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */, + 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */, 9654F79F1197DA3F00F72B43 /* libunwind */, 26B4667011A2091600CF6220 /* LibUnwindRegisterContext.h */, 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */, @@ -1690,6 +1714,9 @@ 26BC7C4B10F1B6C100F91463 /* Symbol */ = { isa = PBXGroup; children = ( + 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */, + 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */, + 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */, 26BC7C5510F1B6E900F91463 /* Block.h */, 26BC7F1310F1B8EC00F91463 /* Block.cpp */, 26BC7C5610F1B6E900F91463 /* ClangASTContext.h */, @@ -2235,6 +2262,8 @@ 4911934C1226383D00578B7F /* ASTStructExtractor.h in Headers */, 497C86C2122823F300B54702 /* ClangUtilityFunction.h in Headers */, 49CF9834122C718B007A0B96 /* IRDynamicChecks.h in Headers */, + 961FABEB1235F26800F93A47 /* UnwindAssemblyProfiler-x86.h in Headers */, + 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2685,6 +2714,13 @@ 491193521226386000578B7F /* ASTStructExtractor.cpp in Sources */, 497C86BE122823D800B54702 /* ClangUtilityFunction.cpp in Sources */, 49CF982A122C70BD007A0B96 /* IRDynamicChecks.cpp in Sources */, + 961FABBB1235DE1600F93A47 /* FuncUnwinders.cpp in Sources */, + 961FABBC1235DE1600F93A47 /* UnwindPlan.cpp in Sources */, + 961FABBD1235DE1600F93A47 /* UnwindTable.cpp in Sources */, + 961FABE51235F15900F93A47 /* UnwindAssemblyProfiler.cpp in Sources */, + 961FABEA1235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp in Sources */, + 961FAC19123605A200F93A47 /* ArchDefaultUnwindPlan.cpp in Sources */, + 961FAC1E12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp in Sources */, 69A01E211236C5D400C660B5 /* Condition.cpp in Sources */, 69A01E221236C5D400C660B5 /* Host.cpp in Sources */, 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */, Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Sep 10 02:49:16 2010 @@ -106,7 +106,7 @@ if (reg_info) { output_stream.Printf("%-12s = ", reg_info->name); - if (reg_context->ReadRegisterBytes(reg_info->reg, reg_data)) + if (reg_context->ReadRegisterBytes(reg_info->kinds[eRegisterKindLLDB], reg_data)) { reg_data.Dump(&output_stream, 0, reg_info->format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); } @@ -183,7 +183,7 @@ Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size)); if (error.Success()) { - if (reg_context->WriteRegisterValue(reg_info->reg, scalar)) + if (reg_context->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar)) { result.SetStatus (eReturnStatusSuccessFinishNoResult); return true; Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Fri Sep 10 02:49:16 2010 @@ -1131,3 +1131,244 @@ } +#pragma mark UnwindAssemblyProfiler + +struct UnwindAssemblyProfilerInstance +{ + UnwindAssemblyProfilerInstance() : + name(), + description(), + create_callback(NULL) + { + } + + std::string name; + std::string description; + UnwindAssemblyProfilerCreateInstance create_callback; +}; + +typedef std::vector UnwindAssemblyProfilerInstances; + +static bool +AccessUnwindAssemblyProfilerInstances (PluginAction action, UnwindAssemblyProfilerInstance &instance, uint32_t index) +{ + static UnwindAssemblyProfilerInstances g_plugin_instances; + + switch (action) + { + case ePluginRegisterInstance: + if (instance.create_callback) + { + g_plugin_instances.push_back (instance); + return true; + } + break; + + case ePluginUnregisterInstance: + if (instance.create_callback) + { + UnwindAssemblyProfilerInstances::iterator pos, end = g_plugin_instances.end(); + for (pos = g_plugin_instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == instance.create_callback) + { + g_plugin_instances.erase(pos); + return true; + } + } + } + break; + + case ePluginGetInstanceAtIndex: + if (index < g_plugin_instances.size()) + { + instance = g_plugin_instances[index]; + return true; + } + break; + + default: + break; + } + return false; +} + +bool +PluginManager::RegisterPlugin +( + const char *name, + const char *description, + UnwindAssemblyProfilerCreateInstance create_callback +) +{ + if (create_callback) + { + UnwindAssemblyProfilerInstance instance; + assert (name && name[0]); + instance.name = name; + if (description && description[0]) + instance.description = description; + instance.create_callback = create_callback; + return AccessUnwindAssemblyProfilerInstances (ePluginRegisterInstance, instance, 0); + } + return false; +} + +bool +PluginManager::UnregisterPlugin (UnwindAssemblyProfilerCreateInstance create_callback) +{ + if (create_callback) + { + UnwindAssemblyProfilerInstance instance; + instance.create_callback = create_callback; + return AccessUnwindAssemblyProfilerInstances (ePluginUnregisterInstance, instance, 0); + } + return false; +} + +UnwindAssemblyProfilerCreateInstance +PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx) +{ + UnwindAssemblyProfilerInstance instance; + if (AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx)) + return instance.create_callback; + return NULL; +} + +UnwindAssemblyProfilerCreateInstance +PluginManager::GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name) +{ + if (name && name[0]) + { + UnwindAssemblyProfilerInstance instance; + std::string ss_name(name); + for (uint32_t idx = 0; AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + { + if (instance.name == ss_name) + return instance.create_callback; + } + } + return NULL; +} + +#pragma mark ArchDefaultUnwindPlan + +struct ArchDefaultUnwindPlanInstance +{ + ArchDefaultUnwindPlanInstance() : + name(), + description(), + create_callback(NULL) + { + } + + std::string name; + std::string description; + ArchDefaultUnwindPlanCreateInstance create_callback; +}; + +typedef std::vector ArchDefaultUnwindPlanInstances; + +static bool +AccessArchDefaultUnwindPlanInstances (PluginAction action, ArchDefaultUnwindPlanInstance &instance, uint32_t index) +{ + static ArchDefaultUnwindPlanInstances g_plugin_instances; + + switch (action) + { + case ePluginRegisterInstance: + if (instance.create_callback) + { + g_plugin_instances.push_back (instance); + return true; + } + break; + + case ePluginUnregisterInstance: + if (instance.create_callback) + { + ArchDefaultUnwindPlanInstances::iterator pos, end = g_plugin_instances.end(); + for (pos = g_plugin_instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == instance.create_callback) + { + g_plugin_instances.erase(pos); + return true; + } + } + } + break; + + case ePluginGetInstanceAtIndex: + if (index < g_plugin_instances.size()) + { + instance = g_plugin_instances[index]; + return true; + } + break; + + default: + break; + } + return false; +} + +bool +PluginManager::RegisterPlugin +( + const char *name, + const char *description, + ArchDefaultUnwindPlanCreateInstance create_callback +) +{ + if (create_callback) + { + ArchDefaultUnwindPlanInstance instance; + assert (name && name[0]); + instance.name = name; + if (description && description[0]) + instance.description = description; + instance.create_callback = create_callback; + return AccessArchDefaultUnwindPlanInstances (ePluginRegisterInstance, instance, 0); + } + return false; +} + +bool +PluginManager::UnregisterPlugin (ArchDefaultUnwindPlanCreateInstance create_callback) +{ + if (create_callback) + { + ArchDefaultUnwindPlanInstance instance; + instance.create_callback = create_callback; + return AccessArchDefaultUnwindPlanInstances (ePluginUnregisterInstance, instance, 0); + } + return false; +} + +ArchDefaultUnwindPlanCreateInstance +PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx) +{ + ArchDefaultUnwindPlanInstance instance; + if (AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx)) + return instance.create_callback; + return NULL; +} + +ArchDefaultUnwindPlanCreateInstance +PluginManager::GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name) +{ + if (name && name[0]) + { + ArchDefaultUnwindPlanInstance instance; + std::string ss_name(name); + for (uint32_t idx = 0; AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + { + if (instance.name == ss_name) + return instance.create_callback; + } + } + return NULL; +} + + Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Fri Sep 10 02:49:16 2010 @@ -11,6 +11,7 @@ // C Includes #include +#include #include "llvm/Support/MachO.h" // C++ Includes Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Sep 10 02:49:16 2010 @@ -472,8 +472,8 @@ { size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); - unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->reg; - unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->reg; + unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; + unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; switch (bit_width) { @@ -512,7 +512,7 @@ } else if (ClangASTContext::IsPointerType (value_type)) { - unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->reg; + unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; value.GetScalar() = ptr; } Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri Sep 10 02:49:16 2010 @@ -63,7 +63,7 @@ if (!reg_ctx) return false; - uint32_t rdiID = reg_ctx->GetRegisterInfoByName("rdi", 0)->reg; + uint32_t rdiID = reg_ctx->GetRegisterInfoByName("rdi", 0)->kinds[eRegisterKindLLDB]; #define CHAIN_RBP #ifndef CHAIN_RBP @@ -226,12 +226,12 @@ uint32_t argument_register_ids[6]; - argument_register_ids[0] = reg_ctx->GetRegisterInfoByName("rdi", 0)->reg; - argument_register_ids[1] = reg_ctx->GetRegisterInfoByName("rsi", 0)->reg; - argument_register_ids[2] = reg_ctx->GetRegisterInfoByName("rdx", 0)->reg; - argument_register_ids[3] = reg_ctx->GetRegisterInfoByName("rcx", 0)->reg; - argument_register_ids[4] = reg_ctx->GetRegisterInfoByName("r8", 0)->reg; - argument_register_ids[5] = reg_ctx->GetRegisterInfoByName("r9", 0)->reg; + argument_register_ids[0] = reg_ctx->GetRegisterInfoByName("rdi", 0)->kinds[eRegisterKindLLDB]; + argument_register_ids[1] = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; + argument_register_ids[2] = reg_ctx->GetRegisterInfoByName("rdx", 0)->kinds[eRegisterKindLLDB]; + argument_register_ids[3] = reg_ctx->GetRegisterInfoByName("rcx", 0)->kinds[eRegisterKindLLDB]; + argument_register_ids[4] = reg_ctx->GetRegisterInfoByName("r8", 0)->kinds[eRegisterKindLLDB]; + argument_register_ids[5] = reg_ctx->GetRegisterInfoByName("r9", 0)->kinds[eRegisterKindLLDB]; unsigned int current_argument_register = 0; @@ -313,7 +313,7 @@ // Extract the register context so we can read arguments from registers size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); - unsigned rax_id = reg_ctx->GetRegisterInfoByName("rax", 0)->reg; + unsigned rax_id = reg_ctx->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; switch (bit_width) { @@ -349,7 +349,7 @@ } else if (ClangASTContext::IsPointerType (value_type)) { - unsigned rax_id = reg_ctx->GetRegisterInfoByName("rax", 0)->reg; + unsigned rax_id = reg_ctx->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); } else Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Fri Sep 10 02:49:16 2010 @@ -305,23 +305,23 @@ #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ { #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, \ - eFormatHex, gpr_##reg, { kind1, kind2, kind3, kind4 } } + eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg } } #define DEFINE_FPR(reg, kind1, kind2, kind3, kind4) \ { #reg, NULL, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, \ - eFormatHex, fpu_##reg, { kind1, kind2, kind3, kind4 } } + eFormatHex, { kind1, kind2, kind3, kind4, fpu_##reg } } #define DEFINE_FP(reg, i) \ { #reg#i, NULL, FP_SIZE, FPR_OFFSET(reg[i]), eEncodingVector, \ - eFormatVectorOfUInt8, fpu_##reg##i, \ + eFormatVectorOfUInt8, \ { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, \ - LLDB_INVALID_REGNUM, gdb_fpu_##reg##i } } + LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i } } #define DEFINE_XMM(reg, i) \ { #reg#i, NULL, XMM_SIZE, FPR_OFFSET(reg[i]), eEncodingVector, \ - eFormatVectorOfUInt8, fpu_##reg##i, \ + eFormatVectorOfUInt8, \ { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, \ - LLDB_INVALID_REGNUM, gdb_fpu_##reg##i } } + LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i } } static RegisterInfo g_register_infos[k_num_registers] = @@ -642,6 +642,10 @@ return LLDB_INVALID_REGNUM; } } + else if (kind == eRegisterKindLLDB) + { + return reg; + } return LLDB_INVALID_REGNUM; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp Fri Sep 10 02:49:16 2010 @@ -86,11 +86,11 @@ const RegisterInfo * reg_info; reg_info = reg_ctx->GetRegisterInfoByName ("bvr0"); if (reg_info) - m_bvr0_reg = reg_info->reg; + m_bvr0_reg = reg_info->kinds[eRegisterKindLLDB]; reg_info = reg_ctx->GetRegisterInfoByName ("bcr0"); if (reg_info) - m_bcr0_reg = reg_info->reg; + m_bcr0_reg = reg_info->kinds[eRegisterKindLLDB]; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp Fri Sep 10 02:49:16 2010 @@ -182,69 +182,69 @@ #define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextMach_arm::GPR) + sizeof (RegisterContextMach_arm::FPU)) #define DBG_OFFSET(reg) (offsetof (RegisterContextMach_arm::DBG, reg) + sizeof (RegisterContextMach_arm::GPR) + sizeof (RegisterContextMach_arm::FPU) + sizeof (RegisterContextMach_arm::EXC)) -#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextMach_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, dbg_##reg##i, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM } +#define DEFINE_DBG(reg, i) #reg, NULL, sizeof(((RegisterContextMach_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, dbg_##reg##i } #define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_arm::GPR) + sizeof (RegisterContextMach_arm::FPU) + sizeof (RegisterContextMach_arm::EXC)) // General purpose registers static lldb::RegisterInfo g_register_infos[] = { -// NAME ALT SZ OFFSET ENCODING FORMAT NATIVE COMPILER DWARF GENERIC -// ====== ======= == ============= ============= ============ ========== =============== =============== ========= -{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, gpr_r0, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM }}, -{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, gpr_r1, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM }}, -{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, gpr_r2, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM }}, -{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, gpr_r3, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM }}, -{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, gpr_r4, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM }}, -{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, gpr_r5, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM }}, -{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, gpr_r6, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM }}, -{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, gpr_r7, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP }}, -{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, gpr_r8, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM }}, -{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, gpr_r9, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM }}, -{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, gpr_r10, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM }}, -{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, gpr_r11, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM }}, -{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, gpr_r12, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM }}, -{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, gpr_sp, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP }}, -{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, gpr_lr, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA }}, -{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, gpr_pc, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC }}, -{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, gpr_cpsr, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS }}, - -{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, fpu_s0, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM }}, -{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, fpu_s1, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM }}, -{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, fpu_s2, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM }}, -{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, fpu_s3, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM }}, -{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, fpu_s4, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM }}, -{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, fpu_s5, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM }}, -{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, fpu_s6, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM }}, -{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, fpu_s7, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM }}, -{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, fpu_s8, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM }}, -{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, fpu_s9, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM }}, -{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, fpu_s10, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM }}, -{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, fpu_s11, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM }}, -{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, fpu_s12, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM }}, -{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, fpu_s13, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM }}, -{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, fpu_s14, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM }}, -{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, fpu_s15, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM }}, -{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, fpu_s16, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM }}, -{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, fpu_s17, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM }}, -{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, fpu_s18, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM }}, -{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, fpu_s19, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM }}, -{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, fpu_s20, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM }}, -{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, fpu_s21, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM }}, -{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, fpu_s22, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM }}, -{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, fpu_s23, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM }}, -{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, fpu_s24, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM }}, -{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, fpu_s25, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM }}, -{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, fpu_s26, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM }}, -{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, fpu_s27, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM }}, -{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, fpu_s28, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM }}, -{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, fpu_s29, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM }}, -{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, fpu_s30, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM }}, -{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, fpu_s31, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM }}, -{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, fpu_fpscr, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, - -{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, exc_exception,{ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, -{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, exc_fsr, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, -{ "far", NULL, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, exc_far, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, +// NAME ALT SZ OFFSET ENCODING FORMAT COMPILER DWARF GENERIC LLDB NATIVE +// ====== ======= == ============= ============= ============ =============== =============== ========= ========== +{ "r0", NULL, 4, GPR_OFFSET(0), eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, gpr_r0 }}, +{ "r1", NULL, 4, GPR_OFFSET(1), eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, gpr_r1 }}, +{ "r2", NULL, 4, GPR_OFFSET(2), eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, gpr_r2 }}, +{ "r3", NULL, 4, GPR_OFFSET(3), eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, gpr_r3 }}, +{ "r4", NULL, 4, GPR_OFFSET(4), eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gpr_r4 }}, +{ "r5", NULL, 4, GPR_OFFSET(5), eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gpr_r5 }}, +{ "r6", NULL, 4, GPR_OFFSET(6), eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gpr_r6 }}, +{ "r7", NULL, 4, GPR_OFFSET(7), eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gpr_r7 }}, +{ "r8", NULL, 4, GPR_OFFSET(8), eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gpr_r8 }}, +{ "r9", NULL, 4, GPR_OFFSET(9), eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gpr_r9 }}, +{ "r10", NULL, 4, GPR_OFFSET(10), eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gpr_r10 }}, +{ "r11", NULL, 4, GPR_OFFSET(11), eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gpr_r11 }}, +{ "r12", NULL, 4, GPR_OFFSET(12), eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gpr_r12 }}, +{ "sp", "r13", 4, GPR_OFFSET(13), eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gpr_sp }}, +{ "lr", "r14", 4, GPR_OFFSET(14), eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gpr_lr }}, +{ "pc", "r15", 4, GPR_OFFSET(15), eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gpr_pc }}, +{ "cpsr", "psr", 4, GPR_OFFSET(16), eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gpr_cpsr }}, + +{ "s0", NULL, 4, FPU_OFFSET(0), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, fpu_s0 }}, +{ "s1", NULL, 4, FPU_OFFSET(1), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, fpu_s1 }}, +{ "s2", NULL, 4, FPU_OFFSET(2), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, fpu_s2 }}, +{ "s3", NULL, 4, FPU_OFFSET(3), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, fpu_s3 }}, +{ "s4", NULL, 4, FPU_OFFSET(4), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, fpu_s4 }}, +{ "s5", NULL, 4, FPU_OFFSET(5), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, fpu_s5 }}, +{ "s6", NULL, 4, FPU_OFFSET(6), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, fpu_s6 }}, +{ "s7", NULL, 4, FPU_OFFSET(7), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, fpu_s7 }}, +{ "s8", NULL, 4, FPU_OFFSET(8), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, fpu_s8 }}, +{ "s9", NULL, 4, FPU_OFFSET(9), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, fpu_s9 }}, +{ "s10", NULL, 4, FPU_OFFSET(10), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, fpu_s10 }}, +{ "s11", NULL, 4, FPU_OFFSET(11), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, fpu_s11 }}, +{ "s12", NULL, 4, FPU_OFFSET(12), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, fpu_s12 }}, +{ "s13", NULL, 4, FPU_OFFSET(13), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, fpu_s13 }}, +{ "s14", NULL, 4, FPU_OFFSET(14), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, fpu_s14 }}, +{ "s15", NULL, 4, FPU_OFFSET(15), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, fpu_s15 }}, +{ "s16", NULL, 4, FPU_OFFSET(16), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, fpu_s16 }}, +{ "s17", NULL, 4, FPU_OFFSET(17), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, fpu_s17 }}, +{ "s18", NULL, 4, FPU_OFFSET(18), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, fpu_s18 }}, +{ "s19", NULL, 4, FPU_OFFSET(19), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, fpu_s19 }}, +{ "s20", NULL, 4, FPU_OFFSET(20), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, fpu_s20 }}, +{ "s21", NULL, 4, FPU_OFFSET(21), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, fpu_s21 }}, +{ "s22", NULL, 4, FPU_OFFSET(22), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, fpu_s22 }}, +{ "s23", NULL, 4, FPU_OFFSET(23), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, fpu_s23 }}, +{ "s24", NULL, 4, FPU_OFFSET(24), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, fpu_s24 }}, +{ "s25", NULL, 4, FPU_OFFSET(25), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, fpu_s25 }}, +{ "s26", NULL, 4, FPU_OFFSET(26), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, fpu_s26 }}, +{ "s27", NULL, 4, FPU_OFFSET(27), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, fpu_s27 }}, +{ "s28", NULL, 4, FPU_OFFSET(28), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, fpu_s28 }}, +{ "s29", NULL, 4, FPU_OFFSET(29), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, fpu_s29 }}, +{ "s30", NULL, 4, FPU_OFFSET(30), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, fpu_s30 }}, +{ "s31", NULL, 4, FPU_OFFSET(31), eEncodingIEEE754,eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, fpu_s31 }}, +{ "fpscr", NULL, 4, FPU_OFFSET(32), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpu_fpscr }}, + +{ "exception",NULL, 4, EXC_OFFSET(0), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_exception }}, +{ "fsr", NULL, 4, EXC_OFFSET(1), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_fsr }}, +{ "far", NULL, 4, EXC_OFFSET(2), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, exc_far }}, { DEFINE_DBG (bvr, 0) }, { DEFINE_DBG (bvr, 0) }, @@ -1138,6 +1138,10 @@ case gcc_cpsr: return gpr_cpsr; } } + else if (kind == eRegisterKindLLDB) + { + return reg; + } return LLDB_INVALID_REGNUM; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp Fri Sep 10 02:49:16 2010 @@ -212,44 +212,44 @@ // register offset, encoding, format and native register. This ensures that // the register state structures are defined correctly and have the correct // sizes and offsets. -#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextMach_i386::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex, gpr_##reg -#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex, fpu_##reg -#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, fpu_##reg##i, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, gdb_##reg##i } +#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextMach_i386::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex +#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex +#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_i386::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, dwarf_##reg##i, LLDB_INVALID_REGNUM, gdb_##reg##i, fpu_##reg##i } -#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex, exc_##reg +#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_i386::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex #define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_i386::GPR) + sizeof (RegisterContextMach_i386::FPU) + sizeof (RegisterContextMach_i386::EXC)) static RegisterInfo g_register_infos[] = { -// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM -// =============================== ======================= =================== ========================== ========================== - { DEFINE_GPR(eax , NULL) , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax }}, - { DEFINE_GPR(ebx , NULL) , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx }}, - { DEFINE_GPR(ecx , NULL) , { gcc_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , gdb_ecx }}, - { DEFINE_GPR(edx , NULL) , { gcc_edx , dwarf_edx , LLDB_INVALID_REGNUM , gdb_edx }}, - { DEFINE_GPR(edi , NULL) , { gcc_edi , dwarf_edi , LLDB_INVALID_REGNUM , gdb_edi }}, - { DEFINE_GPR(esi , NULL) , { gcc_esi , dwarf_esi , LLDB_INVALID_REGNUM , gdb_esi }}, - { DEFINE_GPR(ebp , "fp") , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp }}, - { DEFINE_GPR(esp , "sp") , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp }}, - { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss }}, - { DEFINE_GPR(eflags , "flags") , { gcc_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags }}, - { DEFINE_GPR(eip , "pc") , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip }}, - { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs }}, - { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds }}, - { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es }}, - { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs }}, - { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs }}, - - { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fcw }}, - { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fsw }}, - { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftw }}, - { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop }}, - { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ip }}, - { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs }}, - { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_dp }}, - { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds }}, - { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr }}, - { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, +// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM LLDB REG KIND NUM +// =============================== ======================= =================== ========================== ========================== ================= + { DEFINE_GPR(eax , NULL) , { gcc_eax , dwarf_eax , LLDB_INVALID_REGNUM , gdb_eax , gpr_eax }}, + { DEFINE_GPR(ebx , NULL) , { gcc_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , gdb_ebx , gpr_ebx }}, + { DEFINE_GPR(ecx , NULL) , { gcc_ecx , dwarf_ecx , LLDB_INVALID_REGNUM , gdb_ecx , gpr_ecx }}, + { DEFINE_GPR(edx , NULL) , { gcc_edx , dwarf_edx , LLDB_INVALID_REGNUM , gdb_edx , gpr_edx }}, + { DEFINE_GPR(edi , NULL) , { gcc_edi , dwarf_edi , LLDB_INVALID_REGNUM , gdb_edi , gpr_edi }}, + { DEFINE_GPR(esi , NULL) , { gcc_esi , dwarf_esi , LLDB_INVALID_REGNUM , gdb_esi , gpr_esi }}, + { DEFINE_GPR(ebp , "fp") , { gcc_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , gdb_ebp , gpr_ebp }}, + { DEFINE_GPR(esp , "sp") , { gcc_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , gdb_esp , gpr_esp }}, + { DEFINE_GPR(ss , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ss , gpr_ss }}, + { DEFINE_GPR(eflags , "flags") , { gcc_eflags , dwarf_eflags , LLDB_REGNUM_GENERIC_FLAGS , gdb_eflags , gpr_eflags }}, + { DEFINE_GPR(eip , "pc") , { gcc_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , gdb_eip , gpr_eip }}, + { DEFINE_GPR(cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , gpr_cs }}, + { DEFINE_GPR(ds , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , gpr_ds }}, + { DEFINE_GPR(es , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_es , gpr_es }}, + { DEFINE_GPR(fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fs , gpr_fs }}, + { DEFINE_GPR(gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gs , gpr_gs }}, + + { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fcw , fpu_fcw }}, + { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fsw , fpu_fsw }}, + { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ftw , fpu_ftw }}, + { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fop , fpu_fop }}, + { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ip , fpu_ip }}, + { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_cs , fpu_cs }}, + { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_dp , fpu_dp }}, + { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_ds , fpu_ds }}, + { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_mxcsr , fpu_mxcsr }}, + { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , fpu_mxcsrmask }}, { DEFINE_FPU_VECT(stmm,0) }, { DEFINE_FPU_VECT(stmm,1) }, { DEFINE_FPU_VECT(stmm,2) }, @@ -267,9 +267,9 @@ { DEFINE_FPU_VECT(xmm,6) }, { DEFINE_FPU_VECT(xmm,7) }, - { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, - { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, - { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }} + { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_trapno }}, + { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_err }}, + { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_faultvaddr }} }; static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); @@ -1167,6 +1167,10 @@ break; } } + else if (kind == eRegisterKindLLDB) + { + return reg; + } return LLDB_INVALID_REGNUM; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp Fri Sep 10 02:49:16 2010 @@ -233,50 +233,50 @@ // register offset, encoding, format and native register. This ensures that // the register state structures are defined correctly and have the correct // sizes and offsets. -#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextMach_x86_64::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex, gpr_##reg -#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex, fpu_##reg -#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, fpu_##reg##i, { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, gdb_fpu_##reg##i } -#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex, exc_##reg +#define DEFINE_GPR(reg, alt) #reg, alt, sizeof(((RegisterContextMach_x86_64::GPR *)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex +#define DEFINE_FPU_UINT(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg), FPU_OFFSET(reg), eEncodingUint, eFormatHex +#define DEFINE_FPU_VECT(reg, i) #reg#i, NULL, sizeof(((RegisterContextMach_x86_64::FPU *)NULL)->reg[i].bytes), FPU_OFFSET(reg[i]), eEncodingVector, eFormatVectorOfUInt8, { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i } +#define DEFINE_EXC(reg) #reg, NULL, sizeof(((RegisterContextMach_x86_64::EXC *)NULL)->reg), EXC_OFFSET(reg), eEncodingUint, eFormatHex #define REG_CONTEXT_SIZE (sizeof (RegisterContextMach_x86_64::GPR) + sizeof (RegisterContextMach_x86_64::FPU) + sizeof (RegisterContextMach_x86_64::EXC)) // General purpose registers for 64 bit static RegisterInfo g_register_infos[] = { -// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM -// =============================== ======================= =================== ========================== ========================== - { DEFINE_GPR (rax , NULL) , { gcc_dwarf_gpr_rax , gcc_dwarf_gpr_rax , LLDB_INVALID_REGNUM , gdb_gpr_rax }}, - { DEFINE_GPR (rbx , NULL) , { gcc_dwarf_gpr_rbx , gcc_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , gdb_gpr_rbx }}, - { DEFINE_GPR (rcx , NULL) , { gcc_dwarf_gpr_rcx , gcc_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , gdb_gpr_rcx }}, - { DEFINE_GPR (rdx , NULL) , { gcc_dwarf_gpr_rdx , gcc_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , gdb_gpr_rdx }}, - { DEFINE_GPR (rdi , NULL) , { gcc_dwarf_gpr_rdi , gcc_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , gdb_gpr_rdi }}, - { DEFINE_GPR (rsi , NULL) , { gcc_dwarf_gpr_rsi , gcc_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , gdb_gpr_rsi }}, - { DEFINE_GPR (rbp , "fp") , { gcc_dwarf_gpr_rbp , gcc_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , gdb_gpr_rbp }}, - { DEFINE_GPR (rsp , "sp") , { gcc_dwarf_gpr_rsp , gcc_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , gdb_gpr_rsp }}, - { DEFINE_GPR (r8 , NULL) , { gcc_dwarf_gpr_r8 , gcc_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , gdb_gpr_r8 }}, - { DEFINE_GPR (r9 , NULL) , { gcc_dwarf_gpr_r9 , gcc_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , gdb_gpr_r9 }}, - { DEFINE_GPR (r10 , NULL) , { gcc_dwarf_gpr_r10 , gcc_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , gdb_gpr_r10 }}, - { DEFINE_GPR (r11 , NULL) , { gcc_dwarf_gpr_r11 , gcc_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , gdb_gpr_r11 }}, - { DEFINE_GPR (r12 , NULL) , { gcc_dwarf_gpr_r12 , gcc_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , gdb_gpr_r12 }}, - { DEFINE_GPR (r13 , NULL) , { gcc_dwarf_gpr_r13 , gcc_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , gdb_gpr_r13 }}, - { DEFINE_GPR (r14 , NULL) , { gcc_dwarf_gpr_r14 , gcc_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , gdb_gpr_r14 }}, - { DEFINE_GPR (r15 , NULL) , { gcc_dwarf_gpr_r15 , gcc_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , gdb_gpr_r15 }}, - { DEFINE_GPR (rip , "pc") , { gcc_dwarf_gpr_rip , gcc_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , gdb_gpr_rip }}, - { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_gpr_rflags}}, - { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_cs }}, - { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_fs }}, - { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_gs }}, - - { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fcw }}, - { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fsw }}, - { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ftw }}, - { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fop }}, - { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ip }}, - { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_cs }}, - { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_dp }}, - { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ds }}, - { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_mxcsr }}, - { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, +// Macro auto defines most stuff GCC REG KIND NUM DWARF REG KIND NUM GENERIC REG KIND NUM GDB REG KIND NUM LLDB REG KIND NUM +// =============================== ======================= =================== ========================== ========================== ===================== + { DEFINE_GPR (rax , NULL) , { gcc_dwarf_gpr_rax , gcc_dwarf_gpr_rax , LLDB_INVALID_REGNUM , gdb_gpr_rax , gpr_rax }}, + { DEFINE_GPR (rbx , NULL) , { gcc_dwarf_gpr_rbx , gcc_dwarf_gpr_rbx , LLDB_INVALID_REGNUM , gdb_gpr_rbx , gpr_rbx }}, + { DEFINE_GPR (rcx , NULL) , { gcc_dwarf_gpr_rcx , gcc_dwarf_gpr_rcx , LLDB_INVALID_REGNUM , gdb_gpr_rcx , gpr_rcx }}, + { DEFINE_GPR (rdx , NULL) , { gcc_dwarf_gpr_rdx , gcc_dwarf_gpr_rdx , LLDB_INVALID_REGNUM , gdb_gpr_rdx , gpr_rdx }}, + { DEFINE_GPR (rdi , NULL) , { gcc_dwarf_gpr_rdi , gcc_dwarf_gpr_rdi , LLDB_INVALID_REGNUM , gdb_gpr_rdi , gpr_rdi }}, + { DEFINE_GPR (rsi , NULL) , { gcc_dwarf_gpr_rsi , gcc_dwarf_gpr_rsi , LLDB_INVALID_REGNUM , gdb_gpr_rsi , gpr_rsi }}, + { DEFINE_GPR (rbp , "fp") , { gcc_dwarf_gpr_rbp , gcc_dwarf_gpr_rbp , LLDB_REGNUM_GENERIC_FP , gdb_gpr_rbp , gpr_rbp }}, + { DEFINE_GPR (rsp , "sp") , { gcc_dwarf_gpr_rsp , gcc_dwarf_gpr_rsp , LLDB_REGNUM_GENERIC_SP , gdb_gpr_rsp , gpr_rsp }}, + { DEFINE_GPR (r8 , NULL) , { gcc_dwarf_gpr_r8 , gcc_dwarf_gpr_r8 , LLDB_INVALID_REGNUM , gdb_gpr_r8 , gpr_r8 }}, + { DEFINE_GPR (r9 , NULL) , { gcc_dwarf_gpr_r9 , gcc_dwarf_gpr_r9 , LLDB_INVALID_REGNUM , gdb_gpr_r9 , gpr_r9 }}, + { DEFINE_GPR (r10 , NULL) , { gcc_dwarf_gpr_r10 , gcc_dwarf_gpr_r10 , LLDB_INVALID_REGNUM , gdb_gpr_r10 , gpr_r10 }}, + { DEFINE_GPR (r11 , NULL) , { gcc_dwarf_gpr_r11 , gcc_dwarf_gpr_r11 , LLDB_INVALID_REGNUM , gdb_gpr_r11 , gpr_r11 }}, + { DEFINE_GPR (r12 , NULL) , { gcc_dwarf_gpr_r12 , gcc_dwarf_gpr_r12 , LLDB_INVALID_REGNUM , gdb_gpr_r12 , gpr_r12 }}, + { DEFINE_GPR (r13 , NULL) , { gcc_dwarf_gpr_r13 , gcc_dwarf_gpr_r13 , LLDB_INVALID_REGNUM , gdb_gpr_r13 , gpr_r13 }}, + { DEFINE_GPR (r14 , NULL) , { gcc_dwarf_gpr_r14 , gcc_dwarf_gpr_r14 , LLDB_INVALID_REGNUM , gdb_gpr_r14 , gpr_r14 }}, + { DEFINE_GPR (r15 , NULL) , { gcc_dwarf_gpr_r15 , gcc_dwarf_gpr_r15 , LLDB_INVALID_REGNUM , gdb_gpr_r15 , gpr_r15 }}, + { DEFINE_GPR (rip , "pc") , { gcc_dwarf_gpr_rip , gcc_dwarf_gpr_rip , LLDB_REGNUM_GENERIC_PC , gdb_gpr_rip , gpr_rip }}, + { DEFINE_GPR (rflags, "flags") , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , gdb_gpr_rflags , gpr_rflags }}, + { DEFINE_GPR (cs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_cs , gpr_cs }}, + { DEFINE_GPR (fs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_fs , gpr_fs }}, + { DEFINE_GPR (gs , NULL) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_gpr_gs , gpr_gs }}, + + { DEFINE_FPU_UINT(fcw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fcw , fpu_fcw }}, + { DEFINE_FPU_UINT(fsw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fsw , fpu_fsw }}, + { DEFINE_FPU_UINT(ftw) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ftw , fpu_ftw }}, + { DEFINE_FPU_UINT(fop) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_fop , fpu_fop }}, + { DEFINE_FPU_UINT(ip) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ip , fpu_ip }}, + { DEFINE_FPU_UINT(cs) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_cs , fpu_cs }}, + { DEFINE_FPU_UINT(dp) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_dp , fpu_dp }}, + { DEFINE_FPU_UINT(ds) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_ds , fpu_ds }}, + { DEFINE_FPU_UINT(mxcsr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , gdb_fpu_mxcsr , fpu_mxcsr }}, + { DEFINE_FPU_UINT(mxcsrmask) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , fpu_mxcsrmask }}, { DEFINE_FPU_VECT(stmm,0) }, { DEFINE_FPU_VECT(stmm,1) }, { DEFINE_FPU_VECT(stmm,2) }, @@ -302,9 +302,9 @@ { DEFINE_FPU_VECT(xmm,14) }, { DEFINE_FPU_VECT(xmm,15) }, - { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, - { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }}, - { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM }} + { DEFINE_EXC(trapno) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_trapno }}, + { DEFINE_EXC(err) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_err }}, + { DEFINE_EXC(faultvaddr) , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , exc_faultvaddr }} }; static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); @@ -1297,6 +1297,10 @@ break; } } + else if (kind == eRegisterKindLLDB) + { + return reg; + } return LLDB_INVALID_REGNUM; } Added: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,155 @@ +//===-- ArchDefaultUnwindPlan-x86.cpp --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ArchDefaultUnwindPlan-x86.h" + +#include "lldb/lldb-private.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/lldb-enumerations.h" + +using namespace lldb; +using namespace lldb_private; + +lldb_private::UnwindPlan* +ArchDefaultUnwindPlan_x86::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) +{ + if (m_cpu == CPU_TYPE_X86_64) + { + return &m_64bit_default; + } + if (m_cpu == CPU_TYPE_I386) + { + return &m_32bit_default; + } + return NULL; +} + +lldb_private::ArchDefaultUnwindPlan * +ArchDefaultUnwindPlan_x86::CreateInstance (const lldb_private::ArchSpec &arch) +{ + uint32_t cpu = arch.GetCPUType (); + if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + return NULL; + + return new ArchDefaultUnwindPlan_x86 (cpu); +} + +ArchDefaultUnwindPlan_x86::ArchDefaultUnwindPlan_x86(int cpu) : + lldb_private::ArchDefaultUnwindPlan(), + m_cpu(cpu), + m_32bit_default(), + m_64bit_default() +{ + UnwindPlan::Row row; + UnwindPlan::Row::RegisterLocation regloc; + + m_32bit_default.SetRegisterKind (eRegisterKindGeneric); + row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); + row.SetCFAOffset (2 * 4); + row.SetOffset (0); + + regloc.SetAtCFAPlusOffset (2 * -4); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); + regloc.SetAtCFAPlusOffset (1 * -4); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); + regloc.SetIsCFAPlusOffset (0); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); + + m_32bit_default.AppendRow (row); + + row.Clear(); + + m_64bit_default.SetRegisterKind (eRegisterKindGeneric); + row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); + row.SetCFAOffset (2 * 8); + row.SetOffset (0); + + regloc.SetAtCFAPlusOffset (2 * -8); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); + regloc.SetAtCFAPlusOffset (1 * -8); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); + regloc.SetIsCFAPlusOffset (0); + row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); + + m_64bit_default.AppendRow (row); +} + + + + +//------------------------------------------------------------------ +// PluginInterface protocol in UnwindAssemblyParser_x86 +//------------------------------------------------------------------ + +const char * +ArchDefaultUnwindPlan_x86::GetPluginName() +{ + return "ArchDefaultUnwindPlan_x86"; +} + +const char * +ArchDefaultUnwindPlan_x86::GetShortPluginName() +{ + return "archdefaultunwindplan.x86"; +} + + +uint32_t +ArchDefaultUnwindPlan_x86::GetPluginVersion() +{ + return 1; +} + +void +ArchDefaultUnwindPlan_x86::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +ArchDefaultUnwindPlan_x86::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +ArchDefaultUnwindPlan_x86::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +void +ArchDefaultUnwindPlan_x86::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +ArchDefaultUnwindPlan_x86::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +ArchDefaultUnwindPlan_x86::GetPluginNameStatic() +{ + return "ArchDefaultUnwindPlan_x86"; +} + +const char * +ArchDefaultUnwindPlan_x86::GetPluginDescriptionStatic() +{ + return "i386 and x86_64 architecture default unwind plan assembly plugin."; +} Added: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,76 @@ +//===-- ArchDefaultUnwindPlan-x86.h ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ArchDefaultUnwindPlan_x86_h_ +#define liblldb_ArchDefaultUnwindPlan_x86_h_ + +#include "lldb/lldb-private.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Target/Thread.h" +#include "lldb/Symbol/UnwindPlan.h" + +namespace lldb_private { + +class ArchDefaultUnwindPlan_x86 : public lldb_private::ArchDefaultUnwindPlan +{ +public: + + ~ArchDefaultUnwindPlan_x86 () { } + + virtual lldb_private::UnwindPlan* + GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); + + static lldb_private::ArchDefaultUnwindPlan * + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + +private: + ArchDefaultUnwindPlan_x86(int cpu); // Call CreateInstance instead. + + int m_cpu; + lldb_private::UnwindPlan m_32bit_default; + lldb_private::UnwindPlan m_64bit_default; +}; + + +} // namespace lldb_private + +#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Added: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,803 @@ +//===-- UnwindAssemblyProfiler-x86.cpp --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "UnwindAssemblyProfiler-x86.h" + +#include "lldb/lldb-private.h" +#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Core/Address.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/Target.h" +#include "lldb/Symbol/UnwindPlan.h" + +#include "lldb/lldb-enumerations.h" +#include "llvm-c/EnhancedDisassembly.h" + +#include "UnwindAssemblyProfiler-x86.h" + + +using namespace lldb; +using namespace lldb_private; + +enum CPU { + k_i386, + k_x86_64 +}; + +enum i386_register_numbers { + k_machine_eax = 0, + k_machine_ecx = 1, + k_machine_edx = 2, + k_machine_ebx = 3, + k_machine_esp = 4, + k_machine_ebp = 5, + k_machine_esi = 6, + k_machine_edi = 7, + k_machine_eip = 8 +}; + +enum x86_64_register_numbers { + k_machine_rax = 0, + k_machine_rcx = 1, + k_machine_rdx = 2, + k_machine_rbx = 3, + k_machine_rsp = 4, + k_machine_rbp = 5, + k_machine_rsi = 6, + k_machine_rdi = 7, + k_machine_r8 = 8, + k_machine_r9 = 9, + k_machine_r10 = 10, + k_machine_r11 = 11, + k_machine_r12 = 12, + k_machine_r13 = 13, + k_machine_r14 = 14, + k_machine_r15 = 15, + k_machine_rip = 16 +}; + +struct regmap_ent { + const char *name; + int machine_regno; + int lldb_regno; +}; + +static struct regmap_ent i386_register_map[] = { + {"eax", k_machine_eax, -1}, + {"ecx", k_machine_ecx, -1}, + {"edx", k_machine_edx, -1}, + {"ebx", k_machine_ebx, -1}, + {"esp", k_machine_esp, -1}, + {"ebp", k_machine_ebp, -1}, + {"esi", k_machine_esi, -1}, + {"edi", k_machine_edi, -1}, + {"eip", k_machine_eip, -1} +}; + +const int size_of_i386_register_map = sizeof (i386_register_map) / sizeof (struct regmap_ent); + +static int i386_register_map_initialized = 0; + +static struct regmap_ent x86_64_register_map[] = { + {"rax", k_machine_rax, -1}, + {"rcx", k_machine_rcx, -1}, + {"rdx", k_machine_rdx, -1}, + {"rbx", k_machine_rbx, -1}, + {"rsp", k_machine_rsp, -1}, + {"rbp", k_machine_rbp, -1}, + {"rsi", k_machine_rsi, -1}, + {"rdi", k_machine_rdi, -1}, + {"r8", k_machine_r8, -1}, + {"r9", k_machine_r9, -1}, + {"r10", k_machine_r10, -1}, + {"r11", k_machine_r11, -1}, + {"r12", k_machine_r12, -1}, + {"r13", k_machine_r13, -1}, + {"r14", k_machine_r14, -1}, + {"r15", k_machine_r15, -1}, + {"rip", k_machine_rip, -1} +}; + +const int size_of_x86_64_register_map = sizeof (x86_64_register_map) / sizeof (struct regmap_ent); + +static int x86_64_register_map_initialized = 0; + +//----------------------------------------------------------------------------------------------- +// AssemblyParse_x86 local-file class definition & implementation functions +//----------------------------------------------------------------------------------------------- + +class AssemblyParse_x86 { +public: + + AssemblyParse_x86 (Target &target, Thread *thread, int cpu, AddressRange func); + + bool get_non_call_site_unwind_plan (UnwindPlan &unwind_plan); + + bool get_fast_unwind_plan (UnwindPlan &unwind_plan); + + bool find_first_non_prologue_insn (Address &address); + +private: + enum { kMaxInstructionByteSize = 32 }; + + bool nonvolatile_reg_p (int machine_regno); + bool push_rbp_pattern_p (); + bool push_0_pattern_p (); + bool mov_rsp_rbp_pattern_p (); + bool sub_rsp_pattern_p (int& amount); + bool push_reg_p (int& regno); + bool mov_reg_to_local_stack_frame_p (int& regno, int& fp_offset); + bool ret_pattern_p (); + uint32_t extract_4 (uint8_t *b); + bool machine_regno_to_lldb_regno (int machine_regno, uint32_t& lldb_regno); + bool instruction_length (Address addr, int &length); + + Target &m_target; + Thread* m_thread; + + AddressRange m_func_bounds; + + Address m_cur_insn; + uint8_t m_cur_insn_bytes[kMaxInstructionByteSize]; + + int m_machine_ip_regnum; + int m_machine_sp_regnum; + int m_machine_fp_regnum; + + int m_lldb_ip_regnum; + int m_lldb_sp_regnum; + int m_lldb_fp_regnum; + + int m_wordsize; + int m_cpu; +}; + +AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : + m_target (target), m_thread (thread), m_cpu(cpu), m_func_bounds(func) +{ + int *initialized_flag = NULL; + m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; + if (cpu == k_i386) + { + m_machine_ip_regnum = k_machine_eip; + m_machine_sp_regnum = k_machine_esp; + m_machine_fp_regnum = k_machine_ebp; + m_wordsize = 4; + initialized_flag = &i386_register_map_initialized; + } + else + { + m_machine_ip_regnum = k_machine_rip; + m_machine_sp_regnum = k_machine_rsp; + m_machine_fp_regnum = k_machine_rbp; + m_wordsize = 8; + initialized_flag = &x86_64_register_map_initialized; + } + + // we only look at prologue - it will be complete earlier than 512 bytes into func + if (m_func_bounds.GetByteSize() == 0) + m_func_bounds.SetByteSize(512); + + if (m_thread && *initialized_flag == 0) + { + RegisterContext *rctx = m_thread->GetRegisterContext(); + if (rctx) + { + struct regmap_ent *ent; + int count, i; + if (cpu == k_i386) + { + ent = i386_register_map; + count = size_of_i386_register_map; + } + else + { + ent = x86_64_register_map; + count = size_of_x86_64_register_map; + } + for (i = 0; i < count; i++, ent++) + { + const RegisterInfo *ri = rctx->GetRegisterInfoByName (ent->name); + if (ri) + ent->lldb_regno = ri->kinds[eRegisterKindLLDB]; + } + *initialized_flag = 1; + } + } + + // on initial construction we may not have a Thread so these have to remain + // uninitialized until we can get a RegisterContext to set up the register map table + if (*initialized_flag == 1) + { + uint32_t lldb_regno; + if (machine_regno_to_lldb_regno (m_machine_sp_regnum, lldb_regno)) + m_lldb_sp_regnum = lldb_regno; + if (machine_regno_to_lldb_regno (m_machine_fp_regnum, lldb_regno)) + m_lldb_fp_regnum = lldb_regno; + if (machine_regno_to_lldb_regno (m_machine_ip_regnum, lldb_regno)) + m_lldb_ip_regnum = lldb_regno; + } +} + + +// This function expects an x86 native register number (i.e. the bits stripped out of the +// actual instruction), not an lldb register number. + +bool +AssemblyParse_x86::nonvolatile_reg_p (int machine_regno) +{ + if (m_cpu == k_i386) + { + switch (machine_regno) { + case k_machine_ebx: + case k_machine_ebp: // not actually a nonvolatile but often treated as such by convention + case k_machine_esi: + case k_machine_edi: + case k_machine_esp: + return true; + default: + return false; + } + } + if (m_cpu == k_x86_64) + { + switch (machine_regno) { + case k_machine_rbx: + case k_machine_rsp: + case k_machine_rbp: // not actually a nonvolatile but often treated as such by convention + case k_machine_r12: + case k_machine_r13: + case k_machine_r14: + case k_machine_r15: + return true; + default: + return false; + } + } + return false; +} + + +// Macro to detect if this is a REX mode prefix byte. +#define REX_W_PREFIX_P(opcode) (((opcode) & (~0x5)) == 0x48) + +// The high bit which should be added to the source register number (the "R" bit) +#define REX_W_SRCREG(opcode) (((opcode) & 0x4) >> 2) + +// The high bit which should be added to the destination register number (the "B" bit) +#define REX_W_DSTREG(opcode) ((opcode) & 0x1) + +// pushq %rbp [0x55] +bool AssemblyParse_x86::push_rbp_pattern_p () { + uint8_t *p = m_cur_insn_bytes; + if (*p == 0x55) + return true; + return false; +} + +// pushq $0 ; the first instruction in start() [0x6a 0x00] +bool AssemblyParse_x86::push_0_pattern_p () +{ + uint8_t *p = m_cur_insn_bytes; + if (*p == 0x6a && *(p + 1) == 0x0) + return true; + return false; +} + +// movq %rsp, %rbp [0x48 0x8b 0xec] or [0x48 0x89 0xe5] +// movl %esp, %ebp [0x8b 0xec] or [0x89 0xe5] +bool AssemblyParse_x86::mov_rsp_rbp_pattern_p () { + uint8_t *p = m_cur_insn_bytes; + if (m_wordsize == 8 && *p == 0x48) + p++; + if (*(p) == 0x8b && *(p + 1) == 0xec) + return true; + if (*(p) == 0x89 && *(p + 1) == 0xe5) + return true; + return false; +} + +// subq $0x20, %rsp +bool AssemblyParse_x86::sub_rsp_pattern_p (int& amount) { + uint8_t *p = m_cur_insn_bytes; + if (m_wordsize == 8 && *p == 0x48) + p++; + // 8-bit immediate operand + if (*p == 0x83 && *(p + 1) == 0xec) { + amount = (int8_t) *(p + 2); + return true; + } + // 32-bit immediate operand + if (*p == 0x81 && *(p + 1) == 0xec) { + amount = (int32_t) extract_4 (p + 2); + return true; + } + // Not handled: [0x83 0xc4] for imm8 with neg values + // [0x81 0xc4] for imm32 with neg values + return false; +} + +// pushq %rbx +// pushl $ebx +bool AssemblyParse_x86::push_reg_p (int& regno) { + uint8_t *p = m_cur_insn_bytes; + int regno_prefix_bit = 0; + // If we have a rex prefix byte, check to see if a B bit is set + if (m_wordsize == 8 && *p == 0x41) { + regno_prefix_bit = 1 << 3; + p++; + } + if (*p >= 0x50 && *p <= 0x57) { + regno = (*p - 0x50) | regno_prefix_bit; + return true; + } + return false; +} + +// Look for an instruction sequence storing a nonvolatile register +// on to the stack frame. + +// movq %rax, -0x10(%rbp) [0x48 0x89 0x45 0xf0] +// movl %eax, -0xc(%ebp) [0x89 0x45 0xf4] +bool AssemblyParse_x86::mov_reg_to_local_stack_frame_p (int& regno, int& rbp_offset) { + uint8_t *p = m_cur_insn_bytes; + int src_reg_prefix_bit = 0; + int target_reg_prefix_bit = 0; + + if (m_wordsize == 8 && REX_W_PREFIX_P (*p)) { + src_reg_prefix_bit = REX_W_SRCREG (*p) << 3; + target_reg_prefix_bit = REX_W_DSTREG (*p) << 3; + if (target_reg_prefix_bit == 1) { + // rbp/ebp don't need a prefix bit - we know this isn't the + // reg we care about. + return false; + } + p++; + } + + if (*p == 0x89) { + /* Mask off the 3-5 bits which indicate the destination register + if this is a ModR/M byte. */ + int opcode_destreg_masked_out = *(p + 1) & (~0x38); + + /* Is this a ModR/M byte with Mod bits 01 and R/M bits 101 + and three bits between them, e.g. 01nnn101 + We're looking for a destination of ebp-disp8 or ebp-disp32. */ + int immsize; + if (opcode_destreg_masked_out == 0x45) + immsize = 2; + else if (opcode_destreg_masked_out == 0x85) + immsize = 4; + else + return false; + + int offset = 0; + if (immsize == 2) + offset = (int8_t) *(p + 2); + if (immsize == 4) + offset = (uint32_t) extract_4 (p + 2); + if (offset > 0) + return false; + + regno = ((*(p + 1) >> 3) & 0x7) | src_reg_prefix_bit; + rbp_offset = offset > 0 ? offset : -offset; + return true; + } + return false; +} + +// ret [0xc9] or [0xc2 imm8] or [0xca imm8] +bool +AssemblyParse_x86::ret_pattern_p () +{ + uint8_t *p = m_cur_insn_bytes; + if (*p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3) + return true; + return false; +} + +uint32_t +AssemblyParse_x86::extract_4 (uint8_t *b) +{ + uint32_t v = 0; + for (int i = 3; i >= 0; i--) + v = (v << 8) | b[i]; + return v; +} + +bool +AssemblyParse_x86::machine_regno_to_lldb_regno (int machine_regno, uint32_t &lldb_regno) +{ + struct regmap_ent *ent; + int count, i; + if (m_cpu == k_i386) + { + ent = i386_register_map; + count = size_of_i386_register_map; + } + else + { + ent = x86_64_register_map; + count = size_of_x86_64_register_map; + } + for (i = 0; i < count; i++, ent++) + { + if (ent->machine_regno == machine_regno) + if (ent->lldb_regno != -1) + { + lldb_regno = ent->lldb_regno; + return true; + } + } + return false; +} + +struct edis_byte_read_token +{ + Address *address; + Target *target; +}; + + +static int +read_byte_for_edis (uint8_t *buf, uint64_t offset_address, void *arg) +{ + if (arg == 0) + return -1; + struct edis_byte_read_token *tok = (edis_byte_read_token *) arg; + Address *base_address = tok->address; + Target *target = tok->target; + + Address read_addr = *base_address; + read_addr.SetOffset (offset_address); + + uint8_t onebyte_buf[1]; + Error error; + if (target->ReadMemory (read_addr, onebyte_buf, 1, error) != -1) + { + *buf = onebyte_buf[0]; + return 0; + } + return -1; +} + + +bool +AssemblyParse_x86::instruction_length (Address addr, int &length) +{ + const char *triple; + // FIXME should probably pass down the ArchSpec and work from that to make a portable triple + if (m_cpu == k_i386) + triple = "i386-apple-darwin"; + else + triple = "x86_64-apple-darwin"; + + EDDisassemblerRef disasm; + EDInstRef cur_insn; + + if (EDGetDisassembler (&disasm, "i386-apple-darwin", kEDAssemblySyntaxX86ATT) != 0) + { + false; + } + + uint64_t addr_offset = addr.GetOffset(); + struct edis_byte_read_token arg; + arg.address = &addr; + arg.target = &m_target; + if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr_offset, &arg) != 1) + { + false; + } + length = EDInstByteSize (cur_insn); + EDReleaseInst (cur_insn); + return true; +} + + +bool +AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) +{ + UnwindPlan up; + UnwindPlan::Row row; + int non_prologue_insn_count = 0; + Address m_cur_insn = m_func_bounds.GetBaseAddress (); + int current_func_text_offset = 0; + int current_sp_bytes_offset_from_cfa = 0; + UnwindPlan::Row::RegisterLocation regloc; + + unwind_plan.SetPlanValidAddressRange (m_func_bounds); + unwind_plan.SetRegisterKind (eRegisterKindLLDB); + + // At the start of the function, find the CFA by adding wordsize to the SP register + row.SetOffset (current_func_text_offset); + row.SetCFARegister (m_lldb_sp_regnum); + row.SetCFAOffset (m_wordsize); + + // caller's stack pointer value before the call insn is the CFA address + regloc.SetIsCFAPlusOffset (0); + row.SetRegisterInfo (m_lldb_sp_regnum, regloc); + + // saved instruction pointer can be found at CFA - wordsize. + current_sp_bytes_offset_from_cfa = m_wordsize; + regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); + row.SetRegisterInfo (m_lldb_ip_regnum, regloc); + + unwind_plan.AppendRow (row); + + while (m_func_bounds.ContainsFileAddress (m_cur_insn) && non_prologue_insn_count < 10) + { + int stack_offset, insn_len; + int machine_regno; // register numbers masked directly out of instructions + uint32_t lldb_regno; // register numbers in lldb's eRegisterKindLLDB numbering scheme + Error error; + + if (!instruction_length (m_cur_insn, insn_len) || insn_len == 0 || insn_len > kMaxInstructionByteSize) + { + // An unrecognized/junk instruction + break; + } + if (m_target.ReadMemory (m_cur_insn, m_cur_insn_bytes, insn_len, error) == -1) + { + // Error reading the instruction out of the file, stop scanning + break; + } + + if (push_rbp_pattern_p ()) + { + row.SetOffset (current_func_text_offset + insn_len); + current_sp_bytes_offset_from_cfa += m_wordsize; + row.SetCFAOffset (current_sp_bytes_offset_from_cfa); + UnwindPlan::Row::RegisterLocation regloc; + regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); + row.SetRegisterInfo (m_lldb_fp_regnum, regloc); + unwind_plan.AppendRow (row); + goto loopnext; + } + + if (push_0_pattern_p ()) + { + row.SetOffset (current_func_text_offset + insn_len); + current_sp_bytes_offset_from_cfa += m_wordsize; + row.SetCFAOffset (current_sp_bytes_offset_from_cfa); + unwind_plan.AppendRow (row); + goto loopnext; + } + + if (push_reg_p (machine_regno)) + { + current_sp_bytes_offset_from_cfa += m_wordsize; + if (nonvolatile_reg_p (machine_regno) && machine_regno_to_lldb_regno (machine_regno, lldb_regno)) + { + row.SetOffset (current_func_text_offset + insn_len); + if (row.GetCFARegister() == m_lldb_sp_regnum) + { + row.SetCFAOffset (current_sp_bytes_offset_from_cfa); + } + UnwindPlan::Row::RegisterLocation regloc; + regloc.SetAtCFAPlusOffset (-current_sp_bytes_offset_from_cfa); + row.SetRegisterInfo (lldb_regno, regloc); + unwind_plan.AppendRow (row); + } + goto loopnext; + } + + if (mov_reg_to_local_stack_frame_p (machine_regno, stack_offset) && nonvolatile_reg_p (machine_regno)) + { + if (machine_regno_to_lldb_regno (machine_regno, lldb_regno)) + { + row.SetOffset (current_func_text_offset + insn_len); + UnwindPlan::Row::RegisterLocation regloc; + regloc.SetAtCFAPlusOffset (-row.GetCFAOffset()); + row.SetRegisterInfo (lldb_regno, regloc); + unwind_plan.AppendRow (row); + goto loopnext; + } + } + + if (sub_rsp_pattern_p (stack_offset)) + { + current_sp_bytes_offset_from_cfa += stack_offset; + if (row.GetCFARegister() == m_lldb_sp_regnum) + { + row.SetOffset (current_func_text_offset + insn_len); + row.SetCFAOffset (current_sp_bytes_offset_from_cfa); + unwind_plan.AppendRow (row); + } + goto loopnext; + } + + if (mov_rsp_rbp_pattern_p ()) + { + row.SetOffset (current_func_text_offset + insn_len); + row.SetCFARegister (m_lldb_fp_regnum); + unwind_plan.AppendRow (row); + goto loopnext; + } + + if (ret_pattern_p ()) + { + // we know where the end of the function is; set the limit on the PlanValidAddressRange + // in case our initial "high pc" value was overly large + // int original_size = m_func_bounds.GetByteSize(); + // int calculated_size = m_cur_insn.GetOffset() - m_func_bounds.GetBaseAddress().GetOffset() + insn_len + 1; + // m_func_bounds.SetByteSize (calculated_size); + // unwind_plan.SetPlanValidAddressRange (m_func_bounds); + break; + } + + // FIXME recognize the i386 picbase setup instruction sequence, + // 0x1f16: call 0x1f1b ; main + 11 at /private/tmp/a.c:3 + // 0x1f1b: popl %eax + // and record the temporary stack movements if the CFA is not expressed in terms of ebp. + + non_prologue_insn_count++; +loopnext: + m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); + current_func_text_offset += insn_len; + } + + return true; +} + +bool +AssemblyParse_x86::get_fast_unwind_plan (UnwindPlan &unwind_plan) +{ + UnwindPlan up; + return false; +} + +bool +AssemblyParse_x86::find_first_non_prologue_insn (Address &address) +{ + m_cur_insn = m_func_bounds.GetBaseAddress (); + while (m_func_bounds.ContainsFileAddress (m_cur_insn)) + { + Error error; + int insn_len, offset, regno; + if (!instruction_length (m_cur_insn, insn_len) || insn_len > kMaxInstructionByteSize || insn_len == 0) + { + // An error parsing the instruction, i.e. probably data/garbage - stop scanning + break; + } + if (m_target.ReadMemory (m_cur_insn, m_cur_insn_bytes, insn_len, error) == -1) + { + // Error reading the instruction out of the file, stop scanning + break; + } + + if (push_rbp_pattern_p () || mov_rsp_rbp_pattern_p () || sub_rsp_pattern_p (offset) + || push_reg_p (regno) || mov_reg_to_local_stack_frame_p (regno, offset)) + { + m_cur_insn.SetOffset (m_cur_insn.GetOffset() + insn_len); + continue; + } + + // Unknown non-prologue instruction - stop scanning + break; + } + + address = m_cur_insn; + return true; +} + + + + + + +//----------------------------------------------------------------------------------------------- +// UnwindAssemblyParser_x86 method definitions +//----------------------------------------------------------------------------------------------- + +bool +UnwindAssemblyProfiler_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan) +{ + AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); + return asm_parse.get_non_call_site_unwind_plan (unwind_plan); +} + +bool +UnwindAssemblyProfiler_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan) +{ + AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func); + return asm_parse.get_fast_unwind_plan (unwind_plan); +} + +bool +UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn) +{ + AssemblyParse_x86 asm_parse(target, thread, m_cpu, func); + return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); +} + +lldb_private::UnwindAssemblyProfiler * +UnwindAssemblyProfiler_x86::CreateInstance (const lldb_private::ArchSpec &arch) +{ + uint32_t cpu = arch.GetCPUType (); + if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + return NULL; + + return new UnwindAssemblyProfiler_x86 (cpu == CPU_TYPE_X86_64 ? k_x86_64 : k_i386); +} + + +//------------------------------------------------------------------ +// PluginInterface protocol in UnwindAssemblyParser_x86 +//------------------------------------------------------------------ + +const char * +UnwindAssemblyProfiler_x86::GetPluginName() +{ + return "UnwindAssemblyProfiler_x86"; +} + +const char * +UnwindAssemblyProfiler_x86::GetShortPluginName() +{ + return "unwindassemblyprofiler.x86"; +} + + +uint32_t +UnwindAssemblyProfiler_x86::GetPluginVersion() +{ + return 1; +} + +void +UnwindAssemblyProfiler_x86::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +UnwindAssemblyProfiler_x86::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +UnwindAssemblyProfiler_x86::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +void +UnwindAssemblyProfiler_x86::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +UnwindAssemblyProfiler_x86::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +UnwindAssemblyProfiler_x86::GetPluginNameStatic() +{ + return "UnwindAssemblyProfiler_x86"; +} + +const char * +UnwindAssemblyProfiler_x86::GetPluginDescriptionStatic() +{ + return "i386 and x86_64 assembly language profiler plugin."; +} Added: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h Fri Sep 10 02:49:16 2010 @@ -0,0 +1,82 @@ +//===-- UnwindAssemblyProfiler-x86.h ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_UnwindAssemblyProfiler_x86_h_ +#define liblldb_UnwindAssemblyProfiler_x86_h_ + +#include "lldb/lldb-private.h" +#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Target/Thread.h" + +namespace lldb_private { + +class UnwindAssemblyProfiler_x86 : public lldb_private::UnwindAssemblyProfiler +{ +public: + + ~UnwindAssemblyProfiler_x86 () { } + + virtual bool + GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, lldb_private::Thread& thread, UnwindPlan& unwind_plan); + + virtual bool + GetFastUnwindPlan (AddressRange& func, lldb_private::Thread& thread, UnwindPlan &unwind_plan); + + // thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch). + virtual bool + FirstNonPrologueInsn (AddressRange& func, lldb_private::Target& target, lldb_private::Thread* thread, Address& first_non_prologue_insn); + + static lldb_private::UnwindAssemblyProfiler * + CreateInstance (const lldb_private::ArchSpec &arch); + + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + +private: + UnwindAssemblyProfiler_x86(int cpu) : + lldb_private::UnwindAssemblyProfiler(), m_cpu(cpu) { } // Call CreateInstance instead. + + int m_cpu; +}; + + +} // namespace lldb_private + +#endif // liblldb_UnwindAssemblyProfiler_x86_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Fri Sep 10 02:49:16 2010 @@ -416,83 +416,83 @@ static lldb::RegisterInfo g_register_infos[] = { - // NAME ALT SZ OFF ENCODING FORMAT NUM COMPILER DWARF GENERIC - // ====== ======= == ==== ============= ============ === =============== =============== ========= - { "r0", NULL, 4, 0, eEncodingUint, eFormatHex, 0, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM }}, - { "r1", NULL, 4, 4, eEncodingUint, eFormatHex, 1, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM }}, - { "r2", NULL, 4, 8, eEncodingUint, eFormatHex, 2, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM }}, - { "r3", NULL, 4, 12, eEncodingUint, eFormatHex, 3, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM }}, - { "r4", NULL, 4, 16, eEncodingUint, eFormatHex, 4, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM }}, - { "r5", NULL, 4, 20, eEncodingUint, eFormatHex, 5, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM }}, - { "r6", NULL, 4, 24, eEncodingUint, eFormatHex, 6, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM }}, - { "r7", NULL, 4, 28, eEncodingUint, eFormatHex, 7, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP }}, - { "r8", NULL, 4, 32, eEncodingUint, eFormatHex, 8, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM }}, - { "r9", NULL, 4, 36, eEncodingUint, eFormatHex, 9, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM }}, - { "r10", NULL, 4, 40, eEncodingUint, eFormatHex, 10, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM }}, - { "r11", NULL, 4, 44, eEncodingUint, eFormatHex, 11, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM }}, - { "r12", NULL, 4, 48, eEncodingUint, eFormatHex, 12, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM }}, - { "sp", "r13", 4, 52, eEncodingUint, eFormatHex, 13, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP }}, - { "lr", "r14", 4, 56, eEncodingUint, eFormatHex, 14, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA }}, - { "pc", "r15", 4, 60, eEncodingUint, eFormatHex, 15, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC }}, - { NULL, NULL, 12, 64, eEncodingIEEE754, eFormatFloat, 16, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 76, eEncodingIEEE754, eFormatFloat, 17, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 88, eEncodingIEEE754, eFormatFloat, 18, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 100, eEncodingIEEE754, eFormatFloat, 19, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 112, eEncodingIEEE754, eFormatFloat, 20, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 124, eEncodingIEEE754, eFormatFloat, 21, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 136, eEncodingIEEE754, eFormatFloat, 22, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 148, eEncodingIEEE754, eFormatFloat, 23, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { NULL, NULL, 12, 160, eEncodingIEEE754, eFormatFloat, 24, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS }}, - { "cpsr", "psr", 4, 172, eEncodingUint, eFormatHex, 25, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS }}, - { "s0", NULL, 4, 176, eEncodingIEEE754, eFormatFloat, 26, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM }}, - { "s1", NULL, 4, 180, eEncodingIEEE754, eFormatFloat, 27, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM }}, - { "s2", NULL, 4, 184, eEncodingIEEE754, eFormatFloat, 28, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM }}, - { "s3", NULL, 4, 188, eEncodingIEEE754, eFormatFloat, 29, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM }}, - { "s4", NULL, 4, 192, eEncodingIEEE754, eFormatFloat, 30, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM }}, - { "s5", NULL, 4, 196, eEncodingIEEE754, eFormatFloat, 31, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM }}, - { "s6", NULL, 4, 200, eEncodingIEEE754, eFormatFloat, 32, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM }}, - { "s7", NULL, 4, 204, eEncodingIEEE754, eFormatFloat, 33, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM }}, - { "s8", NULL, 4, 208, eEncodingIEEE754, eFormatFloat, 34, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM }}, - { "s9", NULL, 4, 212, eEncodingIEEE754, eFormatFloat, 35, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM }}, - { "s10", NULL, 4, 216, eEncodingIEEE754, eFormatFloat, 36, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM }}, - { "s11", NULL, 4, 220, eEncodingIEEE754, eFormatFloat, 37, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM }}, - { "s12", NULL, 4, 224, eEncodingIEEE754, eFormatFloat, 38, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM }}, - { "s13", NULL, 4, 228, eEncodingIEEE754, eFormatFloat, 39, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM }}, - { "s14", NULL, 4, 232, eEncodingIEEE754, eFormatFloat, 40, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM }}, - { "s15", NULL, 4, 236, eEncodingIEEE754, eFormatFloat, 41, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM }}, - { "s16", NULL, 4, 240, eEncodingIEEE754, eFormatFloat, 42, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM }}, - { "s17", NULL, 4, 244, eEncodingIEEE754, eFormatFloat, 43, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM }}, - { "s18", NULL, 4, 248, eEncodingIEEE754, eFormatFloat, 44, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM }}, - { "s19", NULL, 4, 252, eEncodingIEEE754, eFormatFloat, 45, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM }}, - { "s20", NULL, 4, 256, eEncodingIEEE754, eFormatFloat, 46, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM }}, - { "s21", NULL, 4, 260, eEncodingIEEE754, eFormatFloat, 47, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM }}, - { "s22", NULL, 4, 264, eEncodingIEEE754, eFormatFloat, 48, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM }}, - { "s23", NULL, 4, 268, eEncodingIEEE754, eFormatFloat, 49, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM }}, - { "s24", NULL, 4, 272, eEncodingIEEE754, eFormatFloat, 50, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM }}, - { "s25", NULL, 4, 276, eEncodingIEEE754, eFormatFloat, 51, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM }}, - { "s26", NULL, 4, 280, eEncodingIEEE754, eFormatFloat, 52, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM }}, - { "s27", NULL, 4, 284, eEncodingIEEE754, eFormatFloat, 53, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM }}, - { "s28", NULL, 4, 288, eEncodingIEEE754, eFormatFloat, 54, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM }}, - { "s29", NULL, 4, 292, eEncodingIEEE754, eFormatFloat, 55, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM }}, - { "s30", NULL, 4, 296, eEncodingIEEE754, eFormatFloat, 56, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM }}, - { "s31", NULL, 4, 300, eEncodingIEEE754, eFormatFloat, 57, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM }}, - { "fpscr", NULL, 4, 304, eEncodingUint, eFormatHex, 58, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM }}, - { "d16", NULL, 8, 308, eEncodingIEEE754, eFormatFloat, 59, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM }}, - { "d17", NULL, 8, 316, eEncodingIEEE754, eFormatFloat, 60, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM }}, - { "d18", NULL, 8, 324, eEncodingIEEE754, eFormatFloat, 61, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM }}, - { "d19", NULL, 8, 332, eEncodingIEEE754, eFormatFloat, 62, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM }}, - { "d20", NULL, 8, 340, eEncodingIEEE754, eFormatFloat, 63, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM }}, - { "d21", NULL, 8, 348, eEncodingIEEE754, eFormatFloat, 64, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM }}, - { "d22", NULL, 8, 356, eEncodingIEEE754, eFormatFloat, 65, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM }}, - { "d23", NULL, 8, 364, eEncodingIEEE754, eFormatFloat, 66, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM }}, - { "d24", NULL, 8, 372, eEncodingIEEE754, eFormatFloat, 67, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM }}, - { "d25", NULL, 8, 380, eEncodingIEEE754, eFormatFloat, 68, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM }}, - { "d26", NULL, 8, 388, eEncodingIEEE754, eFormatFloat, 69, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM }}, - { "d27", NULL, 8, 396, eEncodingIEEE754, eFormatFloat, 70, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM }}, - { "d28", NULL, 8, 404, eEncodingIEEE754, eFormatFloat, 71, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM }}, - { "d29", NULL, 8, 412, eEncodingIEEE754, eFormatFloat, 72, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM }}, - { "d30", NULL, 8, 420, eEncodingIEEE754, eFormatFloat, 73, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM }}, - { "d31", NULL, 8, 428, eEncodingIEEE754, eFormatFloat, 74, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM }}, + // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE + // ====== ======= == ==== ============= ============ =============== =============== ========= ===== =========== + { "r0", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 0 }}, + { "r1", NULL, 4, 4, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 1 }}, + { "r2", NULL, 4, 8, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 2 }}, + { "r3", NULL, 4, 12, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 3 }}, + { "r4", NULL, 4, 16, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 4 }}, + { "r5", NULL, 4, 20, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 5 }}, + { "r6", NULL, 4, 24, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 6 }}, + { "r7", NULL, 4, 28, eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, 7 }}, + { "r8", NULL, 4, 32, eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 8 }}, + { "r9", NULL, 4, 36, eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 9 }}, + { "r10", NULL, 4, 40, eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 10 }}, + { "r11", NULL, 4, 44, eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 11 }}, + { "r12", NULL, 4, 48, eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 12 }}, + { "sp", "r13", 4, 52, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, 13 }}, + { "lr", "r14", 4, 56, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, 14 }}, + { "pc", "r15", 4, 60, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, 15 }}, + { NULL, NULL, 12, 64, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 16 }}, + { NULL, NULL, 12, 76, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 17 }}, + { NULL, NULL, 12, 88, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 18 }}, + { NULL, NULL, 12, 100, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 19 }}, + { NULL, NULL, 12, 112, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 20 }}, + { NULL, NULL, 12, 124, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 21 }}, + { NULL, NULL, 12, 136, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 22 }}, + { NULL, NULL, 12, 148, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 23 }}, + { NULL, NULL, 12, 160, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 24 }}, + { "cpsr", "psr", 4, 172, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 25 }}, + { "s0", NULL, 4, 176, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 26 }}, + { "s1", NULL, 4, 180, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 27 }}, + { "s2", NULL, 4, 184, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 28 }}, + { "s3", NULL, 4, 188, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 29 }}, + { "s4", NULL, 4, 192, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 30 }}, + { "s5", NULL, 4, 196, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 31 }}, + { "s6", NULL, 4, 200, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 32 }}, + { "s7", NULL, 4, 204, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 33 }}, + { "s8", NULL, 4, 208, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 34 }}, + { "s9", NULL, 4, 212, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 35 }}, + { "s10", NULL, 4, 216, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 36 }}, + { "s11", NULL, 4, 220, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 37 }}, + { "s12", NULL, 4, 224, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 38 }}, + { "s13", NULL, 4, 228, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 39 }}, + { "s14", NULL, 4, 232, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 40 }}, + { "s15", NULL, 4, 236, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 41 }}, + { "s16", NULL, 4, 240, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 42 }}, + { "s17", NULL, 4, 244, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 43 }}, + { "s18", NULL, 4, 248, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 44 }}, + { "s19", NULL, 4, 252, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 45 }}, + { "s20", NULL, 4, 256, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 46 }}, + { "s21", NULL, 4, 260, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 47 }}, + { "s22", NULL, 4, 264, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 48 }}, + { "s23", NULL, 4, 268, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 49 }}, + { "s24", NULL, 4, 272, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 50 }}, + { "s25", NULL, 4, 276, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 51 }}, + { "s26", NULL, 4, 280, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 52 }}, + { "s27", NULL, 4, 284, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 53 }}, + { "s28", NULL, 4, 288, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 54 }}, + { "s29", NULL, 4, 292, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 55 }}, + { "s30", NULL, 4, 296, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 56 }}, + { "s31", NULL, 4, 300, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 57 }}, + { "fpscr", NULL, 4, 304, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58 }}, + { "d16", NULL, 8, 308, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 59 }}, + { "d17", NULL, 8, 316, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 60 }}, + { "d18", NULL, 8, 324, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 61 }}, + { "d19", NULL, 8, 332, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 62 }}, + { "d20", NULL, 8, 340, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 63 }}, + { "d21", NULL, 8, 348, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 64 }}, + { "d22", NULL, 8, 356, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 65 }}, + { "d23", NULL, 8, 364, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 66 }}, + { "d24", NULL, 8, 372, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 67 }}, + { "d25", NULL, 8, 380, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 68 }}, + { "d26", NULL, 8, 388, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 69 }}, + { "d27", NULL, 8, 396, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 70 }}, + { "d28", NULL, 8, 404, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 71 }}, + { "d29", NULL, 8, 412, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 72 }}, + { "d30", NULL, 8, 420, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 73 }}, + { "d31", NULL, 8, 428, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 74 }}, }; static const uint32_t num_registers = sizeof (g_register_infos)/sizeof (lldb::RegisterInfo); static ConstString gpr_reg_set ("General Purpose Registers"); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Fri Sep 10 02:49:16 2010 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/lldb-enumerations.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Target/RegisterContext.h" 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=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Sep 10 02:49:16 2010 @@ -214,12 +214,12 @@ reg_offset, // offset eEncodingUint, // encoding eFormatHex, // formate - reg_num, // native register number { LLDB_INVALID_REGNUM, // GCC reg num LLDB_INVALID_REGNUM, // DWARF reg num LLDB_INVALID_REGNUM, // generic reg num - reg_num // GDB reg num + reg_num, // GDB reg num + reg_num // native register number } }; Modified: lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp (original) +++ lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp Fri Sep 10 02:49:16 2010 @@ -12,8 +12,7 @@ // C++ Includes #include -// Other libraries and framework includes -// Project includes +#include "lldb/Core/Section.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" @@ -21,413 +20,83 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Core/Section.h" #include "lldb/Target/Thread.h" +#include "lldb/Symbol/UnwindPlan.h" using namespace lldb; using namespace lldb_private; -static void -DumpRegisterName (Stream *s, Thread *thread, const ArchSpec *arch, uint32_t reg_kind, uint32_t reg_num) +DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile& objfile, SectionSP& section, uint32_t reg_kind, bool is_eh_frame) : + m_objfile (objfile), + m_section (section), + m_reg_kind (reg_kind), // The flavor of registers that the CFI data uses (enum RegisterKind) + m_cie_map (), + m_cfi_data (), + m_cfi_data_initialized (false), + m_fde_index (), + m_fde_index_initialized (false), + m_is_eh_frame (is_eh_frame) { - const char *reg_name = NULL; - RegisterContext *reg_ctx = NULL; - if (thread) - { - reg_ctx = thread->GetRegisterContext(); - if (reg_ctx) - reg_name = reg_ctx->GetRegisterName (reg_ctx->ConvertRegisterKindToRegisterNumber (reg_kind, reg_num)); - } - - if (reg_name == NULL && arch != NULL) - { - switch (reg_kind) - { - case eRegisterKindDWARF: reg_name = arch->GetRegisterName(reg_num, eRegisterKindDWARF); break; - case eRegisterKindGCC: reg_name = arch->GetRegisterName(reg_num, eRegisterKindGCC); break; - default: - break; - } - } - - if (reg_name) - s->PutCString(reg_name); - else - { - const char *reg_kind_name = NULL; - switch (reg_kind) - { - case eRegisterKindDWARF: reg_kind_name = "dwarf-reg"; break; - case eRegisterKindGCC: reg_kind_name = "compiler-reg"; break; - case eRegisterKindGeneric: reg_kind_name = "generic-reg"; break; - default: - break; - } - if (reg_kind_name) - s->Printf("%s(%u)", reg_kind_name, reg_num); - else - s->Printf("reg(%d.%u)", reg_kind, reg_num); - } } - -#pragma mark DWARFCallFrameInfo::RegisterLocation - -DWARFCallFrameInfo::RegisterLocation::RegisterLocation() : - m_type(isSame) +DWARFCallFrameInfo::~DWARFCallFrameInfo() { } bool -DWARFCallFrameInfo::RegisterLocation::operator == (const DWARFCallFrameInfo::RegisterLocation& rhs) const +DWARFCallFrameInfo::GetAddressRange (Address addr, AddressRange &range) { - if (m_type != rhs.m_type) + FDEEntry fde_entry; + if (GetFDEEntryByAddress (addr, fde_entry) == false) return false; - switch (m_type) - { - case unspecified: - case isUndefined: - case isSame: - return true; - - case atCFAPlusOffset: - return m_location.offset == rhs.m_location.offset; - - case isCFAPlusOffset: - return m_location.offset == rhs.m_location.offset; - - case inOtherRegister: - return m_location.reg_num == rhs.m_location.reg_num; - - default: - break; - } - return false; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetUnspecified() -{ - m_type = unspecified; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetUndefined() -{ - m_type = isUndefined; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetSame() -{ - m_type = isSame; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetAtCFAPlusOffset(int64_t offset) -{ - m_type = atCFAPlusOffset; - m_location.offset = offset; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetIsCFAPlusOffset(int64_t offset) -{ - m_type = isCFAPlusOffset; - m_location.offset = offset; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetInRegister (uint32_t reg_num) -{ - m_type = inOtherRegister; - m_location.reg_num = reg_num; + range = fde_entry.bounds; + return true; } -void -DWARFCallFrameInfo::RegisterLocation::SetAtDWARFExpression(const uint8_t *opcodes, uint32_t len) -{ - m_type = atDWARFExpression; - m_location.expr.opcodes = opcodes; - m_location.expr.length = len; -} - -void -DWARFCallFrameInfo::RegisterLocation::SetIsDWARFExpression(const uint8_t *opcodes, uint32_t len) -{ - m_type = isDWARFExpression; - m_location.expr.opcodes = opcodes; - m_location.expr.length = len; -} - -void -DWARFCallFrameInfo::RegisterLocation::Dump(Stream *s, const DWARFCallFrameInfo &cfi, Thread *thread, const Row *row, uint32_t reg_num) const -{ - const ArchSpec *arch = cfi.GetArchitecture(); - const uint32_t reg_kind = cfi.GetRegisterKind(); - - DumpRegisterName (s, thread, arch, reg_kind, reg_num); - s->PutChar('='); - - switch (m_type) - { - case unspecified: - s->PutChar('?'); - break; - - case isUndefined: - s->PutCString("undefined"); - break; - - case isSame: - s->PutCString("same"); - break; - - case atCFAPlusOffset: - s->PutChar('['); - // Fall through to isCFAPlusOffset... - case isCFAPlusOffset: - { - DumpRegisterName (s, thread, arch, reg_kind, row->GetCFARegister()); - int32_t offset = row->GetCFAOffset() + m_location.offset; - if (offset != 0) - s->Printf("%-+d", offset); - if (m_type == atCFAPlusOffset) - s->PutChar(']'); - } - break; - - case inOtherRegister: - DumpRegisterName (s, thread, arch, reg_kind, m_location.reg_num); - break; - - case atDWARFExpression: - s->PutCString("[EXPR] "); - break; - - case isDWARFExpression: - s->PutCString("EXPR "); - break; - } -} - - -#pragma mark DWARFCallFrameInfo::Row - -DWARFCallFrameInfo::Row::Row() : - m_offset(0), - m_cfa_reg_num(0), - m_cfa_offset(0), - m_register_locations() -{ -} - -DWARFCallFrameInfo::Row::~Row() -{ -} - -void -DWARFCallFrameInfo::Row::Clear() -{ - m_register_locations.clear(); -} bool -DWARFCallFrameInfo::Row::GetRegisterInfo (uint32_t reg_num, DWARFCallFrameInfo::RegisterLocation& register_location) const +DWARFCallFrameInfo::GetUnwindPlan (Address addr, UnwindPlan& unwind_plan) { - collection::const_iterator pos = m_register_locations.find(reg_num); - if (pos != m_register_locations.end()) - { - register_location = pos->second; - return true; - } - return false; + FDEEntry fde_entry; + if (GetFDEEntryByAddress (addr, fde_entry) == false) + return false; + return FDEToUnwindPlan (fde_entry.offset, addr, unwind_plan); } -void -DWARFCallFrameInfo::Row::SetRegisterInfo (uint32_t reg_num, const RegisterLocation& register_location) +bool +DWARFCallFrameInfo::GetFDEEntryByAddress (Address addr, FDEEntry& fde_entry) { - m_register_locations[reg_num] = register_location; -} + if (m_section.get() == NULL) + return false; + GetFDEIndex(); + struct FDEEntry searchfde; + searchfde.bounds = AddressRange (addr, 1); -void -DWARFCallFrameInfo::Row::Dump(Stream* s, const DWARFCallFrameInfo &cfi, Thread *thread, lldb::addr_t base_addr) const -{ - const ArchSpec *arch = cfi.GetArchitecture(); - const uint32_t reg_kind = cfi.GetRegisterKind(); - collection::const_iterator pos, end = m_register_locations.end(); - s->Indent(); - s->Printf("0x%16.16llx: CFA=", m_offset + base_addr); - DumpRegisterName(s, thread, arch, reg_kind, m_cfa_reg_num); - if (m_cfa_offset != 0) - s->Printf("%-+lld", m_cfa_offset); + std::vector::const_iterator idx; + if (m_fde_index.size() == 0) + return false; - for (pos = m_register_locations.begin(); pos != end; ++pos) + idx = std::lower_bound (m_fde_index.begin(), m_fde_index.end(), searchfde); + if (idx == m_fde_index.end()) { - s->PutChar(' '); - pos->second.Dump(s, cfi, thread, this, pos->first); + --idx; } - s->EOL(); -} - - -#pragma mark DWARFCallFrameInfo::FDE - - -DWARFCallFrameInfo::FDE::FDE (dw_offset_t offset, const AddressRange &range) : - m_fde_offset (offset), - m_range (range), - m_row_list () -{ -} - -DWARFCallFrameInfo::FDE::~FDE() -{ -} - -void -DWARFCallFrameInfo::FDE::AppendRow (const Row &row) -{ - if (m_row_list.empty() || m_row_list.back().GetOffset() != row.GetOffset()) - m_row_list.push_back(row); - else - m_row_list.back() = row; -} - -void -DWARFCallFrameInfo::FDE::Dump (Stream *s, const DWARFCallFrameInfo &cfi, Thread* thread) const -{ - s->Indent(); - s->Printf("FDE{0x%8.8x} ", m_fde_offset); - m_range.Dump(s, NULL, Address::DumpStyleFileAddress); - lldb::addr_t fde_base_addr = m_range.GetBaseAddress().GetFileAddress(); - s->EOL(); - s->IndentMore(); - collection::const_iterator pos, end = m_row_list.end(); - for (pos = m_row_list.begin(); pos != end; ++pos) + if (idx != m_fde_index.begin() && idx->bounds.GetBaseAddress().GetOffset() != addr.GetOffset()) { - pos->Dump(s, cfi, thread, fde_base_addr); + --idx; } - s->IndentLess(); -} - -const AddressRange & -DWARFCallFrameInfo::FDE::GetAddressRange() const -{ - return m_range; -} - -bool -DWARFCallFrameInfo::FDE::IsValidRowIndex (uint32_t idx) const -{ - return idx < m_row_list.size(); -} - -const DWARFCallFrameInfo::Row& -DWARFCallFrameInfo::FDE::GetRowAtIndex (uint32_t idx) -{ - // You must call IsValidRowIndex(idx) first before calling this!!! - return m_row_list[idx]; -} -#pragma mark DWARFCallFrameInfo::FDEInfo - -DWARFCallFrameInfo::FDEInfo::FDEInfo () : - fde_offset (0), - fde_sp() -{ -} - -DWARFCallFrameInfo::FDEInfo::FDEInfo (off_t offset) : - fde_offset(offset), - fde_sp() -{ -} - -#pragma mark DWARFCallFrameInfo::CIE - -DWARFCallFrameInfo::CIE::CIE(dw_offset_t offset) : - cie_offset (offset), - version (0), - augmentation(), - code_align (0), - data_align (0), - return_addr_reg_num (0), - inst_offset (0), - inst_length (0), - ptr_encoding (DW_EH_PE_absptr) -{ -} - - -DWARFCallFrameInfo::CIE::~CIE() -{ -} - -void -DWARFCallFrameInfo::CIE::Dump(Stream *s, Thread* thread, const ArchSpec *arch, uint32_t reg_kind) const -{ - s->Indent(); - s->Printf("CIE{0x%8.8x} version=%u, code_align=%u, data_align=%d, return_addr_reg=", cie_offset, version, code_align, data_align); - DumpRegisterName(s, thread, arch, reg_kind, return_addr_reg_num); - s->Printf(", instr_offset=0x%8.8x, instr_length=%u, ptr_encoding=0x%02x\n", - inst_offset, - inst_length, - ptr_encoding); -} - -#pragma mark DWARFCallFrameInfo::CIE - -DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile *objfile, Section *section, uint32_t reg_kind) : - m_objfile (objfile), - m_section (section), - m_reg_kind (reg_kind), // The flavor of registers that the CFI data uses (One of the defines that starts with "LLDB_REGKIND_") - m_cfi_data (), - m_cie_map (), - m_fde_map () -{ - if (objfile && section) + if (idx->bounds.ContainsFileAddress (addr)) { - section->ReadSectionDataFromObjectFile (objfile, m_cfi_data); + fde_entry = *idx; + return true; } -} - -DWARFCallFrameInfo::~DWARFCallFrameInfo() -{ -} -bool -DWARFCallFrameInfo::IsEHFrame() const -{ - return (m_reg_kind == eRegisterKindGCC); -} - -const ArchSpec * -DWARFCallFrameInfo::GetArchitecture() const -{ - if (m_objfile && m_objfile->GetModule()) - return &m_objfile->GetModule()->GetArchitecture(); - return NULL; -} - -uint32_t -DWARFCallFrameInfo::GetRegisterKind () const -{ - return m_reg_kind; -} - -void -DWARFCallFrameInfo::SetRegisterKind (uint32_t reg_kind) -{ - m_reg_kind = reg_kind; + return false; } - - - const DWARFCallFrameInfo::CIE* DWARFCallFrameInfo::GetCIE(dw_offset_t cie_offset) { - Index (); - cie_map_t::iterator pos = m_cie_map.find(cie_offset); if (pos != m_cie_map.end()) @@ -441,16 +110,20 @@ return NULL; } -DWARFCallFrameInfo::CIE::shared_ptr +DWARFCallFrameInfo::CIESP DWARFCallFrameInfo::ParseCIE (const dw_offset_t cie_offset) { - CIE::shared_ptr cie_sp(new CIE(cie_offset)); - const bool for_eh_frame = IsEHFrame(); + CIESP cie_sp(new CIE(cie_offset)); dw_offset_t offset = cie_offset; + if (m_cfi_data_initialized == false) + { + m_section->ReadSectionDataFromObjectFile (&m_objfile, m_cfi_data); + m_cfi_data_initialized = true; + } const uint32_t length = m_cfi_data.GetU32(&offset); const dw_offset_t cie_id = m_cfi_data.GetU32(&offset); const dw_offset_t end_offset = cie_offset + length + 4; - if (length > 0 && (!for_eh_frame && cie_id == 0xfffffffful) || (for_eh_frame && cie_id == 0ul)) + if (length > 0 && (!m_is_eh_frame && cie_id == 0xfffffffful) || (m_is_eh_frame && cie_id == 0ul)) { size_t i; // cie.offset = cie_offset; @@ -555,164 +228,158 @@ cie_sp->inst_offset = offset; cie_sp->inst_length = end_offset - offset; } + while (offset < end_offset) + { + uint8_t inst = m_cfi_data.GetU8(&offset); + uint8_t primary_opcode = inst & 0xC0; + uint8_t extended_opcode = inst & 0x3F; + + if (extended_opcode == DW_CFA_def_cfa) + { + // Takes two unsigned LEB128 operands representing a register + // number and a (non-factored) offset. The required action + // is to define the current CFA rule to use the provided + // register and offset. + uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset); + int op_offset = (int32_t)m_cfi_data.GetULEB128(&offset); + cie_sp->initial_row.SetCFARegister (reg_num); + cie_sp->initial_row.SetCFAOffset (op_offset); + continue; + } + if (primary_opcode == DW_CFA_offset) + { + // 0x80 - high 2 bits are 0x2, lower 6 bits are register. + // Takes two arguments: an unsigned LEB128 constant representing a + // factored offset and a register number. The required action is to + // change the rule for the register indicated by the register number + // to be an offset(N) rule with a value of + // (N = factored offset * data_align). + uint32_t reg_num = extended_opcode; + int op_offset = (int32_t)m_cfi_data.GetULEB128(&offset) * cie_sp->data_align; + UnwindPlan::Row::RegisterLocation reg_location; + reg_location.SetAtCFAPlusOffset(op_offset); + cie_sp->initial_row.SetRegisterInfo (reg_num, reg_location); + continue; + } + if (extended_opcode == DW_CFA_nop) + { + continue; + } + break; // Stop if we hit an unrecognized opcode + } } return cie_sp; } -DWARFCallFrameInfo::FDE::shared_ptr -DWARFCallFrameInfo::ParseFDE(const dw_offset_t fde_offset) +// Scan through the eh_frame or debug_frame section looking for FDEs and noting the start/end addresses +// of the functions and a pointer back to the function's FDE for later expansion. +// Internalize CIEs as we come across them. + +void +DWARFCallFrameInfo::GetFDEIndex () { - const bool for_eh_frame = IsEHFrame(); - FDE::shared_ptr fde_sp; + if (m_section.get() == NULL) + return; + if (m_fde_index_initialized) + return; - dw_offset_t offset = fde_offset; - const uint32_t length = m_cfi_data.GetU32(&offset); - dw_offset_t cie_offset = m_cfi_data.GetU32(&offset); - const dw_offset_t end_offset = fde_offset + length + 4; + dw_offset_t offset = 0; + if (m_cfi_data_initialized == false) + { + m_section->ReadSectionDataFromObjectFile (&m_objfile, m_cfi_data); + m_cfi_data_initialized = true; + } + while (m_cfi_data.ValidOffsetForDataOfSize (offset, 8)) + { + dw_offset_t current_entry = offset; + uint32_t len = m_cfi_data.GetU32 (&offset); + dw_offset_t next_entry = current_entry + len + 4; + dw_offset_t cie_id = m_cfi_data.GetU32 (&offset); - // Translate the CIE_id from the eh_frame format, which - // is relative to the FDE offset, into a __eh_frame section - // offset - if (for_eh_frame) - cie_offset = offset - (cie_offset + 4); + if (cie_id == 0 || cie_id == UINT32_MAX) + { + m_cie_map[current_entry] = ParseCIE (current_entry); + offset = next_entry; + continue; + } + + const CIE *cie = GetCIE (current_entry + 4 - cie_id); + assert (cie != NULL); - const CIE* cie = GetCIE(cie_offset); - if (cie) - { const lldb::addr_t pc_rel_addr = m_section->GetFileAddress(); const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS; - lldb::addr_t range_base = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); - lldb::addr_t range_len = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); - if (cie->augmentation[0] == 'z') - { - uint32_t aug_data_len = (uint32_t)m_cfi_data.GetULEB128(&offset); - offset += aug_data_len; - } + lldb::addr_t addr = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); + lldb::addr_t length = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); + FDEEntry fde; + fde.bounds = AddressRange (addr, length, m_objfile.GetSectionList()); + fde.offset = current_entry; + m_fde_index.push_back(fde); - AddressRange fde_range (range_base, range_len, m_objfile->GetSectionList ()); - fde_sp.reset(new FDE(fde_offset, fde_range)); - if (offset < end_offset) - { - dw_offset_t fde_instr_offset = offset; - uint32_t fde_instr_length = end_offset - offset; - if (cie->inst_length > 0) - ParseInstructions(cie, fde_sp.get(), cie->inst_offset, cie->inst_length); - ParseInstructions(cie, fde_sp.get(), fde_instr_offset, fde_instr_length); - } + offset = next_entry; } - return fde_sp; + std::sort (m_fde_index.begin(), m_fde_index.end()); + m_fde_index_initialized = true; } -const DWARFCallFrameInfo::FDE * -DWARFCallFrameInfo::FindFDE(const Address &addr) +bool +DWARFCallFrameInfo::FDEToUnwindPlan (dw_offset_t offset, Address startaddr, UnwindPlan& unwind_plan) { - Index (); + dw_offset_t current_entry = offset; - VMRange find_range(addr.GetFileAddress(), 0); - fde_map_t::iterator pos = m_fde_map.lower_bound (find_range); - fde_map_t::iterator end = m_fde_map.end(); + if (m_section.get() == NULL) + return false; - if (pos != end) + if (m_cfi_data_initialized == false) { - if (pos->first.Contains(find_range.GetBaseAddress())) - { - // Parse and cache the FDE if we already haven't - if (pos->second.fde_sp.get() == NULL) - pos->second.fde_sp = ParseFDE(pos->second.fde_offset); - - return pos->second.fde_sp.get(); - } + m_section->ReadSectionDataFromObjectFile (&m_objfile, m_cfi_data); + m_cfi_data_initialized = true; } - return NULL; -} + uint32_t length = m_cfi_data.GetU32 (&offset); + dw_offset_t cie_offset = m_cfi_data.GetU32 (&offset); -void -DWARFCallFrameInfo::Index () -{ - if (m_flags.IsClear(eFlagParsedIndex)) - { - m_flags.Set (eFlagParsedIndex); - const bool for_eh_frame = IsEHFrame(); - CIE::shared_ptr empty_cie_sp; - dw_offset_t offset = 0; - // Parse all of the CIEs first since we will need them to be able to - // properly parse the FDE addresses due to them possibly having - // GNU pointer encodings in their augmentations... - while (m_cfi_data.ValidOffsetForDataOfSize(offset, 8)) - { - const dw_offset_t curr_offset = offset; - const uint32_t length = m_cfi_data.GetU32(&offset); - const dw_offset_t next_offset = offset + length; - const dw_offset_t cie_id = m_cfi_data.GetU32(&offset); - - bool is_cie = for_eh_frame ? cie_id == 0 : cie_id == UINT32_MAX; - if (is_cie) - m_cie_map[curr_offset]= ParseCIE(curr_offset); + assert (cie_offset != 0 && cie_offset != UINT32_MAX); - offset = next_offset; - } + // Translate the CIE_id from the eh_frame format, which + // is relative to the FDE offset, into a __eh_frame section + // offset + if (m_is_eh_frame) + cie_offset = current_entry + 4 - cie_offset; - // Now go back through and index all FDEs - offset = 0; - const lldb::addr_t pc_rel_addr = m_section->GetFileAddress(); - const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; - const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS; - while (m_cfi_data.ValidOffsetForDataOfSize(offset, 8)) - { - const dw_offset_t curr_offset = offset; - const dw_offset_t next_offset = offset + m_cfi_data.GetU32(&offset); - const dw_offset_t cie_id = m_cfi_data.GetU32(&offset); + const CIE *cie = GetCIE (cie_offset); + assert (cie != NULL); - bool is_fde = for_eh_frame ? cie_id != 0 : cie_id != UINT32_MAX; - if (is_fde) - { - dw_offset_t cie_offset; - if (for_eh_frame) - cie_offset = offset - (cie_id + 4); - else - cie_offset = cie_id; - - const CIE* cie = GetCIE(cie_offset); - assert(cie); - lldb::addr_t addr = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); - lldb::addr_t length = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); - m_fde_map[VMRange(addr, addr + length)] = FDEInfo(curr_offset); - } + const dw_offset_t end_offset = current_entry + length + 4; - offset = next_offset; - } - } -} + const lldb::addr_t pc_rel_addr = m_section->GetFileAddress(); + const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; + const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS; + lldb::addr_t range_base = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); + lldb::addr_t range_len = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); + AddressRange range (range_base, m_objfile.GetAddressByteSize(), m_objfile.GetSectionList()); + range.SetByteSize (range_len); -//---------------------------------------------------------------------- -// Parse instructions for a FDE. The initial instruction for the CIE -// are parsed first, then the instructions for the FDE are parsed -//---------------------------------------------------------------------- -void -DWARFCallFrameInfo::ParseInstructions(const CIE *cie, FDE *fde, dw_offset_t instr_offset, uint32_t instr_length) -{ - if (cie != NULL && fde == NULL) - return; + if (cie->augmentation[0] == 'z') + { + uint32_t aug_data_len = (uint32_t)m_cfi_data.GetULEB128(&offset); + offset += aug_data_len; + } uint32_t reg_num = 0; int32_t op_offset = 0; uint32_t tmp_uval32; uint32_t code_align = cie->code_align; int32_t data_align = cie->data_align; - typedef std::list RowStack; - RowStack row_stack; - Row row; - if (fde->IsValidRowIndex(0)) - row = fde->GetRowAtIndex(0); - - dw_offset_t offset = instr_offset; - const dw_offset_t end_offset = instr_offset + instr_length; - RegisterLocation reg_location; + unwind_plan.SetPlanValidAddressRange (range); + UnwindPlan::Row row = cie->initial_row; + + unwind_plan.SetRegisterKind (m_reg_kind); + + UnwindPlan::Row::RegisterLocation reg_location; while (m_cfi_data.ValidOffset(offset) && offset < end_offset) { uint8_t inst = m_cfi_data.GetU8(&offset); @@ -730,7 +397,7 @@ // value that is computed by taking the current entry's location // value and adding (delta * code_align). All other // values in the new row are initially identical to the current row. - fde->AppendRow(row); + unwind_plan.AppendRow(row); row.SlideOffset(extended_opcode * code_align); } break; @@ -758,9 +425,9 @@ // We only keep enough register locations around to // unwind what is in our thread, and these are organized // by the register index in that state, so we need to convert our - // GCC register number from the EH frame info, to a registe index + // GCC register number from the EH frame info, to a register index - if (fde->IsValidRowIndex(0) && fde->GetRowAtIndex(0).GetRegisterInfo(reg_num, reg_location)) + if (unwind_plan.IsValidRowIndex(0) && unwind_plan.GetRowAtIndex(0).GetRegisterInfo(reg_num, reg_location)) row.SetRegisterInfo (reg_num, reg_location); } break; @@ -780,8 +447,8 @@ // specified address as the location. All other values in the new row // are initially identical to the current row. The new location value // should always be greater than the current one. - fde->AppendRow(row); - row.SetOffset(m_cfi_data.GetPointer(&offset) - fde->GetAddressRange().GetBaseAddress().GetFileAddress()); + unwind_plan.AppendRow(row); + row.SetOffset(m_cfi_data.GetPointer(&offset) - startaddr.GetFileAddress()); } break; @@ -790,7 +457,7 @@ // takes a single uword argument that represents a constant delta. // This instruction is identical to DW_CFA_advance_loc except for the // encoding and size of the delta argument. - fde->AppendRow(row); + unwind_plan.AppendRow(row); row.SlideOffset (m_cfi_data.GetU8(&offset) * code_align); } break; @@ -800,7 +467,7 @@ // takes a single uword argument that represents a constant delta. // This instruction is identical to DW_CFA_advance_loc except for the // encoding and size of the delta argument. - fde->AppendRow(row); + unwind_plan.AppendRow(row); row.SlideOffset (m_cfi_data.GetU16(&offset) * code_align); } break; @@ -810,7 +477,7 @@ // takes a single uword argument that represents a constant delta. // This instruction is identical to DW_CFA_advance_loc except for the // encoding and size of the delta argument. - fde->AppendRow(row); + unwind_plan.AppendRow(row); row.SlideOffset (m_cfi_data.GetU32(&offset) * code_align); } break; @@ -833,7 +500,7 @@ // number. This instruction is identical to DW_CFA_restore except for // the encoding and size of the register argument. reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset); - if (fde->IsValidRowIndex(0) && fde->GetRowAtIndex(0).GetRegisterInfo(reg_num, reg_location)) + if (unwind_plan.IsValidRowIndex(0) && unwind_plan.GetRowAtIndex(0).GetRegisterInfo(reg_num, reg_location)) row.SetRegisterInfo (reg_num, reg_location); } break; @@ -881,7 +548,7 @@ // the stack and place them in the current row. (This operation is // useful for compilers that move epilogue code into the body of a // function.) - row_stack.push_back(row); + unwind_plan.AppendRow (row); break; case DW_CFA_restore_state : // 0xB @@ -893,8 +560,7 @@ // useful for compilers that move epilogue code into the body of a // function.) { - row = row_stack.back(); - row_stack.pop_back(); + row = unwind_plan.GetRowAtIndex(unwind_plan.GetRowCount() - 1); } break; @@ -1059,285 +725,7 @@ } } } - fde->AppendRow(row); -} + unwind_plan.AppendRow(row); -void -DWARFCallFrameInfo::ParseAll() -{ - Index(); - fde_map_t::iterator pos, end = m_fde_map.end(); - for (pos = m_fde_map.begin(); pos != end; ++ pos) - { - if (pos->second.fde_sp.get() == NULL) - pos->second.fde_sp = ParseFDE(pos->second.fde_offset); - } + return true; } - - -//bool -//DWARFCallFrameInfo::UnwindRegisterAtIndex -//( -// const uint32_t reg_idx, -// const Thread* currState, -// const DWARFCallFrameInfo::Row* row, -// mapped_memory_t * memCache, -// Thread* unwindState -//) -//{ -// bool get_reg_success = false; -// -// const RegLocation* regLocation = row->regs.GetRegisterInfo(reg_idx); -// -// // On some systems, we may not get unwind info for the program counter, -// // but the return address register can be used to get that information. -// if (reg_idx == currState->GetPCRegNum(Thread::Index)) -// { -// const RegLocation* returnAddrRegLocation = row->regs.GetRegisterInfo(currState->GetRARegNum(Thread::Index)); -// if (regLocation == NULL) -// { -// // We have nothing to the program counter, so lets see if this -// // thread state has a return address (link register) that can -// // help us track down the previous PC -// regLocation = returnAddrRegLocation; -// } -// else if (regLocation->type == RegLocation::unspecified) -// { -// // We did have a location that didn't specify a value for unwinding -// // the PC, so if there is a info for the return return address -// // register (link register) lets use that -// if (returnAddrRegLocation) -// regLocation = returnAddrRegLocation; -// } -// } -// -// if (regLocation) -// { -// mach_vm_address_t unwoundRegValue = INVALID_VMADDR; -// switch (regLocation->type) -// { -// case RegLocation::undefined: -// // Register is not available, mark it as invalid -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// return true; -// -// case RegLocation::unspecified: -// // Nothing to do if it is the same -// return true; -// -// case RegLocation::same: -// // Nothing to do if it is the same -// return true; -// -// case RegLocation::atFPPlusOffset: -// case RegLocation::isFPPlusOffset: -// { -// uint64_t unwindAddress = currState->GetRegisterValue(row->cfa_register, Thread::GCC, INVALID_VMADDR, &get_reg_success); -// -// if (get_reg_success) -// { -// unwindAddress += row->cfa_offset + regLocation->location.offset; -// -// if (regLocation->type == RegLocation::isFPPlusOffset) -// { -// unwindState->SetRegisterValue(reg_idx, Thread::Index, unwindAddress); -// return true; -// } -// else -// { -// kern_return_t err = mapped_memory_read_pointer(memCache, unwindAddress, &unwoundRegValue); -// if (err != KERN_SUCCESS) -// { -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// return false; -// } -// unwindState->SetRegisterValue(reg_idx, Thread::Index, unwoundRegValue); -// return true; -// } -// } -// else -// { -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// } -// return false; -// } -// break; -// -// case RegLocation::atDWARFExpression: -// case RegLocation::isDWARFExpression: -// { -// bool swap = false; -// DWARFExpressionBaton baton = { currState, memCache, swap }; -// uint64_t expr_result = 0; -// CSBinaryDataRef opcodes(regLocation->location.expr.opcodes, regLocation->location.expr.length, swap); -// opcodes.SetPointerSize(currState->Is64Bit() ? 8 : 4); -// const char * expr_err = CSDWARFExpression::Evaluate(DWARFExpressionReadMemoryDCScriptInterpreter::Type, -// DWARFExpressionReadRegisterDCScriptInterpreter::Type, -// &baton, -// opcodes, -// 0, -// regLocation->location.expr.length, -// NULL, -// expr_result); -// if (expr_err == NULL) -// { -// // SUCCESS! -// if (regLocation->type == RegLocation::isDWARFExpression) -// { -// unwindState->SetRegisterValue(reg_idx, Thread::Index, expr_result); -// return true; -// } -// else -// { -// kern_return_t err = mapped_memory_read_pointer(memCache, expr_result, &unwoundRegValue); -// if (err != KERN_SUCCESS) -// { -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// return false; -// } -// unwindState->SetRegisterValue(reg_idx, Thread::Index, unwoundRegValue); -// return true; -// } -// } -// else -// { -// // FAIL -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// } -// return false; -// } -// break; -// -// -// case RegLocation::inRegister: -// // The value is in another register. -// unwoundRegValue = currState->GetRegisterValue(regLocation->location.reg, Thread::GCC, 0, &get_reg_success); -// if (get_reg_success) -// { -// unwindState->SetRegisterValue(reg_idx, Thread::Index, unwoundRegValue); -// return true; -// } -// return false; -// -// default: -// break; -// } -// } -// -// if (reg_idx == currState->GetSPRegNum(Thread::Index)) -// { -// uint64_t cfa = currState->GetRegisterValue(row->cfa_register, Thread::GCC, 0, &get_reg_success); -// if (get_reg_success) -// { -// return unwindState->SetSP(cfa + row->cfa_offset); -// } -// else -// { -// unwindState->SetRegisterIsValid(reg_idx, Thread::Index, false); -// return false; -// } -// } -// -// return false; -//} - -void -DWARFCallFrameInfo::Dump(Stream *s, Thread *thread) const -{ - s->Indent(); - s->Printf("DWARFCallFrameInfo for "); - *s << m_objfile->GetFileSpec(); - if (m_flags.IsSet(eFlagParsedIndex)) - { - s->Printf(" (CIE[%zu], FDE[%zu])\n", m_cie_map.size(), m_fde_map.size()); - s->IndentMore(); - cie_map_t::const_iterator cie_pos, cie_end = m_cie_map.end(); - const ArchSpec *arch = &m_objfile->GetModule()->GetArchitecture(); - - for (cie_pos = m_cie_map.begin(); cie_pos != cie_end; ++ cie_pos) - { - if (cie_pos->second.get() == NULL) - { - s->Indent(); - s->Printf("CIE{0x%8.8x} - unparsed\n", cie_pos->first); - } - else - { - cie_pos->second->Dump(s, thread, arch, m_reg_kind); - } - } - - fde_map_t::const_iterator fde_pos, fde_end = m_fde_map.end(); - for (fde_pos = m_fde_map.begin(); fde_pos != fde_end; ++ fde_pos) - { - if (fde_pos->second.fde_sp.get() == NULL) - { - s->Indent(); - s->Printf("FDE{0x%8.8x} - unparsed\n", fde_pos->second.fde_offset); - } - else - { - fde_pos->second.fde_sp->Dump(s, *this, thread); - } - } - s->IndentLess(); - } - else - { - s->PutCString(" (not indexed yet)\n"); - } -} - - -//uint32_t -//DWARFCallFrameInfo::UnwindThreadState(const Thread* currState, mapped_memory_t *memCache, bool is_first_frame, Thread* unwindState) -//{ -// if (currState == NULL || unwindState == NULL) -// return 0; -// -// *unwindState = *currState; -// uint32_t numRegisterUnwound = 0; -// uint64_t currPC = currState->GetPC(INVALID_VMADDR); -// -// if (currPC != INVALID_VMADDR) -// { -// // If this is not the first frame, we care about the previous instruction -// // since it will be at the instruction following the instruction that -// // made the function call. -// uint64_t unwindPC = currPC; -// if (unwindPC > 0 && !is_first_frame) -// --unwindPC; -// -//#if defined(__i386__) || defined(__x86_64__) -// // Only on i386 do we have __IMPORT segments that contain trampolines -// if (!currState->Is64Bit() && ImportRangesContainsAddress(unwindPC)) -// { -// uint64_t curr_sp = currState->GetSP(INVALID_VMADDR); -// mach_vm_address_t pc = INVALID_VMADDR; -// unwindState->SetSP(curr_sp + 4); -// kern_return_t err = mapped_memory_read_pointer(memCache, curr_sp, &pc); -// if (err == KERN_SUCCESS) -// { -// unwindState->SetPC(pc); -// return 2; -// } -// } -//#endif -// FDE *fde = FindFDE(unwindPC); -// if (fde) -// { -// FindRowUserData rowUserData (currState, unwindPC); -// ParseInstructions (currState, fde, FindRowForAddress, &rowUserData); -// -// const uint32_t numRegs = currState->NumRegisters(); -// for (uint32_t regNum = 0; regNum < numRegs; regNum++) -// { -// if (UnwindRegisterAtIndex(regNum, currState, &rowUserData.state, memCache, unwindState)) -// numRegisterUnwound++; -// } -// } -// } -// return numRegisterUnwound; -//} - - Added: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (added) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,126 @@ +//===-- FuncUnwinders.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/lldb-private.h" +#include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Core/AddressRange.h" +#include "lldb/Core/Address.h" +#include "lldb/Symbol/UnwindTable.h" +#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" +#include "lldb/Symbol/DWARFCallFrameInfo.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + + +FuncUnwinders::FuncUnwinders (UnwindTable& unwind_table, UnwindAssemblyProfiler *assembly_profiler, AddressRange range) : + m_unwind_table(unwind_table), + m_assembly_profiler(assembly_profiler), + m_range(range), + m_unwind_at_call_site(NULL), + m_unwind_at_non_call_site(NULL), + m_fast_unwind(NULL), + m_arch_default_unwind(NULL), + m_first_non_prologue_insn() { } + +FuncUnwinders::~FuncUnwinders () +{ + if (m_unwind_at_call_site) + delete m_unwind_at_call_site; + if (m_unwind_at_non_call_site) + delete m_unwind_at_non_call_site; + if (m_fast_unwind) + delete m_fast_unwind; + if (m_arch_default_unwind) + delete m_arch_default_unwind; +} + +UnwindPlan* +FuncUnwinders::GetUnwindPlanAtCallSite () +{ + if (m_unwind_at_call_site != NULL) + return m_unwind_at_call_site; + if (!m_range.GetBaseAddress().IsValid()) + return NULL; + + DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); + if (eh_frame) + { + UnwindPlan *up = new UnwindPlan; + if (eh_frame->GetUnwindPlan (m_range.GetBaseAddress (), *up) == true) + { + m_unwind_at_call_site = up; + return m_unwind_at_call_site; + } + } + return NULL; +} + +UnwindPlan* +FuncUnwinders::GetUnwindPlanAtNonCallSite (Thread& thread) +{ + if (m_unwind_at_non_call_site != NULL) + m_unwind_at_non_call_site; + m_unwind_at_non_call_site = new UnwindPlan; + m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_at_non_call_site); + return m_unwind_at_non_call_site; +} + +UnwindPlan* +FuncUnwinders::GetUnwindPlanFastUnwind (Thread& thread) +{ + if (m_fast_unwind != NULL) + return m_fast_unwind; + m_fast_unwind = new UnwindPlan; + m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_fast_unwind); + return m_fast_unwind; +} + +UnwindPlan* +FuncUnwinders::GetUnwindPlanArchitectureDefault (Thread& thread) +{ + if (m_arch_default_unwind != NULL) + return m_arch_default_unwind; + + Address current_pc; + Target *target = thread.CalculateTarget(); + ArchSpec arch; + if (target) + { + ArchSpec arch = target->GetArchitecture (); + ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); + if (arch_default) + { + m_arch_default_unwind = arch_default->GetArchDefaultUnwindPlan (thread, current_pc); + } + } + + return m_arch_default_unwind; +} + +Address& +FuncUnwinders::GetFirstNonPrologueInsn (Target& target) +{ + if (m_first_non_prologue_insn.IsValid()) + return m_first_non_prologue_insn; + m_assembly_profiler->FirstNonPrologueInsn (m_range, target, NULL, m_first_non_prologue_insn); + return m_first_non_prologue_insn; +} + +const Address& +FuncUnwinders::GetFunctionStartAddress () const +{ + return m_range.GetBaseAddress(); +} + Added: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (added) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,309 @@ +//===-- UnwindPlan.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/Symbol/UnwindPlan.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/RegisterContext.h" + +using namespace lldb; +using namespace lldb_private; + +bool +UnwindPlan::Row::RegisterLocation::operator == (const UnwindPlan::Row::RegisterLocation& rhs) const +{ + if (m_type != rhs.m_type) + return false; + if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset) + return m_location.offset == rhs.m_location.offset; + if (m_type == inOtherRegister) + return m_location.reg_num == rhs.m_location.reg_num; + if (m_type == atDWARFExpression || m_type == isDWARFExpression) + if (m_location.expr.length == rhs.m_location.expr.length) + return !memcmp (m_location.expr.opcodes, rhs.m_location.expr.opcodes, m_location.expr.length); + return false; +} + +// This function doesn't copy the dwarf expression bytes; they must remain in allocated +// memory for the lifespan of this UnwindPlan object. +void +UnwindPlan::Row::RegisterLocation::SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len) +{ + m_type = atDWARFExpression; + m_location.expr.opcodes = opcodes; + m_location.expr.length = len; +} + +// This function doesn't copy the dwarf expression bytes; they must remain in allocated +// memory for the lifespan of this UnwindPlan object. +void +UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len) +{ + m_type = isDWARFExpression; + m_location.expr.opcodes = opcodes; + m_location.expr.length = len; +} + +void +UnwindPlan::Row::RegisterLocation::SetUnspecified () +{ + m_type = unspecified; +} + +void +UnwindPlan::Row::RegisterLocation::SetUndefined () +{ + m_type = isUndefined; +} + +void +UnwindPlan::Row::RegisterLocation::SetSame () +{ + m_type = isSame; +} + + +void +UnwindPlan::Row::RegisterLocation::SetAtCFAPlusOffset (int32_t offset) +{ + m_type = atCFAPlusOffset; + m_location.offset = offset; +} + +void +UnwindPlan::Row::RegisterLocation::SetIsCFAPlusOffset (int32_t offset) +{ + m_type = isCFAPlusOffset; + m_location.offset = offset; +} + +void +UnwindPlan::Row::RegisterLocation::SetInRegister (uint32_t reg_num) +{ + m_type = inOtherRegister; + m_location.reg_num = reg_num; +} + +void +UnwindPlan::Row::RegisterLocation::Dump (Stream &s) const +{ + switch (m_type) + { + case unspecified: + s.Printf ("unspecified"); + break; + case isUndefined: + s.Printf ("isUndefined"); + break; + case isSame: + s.Printf ("isSame"); + break; + case atCFAPlusOffset: + s.Printf ("atCFAPlusOffset %d", m_location.offset); + break; + case isCFAPlusOffset: + s.Printf ("isCFAPlusOffset %d", m_location.offset); + break; + case inOtherRegister: + s.Printf ("inOtherRegister %d", m_location.reg_num); + break; + case atDWARFExpression: + s.Printf ("atDWARFExpression"); + break; + case isDWARFExpression: + s.Printf ("isDWARFExpression"); + break; + } +} + +void +UnwindPlan::Row::Clear () +{ + m_offset = 0; + m_cfa_reg_num = 0; + m_cfa_offset = 0; + m_register_locations.clear(); +} + +void +UnwindPlan::Row::Dump (Stream& s, int register_kind, Thread* thread) const +{ + RegisterContext *rctx = NULL; + const RegisterInfo *rinfo = NULL; + int translated_regnum; + if (thread && thread->GetRegisterContext()) + { + rctx = thread->GetRegisterContext(); + } + s.Printf ("offset %ld, CFA reg ", (long) GetOffset()); + if (rctx + && (translated_regnum = rctx->ConvertRegisterKindToRegisterNumber (register_kind, GetCFARegister())) != -1 + && (rinfo = rctx->GetRegisterInfoAtIndex (translated_regnum)) != NULL + && rinfo->name != NULL + && rinfo->name[0] != '\0') + { + s.Printf ("%s, ", rinfo->name); + } + else + { + s.Printf ("%d, ", (int)(int) GetCFARegister()); + } + s.Printf ("CFA offset %d", (int) GetCFAOffset ()); + for (collection::const_iterator idx = m_register_locations.begin (); idx != m_register_locations.end (); ++idx) + { + s.Printf (" ["); + bool printed_name = false; + if (thread && thread->GetRegisterContext()) + { + rctx = thread->GetRegisterContext(); + translated_regnum = rctx->ConvertRegisterKindToRegisterNumber (register_kind, idx->first); + rinfo = rctx->GetRegisterInfoAtIndex (translated_regnum); + if (rinfo && rinfo->name) + { + s.Printf ("%s ", rinfo->name); + printed_name = true; + } + } + if (!printed_name) + { + s.Printf ("reg %d ", idx->first); + } + idx->second.Dump(s); + s.Printf ("]"); + } + s.Printf ("\n"); +} + +UnwindPlan::Row::Row() : + m_offset(0), + m_cfa_reg_num(0), + m_cfa_offset(0), + m_register_locations() +{ +} + +bool +UnwindPlan::Row::GetRegisterInfo (uint32_t reg_num, UnwindPlan::Row::RegisterLocation& register_location) const +{ + collection::const_iterator pos = m_register_locations.find(reg_num); + if (pos != m_register_locations.end()) + { + register_location = pos->second; + return true; + } + return false; +} + +void +UnwindPlan::Row::SetRegisterInfo (uint32_t reg_num, const UnwindPlan::Row::RegisterLocation register_location) +{ + m_register_locations[reg_num] = register_location; +} + + +void +UnwindPlan::AppendRow (const UnwindPlan::Row &row) +{ + if (m_row_list.empty() || m_row_list.back().GetOffset() != row.GetOffset()) + m_row_list.push_back(row); + else + m_row_list.back() = row; +} + +const UnwindPlan::Row * +UnwindPlan::GetRowForFunctionOffset (int offset) const +{ + const UnwindPlan::Row *rowp = NULL; + for (int i = 0; i < m_row_list.size(); ++i) + { + if (m_row_list[i].GetOffset() <= offset) + { + rowp = &m_row_list[i]; + } + else + { + break; + } + } + return rowp; +} + +bool +UnwindPlan::IsValidRowIndex (uint32_t idx) const +{ + return idx < m_row_list.size(); +} + +const UnwindPlan::Row& +UnwindPlan::GetRowAtIndex (uint32_t idx) const +{ + // You must call IsValidRowIndex(idx) first before calling this!!! + return m_row_list[idx]; +} + +int +UnwindPlan::GetRowCount () const +{ + return m_row_list.size (); +} + +void +UnwindPlan::SetRegisterKind (uint32_t rk) +{ + m_register_kind = rk; +} + +uint32_t +UnwindPlan::GetRegisterKind (void) const +{ + return m_register_kind; +} + +void +UnwindPlan::SetPlanValidAddressRange (const AddressRange& range) +{ + m_plan_valid_address_range = range; +// .GetBaseAddress() = addr; +// m_plan_valid_address_range.SetByteSize (range.GetByteSize()); +} + +bool +UnwindPlan::PlanValidAtAddress (Address addr) +{ + if (!m_plan_valid_address_range.GetBaseAddress().IsValid()) + return true; + + if (m_plan_valid_address_range.ContainsFileAddress (addr)) + return true; + + return false; +} + +void +UnwindPlan::Dump (Stream& s, Process* process, Thread *thread) const +{ + s.Printf ("Address range of this UnwindPlan: "); + m_plan_valid_address_range.Dump (&s, process, Address::DumpStyleSectionNameOffset); + s.Printf ("\n"); + s.Printf ("UnwindPlan register kind %d", m_register_kind); + switch (m_register_kind) + { + case eRegisterKindGCC: s.Printf (" [eRegisterKindGCC]"); break; + case eRegisterKindDWARF: s.Printf (" [eRegisterKindDWARF]"); break; + case eRegisterKindGeneric: s.Printf (" [eRegisterKindGeneric]"); break; + case eRegisterKindGDB: s.Printf (" [eRegisterKindGDB]"); break; + case eRegisterKindLLDB: s.Printf (" [eRegisterKindLLDB]"); break; + default: break; + } + s.Printf ("\n"); + for (int i = 0; IsValidRowIndex (i); i++) + { + s.Printf ("UnwindPlan row at index %d: ", i); + m_row_list[i].Dump(s, m_register_kind, thread); + } +} Added: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (added) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,132 @@ +//===-- UnwindTable.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/Symbol/ObjectFile.h" + +#include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Core/Section.h" +#include "lldb/Core/Module.h" +#include "lldb/lldb-forward.h" +#include "lldb/Utility/UnwindAssemblyProfiler.h" +#include "lldb/Symbol/DWARFCallFrameInfo.h" + +#include "lldb/Symbol/UnwindTable.h" +#include + +// There is one UnwindTable object per ObjectFile. +// It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile. +// Each Unwind object has multiple UnwindPlans for different scenarios. + +using namespace lldb; +using namespace lldb_private; + +UnwindTable::UnwindTable (ObjectFile& objfile) : m_object_file(objfile), + m_unwinds(), + m_initialized(false), + m_eh_frame(NULL), + m_assembly_profiler(NULL) +{ +} + +// We can't do some of this initialization when the ObjectFile is running its ctor; delay doing it +// until needed for something. + +void +UnwindTable::initialize () +{ + if (m_initialized) + return; + + SectionList* sl = m_object_file.GetSectionList (); + if (sl) + { + SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true); + if (sect.get()) + { + m_eh_frame = new DWARFCallFrameInfo(m_object_file, sect, eRegisterKindGCC, true); + } + } + + ArchSpec arch; + ConstString str; + m_object_file.GetTargetTriple (str); + arch.SetArchFromTargetTriple (str.GetCString()); + m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch); + + m_initialized = true; +} + +UnwindTable::~UnwindTable () +{ + if (m_eh_frame) + delete m_eh_frame; +} + +FuncUnwindersSP +UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc) +{ + FuncUnwindersSP no_unwind_found; + + initialize(); + + // Create a FuncUnwinders object for the binary search below + AddressRange search_range(addr, 1); + FuncUnwindersSP search_unwind(new FuncUnwinders (*this, NULL, search_range)); + + const_iterator idx; + idx = std::lower_bound (m_unwinds.begin(), m_unwinds.end(), search_unwind); + + bool found_match = true; + if (m_unwinds.size() == 0) + { + found_match = false; + } + else if (idx == m_unwinds.end()) + { + --idx; + } + if (idx != m_unwinds.begin() && (*idx)->GetFunctionStartAddress().GetOffset() != addr.GetOffset()) + { + --idx; + } + if (found_match && (*idx)->ContainsAddress (addr)) + { + return *idx; + } + + AddressRange range; + if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range)) + { + FuncUnwindersSP unw(new FuncUnwinders(*this, m_assembly_profiler, range)); + m_unwinds.push_back (unw); + std::sort (m_unwinds.begin(), m_unwinds.end()); + return unw; + } + else + { + // Does the eh_frame unwind info has a function bounds defined for this addr? + if (m_eh_frame->GetAddressRange (addr, range)) + { + FuncUnwindersSP unw(new FuncUnwinders(*this, m_assembly_profiler, range)); + m_unwinds.push_back (unw); + std::sort (m_unwinds.begin(), m_unwinds.end()); + return unw; + // FIXME we should create a syntheic Symbol based on the address range with a synthesized symbol name + } + } + return no_unwind_found; +} + +DWARFCallFrameInfo * +UnwindTable::GetEHFrameInfo () +{ + initialize(); + return m_eh_frame; +} Modified: lldb/trunk/source/Target/RegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/Target/RegisterContext.cpp (original) +++ lldb/trunk/source/Target/RegisterContext.cpp Fri Sep 10 02:49:16 2010 @@ -235,4 +235,26 @@ } +bool +RegisterContext::ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t target_regnum) +{ + const uint32_t num_registers = GetRegisterCount(); + for (uint32_t reg = 0; reg < num_registers; ++reg) + { + const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg); + if (reg_info->kinds[source_rk] == source_regnum) + { + target_regnum = reg_info->kinds[target_rk]; + if (target_regnum == LLDB_INVALID_REGNUM) + { + return false; + } + else + { + return true; + } + } + } + return false; +} Added: lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (added) +++ lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,40 @@ +//===-- ArchDefaultUnwindPlan.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb-private.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/PluginInterface.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" + +using namespace lldb; +using namespace lldb_private; + +ArchDefaultUnwindPlan* +ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch) +{ + ArchDefaultUnwindPlanCreateInstance create_callback; + + for (uint32_t idx = 0; + (create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL; + ++idx) + { + std::auto_ptr default_unwind_plan_ap (create_callback (arch)); + if (default_unwind_plan_ap.get ()) + return default_unwind_plan_ap.release (); + } + return NULL; +} + +ArchDefaultUnwindPlan::ArchDefaultUnwindPlan () +{ +} + +ArchDefaultUnwindPlan::~ArchDefaultUnwindPlan () +{ +} Added: lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp?rev=113581&view=auto ============================================================================== --- lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp (added) +++ lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Fri Sep 10 02:49:16 2010 @@ -0,0 +1,40 @@ +//===-- UnwindAssemblyProfiler.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb-private.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/PluginInterface.h" +#include "lldb/Utility/UnwindAssemblyProfiler.h" + +using namespace lldb; +using namespace lldb_private; + +UnwindAssemblyProfiler* +UnwindAssemblyProfiler::FindPlugin (const ArchSpec &arch) +{ + UnwindAssemblyProfilerCreateInstance create_callback; + + for (uint32_t idx = 0; + (create_callback = PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex(idx)) != NULL; + ++idx) + { + std::auto_ptr assembly_profiler_ap (create_callback (arch)); + if (assembly_profiler_ap.get ()) + return assembly_profiler_ap.release (); + } + return NULL; +} + +UnwindAssemblyProfiler::UnwindAssemblyProfiler () +{ +} + +UnwindAssemblyProfiler::~UnwindAssemblyProfiler () +{ +} Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=113581&r1=113580&r2=113581&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Fri Sep 10 02:49:16 2010 @@ -22,6 +22,8 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" +#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" +#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" #ifdef __APPLE__ #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" @@ -63,6 +65,8 @@ SymbolFileDWARF::Initialize(); SymbolFileDWARFDebugMap::Initialize(); SymbolFileSymtab::Initialize(); + UnwindAssemblyProfiler_x86::Initialize(); + ArchDefaultUnwindPlan_x86::Initialize(); #ifdef __APPLE__ ABIMacOSX_i386::Initialize(); @@ -99,6 +103,8 @@ SymbolFileDWARF::Terminate(); SymbolFileDWARFDebugMap::Terminate(); SymbolFileSymtab::Terminate(); + UnwindAssemblyProfiler_x86::Terminate(); + ArchDefaultUnwindPlan_x86::Terminate(); #ifdef __APPLE__ DynamicLoaderMacOSXDYLD::Terminate(); From johnny.chen at apple.com Fri Sep 10 11:19:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 16:19:10 -0000 Subject: [Lldb-commits] [lldb] r113589 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100910161910.A892F2A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 11:19:10 2010 New Revision: 113589 URL: http://llvm.org/viewvc/llvm-project?rev=113589&view=rev Log: Don't flatten lldb and import everything into the global namespace. Instead, set the debugger_unique_id with the lldb prefix. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113589&r1=113588&r2=113589&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 10 11:19:10 2010 @@ -196,7 +196,7 @@ if (success == 0) { // Import the Script Bridge module. - success = PyRun_SimpleString ("from lldb import *"); + success = PyRun_SimpleString ("import lldb"); } const char *pty_slave_name = GetScriptInterpreterPtyName (); @@ -241,7 +241,7 @@ PyRun_SimpleString ("tcsetattr (new_stdin, TCSANOW, new_mode)"); run_string.Clear(); - run_string.Printf ("debugger_unique_id = %d", interpreter.GetDebugger().GetID()); + run_string.Printf ("lldb.debugger_unique_id = %d", interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); } From johnny.chen at apple.com Fri Sep 10 13:21:11 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 18:21:11 -0000 Subject: [Lldb-commits] [lldb] r113596 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectBreakpointCommand.cpp source/Interpreter/ScriptInterpreterPython.cpp test/conditional_break/TestConditionalBreak.py Message-ID: <20100910182111.34A9A2A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 13:21:10 2010 New Revision: 113596 URL: http://llvm.org/viewvc/llvm-project?rev=113596&view=rev Log: Added the capability to specify a one-liner Python script as the callback command for a breakpoint, for example: (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" The ScriptInterpreter interface has an extra method: /// Set a one-liner as the callback for the breakpoint command. virtual void SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, const char *oneliner); to accomplish the above. Also added a test case to demonstrate lldb's use of breakpoint callback command to stop at function c() only when its immediate caller is function a(). The following session shows the user entering the following commands: 1) command source .lldb (set up executable, breakpoint, and breakpoint command) 2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a()) 3) bt (to see that indeed c()'s immediate caller is a()) 4) c (to continue and finish the program) test/conditional_break $ ../../build/Debug/lldb (lldb) command source .lldb Executing commands in '.lldb'. (lldb) file a.out Current executable set to 'a.out' (x86_64). (lldb) breakpoint set -n c Breakpoint created: 1: name = 'c', locations = 1 (lldb) script import sys, os (lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir)) (lldb) script import conditional_break (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" (lldb) run run Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out' (x86_64) (lldb) Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`a at main.c:25 frame #3: a.out`main at main.c:44 frame #4: a.out`start c called from b Continuing... Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`main at main.c:47 frame #3: a.out`start c called from b Continuing... Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`a at main.c:27 frame #2: a.out`main at main.c:50 frame #3: a.out`start c called from a Stopped at c() with immediate caller as a(). a(1) returns 4 b(2) returns 5 Process 20420 Stopped * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 36 37 int c(int val) 38 { 39 -> return val + 3; 40 } 41 42 int main (int argc, char const *argv[]) (lldb) bt bt thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39 frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27 frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50 frame #3: 0x0000000100000d88 a.out`start + 52 (lldb) c c Resuming process 20420 Process 20420 Exited a(3) returns 6 (lldb) Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=113596&r1=113595&r2=113596&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Sep 10 13:21:10 2010 @@ -77,6 +77,15 @@ BreakpointOptions *bp_options, CommandReturnObject &result); + /// Set a one-liner as the callback for the breakpoint command. + virtual void + SetBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, + const char *oneliner) + { + return; + } + const char * GetScriptInterpreterPtyName (); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=113596&r1=113595&r2=113596&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Sep 10 13:21:10 2010 @@ -62,6 +62,12 @@ BreakpointOptions *bp_options, CommandReturnObject &result); + /// Set a one-liner as the callback for the breakpoint command. + void + SetBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, + const char *oneliner); + StringList ReadCommandInputFromUser (FILE *in_file); Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113596&r1=113595&r2=113596&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 13:21:10 2010 @@ -258,9 +258,15 @@ { if (m_options.m_use_script_language) { - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp_loc_sp->GetLocationOptions(), - result); + // Special handling for one-liner. + if (command.GetArgumentCount() == 2) + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, + bp_loc_sp->GetLocationOptions(), + command.GetArgumentAtIndex(1)); + else + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, + bp_loc_sp->GetLocationOptions(), + result); } else { @@ -274,9 +280,15 @@ { if (m_options.m_use_script_language) { - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp->GetOptions(), - result); + // Special handling for one-liner. + if (command.GetArgumentCount() == 2) + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, + bp->GetOptions(), + command.GetArgumentAtIndex(1)); + else + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, + bp->GetOptions(), + result); } else { Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113596&r1=113595&r2=113596&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 10 13:21:10 2010 @@ -653,6 +653,26 @@ } } +// Set a Python one-liner as the callback for the breakpoint command. +void +ScriptInterpreterPython::SetBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, + const char *oneliner) +{ + std::auto_ptr data_ap(new BreakpointOptions::CommandData()); + + // It's necessary to set both user_source and script_source to the oneliner. + // The former is used to generate callback description (as in breakpoint command list) + // while the latter is used for Python to interpret during the actual callback. + data_ap->user_source.AppendString (oneliner); + data_ap->script_source.AppendString (oneliner); + + BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); + bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); + + return; +} + bool ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter (StringList &function_def) { Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113596&r1=113595&r2=113596&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Fri Sep 10 13:21:10 2010 @@ -13,16 +13,27 @@ mydir = "conditional_break" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_with_dsym(self): + def test_with_dsym_python(self): """Exercise some thread and frame APIs to break if c() is called by a().""" self.buildDsym() self.do_conditional_break() - def test_with_dwarf(self): + def test_with_dwarf_python(self): """Exercise some thread and frame APIs to break if c() is called by a().""" self.buildDwarf() self.do_conditional_break() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_command(self): + """Simulate a user using lldb commands to break on c() if called from a().""" + self.buildDsym() + self.simulate_conditional_break_by_user() + + def test_with_dwarf_command(self): + """Simulate a user using lldb commands to break on c() if called from a().""" + self.buildDwarf() + self.simulate_conditional_break_by_user() + def do_conditional_break(self): """Exercise some thread and frame APIs to break if c() is called by a().""" exe = os.path.join(os.getcwd(), "a.out") @@ -70,6 +81,33 @@ #process.Continue() self.runCmd("process continue") + def simulate_conditional_break_by_user(self): + """Simulate a user using lldb commands to break on c() if called from a().""" + + # Sourcing .lldb in the current working directory, which sets the main + # executable, sets the breakpoint on c(), and adds the callback for the + # breakpoint such that lldb only stops when the caller of c() is a(). + # the "my" package that defines the date() function. + self.runCmd("command source .lldb") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', 'stop reason = breakpoint']) + + # The frame info for frame #0 points to a.out`c and its immediate caller + # (frame #1) points to a.out`a. + + self.expect("frame info", "We should stop at c()", + substrs = ["a.out`c"]) + + # Select our parent frame as the current frame. + self.runCmd("frame select 1") + self.expect("frame info", "The immediate caller should be a()", + substrs = ["a.out`a"]) + + if __name__ == '__main__': import atexit From johnny.chen at apple.com Fri Sep 10 13:28:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 18:28:27 -0000 Subject: [Lldb-commits] [lldb] r113598 - in /lldb/trunk/test/conditional_break: .lldb conditional_break.py Message-ID: <20100910182827.A011F2A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 13:28:27 2010 New Revision: 113598 URL: http://llvm.org/viewvc/llvm-project?rev=113598&view=rev Log: These two files should have been in r113596. Oops! Added: lldb/trunk/test/conditional_break/.lldb lldb/trunk/test/conditional_break/conditional_break.py Added: lldb/trunk/test/conditional_break/.lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/.lldb?rev=113598&view=auto ============================================================================== --- lldb/trunk/test/conditional_break/.lldb (added) +++ lldb/trunk/test/conditional_break/.lldb Fri Sep 10 13:28:27 2010 @@ -0,0 +1,7 @@ +file a.out +breakpoint set -n c +script import sys, os +script sys.path.append(os.path.join(os.getcwd(), os.pardir)) +script import conditional_break +breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" + Added: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=113598&view=auto ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (added) +++ lldb/trunk/test/conditional_break/conditional_break.py Fri Sep 10 13:28:27 2010 @@ -0,0 +1,27 @@ +import sys +import lldb +import lldbutil + +def stop_if_called_from_a(): + dbg = lldb.SBDebugger.FindDebuggerWithID(lldb.debugger_unique_id) + dbg.SetAsync(False) + ci = dbg.GetCommandInterpreter() + res = lldb.SBCommandReturnObject() + + target = dbg.GetSelectedTarget() + process = target.GetProcess() + thread = process.GetThreadAtIndex(0) + + print >> sys.stderr, "Checking call frames..." + lldbutil.PrintStackTrace(thread) + if thread.GetNumFrames() >= 2: + funcs = lldbutil.GetFunctionNames(thread) + print >> sys.stderr, funcs[0], "called from", funcs[1] + if (funcs[0] == 'c' and funcs[1] == 'a'): + print >> sys.stderr, "Stopped at c() with immediate caller as a()." + else: + print >> sys.stderr, "Continuing..." + ci.HandleCommand("process continue", res) + + return True + From ctice at apple.com Fri Sep 10 13:31:03 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 10 Sep 2010 11:31:03 -0700 Subject: [Lldb-commits] [lldb] r113575 - in /lldb/trunk: include/lldb/API/SBFileSpec.h include/lldb/Core/FileSpec.h include/lldb/Host/Host.h source/API/SBFileSpec.cpp source/Commands/CommandObjectFile.cpp source/Core/FileSpec.cpp source/Host/common/Host.cpp source/Target/TargetList.cpp tools/driver/Driver.cpp In-Reply-To: References: <20100910044856.275C02A6C12C@llvm.org> Message-ID: <2B2C2F0D-8C44-464F-8EB9-E63FB95CCA5E@apple.com> I was unaware of that function in llvm; I will change my lldb stuff to use it. -- Caroline On Sep 9, 2010, at 10:28 PM, Chris Lattner wrote: > > On Sep 9, 2010, at 9:48 PM, Caroline Tice wrote: > >> Author: ctice >> Date: Thu Sep 9 23:48:55 2010 >> New Revision: 113575 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=113575&view=rev >> Log: >> If the file the user specifies can't be found in the current directory, >> and the user didn't specify a particular directory, search for the file >> using the $PATH environment variable. > > Cool, thanks for doing this Caroline. Did you consider using llvm::sys::Program::FindProgramByName? It already handles this, as well as handling the other annoying cases on windows. In general, we should aim to reuse existing support stuff that LLVM provides rather than reinvent it. The corresponding header is "llvm/System/Program.h". > > -Chris > >> >> >> Modified: >> lldb/trunk/include/lldb/API/SBFileSpec.h >> lldb/trunk/include/lldb/Core/FileSpec.h >> lldb/trunk/include/lldb/Host/Host.h >> lldb/trunk/source/API/SBFileSpec.cpp >> lldb/trunk/source/Commands/CommandObjectFile.cpp >> lldb/trunk/source/Core/FileSpec.cpp >> lldb/trunk/source/Host/common/Host.cpp >> lldb/trunk/source/Target/TargetList.cpp >> lldb/trunk/tools/driver/Driver.cpp >> >> Modified: lldb/trunk/include/lldb/API/SBFileSpec.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) >> +++ lldb/trunk/include/lldb/API/SBFileSpec.h Thu Sep 9 23:48:55 2010 >> @@ -36,6 +36,9 @@ >> bool >> Exists () const; >> >> + bool >> + ResolveExecutableLocation (); >> + >> const char * >> GetFilename() const; >> >> >> Modified: lldb/trunk/include/lldb/Core/FileSpec.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/Core/FileSpec.h (original) >> +++ lldb/trunk/include/lldb/Core/FileSpec.h Thu Sep 9 23:48:55 2010 >> @@ -261,6 +261,21 @@ >> bool >> Exists () const; >> >> + >> + //------------------------------------------------------------------ >> + /// Expanded existence test. >> + /// >> + /// Call into the Host to see if it can help find the file (e.g. by >> + /// searching paths set in the environment, etc.). >> + /// >> + /// If found, sets the value of m_directory to the directory where the file was found. >> + /// >> + /// @return >> + /// \b true if was able to find the file using expanded search methods, \b false otherwise. >> + //------------------------------------------------------------------ >> + bool >> + ResolveExecutableLocation (); >> + >> uint64_t >> GetByteSize() const; >> >> >> Modified: lldb/trunk/include/lldb/Host/Host.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/Host/Host.h (original) >> +++ lldb/trunk/include/lldb/Host/Host.h Thu Sep 9 23:48:55 2010 >> @@ -258,6 +258,9 @@ >> >> static bool >> ResolveExecutableInBundle (FileSpec *file); >> + >> + static bool >> + ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename); >> >> static uint32_t >> ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); >> >> Modified: lldb/trunk/source/API/SBFileSpec.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/source/API/SBFileSpec.cpp (original) >> +++ lldb/trunk/source/API/SBFileSpec.cpp Thu Sep 9 23:48:55 2010 >> @@ -61,6 +61,13 @@ >> return false; >> } >> >> +bool >> +SBFileSpec::ResolveExecutableLocation () >> +{ >> + if (m_opaque_ap.get()) >> + return m_opaque_ap->ResolveExecutableLocation (); >> + return false; >> +} >> >> int >> SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len) >> >> Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) >> +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Thu Sep 9 23:48:55 2010 >> @@ -117,7 +117,7 @@ >> { >> FileSpec file_spec (file_path); >> >> - if (! file_spec.Exists()) >> + if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) >> { >> result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); >> result.SetStatus (eReturnStatusFailed); >> >> Modified: lldb/trunk/source/Core/FileSpec.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/source/Core/FileSpec.cpp (original) >> +++ lldb/trunk/source/Core/FileSpec.cpp Thu Sep 9 23:48:55 2010 >> @@ -22,6 +22,7 @@ >> #include "lldb/Core/DataBufferHeap.h" >> #include "lldb/Core/DataBufferMemoryMap.h" >> #include "lldb/Core/Stream.h" >> +#include "lldb/Host/Host.h" >> >> using namespace lldb; >> using namespace lldb_private; >> @@ -414,6 +415,12 @@ >> return GetFileStats (this, &file_stats); >> } >> >> +bool >> +FileSpec::ResolveExecutableLocation () >> +{ >> + return Host::ResolveExecutableLocation (m_directory, m_filename); >> +} >> + >> uint64_t >> FileSpec::GetByteSize() const >> { >> >> Modified: lldb/trunk/source/Host/common/Host.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/source/Host/common/Host.cpp (original) >> +++ lldb/trunk/source/Host/common/Host.cpp Thu Sep 9 23:48:55 2010 >> @@ -727,3 +727,59 @@ >> return false; >> } >> #endif >> + >> +bool >> +Host::ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename) >> +{ >> + // If the user specified just a plain filename, there may be additional ways to find the >> + // file, such as searching the PATH environment variable on UNIX systems. This is the location >> + // to implement such additional searches. >> + >> + // For now the only search we are implementing is search $PATH, which makes no sense if >> + // the user already specified a directory. >> + >> + if (directory_name.GetLength() > 0) >> + return false; >> + >> + std::string search_path (getenv ("PATH")); >> + char dir_separator = ':'; >> + >> + bool done = false; >> + bool found = false; >> + size_t start = 0; >> + while (!done && !found) >> + { >> + size_t end = search_path.find (dir_separator, start); >> + size_t length; >> + if (end == std::string::npos) >> + { >> + done = true; >> + length = search_path.length() - start; >> + } >> + else >> + length = end - start; >> + >> + std::string directory_str = search_path.substr (start, length); >> + >> + if (directory_str.length() > 0) >> + { >> + StreamString tmp_full_path_name; >> + if (directory_str[directory_str.length()-1] == '/') >> + tmp_full_path_name.Printf ("%s%s", directory_str.c_str(), filename.AsCString()); >> + else >> + tmp_full_path_name.Printf ("%s/%s", directory_str.c_str(), filename.AsCString()); >> + >> + struct stat sb; >> + >> + if (::stat (tmp_full_path_name.GetData(), &sb) == 0) >> + { >> + found = true; >> + directory_name.SetCString (directory_str.c_str()); >> + } >> + } >> + >> + if (!done) >> + start = end + 1; >> + } >> + return found; >> +} >> >> Modified: lldb/trunk/source/Target/TargetList.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/source/Target/TargetList.cpp (original) >> +++ lldb/trunk/source/Target/TargetList.cpp Thu Sep 9 23:48:55 2010 >> @@ -71,6 +71,10 @@ >> { >> ModuleSP exe_module_sp; >> FileSpec resolved_file(file); >> + >> + if (!resolved_file.Exists()) >> + resolved_file.ResolveExecutableLocation (); >> + >> if (!Host::ResolveExecutableInBundle (&resolved_file)) >> resolved_file = file; >> >> >> Modified: lldb/trunk/tools/driver/Driver.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113575&r1=113574&r2=113575&view=diff >> ============================================================================== >> --- lldb/trunk/tools/driver/Driver.cpp (original) >> +++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 9 23:48:55 2010 >> @@ -527,6 +527,13 @@ >> SBFileSpec file(optarg); >> if (file.Exists()) >> m_option_data.m_filename = optarg; >> + else if (file.ResolveExecutableLocation()) >> + { >> + char path[PATH_MAX]; >> + int path_len; >> + file.GetPath (path, path_len); >> + m_option_data.m_filename = path; >> + } >> else >> error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); >> } >> @@ -550,6 +557,14 @@ >> SBFileSpec file(optarg); >> if (file.Exists()) >> m_option_data.m_source_command_files.push_back (optarg); >> + else if (file.ResolveExecutableLocation()) >> + { >> + char final_path[PATH_MAX]; >> + size_t path_len; >> + file.GetPath (final_path, path_len); >> + std::string path_str (final_path); >> + m_option_data.m_source_command_files.push_back (path_str); >> + } >> else >> error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); >> } >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From gclayton at apple.com Fri Sep 10 13:31:35 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Sep 2010 18:31:35 -0000 Subject: [Lldb-commits] [lldb] r113599 - in /lldb/trunk: examples/ examples/lookup/ examples/lookup/main.cpp include/lldb/API/SBAddress.h include/lldb/API/SBModule.h include/lldb/API/SBSymbolContext.h include/lldb/API/SBSymbolContextList.h lldb.xcodeproj/project.pbxproj source/API/SBAddress.cpp source/API/SBModule.cpp source/API/SBSymbolContext.cpp source/API/SBSymbolContextList.cpp source/Core/Timer.cpp Message-ID: <20100910183135.6F6C92A6C12C@llvm.org> Author: gclayton Date: Fri Sep 10 13:31:35 2010 New Revision: 113599 URL: http://llvm.org/viewvc/llvm-project?rev=113599&view=rev Log: Added some missing API for address resolving within a module, and looking up a seciton offset address (SBAddress) within a module that returns a symbol context (SBSymbolContext). Also added a SBSymbolContextList in preparation for adding find/lookup APIs that can return multiple results. Added a lookup example code that shows how to do address lookups. Added: lldb/trunk/examples/ lldb/trunk/examples/lookup/ lldb/trunk/examples/lookup/main.cpp lldb/trunk/include/lldb/API/SBSymbolContextList.h lldb/trunk/source/API/SBSymbolContextList.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBSymbolContext.cpp lldb/trunk/source/Core/Timer.cpp Added: lldb/trunk/examples/lookup/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/lookup/main.cpp?rev=113599&view=auto ============================================================================== --- lldb/trunk/examples/lookup/main.cpp (added) +++ lldb/trunk/examples/lookup/main.cpp Fri Sep 10 13:31:35 2010 @@ -0,0 +1,105 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include + +#include "lldb/API/SBBlock.h" +#include "lldb/API/SBCompileUnit.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBFunction.h" +#include "lldb/API/SBModule.h" +#include "lldb/API/SBSymbol.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" +#include "lldb/API/SBProcess.h" + +using namespace lldb; + +//---------------------------------------------------------------------- +// This quick sample code shows how to create a debugger instance and +// create an "i386" executable target. Then we can lookup the executable +// module and resolve a file address into a section offset address, +// and find all symbol context objects (if any) for that address: +// compile unit, function, deepest block, line table entry and the +// symbol. +//---------------------------------------------------------------------- +int +main (int argc, char const *argv[]) +{ + // Initialize LLDB + SBDebugger::Initialize(); + + if (argc < 3) + exit (1); + + // The first argument is the file path we want to look something up in + const char *exe_file_path = argv[1]; + // The second arguemnt in the address that we want to lookup + lldb::addr_t file_addr = strtoull (argv[2], NULL, 0); + + // Make a file spec out of our executable path + SBFileSpec exe_file_spec (exe_file_path); + + // Create a debugger instance so we can create a target + SBDebugger debugger (SBDebugger::Create()); + + if (debugger.IsValid()) + { + // Create a target using the executable. + SBTarget target (debugger.CreateTargetWithFileAndArch (exe_file_path, "i386")); + if (target.IsValid()) + { + // Find the executable module so we can do a lookup inside it + SBModule module (target.FindModule (exe_file_spec)); + SBAddress addr; + + // Take a file virtual address and resolve it to a section offset + // address that can be used to do a symbol lookup by address + if (module.ResolveFileAddress (file_addr, addr)) + { + // We can resolve a section offset address in the module + // and only ask for what we need. You can logical or together + // bits from the SymbolContextItem enumeration found in + // lldb-enumeration.h to request only what you want. Here we + // are asking for everything. + // + // NOTE: the less you ask for, the less LLDB will parse as + // LLDB does partial parsing on just about everything. + SBSymbolContext symbol_context (module.ResolveSymbolContextForAddress (addr, eSymbolContextEverything)); + + SBCompileUnit comp_unit (symbol_context.GetCompileUnit()); + if (comp_unit.IsValid()) + { + } + SBFunction function (symbol_context.GetFunction()); + if (function.IsValid()) + { + } + SBBlock block (symbol_context.GetBlock()); + if (block.IsValid()) + { + } + SBLineEntry line_entry (symbol_context.GetLineEntry()); + if (line_entry.IsValid()) + { + } + SBSymbol symbol (symbol_context.GetSymbol()); + if (symbol.IsValid()) + { + } + } + } + } + + // Terminate LLDB + SBDebugger::Terminate(); + return 0; +} + Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Fri Sep 10 13:31:35 2010 @@ -32,6 +32,9 @@ bool IsValid () const; + void + Clear (); + addr_t GetFileAddress () const; @@ -45,17 +48,24 @@ friend class SBFrame; friend class SBLineEntry; + friend class SBModule; friend class SBSymbolContext; friend class SBThread; #ifndef SWIG + lldb_private::Address * + operator->(); + const lldb_private::Address * operator->() const; const lldb_private::Address & operator*() const; + lldb_private::Address & + operator*(); + #endif Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Fri Sep 10 13:31:35 2010 @@ -11,6 +11,7 @@ #define LLDB_SBModule_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBSymbolContext.h" namespace lldb { @@ -40,6 +41,13 @@ #endif + bool + ResolveFileAddress (lldb::addr_t vm_addr, + lldb::SBAddress& addr); + + lldb::SBSymbolContext + ResolveSymbolContextForAddress (const lldb::SBAddress& addr, + uint32_t resolve_scope); private: friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Fri Sep 10 13:31:35 2010 @@ -46,17 +46,25 @@ protected: friend class SBFrame; + friend class SBModule; friend class SBThread; + friend class SBSymbolContextList; #ifndef SWIG lldb_private::SymbolContext* operator->() const; + lldb_private::SymbolContext& + operator*(); + + const lldb_private::SymbolContext& + operator*() const; + #endif lldb_private::SymbolContext * - GetLLDBObjectPtr() const; + get() const; SBSymbolContext (const lldb_private::SymbolContext *sc_ptr); Added: lldb/trunk/include/lldb/API/SBSymbolContextList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContextList.h?rev=113599&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContextList.h (added) +++ lldb/trunk/include/lldb/API/SBSymbolContextList.h Fri Sep 10 13:31:35 2010 @@ -0,0 +1,60 @@ +//===-- SBSymbolContextList.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_SBSymbolContextList_h_ +#define LLDB_SBSymbolContextList_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBSymbolContext.h" + +namespace lldb { + +class SBSymbolContextList +{ +public: + SBSymbolContextList (); + + SBSymbolContextList (const lldb::SBSymbolContextList& rhs); + + ~SBSymbolContextList (); + +#ifndef SWIG + const lldb::SBSymbolContextList & + operator = (const lldb::SBSymbolContextList &rhs); +#endif + + bool + IsValid () const; + + uint32_t + GetSize() const; + + SBSymbolContext + GetContextAtIndex (uint32_t idx); + +protected: + +#ifndef SWIG + + lldb_private::SymbolContextList* + operator->() const; + + lldb_private::SymbolContextList& + operator*() const; + +#endif + +private: + std::auto_ptr m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBSymbolContextList_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 10 13:31:35 2010 @@ -63,6 +63,8 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; + 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; }; + 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D27C9D11ED3A4E0024D721 /* ELFHeader.cpp */; }; @@ -567,6 +569,8 @@ 2689B0A4113EE3CD00A4AEDB /* Symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Symbols.h; path = include/lldb/Host/Symbols.h; sourceTree = ""; }; 2689B0B5113EE47E00A4AEDB /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Symbols.cpp; path = source/Host/macosx/Symbols.cpp; sourceTree = ""; }; 268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = ""; }; + 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = ""; }; + 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; 269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = ""; }; 26A0604711A5BC7A00F75969 /* Baton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Core/Baton.h; sourceTree = ""; }; @@ -1479,6 +1483,8 @@ 26DE20641161904E00A093E2 /* SBSymbol.cpp */, 26DE204011618AB900A093E2 /* SBSymbolContext.h */, 26DE204611618AED00A093E2 /* SBSymbolContext.cpp */, + 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */, + 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */, 9A9831081125FC5800A56CB0 /* SBTarget.h */, 9A9831071125FC5800A56CB0 /* SBTarget.cpp */, 9A98310A1125FC5800A56CB0 /* SBThread.h */, @@ -2264,6 +2270,7 @@ 49CF9834122C718B007A0B96 /* IRDynamicChecks.h in Headers */, 961FABEB1235F26800F93A47 /* UnwindAssemblyProfiler-x86.h in Headers */, 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */, + 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2726,6 +2733,7 @@ 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */, 69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */, 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */, + 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Fri Sep 10 13:31:35 2010 @@ -55,6 +55,12 @@ } void +SBAddress::Clear () +{ + m_opaque_ap.reset(); +} + +void SBAddress::SetAddress (const lldb_private::Address *lldb_object_ptr) { if (lldb_object_ptr) @@ -102,6 +108,11 @@ return false; } +lldb_private::Address * +SBAddress::operator->() +{ + return m_opaque_ap.get(); +} const lldb_private::Address * SBAddress::operator->() const @@ -109,9 +120,18 @@ return m_opaque_ap.get(); } +lldb_private::Address & +SBAddress::operator*() +{ + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new lldb_private::Address); + return *m_opaque_ap; +} + const lldb_private::Address & SBAddress::operator*() const { + assert (m_opaque_ap.get()); return *m_opaque_ap; } Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Fri Sep 10 13:31:35 2010 @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBModule.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpec.h" #include "lldb/Core/Module.h" @@ -105,3 +107,23 @@ m_opaque_sp = module_sp; } + +bool +SBModule::ResolveFileAddress (lldb::addr_t vm_addr, SBAddress& addr) +{ + if (m_opaque_sp) + return m_opaque_sp->ResolveFileAddress (vm_addr, *addr); + + addr->Clear(); + return false; +} + +SBSymbolContext +SBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) +{ + SBSymbolContext sb_sc; + if (m_opaque_sp && addr.IsValid()) + m_opaque_sp->ResolveSymbolContextForAddress (*addr, resolve_scope, *sb_sc); + return sb_sc; +} + Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Fri Sep 10 13:31:35 2010 @@ -123,8 +123,25 @@ return m_opaque_ap.get(); } + +const lldb_private::SymbolContext& +SBSymbolContext::operator*() const +{ + assert (m_opaque_ap.get()); + return *m_opaque_ap.get(); +} + + +lldb_private::SymbolContext& +SBSymbolContext::operator*() +{ + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new SymbolContext); + return *m_opaque_ap.get(); +} + lldb_private::SymbolContext * -SBSymbolContext::GetLLDBObjectPtr() const +SBSymbolContext::get() const { return m_opaque_ap.get(); } Added: lldb/trunk/source/API/SBSymbolContextList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContextList.cpp?rev=113599&view=auto ============================================================================== --- lldb/trunk/source/API/SBSymbolContextList.cpp (added) +++ lldb/trunk/source/API/SBSymbolContextList.cpp Fri Sep 10 13:31:35 2010 @@ -0,0 +1,91 @@ +//===-- SBSymbolContextList.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/SBSymbolContextList.h" +#include "lldb/Symbol/SymbolContext.h" + +using namespace lldb; +using namespace lldb_private; + +SBSymbolContextList::SBSymbolContextList () : + m_opaque_ap () +{ +} + +SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) : + m_opaque_ap () +{ + if (rhs.IsValid()) + *m_opaque_ap = *rhs.m_opaque_ap; +} + +SBSymbolContextList::~SBSymbolContextList () +{ +} + +const SBSymbolContextList & +SBSymbolContextList::operator = (const SBSymbolContextList &rhs) +{ + if (this != &rhs) + { + if (rhs.IsValid()) + m_opaque_ap.reset (new lldb_private::SymbolContextList(*rhs.m_opaque_ap.get())); + } + return *this; +} + +uint32_t +SBSymbolContextList::GetSize() const +{ + if (m_opaque_ap.get()) + return m_opaque_ap->GetSize(); + return 0; +} + +SBSymbolContext +SBSymbolContextList::GetContextAtIndex (uint32_t idx) +{ + SBSymbolContext sb_sc; + if (m_opaque_ap.get()) + { + SymbolContext sc; + if (m_opaque_ap->GetContextAtIndex (idx, sc)) + { + sb_sc.SetSymbolContext(&sc); + } + } + return sb_sc; +} + + +bool +SBSymbolContextList::IsValid () const +{ + return m_opaque_ap.get() != NULL; +} + + + +lldb_private::SymbolContextList* +SBSymbolContextList::operator->() const +{ + return m_opaque_ap.get(); +} + + +lldb_private::SymbolContextList& +SBSymbolContextList::operator*() const +{ + assert (m_opaque_ap.get()); + return *m_opaque_ap.get(); +} + + + + Modified: lldb/trunk/source/Core/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Timer.cpp?rev=113599&r1=113598&r2=113599&view=diff ============================================================================== --- lldb/trunk/source/Core/Timer.cpp (original) +++ lldb/trunk/source/Core/Timer.cpp Fri Sep 10 13:31:35 2010 @@ -20,6 +20,7 @@ using namespace lldb_private; #define TIMER_INDENT_AMOUNT 2 +static bool g_quiet = true; uint32_t Timer::g_depth = 0; uint32_t Timer::g_display_depth = 0; FILE * Timer::g_file = NULL; @@ -78,16 +79,19 @@ { if (g_depth++ < g_display_depth) { - // Indent - ::fprintf (g_file, "%*s", g_depth * TIMER_INDENT_AMOUNT, ""); - // Print formatted string - va_list args; - va_start (args, format); - ::vfprintf (g_file, format, args); - va_end (args); + if (g_quiet == false) + { + // Indent + ::fprintf (g_file, "%*s", g_depth * TIMER_INDENT_AMOUNT, ""); + // Print formatted string + va_list args; + va_start (args, format); + ::vfprintf (g_file, format, args); + va_end (args); - // Newline - ::fprintf (g_file, "\n"); + // Newline + ::fprintf (g_file, "\n"); + } TimeValue start_time(TimeValue::Now()); m_total_start = start_time; m_timer_start = start_time; @@ -133,11 +137,16 @@ const uint64_t timer_nsec_uint = GetTimerElapsedNanoSeconds(); const double total_nsec = total_nsec_uint; const double timer_nsec = timer_nsec_uint; - ::fprintf (g_file, - "%*s%.9f sec (%.9f sec)\n", - (g_depth - 1) *TIMER_INDENT_AMOUNT, "", - total_nsec / 1000000000.0, - timer_nsec / 1000000000.0); + + if (g_quiet == false) + { + + ::fprintf (g_file, + "%*s%.9f sec (%.9f sec)\n", + (g_depth - 1) *TIMER_INDENT_AMOUNT, "", + total_nsec / 1000000000.0, + timer_nsec / 1000000000.0); + } // Keep total results for each category so we can dump results. Mutex::Locker locker (GetCategoryMutex()); From clattner at apple.com Fri Sep 10 13:50:41 2010 From: clattner at apple.com (Chris Lattner) Date: Fri, 10 Sep 2010 11:50:41 -0700 Subject: [Lldb-commits] [lldb] r113575 - in /lldb/trunk: include/lldb/API/SBFileSpec.h include/lldb/Core/FileSpec.h include/lldb/Host/Host.h source/API/SBFileSpec.cpp source/Commands/CommandObjectFile.cpp source/Core/FileSpec.cpp source/Host/common/Host.cpp source/Target/TargetList.cpp tools/driver/Driver.cpp In-Reply-To: <2B2C2F0D-8C44-464F-8EB9-E63FB95CCA5E@apple.com> References: <20100910044856.275C02A6C12C@llvm.org> <2B2C2F0D-8C44-464F-8EB9-E63FB95CCA5E@apple.com> Message-ID: On Sep 10, 2010, at 11:31 AM, Caroline Tice wrote: > I was unaware of that function in llvm; I will change my lldb stuff to use it. Thanks Caroline, I'm sorry for not pointing it out earlier, I forgot it existed also and had to grep around to find it. Your code to slice up $PATH reminded me that we had it somewhere. -Chris > > -- Caroline > > On Sep 9, 2010, at 10:28 PM, Chris Lattner wrote: > >> >> On Sep 9, 2010, at 9:48 PM, Caroline Tice wrote: >> >>> Author: ctice >>> Date: Thu Sep 9 23:48:55 2010 >>> New Revision: 113575 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=113575&view=rev >>> Log: >>> If the file the user specifies can't be found in the current directory, >>> and the user didn't specify a particular directory, search for the file >>> using the $PATH environment variable. >> >> Cool, thanks for doing this Caroline. Did you consider using llvm::sys::Program::FindProgramByName? It already handles this, as well as handling the other annoying cases on windows. In general, we should aim to reuse existing support stuff that LLVM provides rather than reinvent it. The corresponding header is "llvm/System/Program.h". >> >> -Chris >> >>> >>> >>> Modified: >>> lldb/trunk/include/lldb/API/SBFileSpec.h >>> lldb/trunk/include/lldb/Core/FileSpec.h >>> lldb/trunk/include/lldb/Host/Host.h >>> lldb/trunk/source/API/SBFileSpec.cpp >>> lldb/trunk/source/Commands/CommandObjectFile.cpp >>> lldb/trunk/source/Core/FileSpec.cpp >>> lldb/trunk/source/Host/common/Host.cpp >>> lldb/trunk/source/Target/TargetList.cpp >>> lldb/trunk/tools/driver/Driver.cpp >>> >>> Modified: lldb/trunk/include/lldb/API/SBFileSpec.h >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) >>> +++ lldb/trunk/include/lldb/API/SBFileSpec.h Thu Sep 9 23:48:55 2010 >>> @@ -36,6 +36,9 @@ >>> bool >>> Exists () const; >>> >>> + bool >>> + ResolveExecutableLocation (); >>> + >>> const char * >>> GetFilename() const; >>> >>> >>> Modified: lldb/trunk/include/lldb/Core/FileSpec.h >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Core/FileSpec.h (original) >>> +++ lldb/trunk/include/lldb/Core/FileSpec.h Thu Sep 9 23:48:55 2010 >>> @@ -261,6 +261,21 @@ >>> bool >>> Exists () const; >>> >>> + >>> + //------------------------------------------------------------------ >>> + /// Expanded existence test. >>> + /// >>> + /// Call into the Host to see if it can help find the file (e.g. by >>> + /// searching paths set in the environment, etc.). >>> + /// >>> + /// If found, sets the value of m_directory to the directory where the file was found. >>> + /// >>> + /// @return >>> + /// \b true if was able to find the file using expanded search methods, \b false otherwise. >>> + //------------------------------------------------------------------ >>> + bool >>> + ResolveExecutableLocation (); >>> + >>> uint64_t >>> GetByteSize() const; >>> >>> >>> Modified: lldb/trunk/include/lldb/Host/Host.h >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/include/lldb/Host/Host.h (original) >>> +++ lldb/trunk/include/lldb/Host/Host.h Thu Sep 9 23:48:55 2010 >>> @@ -258,6 +258,9 @@ >>> >>> static bool >>> ResolveExecutableInBundle (FileSpec *file); >>> + >>> + static bool >>> + ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename); >>> >>> static uint32_t >>> ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); >>> >>> Modified: lldb/trunk/source/API/SBFileSpec.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/API/SBFileSpec.cpp (original) >>> +++ lldb/trunk/source/API/SBFileSpec.cpp Thu Sep 9 23:48:55 2010 >>> @@ -61,6 +61,13 @@ >>> return false; >>> } >>> >>> +bool >>> +SBFileSpec::ResolveExecutableLocation () >>> +{ >>> + if (m_opaque_ap.get()) >>> + return m_opaque_ap->ResolveExecutableLocation (); >>> + return false; >>> +} >>> >>> int >>> SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len) >>> >>> Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) >>> +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Thu Sep 9 23:48:55 2010 >>> @@ -117,7 +117,7 @@ >>> { >>> FileSpec file_spec (file_path); >>> >>> - if (! file_spec.Exists()) >>> + if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) >>> { >>> result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); >>> result.SetStatus (eReturnStatusFailed); >>> >>> Modified: lldb/trunk/source/Core/FileSpec.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Core/FileSpec.cpp (original) >>> +++ lldb/trunk/source/Core/FileSpec.cpp Thu Sep 9 23:48:55 2010 >>> @@ -22,6 +22,7 @@ >>> #include "lldb/Core/DataBufferHeap.h" >>> #include "lldb/Core/DataBufferMemoryMap.h" >>> #include "lldb/Core/Stream.h" >>> +#include "lldb/Host/Host.h" >>> >>> using namespace lldb; >>> using namespace lldb_private; >>> @@ -414,6 +415,12 @@ >>> return GetFileStats (this, &file_stats); >>> } >>> >>> +bool >>> +FileSpec::ResolveExecutableLocation () >>> +{ >>> + return Host::ResolveExecutableLocation (m_directory, m_filename); >>> +} >>> + >>> uint64_t >>> FileSpec::GetByteSize() const >>> { >>> >>> Modified: lldb/trunk/source/Host/common/Host.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Host/common/Host.cpp (original) >>> +++ lldb/trunk/source/Host/common/Host.cpp Thu Sep 9 23:48:55 2010 >>> @@ -727,3 +727,59 @@ >>> return false; >>> } >>> #endif >>> + >>> +bool >>> +Host::ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename) >>> +{ >>> + // If the user specified just a plain filename, there may be additional ways to find the >>> + // file, such as searching the PATH environment variable on UNIX systems. This is the location >>> + // to implement such additional searches. >>> + >>> + // For now the only search we are implementing is search $PATH, which makes no sense if >>> + // the user already specified a directory. >>> + >>> + if (directory_name.GetLength() > 0) >>> + return false; >>> + >>> + std::string search_path (getenv ("PATH")); >>> + char dir_separator = ':'; >>> + >>> + bool done = false; >>> + bool found = false; >>> + size_t start = 0; >>> + while (!done && !found) >>> + { >>> + size_t end = search_path.find (dir_separator, start); >>> + size_t length; >>> + if (end == std::string::npos) >>> + { >>> + done = true; >>> + length = search_path.length() - start; >>> + } >>> + else >>> + length = end - start; >>> + >>> + std::string directory_str = search_path.substr (start, length); >>> + >>> + if (directory_str.length() > 0) >>> + { >>> + StreamString tmp_full_path_name; >>> + if (directory_str[directory_str.length()-1] == '/') >>> + tmp_full_path_name.Printf ("%s%s", directory_str.c_str(), filename.AsCString()); >>> + else >>> + tmp_full_path_name.Printf ("%s/%s", directory_str.c_str(), filename.AsCString()); >>> + >>> + struct stat sb; >>> + >>> + if (::stat (tmp_full_path_name.GetData(), &sb) == 0) >>> + { >>> + found = true; >>> + directory_name.SetCString (directory_str.c_str()); >>> + } >>> + } >>> + >>> + if (!done) >>> + start = end + 1; >>> + } >>> + return found; >>> +} >>> >>> Modified: lldb/trunk/source/Target/TargetList.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Target/TargetList.cpp (original) >>> +++ lldb/trunk/source/Target/TargetList.cpp Thu Sep 9 23:48:55 2010 >>> @@ -71,6 +71,10 @@ >>> { >>> ModuleSP exe_module_sp; >>> FileSpec resolved_file(file); >>> + >>> + if (!resolved_file.Exists()) >>> + resolved_file.ResolveExecutableLocation (); >>> + >>> if (!Host::ResolveExecutableInBundle (&resolved_file)) >>> resolved_file = file; >>> >>> >>> Modified: lldb/trunk/tools/driver/Driver.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=113575&r1=113574&r2=113575&view=diff >>> ============================================================================== >>> --- lldb/trunk/tools/driver/Driver.cpp (original) >>> +++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 9 23:48:55 2010 >>> @@ -527,6 +527,13 @@ >>> SBFileSpec file(optarg); >>> if (file.Exists()) >>> m_option_data.m_filename = optarg; >>> + else if (file.ResolveExecutableLocation()) >>> + { >>> + char path[PATH_MAX]; >>> + int path_len; >>> + file.GetPath (path, path_len); >>> + m_option_data.m_filename = path; >>> + } >>> else >>> error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); >>> } >>> @@ -550,6 +557,14 @@ >>> SBFileSpec file(optarg); >>> if (file.Exists()) >>> m_option_data.m_source_command_files.push_back (optarg); >>> + else if (file.ResolveExecutableLocation()) >>> + { >>> + char final_path[PATH_MAX]; >>> + size_t path_len; >>> + file.GetPath (final_path, path_len); >>> + std::string path_str (final_path); >>> + m_option_data.m_source_command_files.push_back (path_str); >>> + } >>> else >>> error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); >>> } >>> >>> >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >> > From johnny.chen at apple.com Fri Sep 10 14:34:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 19:34:12 -0000 Subject: [Lldb-commits] [lldb] r113607 - /lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Message-ID: <20100910193412.B94A72A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 14:34:12 2010 New Revision: 113607 URL: http://llvm.org/viewvc/llvm-project?rev=113607&view=rev Log: Updated help text for "breakpoint command add" to reflect r113596 changeset. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113607&r1=113606&r2=113607&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 14:34:12 2010 @@ -162,6 +162,22 @@ > print \"Hit this breakpoint!\" \n\ > DONE \n\ \n\ +As a convenience, this also works for a short Python one-liner: \n\ +(lldb) breakpoint command add -p 1 \"import time; print time.asctime()\" \n\ +(lldb) run \n\ +Launching '.../a.out' (x86_64) \n\ +(lldb) Fri Sep 10 12:17:45 2010 \n\ +Process 21778 Stopped \n\ +* thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread \n\ + 36 \n\ + 37 int c(int val)\n\ + 38 {\n\ + 39 -> return val + 3;\n\ + 40 }\n\ + 41 \n\ + 42 int main (int argc, char const *argv[])\n\ +(lldb) \n\ + \n\ Example multiple line Python breakpoint command, using function definition: \n\ \n\ (lldb) breakpoint command add -p 1 \n\ From jingham at apple.com Fri Sep 10 14:38:27 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 12:38:27 -0700 Subject: [Lldb-commits] [lldb] r113596 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectBreakpointCommand.cpp source/Interpreter/ScriptInterpreterPython.cpp test/conditional_break/TestConditionalBreak.py In-Reply-To: <20100910182111.34A9A2A6C12C@llvm.org> References: <20100910182111.34A9A2A6C12C@llvm.org> Message-ID: This is a fine idea, but can we do is some other way than by relying on there being only one breakpoint-id given to "command add"? It would actually be convenient to do: breakpoint command add -p 1 3 5 6 > commands > DONE and have the commands apply to the list of breakpoints. I intended to do this but just haven't gotten around to it... Also, it looks like your implementation only works for script command callbacks? Seems equally useful to add a little command-line one-liner. So maybe it would be better to add an option which takes the command data directly. Maybe use "-d" for data or "-o" for one-liner? Anyway then you'd do (lldb) breakpoint command add -p -d "Script Data" or (lldb) breakpoint command add -c -d "backtrace" and then: (lldb) breakpoint command add -c -d "backtrace" 1 2 3 4 5 when I get around to adding breakpoint lists to the arguments, which would be really handy. Another thing about putting it into an option is that it would be pretty easy to then make a "command completer" so you could use in the "Script Data". It's possible to add completers to inhomogenous positional arguments but it's more work. Jim On Sep 10, 2010, at 11:21 AM, Johnny Chen wrote: > Author: johnny > Date: Fri Sep 10 13:21:10 2010 > New Revision: 113596 > > URL: http://llvm.org/viewvc/llvm-project?rev=113596&view=rev > Log: > Added the capability to specify a one-liner Python script as the callback > command for a breakpoint, for example: > > (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" > > The ScriptInterpreter interface has an extra method: > > /// Set a one-liner as the callback for the breakpoint command. > virtual void > SetBreakpointCommandCallback (CommandInterpreter &interpreter, > BreakpointOptions *bp_options, > const char *oneliner); > > to accomplish the above. > > Also added a test case to demonstrate lldb's use of breakpoint callback command > to stop at function c() only when its immediate caller is function a(). The > following session shows the user entering the following commands: > > 1) command source .lldb (set up executable, breakpoint, and breakpoint command) > 2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a()) > 3) bt (to see that indeed c()'s immediate caller is a()) > 4) c (to continue and finish the program) > > test/conditional_break $ ../../build/Debug/lldb > (lldb) command source .lldb > Executing commands in '.lldb'. > (lldb) file a.out > Current executable set to 'a.out' (x86_64). > (lldb) breakpoint set -n c > Breakpoint created: 1: name = 'c', locations = 1 > (lldb) script import sys, os > (lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir)) > (lldb) script import conditional_break > (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" > (lldb) run > run > Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out' (x86_64) > (lldb) Checking call frames... > Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: > frame #0: a.out`c at main.c:39 > frame #1: a.out`b at main.c:34 > frame #2: a.out`a at main.c:25 > frame #3: a.out`main at main.c:44 > frame #4: a.out`start > c called from b > Continuing... > Checking call frames... > Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: > frame #0: a.out`c at main.c:39 > frame #1: a.out`b at main.c:34 > frame #2: a.out`main at main.c:47 > frame #3: a.out`start > c called from b > Continuing... > Checking call frames... > Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: > frame #0: a.out`c at main.c:39 > frame #1: a.out`a at main.c:27 > frame #2: a.out`main at main.c:50 > frame #3: a.out`start > c called from a > Stopped at c() with immediate caller as a(). > a(1) returns 4 > b(2) returns 5 > Process 20420 Stopped > * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread > 36 > 37 int c(int val) > 38 { > 39 -> return val + 3; > 40 } > 41 > 42 int main (int argc, char const *argv[]) > (lldb) bt > bt > thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread > frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39 > frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27 > frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50 > frame #3: 0x0000000100000d88 a.out`start + 52 > (lldb) c > c > Resuming process 20420 > Process 20420 Exited > a(3) returns 6 > (lldb) > > Modified: > lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h > lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h > lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp > lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp > lldb/trunk/test/conditional_break/TestConditionalBreak.py > > Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=113596&r1=113595&r2=113596&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) > +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Sep 10 13:21:10 2010 > @@ -77,6 +77,15 @@ > BreakpointOptions *bp_options, > CommandReturnObject &result); > > + /// Set a one-liner as the callback for the breakpoint command. > + virtual void > + SetBreakpointCommandCallback (CommandInterpreter &interpreter, > + BreakpointOptions *bp_options, > + const char *oneliner) > + { > + return; > + } > + > const char * > GetScriptInterpreterPtyName (); > > > Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=113596&r1=113595&r2=113596&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) > +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Sep 10 13:21:10 2010 > @@ -62,6 +62,12 @@ > BreakpointOptions *bp_options, > CommandReturnObject &result); > > + /// Set a one-liner as the callback for the breakpoint command. > + void > + SetBreakpointCommandCallback (CommandInterpreter &interpreter, > + BreakpointOptions *bp_options, > + const char *oneliner); > + > StringList > ReadCommandInputFromUser (FILE *in_file); > > > Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113596&r1=113595&r2=113596&view=diff > ============================================================================== > --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) > +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 13:21:10 2010 > @@ -258,9 +258,15 @@ > { > if (m_options.m_use_script_language) > { > - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, > - bp_loc_sp->GetLocationOptions(), > - result); > + // Special handling for one-liner. > + if (command.GetArgumentCount() == 2) > + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, > + bp_loc_sp->GetLocationOptions(), > + command.GetArgumentAtIndex(1)); > + else > + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, > + bp_loc_sp->GetLocationOptions(), > + result); > } > else > { > @@ -274,9 +280,15 @@ > { > if (m_options.m_use_script_language) > { > - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, > - bp->GetOptions(), > - result); > + // Special handling for one-liner. > + if (command.GetArgumentCount() == 2) > + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, > + bp->GetOptions(), > + command.GetArgumentAtIndex(1)); > + else > + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, > + bp->GetOptions(), > + result); > } > else > { > > Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113596&r1=113595&r2=113596&view=diff > ============================================================================== > --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) > +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 10 13:21:10 2010 > @@ -653,6 +653,26 @@ > } > } > > +// Set a Python one-liner as the callback for the breakpoint command. > +void > +ScriptInterpreterPython::SetBreakpointCommandCallback (CommandInterpreter &interpreter, > + BreakpointOptions *bp_options, > + const char *oneliner) > +{ > + std::auto_ptr data_ap(new BreakpointOptions::CommandData()); > + > + // It's necessary to set both user_source and script_source to the oneliner. > + // The former is used to generate callback description (as in breakpoint command list) > + // while the latter is used for Python to interpret during the actual callback. > + data_ap->user_source.AppendString (oneliner); > + data_ap->script_source.AppendString (oneliner); > + > + BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); > + bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); > + > + return; > +} > + > bool > ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter (StringList &function_def) > { > > Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113596&r1=113595&r2=113596&view=diff > ============================================================================== > --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) > +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Fri Sep 10 13:21:10 2010 > @@ -13,16 +13,27 @@ > mydir = "conditional_break" > > @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") > - def test_with_dsym(self): > + def test_with_dsym_python(self): > """Exercise some thread and frame APIs to break if c() is called by a().""" > self.buildDsym() > self.do_conditional_break() > > - def test_with_dwarf(self): > + def test_with_dwarf_python(self): > """Exercise some thread and frame APIs to break if c() is called by a().""" > self.buildDwarf() > self.do_conditional_break() > > + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") > + def test_with_dsym_command(self): > + """Simulate a user using lldb commands to break on c() if called from a().""" > + self.buildDsym() > + self.simulate_conditional_break_by_user() > + > + def test_with_dwarf_command(self): > + """Simulate a user using lldb commands to break on c() if called from a().""" > + self.buildDwarf() > + self.simulate_conditional_break_by_user() > + > def do_conditional_break(self): > """Exercise some thread and frame APIs to break if c() is called by a().""" > exe = os.path.join(os.getcwd(), "a.out") > @@ -70,6 +81,33 @@ > #process.Continue() > self.runCmd("process continue") > > + def simulate_conditional_break_by_user(self): > + """Simulate a user using lldb commands to break on c() if called from a().""" > + > + # Sourcing .lldb in the current working directory, which sets the main > + # executable, sets the breakpoint on c(), and adds the callback for the > + # breakpoint such that lldb only stops when the caller of c() is a(). > + # the "my" package that defines the date() function. > + self.runCmd("command source .lldb") > + > + self.runCmd("run", RUN_SUCCEEDED) > + > + # The stop reason of the thread should be breakpoint. > + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, > + substrs = ['state is Stopped', 'stop reason = breakpoint']) > + > + # The frame info for frame #0 points to a.out`c and its immediate caller > + # (frame #1) points to a.out`a. > + > + self.expect("frame info", "We should stop at c()", > + substrs = ["a.out`c"]) > + > + # Select our parent frame as the current frame. > + self.runCmd("frame select 1") > + self.expect("frame info", "The immediate caller should be a()", > + substrs = ["a.out`a"]) > + > + > > if __name__ == '__main__': > import atexit > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Fri Sep 10 15:15:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 20:15:14 -0000 Subject: [Lldb-commits] [lldb] r113609 - /lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Message-ID: <20100910201514.2A8422A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 15:15:13 2010 New Revision: 113609 URL: http://llvm.org/viewvc/llvm-project?rev=113609&view=rev Log: Fixed the breakage of "breakpoint command add -p 1 2" caused by r113596 as pointed out by Jim Ingham. The convenient one-liner specification should only apply when there is only one breakpoint id being specified for the time being. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113609&r1=113608&r2=113609&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 15:15:13 2010 @@ -275,7 +275,7 @@ if (m_options.m_use_script_language) { // Special handling for one-liner. - if (command.GetArgumentCount() == 2) + if (command.GetArgumentCount() == 2 && count == 1) interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, bp_loc_sp->GetLocationOptions(), command.GetArgumentAtIndex(1)); @@ -297,7 +297,7 @@ if (m_options.m_use_script_language) { // Special handling for one-liner. - if (command.GetArgumentCount() == 2) + if (command.GetArgumentCount() == 2 && count == 1) interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, bp->GetOptions(), command.GetArgumentAtIndex(1)); From johnny.chen at apple.com Fri Sep 10 15:18:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 10 Sep 2010 13:18:17 -0700 Subject: [Lldb-commits] [lldb] r113596 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectBreakpointCommand.cpp source/Interpreter/ScriptInterpreterPython.cpp test/conditional_break/TestConditionalBreak.py In-Reply-To: References: <20100910182111.34A9A2A6C12C@llvm.org> Message-ID: <2D65A108-3878-4447-A6A1-42EC3C0D7DD3@apple.com> So I broke the "breakpoint command add -p 1 2" use case. The option thing may be more involved, I'll fix the breakage with a simple workaround for the time being. On Sep 10, 2010, at 12:38 PM, Jim Ingham wrote: > This is a fine idea, but can we do is some other way than by relying on there being only one breakpoint-id given to "command add"? It would actually be convenient to do: > > breakpoint command add -p 1 3 5 6 >> commands >> DONE > > and have the commands apply to the list of breakpoints. I intended to do this but just haven't gotten around to it... > > Also, it looks like your implementation only works for script command callbacks? Seems equally useful to add a little command-line one-liner. > > So maybe it would be better to add an option which takes the command data directly. Maybe use "-d" for data or "-o" for one-liner? Anyway then you'd do > > (lldb) breakpoint command add -p -d "Script Data" > > or > > (lldb) breakpoint command add -c -d "backtrace" > > and then: > > (lldb) breakpoint command add -c -d "backtrace" 1 2 3 4 5 > > when I get around to adding breakpoint lists to the arguments, which would be really handy. > > Another thing about putting it into an option is that it would be pretty easy to then make a "command completer" so you could use in the "Script Data". It's possible to add completers to inhomogenous positional arguments but it's more work. > > Jim > > On Sep 10, 2010, at 11:21 AM, Johnny Chen wrote: > >> Author: johnny >> Date: Fri Sep 10 13:21:10 2010 >> New Revision: 113596 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=113596&view=rev >> Log: >> Added the capability to specify a one-liner Python script as the callback >> command for a breakpoint, for example: >> >> (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" >> >> The ScriptInterpreter interface has an extra method: >> >> /// Set a one-liner as the callback for the breakpoint command. >> virtual void >> SetBreakpointCommandCallback (CommandInterpreter &interpreter, >> BreakpointOptions *bp_options, >> const char *oneliner); >> >> to accomplish the above. >> >> Also added a test case to demonstrate lldb's use of breakpoint callback command >> to stop at function c() only when its immediate caller is function a(). The >> following session shows the user entering the following commands: >> >> 1) command source .lldb (set up executable, breakpoint, and breakpoint command) >> 2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a()) >> 3) bt (to see that indeed c()'s immediate caller is a()) >> 4) c (to continue and finish the program) >> >> test/conditional_break $ ../../build/Debug/lldb >> (lldb) command source .lldb >> Executing commands in '.lldb'. >> (lldb) file a.out >> Current executable set to 'a.out' (x86_64). >> (lldb) breakpoint set -n c >> Breakpoint created: 1: name = 'c', locations = 1 >> (lldb) script import sys, os >> (lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir)) >> (lldb) script import conditional_break >> (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" >> (lldb) run >> run >> Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out' (x86_64) >> (lldb) Checking call frames... >> Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: >> frame #0: a.out`c at main.c:39 >> frame #1: a.out`b at main.c:34 >> frame #2: a.out`a at main.c:25 >> frame #3: a.out`main at main.c:44 >> frame #4: a.out`start >> c called from b >> Continuing... >> Checking call frames... >> Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: >> frame #0: a.out`c at main.c:39 >> frame #1: a.out`b at main.c:34 >> frame #2: a.out`main at main.c:47 >> frame #3: a.out`start >> c called from b >> Continuing... >> Checking call frames... >> Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: >> frame #0: a.out`c at main.c:39 >> frame #1: a.out`a at main.c:27 >> frame #2: a.out`main at main.c:50 >> frame #3: a.out`start >> c called from a >> Stopped at c() with immediate caller as a(). >> a(1) returns 4 >> b(2) returns 5 >> Process 20420 Stopped >> * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread >> 36 >> 37 int c(int val) >> 38 { >> 39 -> return val + 3; >> 40 } >> 41 >> 42 int main (int argc, char const *argv[]) >> (lldb) bt >> bt >> thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread >> frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39 >> frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27 >> frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50 >> frame #3: 0x0000000100000d88 a.out`start + 52 >> (lldb) c >> c >> Resuming process 20420 >> Process 20420 Exited >> a(3) returns 6 >> (lldb) >> >> Modified: >> lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h >> lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h >> lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp >> lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp >> lldb/trunk/test/conditional_break/TestConditionalBreak.py >> >> Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=113596&r1=113595&r2=113596&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) >> +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Sep 10 13:21:10 2010 >> @@ -77,6 +77,15 @@ >> BreakpointOptions *bp_options, >> CommandReturnObject &result); >> >> + /// Set a one-liner as the callback for the breakpoint command. >> + virtual void >> + SetBreakpointCommandCallback (CommandInterpreter &interpreter, >> + BreakpointOptions *bp_options, >> + const char *oneliner) >> + { >> + return; >> + } >> + >> const char * >> GetScriptInterpreterPtyName (); >> >> >> Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=113596&r1=113595&r2=113596&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) >> +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Sep 10 13:21:10 2010 >> @@ -62,6 +62,12 @@ >> BreakpointOptions *bp_options, >> CommandReturnObject &result); >> >> + /// Set a one-liner as the callback for the breakpoint command. >> + void >> + SetBreakpointCommandCallback (CommandInterpreter &interpreter, >> + BreakpointOptions *bp_options, >> + const char *oneliner); >> + >> StringList >> ReadCommandInputFromUser (FILE *in_file); >> >> >> Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113596&r1=113595&r2=113596&view=diff >> ============================================================================== >> --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) >> +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 13:21:10 2010 >> @@ -258,9 +258,15 @@ >> { >> if (m_options.m_use_script_language) >> { >> - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, >> - bp_loc_sp->GetLocationOptions(), >> - result); >> + // Special handling for one-liner. >> + if (command.GetArgumentCount() == 2) >> + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, >> + bp_loc_sp->GetLocationOptions(), >> + command.GetArgumentAtIndex(1)); >> + else >> + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, >> + bp_loc_sp->GetLocationOptions(), >> + result); >> } >> else >> { >> @@ -274,9 +280,15 @@ >> { >> if (m_options.m_use_script_language) >> { >> - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, >> - bp->GetOptions(), >> - result); >> + // Special handling for one-liner. >> + if (command.GetArgumentCount() == 2) >> + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, >> + bp->GetOptions(), >> + command.GetArgumentAtIndex(1)); >> + else >> + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, >> + bp->GetOptions(), >> + result); >> } >> else >> { >> >> Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113596&r1=113595&r2=113596&view=diff >> ============================================================================== >> --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) >> +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 10 13:21:10 2010 >> @@ -653,6 +653,26 @@ >> } >> } >> >> +// Set a Python one-liner as the callback for the breakpoint command. >> +void >> +ScriptInterpreterPython::SetBreakpointCommandCallback (CommandInterpreter &interpreter, >> + BreakpointOptions *bp_options, >> + const char *oneliner) >> +{ >> + std::auto_ptr data_ap(new BreakpointOptions::CommandData()); >> + >> + // It's necessary to set both user_source and script_source to the oneliner. >> + // The former is used to generate callback description (as in breakpoint command list) >> + // while the latter is used for Python to interpret during the actual callback. >> + data_ap->user_source.AppendString (oneliner); >> + data_ap->script_source.AppendString (oneliner); >> + >> + BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); >> + bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); >> + >> + return; >> +} >> + >> bool >> ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter (StringList &function_def) >> { >> >> Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113596&r1=113595&r2=113596&view=diff >> ============================================================================== >> --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) >> +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Fri Sep 10 13:21:10 2010 >> @@ -13,16 +13,27 @@ >> mydir = "conditional_break" >> >> @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") >> - def test_with_dsym(self): >> + def test_with_dsym_python(self): >> """Exercise some thread and frame APIs to break if c() is called by a().""" >> self.buildDsym() >> self.do_conditional_break() >> >> - def test_with_dwarf(self): >> + def test_with_dwarf_python(self): >> """Exercise some thread and frame APIs to break if c() is called by a().""" >> self.buildDwarf() >> self.do_conditional_break() >> >> + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") >> + def test_with_dsym_command(self): >> + """Simulate a user using lldb commands to break on c() if called from a().""" >> + self.buildDsym() >> + self.simulate_conditional_break_by_user() >> + >> + def test_with_dwarf_command(self): >> + """Simulate a user using lldb commands to break on c() if called from a().""" >> + self.buildDwarf() >> + self.simulate_conditional_break_by_user() >> + >> def do_conditional_break(self): >> """Exercise some thread and frame APIs to break if c() is called by a().""" >> exe = os.path.join(os.getcwd(), "a.out") >> @@ -70,6 +81,33 @@ >> #process.Continue() >> self.runCmd("process continue") >> >> + def simulate_conditional_break_by_user(self): >> + """Simulate a user using lldb commands to break on c() if called from a().""" >> + >> + # Sourcing .lldb in the current working directory, which sets the main >> + # executable, sets the breakpoint on c(), and adds the callback for the >> + # breakpoint such that lldb only stops when the caller of c() is a(). >> + # the "my" package that defines the date() function. >> + self.runCmd("command source .lldb") >> + >> + self.runCmd("run", RUN_SUCCEEDED) >> + >> + # The stop reason of the thread should be breakpoint. >> + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, >> + substrs = ['state is Stopped', 'stop reason = breakpoint']) >> + >> + # The frame info for frame #0 points to a.out`c and its immediate caller >> + # (frame #1) points to a.out`a. >> + >> + self.expect("frame info", "We should stop at c()", >> + substrs = ["a.out`c"]) >> + >> + # Select our parent frame as the current frame. >> + self.runCmd("frame select 1") >> + self.expect("frame info", "The immediate caller should be a()", >> + substrs = ["a.out`a"]) >> + >> + >> >> if __name__ == '__main__': >> import atexit >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From gclayton at apple.com Fri Sep 10 15:20:35 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Sep 2010 20:20:35 -0000 Subject: [Lldb-commits] [lldb] r113611 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20100910202035.A90B22A6C12C@llvm.org> Author: gclayton Date: Fri Sep 10 15:20:35 2010 New Revision: 113611 URL: http://llvm.org/viewvc/llvm-project?rev=113611&view=rev Log: There was a check to make sure that the frame had a valid function before the expression parser would allow decl lookups which was not needed. After removing this you can evaluate expressions correctly when stopped in a frame that only has a symbol or has no symbol context at all. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113611&r1=113610&r2=113611&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Sep 10 15:20:35 2010 @@ -719,16 +719,7 @@ // Back out in all cases where we're not fully initialized if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) return; - - Function *function = m_sym_ctx->function; - - if (!function) - { - if (log) - log->Printf("Can't evaluate an expression when not in a function"); - return; - } - + ConstString name_cs(name); SymbolContextList sym_ctxs; From gclayton at apple.com Fri Sep 10 17:05:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Sep 2010 22:05:05 -0000 Subject: [Lldb-commits] [lldb] r113645 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20100910220505.BDF7B2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 10 17:05:05 2010 New Revision: 113645 URL: http://llvm.org/viewvc/llvm-project?rev=113645&view=rev Log: Make sure the address passed into SymbolContext::DumpStopContext() is valid before trying to calculate any offsets. 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=113645&r1=113644&r2=113645&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Sep 10 17:05:05 2010 @@ -156,9 +156,12 @@ return; } } - const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); - if (function_offset) - s->Printf(" + %llu", function_offset); + if (addr.IsValid()) + { + const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); + if (function_offset) + s->Printf(" + %llu", function_offset); + } if (block != NULL) { @@ -180,14 +183,14 @@ { symbol->GetMangled().GetName().Dump(s); - if (symbol->GetAddressRangePtr()) + if (addr.IsValid() && symbol->GetAddressRangePtr()) { const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset(); if (symbol_offset) s->Printf(" + %llu", symbol_offset); } } - else + else if (addr.IsValid()) { addr.Dump(s, exe_scope, Address::DumpStyleModuleWithFileAddress); } From jingham at apple.com Fri Sep 10 18:02:28 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 23:02:28 -0000 Subject: [Lldb-commits] [lldb] r113655 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20100910230228.4922A2A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 18:02:28 2010 New Revision: 113655 URL: http://llvm.org/viewvc/llvm-project?rev=113655&view=rev Log: Always look up the symbols with FindSymbolByID since we are minimizing the symbol list. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113655&r1=113654&r2=113655&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Sep 10 18:02:28 2010 @@ -1091,7 +1091,6 @@ } } } - if (add_nlist) { bool symbol_name_is_mangled = false; @@ -1104,7 +1103,6 @@ if (symbol_name) sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); - if (type == eSymbolTypeCode) { // See if we can find a N_FUN entry for any code symbols. @@ -1147,7 +1145,6 @@ } } } - if (symbol_section != NULL) symbol_value -= symbol_section->GetFileAddress(); @@ -1166,7 +1163,6 @@ } - // STAB N_GSYM entries end up having a symbol type eSymbolTypeGlobal and when the symbol value // is zero, the address of the global ends up being in a non-STAB entry. Try and fix up all // such entries by figuring out what the address for the global is by looking up this non-STAB @@ -1230,11 +1226,7 @@ { const uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); - Symbol *stub_symbol; - if (minimize) - stub_symbol = symtab->FindSymbolByID (symbol_index); - else - stub_symbol = symtab->SymbolAtIndex (symbol_index); + Symbol *stub_symbol = symtab->FindSymbolByID (symbol_index); assert (stub_symbol); if (stub_symbol) From jingham at apple.com Fri Sep 10 18:06:30 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 23:06:30 -0000 Subject: [Lldb-commits] [lldb] r113657 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20100910230630.A69F42A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 18:06:30 2010 New Revision: 113657 URL: http://llvm.org/viewvc/llvm-project?rev=113657&view=rev Log: When the debugger updates its symbol context, if no thread or frame are selected select the first thread's 0th frame. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113657&r1=113656&r2=113657&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Sep 10 18:06:30 2010 @@ -503,12 +503,22 @@ { m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get(); if (m_exe_ctx.thread == NULL) + { m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + // If we didn't have a selected thread, select one here. + if (m_exe_ctx.thread != NULL) + m_exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID(0); + } if (m_exe_ctx.thread) { m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get(); if (m_exe_ctx.frame == NULL) + { m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); + // If we didn't have a selected frame select one here. + if (m_exe_ctx.frame != NULL) + m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame); + } } } } From jingham at apple.com Fri Sep 10 18:07:48 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 23:07:48 -0000 Subject: [Lldb-commits] [lldb] r113658 - /lldb/trunk/source/Expression/ClangFunction.cpp Message-ID: <20100910230748.D52A72A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 18:07:48 2010 New Revision: 113658 URL: http://llvm.org/viewvc/llvm-project?rev=113658&view=rev Log: Little bit of line wrapping cleanup. Mainly ExecuteFunction should save & restore the currently selected Thread & Frame. Modified: lldb/trunk/source/Expression/ClangFunction.cpp Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=113658&r1=113657&r2=113658&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Fri Sep 10 18:07:48 2010 @@ -45,7 +45,11 @@ //---------------------------------------------------------------------- // ClangFunction constructor //---------------------------------------------------------------------- -ClangFunction::ClangFunction(const char *target_triple, ClangASTContext *ast_context, void *return_qualtype, const Address& functionAddress, const ValueList &arg_value_list) : +ClangFunction::ClangFunction(const char *target_triple, + ClangASTContext *ast_context, + void *return_qualtype, + const Address& functionAddress, + const ValueList &arg_value_list) : m_target_triple (target_triple), m_function_ptr (NULL), m_function_addr (functionAddress), @@ -61,7 +65,10 @@ { } -ClangFunction::ClangFunction(const char *target_triple, Function &function, ClangASTContext *ast_context, const ValueList &arg_value_list) : +ClangFunction::ClangFunction(const char *target_triple, + Function &function, + ClangASTContext *ast_context, + const ValueList &arg_value_list) : m_target_triple (target_triple), m_function_ptr (&function), m_function_addr (), @@ -245,7 +252,11 @@ // FIXME: Assure that the ValueList we were passed in is consistent with the one that defined this function. bool -ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Address function_address, ValueList &arg_values, Stream &errors) +ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, + lldb::addr_t &args_addr_ref, + Address function_address, + ValueList &arg_values, + Stream &errors) { // All the information to reconstruct the struct is provided by the // StructExtractor. @@ -448,8 +459,25 @@ Stream &errors) { // Save this value for restoration of the execution context after we run - uint32_t tid = exe_ctx.thread->GetID(); + uint32_t tid = exe_ctx.thread->GetIndexID(); + // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, + // so we should arrange to reset them as well. + + lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread(); + lldb::StackFrameSP selected_frame_sp; + + uint32_t selected_tid; + if (selected_thread_sp != NULL) + { + selected_tid = selected_thread_sp->GetIndexID(); + selected_frame_sp = selected_thread_sp->GetSelectedFrame(); + } + else + { + selected_tid = LLDB_INVALID_THREAD_ID; + } + ClangFunction::ExecutionResults return_value = eExecutionSetupError; lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, errors, stop_others, false)); @@ -496,7 +524,6 @@ lldb::EventSP event_sp; // Now wait for the process to stop again: - // FIXME: Probably want a time out. lldb::StateType stop_state = exe_ctx.process->WaitForStateChangedEvents (timeout_ptr, event_sp); if (stop_state == lldb::eStateInvalid && timeout_ptr != NULL) @@ -505,7 +532,10 @@ // We should interrupt the process here... // Not really sure what to do if Halt fails here... if (log) - log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.", single_thread_timeout_usec); + if (try_all_threads) + log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.", single_thread_timeout_usec); + else + log->Printf ("Running function with timeout: %d timed out, abandoning execution.", single_thread_timeout_usec); if (exe_ctx.process->Halt().Success()) { @@ -633,9 +663,21 @@ // Thread we ran the function in may have gone away because we ran the target // Check that it's still there. - exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByID(tid, true).get(); + exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); + // Also restore the current process'es selected frame & thread, since this function calling may + // be done behind the user's back. + + if (selected_tid != LLDB_INVALID_THREAD_ID) + { + if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid)) + { + // We were able to restore the selected thread, now restore the frame: + exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(selected_frame_sp.get()); + } + } + return return_value; } @@ -668,7 +710,8 @@ return eExecutionSetupError; } - return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others, try_all_threads, single_thread_timeout_usec, errors); + return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others, + try_all_threads, single_thread_timeout_usec, errors); if (args_addr_ptr != NULL) *args_addr_ptr = args_addr; From jingham at apple.com Fri Sep 10 18:12:17 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 23:12:17 -0000 Subject: [Lldb-commits] [lldb] r113660 - in /lldb/trunk: include/lldb/API/SBValue.h include/lldb/Core/ValueObject.h include/lldb/Target/ObjCObjectPrinter.h source/API/SBValue.cpp source/Commands/CommandObjectFrame.cpp source/Core/ValueObject.cpp source/Target/ObjCObjectPrinter.cpp Message-ID: <20100910231217.B143F2A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 18:12:17 2010 New Revision: 113660 URL: http://llvm.org/viewvc/llvm-project?rev=113660&view=rev Log: Move the "Object Description" into the ValueObject, and the add an API to SBValue to access it. For now this is just the result of ObjC NSPrintForDebugger, but could be extended. Also store the results of the ObjC Object Printer in a Stream, not a ConstString. Modified: lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Target/ObjCObjectPrinter.cpp Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Fri Sep 10 18:12:17 2010 @@ -49,6 +49,9 @@ const char * GetSummary (const lldb::SBFrame &frame); + + const char * + GetObjectDescription (const lldb::SBFrame &frame); const char * GetLocation (const lldb::SBFrame &frame); Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Sep 10 18:12:17 2010 @@ -140,6 +140,10 @@ const char * GetSummaryAsCString (ExecutionContextScope *exe_scope); + + const char * + GetObjectDescription (ExecutionContextScope *exe_scope); + lldb::user_id_t GetUpdateID() const; @@ -190,6 +194,8 @@ std::string m_old_value_str;// Cached old value string from the last time the value was gotten std::string m_location_str; // Cached location string that will get cleared if/when the value is updated. std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated. + std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary + // in that the summary is consed up by us, the object_desc_string is builtin. std::vector m_children; std::map m_synthetic_children; bool m_value_is_valid:1, Modified: lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h (original) +++ lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h Fri Sep 10 18:12:17 2010 @@ -31,7 +31,7 @@ ~ObjCObjectPrinter (); bool - PrintObject (ConstString &str, Value &object_ptr, ExecutionContext &exe_ctx); + PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx); protected: Process &m_process; std::auto_ptr
m_PrintForDebugger_addr; Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri Sep 10 18:12:17 2010 @@ -176,6 +176,15 @@ return value_string; } +const char * +SBValue::GetObjectDescription (const SBFrame &frame) +{ + const char *value_string = NULL; + if ( m_opaque_sp) + value_string = m_opaque_sp->GetObjectDescription (frame.get()); + return value_string; +} + bool SBValue::GetValueDidChange (const SBFrame &frame) { Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 10 18:12:17 2010 @@ -444,41 +444,11 @@ if (use_objc) { - if (!ClangASTContext::IsPointerType (valobj->GetOpaqueClangQualType())) - return; - - if (!valobj->GetValueIsValid()) - return; - - Process *process = exe_scope->CalculateProcess(); - - if (!process) - return; - - Scalar scalar; - - if (!ClangASTType::GetValueAsScalar (valobj->GetClangAST(), - valobj->GetOpaqueClangQualType(), - valobj->GetDataExtractor(), - 0, - valobj->GetByteSize(), - scalar)) - return; - - ConstString po_output; - - ExecutionContext exe_ctx; - exe_scope->Calculate(exe_ctx); - - Value val(scalar); - val.SetContext(Value::eContextTypeOpaqueClangQualType, - ClangASTContext::GetVoidPtrType(valobj->GetClangAST(), false)); - - if (!process->GetObjCObjectPrinter().PrintObject(po_output, val, exe_ctx)) - return; - - s.Printf("\n%s\n", po_output.GetCString()); - + const char *object_desc = valobj->GetObjectDescription(exe_scope); + if (object_desc) + s.Printf("\n%s\n", object_desc); + else + s.Printf ("No description available.\n"); return; } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Sep 10 18:12:17 2010 @@ -24,6 +24,7 @@ #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Type.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" @@ -48,6 +49,7 @@ m_old_value_str (), m_location_str (), m_summary_str (), + m_object_desc_str (), m_children (), m_synthetic_children (), m_value_is_valid (false), @@ -96,6 +98,7 @@ } m_location_str.clear(); m_summary_str.clear(); + m_object_desc_str.clear(); const bool value_was_valid = GetValueIsValid(); SetValueDidChange (false); @@ -499,6 +502,48 @@ return m_summary_str.c_str(); } +const char * +ValueObject::GetObjectDescription (ExecutionContextScope *exe_scope) +{ + if (!m_object_desc_str.empty()) + return m_object_desc_str.c_str(); + + if (!ClangASTContext::IsPointerType (GetOpaqueClangQualType())) + return NULL; + + if (!GetValueIsValid()) + return NULL; + + Process *process = exe_scope->CalculateProcess(); + + if (!process) + return NULL; + + Scalar scalar; + + if (!ClangASTType::GetValueAsScalar (GetClangAST(), + GetOpaqueClangQualType(), + GetDataExtractor(), + 0, + GetByteSize(), + scalar)) + return NULL; + + ExecutionContext exe_ctx; + exe_scope->Calculate(exe_ctx); + + Value val(scalar); + val.SetContext(Value::eContextTypeOpaqueClangQualType, + ClangASTContext::GetVoidPtrType(GetClangAST(), false)); + + StreamString s; + // FIXME: Check the runtime this object belongs to and get the appropriate object printer for the object kind. + if (process->GetObjCObjectPrinter().PrintObject(s, val, exe_ctx)) + { + m_object_desc_str.append (s.GetData()); + } + return m_object_desc_str.c_str(); +} const char * ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope) Modified: lldb/trunk/source/Target/ObjCObjectPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCObjectPrinter.cpp?rev=113660&r1=113659&r2=113660&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCObjectPrinter.cpp (original) +++ lldb/trunk/source/Target/ObjCObjectPrinter.cpp Fri Sep 10 18:12:17 2010 @@ -38,7 +38,7 @@ } bool -ObjCObjectPrinter::PrintObject (ConstString &str, Value &object_ptr, ExecutionContext &exe_ctx) +ObjCObjectPrinter::PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx) { if (!exe_ctx.process) return false; @@ -64,8 +64,14 @@ lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); // FIXME: Check result of ExecuteFunction. - func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret); - + ClangFunction::ExecutionResults results + = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret); + if (results != ClangFunction::eExecutionCompleted) + { + str.Printf("Error evaluating Print Object function: %d.\n", results); + return false; + } + addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); // poor man's strcpy @@ -86,7 +92,7 @@ if (!desc.empty()) { - str.SetCString(&desc.front()); + str.PutCString(&desc.front()); return true; } return false; From jingham at apple.com Fri Sep 10 18:12:45 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 10 Sep 2010 23:12:45 -0000 Subject: [Lldb-commits] [lldb] r113661 - /lldb/trunk/docs/lldb-for-gdb-users.txt Message-ID: <20100910231245.A8C4B2A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 18:12:45 2010 New Revision: 113661 URL: http://llvm.org/viewvc/llvm-project?rev=113661&view=rev Log: Few clarifications. Modified: lldb/trunk/docs/lldb-for-gdb-users.txt Modified: lldb/trunk/docs/lldb-for-gdb-users.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-for-gdb-users.txt?rev=113661&r1=113660&r2=113661&view=diff ============================================================================== --- lldb/trunk/docs/lldb-for-gdb-users.txt (original) +++ lldb/trunk/docs/lldb-for-gdb-users.txt Fri Sep 10 18:12:45 2010 @@ -7,11 +7,28 @@ First some details on lldb command structure to help orient you... Unlike gdb's command set, which is rather free-form, we tried to make -the lldb command set fairly structured. The commands are all of the +the lldb command syntax fairly structured. The commands are all of the form [-options [option-value]] [argument [argument...]] +The command line parsing is done before command execution, so it is +uniform across all the commands. The command syntax is very simple, +basically arguments, options and option values are all white-space +separated. If you need to put a backslash or double-quote character +in an argument you back-slash it in the argument. That makes the +command syntax more regular, but it also means you may have to +quote some arguments in lldb that you wouldn't in gdb. + +Options can be placed anywhere on the command line, but if the arguments +begin with a "-" then you have to tell lldb that you're done with options +using the "--" option. So for instance, the "process launch" command takes +the "-s" option to mean "stop the process at the first instruction". It's +arguments are the arguments you are passing to the program. So if you wanted +to pass an argument that contained a "-" you would have to do: + +(lldb) process launch -- -program_arg value + We also tried to reduce the number of special purpose argument parsers, which sometimes forces the user to be a little more explicit about stating their intentions. The first instance you'll note of @@ -53,14 +70,7 @@ for all functions called foo in the shared library foo.dylib. Suggestions on more interesting primitives of this sort are also very welcome. -The next structural difference between lldb & gdb is that the command -line is actually parsed by the command interpreter not the commands. -That means the command syntax is more regular, but it also means you -may have to quote some arguments in lldb that you wouldn't in gdb. -But the command syntax is very simple, basically arguments, options -and option values are all white-space separated. If you need to put a -backslash or double-quote character in an argument you back-slash it -in the argument. So for instance: +So for instance: (lldb) breakpoint set -n "-[SKTGraphicView alignLeftEdges:]" @@ -150,13 +160,35 @@ 1: name = 'alignLeftEdges:', locations = 1, resolved = 1 1.1: where = Sketch`-[SKTGraphicView alignLeftEdges:] + 33 at /Volumes/ThePlayground/Users/jingham/Projects/Sketch/SKTGraphicView.m:1405, address = 0x0000000100010d5b, resolved, hit count = 0 -Note that each "logical" breakpoint can have multiple resolved -"locations". The logical breakpoint has an integer id, and it's -locations have a an id within their parent breakpoint (the two are -joined by a ".", e.g. 1.1 in the example above.) Also the breakpoints -remain "live" so that if another shared library were to be loaded that -had another implementation of the "alignLeftEdges:" selector, and new -location would be added to the breakpoint 1 for it. +Note that each "logical" breakpoint can have multiple "locations". +The logical breakpoint has an integer id, and it's locations have a an +id within their parent breakpoint (the two are joined by a ".", +e.g. 1.1 in the example above.) + +Also the breakpoints remain "live" so that if another shared library +were to be loaded that had another implementation of the +"alignLeftEdges:" selector, and new location would be added to the +breakpoint 1 for it. + +The other piece of information in the breakpoint listing is whether the +breakpoint location was "resolved" or not. A location gets resolved when +the file address it corresponds to gets loaded into the program you are +debugging. For instance if you set a breakpoint in a dylib that then +gets unloaded, that breakpoint location will remain, but it will no longer +be "resolved". + +One other thing to note for gdb users is that lldb acts like gdb with: + +(gdb) set breakpoint pending on + +That is, lldb always make breakpoints from your specification, even if it +couldn't find any locations that match the specification. You can tell whether the +expression was resolved or not by checking the locations field in the breakpoint +reporting, and we mark the breakpoint as "pending" so you can tell you've made +a typo more easily, if that was indeed the reason no locations were found: + +(lldb) b s -f no_such_file.c -l 10000000 +Breakpoint created: 1: file ='no_such_file.c', line = 10000000, locations = 0 (pending) You can delete, disable, set conditions and ignore counts either on all the locations generated by your logical breakpoint. So for From jingham at apple.com Fri Sep 10 19:03:03 2010 From: jingham at apple.com (Jim Ingham) Date: Sat, 11 Sep 2010 00:03:03 -0000 Subject: [Lldb-commits] [lldb] r113669 - /lldb/trunk/docs/lldb-for-gdb-users.txt Message-ID: <20100911000303.C14192A6C12C@llvm.org> Author: jingham Date: Fri Sep 10 19:03:03 2010 New Revision: 113669 URL: http://llvm.org/viewvc/llvm-project?rev=113669&view=rev Log: Don't use lldb syntax in the gdb examples... Modified: lldb/trunk/docs/lldb-for-gdb-users.txt Modified: lldb/trunk/docs/lldb-for-gdb-users.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-for-gdb-users.txt?rev=113669&r1=113668&r2=113669&view=diff ============================================================================== --- lldb/trunk/docs/lldb-for-gdb-users.txt (original) +++ lldb/trunk/docs/lldb-for-gdb-users.txt Fri Sep 10 19:03:03 2010 @@ -35,11 +35,11 @@ this is the breakpoint command. In gdb, to set a breakpoint, you would just say: -(gdb) break set foo.c:12 +(gdb) break foo.c:12 or -(gdb) break set foo +(gdb) break foo if foo is a function. As time went on, the parser that tells foo.c:12 from foo from foo.c::foo (which means the function foo in the file From johnny.chen at apple.com Fri Sep 10 19:18:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 11 Sep 2010 00:18:09 -0000 Subject: [Lldb-commits] [lldb] r113672 - in /lldb/trunk: source/Commands/CommandObjectBreakpointCommand.cpp source/Commands/CommandObjectBreakpointCommand.h test/conditional_break/.lldb Message-ID: <20100911001809.A3E932A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 19:18:09 2010 New Revision: 113672 URL: http://llvm.org/viewvc/llvm-project?rev=113672&view=rev Log: Added [-o ] to the "breakpoint command add" lldb command to be able to specify a one-liner (either scripting or lldb command) inline. Refactored CommandObjectBreakpointCommandAdd::Execute() a little bit and added some comments. Sn now, we use: breakpoint command add -p 1 -o "conditional_break.stop_if_called_from_a()" to specify a Python one-liner as the callback for breakpoint #1. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/test/conditional_break/.lldb Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113672&r1=113671&r2=113672&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 19:18:09 2010 @@ -32,7 +32,12 @@ //------------------------------------------------------------------------- CommandObjectBreakpointCommandAdd::CommandOptions::CommandOptions () : - Options () + Options (), + m_use_commands (false), + m_use_script_language (false), + m_script_language (eScriptLanguageNone), + m_use_one_liner (false), + m_one_liner() { } @@ -43,6 +48,9 @@ lldb::OptionDefinition CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] = { + { LLDB_OPT_SET_ALL, false, "one_liner", 'o', required_argument, NULL, 0, "", + "Specify a one-liner inline." }, + { LLDB_OPT_SET_1, true, "script", 's', no_argument, NULL, 0, NULL, "Write the breakpoint command script in the default scripting language."}, @@ -74,6 +82,10 @@ switch (short_option) { + case 'o': + m_use_one_liner = true; + m_one_liner = option_arg; + break; case 's': m_use_commands = false; m_use_script_language = true; @@ -103,6 +115,9 @@ m_use_commands = false; m_use_script_language = false; m_script_language = eScriptLanguageNone; + + m_use_one_liner = false; + m_one_liner.clear(); } //------------------------------------------------------------------------- @@ -163,7 +178,7 @@ > DONE \n\ \n\ As a convenience, this also works for a short Python one-liner: \n\ -(lldb) breakpoint command add -p 1 \"import time; print time.asctime()\" \n\ +(lldb) breakpoint command add -p 1 -o \"import time; print time.asctime()\" \n\ (lldb) run \n\ Launching '.../a.out' (x86_64) \n\ (lldb) Fri Sep 10 12:17:45 2010 \n\ @@ -267,51 +282,50 @@ if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) { Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); - if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) + BreakpointOptions *bp_options = NULL; + if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) + { + // This breakpoint does not have an associated location. + bp_options = bp->GetOptions(); + } + else { BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID())); + // This breakpoint does have an associated location. + // Get its breakpoint options. if (bp_loc_sp) - { - if (m_options.m_use_script_language) - { - // Special handling for one-liner. - if (command.GetArgumentCount() == 2 && count == 1) - interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, - bp_loc_sp->GetLocationOptions(), - command.GetArgumentAtIndex(1)); - else - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp_loc_sp->GetLocationOptions(), - result); - } - else - { - CollectDataForBreakpointCommandCallback (interpreter, - bp_loc_sp->GetLocationOptions(), - result); - } - } + bp_options = bp_loc_sp->GetLocationOptions(); + } + + // Skip this breakpoiont if bp_options is not good. + if (bp_options == NULL) continue; + + // If we are using script language, get the script interpreter + // in order to set or collect command callback. Otherwise, call + // the methods associated with this object. + if (m_options.m_use_script_language) + { + // Special handling for one-liner specified inline. + if (m_options.m_use_one_liner) + interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, + bp_options, + m_options.m_one_liner.c_str()); + else + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, + bp_options, + result); } else { - if (m_options.m_use_script_language) - { - // Special handling for one-liner. - if (command.GetArgumentCount() == 2 && count == 1) - interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, - bp->GetOptions(), - command.GetArgumentAtIndex(1)); - else - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp->GetOptions(), - result); - } + // Special handling for one-liner specified inline. + if (m_options.m_use_one_liner) + SetBreakpointCommandCallback (interpreter, + bp_options, + m_options.m_one_liner.c_str()); else - { CollectDataForBreakpointCommandCallback (interpreter, - bp->GetOptions(), + bp_options, result); - } } } } @@ -368,6 +382,26 @@ } +// Set a one-liner as the callback for the breakpoint command. +void +CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, + const char *oneliner) +{ + std::auto_ptr data_ap(new BreakpointOptions::CommandData()); + + // It's necessary to set both user_source and script_source to the oneliner. + // The former is used to generate callback description (as in breakpoint command list) + // while the latter is used for Python to interpret during the actual callback. + data_ap->user_source.AppendString (oneliner); + data_ap->script_source.AppendString (oneliner); + + BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); + bp_options->SetCallback (CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction, baton_sp); + + return; +} + size_t CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ( Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=113672&r1=113671&r2=113672&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Fri Sep 10 19:18:09 2010 @@ -74,6 +74,11 @@ BreakpointOptions *bp_options, CommandReturnObject &result); + void + SetBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, + const char *oneliner); + static size_t GenerateBreakpointCommandCallback (void *baton, InputReader &reader, @@ -115,6 +120,10 @@ bool m_use_commands; bool m_use_script_language; lldb::ScriptLanguage m_script_language; + + // Instance variables to hold the values for one_liner options. + bool m_use_one_liner; + std::string m_one_liner; }; private: Modified: lldb/trunk/test/conditional_break/.lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/.lldb?rev=113672&r1=113671&r2=113672&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/.lldb (original) +++ lldb/trunk/test/conditional_break/.lldb Fri Sep 10 19:18:09 2010 @@ -3,5 +3,5 @@ script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) script import conditional_break -breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" +breakpoint command add -p 1 -o "conditional_break.stop_if_called_from_a()" From johnny.chen at apple.com Fri Sep 10 19:23:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 11 Sep 2010 00:23:59 -0000 Subject: [Lldb-commits] [lldb] r113673 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectBreakpointCommand.cpp source/Commands/CommandObjectBreakpointCommand.h source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100911002400.087922A6C12C@llvm.org> Author: johnny Date: Fri Sep 10 19:23:59 2010 New Revision: 113673 URL: http://llvm.org/viewvc/llvm-project?rev=113673&view=rev Log: Fixed some comments. Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=113673&r1=113672&r2=113673&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Sep 10 19:23:59 2010 @@ -77,7 +77,7 @@ BreakpointOptions *bp_options, CommandReturnObject &result); - /// Set a one-liner as the callback for the breakpoint command. + /// Set a one-liner as the callback for the breakpoint. virtual void SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=113673&r1=113672&r2=113673&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Sep 10 19:23:59 2010 @@ -62,7 +62,7 @@ BreakpointOptions *bp_options, CommandReturnObject &result); - /// Set a one-liner as the callback for the breakpoint command. + /// Set a Python one-liner as the callback for the breakpoint. void SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=113673&r1=113672&r2=113673&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 10 19:23:59 2010 @@ -382,7 +382,7 @@ } -// Set a one-liner as the callback for the breakpoint command. +// Set a one-liner as the callback for the breakpoint. void CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=113673&r1=113672&r2=113673&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Fri Sep 10 19:23:59 2010 @@ -74,6 +74,7 @@ BreakpointOptions *bp_options, CommandReturnObject &result); + /// Set a one-liner as the callback for the breakpoint. void SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113673&r1=113672&r2=113673&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 10 19:23:59 2010 @@ -653,7 +653,7 @@ } } -// Set a Python one-liner as the callback for the breakpoint command. +// Set a Python one-liner as the callback for the breakpoint. void ScriptInterpreterPython::SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, From jmolenda at apple.com Fri Sep 10 19:37:21 2010 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 11 Sep 2010 00:37:21 -0000 Subject: [Lldb-commits] [lldb] r113674 - /lldb/trunk/docs/lldb-for-gdb-users.txt Message-ID: <20100911003721.D811E2A6C12C@llvm.org> Author: jmolenda Date: Fri Sep 10 19:37:21 2010 New Revision: 113674 URL: http://llvm.org/viewvc/llvm-project?rev=113674&view=rev Log: Minor copy edits. Modified: lldb/trunk/docs/lldb-for-gdb-users.txt Modified: lldb/trunk/docs/lldb-for-gdb-users.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-for-gdb-users.txt?rev=113674&r1=113673&r2=113674&view=diff ============================================================================== --- lldb/trunk/docs/lldb-for-gdb-users.txt (original) +++ lldb/trunk/docs/lldb-for-gdb-users.txt Fri Sep 10 19:37:21 2010 @@ -50,7 +50,8 @@ (lldb) breakpoint set -f foo.c -l 12 -to set a file & line breakpoint. To set a breakpoint on a function by name, you do: +to set a file & line breakpoint. To set a breakpoint on a function +by name, you do: (lldb) breakpoint set -n foo @@ -58,7 +59,7 @@ (lldb) breakpoint set -M foo -to break on all methods named foo, or: +to break on all C++ methods named foo, or: (lldb) breakpoint set -S alignLeftEdges: @@ -82,14 +83,14 @@ lldb also supports command completion for source file names, symbol names, file names, etc. Completion is initiated by a hitting a . -Individual options a command can have different completers, so for +Individual options in a command can have different completers, so for instance the -f option in "breakpoint" completes to source files, the --s option to currently loaded dylibs, etc... We can even do things -like if you specify -s, and are completing on -f, we will only -list source files in the dylib specified by -s... +-s option to currently loaded shared libraries, etc... We can even do +things like if you specify -s, and are completing on -f, we will only +list source files in the shared library specified by -s... The individual commands are pretty extensively documented, using -with the "help" command. And there is an "apropos" command that will +the "help" command. And there is an "apropos" command that will search the help for a particular word and dump a summary help string for each matching command. @@ -158,51 +159,53 @@ (lldb) break list Current breakpoints: 1: name = 'alignLeftEdges:', locations = 1, resolved = 1 - 1.1: where = Sketch`-[SKTGraphicView alignLeftEdges:] + 33 at /Volumes/ThePlayground/Users/jingham/Projects/Sketch/SKTGraphicView.m:1405, address = 0x0000000100010d5b, resolved, hit count = 0 + 1.1: where = Sketch`-[SKTGraphicView alignLeftEdges:] + 33 at /Projects/Sketch/SKTGraphicView.m:1405, address = 0x0000000100010d5b, resolved, hit count = 0 Note that each "logical" breakpoint can have multiple "locations". -The logical breakpoint has an integer id, and it's locations have a an +The logical breakpoint has an integer id, and it's locations have an id within their parent breakpoint (the two are joined by a ".", e.g. 1.1 in the example above.) Also the breakpoints remain "live" so that if another shared library were to be loaded that had another implementation of the -"alignLeftEdges:" selector, and new location would be added to the -breakpoint 1 for it. +"alignLeftEdges:" selector, the new location would be added to +breakpoint 1 (e.g. a "1.2" breakpoint would be set on the newly loaded +selector). The other piece of information in the breakpoint listing is whether the breakpoint location was "resolved" or not. A location gets resolved when the file address it corresponds to gets loaded into the program you are -debugging. For instance if you set a breakpoint in a dylib that then -gets unloaded, that breakpoint location will remain, but it will no longer -be "resolved". +debugging. For instance if you set a breakpoint in a shared library that +then gets unloaded, that breakpoint location will remain, but it will no +longer be "resolved". One other thing to note for gdb users is that lldb acts like gdb with: (gdb) set breakpoint pending on -That is, lldb always make breakpoints from your specification, even if it -couldn't find any locations that match the specification. You can tell whether the -expression was resolved or not by checking the locations field in the breakpoint -reporting, and we mark the breakpoint as "pending" so you can tell you've made -a typo more easily, if that was indeed the reason no locations were found: +That is, lldb should always make a breakpoint from your specification, even +if it couldn't find any locations that match the specification. You can tell +whether the expression was resolved or not by checking the locations field +in "breakpoint list", and we report the breakpoint as "pending" when you +set it so you can tell you've made a typo more easily, if that was indeed +the reason no locations were found: (lldb) b s -f no_such_file.c -l 10000000 Breakpoint created: 1: file ='no_such_file.c', line = 10000000, locations = 0 (pending) -You can delete, disable, set conditions and ignore counts either on -all the locations generated by your logical breakpoint. So for -instance if we wanted to add a command to print a backtrace when we -hit this breakpoint we could do: +You can delete, disable, set conditions and ignore counts either on all the +locations generated by your logical breakpoint, or on particular locations +your specification resolved to. For instance if we wanted to add a command +to print a backtrace when we hit this breakpoint we could do: (lldb) b command add -c 1.1 Enter your debugger command(s). Type 'DONE' to end. > bt > DONE -The "-c" specifies that the breakpoint command is a set of lldb +The "-c" option specifies that the breakpoint command is a set of lldb commmand interpreter commands. Use "-s" if you want to implement your -breakpoint command using the lldb Python interface instead. +breakpoint command using the Python interface instead. c) Running the program: @@ -240,7 +243,7 @@ d) Controlling execution: -Then we can continue till we hit our breakpoint. The primitive +After launching, we can continue until we hit our breakpoint. The primitive commands for process control all exist under the "thread" command: (lldb) thread continue @@ -250,31 +253,23 @@ At present you can only operate on one thread at a time, but the design will ultimately support saying "step over the function in -Thread-1, and step into the function in Thread 2, and continue Thread +Thread 1, and step into the function in Thread 2, and continue Thread 3" etc. When we eventually support keeping some threads running while others are stopped this will be particularly important. For -convenience, however, all the stepping type commands have easy -aliases. So "thread continue" is just "c", etc. +convenience, however, all the stepping commands have easy aliases. +So "thread continue" is just "c", etc. -The other program stepping commands are pretty much the same as in gdb. You've got: +The other program stepping commands are pretty much the same as in gdb. +You've got: -(lldb) thread step-in + 1. (lldb) thread step-in + The same as gdb's "step" -- there is also the alias "s" in lldb -which is the same as gdb's "step" or the alias: + 2. (lldb) thread step-over + The same as gdb's "next" -- there is also the alias "n" in lldb -(lldb) s - -(lldb) thread step-over - -which is the same as gdb's "next" and is aliased to - -(lldb) n - -(lldb) thread step-out - -which is the same as gdb's "finish" and is aliased to - -(lldb) f + 3. (lldb) thread step-out + The same as gdb's "finish" -- there is also the alias "f" in lldb And the "by instruction" versions: @@ -287,17 +282,16 @@ which runs the thread in the current frame till it reaches line 100 in this frame or stops if it leaves the current frame. This is a pretty -close equivalent to gdb's until command. +close equivalent to gdb's "until" command. -One thing here that might be a little disconcerting to gdb users here -is that when you resume you immediately get a prompt back. That's -because the lldb interpreter remains live when you are running the -target. This allows you to set a breakpoint, etc without having to -explicitly interrupt the program you are debugging. We're still -working out all the operations that it is safe to do while running. -But this way of operation will set us up for "no stop" debugging when -we get to implementing that. +One thing here that might be a little disconcerting to gdb users here is that +when you resume process execution, you immediately get a prompt back. That's +because the lldb interpreter remains live when you are running the target. +This allows you to set a breakpoint, etc without having to explicitly interrupt +the program you are debugging. We're still working out all the operations +that it is safe to do while running. But this way of operation will set us +up for "no stop" debugging when we get to implementing that. If you want to interrupt a running program do: @@ -353,7 +347,7 @@ You can also provide a list of threads to backtrace, or the keyword "all" to see all threads: -(lldb) thread backtrace all... +(lldb) thread backtrace all Next task is inspecting data: @@ -372,7 +366,8 @@ (lldb) frame variable self (SKTGraphicView *) self = 0x0000000100208b40 -The frame variable command is not a full expression parser but it does support some common operations like defererencing: +The frame variable command is not a full expression parser but it +does support some common operations like defererencing: (lldb) fr v *self (SKTGraphicView *) self = 0x0000000100208b40 @@ -382,11 +377,11 @@ and structure element references: -(lldb) frame variable self.NS(lldb) frame variable self.isa +(lldb) frame variable self.isa (struct objc_class *) self.isa = 0x0000000100023730 -The frame variable command will also perform "object printing" operations on variables (currently we -only support NSPrintForDebugger) with: +The frame variable command will also perform "object printing" operations on +variables (currently we only support NSPrintForDebugger) with: (lldb) fr v -o self (SKTGraphicView *) self = 0x0000000100208b40 @@ -426,12 +421,13 @@ $2 = (int) 22 I have a pointer 0x0. -One thing to note from this example is that lldb commands can be -defined to take "raw" input. "expression" is one of these. So in the expression command, -you don't have to quote your whole expression, nor backslash protect quotes, etc... +One thing to note from this example is that lldb commands can be defined to +take "raw" input. "expression" is one of these. So in the expression command, +you don't have to quote your whole expression, nor backslash protect quotes, +etc... -Finally, the results of the expressions are stored in persistent -variables (of the form \$([0-9])+) that you can use in further expressions, like: +Finally, the results of the expressions are stored in persistent variables +(of the form $[0-9]+) that you can use in further expressions, like: (lldb) expr self = $0 $4 = (SKTGraphicView *) 0x0000000100135430 From gclayton at apple.com Fri Sep 10 22:13:28 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 11 Sep 2010 03:13:28 -0000 Subject: [Lldb-commits] [lldb] r113678 - in /lldb/trunk: include/lldb/Symbol/Symtab.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectImage.cpp source/Core/Module.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Symbol/Symbol.cpp source/Symbol/Symtab.cpp Message-ID: <20100911031328.4999E2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 10 22:13:28 2010 New Revision: 113678 URL: http://llvm.org/viewvc/llvm-project?rev=113678&view=rev Log: Remove the eSymbolTypeFunction, eSymbolTypeGlobal, and eSymbolTypeStatic. They will now be represented as: eSymbolTypeFunction: eSymbolTypeCode with IsDebug() == true eSymbolTypeGlobal: eSymbolTypeData with IsDebug() == true and IsExternal() == true eSymbolTypeStatic: eSymbolTypeData with IsDebug() == true and IsExternal() == false This simplifies the logic when dealing with symbols and allows for symbols to be coalesced into a single symbol most of the time. Enabled the minimal symbol table for mach-o again after working out all the kinks. We now get nice concise symbol tables and debugging with DWARF in the .o files with a debug map in the binary works well again. There were issues where the SymbolFileDWARFDebugMap symbol file parser was using symbol IDs and symbol indexes interchangeably. Now that all those issues are resolved debugging is working nicely. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Fri Sep 10 22:13:28 2010 @@ -22,6 +22,18 @@ class Symtab { public: + typedef enum Debug { + eDebugNo, // Not a debug symbol + eDebugYes, // A debug symbol + eDebugAny + } Debug; + + typedef enum Visibility { + eVisibilityAny, + eVisibilityExtern, + eVisibilityPrivate + } Visibility; + Symtab(ObjectFile *objfile); ~Symtab(); @@ -31,19 +43,24 @@ size_t GetNumSymbols() const; void Dump(Stream *s, Process *process) const; void Dump(Stream *s, Process *process, std::vector& indexes) const; - + uint32_t GetIndexForSymbol (const Symbol *symbol) const; Symbol * FindSymbolByID (lldb::user_id_t uid) const; Symbol * SymbolAtIndex (uint32_t idx); const Symbol * SymbolAtIndex (uint32_t idx) const; - Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx); - const Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx) const; - uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector& matches, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; + Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx); +// const Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx) const; + uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; + uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector& matches); + uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches); uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, std::vector& matches); + uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches); uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector& indexes); + uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes); size_t FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, std::vector& symbol_indexes); - size_t FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector& symbol_indexes); - Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); + size_t FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes); + size_t FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes); + Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility); Symbol * FindSymbolWithFileAddress (lldb::addr_t file_addr); // Symbol * FindSymbolContainingAddress (const Address& value, const uint32_t* indexes, uint32_t num_indexes); // Symbol * FindSymbolContainingAddress (const Address& value); @@ -69,6 +86,41 @@ UniqueCStringMap m_name_to_index; private: + + bool + CheckSymbolAtIndex (uint32_t idx, Debug symbol_debug_type, Visibility symbol_visibility) const + { + switch (symbol_debug_type) + { + case eDebugNo: + if (m_symbols[idx].IsDebug() == true) + return false; + break; + + case eDebugYes: + if (m_symbols[idx].IsDebug() == false) + return false; + break; + + case eDebugAny: + break; + } + + switch (symbol_visibility) + { + case eVisibilityAny: + return true; + + case eVisibilityExtern: + return m_symbols[idx].IsExternal(); + + case eVisibilityPrivate: + return !m_symbols[idx].IsExternal(); + } + return false; + } + + DISALLOW_COPY_AND_ASSIGN (Symtab); }; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep 10 22:13:28 2010 @@ -248,12 +248,8 @@ eSymbolTypeSourceFile, eSymbolTypeHeaderFile, eSymbolTypeObjectFile, - eSymbolTypeFunction, - eSymbolTypeFunctionEnd, eSymbolTypeCommonBlock, eSymbolTypeBlock, - eSymbolTypeStatic, - eSymbolTypeGlobal, eSymbolTypeLocal, eSymbolTypeParam, eSymbolTypeVariable, Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Fri Sep 10 22:13:28 2010 @@ -276,7 +276,8 @@ if (name_is_regex) { RegularExpression name_regexp(name); - num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType (name_regexp, eSymbolTypeAny, + num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType (name_regexp, + eSymbolTypeAny, match_indexes); } else Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Fri Sep 10 22:13:28 2010 @@ -438,7 +438,7 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - return symtab->FindFirstSymbolWithNameAndType (name, symbol_type); + return symtab->FindFirstSymbolWithNameAndType (name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny); } return NULL; } @@ -506,7 +506,7 @@ if (symtab) { std::vector symbol_indexes; - symtab->FindAllSymbolsMatchingRexExAndType (regex, symbol_type, symbol_indexes); + symtab->FindAllSymbolsMatchingRexExAndType (regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes); SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list); } } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Sep 10 22:13:28 2010 @@ -206,7 +206,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); - ParseSymtab (false); + ParseSymtab (true); } return m_symtab_ap.get(); } @@ -638,7 +638,7 @@ // ... assert (!"UNIMPLEMENTED: Swap all nlist entries"); } - uint32_t N_SO_index = UINT_MAX; + uint32_t N_SO_index = UINT32_MAX; MachSymtabSectionInfo section_info (section_list); std::vector N_FUN_indexes; @@ -647,8 +647,12 @@ std::vector N_BRAC_indexes; std::vector N_COMM_indexes; typedef std::map ValueToSymbolIndexMap; + typedef std::map IndexToIndexMap; ValueToSymbolIndexMap N_FUN_addr_to_sym_idx; ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx; + // Any symbols that get merged into another will get an entry + // in this map so we know + IndexToIndexMap m_index_map; uint32_t nlist_idx = 0; Symbol *symbol_ptr = NULL; @@ -693,21 +697,22 @@ case StabGlobalSymbol: // N_GSYM -- global symbol: name,,NO_SECT,type,0 // Sometimes the N_GSYM value contains the address. + sym[sym_idx].SetExternal(true); if (nlist.n_value != 0) symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); - type = eSymbolTypeGlobal; + type = eSymbolTypeData; break; case StabFunctionName: // N_FNAME -- procedure name (f77 kludge): name,,NO_SECT,0,0 - type = eSymbolTypeFunction; + type = eSymbolTypeCompiler; break; case StabFunction: // N_FUN -- procedure: name,,n_sect,linenumber,address if (symbol_name) { - type = eSymbolTypeFunction; + type = eSymbolTypeCode; symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); N_FUN_addr_to_sym_idx[nlist.n_value] = sym_idx; @@ -717,7 +722,7 @@ } else { - type = eSymbolTypeFunctionEnd; + type = eSymbolTypeCompiler; if ( !N_FUN_indexes.empty() ) { @@ -738,7 +743,7 @@ // N_STSYM -- static symbol: name,,n_sect,type,address N_STSYM_addr_to_sym_idx[nlist.n_value] = sym_idx; symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); - type = eSymbolTypeStatic; + type = eSymbolTypeData; break; case StabLocalCommon: @@ -814,20 +819,15 @@ type = eSymbolTypeSourceFile; if (symbol_name == NULL) { - if (N_SO_index == UINT_MAX) - { - // Skip the extra blank N_SO entries that happen when the entire - // path is contained in the second consecutive N_SO STAB. - if (minimize) - add_nlist = false; - } - else + if (minimize) + add_nlist = false; + if (N_SO_index != UINT32_MAX) { // Set the size of the N_SO to the terminating index of this N_SO // so that we can always skip the entire N_SO if we need to navigate // more quickly at the source level when parsing STABS symbol_ptr = symtab->SymbolAtIndex(N_SO_index); - symbol_ptr->SetByteSize(sym_idx + 1); + symbol_ptr->SetByteSize(sym_idx + (minimize ? 0 : 1)); symbol_ptr->SetSizeIsSibling(true); } N_NSYM_indexes.clear(); @@ -835,14 +835,30 @@ N_BRAC_indexes.clear(); N_COMM_indexes.clear(); N_FUN_indexes.clear(); - N_SO_index = UINT_MAX; + N_SO_index = UINT32_MAX; } - else if (symbol_name[0] == '/') + else { // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out - N_SO_index = sym_idx; + if (symbol_name[0] == '/') + N_SO_index = sym_idx; + else if (minimize && (N_SO_index == sym_idx - 1)) + { + const char *so_path = sym[sym_idx - 1].GetMangled().GetDemangledName().AsCString(); + if (so_path && so_path[0]) + { + std::string full_so_path (so_path); + if (*full_so_path.rbegin() != '/') + full_so_path += '/'; + full_so_path += symbol_name; + sym[sym_idx - 1].GetMangled().SetValue(full_so_path.c_str(), false); + add_nlist = false; + m_index_map[nlist_idx] = sym_idx - 1; + } + } } + break; case StabObjectFileName: @@ -1103,45 +1119,48 @@ if (symbol_name) sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); - if (type == eSymbolTypeCode) + if (is_debug == false) { - // See if we can find a N_FUN entry for any code symbols. - // If we do find a match, and the name matches, then we - // can merge the two into just the function symbol to avoid - // duplicate entries in the symbol table - ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value); - if (pos != N_FUN_addr_to_sym_idx.end()) + if (type == eSymbolTypeCode) { - if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || - (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + // See if we can find a N_FUN entry for any code symbols. + // If we do find a match, and the name matches, then we + // can merge the two into just the function symbol to avoid + // duplicate entries in the symbol table + ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value); + if (pos != N_FUN_addr_to_sym_idx.end()) { - - // We just need the flags from the linker symbol, so put these flags - // into the N_FUN flags to avoid duplicate symbols in the symbol table - sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); - sym[sym_idx].GetMangled().Clear(); - continue; + if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || + (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + { + m_index_map[nlist_idx] = pos->second; + // We just need the flags from the linker symbol, so put these flags + // into the N_FUN flags to avoid duplicate symbols in the symbol table + sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + sym[sym_idx].Clear(); + continue; + } } } - } - else if (type == eSymbolTypeData) - { - // See if we can find a N_STSYM entry for any data symbols. - // If we do find a match, and the name matches, then we - // can merge the two into just the Static symbol to avoid - // duplicate entries in the symbol table - ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value); - if (pos != N_STSYM_addr_to_sym_idx.end()) + else if (type == eSymbolTypeData) { - if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || - (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + // See if we can find a N_STSYM entry for any data symbols. + // If we do find a match, and the name matches, then we + // can merge the two into just the Static symbol to avoid + // duplicate entries in the symbol table + ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value); + if (pos != N_STSYM_addr_to_sym_idx.end()) { - - // We just need the flags from the linker symbol, so put these flags - // into the N_STSYM flags to avoid duplicate symbols in the symbol table - sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); - sym[sym_idx].GetMangled().Clear(); - continue; + if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || + (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) + { + m_index_map[nlist_idx] = pos->second; + // We just need the flags from the linker symbol, so put these flags + // into the N_STSYM flags to avoid duplicate symbols in the symbol table + sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); + sym[sym_idx].Clear(); + continue; + } } } } @@ -1171,13 +1190,13 @@ Symbol *global_symbol = NULL; for (nlist_idx = 0; - nlist_idx < symtab_load_command.nsyms && (global_symbol = symtab->FindSymbolWithType(eSymbolTypeGlobal, nlist_idx)) != NULL; + nlist_idx < symtab_load_command.nsyms && (global_symbol = symtab->FindSymbolWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, nlist_idx)) != NULL; nlist_idx++) { if (global_symbol->GetValue().GetFileAddress() == 0) { std::vector indexes; - if (symtab->AppendSymbolIndexesWithName(global_symbol->GetMangled().GetName(), indexes) > 0) + if (symtab->AppendSymbolIndexesWithName (global_symbol->GetMangled().GetName(), indexes) > 0) { std::vector::const_iterator pos; std::vector::const_iterator end = indexes.end(); @@ -1200,6 +1219,7 @@ if (indirect_symbol_indexes_sp && indirect_symbol_indexes_sp->GetByteSize()) { + IndexToIndexMap::const_iterator end_index_pos = m_index_map.end(); DataExtractor indirect_symbol_index_data (indirect_symbol_indexes_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize()); for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx) @@ -1224,7 +1244,12 @@ uint32_t symbol_stub_offset = symbol_stub_index * 4; if (indirect_symbol_index_data.ValidOffsetForDataOfSize(symbol_stub_offset, 4)) { - const uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); + uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); + + IndexToIndexMap::const_iterator index_pos = m_index_map.find (symbol_index); + assert (index_pos == end_index_pos); // TODO: remove this assert if it fires, else remove m_index_map + if (index_pos != end_index_pos) + symbol_index = index_pos->second; Symbol *stub_symbol = symtab->FindSymbolByID (symbol_index); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Sep 10 22:13:28 2010 @@ -91,8 +91,8 @@ std::vector oso_indexes; const uint32_t oso_index_count = symtab->AppendSymbolIndexesWithType(eSymbolTypeObjectFile, oso_indexes); - symtab->AppendSymbolIndexesWithType(eSymbolTypeFunction, m_func_indexes); - symtab->AppendSymbolIndexesWithType(eSymbolTypeGlobal, m_glob_indexes); + symtab->AppendSymbolIndexesWithType (eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); + symtab->AppendSymbolIndexesWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, m_glob_indexes); symtab->SortSymbolIndexesByValue(m_func_indexes, true); symtab->SortSymbolIndexesByValue(m_glob_indexes, true); @@ -109,6 +109,12 @@ if (m_compile_unit_infos[i].so_symbol->GetSiblingIndex() == 0) m_compile_unit_infos[i].so_symbol = symtab->SymbolAtIndex(oso_indexes[i] - 2); m_compile_unit_infos[i].oso_symbol = symtab->SymbolAtIndex(oso_indexes[i]); + uint32_t sibling_idx = m_compile_unit_infos[i].so_symbol->GetSiblingIndex(); + assert (sibling_idx != 0); + assert (sibling_idx > i + 1); + m_compile_unit_infos[i].last_symbol = symtab->SymbolAtIndex (sibling_idx - 1); + m_compile_unit_infos[i].first_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].so_symbol); + m_compile_unit_infos[i].last_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].last_symbol); } } } @@ -243,7 +249,9 @@ //SectionList *oso_sections = oso_objfile->Sections(); // Now we need to make sections that map from zero based object // file addresses to where things eneded up in the main executable. - uint32_t oso_start_idx = comp_unit_info->oso_symbol->GetID() + 1; + uint32_t oso_start_idx = exe_symtab->GetIndexForSymbol (comp_unit_info->oso_symbol); + assert (oso_start_idx != UINT32_MAX); + oso_start_idx += 1; const uint32_t oso_end_idx = comp_unit_info->so_symbol->GetSiblingIndex(); uint32_t sect_id = 0x10000; for (uint32_t idx = oso_start_idx; idx < oso_end_idx; ++idx) @@ -251,9 +259,12 @@ Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx); if (exe_symbol) { + if (exe_symbol->IsDebug() == false) + continue; + switch (exe_symbol->GetType()) { - case eSymbolTypeFunction: + case eSymbolTypeCode: { // For each N_FUN, or function that we run into in the debug map // we make a new section that we add to the sections found in the @@ -265,7 +276,7 @@ // correctly to the new addresses in the main executable. // First we find the original symbol in the .o file's symbol table - Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeCode); + Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny); if (oso_fun_symbol) { // If we found the symbol, then we @@ -299,8 +310,7 @@ } break; - case eSymbolTypeGlobal: - case eSymbolTypeStatic: + case eSymbolTypeData: { // For each N_GSYM we remap the address for the global by making // a new section that we add to the sections found in the .o file. @@ -317,7 +327,7 @@ #if 0 // First we find the non-stab entry that corresponds to the N_GSYM in the executable - Symbol *exe_gsym_symbol = exe_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData); + Symbol *exe_gsym_symbol = exe_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny); #else // The mach-o object file parser already matches up the N_GSYM with with the non-stab // entry, so we shouldn't have to do that. If this ever changes, enable the code above @@ -325,7 +335,7 @@ Symbol *exe_gsym_symbol = exe_symbol; #endif // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file - Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData); + Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny); if (exe_gsym_symbol && oso_gsym_symbol) { // If we found the symbol, then we @@ -598,7 +608,7 @@ resolved_flags |= eSymbolContextSymbol; uint32_t oso_idx = 0; - CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithIndex (sc.symbol->GetID(), &oso_idx); + CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithID (sc.symbol->GetID(), &oso_idx); if (comp_unit_info) { SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); @@ -709,7 +719,7 @@ if (symtab) { std::vector indexes; - const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeGlobal, indexes); + const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, indexes); if (match_count) { PrivateFindGlobalVariables (name, indexes, max_matches, variables); @@ -728,14 +738,29 @@ int -SymbolFileDWARFDebugMap::SymbolContainsSymbolIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) +SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) { const uint32_t symbol_idx = *symbol_idx_ptr; - if (symbol_idx < comp_unit_info->so_symbol->GetID()) + if (symbol_idx < comp_unit_info->first_symbol_index) + return -1; + + if (symbol_idx <= comp_unit_info->last_symbol_index) + return 0; + + return 1; +} + + +int +SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) +{ + const user_id_t symbol_id = *symbol_idx_ptr; + + if (symbol_id < comp_unit_info->so_symbol->GetID()) return -1; - if (symbol_idx < comp_unit_info->so_symbol->GetSiblingIndex()) + if (symbol_id <= comp_unit_info->last_symbol->GetID()) return 0; return 1; @@ -749,7 +774,7 @@ CompileUnitInfo *comp_unit_info = NULL; if (oso_index_count) { - comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolIndex); + comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolWithIndex); } if (oso_idx_ptr) @@ -762,6 +787,27 @@ return comp_unit_info; } +SymbolFileDWARFDebugMap::CompileUnitInfo* +SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID (user_id_t symbol_id, uint32_t *oso_idx_ptr) +{ + const uint32_t oso_index_count = m_compile_unit_infos.size(); + CompileUnitInfo *comp_unit_info = NULL; + if (oso_index_count) + { + comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_id, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolWithID); + } + + if (oso_idx_ptr) + { + if (comp_unit_info != NULL) + *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0]; + else + *oso_idx_ptr = UINT32_MAX; + } + return comp_unit_info; +} + + static void RemoveFunctionsWithModuleNotEqualTo (Module *module, SymbolContextList &sc_list, uint32_t start_idx) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Sep 10 22:13:28 2010 @@ -105,26 +105,29 @@ lldb_private::FileSpec so_file; lldb_private::Symbol *so_symbol; lldb_private::Symbol *oso_symbol; + lldb_private::Symbol *last_symbol; + uint32_t first_symbol_index; + uint32_t last_symbol_index; lldb::ModuleSP oso_module_sp; lldb::CompUnitSP oso_compile_unit_sp; lldb_private::SymbolVendor *oso_symbol_vendor; -// lldb_private::shared_ptr oso_dwarf_sp; -// lldb_private::shared_ptr oso_dwarf_sp; std::vector function_indexes; std::vector static_indexes; lldb::SharedPtr::Type debug_map_sections_sp; CompileUnitInfo() : - so_file(), - so_symbol(NULL), - oso_symbol(NULL), - oso_module_sp(), - oso_compile_unit_sp(), - oso_symbol_vendor(NULL), -// oso_dwarf_sp(), - function_indexes(), - static_indexes(), - debug_map_sections_sp() + so_file (), + so_symbol (NULL), + oso_symbol (NULL), + last_symbol (NULL), + first_symbol_index (UINT32_MAX), + last_symbol_index (UINT32_MAX), + oso_module_sp (), + oso_compile_unit_sp (), + oso_symbol_vendor (NULL), + function_indexes (), + static_indexes (), + debug_map_sections_sp () { } }; @@ -162,11 +165,17 @@ SymbolFileDWARF * GetSymbolFileByOSOIndex (uint32_t oso_idx); - CompileUnitInfo* + CompileUnitInfo * GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr); + + CompileUnitInfo * + GetCompileUnitInfoForSymbolWithID (lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr); + + static int + SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); static int - SymbolContainsSymbolIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); + SymbolContainsSymbolWithID (lldb::user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); uint32_t PrivateFindGlobalVariables (const lldb_private::ConstString &name, Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Sep 10 22:13:28 2010 @@ -90,14 +90,14 @@ { abilities |= CompileUnits; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeFunction, m_func_indexes); + symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); if (!m_func_indexes.empty()) { symtab->SortSymbolIndexesByValue(m_func_indexes, true); abilities |= Functions; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, m_code_indexes); + symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes); if (!m_code_indexes.empty()) { symtab->SortSymbolIndexesByValue(m_code_indexes, true); @@ -319,8 +319,7 @@ { const uint32_t start_size = sc_list.GetSize(); std::vector symbol_indexes; - symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeFunction, symbol_indexes); - symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, symbol_indexes); + symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes); const uint32_t num_matches = symbol_indexes.size(); if (num_matches) { Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Fri Sep 10 22:13:28 2010 @@ -268,7 +268,7 @@ uint32_t Symbol::GetPrologueByteSize () { - if (m_type == eSymbolTypeCode || m_type == eSymbolTypeFunction) + if (m_type == eSymbolTypeCode) { if (!m_type_data_resolved) { @@ -326,12 +326,8 @@ ENUM_TO_CSTRING(SourceFile); ENUM_TO_CSTRING(HeaderFile); ENUM_TO_CSTRING(ObjectFile); - ENUM_TO_CSTRING(Function); - ENUM_TO_CSTRING(FunctionEnd); ENUM_TO_CSTRING(CommonBlock); ENUM_TO_CSTRING(Block); - ENUM_TO_CSTRING(Static); - ENUM_TO_CSTRING(Global); ENUM_TO_CSTRING(Local); ENUM_TO_CSTRING(Param); ENUM_TO_CSTRING(Variable); Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113678&r1=113677&r2=113678&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Fri Sep 10 22:13:28 2010 @@ -218,7 +218,7 @@ } uint32_t -Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const +Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { uint32_t prev_size = indexes.size(); @@ -233,6 +233,35 @@ return indexes.size() - prev_size; } +uint32_t +Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const +{ + uint32_t prev_size = indexes.size(); + + const uint32_t count = std::min (m_symbols.size(), end_index); + + for (uint32_t i = start_idx; i < count; ++i) + { + if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type) + { + if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility)) + indexes.push_back(i); + } + } + + return indexes.size() - prev_size; +} + + +uint32_t +Symtab::GetIndexForSymbol (const Symbol *symbol) const +{ + const Symbol *first_symbol = &m_symbols[0]; + if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size()) + return symbol - first_symbol; + return UINT32_MAX; +} + struct SymbolSortInfo { const bool sort_by_load_addr; @@ -291,7 +320,7 @@ } uint32_t -Symtab::AppendSymbolIndexesWithName(const ConstString& symbol_name, std::vector& indexes) +Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector& indexes) { Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (symbol_name) @@ -314,7 +343,31 @@ } uint32_t -Symtab::AppendSymbolIndexesWithNameAndType(const ConstString& symbol_name, SymbolType symbol_type, std::vector& indexes) +Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) +{ + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); + if (symbol_name) + { + const size_t old_size = indexes.size(); + if (m_name_to_index.IsEmpty()) + InitNameIndexes(); + + const char *symbol_cstr = symbol_name.GetCString(); + const UniqueCStringMap::Entry *entry_ptr; + for (entry_ptr = m_name_to_index.FindFirstValueForName (symbol_cstr); + entry_ptr!= NULL; + entry_ptr = m_name_to_index.FindNextValueForName (symbol_cstr, entry_ptr)) + { + if (CheckSymbolAtIndex(entry_ptr->value, symbol_debug_type, symbol_visibility)) + indexes.push_back (entry_ptr->value); + } + return indexes.size() - old_size; + } + return 0; +} + +uint32_t +Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, std::vector& indexes) { if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) { @@ -331,6 +384,24 @@ } uint32_t +Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) +{ + if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type, symbol_visibility, indexes) > 0) + { + std::vector::iterator pos = indexes.begin(); + while (pos != indexes.end()) + { + if (symbol_type == eSymbolTypeAny || m_symbols[*pos].GetType() == symbol_type) + ++pos; + else + indexes.erase(pos); + } + } + return indexes.size(); +} + + +uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, std::vector& indexes) { uint32_t prev_size = indexes.size(); @@ -352,31 +423,44 @@ } -Symbol * -Symtab::FindSymbolWithType(SymbolType symbol_type, uint32_t& start_idx) +uint32_t +Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { - const size_t count = m_symbols.size(); - for (uint32_t idx = start_idx; idx < count; ++idx) + uint32_t prev_size = indexes.size(); + uint32_t sym_end = m_symbols.size(); + + for (int i = 0; i < sym_end; i++) { - if (symbol_type == eSymbolTypeAny || m_symbols[idx].GetType() == symbol_type) + if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type) { - start_idx = idx; - return &m_symbols[idx]; + if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility) == false) + continue; + + const char *name = m_symbols[i].GetMangled().GetName().AsCString(); + if (name) + { + if (regexp.Execute (name)) + indexes.push_back(i); + } } } - return NULL; + return indexes.size() - prev_size; + } -const Symbol * -Symtab::FindSymbolWithType(SymbolType symbol_type, uint32_t& start_idx) const +Symbol * +Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t& start_idx) { const size_t count = m_symbols.size(); for (uint32_t idx = start_idx; idx < count; ++idx) { if (symbol_type == eSymbolTypeAny || m_symbols[idx].GetType() == symbol_type) { - start_idx = idx; - return &m_symbols[idx]; + if (CheckSymbolAtIndex(idx, symbol_debug_type, symbol_visibility)) + { + start_idx = idx; + return &m_symbols[idx]; + } } } return NULL; @@ -395,20 +479,38 @@ { // The string table did have a string that matched, but we need // to check the symbols and match the symbol_type if any was given. - AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes); + AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_indexes); + } + return symbol_indexes.size(); +} + +size_t +Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) +{ + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); + // Initialize all of the lookup by name indexes before converting NAME + // to a uniqued string NAME_STR below. + if (m_name_to_index.IsEmpty()) + InitNameIndexes(); + + if (name) + { + // The string table did have a string that matched, but we need + // to check the symbols and match the symbol_type if any was given. + AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); } return symbol_indexes.size(); } size_t -Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, SymbolType symbol_type, std::vector& symbol_indexes) +Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) { - AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_indexes); + AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); return symbol_indexes.size(); } Symbol * -Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type) +Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility) { Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (m_name_to_index.IsEmpty()) @@ -419,7 +521,7 @@ std::vector matching_indexes; // The string table did have a string that matched, but we need // to check the symbols and match the symbol_type if any was given. - if (AppendSymbolIndexesWithNameAndType(name, symbol_type, matching_indexes)) + if (AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_debug_type, symbol_visibility, matching_indexes)) { std::vector::const_iterator pos, end = matching_indexes.end(); for (pos = matching_indexes.begin(); pos != end; ++pos) @@ -514,9 +616,6 @@ { if (m_addr_indexes.empty()) { - AppendSymbolIndexesWithType (eSymbolTypeFunction, m_addr_indexes); - AppendSymbolIndexesWithType (eSymbolTypeGlobal, m_addr_indexes); - AppendSymbolIndexesWithType (eSymbolTypeStatic, m_addr_indexes); AppendSymbolIndexesWithType (eSymbolTypeCode, m_addr_indexes); AppendSymbolIndexesWithType (eSymbolTypeTrampoline, m_addr_indexes); AppendSymbolIndexesWithType (eSymbolTypeData, m_addr_indexes); From ctice at apple.com Sat Sep 11 19:10:52 2010 From: ctice at apple.com (Caroline Tice) Date: Sun, 12 Sep 2010 00:10:52 -0000 Subject: [Lldb-commits] [lldb] r113709 - in /lldb/trunk: include/lldb/Host/Host.h source/Core/FileSpec.cpp source/Host/common/Host.cpp Message-ID: <20100912001052.9CD462A6C12C@llvm.org> Author: ctice Date: Sat Sep 11 19:10:52 2010 New Revision: 113709 URL: http://llvm.org/viewvc/llvm-project?rev=113709&view=rev Log: Remove Host::ResolveExecutableLocation (very recent addition); replace use of it with llvm::sys::Program::FindProgramByName. Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113709&r1=113708&r2=113709&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Sat Sep 11 19:10:52 2010 @@ -259,9 +259,6 @@ static bool ResolveExecutableInBundle (FileSpec *file); - static bool - ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename); - static uint32_t ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=113709&r1=113708&r2=113709&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Sat Sep 11 19:10:52 2010 @@ -18,6 +18,10 @@ #include +#include "llvm/ADT/StringRef.h" +#include "llvm/System/Path.h" +#include "llvm/System/Program.h" + #include "lldb/Core/FileSpec.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferMemoryMap.h" @@ -418,7 +422,35 @@ bool FileSpec::ResolveExecutableLocation () { - return Host::ResolveExecutableLocation (m_directory, m_filename); + if (m_directory.GetLength() == 0) + { + const std::string file_str (m_filename.AsCString()); + llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str); + llvm::StringRef dir_ref = path.getDirname(); + if (! dir_ref.empty()) + { + // FindProgramByName returns "." if it can't find the file. + if (strcmp (".", dir_ref.data()) == 0) + return false; + + m_directory.SetCString (dir_ref.data()); + if (Exists()) + return true; + else + { + // If FindProgramByName found the file, it returns the directory + filename in its return results. + // We need to separate them. + FileSpec tmp_file (dir_ref.data()); + if (tmp_file.Exists()) + { + m_directory = tmp_file.m_directory; + return true; + } + } + } + } + + return false; } uint64_t Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113709&r1=113708&r2=113709&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Sat Sep 11 19:10:52 2010 @@ -727,59 +727,3 @@ return false; } #endif - -bool -Host::ResolveExecutableLocation (ConstString &directory_name, const ConstString &filename) -{ - // If the user specified just a plain filename, there may be additional ways to find the - // file, such as searching the PATH environment variable on UNIX systems. This is the location - // to implement such additional searches. - - // For now the only search we are implementing is search $PATH, which makes no sense if - // the user already specified a directory. - - if (directory_name.GetLength() > 0) - return false; - - std::string search_path (getenv ("PATH")); - char dir_separator = ':'; - - bool done = false; - bool found = false; - size_t start = 0; - while (!done && !found) - { - size_t end = search_path.find (dir_separator, start); - size_t length; - if (end == std::string::npos) - { - done = true; - length = search_path.length() - start; - } - else - length = end - start; - - std::string directory_str = search_path.substr (start, length); - - if (directory_str.length() > 0) - { - StreamString tmp_full_path_name; - if (directory_str[directory_str.length()-1] == '/') - tmp_full_path_name.Printf ("%s%s", directory_str.c_str(), filename.AsCString()); - else - tmp_full_path_name.Printf ("%s/%s", directory_str.c_str(), filename.AsCString()); - - struct stat sb; - - if (::stat (tmp_full_path_name.GetData(), &sb) == 0) - { - found = true; - directory_name.SetCString (directory_str.c_str()); - } - } - - if (!done) - start = end + 1; - } - return found; -} From ctice at apple.com Sat Sep 11 23:48:45 2010 From: ctice at apple.com (Caroline Tice) Date: Sun, 12 Sep 2010 04:48:45 -0000 Subject: [Lldb-commits] [lldb] r113714 - /lldb/trunk/source/Interpreter/Args.cpp Message-ID: <20100912044845.8543F2A6C12C@llvm.org> Author: ctice Date: Sat Sep 11 23:48:45 2010 New Revision: 113714 URL: http://llvm.org/viewvc/llvm-project?rev=113714&view=rev Log: Add missing result.SetStatus, to allow aliases to be created with missing arguments for some of the command options. Modified: lldb/trunk/source/Interpreter/Args.cpp Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=113714&r1=113713&r2=113714&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Sat Sep 11 23:48:45 2010 @@ -893,6 +893,7 @@ { case no_argument: option_arg_vector->push_back (OptionArgPair (std::string (option_str.GetData()), "")); + result.SetStatus (eReturnStatusSuccessFinishNoResult); break; case required_argument: if (optarg != NULL) From ctice at apple.com Sat Sep 11 23:56:10 2010 From: ctice at apple.com (Caroline Tice) Date: Sun, 12 Sep 2010 04:56:10 -0000 Subject: [Lldb-commits] [lldb] r113715 - /lldb/trunk/source/Commands/CommandObjectCommands.cpp Message-ID: <20100912045610.93A682A6C12C@llvm.org> Author: ctice Date: Sat Sep 11 23:56:10 2010 New Revision: 113715 URL: http://llvm.org/viewvc/llvm-project?rev=113715&view=rev Log: Add 'unalias' to the commands sub-command dictionary. Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=113715&r1=113714&r2=113715&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Sat Sep 11 23:56:10 2010 @@ -349,8 +349,8 @@ public: CommandObjectCommandsUnalias () : CommandObject ("commands unalias", - "Allows the user to remove/delete a user-defined command abbreviation.", - "unalias ") + "Allow the user to remove/delete a user-defined command abbreviation.", + "unalias ") { } @@ -429,6 +429,7 @@ { LoadSubCommand (interpreter, "source", CommandObjectSP (new CommandObjectCommandsSource ())); LoadSubCommand (interpreter, "alias", CommandObjectSP (new CommandObjectCommandsAlias ())); + LoadSubCommand (interpreter, "unalias", CommandObjectSP (new CommandObjectCommandsUnalias ())); } CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands () From gclayton at apple.com Sun Sep 12 00:25:17 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 12 Sep 2010 05:25:17 -0000 Subject: [Lldb-commits] [lldb] r113719 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp Message-ID: <20100912052517.313012A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 00:25:16 2010 New Revision: 113719 URL: http://llvm.org/viewvc/llvm-project?rev=113719&view=rev Log: Fixed an issue I found in the mach-o symbol table parsing where we cached remapping information using the old nlist index to the new symbol index, yet we tried to lookup the symbol stubs that were for symbols that had been remapped by ID instead of using the new symbol index. This is now fixed and the mach-o symbol tables are fixed. Use the delta between two vector entries to determine the stride in case any padding is inserted by compilers for bsearch calls on symbol tables when finding symbols by their original ID. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113719&r1=113718&r2=113719&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Sep 12 00:25:16 2010 @@ -2325,7 +2325,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113719&r1=113718&r2=113719&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Sun Sep 12 00:25:16 2010 @@ -647,12 +647,12 @@ std::vector N_BRAC_indexes; std::vector N_COMM_indexes; typedef std::map ValueToSymbolIndexMap; - typedef std::map IndexToIndexMap; + typedef std::map NListIndexToSymbolIndexMap; ValueToSymbolIndexMap N_FUN_addr_to_sym_idx; ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx; // Any symbols that get merged into another will get an entry // in this map so we know - IndexToIndexMap m_index_map; + NListIndexToSymbolIndexMap m_nlist_idx_to_sym_idx; uint32_t nlist_idx = 0; Symbol *symbol_ptr = NULL; @@ -854,7 +854,7 @@ full_so_path += symbol_name; sym[sym_idx - 1].GetMangled().SetValue(full_so_path.c_str(), false); add_nlist = false; - m_index_map[nlist_idx] = sym_idx - 1; + m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1; } } } @@ -1133,7 +1133,7 @@ if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) { - m_index_map[nlist_idx] = pos->second; + m_nlist_idx_to_sym_idx[nlist_idx] = pos->second; // We just need the flags from the linker symbol, so put these flags // into the N_FUN flags to avoid duplicate symbols in the symbol table sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); @@ -1154,7 +1154,7 @@ if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) || (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName())) { - m_index_map[nlist_idx] = pos->second; + m_nlist_idx_to_sym_idx[nlist_idx] = pos->second; // We just need the flags from the linker symbol, so put these flags // into the N_STSYM flags to avoid duplicate symbols in the symbol table sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc); @@ -1212,6 +1212,15 @@ } } } + + // Trim our symbols down to just what we ended up with after + // removing any symbols. + if (sym_idx < num_syms) + { + num_syms = sym_idx; + sym = symtab->Resize (num_syms); + } + // Now synthesize indirect symbols if (m_dysymtab.nindirectsyms != 0) { @@ -1219,7 +1228,7 @@ if (indirect_symbol_indexes_sp && indirect_symbol_indexes_sp->GetByteSize()) { - IndexToIndexMap::const_iterator end_index_pos = m_index_map.end(); + NListIndexToSymbolIndexMap::const_iterator end_index_pos = m_nlist_idx_to_sym_idx.end(); DataExtractor indirect_symbol_index_data (indirect_symbol_indexes_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize()); for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx) @@ -1236,7 +1245,7 @@ continue; const uint32_t symbol_stub_index_offset = m_mach_sections[sect_idx].reserved1; - uint32_t stub_sym_id = symtab_load_command.nsyms; + uint32_t synthetic_stub_sym_id = symtab_load_command.nsyms; for (uint32_t stub_idx = 0; stub_idx < num_symbol_stubs; ++stub_idx) { const uint32_t symbol_stub_index = symbol_stub_index_offset + stub_idx; @@ -1244,14 +1253,23 @@ uint32_t symbol_stub_offset = symbol_stub_index * 4; if (indirect_symbol_index_data.ValidOffsetForDataOfSize(symbol_stub_offset, 4)) { - uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); + const uint32_t stub_sym_id = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); - IndexToIndexMap::const_iterator index_pos = m_index_map.find (symbol_index); - assert (index_pos == end_index_pos); // TODO: remove this assert if it fires, else remove m_index_map + NListIndexToSymbolIndexMap::const_iterator index_pos = m_nlist_idx_to_sym_idx.find (stub_sym_id); + Symbol *stub_symbol = NULL; if (index_pos != end_index_pos) - symbol_index = index_pos->second; - - Symbol *stub_symbol = symtab->FindSymbolByID (symbol_index); + { + // We have a remapping from the original nlist index to + // a current symbol index, so just look this up by index + stub_symbol = symtab->SymbolAtIndex (index_pos->second); + } + else + { + // We need to lookup a symbol using the original nlist + // symbol index since this index is coming from the + // S_SYMBOL_STUBS + stub_symbol = symtab->FindSymbolByID (stub_sym_id); + } assert (stub_symbol); if (stub_symbol) @@ -1273,11 +1291,8 @@ { // Make a synthetic symbol to describe the trampoline stub if (sym_idx >= num_syms) - { - sym = symtab->Resize (num_syms + 16); - num_syms = symtab->GetNumSymbols(); - } - sym[sym_idx].SetID (stub_sym_id++); + sym = symtab->Resize (++num_syms); + sym[sym_idx].SetID (synthetic_stub_sym_id++); sym[sym_idx].GetMangled() = stub_symbol->GetMangled(); sym[sym_idx].SetType (eSymbolTypeTrampoline); sym[sym_idx].SetIsSynthetic (true); @@ -1293,9 +1308,6 @@ } } - if (sym_idx != symtab->GetNumSymbols()) - symtab->Resize (sym_idx); - return symtab->GetNumSymbols(); } } Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113719&r1=113718&r2=113719&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Sun Sep 12 00:25:16 2010 @@ -155,7 +155,7 @@ Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, &m_symbols[0], m_symbols.size(), - sizeof(Symbol), + (uint8_t *)&m_symbols[1] - (uint8_t *)&m_symbols[0], CompareSymbolID); return symbol; } From gclayton at apple.com Sun Sep 12 01:24:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 12 Sep 2010 06:24:05 -0000 Subject: [Lldb-commits] [lldb] r113721 - in /lldb/trunk: include/lldb/Symbol/LineTable.h source/Symbol/CompileUnit.cpp source/Symbol/LineTable.cpp Message-ID: <20100912062405.7D88A2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 01:24:05 2010 New Revision: 113721 URL: http://llvm.org/viewvc/llvm-project?rev=113721&view=rev Log: Bug #: 8408441 Fixed an issue where LLDB would fail to set a breakpoint by file and line if the DWARF line table has multiple file entries in the support files for a source file. Modified: lldb/trunk/include/lldb/Symbol/LineTable.h lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/LineTable.cpp Modified: lldb/trunk/include/lldb/Symbol/LineTable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=113721&r1=113720&r2=113721&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineTable.h (original) +++ lldb/trunk/include/lldb/Symbol/LineTable.h Sun Sep 12 01:24:05 2010 @@ -158,6 +158,13 @@ uint32_t FindLineEntryIndexByFileIndex (uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry* line_entry_ptr); + uint32_t + FindLineEntryIndexByFileIndex (uint32_t start_idx, + const std::vector &file_indexes, + uint32_t line, + bool exact, + LineEntry* line_entry_ptr); + //------------------------------------------------------------------ /// Get the line entry from the line table at index \a idx. /// Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=113721&r1=113720&r2=113721&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Sun Sep 12 01:24:05 2010 @@ -281,58 +281,88 @@ SymbolContextList &sc_list ) { - const uint32_t prev_size = sc_list.GetSize(); + // First find all of the file indexes that match our "file_spec". If + // "file_spec" has an empty directory, then only compare the basenames + // when finding file indexes + std::vector file_indexes; bool file_spec_matches_cu_file_spec = FileSpec::Compare(file_spec, this, !file_spec.GetDirectory().IsEmpty()) == 0; - if (check_inlines || file_spec_matches_cu_file_spec) + + // If we are not looking for inlined functions and our file spec doesn't + // match then we are done... + if (file_spec_matches_cu_file_spec == false && check_inlines == false) + return 0; + + uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec); + while (file_idx != UINT32_MAX) { - SymbolContext sc(GetModule()); - sc.comp_unit = this; + file_indexes.push_back (file_idx); + file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec); + } + + const size_t num_file_indexes = file_indexes.size(); + if (num_file_indexes == 0) + return 0; + + const uint32_t prev_size = sc_list.GetSize(); - uint32_t file_idx = UINT32_MAX; + SymbolContext sc(GetModule()); + sc.comp_unit = this; - // If we are looking for inline functions only and we don't - // find it in the support files, we are done. - if (check_inlines) - { - file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); - if (file_idx == UINT32_MAX) - return 0; - } + if (line != 0) + { + LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line != 0) + if (line_table != NULL) { - LineTable *line_table = sc.comp_unit->GetLineTable(); - - if (line_table != NULL) + uint32_t found_line; + uint32_t line_idx; + + if (num_file_indexes == 1) { - // We will have already looked up the file index if - // we are searching for inline entries. - if (!check_inlines) - file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); + // We only have a single support file that matches, so use + // the line table function that searches for a line entries + // that match a single support file index + line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes.front(), line, exact, &sc.line_entry); + + // If "exact == true", then "found_line" will be the same + // as "line". If "exact == false", the "found_line" will be the + // closest line entry with a line number greater than "line" and + // we will use this for our subsequent line exact matches below. + found_line = sc.line_entry.line; - if (file_idx != UINT32_MAX) + while (line_idx != UINT_MAX) { - uint32_t found_line; - - uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_idx, line, exact, &sc.line_entry); - found_line = sc.line_entry.line; + sc_list.Append(sc); + line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &sc.line_entry); + } + } + else + { + // We found multiple support files that match "file_spec" so use + // the line table function that searches for a line entries + // that match a multiple support file indexes. + line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes, line, exact, &sc.line_entry); + + // If "exact == true", then "found_line" will be the same + // as "line". If "exact == false", the "found_line" will be the + // closest line entry with a line number greater than "line" and + // we will use this for our subsequent line exact matches below. + found_line = sc.line_entry.line; - while (line_idx != UINT_MAX) - { - sc_list.Append(sc); - line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_idx, found_line, true, &sc.line_entry); - } + while (line_idx != UINT_MAX) + { + sc_list.Append(sc); + line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &sc.line_entry); } } } - else if (file_spec_matches_cu_file_spec && !check_inlines) - { - // only append the context if we aren't looking for inline call sites - // by file and line and if the file spec matches that of the compile unit - sc_list.Append(sc); - } - + } + else if (file_spec_matches_cu_file_spec && !check_inlines) + { + // only append the context if we aren't looking for inline call sites + // by file and line and if the file spec matches that of the compile unit + sc_list.Append(sc); } return sc_list.GetSize() - prev_size; } Modified: lldb/trunk/source/Symbol/LineTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=113721&r1=113720&r2=113721&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineTable.cpp (original) +++ lldb/trunk/source/Symbol/LineTable.cpp Sun Sep 12 01:24:05 2010 @@ -281,6 +281,64 @@ } uint32_t +LineTable::FindLineEntryIndexByFileIndex +( + uint32_t start_idx, + const std::vector &file_indexes, + uint32_t line, + bool exact, + LineEntry* line_entry_ptr +) +{ + + const size_t count = m_entries.size(); + std::vector::const_iterator begin_pos = file_indexes.begin(); + std::vector::const_iterator end_pos = file_indexes.end(); + size_t best_match = UINT_MAX; + + for (size_t idx = start_idx; idx < count; ++idx) + { + // Skip line table rows that terminate the previous row (is_terminal_entry is non-zero) + if (m_entries[idx].is_terminal_entry) + continue; + + if (find (begin_pos, end_pos, m_entries[idx].file_idx) == end_pos) + continue; + + // Exact match always wins. Otherwise try to find the closest line > the desired + // line. + // FIXME: Maybe want to find the line closest before and the line closest after and + // if they're not in the same function, don't return a match. + + if (m_entries[idx].line < line) + { + continue; + } + else if (m_entries[idx].line == line) + { + if (line_entry_ptr) + ConvertEntryAtIndexToLineEntry (idx, *line_entry_ptr); + return idx; + } + else if (!exact) + { + if (best_match == UINT32_MAX) + best_match = idx; + else if (m_entries[idx].line < m_entries[best_match].line) + best_match = idx; + } + } + + if (best_match != UINT_MAX) + { + if (line_entry_ptr) + ConvertEntryAtIndexToLineEntry (best_match, *line_entry_ptr); + return best_match; + } + return UINT_MAX; +} + +uint32_t LineTable::FindLineEntryIndexByFileIndex (uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry* line_entry_ptr) { const size_t count = m_entries.size(); From gclayton at apple.com Sun Sep 12 18:17:56 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 12 Sep 2010 23:17:56 -0000 Subject: [Lldb-commits] [lldb] r113729 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp Message-ID: <20100912231756.D56D42A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 18:17:56 2010 New Revision: 113729 URL: http://llvm.org/viewvc/llvm-project?rev=113729&view=rev Log: Fixed a crash that would happen when using "frame variables" on any struct, union, or class that contained an enumeration type. When I was creating the clang enumeration decl, I wasn't calling "EnumDecl::setIntegerType (QualType)" which means that if the enum decl was ever asked to figure out it's bit width (getTypeInfo()) it would crash. We didn't run into this with enum types that weren't inside classes because the DWARF already told us how big the type was and when we printed an enum we would never need to calculate the size, we would use the pre-cached byte size we got from the DWARF. When the enum was in a struct/union/class and we tried to layout the struct, the layout code would attempt to get the type info and segfault. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=113729&r1=113728&r2=113729&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sun Sep 12 18:17:56 2010 @@ -351,7 +351,7 @@ // Enumeration Types //------------------------------------------------------------------ void * - CreateEnumerationType (const Declaration &decl, const char *name); + CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type); bool AddEnumerationValueToEnumerationType (void * enum_qual_type, Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113729&r1=113728&r2=113729&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Sep 12 18:17:56 2010 @@ -2325,6 +2325,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=113729&r1=113728&r2=113729&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Sep 12 18:17:56 2010 @@ -2866,8 +2866,10 @@ } } } + + void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); - clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr); + clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type); m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); @@ -2876,7 +2878,6 @@ if (die->HasChildren()) { type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die); type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=113729&r1=113728&r2=113729&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Sep 12 18:17:56 2010 @@ -2610,7 +2610,7 @@ #pragma mark Enumeration Types void * -ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name) +ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type) { // TODO: Do something intelligent with the Declaration object passed in // like maybe filling in the SourceLocation with it... @@ -2623,7 +2623,11 @@ SourceLocation(), NULL); if (enum_decl) + { + // TODO: check if we should be setting the promotion type too? + enum_decl->setIntegerType(QualType::getFromOpaquePtr (integer_qual_type)); return ast_context->getTagDeclType(enum_decl).getAsOpaquePtr(); + } return NULL; } From gclayton at apple.com Sun Sep 12 19:50:27 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 00:50:27 -0000 Subject: [Lldb-commits] [lldb] r113730 - in /lldb/trunk/test/class_static: ./ Makefile main.cpp Message-ID: <20100913005027.5DEDB2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 19:50:27 2010 New Revision: 113730 URL: http://llvm.org/viewvc/llvm-project?rev=113730&view=rev Log: I made this example after noting that I was unable to display an unsized static class array. It turns out that gcc 4.2 will emit DWARF that correctly describes the PointType, but it will incorrectly emit debug info for the "g_points" array where the following things are wrong: - the DW_TAG_array_type won't have a subrange info - the DW_TAG_variable for "g_points" won't have a valid byte size, so even though we know the size of PointType, we can't infer the actual size of the array by dividing the size of the variable by the number of elements. We want to make sure clang and llvm-gcc handle this correctly. Added: lldb/trunk/test/class_static/ lldb/trunk/test/class_static/Makefile lldb/trunk/test/class_static/main.cpp Added: lldb/trunk/test/class_static/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/Makefile?rev=113730&view=auto ============================================================================== --- lldb/trunk/test/class_static/Makefile (added) +++ lldb/trunk/test/class_static/Makefile Sun Sep 12 19:50:27 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/class_static/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/main.cpp?rev=113730&view=auto ============================================================================== --- lldb/trunk/test/class_static/main.cpp (added) +++ lldb/trunk/test/class_static/main.cpp Sun Sep 12 19:50:27 2010 @@ -0,0 +1,44 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// I made this example after noting that I was unable to display an unsized +// static class array. It turns out that gcc 4.2 will emit DWARF that correctly +// describes the PointType, but it will incorrectly emit debug info for the +// "g_points" array where the following things are wrong: +// - the DW_TAG_array_type won't have a subrange info +// - the DW_TAG_variable for "g_points" won't have a valid byte size, so even +// though we know the size of PointType, we can't infer the actual size +// of the array by dividing the size of the variable by the number of +// elements. + +#include + +typedef struct PointType +{ + int x, y; +} PointType; + +class A +{ +public: + static PointType g_points[]; +}; + +PointType A::g_points[] = +{ + { 1, 2 }, + { 11, 22 } +}; + +int +main () +{ + printf ("A::g_points[2].x = %i\n", A::g_points[2].x); + return 0; +} From gclayton at apple.com Sun Sep 12 21:31:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 02:31:18 -0000 Subject: [Lldb-commits] [lldb] r113732 - /lldb/trunk/test/class_static/main.cpp Message-ID: <20100913023118.DA8532A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 21:31:18 2010 New Revision: 113732 URL: http://llvm.org/viewvc/llvm-project?rev=113732&view=rev Log: A few modifications to the class arrays test case. Modified: lldb/trunk/test/class_static/main.cpp Modified: lldb/trunk/test/class_static/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/main.cpp?rev=113732&r1=113731&r2=113732&view=diff ============================================================================== --- lldb/trunk/test/class_static/main.cpp (original) +++ lldb/trunk/test/class_static/main.cpp Sun Sep 12 21:31:18 2010 @@ -36,9 +36,16 @@ { 11, 22 } }; +static PointType g_points[] = +{ + { 3, 4 }, + { 33, 44 } +}; + int -main () +main (int argc, char const *argv[]) { - printf ("A::g_points[2].x = %i\n", A::g_points[2].x); + printf ("A::g_points[1].x = %i\n", A::g_points[1].x); + printf ("::g_points[1].x = %i\n", g_points[1].x); return 0; } From gclayton at apple.com Sun Sep 12 21:37:44 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 02:37:44 -0000 Subject: [Lldb-commits] [lldb] r113733 - in /lldb/trunk/source: Commands/CommandObjectFrame.cpp Core/ValueObjectVariable.cpp Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20100913023744.393DE2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 21:37:44 2010 New Revision: 113733 URL: http://llvm.org/viewvc/llvm-project?rev=113733&view=rev Log: Added a work in the DWARF parser when we parse an array that ends up having no elements so that they at least have 1 element. Added the ability to show the declaration location of variables to the "frame variables" with the "--show-declaration" option ("-c" for short). Changed the "frame variables" command over to use the value object code so that we use the same code path as the public API does when accessing and displaying variable values. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113733&r1=113732&r2=113733&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Sep 12 21:37:44 2010 @@ -205,10 +205,11 @@ case 'r': use_regex = true; break; case 'a': show_args = false; break; case 'l': show_locals = false; break; - case 'g': show_globals = false; break; + case 'g': show_globals = true; break; case 't': show_types = false; break; case 'y': show_summary = false; break; case 'L': show_location= true; break; + case 'c': show_decl = true; break; case 'D': debug = true; break; case 'd': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); @@ -223,10 +224,7 @@ break; case 'G': - { - ConstString const_string (option_arg); - globals.push_back(const_string); - } + globals.push_back(ConstString (option_arg)); break; case 's': @@ -251,11 +249,12 @@ use_regex = false; show_args = true; show_locals = true; - show_globals = true; + show_globals = false; show_types = true; show_scope = false; show_summary = true; show_location = false; + show_decl = false; debug = false; max_depth = UINT32_MAX; ptr_depth = 0; @@ -272,16 +271,17 @@ static lldb::OptionDefinition g_option_table[]; std::string name; - bool use_objc; - bool use_regex; - bool show_args; - bool show_locals; - bool show_globals; - bool show_types; - bool show_scope; // local/arg/global/static - bool show_summary; - bool show_location; - bool debug; + bool use_objc:1, + use_regex:1, + show_args:1, + show_locals:1, + show_globals:1, + show_types:1, + show_scope:1, + show_summary:1, + show_location:1, + show_decl:1, + debug:1; uint32_t max_depth; // The depth to print when dumping concrete (not pointers) aggreate values uint32_t ptr_depth; // The default depth that is dumped when we find pointers std::vector globals; @@ -522,16 +522,16 @@ } else { - VariableList variable_list; + Stream &s = result.GetOutputStream(); + + bool get_file_globals = true; + VariableList *variable_list = exe_ctx.frame->GetVariableList (get_file_globals); - bool show_inlined = true; // TODO: Get this from the process - SymbolContext frame_sc = exe_ctx.frame->GetSymbolContext (eSymbolContextEverything); - if (exe_ctx.frame && frame_sc.block) - frame_sc.block->AppendVariables(true, true, show_inlined, &variable_list); VariableSP var_sp; ValueObjectSP valobj_sp; //ValueObjectList &valobj_list = exe_ctx.frame->GetValueObjectList(); const char *name_cstr = NULL; + bool show_fullpaths = true; size_t idx; if (!m_options.globals.empty()) { @@ -563,7 +563,13 @@ if (valobj_sp) { DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, m_options.ptr_depth, 0, m_options.max_depth, false); - result.GetOutputStream().EOL(); + + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().Dump (&s); + } + + s.EOL(); } } } @@ -571,12 +577,9 @@ } } if (fail_count) - { result.SetStatus (eReturnStatusFailed); - } } - - if (command.GetArgumentCount() > 0) + else if (command.GetArgumentCount() > 0) { // If we have any args to the variable command, we will make // variable objects from them... @@ -599,7 +602,7 @@ else name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - var_sp = variable_list.FindVariable(name_const_string); + var_sp = variable_list->FindVariable(name_const_string); if (var_sp) { valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); @@ -714,8 +717,22 @@ if (valobj_sp) { - DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, ptr_depth, 0, m_options.max_depth, m_options.use_objc); - result.GetOutputStream().EOL(); + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } + + DumpValueObject (result, + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + ptr_depth, + 0, + m_options.max_depth, + m_options.use_objc); + + s.EOL(); } } else @@ -727,48 +744,39 @@ } else { - - if (m_options.show_globals) - { - if (frame_sc.comp_unit) - { - variable_list.AddVariables (frame_sc.comp_unit->GetVariableList(true).get()); - } - } - - const uint32_t num_variables = variable_list.GetSize(); + const uint32_t num_variables = variable_list->GetSize(); if (num_variables > 0) { for (uint32_t i=0; iGetVariableAtIndex(i)); bool dump_variable = true; - switch (variable->GetScope()) + switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: dump_variable = m_options.show_globals; if (dump_variable && m_options.show_scope) - result.GetOutputStream().PutCString("GLOBAL: "); + s.PutCString("GLOBAL: "); break; case eValueTypeVariableStatic: dump_variable = m_options.show_globals; if (dump_variable && m_options.show_scope) - result.GetOutputStream().PutCString("STATIC: "); + s.PutCString("STATIC: "); break; case eValueTypeVariableArgument: dump_variable = m_options.show_args; if (dump_variable && m_options.show_scope) - result.GetOutputStream().PutCString(" ARG: "); + s.PutCString(" ARG: "); break; case eValueTypeVariableLocal: dump_variable = m_options.show_locals; if (dump_variable && m_options.show_scope) - result.GetOutputStream().PutCString(" LOCAL: "); + s.PutCString(" LOCAL: "); break; default: @@ -776,7 +784,33 @@ } if (dump_variable) - DumpVariable (result, &exe_ctx, variable); + { + //DumpVariable (result, &exe_ctx, var_sp.get()); + + // Use the variable object code to make sure we are + // using the same APIs as the the public API will be + // using... + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + if (valobj_sp) + { + + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } + DumpValueObject (result, + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.use_objc); + + s.EOL(); + } + } } } } @@ -792,11 +826,12 @@ lldb::OptionDefinition CommandObjectFrameVariable::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, NULL, "Show verbose debug information."}, +{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, NULL, "Enable verbose debug information."}, { LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, "", "Set the max recurse depth when dumping aggregate types (default is infinity)."}, -{ LLDB_OPT_SET_1, false, "globals", 'g', no_argument, NULL, 0, NULL, "List global and static variables for the current stack frame source file."}, -{ LLDB_OPT_SET_1, false, "global", 'G', required_argument, NULL, 0, NULL, "Find a global variable by name (which might not be in the current stack frame source file)."}, +{ LLDB_OPT_SET_1, false, "show-globals",'g', no_argument, NULL, 0, NULL, "Show the current frame source file global and static variables."}, +{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, NULL, "Find a global variable by name (which might not be in the current stack frame source file)."}, { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, NULL, "Show variable location information."}, +{ LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, NULL, "Show variable declaration information (source file and line where the variable was declared)."}, { LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, "", "Lookup a variable by name or regex (--regex) for the current execution context."}, { LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, NULL, "Omit function arguments."}, { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, NULL, "Omit local variables."}, Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=113733&r1=113732&r2=113733&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Sun Sep 12 21:37:44 2010 @@ -133,6 +133,32 @@ // their own values as needed. If this variable is a simple // type, we read all data for it into m_data. // Make sure this type has a value before we try and read it + + // If we have a file address, convert it to a load address if we can. + if (value_type == Value::eValueTypeFileAddress && exe_ctx.process) + { + lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + if (file_addr != LLDB_INVALID_ADDRESS) + { + SymbolContext var_sc; + variable->CalculateSymbolContext(&var_sc); + if (var_sc.module_sp) + { + ObjectFile *objfile = var_sc.module_sp->GetObjectFile(); + if (objfile) + { + Address so_addr(file_addr, objfile->GetSectionList()); + lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.process); + if (load_addr != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeLoadAddress); + m_value.GetScalar() = load_addr; + } + } + } + } + } + if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType())) { // this value object represents an aggregate type whose 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=113733&r1=113732&r2=113733&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Sep 12 21:37:44 2010 @@ -3064,6 +3064,9 @@ { std::vector element_orders; ParseChildArrayInfo(sc, dwarf_cu, die, first_index, element_orders, byte_stride, bit_stride); + // We have an array that claims to have no members, lets give it at least one member... + if (element_orders.empty()) + element_orders.push_back (1); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); void *array_element_type = element_type->GetOpaqueClangQualType(); @@ -3357,6 +3360,7 @@ if (num_attributes > 0) { const char *name = NULL; + const char *mangled = NULL; Declaration decl; uint32_t i; TypeSP type_sp; @@ -3378,6 +3382,7 @@ case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; + case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; case DW_AT_type: var_type = GetUniquedTypeForDIEOffset(form_value.Reference(dwarf_cu), type_sp, 0, 0, false); break; case DW_AT_external: is_external = form_value.Unsigned() != 0; break; case DW_AT_location: @@ -3427,7 +3432,17 @@ { assert(var_type != DIE_IS_BEING_PARSED); - ConstString var_name(name); + ConstString var_name; + if (mangled) + { + Mangled mangled_var_name (mangled, true); + var_name = mangled_var_name.GetDemangledName(); + } + + if (!var_name && name) + { + var_name.SetCString(name); + } ValueType scope = eValueTypeInvalid; From gclayton at apple.com Sun Sep 12 21:54:20 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 02:54:20 -0000 Subject: [Lldb-commits] [lldb] r113734 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20100913025421.011E12A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 21:54:20 2010 New Revision: 113734 URL: http://llvm.org/viewvc/llvm-project?rev=113734&view=rev Log: Removed unused 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=113734&r1=113733&r2=113734&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Sep 12 21:54:20 2010 @@ -531,7 +531,6 @@ ValueObjectSP valobj_sp; //ValueObjectList &valobj_list = exe_ctx.frame->GetValueObjectList(); const char *name_cstr = NULL; - bool show_fullpaths = true; size_t idx; if (!m_options.globals.empty()) { From gclayton at apple.com Sun Sep 12 22:32:57 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 03:32:57 -0000 Subject: [Lldb-commits] [lldb] r113735 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Symbol/ClangASTContext.h source/Core/ValueObject.cpp source/Symbol/ClangASTContext.cpp Message-ID: <20100913033257.E2A7C2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 22:32:57 2010 New Revision: 113735 URL: http://llvm.org/viewvc/llvm-project?rev=113735&view=rev Log: Added the summary values for function pointers so we can show where they point to. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=113735&r1=113734&r2=113735&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Sun Sep 12 22:32:57 2010 @@ -223,6 +223,10 @@ void SetValueIsValid (bool valid); + + lldb::addr_t + GetPointerValue (lldb::AddressType &address_type, + bool scalar_is_load_address); private: //------------------------------------------------------------------ // For ValueObject only Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=113735&r1=113734&r2=113735&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sun Sep 12 22:32:57 2010 @@ -391,6 +391,9 @@ static bool IsCStringType (void *clang_type, uint32_t &length); + + static bool + IsFunctionPointerType (void *clang_type); static bool IsArrayType (void *clang_type, void **member_type = NULL, uint64_t *size = NULL); Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=113735&r1=113734&r2=113735&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Sun Sep 12 22:32:57 2010 @@ -390,108 +390,134 @@ // See if this is a pointer to a C string? uint32_t fixed_length = 0; - if (clang_type && ClangASTContext::IsCStringType (clang_type, fixed_length)) + if (clang_type) { - Process *process = exe_scope->CalculateProcess(); - if (process != NULL) + StreamString sstr; + + if (ClangASTContext::IsCStringType (clang_type, fixed_length)) { - StreamString sstr; - lldb::addr_t cstr_address = LLDB_INVALID_ADDRESS; - lldb::AddressType cstr_address_type = eAddressTypeInvalid; - switch (GetValue().GetValueType()) + Process *process = exe_scope->CalculateProcess(); + if (process != NULL) { - case Value::eValueTypeScalar: - cstr_address = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - cstr_address_type = eAddressTypeLoad; - break; - - case Value::eValueTypeLoadAddress: - case Value::eValueTypeFileAddress: - case Value::eValueTypeHostAddress: + lldb::AddressType cstr_address_type = eAddressTypeInvalid; + lldb::addr_t cstr_address = GetPointerValue (cstr_address_type, true); + + if (cstr_address != LLDB_INVALID_ADDRESS) { - uint32_t data_offset = 0; - cstr_address = m_data.GetPointer(&data_offset); - cstr_address_type = m_value.GetValueAddressType(); - if (cstr_address_type == eAddressTypeInvalid) - cstr_address_type = eAddressTypeLoad; + DataExtractor data; + size_t bytes_read = 0; + std::vector data_buffer; + std::vector cstr_buffer; + size_t cstr_length; + Error error; + if (fixed_length > 0) + { + data_buffer.resize(fixed_length); + // Resize the formatted buffer in case every character + // uses the "\xXX" format and one extra byte for a NULL + cstr_buffer.resize(data_buffer.size() * 4 + 1); + data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); + bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), fixed_length, error); + if (bytes_read > 0) + { + sstr << '"'; + cstr_length = data.Dump (&sstr, + 0, // Start offset in "data" + eFormatChar, // Print as characters + 1, // Size of item (1 byte for a char!) + bytes_read, // How many bytes to print? + UINT32_MAX, // num per line + LLDB_INVALID_ADDRESS,// base address + 0, // bitfield bit size + 0); // bitfield bit offset + sstr << '"'; + } + } + else + { + const size_t k_max_buf_size = 256; + data_buffer.resize (k_max_buf_size + 1); + // NULL terminate in case we don't get the entire C string + data_buffer.back() = '\0'; + // Make a formatted buffer that can contain take 4 + // bytes per character in case each byte uses the + // "\xXX" format and one extra byte for a NULL + cstr_buffer.resize (k_max_buf_size * 4 + 1); + + data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); + size_t total_cstr_len = 0; + while ((bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), k_max_buf_size, error)) > 0) + { + size_t len = strlen(&data_buffer.front()); + if (len == 0) + break; + if (len > bytes_read) + len = bytes_read; + if (sstr.GetSize() == 0) + sstr << '"'; + + cstr_length = data.Dump (&sstr, + 0, // Start offset in "data" + eFormatChar, // Print as characters + 1, // Size of item (1 byte for a char!) + len, // How many bytes to print? + UINT32_MAX, // num per line + LLDB_INVALID_ADDRESS,// base address + 0, // bitfield bit size + 0); // bitfield bit offset + + if (len < k_max_buf_size) + break; + cstr_address += total_cstr_len; + } + if (sstr.GetSize() > 0) + sstr << '"'; + } } - break; } + + if (sstr.GetSize() > 0) + m_summary_str.assign (sstr.GetData(), sstr.GetSize()); + } + else if (ClangASTContext::IsFunctionPointerType (clang_type)) + { + lldb::AddressType func_ptr_address_type = eAddressTypeInvalid; + lldb::addr_t func_ptr_address = GetPointerValue (func_ptr_address_type, true); - if (cstr_address != LLDB_INVALID_ADDRESS) + if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) { - DataExtractor data; - size_t bytes_read = 0; - std::vector data_buffer; - std::vector cstr_buffer; - size_t cstr_length; - Error error; - if (fixed_length > 0) + switch (func_ptr_address_type) { - data_buffer.resize(fixed_length); - // Resize the formatted buffer in case every character - // uses the "\xXX" format and one extra byte for a NULL - cstr_buffer.resize(data_buffer.size() * 4 + 1); - data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); - bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), fixed_length, error); - if (bytes_read > 0) + case eAddressTypeInvalid: + case eAddressTypeFile: + break; + + case eAddressTypeLoad: { - sstr << '"'; - cstr_length = data.Dump (&sstr, - 0, // Start offset in "data" - eFormatChar, // Print as characters - 1, // Size of item (1 byte for a char!) - bytes_read, // How many bytes to print? - UINT32_MAX, // num per line - LLDB_INVALID_ADDRESS,// base address - 0, // bitfield bit size - 0); // bitfield bit offset - sstr << '"'; + Address so_addr; + Process *process = exe_scope->CalculateProcess(); + if (process != NULL) + { + if (process->ResolveLoadAddress(func_ptr_address, so_addr)) + { + so_addr.Dump (&sstr, + exe_scope, + Address::DumpStyleResolvedDescription, + Address::DumpStyleSectionNameOffset); + } + } } - } - else - { - const size_t k_max_buf_size = 256; - data_buffer.resize (k_max_buf_size + 1); - // NULL terminate in case we don't get the entire C string - data_buffer.back() = '\0'; - // Make a formatted buffer that can contain take 4 - // bytes per character in case each byte uses the - // "\xXX" format and one extra byte for a NULL - cstr_buffer.resize (k_max_buf_size * 4 + 1); - - data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); - size_t total_cstr_len = 0; - while ((bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), k_max_buf_size, error)) > 0) - { - size_t len = strlen(&data_buffer.front()); - if (len == 0) - break; - if (len > bytes_read) - len = bytes_read; - if (sstr.GetSize() == 0) - sstr << '"'; + break; - cstr_length = data.Dump (&sstr, - 0, // Start offset in "data" - eFormatChar, // Print as characters - 1, // Size of item (1 byte for a char!) - len, // How many bytes to print? - UINT32_MAX, // num per line - LLDB_INVALID_ADDRESS,// base address - 0, // bitfield bit size - 0); // bitfield bit offset - - if (len < k_max_buf_size) - break; - cstr_address += total_cstr_len; - } - if (sstr.GetSize() > 0) - sstr << '"'; + case eAddressTypeHost: + break; } - - if (sstr.GetSize() > 0) - m_summary_str.assign (sstr.GetData(), sstr.GetSize()); + } + if (sstr.GetSize() > 0) + { + m_summary_str.assign (1, '('); + m_summary_str.append (sstr.GetData(), sstr.GetSize()); + m_summary_str.append (1, ')'); } } } @@ -502,6 +528,7 @@ return m_summary_str.c_str(); } + const char * ValueObject::GetObjectDescription (ExecutionContextScope *exe_scope) { @@ -614,6 +641,36 @@ return m_value_str.c_str(); } +addr_t +ValueObject::GetPointerValue (lldb::AddressType &address_type, bool scalar_is_load_address) +{ + lldb::addr_t address = LLDB_INVALID_ADDRESS; + address_type = eAddressTypeInvalid; + switch (GetValue().GetValueType()) + { + case Value::eValueTypeScalar: + if (scalar_is_load_address) + { + address = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + address_type = eAddressTypeLoad; + } + break; + + case Value::eValueTypeLoadAddress: + case Value::eValueTypeFileAddress: + case Value::eValueTypeHostAddress: + { + uint32_t data_offset = 0; + address = m_data.GetPointer(&data_offset); + address_type = m_value.GetValueAddressType(); + if (address_type == eAddressTypeInvalid) + address_type = eAddressTypeLoad; + } + break; + } + return address; +} + bool ValueObject::SetValueFromCString (ExecutionContextScope *exe_scope, const char *value_str) { Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=113735&r1=113734&r2=113735&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Sep 12 22:32:57 2010 @@ -1185,7 +1185,8 @@ if (qual_type->isAggregateType ()) return true; - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::IncompleteArray: case clang::Type::VariableArray: @@ -1401,7 +1402,8 @@ child_bitfield_bit_size = 0; child_bitfield_bit_offset = 0; QualType parent_qual_type(QualType::getFromOpaquePtr(parent_clang_type)); - switch (parent_qual_type->getTypeClass()) + const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass(); + switch (parent_type_class) { case clang::Type::Builtin: switch (cast(parent_qual_type)->getKind()) @@ -1897,7 +1899,8 @@ if (clang_type && name && name[0]) { QualType qual_type(QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::Record: { @@ -2174,9 +2177,9 @@ { QualType qual_type(QualType::getFromOpaquePtr(clang_type)); - clang::Type::TypeClass qual_type_class = qual_type->getTypeClass(); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (qual_type_class) + switch (type_class) { case clang::Type::Record: { @@ -2402,7 +2405,8 @@ return NULL; QualType qual_type(QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::FunctionNoProto: break; case clang::Type::FunctionProto: break; @@ -2691,7 +2695,8 @@ { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::ObjCObject: case clang::Type::ObjCInterface: @@ -2743,7 +2748,8 @@ return false; QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::ObjCObjectPointer: if (target_type) @@ -2803,7 +2809,8 @@ if (clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::ObjCObjectPointer: if (target_type) @@ -2876,7 +2883,8 @@ if (clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::ConstantArray: { @@ -2934,6 +2942,38 @@ } bool +ClangASTContext::IsFunctionPointerType (void *clang_type) +{ + if (clang_type) + { + QualType qual_type (QualType::getFromOpaquePtr(clang_type)); + + if (qual_type->isFunctionPointerType()) + return true; + + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Typedef: + return ClangASTContext::IsFunctionPointerType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); + + case clang::Type::LValueReference: + case clang::Type::RValueReference: + { + ReferenceType *reference_type = cast(qual_type.getTypePtr()); + if (reference_type) + return ClangASTContext::IsFunctionPointerType (reference_type->getPointeeType().getAsOpaquePtr()); + } + break; + } + } + return false; +} + + + + +bool ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *size) { if (!clang_type) @@ -2941,7 +2981,8 @@ QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { case clang::Type::ConstantArray: if (member_type) From gclayton at apple.com Sun Sep 12 22:44:33 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 03:44:33 -0000 Subject: [Lldb-commits] [lldb] r113736 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20100913034433.56E2E2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 22:44:33 2010 New Revision: 113736 URL: http://llvm.org/viewvc/llvm-project?rev=113736&view=rev Log: Make sure we have a variable list so we don't crash when a frame has no frame variables. 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=113736&r1=113735&r2=113736&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Sep 12 22:44:33 2010 @@ -578,231 +578,157 @@ if (fail_count) result.SetStatus (eReturnStatusFailed); } - else if (command.GetArgumentCount() > 0) + else if (variable_list) { - // If we have any args to the variable command, we will make - // variable objects from them... - for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) + if (command.GetArgumentCount() > 0) { - uint32_t ptr_depth = m_options.ptr_depth; - // If first character is a '*', then show pointer contents - if (name_cstr[0] == '*') + // If we have any args to the variable command, we will make + // variable objects from them... + for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) { - ++ptr_depth; - name_cstr++; // Skip the '*' - } + uint32_t ptr_depth = m_options.ptr_depth; + // If first character is a '*', then show pointer contents + if (name_cstr[0] == '*') + { + ++ptr_depth; + name_cstr++; // Skip the '*' + } - std::string var_path (name_cstr); - size_t separator_idx = var_path.find_first_of(".-["); + std::string var_path (name_cstr); + size_t separator_idx = var_path.find_first_of(".-["); - ConstString name_const_string; - if (separator_idx == std::string::npos) - name_const_string.SetCString (var_path.c_str()); - else - name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); + ConstString name_const_string; + if (separator_idx == std::string::npos) + name_const_string.SetCString (var_path.c_str()); + else + name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - var_sp = variable_list->FindVariable(name_const_string); - if (var_sp) - { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); - - var_path.erase (0, name_const_string.GetLength ()); - // We are dumping at least one child - while (separator_idx != std::string::npos) + var_sp = variable_list->FindVariable(name_const_string); + if (var_sp) { - // Calculate the next separator index ahead of time - ValueObjectSP child_valobj_sp; - const char separator_type = var_path[0]; - switch (separator_type) - { + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); - case '-': - if (var_path.size() >= 2 && var_path[1] != '>') - { - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; - } - var_path.erase (0, 1); // Remove the '-' - // Fall through - case '.': + var_path.erase (0, name_const_string.GetLength ()); + // We are dumping at least one child + while (separator_idx != std::string::npos) + { + // Calculate the next separator index ahead of time + ValueObjectSP child_valobj_sp; + const char separator_type = var_path[0]; + switch (separator_type) { - var_path.erase (0, 1); // Remove the '.' or '>' - separator_idx = var_path.find_first_of(".-["); - ConstString child_name; - if (separator_idx == std::string::npos) - child_name.SetCString (var_path.c_str()); - else - child_name.SetCStringWithLength(var_path.c_str(), separator_idx); - child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); - if (!child_valobj_sp) + case '-': + if (var_path.size() >= 2 && var_path[1] != '>') { - result.GetErrorStream().Printf ("error: can't find child of '%s' named '%s'\n", - valobj_sp->GetName().AsCString(), - child_name.GetCString()); + result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", + var_path.c_str()); var_path.clear(); valobj_sp.reset(); break; } - // Remove the child name from the path - var_path.erase(0, child_name.GetLength()); - } - break; - - case '[': - // Array member access, or treating pointer as an array - if (var_path.size() > 2) // Need at least two brackets and a number - { - char *end = NULL; - int32_t child_index = ::strtol (&var_path[1], &end, 0); - if (end && *end == ']') + var_path.erase (0, 1); // Remove the '-' + // Fall through + case '.': { - - if (valobj_sp->IsPointerType ()) - { - child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); - } + var_path.erase (0, 1); // Remove the '.' or '>' + separator_idx = var_path.find_first_of(".-["); + ConstString child_name; + if (separator_idx == std::string::npos) + child_name.SetCString (var_path.c_str()); else - { - child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); - } + child_name.SetCStringWithLength(var_path.c_str(), separator_idx); + child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { - result.GetErrorStream().Printf ("error: invalid array index %u in '%s'\n", - child_index, - valobj_sp->GetName().AsCString()); + result.GetErrorStream().Printf ("error: can't find child of '%s' named '%s'\n", + valobj_sp->GetName().AsCString(), + child_name.GetCString()); var_path.clear(); valobj_sp.reset(); break; } - - // Erase the array member specification '[%i]' where %i is the array index - var_path.erase(0, (end - var_path.c_str()) + 1); - separator_idx = var_path.find_first_of(".-["); - - // Break out early from the switch since we were able to find the child member - break; + // Remove the child name from the path + var_path.erase(0, child_name.GetLength()); } - } - result.GetErrorStream().Printf ("error: invalid array member specification for '%s' starting at '%s'\n", - valobj_sp->GetName().AsCString(), - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; - - break; + break; - default: - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - separator_idx = std::string::npos; - break; - } + case '[': + // Array member access, or treating pointer as an array + if (var_path.size() > 2) // Need at least two brackets and a number + { + char *end = NULL; + int32_t child_index = ::strtol (&var_path[1], &end, 0); + if (end && *end == ']') + { - if (child_valobj_sp) - valobj_sp = child_valobj_sp; + if (valobj_sp->IsPointerType ()) + { + child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); + } + else + { + child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); + } + + if (!child_valobj_sp) + { + result.GetErrorStream().Printf ("error: invalid array index %u in '%s'\n", + child_index, + valobj_sp->GetName().AsCString()); + var_path.clear(); + valobj_sp.reset(); + break; + } + + // Erase the array member specification '[%i]' where %i is the array index + var_path.erase(0, (end - var_path.c_str()) + 1); + separator_idx = var_path.find_first_of(".-["); - if (var_path.empty()) - break; + // Break out early from the switch since we were able to find the child member + break; + } + } + result.GetErrorStream().Printf ("error: invalid array member specification for '%s' starting at '%s'\n", + valobj_sp->GetName().AsCString(), + var_path.c_str()); + var_path.clear(); + valobj_sp.reset(); + break; - } + break; - if (valobj_sp) - { - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) - { - var_sp->GetDeclaration ().DumpStopContext (&s, false); - s.PutCString (": "); - } + default: + result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", + var_path.c_str()); + var_path.clear(); + valobj_sp.reset(); + separator_idx = std::string::npos; + break; + } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc); + if (child_valobj_sp) + valobj_sp = child_valobj_sp; - s.EOL(); - } - } - else - { - result.GetErrorStream().Printf ("error: unable to find any variables named '%s'\n", name_cstr); - var_path.clear(); - } - } - } - else - { - const uint32_t num_variables = variable_list->GetSize(); - - if (num_variables > 0) - { - for (uint32_t i=0; iGetVariableAtIndex(i)); - bool dump_variable = true; - - switch (var_sp->GetScope()) - { - case eValueTypeVariableGlobal: - dump_variable = m_options.show_globals; - if (dump_variable && m_options.show_scope) - s.PutCString("GLOBAL: "); - break; - - case eValueTypeVariableStatic: - dump_variable = m_options.show_globals; - if (dump_variable && m_options.show_scope) - s.PutCString("STATIC: "); - break; - - case eValueTypeVariableArgument: - dump_variable = m_options.show_args; - if (dump_variable && m_options.show_scope) - s.PutCString(" ARG: "); - break; - - case eValueTypeVariableLocal: - dump_variable = m_options.show_locals; - if (dump_variable && m_options.show_scope) - s.PutCString(" LOCAL: "); - break; + if (var_path.empty()) + break; - default: - break; - } - - if (dump_variable) - { - //DumpVariable (result, &exe_ctx, var_sp.get()); + } - // Use the variable object code to make sure we are - // using the same APIs as the the public API will be - // using... - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); if (valobj_sp) { - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); } + DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, - m_options.ptr_depth, + ptr_depth, 0, m_options.max_depth, m_options.use_objc); @@ -810,10 +736,87 @@ s.EOL(); } } + else + { + result.GetErrorStream().Printf ("error: unable to find any variables named '%s'\n", name_cstr); + var_path.clear(); + } + } + } + else + { + const uint32_t num_variables = variable_list->GetSize(); + + if (num_variables > 0) + { + for (uint32_t i=0; iGetVariableAtIndex(i)); + bool dump_variable = true; + + switch (var_sp->GetScope()) + { + case eValueTypeVariableGlobal: + dump_variable = m_options.show_globals; + if (dump_variable && m_options.show_scope) + s.PutCString("GLOBAL: "); + break; + + case eValueTypeVariableStatic: + dump_variable = m_options.show_globals; + if (dump_variable && m_options.show_scope) + s.PutCString("STATIC: "); + break; + + case eValueTypeVariableArgument: + dump_variable = m_options.show_args; + if (dump_variable && m_options.show_scope) + s.PutCString(" ARG: "); + break; + + case eValueTypeVariableLocal: + dump_variable = m_options.show_locals; + if (dump_variable && m_options.show_scope) + s.PutCString(" LOCAL: "); + break; + + default: + break; + } + + if (dump_variable) + { + //DumpVariable (result, &exe_ctx, var_sp.get()); + + // Use the variable object code to make sure we are + // using the same APIs as the the public API will be + // using... + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + if (valobj_sp) + { + + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } + DumpValueObject (result, + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.use_objc); + + s.EOL(); + } + } + } } } + result.SetStatus (eReturnStatusSuccessFinishResult); } - result.SetStatus (eReturnStatusSuccessFinishResult); } return result.Succeeded(); } From gclayton at apple.com Sun Sep 12 23:34:30 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Sep 2010 04:34:30 -0000 Subject: [Lldb-commits] [lldb] r113737 - /lldb/trunk/source/Target/StackFrame.cpp Message-ID: <20100913043430.6707D2A6C12C@llvm.org> Author: gclayton Date: Sun Sep 12 23:34:30 2010 New Revision: 113737 URL: http://llvm.org/viewvc/llvm-project?rev=113737&view=rev Log: Fixed an assertion that happened when debugging DWARF in .o files with debug map on macosx. Modified: lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=113737&r1=113736&r2=113737&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Sun Sep 12 23:34:30 2010 @@ -136,14 +136,19 @@ m_flags.Set (eSymbolContextTarget); } - if (m_sc.module_sp.get() == NULL && pc_addr.GetSection()) + Module *pc_module = pc_addr.GetModule(); + if (m_sc.module_sp.get() == NULL || m_sc.module_sp.get() != pc_module) { - Module *pc_module = pc_addr.GetSection()->GetModule(); if (pc_module) { m_sc.module_sp = pc_module->GetSP(); m_flags.Set (eSymbolContextModule); } + else + { + m_sc.module_sp.reset(); + } + } }