[Lldb-commits] [lldb] r151876 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Jim Ingham jingham at apple.com
Thu Mar 1 18:24:42 PST 2012


Author: jingham
Date: Thu Mar  1 20:24:42 2012
New Revision: 151876

URL: http://llvm.org/viewvc/llvm-project?rev=151876&view=rev
Log:
Make sure breakpoint partial name matches occur on namespace boundaries.
<rdar://problem/10720345> "break set -n" name matching should only match at namespace boundaries

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

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=151876&r1=151875&r2=151876&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Mar  1 20:24:42 2012
@@ -2908,8 +2908,41 @@
             if (demangled)
             {
                 std::string name_no_parens(partial_name, base_name_end - partial_name);
-                if (strstr (demangled, name_no_parens.c_str()) == NULL)
+                const char *partial_in_demangled = strstr (demangled, name_no_parens.c_str());
+                if (partial_in_demangled == NULL)
                     return false;
+                else
+                {
+                    // Sort out the case where our name is something like "Process::Destroy" and the match is
+                    // "SBProcess::Destroy" - that shouldn't be a match.  We should really always match on
+                    // namespace boundaries...
+                    
+                    if (partial_name[0] == ':'  && partial_name[1] == ':')
+                    {
+                        // The partial name was already on a namespace boundary so all matches are good.
+                        return true;
+                    }
+                    else if (partial_in_demangled == demangled)
+                    {
+                        // They both start the same, so this is an good match.
+                        return true;
+                    }
+                    else
+                    {
+                        if (partial_in_demangled - demangled == 1)
+                        {
+                            // Only one character difference, can't be a namespace boundary...
+                            return false;
+                        }
+                        else if (*(partial_in_demangled - 1) == ':' && *(partial_in_demangled - 2) == ':')
+                        {
+                            // We are on a namespace boundary, so this is also good.
+                            return true;
+                        }
+                        else
+                            return false;
+                    }
+                }
             }
         }
     }





More information about the lldb-commits mailing list