[Lldb-commits] [lldb] r124359 - in /lldb/trunk: include/lldb/Core/ include/lldb/Symbol/ lldb.xcodeproj/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Plugins/SymbolFile/DWARF/ source/Plugins/SymbolFile/Symtab/ source/Symbol/

Greg Clayton gclayton at apple.com
Wed Jan 26 22:44:37 PST 2011


Author: gclayton
Date: Thu Jan 27 00:44:37 2011
New Revision: 124359

URL: http://llvm.org/viewvc/llvm-project?rev=124359&view=rev
Log:
Changed the SymbolFile::FindFunction() function calls to only return 
lldb_private::Function objects. Previously the SymbolFileSymtab subclass
would return lldb_private::Symbol objects when it was asked to find functions.

The Module::FindFunctions (...) now take a boolean "bool include_symbols" so
that the module can track down functions and symbols, yet functions are found
by the SymbolFile plug-ins (through the SymbolVendor class), and symbols are
gotten through the ObjectFile plug-ins.

Fixed and issue where the DWARF parser might run into incomplete class member
function defintions which would make clang mad when we tried to make certain
member functions with invalid number of parameters (such as an operator=
operator that had no parameters). Now we just avoid and don't complete these
incomplete functions.


Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/include/lldb/Symbol/SymbolContext.h
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
    lldb/trunk/source/Commands/CommandCompletions.cpp
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Commands/CommandObjectSource.cpp
    lldb/trunk/source/Core/AddressResolverName.cpp
    lldb/trunk/source/Core/Disassembler.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Jan 27 00:44:37 2011
@@ -143,13 +143,18 @@
     ///     NULL otherwise.
     //------------------------------------------------------------------
     const Symbol *
-    FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
+    FindFirstSymbolWithNameAndType (const ConstString &name, 
+                                    lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
 
     size_t
-    FindSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, SymbolContextList &sc_list);
+    FindSymbolsWithNameAndType (const ConstString &name, 
+                                lldb::SymbolType symbol_type, 
+                                SymbolContextList &sc_list);
 
     size_t
-    FindSymbolsMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list);
+    FindSymbolsMatchingRegExAndType (const RegularExpression &regex, 
+                                     lldb::SymbolType symbol_type, 
+                                     SymbolContextList &sc_list);
 
     //------------------------------------------------------------------
     /// Find functions by name.
@@ -176,7 +181,11 @@
     ///     The number of matches added to \a sc_list.
     //------------------------------------------------------------------
     uint32_t
-    FindFunctions (const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list);
+    FindFunctions (const ConstString &name, 
+                   uint32_t name_type_mask, 
+                   bool symbols_ok, 
+                   bool append, 
+                   SymbolContextList& sc_list);
 
     //------------------------------------------------------------------
     /// Find functions by name.
@@ -197,7 +206,10 @@
     ///     The number of matches added to \a sc_list.
     //------------------------------------------------------------------
     uint32_t
-    FindFunctions (const RegularExpression& regex, bool append, SymbolContextList& sc_list);
+    FindFunctions (const RegularExpression& regex, 
+                   bool symbols_ok, 
+                   bool append, 
+                   SymbolContextList& sc_list);
 
     //------------------------------------------------------------------
     /// Find global and static variables by name.
@@ -223,7 +235,10 @@
     ///     The number of matches added to \a variable_list.
     //------------------------------------------------------------------
     uint32_t
-    FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variable_list);
+    FindGlobalVariables (const ConstString &name, 
+                         bool append, 
+                         uint32_t max_matches, 
+                         VariableList& variable_list);
 
     //------------------------------------------------------------------
     /// Find global and static variables by regular exression.
@@ -248,7 +263,10 @@
     ///     The number of matches added to \a variable_list.
     //------------------------------------------------------------------
     uint32_t
