diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-01-08 00:01:36 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-01-08 00:01:36 +0000 |
| commit | c1b2ccfd34aeded84655af6962dab3428183d6bd (patch) | |
| tree | 5927e2486486976702f75d11164469017c30119f | |
| parent | b9eb593e504b76288af51f8540fcc6ac2fc69b5d (diff) | |
| download | bcm5719-llvm-c1b2ccfd34aeded84655af6962dab3428183d6bd.tar.gz bcm5719-llvm-c1b2ccfd34aeded84655af6962dab3428183d6bd.zip | |
<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.
llvm-svn: 171816
| -rw-r--r-- | lldb/include/lldb/Core/Debugger.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/Core/Module.h | 25 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/Symtab.h | 8 | ||||
| -rw-r--r-- | lldb/include/lldb/lldb-forward.h | 1 | ||||
| -rw-r--r-- | lldb/source/Breakpoint/BreakpointResolverName.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Core/Debugger.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Core/Module.cpp | 19 | ||||
| -rw-r--r-- | lldb/source/Symbol/Symtab.cpp | 69 | ||||
| -rw-r--r-- | lldb/test/functionalities/dead-strip/TestDeadStrip.py | 6 | ||||
| -rw-r--r-- | lldb/test/lang/objc/foundation/TestFoundationDisassembly.py | 2 | ||||
| -rw-r--r-- | lldb/test/lang/objc/foundation/TestObjCMethods.py | 2 | ||||
| -rw-r--r-- | lldb/test/lldbutil.py | 13 | ||||
| -rw-r--r-- | lldb/test/logging/TestLogging.py | 4 |
13 files changed, 141 insertions, 19 deletions
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index cdbf14162a5..88bb57f7592 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -369,7 +369,7 @@ protected: 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; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 5301f9128a2..d63ed92a644 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -173,8 +173,9 @@ public: 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 @@ public: 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 diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h index 25b7ffbec1c..f2a25574140 100644 --- a/lldb/include/lldb/Symbol/Symtab.h +++ b/lldb/include/lldb/Symbol/Symtab.h @@ -56,7 +56,6 @@ public: 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 @@ public: size_t FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, 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 @@ protected: 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 @@ private: return false; } + void + SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes, + SymbolContextList &sc_list); DISALLOW_COPY_AND_ASSIGN (Symtab); }; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index e58aee3e8f9..a436d1ab3de 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -350,6 +350,7 @@ namespace lldb { 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; diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 0f0e06d80fe..60932bf581a 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -182,8 +182,7 @@ BreakpointResolverName::SearchCallback 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); } } } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 015924919c0..2a296dba15b 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2614,13 +2614,13 @@ Debugger::EnableLog (const char *channel, const char **categories, const char *l 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()); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 62a6ab63e61..69fccfc30f8 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1064,6 +1064,25 @@ Module::SymbolIndicesToSymbolContextList (Symtab *symtab, std::vector<uint32_t> } 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 diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 5a2ff1b8308..60f2c75b4d9 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -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 @@ Symtab::InitNameIndexes() // 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 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr) 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; +} + diff --git a/lldb/test/functionalities/dead-strip/TestDeadStrip.py b/lldb/test/functionalities/dead-strip/TestDeadStrip.py index e0c40cc0346..f3feb4f5219 100644 --- a/lldb/test/functionalities/dead-strip/TestDeadStrip.py +++ b/lldb/test/functionalities/dead-strip/TestDeadStrip.py @@ -32,13 +32,13 @@ class DeadStripTestCase(TestBase): 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) diff --git a/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py b/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py index 2975b3aa47f..11dda6543b4 100644 --- a/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py +++ b/lldb/test/lang/objc/foundation/TestFoundationDisassembly.py @@ -81,7 +81,7 @@ class FoundationDisassembleTestCase(TestBase): 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]") diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods.py b/lldb/test/lang/objc/foundation/TestObjCMethods.py index 77418b58287..380c44802ff 100644 --- a/lldb/test/lang/objc/foundation/TestObjCMethods.py +++ b/lldb/test/lang/objc/foundation/TestObjCMethods.py @@ -69,7 +69,7 @@ class FoundationTestCase(TestBase): 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]") diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 4ad0396601f..dc1cca7db92 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -275,6 +275,9 @@ def run_break_set_by_file_and_line (test, file_name, line_number, extra_options 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 @@ def run_break_set_by_symbol (test, symbol, extra_options = None, num_expected_lo 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_symbol (test, symbol, extra_options = None, num_expected_lo 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 diff --git a/lldb/test/logging/TestLogging.py b/lldb/test/logging/TestLogging.py index 93f65e9817b..28cfb7669c1 100644 --- a/lldb/test/logging/TestLogging.py +++ b/lldb/test/logging/TestLogging.py @@ -28,13 +28,13 @@ class LogTestCase(TestBase): 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") |

