4212 – DWARF: void arrays cause gdb errors

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4212 - DWARF: void arrays cause gdb errors
Summary: DWARF: void arrays cause gdb errors
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
Depends on:
Blocks: 4044
Show dependency tree / graph
Reported: 2010年05月20日 12:04 UTC by nfxjfg
Modified: 2014年02月15日 02:18 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2010年05月20日 12:04:46 UTC
(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 Robert Clipsham 2010年05月20日 12:21:57 UTC
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 Robert Clipsham 2010年05月20日 12:45:35 UTC
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 Walter Bright 2010年05月20日 22:07:14 UTC
changeset 495 (dwarf.c changes)


AltStyle によって変換されたページ (->オリジナル) /