-    FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variable_list);
+    FindGlobalVariables (const RegularExpression& regex, 
+                         bool append, 
+                         uint32_t max_matches, 
+                         VariableList& variable_list);
 
     //------------------------------------------------------------------
     /// Find types by name.
@@ -284,43 +302,11 @@
     ///     The number of matches added to \a type_list.
     //------------------------------------------------------------------
     uint32_t
-    FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types);
-
-    //------------------------------------------------------------------
-    /// Find types by name.
-    ///
-    /// @param[in] sc
-    ///     A symbol context that scopes where to extract a type list
-    ///     from.
-    ///
-    /// @param[in] regex
-    ///     A regular expression to use when matching the name.
-    ///
-    /// @param[in] append
-    ///     If \b true, any matches will be appended to \a
-    ///     variable_list, else matches replace the contents of
-    ///     \a variable_list.
-    ///
-    /// @param[in] max_matches
-    ///     Allow the number of matches to be limited to \a
-    ///     max_matches. Specify UINT32_MAX to get all possible matches.
-    ///
-    /// @param[in] encoding
-    ///     Limit the search to specific types, or get all types if
-    ///     set to Type::invalid.
-    ///
-    /// @param[in] udt_name
-    ///     If the encoding is a user defined type, specify the name
-    ///     of the user defined type ("struct", "union", "class", etc).
-    ///
-    /// @param[out] type_list
-    ///     A type list gets populated with any matches.
-    ///
-    /// @return
-    ///     The number of matches added to \a type_list.
-    //------------------------------------------------------------------
-//  uint32_t
-//  FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& type_list);
+    FindTypes (const SymbolContext& sc, 
+               const ConstString &name, 
+               bool append, 
+               uint32_t max_matches, 
+               TypeList& types);
 
     //------------------------------------------------------------------
     /// Get const accessor for the module architecture.

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Thu Jan 27 00:44:37 2011
@@ -164,6 +164,7 @@
     size_t
     FindFunctions (const ConstString &name,
                    uint32_t name_type_mask,
+                   bool include_symbols,
                    bool append,
                    SymbolContextList &sc_list);
 

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Thu Jan 27 00:44:37 2011
@@ -206,6 +206,7 @@
     //------------------------------------------------------------------
     size_t
     FindFunctionsByName (const ConstString &name, 
+                         bool include_symbols, 
                          bool append, 
                          SymbolContextList &sc_list) const;
 
@@ -277,7 +278,10 @@
     ///     A symbol context to append to the list.
     //------------------------------------------------------------------
     void
-    Append(const SymbolContext& sc);
+    Append (const SymbolContext& sc);
+
+    bool
+    AppendIfUnique (const SymbolContext& sc);
 
     //------------------------------------------------------------------
     /// Clear the object's state.

Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Thu Jan 27 00:44:37 2011
@@ -24,8 +24,8 @@
 {
 public:
         typedef enum Debug {
-            eDebugNo,    // Not a debug symbol
-            eDebugYes,    // A debug symbol 
+            eDebugNo,   // Not a debug symbol
+            eDebugYes,  // A debug symbol 
             eDebugAny
         } Debug;
 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jan 27 00:44:37 2011
@@ -2882,6 +2882,7 @@
 					__STDC_LIMIT_MACROS,
 					LLDB_CONFIGURATION_DEBUG,
 				);
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
 				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -2912,6 +2913,7 @@
 					__STDC_LIMIT_MACROS,
 					LLDB_CONFIGURATION_RELEASE,
 				);
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
 				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3100,6 +3102,7 @@
 					__STDC_LIMIT_MACROS,
 					LLDB_CONFIGURATION_BUILD_AND_INTEGRATION,
 				);
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
 				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3129,6 +3132,7 @@
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
@@ -3222,6 +3226,7 @@
 				GCC_MODEL_TUNING = G5;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
@@ -3260,6 +3265,7 @@
 				GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Jan 27 00:44:37 2011
@@ -155,7 +155,28 @@
         if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
             launch_flags |= eLaunchFlagDisableASLR;
 
-        if ((launch_flags & eLaunchFlagLaunchInTTY) || getenv("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY"))
+        static const char *g_launch_tty = NULL;
+        static bool g_got_launch_tty = false;
+        if (!g_got_launch_tty)
+        {
+            // Get the LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY only once
+            g_got_launch_tty = true;
+            g_launch_tty = ::getenv ("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY");
+            if (g_launch_tty)
+            {
+                // LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY is a path to a terminal to reuse
+                // if the first character is '/', else it is a boolean value.
+                if (g_launch_tty[0] != '/')
+                {
+                    if (Args::StringToBoolean(g_launch_tty, false, NULL))
+                        g_launch_tty = "";
+                    else
+                        g_launch_tty = NULL;
+                }
+            }
+        }
+        
+        if ((launch_flags & eLaunchFlagLaunchInTTY) || g_launch_tty)
         {
             ArchSpec arch (m_opaque_sp->GetArchitecture ());
             
@@ -182,14 +203,18 @@
                     exec_path_plus_argv.push_back(NULL);
                         
 
-                    lldb::pid_t pid = Host::LaunchInNewTerminal (NULL,
-                                                             &exec_path_plus_argv[0],
-                                                             envp,
-                                                             working_directory,
-                                                             &arch,
-                                                             true,
-                                                             launch_flags & eLaunchFlagDisableASLR);
-                
+                    const char *tty_name = NULL;
+                    if (g_launch_tty && g_launch_tty[0] == '/')
+                        tty_name = g_launch_tty;
+                    
+                    lldb::pid_t pid = Host::LaunchInNewTerminal (tty_name,
+                                                                 &exec_path_plus_argv[0],
+                                                                 envp,
+                                                                 working_directory,
+                                                                 &arch,
+                                                                 true,
+                                                                 launch_flags & eLaunchFlagDisableASLR);
+
                     if (pid != LLDB_INVALID_PROCESS_ID)
                     {
                         sb_process = AttachToProcessWithID(pid, error);

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Thu Jan 27 00:44:37 2011
@@ -155,6 +155,8 @@
         return Searcher::eCallbackReturnStop;
     }
     
+    const bool include_symbols = false;
+    const bool append = false;
     switch (m_match_type)
     {
         case Breakpoint::Exact:
@@ -162,14 +164,21 @@
             {
                 if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull))
                     context.module_sp->FindSymbolsWithNameAndType (m_func_name, eSymbolTypeCode, sym_list);
-                context.module_sp->FindFunctions (m_func_name, m_func_name_type_mask, false, func_list);
+                context.module_sp->FindFunctions (m_func_name, 
+                                                  m_func_name_type_mask, 
+                                                  include_symbols, 
+                                                  append, 
+                                                  func_list);
             }
             break;
         case Breakpoint::Regexp:
             if (context.module_sp)
             {
                 context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, eSymbolTypeCode, sym_list);
