[Lldb-commits] [lldb] r171816 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/Module.h include/lldb/Symbol/Symtab.h include/lldb/lldb-forward.h source/Breakpoint/BreakpointResolverName.cpp source/Core/Debugger.cpp source/Core/Module.cpp source/Symbol/Symtab.cpp test/functionalities/dead-strip/TestDeadStrip.py test/lang/objc/foundation/TestFoundationDisassembly.py test/lang/objc/foundation/TestObjCMethods.py test/lldbutil.py test/logging/TestLogging.py

Greg Clayton gclayton at apple.com
Mon Jan 7 16:01:36 PST 2013


Author: gclayton
Date: Mon Jan  7 18:01:36 2013
New Revision: 171816

URL: http://llvm.org/viewvc/llvm-project?rev=171816&view=rev
Log:
<rdar://problem/12953853>

Setting breakpoints using "breakpoint set --selector <SEL>" previously didn't when there was no dSYM file.

Also fixed issues in the test suite that arose after fixing the bug.

Also fixed the log channels to properly ref count the log streams using weak pointers to the streams. This fixes a test suite problem that would happen when you specified a full path to the compiler with the "--compiler" option.



Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Symbol/Symtab.cpp
    lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py
    lldb/trunk/test/lang/objc/foundation/TestFoundationDisassembly.py
    lldb/trunk/test/lang/objc/foundation/TestObjCMethods.py
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/logging/TestLogging.py

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Jan  7 18:01:36 2013
@@ -369,7 +369,7 @@
 
     InputReaderStack m_input_reader_stack;
     std::string m_input_reader_data;
-    typedef std::map<std::string, lldb::StreamSP> LogStreamMap;
+    typedef std::map<std::string, lldb::StreamWP> LogStreamMap;
     LogStreamMap m_log_streams;
     lldb::StreamSP m_log_callback_stream_sp;
     ConstString m_instance_name;

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Mon Jan  7 18:01:36 2013
@@ -173,8 +173,9 @@
     virtual void
     DumpSymbolContext (Stream *s);
 
+    
     //------------------------------------------------------------------
-    /// Find a symbol in the object files symbol table.
+    /// Find a symbol in the object file's symbol table.
     ///
     /// @param[in] name
     ///     The name of the symbol that we are looking for.
@@ -204,6 +205,28 @@
                                      SymbolContextList &sc_list);
 
     //------------------------------------------------------------------
+    /// Find a funciton symbols in the object file's symbol table.
+    ///
+    /// @param[in] name
+    ///     The name of the symbol that we are looking for.
+    ///
+    /// @param[in] name_type_mask
+    ///     A mask that has one or more bitwise OR'ed values from the
+    ///     lldb::FunctionNameType enumeration type that indicate what
+    ///     kind of names we are looking for.
+    ///
+    /// @param[out] sc_list
+    ///     A list to append any matching symbol contexts to.
+    ///
+    /// @return
+    ///     The number of symbol contexts that were added to \a sc_list
+    //------------------------------------------------------------------
+    size_t
+    FindFunctionSymbols (const ConstString &name,
+                         uint32_t name_type_mask,
+                         SymbolContextList& sc_list);
+
+    //------------------------------------------------------------------
     /// Find compile units by partial or full path.
     ///
     /// Finds all compile units that match \a path in all of the modules

Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Mon Jan  7 18:01:36 2013
@@ -56,7 +56,6 @@
             Symbol *    SymbolAtIndex (uint32_t idx);
     const   Symbol *    SymbolAtIndex (uint32_t idx) const;
             Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx);
-//    const   Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx) const;
             uint32_t    AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
             uint32_t    AppendSymbolIndexesWithTypeAndFlagsValue (lldb::SymbolType symbol_type, uint32_t flags_value, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
             uint32_t    AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
@@ -71,10 +70,9 @@
             size_t      FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes);
             Symbol *    FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility);
             Symbol *    FindSymbolWithFileAddress (lldb::addr_t file_addr);
-//            Symbol *    FindSymbolContainingAddress (const Address& value, const uint32_t* indexes, uint32_t num_indexes);
-//            Symbol *    FindSymbolContainingAddress (const Address& value);
             Symbol *    FindSymbolContainingFileAddress (lldb::addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes);
             Symbol *    FindSymbolContainingFileAddress (lldb::addr_t file_addr);
+            size_t      FindFunctionSymbols (const ConstString &name, uint32_t name_type_mask, SymbolContextList& sc_list);
             size_t      CalculateSymbolSize (Symbol *symbol);
 
             void        SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const;
@@ -109,6 +107,7 @@
     collection          m_symbols;
     std::vector<uint32_t> m_addr_indexes;
     UniqueCStringMap<uint32_t> m_name_to_index;
+    UniqueCStringMap<uint32_t> m_selector_to_index;
     mutable Mutex       m_mutex; // Provide thread safety for this symbol table
     bool                m_addr_indexes_computed:1,
                         m_name_indexes_computed:1;
@@ -147,6 +146,9 @@
         return false;
     }
 
+    void
+    SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes,
+                                      SymbolContextList &sc_list);
 
     DISALLOW_COPY_AND_ASSIGN (Symtab);
 };

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Mon Jan  7 18:01:36 2013
@@ -350,6 +350,7 @@
     typedef STD_SHARED_PTR(lldb_private::StopInfo) StopInfoSP;
     typedef STD_SHARED_PTR(lldb_private::StoppointLocation) StoppointLocationSP;
     typedef STD_SHARED_PTR(lldb_private::Stream) StreamSP;
+    typedef STD_WEAK_PTR  (lldb_private::Stream) StreamWP;
     typedef STD_SHARED_PTR(lldb_private::StringSummaryFormat) StringTypeSummaryImplSP;
     typedef STD_SHARED_PTR(lldb_private::SymbolFile) SymbolFileSP;
     typedef STD_SHARED_PTR(lldb_private::SymbolFileType) SymbolFileTypeSP;

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Mon Jan  7 18:01:36 2013
@@ -182,8 +182,7 @@
                     
                     if (num_functions == 0 && !filter_by_cu)
                     {
-                        if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeAuto))
-                            context.module_sp->FindSymbolsWithNameAndType (m_func_names[j], eSymbolTypeCode, sym_list);
+                        context.module_sp->FindFunctionSymbols (m_func_names[j], m_func_name_type_mask, sym_list);
                     }
                 }
             }

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Jan  7 18:01:36 2013
@@ -2614,13 +2614,13 @@
     else
     {
         LogStreamMap::iterator pos = m_log_streams.find(log_file);
-        if (pos == m_log_streams.end())
+        if (pos != m_log_streams.end())
+            log_stream_sp = pos->second.lock();
+        if (!log_stream_sp)
         {
             log_stream_sp.reset (new StreamFile (log_file));
             m_log_streams[log_file] = log_stream_sp;
         }
-        else
-            log_stream_sp = pos->second;
     }
     assert (log_stream_sp.get());
     

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Mon Jan  7 18:01:36 2013
@@ -1064,6 +1064,25 @@
 }
 
 size_t
