[Lldb-commits] [lldb] r180167 - Fixed a problem where the expression parser would

Malea, Daniel daniel.malea at intel.com
Wed Apr 24 10:35:01 PDT 2013


Yup, this fails with both clang and gcc; overloaded function resolution is
not working correctly. Here's a little more details on the error:


runCmd: thread list
output: Process 9512 stopped
* thread #1: tid = 0x2528, 0x0000000000400594 a.out`main + 4 at
main.cpp:42, stop reason = breakpoint 1.1


Expecting sub string: stopped
Matched

Expecting sub string: stop reason = breakpoint
Matched

runCmd: expression -- Dump(myB)
runCmd failed!
error: use of undeclared identifier 'Dump'
error: 1 errors parsing expression





Dan



On 2013-04-23 10:13 PM, "Thirumurthi, Ashok" <ashok.thirumurthi at intel.com>
wrote:

>FYI Sean,
>
>The new test case that you added is failing on both Linux buildbots.  I
>believe Duncan Sands can give you an account on the buildbot machines if
>you'd like to have a look...
>
>======================================================================
>FAIL: test_with_dwarf_and_run_command
>(TestOverloadedFunctions.CPPStaticMethodsTestCase)
>   Test that functions with the same name are resolved correctly
>----------------------------------------------------------------------
>Traceback (most recent call last):
>  File 
>"/home/llvmbb/llvm-build-dir/lldb-x86_64-clang/llvm/tools/lldb/test/lldbte
>st.py", line 365, in wrapper
>    return func(self, *args, **kwargs)
>  File 
>"/home/llvmbb/llvm-build-dir/lldb-x86_64-clang/llvm/tools/lldb/test/lang/c
>pp/overloaded-functions/TestOverloadedFunctions.py", line 24, in
>test_with_dwarf_and_run_command
>    self.static_method_commands()
>  File 
>"/home/llvmbb/llvm-build-dir/lldb-x86_64-clang/llvm/tools/lldb/test/lang/c
>pp/overloaded-functions/TestOverloadedFunctions.py", line 44, in
>static_method_commands
>    startstr = "(int) $0 = 2")
>  File 
>"/home/llvmbb/llvm-build-dir/lldb-x86_64-clang/llvm/tools/lldb/test/lldbte
>st.py", line 1450, in expect
>    self.runCmd(str, msg=msg, trace = (True if trace else False), check =
>not error)
>  File 
>"/home/llvmbb/llvm-build-dir/lldb-x86_64-clang/llvm/tools/lldb/test/lldbte
>st.py", line 1376, in runCmd
>    msg if msg else CMD_MSG(cmd))
>AssertionError: False is not True : Command 'expression -- Dump(myB)'
>returns successfully
>Config=x86_64-clang
>----------------------------------------------------------------------
>
>- Ashok
>
>
>
>-----Original Message-----
>From: lldb-commits-bounces at cs.uiuc.edu
>[mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Sean Callanan
>Sent: Tuesday, April 23, 2013 8:35 PM
>To: lldb-commits at cs.uiuc.edu
>Subject: [Lldb-commits] [lldb] r180167 - Fixed a problem where the
>expression parser would
>
>Author: spyffe
>Date: Tue Apr 23 19:34:41 2013
>New Revision: 180167
>
>URL: http://llvm.org/viewvc/llvm-project?rev=180167&view=rev
>Log:
>Fixed a problem where the expression parser would not find multiple
>functions with the same name but different types.  Now we keep track of
>what types we've already reported for a function and only elide functions
>if we've already reported a conflicting one.
>
>Also added a test case.
>
><rdar://problem/11367837>
>
>Added:
>    lldb/trunk/test/lang/cpp/overloaded-functions/
>    lldb/trunk/test/lang/cpp/overloaded-functions/Makefile
>    
>lldb/trunk/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
>    lldb/trunk/test/lang/cpp/overloaded-functions/main.cpp
>    lldb/trunk/test/lang/cpp/overloaded-functions/static-a.cpp
>    lldb/trunk/test/lang/cpp/overloaded-functions/static-b.cpp
>Modified:
>    lldb/trunk/include/lldb/Expression/ClangASTSource.h
>    lldb/trunk/source/Expression/ClangASTSource.cpp
>    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
>
>Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/Cla
>ngASTSource.h?rev=180167&r1=180166&r2=180167&view=diff
>==========================================================================
>====
>--- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original)
>+++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Tue Apr 23
>+++ 19:34:41 2013
>@@ -17,6 +17,8 @@
> #include "lldb/Symbol/ClangASTImporter.h"
> #include "lldb/Target/Target.h"
> 
>+#include "llvm/ADT/SmallSet.h"
>+
> namespace lldb_private {
>     
> //----------------------------------------------------------------------
>@@ -427,11 +429,12 @@ protected:
> /// Decls given appropriate type information.
> //----------------------------------------------------------------------
> struct NameSearchContext {
>-    ClangASTSource &m_ast_source;                       ///< The AST
>source making the request
>-    llvm::SmallVectorImpl<clang::NamedDecl*> &m_decls;  ///< The list of
>declarations already constructed
>-    ClangASTImporter::NamespaceMapSP m_namespace_map;   ///< The mapping
>of all namespaces found for this request back to their modules
>-    const clang::DeclarationName &m_decl_name;          ///< The name
>being looked for
>-    const clang::DeclContext *m_decl_context;           ///< The
>DeclContext to put declarations into
>+    ClangASTSource &m_ast_source;                               ///< The
>AST source making the request
>+    llvm::SmallVectorImpl<clang::NamedDecl*> &m_decls;          ///< The
>list of declarations already constructed
>+    ClangASTImporter::NamespaceMapSP m_namespace_map;           ///< The
>mapping of all namespaces found for this request back to their modules
>+    const clang::DeclarationName &m_decl_name;                  ///< The
>name being looked for
>+    const clang::DeclContext *m_decl_context;                   ///< The
>DeclContext to put declarations into
>+    llvm::SmallSet <lldb::clang_type_t, 5> m_function_types;    ///< All
>the types of functions that have been reported, so we don't report
>conflicts
>     
>     struct {
>         bool variable                   : 1;
>
>Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTS
>ource.cpp?rev=180167&r1=180166&r2=180167&view=diff
>==========================================================================
>====
>--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
>+++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Apr 23 19:34:41
>+++ 2013
>@@ -1724,6 +1724,11 @@ NameSearchContext::AddFunDecl (void *typ  {
>     assert (type && "Type for variable must be non-NULL!");
>     
>+    if (m_function_types.count(type))
>+        return NULL;
>+    
>+    m_function_types.insert(type);
>+    
>     clang::FunctionDecl *func_decl = FunctionDecl::Create
>(*m_ast_source.m_ast_context,
>                  
>const_cast<DeclContext*>(m_decl_context),
>                  
>SourceLocation(),
>
>Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpr
>essionDeclMap.cpp?rev=180167&r1=180166&r2=180167&view=diff
>==========================================================================
>====
>--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
>+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Apr 23
>+++ 19:34:41 2013
>@@ -1328,10 +1328,7 @@ ClangExpressionDeclMap::FindExternalVisi
>                         if (dyn_cast<clang::CXXMethodDecl>(decl_ctx))
>                             continue;
>                  
>-                        // TODO only do this if it's a C function; C++
>functions may be
>-                        // overloaded
>-                        if (!context.m_found.function_with_type_info)
>-                            AddOneFunction(context, sym_ctx.function,
>NULL, current_id);
>+                        AddOneFunction(context, sym_ctx.function, NULL,
>+ current_id);
>                         context.m_found.function_with_type_info = true;
>                         context.m_found.function = true;
>                     }
>@@ -1859,6 +1856,18 @@ ClangExpressionDeclMap::AddOneFunction (
>         if (copied_type)
>         {
>             fun_decl = context.AddFunDecl(copied_type);
>+            
>+            if (!fun_decl)
>+            {
>+                if (log)
>+                {
>+                    log->Printf ("  Failed to create a function decl for
>'%s' {0x%8.8" PRIx64 "}",
>+                                 fun_type->GetName().GetCString(),
>+                                 fun_type->GetID());
>+                }
>+                
>+                return;
>+            }
>         }
>         else
>         {
>
>Added: lldb/trunk/test/lang/cpp/overloaded-functions/Makefile
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/overloaded-fu
>nctions/Makefile?rev=180167&view=auto
>==========================================================================
>====
>--- lldb/trunk/test/lang/cpp/overloaded-functions/Makefile (added)
>+++ lldb/trunk/test/lang/cpp/overloaded-functions/Makefile Tue Apr 23
>+++ 19:34:41 2013
>@@ -0,0 +1,5 @@
>+LEVEL = ../../../make
>+
>+CXX_SOURCES := main.cpp static-a.cpp static-b.cpp
>+
>+include $(LEVEL)/Makefile.rules
>
>Added: 
>lldb/trunk/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/overloaded-fu
>nctions/TestOverloadedFunctions.py?rev=180167&view=auto
>==========================================================================
>====
>--- 
>lldb/trunk/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
>(added)
>+++ lldb/trunk/test/lang/cpp/overloaded-functions/TestOverloadedFunction
>+++ s.py Tue Apr 23 19:34:41 2013
>@@ -0,0 +1,53 @@
>+"""
>+Tests that functions with the same name are resolved correctly.
>+"""
>+
>+import lldb
>+from lldbtest import *
>+import lldbutil
>+
>+class CPPStaticMethodsTestCase(TestBase):
>+    
>+    mydir = os.path.join("lang", "cpp", "overloaded-functions")
>+    
>+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires
>Darwin")
>+    @dsym_test
>+    def test_with_dsym_and_run_command(self):
>+        """Test that functions with the same name are resolved
>correctly"""
>+        self.buildDsym()
>+        self.static_method_commands()
>+
>+    @dwarf_test
>+    def test_with_dwarf_and_run_command(self):
>+        """Test that functions with the same name are resolved
>correctly"""
>+        self.buildDwarf()
>+        self.static_method_commands()
>+
>+    def setUp(self):
>+        TestBase.setUp(self)
>+        self.line = line_number('main.cpp', '// breakpoint')
>+    
>+    def static_method_commands(self):
>+        """Test that static methods are properly distinguished from
>regular methods"""
>+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
>+
>+        lldbutil.run_break_set_by_file_and_line (self, "main.cpp",
>+ self.line, num_expected_locations=1, loc_exact=True)
>+
>+        self.runCmd("process launch", RUN_SUCCEEDED)
>+
>+        # The stop reason of the thread should be breakpoint.
>+        self.expect("thread list",
>+                    STOPPED_DUE_TO_BREAKPOINT,
>+                    substrs = ['stopped', 'stop reason = breakpoint'])
>+
>+        self.expect("expression -- Dump(myB)",
>+                    startstr = "(int) $0 = 2")
>+
>+        self.expect("expression -- Static()",
>+                    startstr = "(int) $1 = 1")
>+
>+if __name__ == '__main__':
>+    import atexit
>+    lldb.SBDebugger.Initialize()
>+    atexit.register(lambda: lldb.SBDebugger.Terminate())
>+    unittest2.main()
>
>Added: lldb/trunk/test/lang/cpp/overloaded-functions/main.cpp
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/overloaded-fu
>nctions/main.cpp?rev=180167&view=auto
>==========================================================================
>====
>--- lldb/trunk/test/lang/cpp/overloaded-functions/main.cpp (added)
>+++ lldb/trunk/test/lang/cpp/overloaded-functions/main.cpp Tue Apr 23
>+++ 19:34:41 2013
>@@ -0,0 +1,43 @@
>+#include <stdio.h>
>+
>+struct A {
>+    int aa;
>+    char ab;
>+};
>+
>+struct B {
>+    int ba;
>+    int bb;
>+};
>+
>+struct C {
>+    int ca;
>+    int cb;
>+};
>+
>+int Dump (A &a)
>+{
>+    return 1;
>+}
>+
>+int Dump (B &b)
>+{
>+    return 2;
>+}
>+
>+int Dump (C &c)
>+{
>+    return 3;
>+}
>+
>+extern int CallStaticA();
>+extern int CallStaticB();
>+
>+int main()
>+{
>+    A myA;
>+    B myB;
>+    C myC;
>+
>+    printf("%d\n", CallStaticA() + CallStaticB()); // breakpoint }
>
>Added: lldb/trunk/test/lang/cpp/overloaded-functions/static-a.cpp
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/overloaded-fu
>nctions/static-a.cpp?rev=180167&view=auto
>==========================================================================
>====
>--- lldb/trunk/test/lang/cpp/overloaded-functions/static-a.cpp (added)
>+++ lldb/trunk/test/lang/cpp/overloaded-functions/static-a.cpp Tue Apr
>+++ 23 19:34:41 2013
>@@ -0,0 +1,9 @@
>+static int Static()
>+{
>+  return 1;
>+}
>+
>+int CallStaticA()
>+{
>+  return Static();
>+}
>
>Added: lldb/trunk/test/lang/cpp/overloaded-functions/static-b.cpp
>URL: 
>http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/overloaded-fu
>nctions/static-b.cpp?rev=180167&view=auto
>==========================================================================
>====
>--- lldb/trunk/test/lang/cpp/overloaded-functions/static-b.cpp (added)
>+++ lldb/trunk/test/lang/cpp/overloaded-functions/static-b.cpp Tue Apr
>+++ 23 19:34:41 2013
>@@ -0,0 +1,9 @@
>+static int Static()
>+{
>+  return 1;
>+}
>+
>+int CallStaticB()
>+{
>+  return Static();
>+}
>
>
>_______________________________________________
>lldb-commits mailing list
>lldb-commits at cs.uiuc.edu
>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
>_______________________________________________
>lldb-commits mailing list
>lldb-commits at cs.uiuc.edu
>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits





More information about the lldb-commits mailing list