-                context.module_sp->FindFunctions (m_regex, true, func_list);
+                context.module_sp->FindFunctions (m_regex, 
+                                                  include_symbols, 
+                                                  append, 
+                                                  func_list);
             }
             break;
         case Breakpoint::Glob:

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Thu Jan 27 00:44:37 2011
@@ -599,35 +599,24 @@
     bool complete
 )
 {
-    SymbolContextList func_list;
-    SymbolContextList sym_list;
-
-    if (context.module_sp != NULL)
+    if (context.module_sp)
     {
-        if (context.module_sp)
-        {
-            context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, lldb::eSymbolTypeCode, sym_list);
-            context.module_sp->FindFunctions (m_regex, true, func_list);
-        }
+        SymbolContextList sc_list;        
+        const bool include_symbols = true;
+        const bool append = true;
+        context.module_sp->FindFunctions (m_regex, include_symbols, append, sc_list);
 
         SymbolContext sc;
         // Now add the functions & symbols to the list - only add if unique:
-        for (uint32_t i = 0; i < func_list.GetSize(); i++)
+        for (uint32_t i = 0; i < sc_list.GetSize(); i++)
         {
-            if (func_list.GetContextAtIndex(i, sc))
+            if (sc_list.GetContextAtIndex(i, sc))
             {
                 if (sc.function)
                 {
                     m_match_set.insert (sc.function->GetMangled().GetDemangledName());
                 }
-            }
-        }
-
-        for (uint32_t i = 0; i < sym_list.GetSize(); i++)
-        {
-            if (sym_list.GetContextAtIndex(i, sc))
-            {
-                if (sc.symbol && sc.symbol->GetAddressRangePtr())
+                else if (sc.symbol && sc.symbol->GetAddressRangePtr())
                 {
                     m_match_set.insert (sc.symbol->GetMangled().GetDemangledName());
                 }

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Jan 27 00:44:37 2011
@@ -360,33 +360,36 @@
     if (module && name && name[0])
     {
         SymbolContextList sc_list;
-
-        SymbolVendor *symbol_vendor = module->GetSymbolVendor();
-        if (symbol_vendor)
+        const bool include_symbols = false;
+        const bool append = true;
+        uint32_t num_matches = 0;
+        if (name_is_regex)
+        {
+            RegularExpression function_name_regex (name);
+            num_matches = module->FindFunctions (function_name_regex, 
+                                                 include_symbols,
+                                                 append, 
+                                                 sc_list);
+        }
+        else
         {
-            uint32_t num_matches = 0;
-            if (name_is_regex)
-            {
-                RegularExpression function_name_regex (name);
-                num_matches = symbol_vendor->FindFunctions(function_name_regex, true, sc_list);
-
-            }
-            else
-            {
-                ConstString function_name(name);
-                num_matches = symbol_vendor->FindFunctions(function_name, eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, true, sc_list);
-            }
+            ConstString function_name (name);
+            num_matches = module->FindFunctions (function_name, 
+                                                 eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, 
+                                                 include_symbols,
+                                                 append, 
+                                                 sc_list);
+        }
 
-            if (num_matches)
-            {
-                strm.Indent ();
-                strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
-                DumpFullpath (strm, &module->GetFileSpec(), 0);
-                strm.PutCString(":\n");
-                DumpSymbolContextList (interpreter, strm, sc_list, true);
-            }
-            return num_matches;
+        if (num_matches)
+        {
+            strm.Indent ();
+            strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
+            DumpFullpath (strm, &module->GetFileSpec(), 0);
+            strm.PutCString(":\n");
+            DumpSymbolContextList (interpreter, strm, sc_list, true);
         }
+        return num_matches;
     }
     return 0;
 }

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Thu Jan 27 00:44:37 2011
@@ -289,6 +289,7 @@
             
             SymbolContextList sc_list;
             ConstString name(m_options.symbol_name.c_str());
+            bool include_symbols = false;
             bool append = true;
             size_t num_matches = 0;
             
@@ -302,13 +303,13 @@
                     {
                         matching_modules.Clear();
                         target->GetImages().FindModules (&module_spec, NULL, NULL, NULL, matching_modules);
-                        num_matches += matching_modules.FindFunctions (name, eFunctionNameTypeBase, append, sc_list);
+                        num_matches += matching_modules.FindFunctions (name, eFunctionNameTypeBase, include_symbols, append, sc_list);
                     }
                 }
             }
             else
             {
-                num_matches = target->GetImages().FindFunctions (name, eFunctionNameTypeBase, append, sc_list);
+                num_matches = target->GetImages().FindFunctions (name, eFunctionNameTypeBase, include_symbols, append, sc_list);
             }
             
             SymbolContext sc;

Modified: lldb/trunk/source/Core/AddressResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressResolverName.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Core/AddressResolverName.cpp (original)
+++ lldb/trunk/source/Core/AddressResolverName.cpp Thu Jan 27 00:44:37 2011
@@ -102,9 +102,11 @@
         return Searcher::eCallbackReturnStop;
     }
 
+    const bool include_symbols = false;
+    const bool append = false;
     switch (m_match_type)
     {
-      case AddressResolver::Exact:
+    case AddressResolver::Exact:
         if (context.module_sp)
         {
             context.module_sp->FindSymbolsWithNameAndType (m_func_name, 
@@ -112,22 +114,26 @@
                                                            sym_list);
             context.module_sp->FindFunctions (m_func_name, 
                                               eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector,
-                                              false, 
+                                              include_symbols,
+                                              append, 
                                               func_list);
         }
         break;
-      case AddressResolver::Regexp:
+
+    case AddressResolver::Regexp:
         if (context.module_sp)
         {
             context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, 
                                                                 eSymbolTypeCode, 
                                                                 sym_list);
             context.module_sp->FindFunctions (m_regex, 
-                                              true, 
+                                              include_symbols,
+                                              append, 
                                               func_list);
         }
         break;
-      case AddressResolver::Glob:
+
+    case AddressResolver::Glob:
         if (log)
             log->Warning ("glob is not supported yet.");
         break;

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Thu Jan 27 00:44:37 2011
@@ -99,39 +99,44 @@
     Stream &strm
 )
 {
-    if (exe_ctx.target == NULL && name)
-        return false;
-
     SymbolContextList sc_list;
-
-    if (module)
-    {
-        if (!module->FindFunctions (name, 
-                                    eFunctionNameTypeBase | 
-                                    eFunctionNameTypeFull | 
-                                    eFunctionNameTypeMethod | 
-                                    eFunctionNameTypeSelector, 
-                                    true,
-                                    sc_list))
-            return false;
-    }
-    else 
+    if (name)
     {
-        if (exe_ctx.target->GetImages().FindFunctions (name, 
+        const bool include_symbols = true;
+        if (module)
+        {
+            module->FindFunctions (name, 
+                                   eFunctionNameTypeBase | 
+                                   eFunctionNameTypeFull | 
+                                   eFunctionNameTypeMethod | 
+                                   eFunctionNameTypeSelector, 
+                                   include_symbols,
+                                   true,
+                                   sc_list);
+        }
+        else if (exe_ctx.target)
+        {
+            exe_ctx.target->GetImages().FindFunctions (name, 
                                                        eFunctionNameTypeBase | 
                                                        eFunctionNameTypeFull | 
                                                        eFunctionNameTypeMethod | 
                                                        eFunctionNameTypeSelector,
+                                                       include_symbols, 
                                                        false,
-                                                       sc_list))
-        {
-            return Disassemble (debugger, arch, exe_ctx, sc_list, num_mixed_context_lines, show_bytes, strm);
-        }
-        else if (exe_ctx.target->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list))
-        {
-            return Disassemble (debugger, arch, exe_ctx, sc_list, num_mixed_context_lines, show_bytes, strm);
+                                                       sc_list);
         }
     }
+    
+    if (sc_list.GetSize ())
+    {
+        return Disassemble (debugger, 
+                            arch, 
+                            exe_ctx, 
+                            sc_list, 
+                            num_mixed_context_lines, 
+                            show_bytes, 
+                            strm);
+    }
     return false;
 }
 

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Jan 27 00:44:37 2011
@@ -321,21 +321,88 @@
 }
 
 uint32_t
