[Lldb-commits] [lldb] r160650 - in /lldb/branches/apple/python-GIL: ./ include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ include/lldb/Target/ scripts/ scripts/Python/interface/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/ObjectFile/PECOFF/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ test/functionalities/process_launch/my_working_dir/ t...

Filipe Cabecinhas me at filcab.net
Mon Jul 23 16:40:38 PDT 2012


Author: filcab
Date: Mon Jul 23 18:40:37 2012
New Revision: 160650

URL: http://llvm.org/viewvc/llvm-project?rev=160650&view=rev
Log:
Merge changes from ToT trunk.

Added:
    lldb/branches/apple/python-GIL/test/functionalities/process_launch/my_working_dir/.keep
      - copied unchanged from r160596, lldb/trunk/test/functionalities/process_launch/my_working_dir/.keep
Modified:
    lldb/branches/apple/python-GIL/   (props changed)
    lldb/branches/apple/python-GIL/include/lldb/API/SBTarget.h
    lldb/branches/apple/python-GIL/include/lldb/Core/Mangled.h
    lldb/branches/apple/python-GIL/include/lldb/Expression/IRForTarget.h
    lldb/branches/apple/python-GIL/include/lldb/Symbol/UnwindPlan.h
    lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
    lldb/branches/apple/python-GIL/include/lldb/lldb-private-enumerations.h
    lldb/branches/apple/python-GIL/llvm.zip
    lldb/branches/apple/python-GIL/scripts/Python/interface/SBTarget.i
    lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff
    lldb/branches/apple/python-GIL/source/API/SBTarget.cpp
    lldb/branches/apple/python-GIL/source/Commands/CommandObjectProcess.cpp
    lldb/branches/apple/python-GIL/source/Core/Mangled.cpp
    lldb/branches/apple/python-GIL/source/Expression/IRForTarget.cpp
    lldb/branches/apple/python-GIL/source/Interpreter/Args.cpp
    lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
    lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/branches/apple/python-GIL/source/Symbol/Function.cpp
    lldb/branches/apple/python-GIL/source/Symbol/Symbol.cpp
    lldb/branches/apple/python-GIL/source/Symbol/UnwindPlan.cpp
    lldb/branches/apple/python-GIL/source/Symbol/Variable.cpp
    lldb/branches/apple/python-GIL/source/Target/Process.cpp
    lldb/branches/apple/python-GIL/source/Target/Target.cpp
    lldb/branches/apple/python-GIL/test/lang/c/struct_types/main.c
    lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.cpp
    lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.h
    lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.cpp
    lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.h
    lldb/branches/apple/python-GIL/tools/debugserver/source/debugserver.cpp

Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 23 18:40:37 2012
@@ -1 +1 @@
-/lldb/trunk:156467-160392
+/lldb/trunk:156467-160596

Modified: lldb/branches/apple/python-GIL/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/API/SBTarget.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/API/SBTarget.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/API/SBTarget.h Mon Jul 23 18:40:37 2012
@@ -152,6 +152,12 @@
     void
     SetWaitForLaunch (bool b);
     
+    bool
+    GetIgnoreExisting ();
+    
+    void
+    SetIgnoreExisting (bool b);
+    
     uint32_t
     GetResumeCount ();
     

Modified: lldb/branches/apple/python-GIL/include/lldb/Core/Mangled.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Core/Mangled.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Core/Mangled.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Core/Mangled.h Mon Jul 23 18:40:37 2012
@@ -33,24 +33,6 @@
 class Mangled
 {
 public:
-
-    //------------------------------------------------------------------
-    /// Token type enumerations.
-    //------------------------------------------------------------------
-    enum TokenType
-    {
-        eInvalid,       ///< Invalid token value (unitialized value)
-        eNameSpace,     ///< The token is a namespace name.
-        eMethodName,    ///< The token is a global or class method name
-        eType,          ///< The token is a language type
-        eTemplate,      ///< The token is a template class
-        eTemplateBeg,   ///< The token that indicates the start of a template parameters
-        eTemplateEnd,   ///< The token that indicates the end of a template parameters
-        eParamsBeg,     ///< The start of a method's parameters (the open parenthesis)
-        eParamsEnd,     ///< The end of a method's parameters (the open parenthesis)
-        eQualifier,     ///< A language qualifier
-        eError          ///< The token failed to parse
-    };
     
     enum NamePreference
     {
@@ -58,224 +40,6 @@
         ePreferDemangled
     };
 
-    //------------------------------------------------------------------
-    /// Mangled::Token structure
-    ///
-    /// As demangled names get tokenized, they get broken up into chunks
-    /// that have type enumerations (TokenType) and string values. Some of
-    /// the tokens are scopes (eTemplateBeg, eTemplateEnd, eParamsBeg,
-    /// eParamsEnd) that can indicate depth and searches can take
-    /// advantage of these to match using wildcards.
-    ///
-    /// For example the mangled string:
-    ///
-    ///     "_ZNSbIhSt11char_traitsIhESaIhEE5eraseEmm"
-    ///
-    /// Demangles to:
-    ///
-    ///     "std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::erase(unsigned long, unsigned long)"
-    ///
-    /// And tokenizes to:
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("basic_string")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char")
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("char_traits")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char")
-    ///     @li eTemplateEnd ()
-    ///     @li eNameSpace ("std")
-    ///     @li eTemplate ("allocator")
-    ///     @li eTemplateBeg ()
-    ///     @li eType ("unsigned char"
-    ///     @li eTemplateEnd ()
-    ///     @li eTemplateEnd ()
-    ///     @li eMethodName ("erase")
-    ///     @li eParamsBeg ()
-    ///     @li eType ("unsigned long")
-    ///     @li eType ("unsigned long")
-    ///     @li eParamsEnd ()
-    ///------------------------------------------------------------------
-    struct Token
-    {
-        //--------------------------------------------------------------
-        /// Default constructor.
-        ///
-        /// Constructs this objet with an invalid token type and an
-        /// empty string.
-        //--------------------------------------------------------------
-        Token();
-
-        //--------------------------------------------------------------
-        /// Equal to operator.
-        ///
-        /// Tests if this object is equal to \a rhs.
-        ///
-        /// @param[in] rhs
-        ///     A const Mangled::Token object reference to compare
-        ///     this object to.
-        ///
-        /// @return
-        ///     \b true if this object is equal to \a rhs, \b false
-        ///     otherwise.
-        //--------------------------------------------------------------
-        bool
-        operator== (const Token& rhs) const;
-
-        //--------------------------------------------------------------
-        /// Dump a description of this object to a Stream \a s.
-        ///
-        /// @param[in] s
-        ///     The stream to which to dump the object descripton.
-        //--------------------------------------------------------------
-        void
-        Dump (Stream *s) const;
-
-        //--------------------------------------------------------------
-        /// Test if this token is a wildcard token.
-        ///
-        /// @return
-        ///     Returns \b true if this token is a wildcard, \b false
-        ///     otherwise.
-        //--------------------------------------------------------------
-        bool
-        IsWildcard() const;
-
-        //--------------------------------------------------------------
-        /// Members
-        //--------------------------------------------------------------
-        TokenType       type;   ///< The type of the token (Mangled::TokenType)
-        ConstString value;  ///< The ConstString value associated with this token
-    };
-
-    //------------------------------------------------------------------
-    /// A collection of tokens.
-    ///
-    /// This class can be instantiated with a demangled names that can
-    /// be used as a query using the
-    /// Mangled::TokenList::MatchesQuery(const TokenList&) const
-    /// function.
-    //------------------------------------------------------------------
-    class TokenList
-    {
-    public:
-        //--------------------------------------------------------------
-        /// Construct with a demangled name.
-        ///
-        /// If demangled is valid the token list will parse up the
-        /// demangled string it is given, else the object will
-        /// initialize an empty token list.
-        //--------------------------------------------------------------
-        TokenList (const char *demangled = NULL);
-
-        //--------------------------------------------------------------
-        /// Destructor
-        //--------------------------------------------------------------
-        ~TokenList ();
-
-        //--------------------------------------------------------------
-        /// Clear the token list.
-        //--------------------------------------------------------------
-        void
-        Clear ();
-
-        //--------------------------------------------------------------
-        /// Dump a description of this object to a Stream \a s.
-        ///
-        /// @param[in] s
-        ///     The stream to which to dump the object descripton.
-        //--------------------------------------------------------------
-        void
-        Dump (Stream *s) const;
-
-        //--------------------------------------------------------------
-        /// Find a token by Mangled::TokenType.
-        ///
-        /// Find the first token in the list that has \a token_type as
-        /// its type.
-        //--------------------------------------------------------------
-        const Token*
-        Find (TokenType token_type) const;
-
-        //--------------------------------------------------------------
-        /// Get a token by index.
-        ///
-        /// @return
-        ///     The token at index \a idx, or NULL if the index is out
-        ///     of range.
-        //--------------------------------------------------------------
-        const Token*
-        GetTokenAtIndex (uint32_t idx) const;
-
-        //--------------------------------------------------------------
-        /// Given a token list, see if it matches this object's tokens.
-        /// \a token_list can contain wild card values to enable powerful
-        /// matching. Matching the std::string::erase(*) example that was
-        /// tokenized above we could use a token list such as:
-        ///
-        ///     token           name
-        ///     -----------     ----------------------------------------
-        ///     eNameSpace      "std"
-        ///     eTemplate       "basic_string"
-        ///     eTemplateBeg
-        ///     eInvalid        "*"
-        ///     eTemplateEnd
-        ///     eMethodName     "erase"
-        ///     eParamsBeg
-        ///     eInvalid        "*"
-        ///     eParamsEnd
-        ///
-        /// @return
-        ///     Returns \b true if it \a token_list matches this
-        ///     object's tokens, \b false otherwise.
-        //--------------------------------------------------------------
-        bool
-        MatchesQuery (const TokenList& token_list) const;
-
-        //--------------------------------------------------------------
-        /// Parses \a demangled into tokens.
-        ///
-        /// This allows complex comparisons to be done on demangled names. Comparisons can
-        /// include wildcards at the namespace, method name, template,
-        /// and template and parameter type levels.
-        ///
-        /// Example queries include:
-        /// "std::basic_string<*>"  // Find all std::basic_string variants
-        /// "std::basic_string<*>::erase(*)"    // Find all std::basic_string::erase variants with any number of parameters
-        /// "*::clear()"            // Find all functions with a method name of
-        ///                         // "clear" that are in any namespace that
-        ///                         // have no parameters
-        /// "::printf"      // Find the printf function in the global namespace
-        /// "printf"        // Ditto
-        /// "foo::*(int)"   // Find all functions in the class or namespace "foo" that take a single integer argument
-        ///
-        /// @return
-        ///     The number of tokens that were decoded, or zero if
-        ///     decoding fails.
-        //--------------------------------------------------------------
-        size_t
-        Parse (const char *demangled);
-
-        //--------------------------------------------------------------
-        /// Get the number of tokens in the list.
-        ///
-        /// @return
-        ///     The number of tokens in the token list.
-        //--------------------------------------------------------------
-        size_t
-        Size () const;
-
-    protected:
-        //--------------------------------------------------------------
-        // Member variables.
-        //--------------------------------------------------------------
-        typedef std::vector<Token> collection; ///< The collection type for a list of Token objects.
-        collection m_tokens; ///< The token list.
-    private:
-        DISALLOW_COPY_AND_ASSIGN (TokenList);
-    };
-
     //----------------------------------------------------------------------
     /// Default constructor.
     ///
@@ -290,14 +54,26 @@
     /// the mangled version.
     ///
     /// @param[in] name
-    ///     The name to copy into this object.
+    ///     The already const name to copy into this object.
     ///
     /// @param[in] is_mangled
     ///     If \b true then \a name is a mangled name, if \b false then
     ///     \a name is demangled.
     //----------------------------------------------------------------------
     explicit
-    Mangled (const char *name, bool is_mangled);
+    Mangled (const ConstString &name, bool is_mangled);
+
+    //----------------------------------------------------------------------
+    /// Construct with name.
+    ///
+    /// Constructor with an optional string and auto-detect if \a name is
+    /// mangled or not.
+    ///
+    /// @param[in] name
+    ///     The already const name to copy into this object.
+    //----------------------------------------------------------------------
+    explicit
+    Mangled (const ConstString &name);
 
     //----------------------------------------------------------------------
     /// Destructor
@@ -401,15 +177,15 @@
     GetDemangledName () const;
 
     void
-    SetDemangledName (const char *name)
+    SetDemangledName (const ConstString &name)
     {
-        m_demangled.SetCString (name);
+        m_demangled = name;
     }
 
     void
-    SetMangledName (const char *name)
+    SetMangledName (const ConstString &name)
     {
-        m_mangled.SetCString (name);
+        m_mangled = name;
     }
 
     //----------------------------------------------------------------------
@@ -471,18 +247,6 @@
     NameMatches (const RegularExpression& regex) const;
 
     //----------------------------------------------------------------------
-    /// Generate the tokens from the demangled name.
-    ///
-    /// @param[out] tokens
-    ///     A token list that will get filled in with the demangled tokens.
-    ///
-    /// @return
-    ///     The number of tokens that were parsed and stored in \a tokens.
-    //----------------------------------------------------------------------
-    size_t
-    GetTokens (Mangled::TokenList &tokens) const;
-
-    //----------------------------------------------------------------------
     /// Get the memory cost of this object.
     ///
     /// Return the size in bytes that this object takes in memory. This
@@ -504,14 +268,26 @@
     /// name, else the demangled name is set to \a name.
     ///
     /// @param[in] name
-    ///     The name to copy into this object.
+    ///     The already const version of the name for this object.
     ///
     /// @param[in] is_mangled
     ///     If \b true then \a name is a mangled name, if \b false then
     ///     \a name is demangled.
     //----------------------------------------------------------------------
     void
-    SetValue (const char *name, bool is_mangled);
+    SetValue (const ConstString &name, bool is_mangled);
+
+    //----------------------------------------------------------------------
+    /// Set the string value in this object.
+    ///
+    /// This version auto detects if the string is mangled by inspecting the
+    /// string value and looking for common mangling prefixes.
+    ///
+    /// @param[in] name
+    ///     The already const version of the name for this object.
+    //----------------------------------------------------------------------
+    void
+    SetValue (const ConstString &name);
 
 private:
     //----------------------------------------------------------------------
@@ -523,8 +299,6 @@
 
 
 Stream& operator << (Stream& s, const Mangled& obj);
-Stream& operator << (Stream& s, const Mangled::TokenList& obj);
-Stream& operator << (Stream& s, const Mangled::Token& obj);
 
 } // namespace lldb_private
 

Modified: lldb/branches/apple/python-GIL/include/lldb/Expression/IRForTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Expression/IRForTarget.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Expression/IRForTarget.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Expression/IRForTarget.h Mon Jul 23 18:40:37 2012
@@ -532,6 +532,20 @@
     ResolveCalls (llvm::BasicBlock &basic_block);
     
     //------------------------------------------------------------------
+    /// Remove calls to __cxa_atexit, which should never be generated by
+    /// expressions.
+    ///
+    /// @param[in] call_inst
+    ///     The call instruction.
+    ///
+    /// @return
+    ///     True if the scan was successful; false if some operation
+    ///     failed
+    //------------------------------------------------------------------
+    bool
+    RemoveCXAAtExit (llvm::BasicBlock &basic_block);
+    
+    //------------------------------------------------------------------
     /// The top-level pass implementation
     ///
     /// @param[in] basic_block

Modified: lldb/branches/apple/python-GIL/include/lldb/Symbol/UnwindPlan.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Symbol/UnwindPlan.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Symbol/UnwindPlan.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Symbol/UnwindPlan.h Mon Jul 23 18:40:37 2012
@@ -241,12 +241,11 @@
         Row ();
     
         Row (const UnwindPlan::Row& rhs) : 
-            m_offset(rhs.m_offset), m_cfa_reg_num(rhs.m_cfa_reg_num), m_cfa_offset(rhs.m_cfa_offset)
+            m_offset             (rhs.m_offset),
+            m_cfa_reg_num        (rhs.m_cfa_reg_num),
+            m_cfa_offset         (rhs.m_cfa_offset),
+            m_register_locations (rhs.m_register_locations)
         {
-            for (collection::const_iterator idx = rhs.m_register_locations.begin(); idx != rhs.m_register_locations.end(); ++idx)
-            {
-                m_register_locations[idx->first] = idx->second;
-            }
         }
 
         bool
@@ -326,13 +325,6 @@
         {
             m_cfa_offset = offset;
         }
-    
-        // Return the number of registers we have locations for
-        int
-        GetRegisterCount () const
-        {
-            return m_register_locations.size();
-        }
 
         void
         Clear ();
@@ -368,7 +360,7 @@
     Dump (Stream& s, Thread* thread, lldb::addr_t base_addr) const;
 
     void 
-    AppendRow (RowSP row);
+    AppendRow (const RowSP& row_sp);
 
     // Returns a pointer to the best row for the given offset into the function's instructions.
     // If offset is -1 it indicates that the function start is unknown - the final row in the UnwindPlan is returned.

Modified: lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/Process.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/Process.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/Process.h Mon Jul 23 18:40:37 2012
@@ -836,6 +836,7 @@
         m_plugin_name (),
         m_resume_count (0),
         m_wait_for_launch (false),
+        m_ignore_existing (true),
         m_continue_once_attached (false)
     {
     }
@@ -845,6 +846,7 @@
         m_plugin_name (),
         m_resume_count (0),
         m_wait_for_launch (false),
+        m_ignore_existing (true),
         m_continue_once_attached (false)
     {
         ProcessInfo::operator= (launch_info);
@@ -865,6 +867,18 @@
     }
 
     bool
+    GetIgnoreExisting () const
+    {
+        return m_ignore_existing;
+    }
+    
+    void
+    SetIgnoreExisting (bool b)
+    {
+        m_ignore_existing = b;
+    }
+
+    bool
     GetContinueOnceAttached () const
     {
         return m_continue_once_attached;
@@ -912,6 +926,8 @@
         m_plugin_name.clear();
         m_resume_count = 0;
         m_wait_for_launch = false;
+        m_ignore_existing = true;
+        m_continue_once_attached = false;
     }
 
     bool
@@ -929,6 +945,7 @@
     std::string m_plugin_name;
     uint32_t m_resume_count; // How many times do we resume after launching
     bool m_wait_for_launch;
+    bool m_ignore_existing;
     bool m_continue_once_attached; // Supports the use-case scenario of immediately continuing the process once attached.
 };
 

Modified: lldb/branches/apple/python-GIL/include/lldb/lldb-private-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/lldb-private-enumerations.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/lldb-private-enumerations.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/lldb-private-enumerations.h Mon Jul 23 18:40:37 2012
@@ -1,4 +1,4 @@
-//===-- lldb-enumerations.h -------------------------------------*- C++ -*-===//
+//===-- lldb-private-enumerations.h -----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -106,7 +106,7 @@
 
 
 //----------------------------------------------------------------------
-// Used in conjunction with Host::GetLLDBResource () to find files that
+// Used in conjunction with Host::GetLLDBPath () to find files that
 // are related to 
 //----------------------------------------------------------------------
 typedef enum PathType

Modified: lldb/branches/apple/python-GIL/llvm.zip
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/llvm.zip?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
Binary files - no diff available.

