www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3391] New: gdb: dynamic arrays and associative arrays are not properly printed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3391

           Summary: gdb: dynamic arrays and associative arrays are not
                    properly printed
           Product: D
           Version: 1.048
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: llucax gmail.com


--- Comment #0 from Leandro Lucarella <llucax gmail.com> 2009-10-12 16:08:36
PDT ---
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...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3391



--- Comment #1 from Leandro Lucarella <llucax gmail.com> 2009-10-17 18:00:47
PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3391



--- Comment #2 from Leandro Lucarella <llucax gmail.com> 2009-10-17 18:01:47
PDT ---
Created an attachment (id=478)
objdump -W for DMD

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3391



--- Comment #3 from Leandro Lucarella <llucax gmail.com> 2009-10-17 18:02:23
PDT ---
Created an attachment (id=479)
objdump -W for LDC

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 17 2009