-Module::FindFunctions(const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list)
+Module::FindFunctions (const ConstString &name, 
+                       uint32_t name_type_mask, 
+                       bool include_symbols, 
+                       bool append, 
+                       SymbolContextList& sc_list)
 {
+    if (!append)
+        sc_list.Clear();
+
+    const uint32_t start_size = sc_list.GetSize();
+
+    // Find all the functions (not symbols, but debug information functions...
     SymbolVendor *symbols = GetSymbolVendor ();
     if (symbols)
-        return symbols->FindFunctions(name, name_type_mask, append, sc_list);
-    return 0;
+        symbols->FindFunctions(name, name_type_mask, append, sc_list);
+
+    // Now check our symbol table for symbols that are code symbols if requested
+    if (include_symbols)
+    {
+        ObjectFile *objfile = GetObjectFile();
+        if (objfile)
+        {
+            Symtab *symtab = objfile->GetSymtab();
+            if (symtab)
+            {
+                std::vector<uint32_t> symbol_indexes;
+                symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
+                const uint32_t num_matches = symbol_indexes.size();
+                if (num_matches)
+                {
+                    SymbolContext sc(this);
+                    for (uint32_t i=0; i<num_matches; i++)
+                    {
+                        sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
+                        sc_list.AppendIfUnique (sc);
+                    }
+                }
+            }
+        }
+    }
+    return sc_list.GetSize() - start_size;
 }
 
 uint32_t
-Module::FindFunctions(const RegularExpression& regex, bool append, SymbolContextList& sc_list)
-{
+Module::FindFunctions (const RegularExpression& regex, 
+                       bool include_symbols, 
+                       bool append, 
+                       SymbolContextList& sc_list)
+{
+    if (!append)
+        sc_list.Clear();
+    
+    const uint32_t start_size = sc_list.GetSize();
+    
     SymbolVendor *symbols = GetSymbolVendor ();
     if (symbols)
         return symbols->FindFunctions(regex, append, sc_list);
-    return 0;
+    // Now check our symbol table for symbols that are code symbols if requested
+    if (include_symbols)
+    {
+        ObjectFile *objfile = GetObjectFile();
+        if (objfile)
+        {
+            Symtab *symtab = objfile->GetSymtab();
+            if (symtab)
+            {
+                std::vector<uint32_t> symbol_indexes;
+                symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
+                const uint32_t num_matches = symbol_indexes.size();
+                if (num_matches)
+                {
+                    SymbolContext sc(this);
+                    for (uint32_t i=0; i<num_matches; i++)
+                    {
+                        sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
+                        sc_list.AppendIfUnique (sc);
+                    }
+                }
+            }
+        }
+    }
+    return sc_list.GetSize() - start_size;
 }
 
 uint32_t

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Thu Jan 27 00:44:37 2011
@@ -141,7 +141,11 @@
 }
 
 size_t
-ModuleList::FindFunctions (const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList &sc_list)
+ModuleList::FindFunctions (const ConstString &name, 
+                           uint32_t name_type_mask, 
+                           bool include_symbols,
+                           bool append, 
+                           SymbolContextList &sc_list)
 {
     if (!append)
         sc_list.Clear();
@@ -150,14 +154,17 @@
     collection::const_iterator pos, end = m_modules.end();
     for (pos = m_modules.begin(); pos != end; ++pos)
     {
-        (*pos)->FindFunctions (name, name_type_mask, true, sc_list);
+        (*pos)->FindFunctions (name, name_type_mask, include_symbols, true, sc_list);
     }
     
     return sc_list.GetSize();
 }
 
 uint32_t
-ModuleList::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variable_list)
+ModuleList::FindGlobalVariables (const ConstString &name, 
+                                 bool append, 
+                                 uint32_t max_matches, 
+                                 VariableList& variable_list)
 {
     size_t initial_size = variable_list.GetSize();
     Mutex::Locker locker(m_modules_mutex);
@@ -171,7 +178,10 @@
 
 
 uint32_t
-ModuleList::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variable_list)
+ModuleList::FindGlobalVariables (const RegularExpression& regex, 
+                                 bool append, 
+                                 uint32_t max_matches, 
+                                 VariableList& variable_list)
 {
     size_t initial_size = variable_list.GetSize();
     Mutex::Locker locker(m_modules_mutex);
@@ -185,7 +195,9 @@
 
 
 size_t
-ModuleList::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
+ModuleList::FindSymbolsWithNameAndType (const ConstString &name, 
+                                        SymbolType symbol_type, 
+                                        SymbolContextList &sc_list)
 {
     Mutex::Locker locker(m_modules_mutex);
     sc_list.Clear();

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Jan 27 00:44:37 2011
@@ -429,8 +429,9 @@
         return false;
 
     SymbolContextList sc_list;
-    
-    m_parser_vars->m_sym_ctx.FindFunctionsByName(name, false, sc_list);
+    const bool include_symbols = true;
+    const bool append = false;
+    m_parser_vars->m_sym_ctx.FindFunctionsByName(name, include_symbols, append, sc_list);
     
     if (!sc_list.GetSize())
         return false;
@@ -1557,7 +1558,12 @@
         }
         else
         {
-            m_parser_vars->m_sym_ctx.FindFunctionsByName (name, false, sc_list);
+            const bool include_symbols = true;
+            const bool append = false;
+            m_parser_vars->m_sym_ctx.FindFunctionsByName (name, 
+                                                          include_symbols, 
+                                                          append, 
+                                                          sc_list);
         
             bool found_specific = false;
             Symbol *generic_symbol = NULL;
@@ -1590,9 +1596,9 @@
             if (!found_specific)
             {
                 if (generic_symbol)
-                    AddOneFunction(context, NULL, generic_symbol);
+                    AddOneFunction (context, NULL, generic_symbol);
                 else if (non_extern_symbol)
-                    AddOneFunction(context, NULL, non_extern_symbol);
+                    AddOneFunction (context, NULL, non_extern_symbol);
             }
 
             ClangNamespaceDecl namespace_decl (m_parser_vars->m_sym_ctx.FindNamespace(name));

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jan 27 00:44:37 2011
@@ -3566,17 +3566,27 @@
                                         // in the DWARF for C++ methods... Default to public for now...
                                         if (accessibility == eAccessNone)
                                             accessibility = eAccessPublic;
-
-                                        clang::CXXMethodDecl *cxx_method_decl;
-                                        cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, 
-                                                                                        type_name_cstr,
-                                                                                        clang_type,
-                                                                                        accessibility,
-                                                                                        is_virtual,
-                                                                                        is_static,
-                                                                                        is_inline,
-                                                                                        is_explicit);
-                                        type_handled = cxx_method_decl != NULL;
+                                        
+                                        if (!is_static && !die->HasChildren())
+                                        {
+                                            // We have a C++ member function with no children (this pointer!)
+                                            // and clang will get mad if we try and make a function that isn't
+                                            // well formed in the DWARF, so we will just skip it...
+                                            type_handled = true;
+                                        }
+                                        else
+                                        {
+                                            clang::CXXMethodDecl *cxx_method_decl;
+                                            cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, 
+                                                                                            type_name_cstr,
+                                                                                            clang_type,
+                                                                                            accessibility,
+                                                                                            is_virtual,
+                                                                                            is_static,
+                                                                                            is_inline,
+                                                                                            is_explicit);
+                                            type_handled = cxx_method_decl != NULL;
+                                        }
                                     }
                                 }
                             }

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Jan 27 00:44:37 2011
@@ -323,25 +323,11 @@
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "SymbolFileSymtab::FindFunctions (name = '%s')",
                         name.GetCString());
-
-    Symtab *symtab = m_obj_file->GetSymtab();
-    if (symtab)
-    {
-        const uint32_t start_size = sc_list.GetSize();
-        std::vector<uint32_t> symbol_indexes;
-        symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
-        const uint32_t num_matches = symbol_indexes.size();
-        if (num_matches)
-        {
-            SymbolContext sc(m_obj_file->GetModule());
-            for (uint32_t i=0; i<num_matches; i++)
-            {
-                sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
-                sc_list.Append(sc);
-            }
-        }
-        return sc_list.GetSize() - start_size;
-    }
+    // If we ever support finding STABS or COFF debug info symbols, 
+    // we will need to add support here. We are not trying to find symbols
+    // here, just "lldb_private::Function" objects that come from complete 
+    // debug information. Any symbol queries should go through the symbol
+    // table itself in the module's object file.
     return 0;
 }
 