Modified: lldb/branches/apple/python-GIL/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/Python/interface/SBTarget.i?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/Python/interface/SBTarget.i (original)
+++ lldb/branches/apple/python-GIL/scripts/Python/interface/SBTarget.i Mon Jul 23 18:40:37 2012
@@ -125,6 +125,12 @@
     void
     SetWaitForLaunch (bool b);
     
+    bool
+    GetIgnoreExisting ();
+    
+    void
+    SetIgnoreExisting (bool b);
+    
     uint32_t
     GetResumeCount ();
     

Modified: lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff (original)
+++ lldb/branches/apple/python-GIL/scripts/llvm.amalgamated.diff Mon Jul 23 18:40:37 2012
@@ -479,6 +479,32 @@
    return MCDisassembler::Success;
  }
  
+Index: lib/Target/X86/Disassembler/X86Disassembler.cpp
+===================================================================
+--- lib/Target/X86/Disassembler/X86Disassembler.cpp	(revision 152265)
++++ lib/Target/X86/Disassembler/X86Disassembler.cpp	(working copy)
+@@ -322,7 +322,12 @@
+ 
+   OperandType type = (OperandType)operand.type;
+ 
++  bool isBranch = false;
++  uint64_t pcrel = 0;
+   if (type == TYPE_RELv) {
++    isBranch = true;
++    pcrel = insn.startLocation +
++            insn.displacementOffset + insn.displacementSize;
+     switch (insn.displacementSize) {
+     default:
+       break;
+@@ -373,8 +378,6 @@
+     }
+   }
+ 
+-  bool isBranch = false;
+-  uint64_t pcrel = 0;
+   switch (type) {
+   case TYPE_XMM128:
+     mcInst.addOperand(MCOperand::CreateReg(X86::XMM0 + (immediate >> 4)));
 Index: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
 ===================================================================
 --- lib/Target/X86/Disassembler/X86DisassemblerDecoder.c	(revision 152265)

Modified: lldb/branches/apple/python-GIL/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/API/SBTarget.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/API/SBTarget.cpp (original)
+++ lldb/branches/apple/python-GIL/source/API/SBTarget.cpp Mon Jul 23 18:40:37 2012
@@ -369,6 +369,18 @@
     m_opaque_sp->SetWaitForLaunch (b);
 }
 
+bool
+SBAttachInfo::GetIgnoreExisting ()
+{
+    return m_opaque_sp->GetIgnoreExisting();
+}
+
+void
+SBAttachInfo::SetIgnoreExisting (bool b)
+{
+    m_opaque_sp->SetIgnoreExisting (b);
+}
+
 uint32_t
 SBAttachInfo::GetUserID()
 {

Modified: lldb/branches/apple/python-GIL/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Commands/CommandObjectProcess.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Commands/CommandObjectProcess.cpp Mon Jul 23 18:40:37 2012
@@ -350,6 +350,10 @@
                 case 'w':   
                     attach_info.SetWaitForLaunch(true);
                     break;
+                    
+                case 'i':
+                    attach_info.SetIgnoreExisting(false);
+                    break;
 
                 default:
                     error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
@@ -618,11 +622,12 @@
 OptionDefinition
 CommandObjectProcessAttach::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "continue",'c', no_argument,       NULL, 0, eArgTypeNone,         "Immediately continue the process once attached."},
-{ LLDB_OPT_SET_ALL, false, "plugin",  'P', required_argument, NULL, 0, eArgTypePlugin,       "Name of the process plugin you want to use."},
-{ LLDB_OPT_SET_1,   false, "pid",     'p', required_argument, NULL, 0, eArgTypePid,          "The process ID of an existing process to attach to."},
-{ LLDB_OPT_SET_2,   false, "name",    'n', required_argument, NULL, 0, eArgTypeProcessName,  "The name of the process to attach to."},
-{ LLDB_OPT_SET_2,   false, "waitfor", 'w', no_argument,       NULL, 0, eArgTypeNone,         "Wait for the process with <process-name> to launch."},
+{ LLDB_OPT_SET_ALL, false, "continue",'c', no_argument,         NULL, 0, eArgTypeNone,         "Immediately continue the process once attached."},
+{ LLDB_OPT_SET_ALL, false, "plugin",  'P', required_argument,   NULL, 0, eArgTypePlugin,       "Name of the process plugin you want to use."},
+{ LLDB_OPT_SET_1,   false, "pid",     'p', required_argument,   NULL, 0, eArgTypePid,          "The process ID of an existing process to attach to."},
+{ LLDB_OPT_SET_2,   false, "name",    'n', required_argument,   NULL, 0, eArgTypeProcessName,  "The name of the process to attach to."},
+{ LLDB_OPT_SET_2,   false, "include-existing", 'i', no_argument, NULL, 0, eArgTypeNone,         "Include existing processes when doing attach -w."},
+{ LLDB_OPT_SET_2,   false, "waitfor", 'w', no_argument,         NULL, 0, eArgTypeNone,         "Wait for the process with <process-name> to launch."},
 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 

Modified: lldb/branches/apple/python-GIL/source/Core/Mangled.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/Mangled.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/Mangled.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/Mangled.cpp Mon Jul 23 18:40:37 2012
@@ -21,6 +21,14 @@
 
 using namespace lldb_private;
 
+static inline bool
+cstring_is_mangled (const char *s)
+{
+    if (s)
+        return s[0] == '_' && s[1] == 'Z';
+    return false;
+}
+
 #pragma mark Mangled
 //----------------------------------------------------------------------
 // Default constructor
@@ -35,14 +43,20 @@
 // Constructor with an optional string and a boolean indicating if it is
 // the mangled version.
 //----------------------------------------------------------------------
-Mangled::Mangled (const char *s, bool mangled) :
+Mangled::Mangled (const ConstString &s, bool mangled) :
     m_mangled(),
     m_demangled()
 {
-    if (s && s[0])
-    {
+    if (s)
         SetValue(s, mangled);
-    }
+}
+
+Mangled::Mangled (const ConstString &s) :
+    m_mangled(),
+    m_demangled()
+{
+    if (s)
+        SetValue(s);
 }
 
 //----------------------------------------------------------------------
@@ -107,28 +121,52 @@
 // demangled name is set.
 //----------------------------------------------------------------------
 void
-Mangled::SetValue (const char *s, bool mangled)
+Mangled::SetValue (const ConstString &s, bool mangled)
 {
     if (s)
     {
         if (mangled)
         {
-            m_demangled.Clear();        
-            m_mangled.SetCString (s);
+            m_demangled.Clear();
+            m_mangled = s;
+        }
+        else
+        {
+            m_demangled = s;
+            m_mangled.Clear();
+        }
+    }
+    else
+    {
+        m_demangled.Clear();
+        m_mangled.Clear();
+    }
+}
+
+void
+Mangled::SetValue (const ConstString &name)
+{
+    if (name)
+    {
+        if (cstring_is_mangled(name.GetCString()))
+        {
+            m_demangled.Clear();
+            m_mangled = name;
         }
         else
         {
-            m_demangled.SetCString(s);
+            m_demangled = name;
             m_mangled.Clear();
         }
     }
     else
     {
-        m_demangled.Clear();        
+        m_demangled.Clear();
         m_mangled.Clear();
     }
 }
 
+
 //----------------------------------------------------------------------
 // Generate the demangled name on demand using this accessor. Code in
 // this class will need to use this accessor if it wishes to decode
@@ -148,17 +186,15 @@
                             "Mangled::GetDemangledName (m_mangled = %s)",
                             m_mangled.GetCString());
 
