Bug 4212 – DWARF: void arrays cause gdb errors

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Linux
Creation time
2010-05-20T12:04:00Z
Last change time
2014-02-15T02:18:49Z
Keywords
patch
Assigned to
nobody
Creator
nfxjfg
Blocks
4044

Comments

Comment #0 by nfxjfg — 2010-05-20T12:04:46Z
(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.
Comment #1 by robert — 2010-05-20T12:21:57Z
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(){} ----
Comment #2 by robert — 2010-05-20T12:45:35Z
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
Comment #3 by bugzilla — 2010-05-20T22:07:14Z
changeset 495 (dwarf.c changes)