@@ -351,7 +337,11 @@
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "SymbolFileSymtab::FindFunctions (regex = '%s')",
                         regex.GetText());
-
+    // If we ever support finding STABS or COFF debug info symbols, 
+    // we will need to add support here. We are not trying to find symbols
+    // here, just "lldb_private::Function" objects that come from complete 
+    // debug information. Any symbol queries should go through the symbol
+    // table itself in the module's object file.
     return 0;
 }
 

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=124359&r1=124358&r2=124359&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Jan 27 00:44:37 2011
@@ -345,23 +345,23 @@
 bool
 lldb_private::operator== (const SymbolContext& lhs, const SymbolContext& rhs)
 {
-    return lhs.target_sp.get() == rhs.target_sp.get() &&
-           lhs.module_sp.get() == rhs.module_sp.get() &&
-           lhs.comp_unit    == rhs.comp_unit &&
-           lhs.function     == rhs.function &&
-           LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0 &&
-           lhs.symbol       == rhs.symbol;
+    return  lhs.function == rhs.function
+            && lhs.symbol == rhs.symbol 
+            && lhs.module_sp.get() == rhs.module_sp.get()
+            && lhs.comp_unit == rhs.comp_unit
+            && lhs.target_sp.get() == rhs.target_sp.get() 
+            && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0;
 }
 
 bool
 lldb_private::operator!= (const SymbolContext& lhs, const SymbolContext& rhs)
 {
-    return lhs.target_sp.get() != rhs.target_sp.get() ||
-           lhs.module_sp.get() != rhs.module_sp.get() ||
-           lhs.comp_unit    != rhs.comp_unit ||
-           lhs.function     != rhs.function ||
-           LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0 ||
-           lhs.symbol       != rhs.symbol;
+    return  lhs.function != rhs.function
+            && lhs.symbol != rhs.symbol 
+            && lhs.module_sp.get() != rhs.module_sp.get()
+            && lhs.comp_unit != rhs.comp_unit
+            && lhs.target_sp.get() != rhs.target_sp.get() 
+            && LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0;
 }
 
 bool
@@ -410,7 +410,10 @@
 }
 
 size_t
-SymbolContext::FindFunctionsByName (const ConstString &name, bool append, SymbolContextList &sc_list) const
+SymbolContext::FindFunctionsByName (const ConstString &name, 
+                                    bool include_symbols, 
+                                    bool append, 
+                                    SymbolContextList &sc_list) const
 {    
     if (!append)
         sc_list.Clear();
@@ -422,10 +425,10 @@
     }
 
     if (module_sp != NULL)
-        module_sp->FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, true, sc_list);
+        module_sp->FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, include_symbols, true, sc_list);
 
     if (target_sp)
-        target_sp->GetImages().FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, true, sc_list);
+        target_sp->GetImages().FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, include_symbols, true, sc_list);
 
     return sc_list.GetSize();
 }
@@ -475,6 +478,19 @@
     m_symbol_contexts.push_back(sc);
 }
 
+bool
+SymbolContextList::AppendIfUnique (const SymbolContext& sc)
+{
+    collection::const_iterator pos, end = m_symbol_contexts.end();
+    for (pos = m_symbol_contexts.begin(); pos != end; ++pos)
+    {
+        if (*pos == sc)
+            return false;
+    }
+    m_symbol_contexts.push_back(sc);
+    return true;
+}
+
 void
 SymbolContextList::Clear()
 {





More information about the lldb-commits mailing list