-        // We already know mangled is valid from the above check,
-        // lets just make sure it isn't empty...
-        const char * mangled = m_mangled.AsCString();
-        // Don't bother running anything that doesn't start with _Z through the demangler
-        if (mangled[0] == '_' && mangled[1] == 'Z')
+        // Don't bother running anything that isn't mangled
+        const char *mangled_cstr = m_mangled.GetCString();
+        if (cstring_is_mangled(mangled_cstr))
         {
             if (!m_mangled.GetMangledCounterpart(m_demangled))
             {
                 // We didn't already mangle this name, demangle it and if all goes well
                 // add it to our map.
-                char *demangled_name = abi::__cxa_demangle (mangled, NULL, NULL, NULL);
+                char *demangled_name = abi::__cxa_demangle (mangled_cstr, NULL, NULL, NULL);
 
                 if (demangled_name)
                 {
@@ -213,22 +249,6 @@
 }
 
 //----------------------------------------------------------------------
-// Generate the tokens from the demangled name.
-//
-// Returns the number of tokens that were parsed.
-//----------------------------------------------------------------------
-size_t
-Mangled::GetTokens (Mangled::TokenList &tokens) const
-{
-    tokens.Clear();
-    const ConstString& demangled = GetDemangledName();
-    if (demangled && !demangled.IsEmpty())
-        tokens.Parse(demangled.AsCString());
-
-    return tokens.Size();
-}
-
-//----------------------------------------------------------------------
 // Dump a Mangled object to stream "s". We don't force our
 // demangled name to be computed currently (we don't use the accessor).
 //----------------------------------------------------------------------
@@ -286,459 +306,3 @@
         s << ", demangled = <error>";
     return s;
 }
-
-
-
-
-#pragma mark Mangled::Token
-
-//--------------------------------------------------------------
-// Default constructor
-//--------------------------------------------------------------
-Mangled::Token::Token () :
-    type(eInvalid),
-    value()
-{
-}
-
-//--------------------------------------------------------------
-// Equal to operator
-//--------------------------------------------------------------
-bool
-Mangled::Token::operator== (const Token& rhs) const
-{
-    return type == rhs.type && value == rhs.value;
-}
-
-//--------------------------------------------------------------
-// Dump the token to a stream "s"
-//--------------------------------------------------------------
-void
-Mangled::Token::Dump (Stream *s) const
-{
-    switch (type)
-    {
-    case eInvalid:      s->PutCString("invalid    "); break;
-    case eNameSpace:    s->PutCString("namespace  "); break;
-    case eMethodName:   s->PutCString("method     "); break;
-    case eType:         s->PutCString("type       "); break;
-    case eTemplate:     s->PutCString("template   "); break;
-    case eTemplateBeg:  s->PutCString("template < "); break;
-    case eTemplateEnd:  s->PutCString("template > "); break;
-    case eParamsBeg:    s->PutCString("params   ( "); break;
-    case eParamsEnd:    s->PutCString("params   ) "); break;
-    case eQualifier:    s->PutCString("qualifier  "); break;
-    case eError:        s->PutCString("ERROR      "); break;
-    default:
-        s->Printf("type = %i", type);
-        break;
-    }
-    value.DumpDebug(s);
-}
-
-//--------------------------------------------------------------
-// Returns true if this token is a wildcard
-//--------------------------------------------------------------
-bool
-Mangled::Token::IsWildcard () const
-{
-    static ConstString g_wildcard_str("*");
-    return value == g_wildcard_str;
-}
-
-
-//----------------------------------------------------------------------
-// Dump "obj" to the supplied stream "s"
-//----------------------------------------------------------------------
-Stream&
-lldb_private::operator << (Stream& s, const Mangled::Token& obj)
-{
-    obj.Dump(&s);
-    return s;
-}
-
-
-#pragma mark Mangled::TokenList
-//----------------------------------------------------------------------
-// Mangled::TokenList
-//----------------------------------------------------------------------
-
-//--------------------------------------------------------------
-// Default constructor. If demangled is non-NULL and not-empty
-// the token list will parse up the demangled string it is
-// given, else the object will initialize an empty token list.
-//--------------------------------------------------------------
-Mangled::TokenList::TokenList (const char *demangled) :
-    m_tokens()
-{
-    if (demangled && demangled[0])
-    {
-        Parse(demangled);
-    }
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-Mangled::TokenList::~TokenList ()
-{
-}
-
-//----------------------------------------------------------------------
-// Parses "demangled" into tokens. This allows complex
-// comparisons to be done. Comparisons can include wildcards at
-// the namespace, method name, template, and template and
-// parameter type levels.
-//
-// Example queries include:
-// "std::basic_string<*>"   // Find all std::basic_string variants
-// "std::basic_string<*>::erase(*)" // Find all std::basic_string::erase variants with any number of parameters
-// "*::clear()"             // Find all functions with a method name of
-//                          // "clear" that are in any namespace that
-//                          // have no parameters
-// "::printf"               // Find the printf function in the global namespace
-// "printf"                 // Ditto
-// "foo::*(int)"            // Find all functions in the class or namespace "foo" that take a single integer argument
-//
-// Returns the number of tokens that were decoded, or zero when
-// we fail.
-//----------------------------------------------------------------------
-size_t
-Mangled::TokenList::Parse (const char *s)
-{
-    m_tokens.clear();
-
-    Token token;
-    token.type = eNameSpace;
-
-    TokenType max_type = eInvalid;
-    const char *p = s;
-    size_t span = 0;
-    size_t sep_size = 0;
-
-    while (*p != '\0')
-    {
-        p = p + span + sep_size;
-        while (isspace(*p))
-            ++p;
-
-        if (*p == '\0')
-            break;
-
-        span = strcspn(p, ":<>(),");
-        sep_size = 1;
-        token.type = eInvalid;
-        switch (p[span])
-        {
-        case '\0':
-            break;
-
-        case ':':
-            if (p[span+1] == ':')
-            {
-                sep_size = 2;
-                if (span > 0)
-                {
-                    token.type = eNameSpace;
-                    token.value.SetCStringWithLength (p, span);
-                    m_tokens.push_back(token);
-                }
-                else
-                    continue;
-            }
-            break;
-
-        case '(':
-            if (span > 0)
-            {
-                token.type = eMethodName;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eParamsBeg;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case ',':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-            else
-            {
-                continue;
-            }
-            break;
-
-        case ')':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eParamsEnd;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case '<':
-            if (span > 0)
-            {
-                token.type = eTemplate;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eTemplateBeg;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-
-        case '>':
-            if (span > 0)
-            {
-                token.type = eType;
-                token.value.SetCStringWithLength (p, span);
-                m_tokens.push_back(token);
-            }
-
-            token.type = eTemplateEnd;
-            token.value.Clear();
-            m_tokens.push_back(token);
-            break;
-        }
-
-        if (max_type < token.type)
-            max_type = token.type;
-
-        if (token.type == eInvalid)
-        {
-            if (max_type >= eParamsEnd)
-            {
-                token.type = eQualifier;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            else if (max_type >= eParamsBeg)
-            {
-                token.type = eType;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            else
-            {
-                token.type = eMethodName;
-                token.value.SetCString(p);
-                m_tokens.push_back(token);
-            }
-            break;
-        }
-    }
-    return m_tokens.size();
-}
-
-
-//----------------------------------------------------------------------
-// Clear the token list.
-//----------------------------------------------------------------------
-void
-Mangled::TokenList::Clear ()
-{
-    m_tokens.clear();
-}
-
-//----------------------------------------------------------------------
-// Dump the token list to the stream "s"
-//----------------------------------------------------------------------
-void
-Mangled::TokenList::Dump (Stream *s) const
-{
-    collection::const_iterator pos;
-    collection::const_iterator beg = m_tokens.begin();
-    collection::const_iterator end = m_tokens.end();
-    for (pos = beg; pos != end; ++pos)
-    {
-        s->Indent("token[");
-        *s << (uint32_t)std::distance(beg, pos) << "] = " << *pos << "\n";
-    }
-}
-
-//----------------------------------------------------------------------
-// Find the first token in the list that has "token_type" as its
-// type
-//----------------------------------------------------------------------
-const Mangled::Token *
-Mangled::TokenList::Find (TokenType token_type) const
-{
-    collection::const_iterator pos;
-    collection::const_iterator beg = m_tokens.begin();
-    collection::const_iterator end = m_tokens.end();
-    for (pos = beg; pos != end; ++pos)
-    {
-        if (pos->type == token_type)
-            return &(*pos);
-    }
-    return NULL;
-}
-
-//----------------------------------------------------------------------
-// Return the token at index "idx", or NULL if the index is
-// out of range.
-//----------------------------------------------------------------------
-const Mangled::Token *
-Mangled::TokenList::GetTokenAtIndex (uint32_t idx) const
-{
-    if (idx < m_tokens.size())
-        return &m_tokens[idx];
-    return NULL;
-}
-
-
-//----------------------------------------------------------------------
-// Given a token list, see if it matches this object's tokens.
-// "token_list" can contain wild card values to enable powerful
-// matching. Matching the std::string::erase(*) example that was
-// tokenized above we could use a token list such as:
-//
-//      token           name
-//      -----------     ----------------------------------------
-//      eNameSpace      "std"
-//      eTemplate       "basic_string"
-//      eTemplateBeg
-//      eInvalid        "*"
-//      eTemplateEnd
-//      eMethodName     "erase"
-//      eParamsBeg
-//      eInvalid        "*"
-//      eParamsEnd
-//
-// Returns true if it "token_list" matches this object's tokens,
-// false otherwise.
-//----------------------------------------------------------------------
-bool
-Mangled::TokenList::MatchesQuery (const Mangled::TokenList &match) const
-{
-    size_t match_count = 0;
-    collection::const_iterator pos;
-    collection::const_iterator pos_end = m_tokens.end();
-
-    collection::const_iterator match_pos;
-    collection::const_iterator match_pos_end = match.m_tokens.end();
-    collection::const_iterator match_wildcard_pos = match_pos_end;
-    collection::const_iterator match_next_pos = match_pos_end;
-
-    size_t template_scope_depth = 0;
-
-    for (pos = m_tokens.begin(), match_pos = match.m_tokens.begin();
-         pos != pos_end && match_pos != match_pos_end;
-         ++match_pos)
-    {
-        match_next_pos = match_pos + 1;
-        // Is this a wildcard?
-        if (match_pos->IsWildcard())
-        {
-            if (match_wildcard_pos != match_pos_end)
-                return false;   // Can't have two wildcards in effect at once.
-
-            match_wildcard_pos = match_pos;
-            // Are we at the end of the MATCH token list?
-            if (match_next_pos == match_pos_end)
-            {
-                // There is nothing more to match, return if we have any matches so far...
-                return match_count > 0;
-            }
-        }
-
-        if (match_pos->type == eInvalid || match_pos->type == eError)
-        {
-            return false;
-        }
-        else
-        {
-            if (match_pos->type == eTemplateBeg)
-            {
-                ++template_scope_depth;
-            }
-            else if (match_pos->type == eTemplateEnd)
-            {
-                assert(template_scope_depth > 0);
-                --template_scope_depth;
-            }
-
-            // Do we have a wildcard going right now?
-            if (match_wildcard_pos == match_pos_end)
-            {
-                // No wildcard matching right now, just check and see if things match
-                if (*pos == *match_pos)
-                    ++match_count;
-                else
-                    return false;
-            }
-            else
-            {
-                // We have a wildcard match going
-
-                // For template types we need to make sure to match the template depths...
-                const size_t start_wildcard_template_scope_depth = template_scope_depth;
-                size_t curr_wildcard_template_scope_depth = template_scope_depth;
-                while (pos != pos_end)
-                {
-                    if (match_wildcard_pos->type == eNameSpace && pos->type == eParamsBeg)
-                        return false;
-
-                    if (start_wildcard_template_scope_depth == curr_wildcard_template_scope_depth)
-                    {
-                        if (*pos == *match_next_pos)
-                        {
-                            ++match_count;
-                            match_pos = match_next_pos;
-                            match_wildcard_pos = match_pos_end;
-                            break;
-                        }
-                    }
-                    if (pos->type == eTemplateBeg)
-                        ++curr_wildcard_template_scope_depth;
-                    else if (pos->type == eTemplateEnd)
-                        --curr_wildcard_template_scope_depth;
-
-
-                    ++pos;
-                }
-            }
-        }
-
-        if (pos != pos_end)
-            ++pos;
-    }
-    if (match_pos != match_pos_end)
-        return false;
-
-    return match_count > 0;
-}
-
-
-//----------------------------------------------------------------------
-// Return the number of tokens in the token collection
-//----------------------------------------------------------------------
-size_t
-Mangled::TokenList::Size () const
-{
-    return m_tokens.size();
-}
-
-
-//----------------------------------------------------------------------
-// Stream out the tokens
-//----------------------------------------------------------------------
-Stream&
-lldb_private::operator << (Stream& s, const Mangled::TokenList& obj)
-{
-    obj.Dump(&s);
-    return s;
-}

Modified: lldb/branches/apple/python-GIL/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Expression/IRForTarget.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Expression/IRForTarget.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Expression/IRForTarget.cpp Mon Jul 23 18:40:37 2012
@@ -229,7 +229,7 @@
     {
         if (!m_decl_map->GetFunctionInfo (fun_decl, fun_addr)) 
         {
-            lldb_private::ConstString alternate_mangling_const_str;
+            lldb_private::ConstString altnernate_name;
             bool found_it = m_decl_map->GetFunctionAddress (name, fun_addr);
             if (!found_it)
             {
@@ -240,27 +240,35 @@
                 {
                     std::string alternate_mangling("_ZNKSs");
                     alternate_mangling.append (name_cstr + strlen("_ZNKSbIcE"));
-                    alternate_mangling_const_str.SetCString(alternate_mangling.c_str());
-                    found_it = m_decl_map->GetFunctionAddress (alternate_mangling_const_str, fun_addr);
+                    altnernate_name.SetCString(alternate_mangling.c_str());
+                    found_it = m_decl_map->GetFunctionAddress (altnernate_name, fun_addr);
                 }
             }
             
             if (!found_it)
             {
+                lldb_private::Mangled mangled_name(name);
+                lldb_private::Mangled alt_mangled_name(altnernate_name);
                 if (log)
                 {
-                    if (alternate_mangling_const_str)
-                        log->Printf("Function \"%s\" (alternate name \"%s\") has no address", name.GetCString(), alternate_mangling_const_str.GetCString());
+                    if (alt_mangled_name)
+                        log->Printf("Function \"%s\" (alternate name \"%s\") has no address",
+                                    mangled_name.GetName().GetCString(),
+                                    alt_mangled_name.GetName().GetCString());
                     else
-                        log->Printf("Function \"%s\" had no address", name.GetCString());
+                        log->Printf("Function \"%s\" had no address",
+                                    mangled_name.GetName().GetCString());
                 }
                 
                 if (m_error_stream)
                 {
-                    if (alternate_mangling_const_str)
-                        m_error_stream->Printf("error: call to a function '%s' (alternate name '%s') that is not present in the target\n", name.GetCString(), alternate_mangling_const_str.GetCString());
+                    if (alt_mangled_name)
+                        m_error_stream->Printf("error: call to a function '%s' (alternate name '%s') that is not present in the target\n",
+                                               mangled_name.GetName().GetCString(),
+                                               alt_mangled_name.GetName().GetCString());
                     else
-                        m_error_stream->Printf("error: call to a function '%s' that is not present in the target\n", name.GetCString());
+                        m_error_stream->Printf("error: call to a function '%s' that is not present in the target\n",
+                                               mangled_name.GetName().GetCString());
                 }
                 return false;
             }
@@ -1810,6 +1818,51 @@
 }
 
 bool
+IRForTarget::RemoveCXAAtExit (BasicBlock &basic_block)
+{
+    BasicBlock::iterator ii;
+    
+    std::vector<CallInst *> calls_to_remove;
+    
+    for (ii = basic_block.begin();
+         ii != basic_block.end();
+         ++ii)
+    {
+        Instruction &inst = *ii;
+        
+        CallInst *call = dyn_cast<CallInst>(&inst);
+        
+        // MaybeHandleCallArguments handles error reporting; we are silent here
+        if (!call)
+            continue;
+        
+        bool remove = false;
+    
+        llvm::Function *func = call->getCalledFunction();
+        
+        if (func && func->getName() == "__cxa_atexit")
+            remove = true;
+        
+        llvm::Value *val = call->getCalledValue();
+        
+        if (val && val->getName() == "__cxa_atexit")
+            remove = true;
+        
+        if (remove)
+            calls_to_remove.push_back(call);
+    }
+    
+    for (std::vector<CallInst *>::iterator ci = calls_to_remove.begin(), ce = calls_to_remove.end();
+         ci != ce;
+         ++ci)
+    {
+        (*ci)->eraseFromParent();
+    }
+    
+    return true;
+}
+
+bool
 IRForTarget::ResolveCalls(BasicBlock &basic_block)
 {        
     /////////////////////////////////////////////////////////////////////////
@@ -2676,6 +2729,16 @@
             
             return false;
         }
+        
+        if (!RemoveCXAAtExit(*bbi))
+        {
+            if (log)
+                log->Printf("RemoveCXAAtExit() failed");
+            
+            // RemoveCXAAtExit() reports its own errors, so we don't do so here
+
+            return false;
+        }
     }
     
     if (m_decl_map && m_execution_policy != lldb_private::eExecutionPolicyAlways)

Modified: lldb/branches/apple/python-GIL/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Interpreter/Args.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Interpreter/Args.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Interpreter/Args.cpp Mon Jul 23 18:40:37 2012
@@ -230,7 +230,18 @@
                             break;
 
                         default:
-                            arg_pos = arg_end + 2;
+                            if (quote_char == '\0')
+                            {
+                                arg.append (arg_piece_start, arg_end - arg_piece_start);
+                                if (arg_end + 1 != '\0')
+                                {
+                                    arg.append (arg_end + 1, 1);
+                                    arg_pos = arg_end + 2;
+                                    arg_piece_start = arg_pos;
+                                }
+                            }
+                            else
+                                arg_pos = arg_end + 2;
                             break;
                     }
                     break;

Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Jul 23 18:40:37 2012
@@ -1801,7 +1801,7 @@
                                                                 {
                                                                     // We have two consecutive N_SO entries where the first contains a directory
                                                                     // and the second contains a full path.
-                                                                    sym[sym_idx - 1].GetMangled().SetValue(symbol_name, false);
+                                                                    sym[sym_idx - 1].GetMangled().SetValue(ConstString(symbol_name), false);
                                                                     m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                                                                     add_nlist = false;
                                                                 }
@@ -1823,7 +1823,7 @@
                                                                     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);
+                                                                    sym[sym_idx - 1].GetMangled().SetValue(ConstString(full_so_path.c_str()), false);
                                                                     add_nlist = false;
                                                                     m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                                                                 }
@@ -2127,8 +2127,8 @@
                                                 
                                                 if (symbol_name_non_abi_mangled)
                                                 {
-                                                    sym[sym_idx].GetMangled().SetMangledName (symbol_name_non_abi_mangled);
-                                                    sym[sym_idx].GetMangled().SetDemangledName (symbol_name);
+                                                    sym[sym_idx].GetMangled().SetMangledName (ConstString(symbol_name_non_abi_mangled));
+                                                    sym[sym_idx].GetMangled().SetDemangledName (ConstString(symbol_name));
                                                 }
                                                 else
                                                 {
@@ -2140,7 +2140,7 @@
                                                     
                                                     if (symbol_name)
                                                     {
-                                                        sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled);
+                                                        sym[sym_idx].GetMangled().SetValue(ConstString(symbol_name), symbol_name_is_mangled);
                                                     }
                                                 }
                                                 
@@ -2520,7 +2520,7 @@
                             {
                                 // We have two consecutive N_SO entries where the first contains a directory
                                 // and the second contains a full path.
-                                sym[sym_idx - 1].GetMangled().SetValue(symbol_name, false);
+                                sym[sym_idx - 1].GetMangled().SetValue(ConstString(symbol_name), false);
                                 m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                                 add_nlist = false;
                             }
@@ -2542,7 +2542,7 @@
                                 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);
+                                sym[sym_idx - 1].GetMangled().SetValue(ConstString(full_so_path.c_str()), false);
                                 add_nlist = false;
                                 m_nlist_idx_to_sym_idx[nlist_idx] = sym_idx - 1;
                             }
