I also tried to obj2yaml the good DWARF and change it, but once you add bytes all of the section sizes and offsets are off so that was not very fruitful, so I ran into errors when trying to convert the yaml back to and ELF file.
Greg > On Aug 5, 2019, at 10:01 AM, Greg Clayton <clayb...@gmail.com> wrote: > > The issue is found when parsing the "hb_font_make_immutable" function: > > > 0x00084270: DW_TAG_subprogram > DW_AT_low_pc (0x0000000000002fb0) > DW_AT_high_pc (0x0000000000002fe4) > DW_AT_frame_base (DW_OP_reg29 W29) > DW_AT_name ("hb_font_make_immutable") > DW_AT_decl_file (".harfbuzz/src/hb-font.cc > <http://hb-font.cc/>") > DW_AT_decl_line (1514) > DW_AT_external (0x01) > DW_AT_APPLE_optimized (0x01) > > 0x0008428d: DW_TAG_formal_parameter > DW_AT_location (0x00008852 > [0x0000000000002fb0, 0x0000000000002fc0): DW_OP_reg0 W0 > [0x0000000000002fc0, 0x0000000000002fe0): DW_OP_reg19 W19) > DW_AT_name ("font") > DW_AT_decl_file (".harfbuzz/src/hb-font.cc > <http://hb-font.cc/>") > DW_AT_decl_line (1514) > DW_AT_type (0x0008431c "hb_font_t*") > > > The parameter has type 0x0008431c: > > 0x0008431c: DW_TAG_pointer_type > DW_AT_type (0x00084322 "hb_font_t") > > Which points to 0x00084322: > > 0x00084322: DW_TAG_typedef > DW_AT_type (0x00084202 "hb_font_t") > DW_AT_name ("hb_font_t") > DW_AT_decl_file (".harfbuzz/src/hb-font.h") > DW_AT_decl_line (40) > > which points to: > > 0x00084202: DW_TAG_structure_type > DW_AT_calling_convention (DW_CC_pass_by_value) > DW_AT_name ("hb_font_t") > DW_AT_byte_size (0x68) > DW_AT_declaration (0x01) > > Boom we crash when parsing the function type. This was compiled with a > derivative of clang version 6.0.0. > > My attempt at a minimal test case was: > > $ cat main.cpp > #include "ByValue.h" > > void f(ByValueTD *arg) {} > > int main() { > return 0; > } > $ cat ByValue.h > struct ByValue { > ~ByValue() = default; > }; > typedef ByValue ByValueTD; > > > The I try to compile with: > > $ clang++ -g -O0 -std=gnu++11 -stdlib=libc++ -flimit-debug-info main.cpp > > But the DWARF from more recent clangs will remove the DW_CC_pass_by_value > from the ByValue. See the DIE at 0x00000082 in the DWARF below, it doesn't > contain the "DW_AT_calling_convention (DW_CC_pass_by_value)" anymore. > > > 0x0000000b: DW_TAG_compile_unit > DW_AT_producer ("Apple LLVM version 10.0.1 > (clang-1001.0.46.4)") > DW_AT_language (DW_LANG_C_plus_plus) > DW_AT_name ("main.cpp") > DW_AT_stmt_list (0x00000000) > DW_AT_comp_dir ("/Users/gclayton/Documents/src/cc_calling") > DW_AT_low_pc (0x0000000100000f90) > DW_AT_high_pc (0x0000000100000faf) > > 0x0000002a: DW_TAG_subprogram > DW_AT_low_pc (0x0000000100000f90) > DW_AT_high_pc (0x0000000100000f9a) > DW_AT_frame_base (DW_OP_reg6 RBP) > DW_AT_linkage_name ("_Z1fP7ByValue") > DW_AT_name ("f") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (3) > DW_AT_external (true) > > 0x00000043: DW_TAG_formal_parameter > DW_AT_location (DW_OP_fbreg -8) > DW_AT_name ("arg") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (3) > DW_AT_type (0x0000000000000072 "ByValueTD*") > > 0x00000051: NULL > > 0x00000052: DW_TAG_subprogram > DW_AT_low_pc (0x0000000100000fa0) > DW_AT_high_pc (0x0000000100000faf) > DW_AT_frame_base (DW_OP_reg6 RBP) > DW_AT_name ("main") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (5) > DW_AT_type (0x000000000000006b "int") > DW_AT_external (true) > > 0x0000006b: DW_TAG_base_type > DW_AT_name ("int") > DW_AT_encoding (DW_ATE_signed) > DW_AT_byte_size (0x04) > > 0x00000072: DW_TAG_pointer_type > DW_AT_type (0x0000000000000077 "ByValueTD") > > 0x00000077: DW_TAG_typedef > DW_AT_type (0x0000000000000082 "ByValue") > DW_AT_name ("ByValueTD") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/./ByValue.h") > DW_AT_decl_line (4) > > 0x00000082: DW_TAG_structure_type > DW_AT_name ("ByValue") > DW_AT_declaration (true) > > 0x00000087: NULL > > > If we compile with -fno-limit-debug-info we get the "DW_AT_calling_convention > (DW_CC_pass_by_value)": > > 0x0000000b: DW_TAG_compile_unit > DW_AT_producer ("Apple LLVM version 10.0.1 > (clang-1001.0.46.4)") > DW_AT_language (DW_LANG_C_plus_plus) > DW_AT_name ("main.cpp") > DW_AT_stmt_list (0x00000000) > DW_AT_comp_dir ("/Users/gclayton/Documents/src/cc_calling") > DW_AT_low_pc (0x0000000100000f90) > DW_AT_high_pc (0x0000000100000faf) > > 0x0000002a: DW_TAG_subprogram > DW_AT_low_pc (0x0000000100000f90) > DW_AT_high_pc (0x0000000100000f9a) > DW_AT_frame_base (DW_OP_reg6 RBP) > DW_AT_linkage_name ("_Z1fP7ByValue") > DW_AT_name ("f") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (3) > DW_AT_external (true) > > 0x00000043: DW_TAG_formal_parameter > DW_AT_location (DW_OP_fbreg -8) > DW_AT_name ("arg") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (3) > DW_AT_type (0x0000000000000072 "ByValueTD*") > > 0x00000051: NULL > > 0x00000052: DW_TAG_subprogram > DW_AT_low_pc (0x0000000100000fa0) > DW_AT_high_pc (0x0000000100000faf) > DW_AT_frame_base (DW_OP_reg6 RBP) > DW_AT_name ("main") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/main.cpp") > DW_AT_decl_line (5) > DW_AT_type (0x000000000000006b "int") > DW_AT_external (true) > > 0x0000006b: DW_TAG_base_type > DW_AT_name ("int") > DW_AT_encoding (DW_ATE_signed) > DW_AT_byte_size (0x04) > > 0x00000072: DW_TAG_pointer_type > DW_AT_type (0x0000000000000077 "ByValueTD") > > 0x00000077: DW_TAG_typedef > DW_AT_type (0x0000000000000082 "ByValue") > DW_AT_name ("ByValueTD") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/./ByValue.h") > DW_AT_decl_line (4) > > 0x00000082: DW_TAG_structure_type > DW_AT_calling_convention (DW_CC_pass_by_value) > DW_AT_name ("ByValue") > DW_AT_byte_size (0x01) > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/./ByValue.h") > DW_AT_decl_line (1) > > 0x0000008b: DW_TAG_subprogram > DW_AT_name ("~ByValue") > DW_AT_decl_file > ("/Users/gclayton/Documents/src/cc_calling/./ByValue.h") > DW_AT_decl_line (2) > DW_AT_declaration (true) > DW_AT_external (true) > > 0x00000092: DW_TAG_formal_parameter > DW_AT_type (0x0000000000000099 "ByValue*") > DW_AT_artificial (true) > > 0x00000097: NULL > > 0x00000098: NULL > > 0x00000099: DW_TAG_pointer_type > DW_AT_type (0x0000000000000082 "ByValue") > > 0x0000009e: NULL > > >> On Aug 4, 2019, at 11:28 AM, Saleem Abdulrasool <compn...@compnerd.org >> <mailto:compn...@compnerd.org>> wrote: >> >> On Wed, Jul 31, 2019 at 11:29 AM Greg Clayton via lldb-commits >> <lldb-commits@lists.llvm.org <mailto:lldb-commits@lists.llvm.org>> wrote: >> >> >> > On Jul 31, 2019, at 10:57 AM, Raphael Isemann <teempe...@gmail.com >> > <mailto:teempe...@gmail.com>> wrote: >> > >> > It seems that patch is lacking a test (which doesn't seem too hard to >> > provide). >> >> I am not the original author of this patch that was causing the crash, just >> fixing a crash that was introduced by the patch. >> >> Perhaps we should identify the original change and revert that instead? >> >> I am all ears for anyone that can provide me with DWARF to help reproduce >> this scenario where we have a DW_CC_pass_by_value struct with no definition. >> Not sure how you would have a compiler that is passing a struct to a >> function as a parameter and yet does not emit debug info for that struct it >> is clearly using in the debug info. >> >> Was this something that you noticed by inspection? It doesn't sound like >> it, so we should be able to reduce something from what caused it to be >> triggered. lldb has been better about adding test coverage, and I think >> that we should be encouraging that. It really does help make it easier to >> make changes to the project where we can be sure that we don't cause >> regressions. >> >> >> > >> > Am Mi., 31. Juli 2019 um 18:24 Uhr schrieb Greg Clayton via >> > lldb-commits <lldb-commits@lists.llvm.org >> > <mailto:lldb-commits@lists.llvm.org>>: >> >> >> >> Author: gclayton >> >> Date: Wed Jul 31 09:24:55 2019 >> >> New Revision: 367441 >> >> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=367441&view=rev >> >> <http://llvm.org/viewvc/llvm-project?rev=367441&view=rev> >> >> Log: >> >> Don't crash when pass by value struct has no definition. >> >> >> >> >> >> Modified: >> >> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >> >> >> >> Modified: >> >> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >> >> URL: >> >> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=367441&r1=367440&r2=367441&view=diff >> >> >> >> <http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=367441&r1=367440&r2=367441&view=diff> >> >> ============================================================================== >> >> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >> >> (original) >> >> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp >> >> Wed Jul 31 09:24:55 2019 >> >> @@ -1010,7 +1010,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro >> >> if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_value) { >> >> clang::CXXRecordDecl *record_decl = >> >> m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); >> >> - if (record_decl) { >> >> + if (record_decl && record_decl->getDefinition()) { >> >> record_decl->setHasTrivialSpecialMemberForCall(); >> >> } >> >> } >> >> >> >> >> >> _______________________________________________ >> >> lldb-commits mailing list >> >> lldb-commits@lists.llvm.org <mailto:lldb-commits@lists.llvm.org> >> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits >> >> <https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits@lists.llvm.org <mailto:lldb-commits@lists.llvm.org> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits >> <https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits> >> >> >> -- >> Saleem Abdulrasool >> compnerd (at) compnerd (dot) org >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits