(This bug report is for dmd 1.061) This code: extern (C) void abort(); struct X { union { void[] a; void[a.sizeof] b; } } void foo(X b) { abort(); } void main() { foo(X.init); } Makes gdb output "Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0x68 [in module /tmp/test/dr]" when the abort() jumps back into the debugger, and you request a stacktrace with "bt". I suspect something is wrong with static void[] arrays.
Test case is for D1, with D2 it fails with an error that has no line number information. Reduced test case for D2: ---- void[8] foo = void; void main(){} ----
The patch below fixes both test cases: Index: backend/dwarf.c =================================================================== --- backend/dwarf.c (revisión: 494) +++ backend/dwarf.c (copia de trabajo) @@ -1558,6 +1558,13 @@ DW_AT_type, DW_FORM_ref4, 0, 0, }; + static unsigned char abbrevTypeArrayVoid[] = + { + DW_TAG_array_type, + 1, // child (the subrange type) + DW_AT_sibling, DW_FORM_ref4, + 0, 0, + }; static unsigned char abbrevTypeSubrange[] = { DW_TAG_subrange_type, @@ -1573,7 +1580,6 @@ DW_AT_type, DW_FORM_ref4, 0, 0, }; - unsigned code1 = dwarf_abbrev_code(abbrevTypeArray, sizeof(abbrevTypeArray)); unsigned code2 = (t->Tflags & TFsizeunknown) ? dwarf_abbrev_code(abbrevTypeSubrange2, sizeof(abbrevTypeSubrange2)) : dwarf_abbrev_code(abbrevTypeSubrange, sizeof(abbrevTypeSubrange)); @@ -1581,12 +1587,15 @@ unsigned idxsibling = 0; unsigned siblingoffset; nextidx = dwarf_typidx(t->Tnext); + unsigned code1 = nextidx ? dwarf_abbrev_code(abbrevTypeArray, sizeof(abbrevTypeArray)) + : dwarf_abbrev_code(abbrevTypeArrayVoid, sizeof(abbrevTypeArrayVoid)); idx = infobuf->size(); infobuf->writeuLEB128(code1); // DW_TAG_array_type siblingoffset = infobuf->size(); infobuf->write32(idxsibling); // DW_AT_sibling - infobuf->write32(nextidx); // DW_AT_type + if (nextidx) + infobuf->write32(nextidx); // DW_AT_type infobuf->writeuLEB128(code2); // DW_TAG_subrange_type infobuf->write32(idxbase); // DW_AT_type
changeset 495 (dwarf.c changes)
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル