[Lldb-commits] [PATCH] D39307: Fix global data symbol resolution

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 25 17:30:15 PDT 2017


xiaobai added a comment.

In https://reviews.llvm.org/D39307#907302, @jingham wrote:

> Note, BTW, we absolutely need some way to say "this symbol from this library".  But first of all, if we're going to do this you need to be able to mix & match within an expression which you can't do with a flag to expr.   Instead you need something like:
>
> (lldb) expr $$MyDylib$my_symbol + $$MyOtherDylib$my_other_symbol
>
> That syntax is ugly, we should try to think of something better.  But the main point is this should only be necessary when lldb can't find a unique symbol.  When we can no intervention should be required.


I see what you mean. I think I'd agree with you here, being able to mix and match would be a useful thing to be able to do while debugging. The syntax is something we can work on.

In https://reviews.llvm.org/D39307#907317, @jingham wrote:

> Actually clang shouldn't be asking us about it at all.  It already knows what it is, and it is a local variable so it should know that it takes priority over anything else we might find.


Right. We get into this whole mess when clang starts to check for redeclaration of parameters in `Sema::ActOnParamDeclaration()` in `$clang_root/lib/Sema/SemaDecl.cpp`. It basically takes your parameter and calls `LookupName` with it. I'm not sure why it would ever need to look beyond the function declaration scope, but that's what it does. It seems to recurse through scopes until it hits the TU scope, and from there it tries to find the symbol `a`. You can get a rough idea of what it tries to do with this backtrace:

  (lldb) bt
  * thread #1, name = 'lldb', stop reason = breakpoint 1.1
    * frame #0: 0x00007fada91245a1 liblldb.so.6`lldb_private::SymbolContext::FindBestGlobalDataSymbol(this=0x00000000007e69b0, name=0x00007ffe8e8c7810, error=0x00007ffe8e8c73c0) at SymbolContext.cpp:804
      frame #1: 0x00007fada930b81d liblldb.so.6`lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(this=0x0000000000852b60, context=0x00007ffe8e8c7e40, module_sp=nullptr, namespace_decl=0x00007ffe8e8c7cb0, current_id=16) at ClangExpressionDeclMap.cpp:1545
      frame #2: 0x00007fada9308a2b liblldb.so.6`lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(this=0x0000000000852b60, context=0x00007ffe8e8c7e40) at ClangExpressionDeclMap.cpp:843
      frame #3: 0x00007fada92d3d03 liblldb.so.6`lldb_private::ClangASTSource::FindExternalVisibleDeclsByName(this=0x0000000000852b60, decl_ctx=0x0000000000934078, clang_decl_name=(Ptr = 9898096)) at ClangASTSource.cpp:261
      frame #4: 0x00007fada90c5c2b liblldb.so.6`lldb_private::ClangASTSource::ClangASTSourceProxy::FindExternalVisibleDeclsByName(this=0x0000000000675040, DC=0x0000000000934078, Name=(Ptr = 9898096)) at ClangASTSource.h:246
      frame #5: 0x00007fadad10a7f1 liblldb.so.6`clang::DeclContext::lookup(this=0x0000000000934078, Name=(Ptr = 9898096)) const at DeclBase.cpp:1542
      frame #6: 0x00007fadac1c2ffa liblldb.so.6`::LookupDirect(S=0x000000000093d7d0, R=0x00007ffe8e8c89c0, DC=0x0000000000934078) at SemaLookup.cpp:843
      frame #7: 0x00007fadac1c35eb liblldb.so.6`::CppNamespaceLookup(S=0x000000000093d7d0, R=0x00007ffe8e8c89c0, Context=0x0000000000926ec0, NS=0x0000000000934078, UDirs=0x00007ffe8e8c8650)::UnqualUsingDirectiveSet &const) at SemaLookup.cpp:942
      frame #8: 0x00007fadac1c4490 liblldb.so.6`clang::Sema::CppLookupName(this=0x000000000093d7d0, R=0x00007ffe8e8c89c0, S=0x00000000009464a0) at SemaLookup.cpp:1322
      frame #9: 0x00007fadac1c5d44 liblldb.so.6`clang::Sema::LookupName(this=0x000000000093d7d0, R=0x00007ffe8e8c89c0, S=0x000000000095aa60, AllowBuiltinCreation=false) at SemaLookup.cpp:1826
      frame #10: 0x00007fadabd285b7 liblldb.so.6`clang::Sema::ActOnParamDeclarator(this=0x000000000093d7d0, S=0x000000000095aa60, D=0x00007ffe8e8c8e30) at SemaDecl.cpp:11775
      frame #11: 0x00007fadab823c62 liblldb.so.6`clang::Parser::ParseParameterDeclarationClause(this=0x0000000000942260, D=0x00007ffe8e8c9b50, FirstArgAttrs=0x00007ffe8e8ca2a0, ParamInfo=0x00007ffe8e8c9930, EllipsisLoc=0x00007ffe8e8ca230) at ParseDecl.cpp:6351
      frame #12: 0x00007fadab866d73 liblldb.so.6`clang::Parser::ParseLambdaExpressionAfterIntroducer(this=0x0000000000942260, Intro=0x00007ffe8e8ca530) at ParseExprCXX.cpp:1127
      frame #13: 0x00007fadab8655fe liblldb.so.6`clang::Parser::ParseLambdaExpression(this=0x0000000000942260) at ParseExprCXX.cpp:685


https://reviews.llvm.org/D39307





More information about the lldb-commits mailing list