@@ -2846,8 +2846,8 @@
 
                 if (symbol_name_non_abi_mangled)
                 {
-                    sym[sym_idx].GetMangled().SetMangledName (symbol_name_non_abi_mangled);
-                    sym[sym_idx].GetMangled().SetDemangledName (symbol_name);
+                    sym[sym_idx].GetMangled().SetMangledName (ConstString(symbol_name_non_abi_mangled));
+                    sym[sym_idx].GetMangled().SetDemangledName (ConstString(symbol_name));
                 }
                 else
                 {
@@ -2859,7 +2859,7 @@
 
                     if (symbol_name)
                     {
-                        sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled);
+                        sym[sym_idx].GetMangled().SetValue(ConstString(symbol_name), symbol_name_is_mangled);
                     }
                 }
 
@@ -3065,7 +3065,7 @@
                                           ++synthetic_function_symbol_idx,
                                           module_sp->GetFileSpec().GetFilename().GetCString());
                                 sym[sym_idx].SetID (synthetic_sym_id++);
-                                sym[sym_idx].GetMangled().SetDemangledName(synthetic_function_symbol);
+                                sym[sym_idx].GetMangled().SetDemangledName(ConstString(synthetic_function_symbol));
                                 sym[sym_idx].SetType (eSymbolTypeCode);
                                 sym[sym_idx].SetIsSynthetic (true);
                                 sym[sym_idx].GetAddress() = symbol_addr;

Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Mon Jul 23 18:40:37 2012
@@ -544,7 +544,7 @@
                     symbol.storage  = symtab_data.GetU8  (&offset);
                     symbol.naux     = symtab_data.GetU8  (&offset);		
                     Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
