Example input: # cat test.cc #include <string> #include <iostream> int main() { std::string msg = "test"; std::cout << msg << std::endl; } Unless compiled with clang++ -fstandalone-debug it cannot read the value of the msg string. Installing gcc-debuginfo, it will work on these conditions: $ g++ -g test.cc; lldb a.out $ g++ -g test.cc; gdb a.out $ clang++ -g test.cc; gdb a.out but not with: $ clang++ -g test.cc; lldb a.out (Actually, lldb is crashing on rhel7, but that should be another issue) Example session on Fedora: clang++ -g test.cc $ lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b main Breakpoint 1: where = a.out`main + 12 at test.cc:4:27, address = 0x000000000040124c (lldb) r Process 9282 launched: '/home/pcpa/sfdc/02445153/a.out' (x86_64) warning: (x86_64) /lib64/libstdc++.so.6 unsupported DW_FORM values: 0x1f20 0x1f21 Process 9282 stopped * thread #1, name = 'a.out', stop reason = breakpoint 1.1 frame #0: 0x000000000040124c a.out`main at test.cc:4:27 1 #include <string> 2 #include <iostream> 3 int main() { -> 4 std::string msg = "test"; 5 std::cout << msg << std::endl; 6 } (lldb) n Process 9282 stopped * thread #1, name = 'a.out', stop reason = step over frame #0: 0x0000000000401278 a.out`main at test.cc:5:12 2 #include <iostream> 3 int main() { 4 std::string msg = "test"; -> 5 std::cout << msg << std::endl; 6 } (lldb) p msg error: incomplete type 'std::string' (aka 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >') where a complete type is required forward declaration of 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >' (lldb) c Process 9282 resuming test Process 9282 exited with status = 0 (0x00000000) (lldb) q This report is likely a dup of rhbz#1732593 User pointed to http://lists.llvm.org/pipermail/cfe-users/2019-August/001559.html that might be an explanation, telling Fedora/Red Hat uses GNU extension not supported by LLDB. It is uncertain if the issue is in clang++ or lldb, as lldb works with g++ generated code, and gdb works with clang++ generated code.
(In reply to Paulo Andrade from comment #0) > (Actually, lldb is crashing on rhel7, but that should be another issue) I guess it is crashing because that time it wasn't protected against DWZ debug info unknown to LLDB. That is now fixed which is why LLDB prints it is ignoring system debug info: > warning: (x86_64) /lib64/libstdc++.so.6 unsupported DW_FORM values: 0x1f20 > 0x1f21 Work on supporting DWZ debug info is tracked by Bug 1482854 and upstream let's say: https://reviews.llvm.org/D40474 I have a custom build of LLDB with this off-trunk DWZ patchset: dnf copr enable jankratochvil/lldb;dnf install lldb-experimental;lldb-experimental Although in this case it crashes for me (and I think it is unrelated to my DWZ support but maybe it is). Anyway that last lldb-experimental build is old now, I am making a new version (primarily for upstreaming). > It is uncertain if the issue is in clang++ or lldb, as lldb works with g++ > generated > code, and gdb works with clang++ generated code. Still I think Fedora/RHEL clang should probably have -fstandalone-debug as default as even with DWZ support in LLDB it looks to me it is needed. Probably because system debug info is from GCC while clang assumes clang-produced debug info in libraries. Also it looks to me GCC is using -fstandalone-debug implicitly.
*** This bug has been marked as a duplicate of bug 1482854 ***
Thanks for the information. I am afraid the lldb-experimental crashes on both rhel7 and fedora 30 with the example test.cpp when attempting to printing the 'msg' value. About gcc having -fstandalone-debug implicitly, at least based on binary size I believe this is the case. The binary generated by 'g++ -g' is slightly larger than one generated by clang++ -g -fstandalone-debug'. But then, gdb should be doing something special, because it works with the binary generated by 'clang++ -g'.
My DWZ patchset for trunk crashes the same way so keeping it as separate Bug to verify it gets fixed. (lldb) p msg #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x41e8ef) #1 llvm::sys::RunSignalHandlers() (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x41ce42) #2 SignalHandler(int) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x41efb8) #3 __restore_rt (/lib64/libpthread.so.0+0x12e80) #4 clang::CXXRecordDecl::bases_begin() const (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd66733) #5 clang::CXXRecordDecl::bases() const (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x257f0cd) #6 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x257dfa6) #7 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x257c6e3) #8 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x257c993) #9 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x257c5e0) #10 clang::CodeGen::CodeGenModule::getOrCreateStaticVarDecl(clang::VarDecl const&, llvm::GlobalValue::LinkageTypes) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x26825dc) #11 clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(clang::VarDecl const&, llvm::GlobalValue::LinkageTypes) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x26816cd) #12 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x2681197) #13 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x24dba1b) #14 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x24d314c) #15 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x24d1efb) #16 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x24dc55a) #17 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x251ee98) #18 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x2539cd3) #19 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x25336f2) #20 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x253ca37) #21 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x2495f5f) #22 lldb_private::ASTResultSynthesizer::HandleTopLevelDecl(clang::DeclGroupRef) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xefe9e7) #23 clang::ParseAST(clang::Sema&, bool, bool) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x2c45953) #24 lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&, clang::CodeCompleteConsumer*, unsigned int, unsigned int) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xf22cc7) #25 lldb_private::ClangUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xefb08c) #26 lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, llvm::StringRef, llvm::StringRef, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::Status&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::shared_ptr<lldb_private::Module>*, lldb_private::ValueObject*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd08bcc) #27 lldb_private::Target::EvaluateExpression(llvm::StringRef, lldb_private::ExecutionContextScope*, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::EvaluateExpressionOptions const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, lldb_private::ValueObject*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xe29f5c) #28 lldb_private::CommandObjectExpression::EvaluateExpression(llvm::StringRef, lldb_private::Stream*, lldb_private::Stream*, lldb_private::CommandReturnObject*) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x24294ce) #29 lldb_private::CommandObjectExpression::DoExecute(llvm::StringRef, lldb_private::CommandReturnObject&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x242a412) #30 lldb_private::CommandObjectRaw::Execute(char const*, lldb_private::CommandReturnObject&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd3cfdf) #31 lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, lldb_private::ExecutionContext*, bool, bool) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd34508) #32 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd37a49) #33 lldb_private::IOHandlerEditline::Run() (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xc873d1) #34 lldb_private::Debugger::ExecuteIOHandlers() (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xc6c566) #35 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0xd388c6) #36 lldb::SBDebugger::RunCommandInterpreter(bool, bool) (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/../lib/liblldb.so.10svn+0x9f0a66) #37 Driver::MainLoop() (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x409d11) #38 main (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x40ad79) #39 __libc_start_main /usr/src/debug/glibc-2.29-24-g2ec0b166bf/csu/../csu/libc-start.c:308:16 #40 _start (/home/jkratoch/redhat/llvm-monorepo-clangassert/bin/lldb+0x4072ee)
*** Bug 1732593 has been marked as a duplicate of this bug. ***
It works now with lldb-experimental DWZ patches, I did not bisect the upstream change fixing this Bug: https://copr.fedorainfracloud.org/coprs/jankratochvil/lldb/package/lldb-experimental/ dnf copr enable jankratochvil/lldb;dnf install lldb-experimental;lldb-experimental ... I was thinking it will need this patch by Pavel Labath but it does not: [lldb] Add basic -flimit-debug-info support to expression evaluator https://reviews.llvm.org/D81561