Bug 3391 – gdb: dynamic arrays and associative arrays are not properly printed

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2009-10-12T16:08:00Z
Last change time
2014-04-18T09:12:06Z
Assigned to
nobody
Creator
leandro.lucarella
Blocks
4044

Attachments

IDFilenameSummaryContent-TypeSize
478dbg.dmd.dumpobjdump -W for DMDtext/plain8246
479dbg.ldc.dumpobjdump -W for LDCtext/plain10159

Comments

Comment #0 by leandro.lucarella — 2009-10-12T16:08:36Z
DMD 1.049/2.034 --------------- $ cat -n bug.d 1 version (Tango) alias char[] string; 2 void main(string[] args) 3 { 4 float[2] f; 5 f[0] = 1.45; 6 f[1] = 3.45; 7 int[] i; 8 i ~= 5; 9 i ~= 15; 10 char[string] h; 11 h["foo"] = 'f'; 12 h["bar"] = 'b'; 13 *(args.ptr + 1_000_000) = "boom"; 14 } $ dmd -gc bug.d $ gdb --quiet ./bug Reading symbols from ./bug...done. (gdb) run 1 2 3 Starting program: ./bug [Thread debugging using libthread_db enabled] Program received signal SIGSEGV, Segmentation fault. 0x08049bd2 in _Dmain (args=578452242739232769) at bug.d:13 13 *(args.ptr + 1_000_000) = "boom"; Current language: auto The current source language is "auto; currently d". (gdb) print i $1 = 13246370664958394370 (gdb) print f $2 = {1.45000005, 3.45000005} (gdb) print h $3 = (void *) 0xb7d48fe0 (gdb) print args $4 = 578452242739232769 LDC does a pretty good job with dynamic arrays (including char[] as strings): Program received signal SIGSEGV, Segmentation fault. 0x08049718 in _Dmain (args=...) at ./bug.d:13 13 *(args.ptr + 1_000_000) = "boom"; (gdb) print i $1 = {5, 15} (gdb) print args $2 = {"./bug", "1", "2", "3"} Associative arrays seems to be not very well handled by any current compiler...
Comment #1 by leandro.lucarella — 2009-10-17T18:00:47Z
Maybe this is useful. For this file: $ cat -n dbg.d 1 2 void dummy_function() 3 { 4 char[][] str_array; 5 str_array ~= "hello"; 6 str_array ~= "world"; 7 int[2] int_sarray; 8 int_sarray[0] = 1; 9 int_sarray[1] = -1; 10 } 11 DMD (svn 1.x branch at r215) generates this: <1><6c>: Abbrev Number: 5 (DW_TAG_array_type) <6d> DW_AT_sibling : <0x7f> <71> DW_AT_type : <0x65> While LDC generates: <2><86>: Abbrev Number: 3 (DW_TAG_variable) <87> DW_AT_name : str_array <91> DW_AT_decl_file : 1 <92> DW_AT_decl_line : 4 <93> DW_AT_type : <0x121> <97> DW_AT_location : 2 byte block: 75 70 (DW_OP_breg5: -16) I will attach the full dump of objdump -W for both DMD and LDC.
Comment #2 by leandro.lucarella — 2009-10-17T18:01:47Z
Created attachment 478 objdump -W for DMD
Comment #3 by leandro.lucarella — 2009-10-17T18:02:23Z
Created attachment 479 objdump -W for LDC
Comment #4 by leandro.lucarella — 2011-12-19T03:53:53Z
Comment #5 by bugzilla — 2012-01-18T20:56:59Z
Fixed by pull 526.