-                    symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z');
+                    symbols[i].GetMangled ().SetValue (ConstString(symbol_name.c_str()));
                     symbols[i].GetAddress() = symbol_addr;
 
                     if (symbol.naux > 0)

Modified: lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Jul 23 18:40:37 2012
@@ -50,6 +50,7 @@
     m_supports_memory_region_info  (eLazyBoolCalculate),
     m_supports_watchpoint_support_info  (eLazyBoolCalculate),
     m_watchpoints_trigger_after_instruction(eLazyBoolCalculate),
+    m_attach_or_wait_reply(eLazyBoolCalculate),
     m_supports_qProcessInfoPID (true),
     m_supports_qfProcessInfo (true),
     m_supports_qUserName (true),
@@ -133,6 +134,26 @@
     }
 }
 
+bool
+GDBRemoteCommunicationClient::GetVAttachOrWaitSupported ()
+{
+    if (m_attach_or_wait_reply == eLazyBoolCalculate)
+    {
+        m_attach_or_wait_reply = eLazyBoolNo;
+        
+        StringExtractorGDBRemote response;
+        if (SendPacketAndWaitForResponse("qVAttachOrWaitSupported", response, false))
+        {
+            if (response.IsOKResponse())
+                m_attach_or_wait_reply = eLazyBoolYes;
+        }
+    }
+    if (m_attach_or_wait_reply == eLazyBoolYes)
+        return true;
+    else
+        return false;
+}
+
 
 void
 GDBRemoteCommunicationClient::ResetDiscoverableSettings()

Modified: lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Mon Jul 23 18:40:37 2012
@@ -221,6 +221,9 @@
     bool
     GetVContSupported (char flavor);
 
+    bool
+    GetVAttachOrWaitSupported ();
+    
     void
     ResetDiscoverableSettings();
 
@@ -365,7 +368,8 @@
     lldb_private::LazyBool m_supports_memory_region_info;
     lldb_private::LazyBool m_supports_watchpoint_support_info;
     lldb_private::LazyBool m_watchpoints_trigger_after_instruction;
-
+    lldb_private::LazyBool m_attach_or_wait_reply;
+    
     bool
         m_supports_qProcessInfoPID:1,
         m_supports_qfProcessInfo:1,

Modified: lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Jul 23 18:40:37 2012
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include <spawn.h>
 #include <stdlib.h>
+#include <netinet/in.h>
 #include <sys/mman.h>       // for mmap
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -80,6 +81,18 @@
 
 static bool rand_initialized = false;
 
+// TODO Randomly assigning a port is unsafe.  We should get an unused
+// ephemeral port from the kernel and make sure we reserve it before passing
+// it to debugserver.
+
+#if defined (__APPLE__)
+#define LOW_PORT    (IPPORT_RESERVED)
+#define HIGH_PORT   (IPPORT_HIFIRSTAUTO)
+#else
+#define LOW_PORT    (1024u)
+#define HIGH_PORT   (49151u)
+#endif
+
 static inline uint16_t
 get_random_port ()
 {
@@ -90,7 +103,7 @@
         rand_initialized = true;
         srand(seed);
     }
-    return (rand() % (UINT16_MAX - 1000u)) + 1000u;
+    return (rand() % (HIGH_PORT - LOW_PORT)) + LOW_PORT;
 }
 
 
@@ -729,6 +742,7 @@
     m_gdb_comm.GetListThreadsInStopReplySupported ();
     m_gdb_comm.GetHostInfo ();
     m_gdb_comm.GetVContSupported ('c');
+    m_gdb_comm.GetVAttachOrWaitSupported();
     
     size_t num_cmds = GetExtraStartupCommands().GetArgumentCount();
     for (size_t idx = 0; idx < num_cmds; idx++)
@@ -916,7 +930,19 @@
             StreamString packet;
             
             if (wait_for_launch)
-                packet.PutCString("vAttachWait");
+            {
+                if (!m_gdb_comm.GetVAttachOrWaitSupported())
+                {
+                    packet.PutCString ("vAttachWait");
+                }
+                else
+                {
+                    if (attach_info.GetIgnoreExisting())
+                        packet.PutCString("vAttachWait");
+                    else
+                        packet.PutCString ("vAttachOrWait");
+                }
+            }
             else
                 packet.PutCString("vAttachName");
             packet.PutChar(';');

Modified: lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Jul 23 18:40:37 2012
@@ -797,7 +797,7 @@
                     // with duplicate entries
                     if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (name && ::strcmp(name, mangled_cstr) != 0)))
                     {
-                        Mangled mangled (mangled_cstr, true);
+                        Mangled mangled (ConstString(mangled_cstr), true);
                         func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
                         if (mangled.GetDemangledName())
                             func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
@@ -819,7 +819,7 @@
                     // with duplicate entries
                     if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
                     {
-                        Mangled mangled (mangled_cstr, true);
+                        Mangled mangled (ConstString(mangled_cstr), true);
                         func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
                         if (mangled.GetDemangledName())
                             func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
@@ -864,7 +864,7 @@
                 // with duplicate entries
                 if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
                 {
-                    Mangled mangled (mangled_cstr, true);
+                    Mangled mangled (ConstString(mangled_cstr), true);
                     globals.Insert (mangled.GetMangledName(), die.GetOffset());
                     if (mangled.GetDemangledName())
                         globals.Insert (mangled.GetDemangledName(), die.GetOffset());

Modified: lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Jul 23 18:40:37 2012
@@ -859,9 +859,9 @@
         {
             Mangled func_name;
             if (mangled)
-                func_name.SetValue(mangled, true);
+                func_name.SetValue(ConstString(mangled), true);
             else if (name)
-                func_name.SetValue(name, false);
+                func_name.SetValue(ConstString(name), false);
 
             FunctionSP func_sp;
             std::auto_ptr<Declaration> decl_ap;
@@ -3069,7 +3069,7 @@
             if (attributes.ExtractFormValueAtIndex(this, idx, form_value))
             {
                 const char *name = form_value.AsCString(&get_debug_str_data());
-                best_name.SetValue (name, true);
+                best_name.SetValue (ConstString(name), true);
             } 
         }
         if (best_name)
@@ -6162,9 +6162,6 @@
                         {
                             std::vector<uint64_t> 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();
                             clang_type_t array_element_type = element_type->GetClangForwardType();

Modified: lldb/branches/apple/python-GIL/source/Symbol/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Symbol/Function.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Symbol/Function.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Symbol/Function.cpp Mon Jul 23 18:40:37 2012
@@ -100,7 +100,7 @@
     const Declaration *call_decl_ptr
 ) :
     FunctionInfo(name, decl_ptr),
-    m_mangled(mangled, true),
+    m_mangled(ConstString(mangled), true),
     m_call_decl (call_decl_ptr)
 {
 }
@@ -233,7 +233,7 @@
     m_comp_unit (comp_unit),
     m_type_uid (type_uid),
     m_type (type),
-    m_mangled (mangled, true),
+    m_mangled (ConstString(mangled), true),
     m_block (func_uid),
     m_range (range),
     m_frame_base (),

Modified: lldb/branches/apple/python-GIL/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Symbol/Symbol.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Symbol/Symbol.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Symbol/Symbol.cpp Mon Jul 23 18:40:37 2012
@@ -54,7 +54,7 @@
 ) :
     SymbolContextScope (),
     m_uid (symID),
-    m_mangled (name, name_is_mangled),
+    m_mangled (ConstString(name), name_is_mangled),
     m_type_data (0),
     m_type_data_resolved (false),
     m_is_synthetic (is_artificial),
@@ -84,7 +84,7 @@
 ) :
     SymbolContextScope (),
     m_uid (symID),
-    m_mangled (name, name_is_mangled),
+    m_mangled (ConstString(name), name_is_mangled),
     m_type_data (0),
     m_type_data_resolved (false),
     m_is_synthetic (is_artificial),

Modified: lldb/branches/apple/python-GIL/source/Symbol/UnwindPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Symbol/UnwindPlan.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Symbol/UnwindPlan.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Symbol/UnwindPlan.cpp Mon Jul 23 18:40:37 2012
@@ -300,25 +300,16 @@
 {
     if (m_offset != rhs.m_offset || m_cfa_reg_num != rhs.m_cfa_reg_num || m_cfa_offset != rhs.m_cfa_offset)
         return false;
-    if (m_register_locations.size() != rhs.m_register_locations.size())
-        return false;
-    for (collection::const_iterator idx = m_register_locations.begin(); idx != m_register_locations.end(); ++idx)
-    {
-        collection::const_iterator lhs_pos = m_register_locations.find(idx->first);
-        collection::const_iterator rhs_pos = rhs.m_register_locations.find(idx->first);
-        if (lhs_pos->second != rhs_pos->second)
-            return false;
-    }
-    return true;
+    return m_register_locations == rhs.m_register_locations;
 }
 
 void
-UnwindPlan::AppendRow (UnwindPlan::RowSP row)
+UnwindPlan::AppendRow (const UnwindPlan::RowSP &row_sp)
 {
-    if (m_row_list.empty() || m_row_list.back()->GetOffset() != row->GetOffset())
-        m_row_list.push_back(row);
+    if (m_row_list.empty() || m_row_list.back()->GetOffset() != row_sp->GetOffset())
+        m_row_list.push_back(row_sp);
     else
-        m_row_list.back() = row;
+        m_row_list.back() = row_sp;
 }
 
 UnwindPlan::RowSP

Modified: lldb/branches/apple/python-GIL/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Symbol/Variable.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Symbol/Variable.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Symbol/Variable.cpp Mon Jul 23 18:40:37 2012
@@ -46,7 +46,7 @@
 ) :
     UserID(uid),
     m_name(name),