+Module::FindFunctionSymbols (const ConstString &name,
+                             uint32_t name_type_mask,
+                             SymbolContextList& sc_list)
+{
+    Timer scoped_timer(__PRETTY_FUNCTION__,
+                       "Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
+                       name.AsCString(),
+                       name_type_mask);
+    ObjectFile *objfile = GetObjectFile ();
+    if (objfile)
+    {
+        Symtab *symtab = objfile->GetSymtab();
+        if (symtab)
+            return symtab->FindFunctionSymbols (name, name_type_mask, sc_list);
+    }
+    return 0;
+}
+
+size_t
 Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
 {
     // No need to protect this call using m_mutex all other method calls are

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Mon Jan  7 18:01:36 2013
@@ -13,6 +13,7 @@
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 
@@ -309,20 +310,25 @@
                 
             // If the demangled name turns out to be an ObjC name, and
             // is a category name, add the version without categories to the index too.
+            ConstString objc_selector_name;
             ConstString objc_base_name;
             if (ObjCLanguageRuntime::ParseMethodName (entry.cstring,
                                                       NULL,
-                                                      NULL,
+                                                      &objc_selector_name,
                                                       &objc_base_name,
                                                       NULL))
             {
                 entry.cstring = objc_base_name.GetCString();
                 m_name_to_index.Append (entry);
+                entry.cstring = objc_selector_name.GetCString();
+                m_selector_to_index.Append (entry);
             }
                                                         
         }
         m_name_to_index.Sort();
         m_name_to_index.SizeToFit();
+        m_selector_to_index.Sort();
+        m_selector_to_index.SizeToFit();
     }
 }
 
@@ -979,3 +985,64 @@
     return FindSymbolContainingFileAddress (file_addr, &m_addr_indexes[0], m_addr_indexes.size());
 }
 
+void
+Symtab::SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list)
+{
+    // No need to protect this call using m_mutex all other method calls are
+    // already thread safe.
+    
+    size_t num_indices = symbol_indexes.size();
+    if (num_indices > 0)
+    {
+        SymbolContext sc;
+        sc.module_sp = m_objfile->GetModule();
+        for (size_t i = 0; i < num_indices; i++)
+        {
+            sc.symbol = SymbolAtIndex (symbol_indexes[i]);
+            if (sc.symbol)
+                sc_list.Append (sc);
+        }
+    }
+}
+
+
+size_t
+Symtab::FindFunctionSymbols (const ConstString &name,
+                             uint32_t name_type_mask,
+                             SymbolContextList& sc_list)
+{
+    size_t count = 0;
+    std::vector<uint32_t> symbol_indexes;
+    if (name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeAuto))
+    {
+        FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, symbol_indexes);
+    }
+    
+    if (name_type_mask & eFunctionNameTypeSelector)
+    {
+        if (!m_name_indexes_computed)
+            InitNameIndexes();
+
+        if (!m_selector_to_index.IsEmpty())
+        {
+            const UniqueCStringMap<uint32_t>::Entry *match;
+            for (match = m_selector_to_index.FindFirstValueForName(name.AsCString());
+                 match != NULL;
+                 match = m_selector_to_index.FindNextValueForName(match))
+            {
+                symbol_indexes.push_back(match->value);
+            }
+        }
+    }
+
+    if (!symbol_indexes.empty())
+    {
+        std::sort(symbol_indexes.begin(), symbol_indexes.end());
+        symbol_indexes.erase(std::unique(symbol_indexes.begin(), symbol_indexes.end()), symbol_indexes.end());
+        count = symbol_indexes.size();
+        SymbolIndicesToSymbolContextList (symbol_indexes, sc_list);
+    }
+
+    return count;
+}
+

Modified: lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py (original)
+++ lldb/trunk/test/functionalities/dead-strip/TestDeadStrip.py Mon Jan  7 18:01:36 2013
@@ -32,13 +32,13 @@
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Break by function name f1 (live code).
-        lldbutil.run_break_set_by_symbol (self, "f1", extra_options="-s a.out", num_expected_locations=1, module_name="a.out")
+        lldbutil.run_break_set_by_symbol (self, "f1", num_expected_locations=1, module_name="a.out")
 
         # Break by function name f2 (dead code).
-        lldbutil.run_break_set_by_symbol (self, "f2", extra_options="-s a.out", num_expected_locations=0)
+        lldbutil.run_break_set_by_symbol (self, "f2", num_expected_locations=0, module_name="a.out")
 
         # Break by function name f3 (live code).
