Jump to page: 1 2
Thread overview
[Issue 4149] New: refs displayed as pointers in gdb
May 02, 2010
Brad Roberts
May 02, 2010
Robert Clipsham
May 02, 2010
Brad Roberts
May 02, 2010
Robert Clipsham
May 02, 2010
Brad Roberts
May 02, 2010
Robert Clipsham
May 02, 2010
Walter Bright
May 09, 2010
Brad Roberts
May 09, 2010
Brad Roberts
May 09, 2010
Brad Roberts
May 09, 2010
Robert Clipsham
Jan 19, 2012
Walter Bright
Jan 19, 2012
Brad Roberts
Jan 26, 2012
Leandro Lucarella
Jan 31, 2012
dawg@dawgfoto.de
Feb 01, 2012
Leandro Lucarella
Feb 02, 2012
Brad Roberts
Feb 02, 2012
dawg@dawgfoto.de
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149

           Summary: refs displayed as pointers in gdb
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: braddr@puremagic.com
            Blocks: 4044


--- Comment #0 from Brad Roberts <braddr@puremagic.com> 2010-05-02 13:36:57 PDT ---
(gdb) list inline.d:1
1  module test.d;
2
3  void foo(ref int x)
4  {
5      ++x;
6  }
7
8  void bar()
9  {
10     int x = 0;
11
12     foo(x);
13 }
14
15 void main()
16 {
17     bar();
18 }

(gdb) break 5
Breakpoint 1 at 0x804910d: file inline.d, line 5.
(gdb) run
Breakpoint 1, test.d.foo (x=0xbffff62c) at inline.d:5
5      ++x;
(gdb) print x
$1 = (int *) 0xbffff62c

Assuming I'm understanding the dwarf records correctly, foo's argument:
 <2><a2>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <a3>   DW_AT_name        : x
    <a5>   DW_AT_type        : <0x69>
    <a9>   DW_AT_location    : 2 byte block: 91 7c    (DW_OP_fbreg: -4)

And type 0x69:
 <1><69>: Abbrev Number: 4 (DW_TAG_pointer_type)
    <6a>   DW_AT_byte_size   : 4
    <6b>   DW_AT_type        : <0x62>


Dwarf formally supports a reference type according to the spec.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149


Robert Clipsham <robert@octarineparrot.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robert@octarineparrot.com


--- Comment #1 from Robert Clipsham <robert@octarineparrot.com> 2010-05-02 21:44:31 BST ---
This is done because C does not have reference types, and no debugger currently supports the debug output produced by dmd when using -g. When using -g dmd should, as you say, use the DWARF reference type, which it does not currently do. When using -gc, it should be a pointer as it is now. I'll try and put a patch together later today. As a side note, classes should be reference types too, rather than acting as pointers as they do currently.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2010-05-02 13:48:41 PDT ---
Depends on if gc implies c, c++, or 'as much as is supported in the built-in debug format without extension'.

I'd argue for the last definition.  Given that dwarf supports it without extension, I'd argue that it should use it.  I'd argue that -g should be built-in + d extensions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #3 from Robert Clipsham <robert@octarineparrot.com> 2010-05-02 21:50:30 BST ---
-gc means act as C. I think I'm going to talk to Walter about this actually, as the debugging situation for D could be far better.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #4 from Brad Roberts <braddr@puremagic.com> 2010-05-02 14:15:36 PDT ---
I've been looking at how to patch up that part of the code, and it looks like the ref-ness has been lost at this layer:

(gdb) print *t
$2 = {id = 4660, Tty = 29, Tflags = 0, Tmangle = 7 '\a', Tcount = 1, Tnext =
0x81ffd20, {Tdim = 0, Tel = 0x0, Tparamtypes = 0x0, Ttag = 0x0, Tident = 0x0,
Tkey = 0x0}, Texcspec = 0x0}
(gdb) print t->Tnext
$3 = (TYPE *) 0x81ffd20
(gdb) print t->Tnext[0]
$4 = {id = 4660, Tty = 10, Tflags = 0, Tmangle = 0 '\000', Tcount = 3, Tnext =
0x0, {Tdim = 0, Tel = 0x0, Tparamtypes = 0x0, Ttag = 0x0, Tident = 0x0, Tkey =
0x0}, Texcspec = 0x0}

Tty 29 == 0x1d == TYnptr

If it was still a TYnref, it'd be easy.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #5 from Robert Clipsham <robert@octarineparrot.com> 2010-05-02 22:17:49 BST ---
It is easy, I wrote the patch that adds support for ref types to the debug info ;) The refness isn't lost, it just uses the same case statement, and thus gets replaced. I'm about to write a patch for it now :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2010-05-02 16:14:03 PDT ---
I agree with Brad's comment 2.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #7 from Brad Roberts <braddr@puremagic.com> 2010-05-09 01:09:56 PDT ---
Created an attachment (id=625)
Fix some plumbing and change the dwarf code to emit ref types.

The ref'ness was lost before it got into the dwarf stage, but also easy to fix, assuming that Walter is right about the backend being ready to handle TYref's now.

I've attached the diff I've whipped up.  It does work to emit the right debug info, but I haven't tested it on much more than the simplest code (specifically, the code at the top of this bug report).

A snippit from a gdb session:

Breakpoint 1, test.foo (x=@0xbffff62c) at inline.d:5
5      ++x;
(gdb) print x
$1 = (int &) @0xbffff62c: 0
(gdb) next
0x08049112 in test.foo (x=@0xbffff62c)
(gdb) print x
$2 = (int &) @0xbffff62c: 1

So, gdb is using C++ style demangling, but that can be addressed by someone working on gdb.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
    Attachment #625|application/octet-stream    |text/plain
          mime type|                            |
 Attachment #625 is|0                           |1
              patch|                            |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4149



--- Comment #8 from Brad Roberts <braddr@puremagic.com> 2010-05-09 04:29:06 PDT ---
Looks like one more minor change is needed to build phobos with these changes:

backed/cgcod.c:
@@ -1508,6 +1508,7 @@ regm_t regmask(tym_t tym, tym_t tyf)
         case TYnptr:
         case TYsptr:
         case TYcptr:
+        case TYref:
             return mAX;
         case TYfloat:
         case TYifloat:

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2