-    m_mangled (mangled, true),
+    m_mangled (ConstString(mangled), true),
     m_symfile_type_sp(symfile_type_sp),
     m_scope(scope),
     m_owner_scope(context),

Modified: lldb/branches/apple/python-GIL/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Process.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Process.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Process.cpp Mon Jul 23 18:40:37 2012
@@ -2709,75 +2709,6 @@
     return error;
 }
 
-//Error
-//Process::Attach (const char *process_name, bool wait_for_launch)
-//{
-//    m_abi_sp.reset();
-//    m_process_input_reader.reset();
-//    
-//    // Find the process and its architecture.  Make sure it matches the architecture
-//    // of the current Target, and if not adjust it.
-//    Error error;
-//    
-//    if (!wait_for_launch)
-//    {
-//        ProcessInstanceInfoList process_infos;
-//        PlatformSP platform_sp (m_target.GetPlatform ());
-//        assert (platform_sp.get());
-//        
-//        if (platform_sp)
-//        {
-//            ProcessInstanceInfoMatch match_info;
-//            match_info.GetProcessInfo().SetName(process_name);
-//            match_info.SetNameMatchType (eNameMatchEquals);
-//            platform_sp->FindProcesses (match_info, process_infos);
-//            if (process_infos.GetSize() > 1)
-//            {
-//                error.SetErrorStringWithFormat ("more than one process named %s", process_name);
-//            }
-//            else if (process_infos.GetSize() == 0)
-//            {
-//                error.SetErrorStringWithFormat ("could not find a process named %s", process_name);
-//            }
-//        }
-//        else
-//        {        
-//            error.SetErrorString ("invalid platform");
-//        }
-//    }
-//
-//    if (error.Success())
-//    {
-//        m_dyld_ap.reset();
-//        m_os_ap.reset();
-//        
-//        error = WillAttachToProcessWithName(process_name, wait_for_launch);
-//        if (error.Success())
-//        {
-//            SetPublicState (eStateAttaching);
-//            error = DoAttachToProcessWithName (process_name, wait_for_launch);
-//            if (error.Fail())
-//            {
-//                if (GetID() != LLDB_INVALID_PROCESS_ID)
-//                {
-//                    SetID (LLDB_INVALID_PROCESS_ID);
-//                    const char *error_string = error.AsCString();
-//                    if (error_string == NULL)
-//                        error_string = "attach failed";
-//
-//                    SetExitStatus(-1, error_string);
-//                }
-//            }
-//            else
-//            {
-//                SetNextEventAction(new Process::AttachCompletionHandler(this, 0));
-//                StartPrivateStateThread();
-//            }
-//        }
-//    }
-//    return error;
-//}
-
 void
 Process::CompleteAttach ()
 {

Modified: lldb/branches/apple/python-GIL/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Target.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Target.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Target.cpp Mon Jul 23 18:40:37 2012
@@ -2915,7 +2915,11 @@
     { TSC_PREFER_DYNAMIC    , eSetVarTypeEnum   , NULL          , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." },
     { TSC_ENABLE_SYNTHETIC  , eSetVarTypeBoolean, "true"        , NULL,                  false, false, "Should synthetic values be used by default whenever available." },
     { TSC_SKIP_PROLOGUE     , eSetVarTypeBoolean, "true"        , NULL,                  false, false, "Skip function prologues when setting breakpoints by name." },
-    { TSC_SOURCE_MAP        , eSetVarTypeArray  , NULL          , NULL,                  false, false, "Source path remappings to use when locating source files from debug information." },
+    { TSC_SOURCE_MAP        , eSetVarTypeArray  , NULL          , NULL,                  false, false, "Source path remappings used to track the change of location between a source file when built, and "
+                                                                                                       "where it exists on the current system.  It consists of an array of duples, the first element of each duple is "
+                                                                                                       "some part (starting at the root) of the path to the file when it was built, "
+                                                                                                       "and the second is where the remainder of the original build hierarchy is rooted on the local system.  "
+                                                                                                       "Each element of the array is checked in order and the first one that results in a match wins." },
     { TSC_EXE_SEARCH_PATHS  , eSetVarTypeArray  , NULL          , NULL,                  false, false, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
     { TSC_MAX_CHILDREN      , eSetVarTypeInt    , "256"         , NULL,                  true,  false, "Maximum number of children to expand in any level of depth." },
     { TSC_MAX_STRLENSUMMARY , eSetVarTypeInt    , "1024"        , NULL,                  true,  false, "Maximum number of characters to show when using %s in summary strings." },

Modified: lldb/branches/apple/python-GIL/test/lang/c/struct_types/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/lang/c/struct_types/main.c?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/lang/c/struct_types/main.c (original)
+++ lldb/branches/apple/python-GIL/test/lang/c/struct_types/main.c Mon Jul 23 18:40:37 2012
@@ -10,6 +10,7 @@
 {
     struct point_tag {
         int x;
+        char padding[0];
         int y;
     }; // Set break point at this line.
 
@@ -17,7 +18,7 @@
         struct point_tag bottom_left;
         struct point_tag top_right;
     };
-    struct point_tag pt = { 2, 3 }; // This is the first executable statement.
-    struct rect_tag rect = {{1,2}, {3,4}};
+    struct point_tag pt = { 2, {}, 3 }; // This is the first executable statement.
+    struct rect_tag rect = {{1, {}, 2}, {3, {}, 4}};
     return 0;
 }

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.cpp Mon Jul 23 18:40:37 2012
@@ -440,10 +440,11 @@
         const char *process_name;
         process_name = strrchr (full_process_name, '/');
         if (process_name == NULL)
-          process_name = full_process_name;
+            process_name = full_process_name;
         else
-          process_name++;
+            process_name++;
 
+        const int process_name_len = strlen(process_name);
         std::vector<struct kinfo_proc> proc_infos;
         const size_t num_proc_infos = GetAllInfos(proc_infos);
         if (num_proc_infos > 0)
@@ -457,10 +458,49 @@
 
                 // Check for process by name. We only check the first MAXCOMLEN
                 // chars as that is all that kp_proc.p_comm holds.
-                if (::strncasecmp(proc_infos[i].kp_proc.p_comm, process_name, MAXCOMLEN) == 0)
+                if (::strncasecmp(process_name, proc_infos[i].kp_proc.p_comm, MAXCOMLEN) == 0)
                 {
-                    // We found a matching process, add it to our list
-                    matching_proc_infos.push_back(proc_infos[i]);
+                    if (process_name_len > MAXCOMLEN)
+                    {
+                        // We found a matching process name whose first MAXCOMLEN
+                        // characters match, but there is more to the name than
+                        // this. We need to get the full process name. 
+
+                        int proc_args_mib[3] = { CTL_KERN, KERN_PROCARGS2, proc_infos[i].kp_proc.p_pid };
+                        
+                        // Get PATH_MAX for argv[0] plus 4 bytes for the argc
+                        char arg_data[PATH_MAX+4];
+                        size_t arg_data_size = sizeof(arg_data);
+                         // Skip the 4 byte argc integer value to get to argv[0]
+                        const char *argv0 = arg_data + 4;
+                        if (::sysctl (proc_args_mib, 3, arg_data, &arg_data_size , NULL, 0) == 0)
+                        {
+                            const char *argv_basename = strrchr(argv0, '/');
+                            if (argv_basename)
+                            {
+                                // Skip the '/'
+                                ++argv_basename;
+                            }
+                            else
+                            {
+                                // We didn't find a directory delimiter in the process argv[0], just use what was in there
+                                argv_basename = argv0;
+                            }
+
+                            if (argv_basename)
+                            {
+                                if (::strncasecmp(process_name, argv_basename, PATH_MAX) == 0)
+                                {
+                                    matching_proc_infos.push_back(proc_infos[i]);
+                                }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        // We found a matching process, add it to our list
+                        matching_proc_infos.push_back(proc_infos[i]);
+                    }
                 }
             }
         }
@@ -472,6 +512,7 @@
 nub_process_t
 DNBProcessAttachWait (const char *waitfor_process_name, 
                       nub_launch_flavor_t launch_flavor,
+                      bool ignore_existing,
                       struct timespec *timeout_abstime, 
                       useconds_t waitfor_interval,
                       char *err_str, 
@@ -495,7 +536,12 @@
     }
 
     if (attach_token == NULL)
-        num_exclude_proc_infos = GetAllInfosMatchingName (waitfor_process_name, exclude_proc_infos);
+    {
+        if (ignore_existing)
+            num_exclude_proc_infos = GetAllInfosMatchingName (waitfor_process_name, exclude_proc_infos);
+        else
+            num_exclude_proc_infos = 0;
+    }
 
     DNBLogThreadedIf (LOG_PROCESS, "Waiting for '%s' to appear...\n", waitfor_process_name);
 

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.h (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/DNB.h Mon Jul 23 18:40:37 2012
@@ -48,7 +48,7 @@
 
 nub_process_t   DNBProcessAttach        (nub_process_t pid, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT;
 nub_process_t   DNBProcessAttachByName  (const char *name, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT;
-nub_process_t   DNBProcessAttachWait    (const char *wait_name, nub_launch_flavor_t launch_flavor, struct timespec *timeout, useconds_t interval, char *err_str, size_t err_len, DNBShouldCancelCallback should_cancel = NULL, void *callback_data = NULL) DNB_EXPORT;
+nub_process_t   DNBProcessAttachWait    (const char *wait_name, nub_launch_flavor_t launch_flavor, bool ignore_existing, struct timespec *timeout, useconds_t interval, char *err_str, size_t err_len, DNBShouldCancelCallback should_cancel = NULL, void *callback_data = NULL) DNB_EXPORT;
 // Resume a process with exact instructions on what to do with each thread:
 // - If no thread actions are supplied (actions is NULL or num_actions is zero),
 //   then all threads are continued.

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.cpp Mon Jul 23 18:40:37 2012
@@ -141,6 +141,7 @@
     t.push_back (Packet (thread_alive_p,                &RNBRemote::HandlePacket_T,             NULL, "T", "Is thread alive"));
     t.push_back (Packet (vattach,                       &RNBRemote::HandlePacket_v,             NULL, "vAttach", "Attach to a new process"));
     t.push_back (Packet (vattachwait,                   &RNBRemote::HandlePacket_v,             NULL, "vAttachWait", "Wait for a process to start up then attach to it"));
+    t.push_back (Packet (vattachorwait,                 &RNBRemote::HandlePacket_v,             NULL, "vAttachOrWait", "Attach to the process or if it doesn't exist, wait for the process to start up then attach to it"));
     t.push_back (Packet (vattachname,                   &RNBRemote::HandlePacket_v,             NULL, "vAttachName", "Attach to an existing process by name"));
     t.push_back (Packet (vcont_list_actions,            &RNBRemote::HandlePacket_v,             NULL, "vCont;", "Verbose resume with thread actions"));
     t.push_back (Packet (vcont_list_actions,            &RNBRemote::HandlePacket_v,             NULL, "vCont?", "List valid continue-with-thread-actions actions"));
@@ -169,6 +170,7 @@
     t.push_back (Packet (query_register_info,           &RNBRemote::HandlePacket_qRegisterInfo, NULL, "qRegisterInfo", "Dynamically discover remote register context information."));
     t.push_back (Packet (query_shlib_notify_info_addr,  &RNBRemote::HandlePacket_qShlibInfoAddr,NULL, "qShlibInfoAddr", "Returns the address that contains info needed for getting shared library notifications"));
     t.push_back (Packet (query_step_packet_supported,   &RNBRemote::HandlePacket_qStepPacketSupported,NULL, "qStepPacketSupported", "Replys with OK if the 's' packet is supported."));
+    t.push_back (Packet (query_vattachorwait_supported, &RNBRemote::HandlePacket_qVAttachOrWaitSupported,NULL, "qVAttachOrWaitSupported", "Replys with OK if the 'vAttachOrWait' packet is supported."));
     t.push_back (Packet (query_host_info,               &RNBRemote::HandlePacket_qHostInfo,     NULL, "qHostInfo", "Replies with multiple 'key:value;' tuples appended to each other."));
 //  t.push_back (Packet (query_symbol_lookup,           &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "qSymbol", "Notify that host debugger is ready to do symbol lookups"));
     t.push_back (Packet (start_noack_mode,              &RNBRemote::HandlePacket_QStartNoAckMode        , NULL, "QStartNoAckMode", "Request that " DEBUGSERVER_PROGRAM_NAME " stop acking remote protocol packets"));
@@ -1302,6 +1304,13 @@
 }
 
 rnb_err_t
+RNBRemote::HandlePacket_qVAttachOrWaitSupported (const char *p)
+{
+    // We support attachOrWait meaning attach if the process exists, otherwise wait to attach.
+    return SendPacket("OK");
+}
+
+rnb_err_t
 RNBRemote::HandlePacket_qThreadStopInfo (const char *p)
 {
     p += strlen ("qThreadStopInfo");
@@ -2678,6 +2687,31 @@
     return SendPacket ("E54");
 }
 
+static bool
+GetProcessNameFrom_vAttach (const char *&p, std::string &attach_name)
+{
+    bool return_val = true;
+    while (*p != '\0')
+    {
+        char smallbuf[3];
+        smallbuf[0] = *p;
+        smallbuf[1] = *(p + 1);
+        smallbuf[2] = '\0';
+
+        errno = 0;
+        int ch = strtoul (smallbuf, NULL, 16);
+        if (errno != 0 && ch == 0)
+        {
+            return_val = false;
+            break;
+        }
+
+        attach_name.push_back(ch);
+        p += 2;
+    }
+    return return_val;
+}
+
 /*
  vAttach;pid
 
@@ -2781,51 +2815,37 @@
     {
         nub_process_t attach_pid = INVALID_NUB_PROCESS;
         char err_str[1024]={'\0'};
+        
         if (strstr (p, "vAttachWait;") == p)
         {
             p += strlen("vAttachWait;");
             std::string attach_name;
-            while (*p != '\0')
+            if (!GetProcessNameFrom_vAttach(p, attach_name))
             {
-                char smallbuf[3];
-                smallbuf[0] = *p;
-                smallbuf[1] = *(p + 1);
-                smallbuf[2] = '\0';
-
-                errno = 0;
-                int ch = strtoul (smallbuf, NULL, 16);
-                if (errno != 0 && ch == 0)
-                {
-                    return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'vAttachWait' pkt");
-                }
-
-                attach_name.push_back(ch);
-                p += 2;
+                return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'vAttachWait' pkt");
             }
+            const bool ignore_existing = true;
+            attach_pid = DNBProcessAttachWait(attach_name.c_str (), m_ctx.LaunchFlavor(), ignore_existing, NULL, 1000, err_str, sizeof(err_str), RNBRemoteShouldCancelCallback);
 
-            attach_pid = DNBProcessAttachWait(attach_name.c_str (), m_ctx.LaunchFlavor(), NULL, 1000, err_str, sizeof(err_str), RNBRemoteShouldCancelCallback);
-
+        }
+        else if (strstr (p, "vAttachOrWait;") == p)
+        {
+            p += strlen("vAttachOrWait;");
+            std::string attach_name;
+            if (!GetProcessNameFrom_vAttach(p, attach_name))
+            {
+                return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'vAttachOrWait' pkt");
+            }
+            const bool ignore_existing = false;
+            attach_pid = DNBProcessAttachWait(attach_name.c_str (), m_ctx.LaunchFlavor(), ignore_existing, NULL, 1000, err_str, sizeof(err_str), RNBRemoteShouldCancelCallback);
         }
         else if (strstr (p, "vAttachName;") == p)
         {
             p += strlen("vAttachName;");
             std::string attach_name;
-            while (*p != '\0')
+            if (!GetProcessNameFrom_vAttach(p, attach_name))
             {
-                char smallbuf[3];
-                smallbuf[0] = *p;
-                smallbuf[1] = *(p + 1);
-                smallbuf[2] = '\0';
-
-                errno = 0;
-                int ch = strtoul (smallbuf, NULL, 16);
-                if (errno != 0 && ch == 0)
-                {
-                    return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'vAttachWait' pkt");
-                }
-
-                attach_name.push_back(ch);
-                p += 2;
+                return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'vAttachName' pkt");
             }
 
             attach_pid = DNBProcessAttachByName (attach_name.c_str(), NULL, err_str, sizeof(err_str));
@@ -2845,7 +2865,9 @@
             }
         }
         else
+        {
             return HandlePacket_UNIMPLEMENTED(p);
+        }
 
 
         if (attach_pid != INVALID_NUB_PROCESS)

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.h?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.h (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/RNBRemote.h Mon Jul 23 18:40:37 2012
@@ -63,6 +63,7 @@
         thread_alive_p,                 // 'T'
         vattach,                        // 'vAttach;pid'
         vattachwait,                    // 'vAttachWait:XX...' where XX is one or more hex encoded process name ASCII bytes
+        vattachorwait,                  // 'vAttachOrWait:XX...' where XX is one or more hex encoded process name ASCII bytes
         vattachname,                    // 'vAttachName:XX...' where XX is one or more hex encoded process name ASCII bytes
         vcont,                          // 'vCont'
         vcont_list_actions,             // 'vCont?'
@@ -91,6 +92,7 @@
         query_register_info,            // 'qRegisterInfo'
         query_shlib_notify_info_addr,   // 'qShlibInfoAddr'
         query_step_packet_supported,    // 'qStepPacketSupported'
+        query_vattachorwait_supported,  // 'qVAttachOrWaitSupported'
         query_host_info,                // 'qHostInfo'
         pass_signals_to_inferior,       // 'QPassSignals'
         start_noack_mode,               // 'QStartNoAckMode'
@@ -164,6 +166,7 @@
     rnb_err_t HandlePacket_qRegisterInfo (const char *p);
     rnb_err_t HandlePacket_qShlibInfoAddr (const char *p);
     rnb_err_t HandlePacket_qStepPacketSupported (const char *p);
+    rnb_err_t HandlePacket_qVAttachOrWaitSupported (const char *p);
     rnb_err_t HandlePacket_qThreadInfo (const char *p);
     rnb_err_t HandlePacket_qThreadExtraInfo (const char *p);
     rnb_err_t HandlePacket_qThreadStopInfo (const char *p);

Modified: lldb/branches/apple/python-GIL/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/debugserver/source/debugserver.cpp?rev=160650&r1=160649&r2=160650&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/debugserver/source/debugserver.cpp Mon Jul 23 18:40:37 2012
@@ -105,7 +105,7 @@
                 err = remote->HandleReceivedPacket (&type);
 
                 // check if we tried to attach to a process
-                if (type == RNBRemote::vattach || type == RNBRemote::vattachwait)
+                if (type == RNBRemote::vattach || type == RNBRemote::vattachwait || type == RNBRemote::vattachorwait)
                 {
                     if (err == rnb_success)
                         return eRNBRunLoopModeInferiorExecuting;
@@ -1319,8 +1319,8 @@
                     }
 
                     ctx.SetLaunchFlavor(launch_flavor);
-
-                    nub_process_t pid = DNBProcessAttachWait (waitfor_pid_name.c_str(), launch_flavor, timeout_ptr, waitfor_interval, err_str, sizeof(err_str));
+                    bool ignore_existing = false;
+                    nub_process_t pid = DNBProcessAttachWait (waitfor_pid_name.c_str(), launch_flavor, ignore_existing, timeout_ptr, waitfor_interval, err_str, sizeof(err_str));
                     g_pid = pid;
 
                     if (pid == INVALID_NUB_PROCESS)





More information about the lldb-commits mailing list