-        lldbutil.run_break_set_by_symbol (self, "f3", extra_options="-s a.out", num_expected_locations=1, module_name="a.out")
+        lldbutil.run_break_set_by_symbol (self, "f3", num_expected_locations=1, module_name="a.out")
 
         self.runCmd("run", RUN_SUCCEEDED)
 

Modified: lldb/trunk/test/lang/objc/foundation/TestFoundationDisassembly.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/foundation/TestFoundationDisassembly.py?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestFoundationDisassembly.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestFoundationDisassembly.py Mon Jan  7 18:01:36 2013
@@ -81,7 +81,7 @@
         lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True)
 
         # Stop at the "description" selector.
-        lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1)
+        lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out')
 
         # Stop at -[NSAutoreleasePool release].
         break_results = lldbutil.run_break_set_command (self, "_regexp-break -[NSAutoreleasePool release]")

Modified: lldb/trunk/test/lang/objc/foundation/TestObjCMethods.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/foundation/TestObjCMethods.py?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/foundation/TestObjCMethods.py (original)
+++ lldb/trunk/test/lang/objc/foundation/TestObjCMethods.py Mon Jan  7 18:01:36 2013
@@ -69,7 +69,7 @@
         lldbutil.run_break_set_by_symbol (self, '-[MyString initWithNSString:]', num_expected_locations=1, sym_exact=True)
 
         # Stop at the "description" selector.
-        lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1)
+        lldbutil.run_break_set_by_selector (self, 'description', num_expected_locations=1, module_name='a.out')
 
         # Stop at -[NSAutoreleasePool release].
         break_results = lldbutil.run_break_set_command(self, "_regexp-break -[NSAutoreleasePool release]")

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Mon Jan  7 18:01:36 2013
@@ -275,6 +275,9 @@
     else:
         command = 'breakpoint set -f "%s" -l %d'%(file_name, line_number)
 
+    if module_name:
+        command += " --shlib '%s'" % (module_name)
+
     if extra_options:
         command += " " + extra_options
 
@@ -292,6 +295,10 @@
 
     If sym_exact is true, then the output symbol must match the input exactly, otherwise we do a substring match."""
     command = 'breakpoint set -n "%s"'%(symbol)
+
+    if module_name:
+        command += " --shlib '%s'" % (module_name)
+
     if extra_options:
         command += " " + extra_options
 
@@ -307,7 +314,11 @@
 def run_break_set_by_selector (test, selector, extra_options = None, num_expected_locations = -1, module_name=None):
     """Set a breakpoint by selector.  Common options are the same as run_break_set_by_file_and_line."""
 
-    command = 'breakpoint set -S "%s"'%(selector)
+    command = 'breakpoint set -S "%s"' % (selector)
+
+    if module_name:
+        command += ' --shlib "%s"' % (module_name)
+
     if extra_options:
         command += " " + extra_options
 

Modified: lldb/trunk/test/logging/TestLogging.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/logging/TestLogging.py?rev=171816&r1=171815&r2=171816&view=diff
==============================================================================
--- lldb/trunk/test/logging/TestLogging.py (original)
+++ lldb/trunk/test/logging/TestLogging.py Mon Jan  7 18:01:36 2013
@@ -28,13 +28,13 @@
                     patterns = [ "Current executable set to .*a.out" ])
 
         log_file = os.path.join (os.getcwd(), "lldb-commands-log-%s-%s-%s.txt" % (type,
-                                                                                  self.getCompiler(),
+                                                                                  os.path.basename(self.getCompiler()),
                                                                                   self.getArchitecture()))
 
         if (os.path.exists (log_file)):
             os.remove (log_file)
 
-        self.runCmd ("log enable lldb commands -f " + log_file)
+        self.runCmd ("log enable -f '%s' lldb commands" % (log_file))
         
         self.runCmd ("command alias bp breakpoint")
                      





More information about the lldb-commits mailing list