[clang] [clang][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72235)
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 3 16:12:50 PST 2024
Michael137 wrote:
> Yeah, that seems to do it:
>
> ```
>
> struct t1 {
>
> t1();
>
> static int i;
>
> };
>
> int t1::i = 43;
>
> int main() {
>
> }
>
> ```
>
> ```
>
> $ clang++-tot -gsplit-dwarf -g test.cpp
>
> $ lldb ./a.out -o "b main" -o "run" -o "p t1::i" -batch
>
> This is google-lldb.
>
> Help: http://go/lldb. File a bug: http://go/lldb-bug.
>
> Stop hook #1 added.
>
> (lldb) target create "./a.out"
>
> Current executable set to '/usr/local/google/home/blaikie/dev/scratch/a.out' (x86_64).
>
> (lldb) b main
>
> Breakpoint 1: where = a.out`main + 4 at test.cpp:7:1, address = 0x0000000000001134
>
> (lldb) run
>
> Process 2043063 launched: '/usr/local/google/home/blaikie/dev/scratch/a.out' (x86_64)
>
> Process 2043063 stopped
>
> * thread #1, name = 'a.out', stop reason = breakpoint 1.1
>
> frame #0: 0x0000555555555134 a.out`main at test.cpp:7:1
>
> 4 };
>
> 5 int t1::i = 43;
>
> 6 int main() {
>
> -> 7 }
>
> (lldb) p t1::i
>
> PLEASE submit a bug report to http://go/llvm-crash-bug and include the crash backtrace.
>
> Stack dump:
>
> 0. Program arguments: lldb ./a.out -o "b main" -o run -o "p t1::i" -batch
>
> 1. HandleCommand(command = "p t1::i")
>
> 2. <user expression 0>:1:5: current parser token 'i'
>
> 3. <lldb wrapper prefix>:44:1: parsing function body '$__lldb_expr'
>
> 4. <lldb wrapper prefix>:44:1: in compound statement ('{}')
>
> #0 0x00005557cda16b58 llvm::sys::RunSignalHandlers() (/usr/bin/lldb+0xc616b58)
>
> #1 0x00005557cda19477 (/usr/bin/lldb+0xc619477)
>
> #2 0x00007fb4905861c0 __restore_rt (/usr/grte/v5/lib64/libpthread.so.0+0x151c0)
>
> #3 0x00005557ca9d0f76 clang::CXXRecordDecl::addedMember(clang::Decl*) (/usr/bin/lldb+0x95d0f76)
>
> #4 0x00005557ca9c8cec clang::DeclContext::addHiddenDecl(clang::Decl*) (/usr/bin/lldb+0x95c8cec)
>
> #5 0x00005557ca9c8d6e clang::DeclContext::addDecl(clang::Decl*) (/usr/bin/lldb+0x95c8d6e)
>
> #6 0x00005557c8c2d190 lldb_private::TypeSystemClang::CreateVariableDeclaration(clang::DeclContext*, lldb_private::OptionalClangModuleID, char const*, clang::QualType) (/usr/bin/lldb+0x782d190)
>
> #7 0x00005557c8bb9667 DWARFASTParserClang::GetClangDeclForDIE(lldb_private::plugin::dwarf::DWARFDIE const&) (/usr/bin/lldb+0x77b9667)
>
> #8 0x00005557c8bb94a7 DWARFASTParserClang::GetClangDeclForDIE(lldb_private::plugin::dwarf::DWARFDIE const&) (/usr/bin/lldb+0x77b94a7)
>
> #9 0x00005557c8bb976e DWARFASTParserClang::GetDeclForUIDFromDWARF(lldb_private::plugin::dwarf::DWARFDIE const&) (/usr/bin/lldb+0x77b976e)
>
> #10 0x00005557c8b88fac lldb_private::plugin::dwarf::SymbolFileDWARF::GetDeclForUID(unsigned long) (/usr/bin/lldb+0x7788fac)
>
> #11 0x00005557c8ceaf2d lldb_private::Variable::GetDecl() (/usr/bin/lldb+0x78eaf2d)
>
> #12 0x00005557c8c72e26 lldb_private::ClangExpressionDeclMap::LookupLocalVariable(lldb_private::NameSearchContext&, lldb_private::ConstString, lldb_private::SymbolContext&, lldb_private::CompilerDeclContext const&) (/usr/bin/lldb+0x7872e26)
>
> #13 0x00005557c8c70f77 lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(lldb_private::NameSearchContext&, std::__u::shared_ptr<lldb_private::Module>, lldb_private::CompilerDeclContext const&) (/usr/bin/lldb+0x7870f77)
>
> #14 0x00005557c8c707aa lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls(lldb_private::NameSearchContext&) (/usr/bin/lldb+0x78707aa)
>
> #15 0x00005557c8c49cbc lldb_private::ClangASTSource::FindExternalVisibleDeclsByName(clang::DeclContext const*, clang::DeclarationName) (/usr/bin/lldb+0x7849cbc)
>
> #16 0x00005557ca9c9c5e clang::DeclContext::lookup(clang::DeclarationName) const (/usr/bin/lldb+0x95c9c5e)
>
> #17 0x00005557ca277728 (/usr/bin/lldb+0x8e77728)
>
> #18 0x00005557ca274400 (/usr/bin/lldb+0x8e74400)
>
> #19 0x00005557ca2739c0 clang::Sema::CppLookupName(clang::LookupResult&, clang::Scope*) (/usr/bin/lldb+0x8e739c0)
>
> #20 0x00005557ca277010 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool, bool) (/usr/bin/lldb+0x8e77010)
>
> #21 0x00005557c9b99e06 clang::Sema::BuildCXXNestedNameSpecifier(clang::Scope*, clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, clang::NamedDecl*, bool, bool*, bool) (/usr/bin/lldb+0x8799e06)
>
> #22 0x00005557c9b9b897 clang::Sema::ActOnCXXNestedNameSpecifier(clang::Scope*, clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, bool*, bool) (/usr/bin/lldb+0x879b897)
>
> #23 0x00005557c9779fdd clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&, clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool, clang::IdentifierInfo**, bool, bool) (/usr/bin/lldb+0x8379fdd)
>
> #24 0x00005557c974c5ea clang::Parser::TryAnnotateTypeOrScopeToken(clang::ImplicitTypenameContext) (/usr/bin/lldb+0x834c5ea)
>
> #25 0x00005557c97d63df clang::Parser::isCXXDeclarationSpecifier(clang::ImplicitTypenameContext, clang::Parser::TPResult, bool*) (/usr/bin/lldb+0x83d63df)
>
> #26 0x00005557c97d5b6b clang::Parser::isCXXSimpleDeclaration(bool) (/usr/bin/lldb+0x83d5b6b)
>
> #27 0x00005557c97d5a3b clang::Parser::isCXXDeclarationStatement(bool) (/usr/bin/lldb+0x83d5a3b)
>
> #28 0x00005557c97fcd2a clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/bin/lldb+0x83fcd2a)
>
> #29 0x00005557c97fc7f8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/bin/lldb+0x83fc7f8)
>
> #30 0x00005557c98076d0 clang::Parser::ParseCompoundStatementBody(bool) (/usr/bin/lldb+0x84076d0)
>
> #31 0x00005557c9808606 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/bin/lldb+0x8408606)
>
> #32 0x00005557c97492c8 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/bin/lldb+0x83492c8)
>
> #33 0x00005557c97b87da clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/bin/lldb+0x83b87da)
>
> #34 0x00005557c9747f12 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/bin/lldb+0x8347f12)
>
> #35 0x00005557c9747918 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/bin/lldb+0x8347918)
>
> #36 0x00005557c9746b1a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/bin/lldb+0x8346b1a)
>
> #37 0x00005557c9744bd7 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/bin/lldb+0x8344bd7)
>
> #38 0x00005557c973fbfe clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/lldb+0x833fbfe)
>
> #39 0x00005557c8c83577 lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&, clang::CodeCompleteConsumer*, unsigned int, unsigned int) (/usr/bin/lldb+0x7883577)
>
> #40 0x00005557c8c57b9d lldb_private::ClangUserExpression::TryParse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContextScope*, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) (/usr/bin/lldb+0x7857b9d)
>
> #41 0x00005557c8c58425 lldb_private::ClangUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) (/usr/bin/lldb+0x7858425)
>
> #42 0x00005557c894b5a6 lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, llvm::StringRef, llvm::StringRef, std::__u::shared_ptr<lldb_private::ValueObject>&, lldb_private::Status&, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, lldb_private::ValueObject*) (/usr/bin/lldb+0x754b5a6)
>
> #43 0x00005557c8d66121 lldb_private::Target::EvaluateExpression(llvm::StringRef, lldb_private::ExecutionContextScope*, std::__u::shared_ptr<lldb_private::ValueObject>&, lldb_private::EvaluateExpressionOptions const&, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, lldb_private::ValueObject*) (/usr/bin/lldb+0x7966121)
>
> #44 0x00005557c8986beb lldb_private::CommandObjectDWIMPrint::DoExecute(llvm::StringRef, lldb_private::CommandReturnObject&) (/usr/bin/lldb+0x7586beb)
>
> #45 0x00005557c8a4354a lldb_private::CommandObjectRaw::Execute(char const*, lldb_private::CommandReturnObject&) (/usr/bin/lldb+0x764354a)
>
> #46 0x00005557c895c10b lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, bool) (/usr/bin/lldb+0x755c10b)
>
> #47 0x00005557c8960cb5 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>&) (/usr/bin/lldb+0x7560cb5)
>
> #48 0x00005557c88c29a3 lldb_private::IOHandlerEditline::Run() (/usr/bin/lldb+0x74c29a3)
>
> #49 0x00005557c88a1a96 lldb_private::Debugger::RunIOHandlers() (/usr/bin/lldb+0x74a1a96)
>
> #50 0x00005557c8962a0a lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) (/usr/bin/lldb+0x7562a0a)
>
> #51 0x00005557c7fa176c lldb::SBDebugger::RunCommandInterpreter(lldb::SBCommandInterpreterRunOptions const&) (/usr/bin/lldb+0x6ba176c)
>
> #52 0x00005557c7f819f5 Driver::MainLoop() (/usr/bin/lldb+0x6b819f5)
>
> #53 0x00005557c7f829a1 main (/usr/bin/lldb+0x6b829a1)
>
> #54 0x00007fb4903da633 __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x61633)
>
> #55 0x00005557c7f7e02a _start (/usr/bin/lldb+0x6b7e02a)
>
> LLDB diagnostics will be written to /tmp/diagnostics-6518ff
>
> Please include the directory content when filing a bug report
>
> Segmentation fault
>
> ```
>
> (Hmm, maybe our google build of lldb enables something to print the stack trace - I can reproduce this with (in this case with a debug+asserts build) an open source build of lldb too, like this:)
>
> ```
>
> $ LD_LIBRARY_PATH=$HOME/dev/llvm/build/default/lib ~/dev/llvm/build/default/bin/lldb ./a.out -o "b main" -o "run" -o "p t1::i"
>
> -batch
>
> (lldb) target create "./a.out"
>
> Current executable set to '/usr/local/google/home/blaikie/dev/scratch/a.out' (x86_64).
>
> (lldb) b main
>
> Breakpoint 1: where = a.out`main + 4 at test.cpp:7:1, address = 0x0000000000001134
>
> (lldb) run
>
> Process 2047004 launched: '/usr/local/google/home/blaikie/dev/scratch/a.out' (x86_64)
>
> Process 2047004 stopped
>
> * thread #1, name = 'a.out', stop reason = breakpoint 1.1
>
> frame #0: 0x0000555555555134 a.out`main at test.cpp:7:1
>
> 4 };
>
> 5 int t1::i = 43;
>
> 6 int main() {
>
> -> 7 }
>
> (lldb) p t1::i
>
> lldb: /usr/local/google/home/blaikie/dev/llvm/src/llvm/../clang/include/clang/AST/DeclCXX.h:464: struct DefinitionData &clang::CXXRecordDecl::data() const: Assertion `DD && "queried property of class with no definition"' failed.
>
> LLDB diagnostics will be written to /tmp/diagnostics-12c7ac
>
> Please include the directory content when filing a bug report
>
> Aborted
>
> ```
>
>
>
>
Awesome thanks for the reproducer! Will look into it asap
https://github.com/llvm/llvm-project/pull/72235
More information about the cfe-commits
mailing list