[Dwarf-Discuss] DW_AT_default_value reference to "subroutine"

Robinson, Paul Paul_Robinson@playstation.sony.com
Wed Sep 17 21:46:06 GMT 2014


Interestingly, one of the suggestions on the LLVM list was also a string providing the expression for the debugger to evaluate. The C++ standard is well-defined when it comes to how to evaluate the expression, but I can see for the debugger it would be harder.

I'll file an issue to resolve the DW_AT_default_value "subroutine" thing (I've found other related terminology issues so it seemed prudent to file them all together as one issue for everyone to look at).
--paulr

From: Ron Brender [mailto:ron.brender@gmail.com]
Sent: Tuesday, September 16, 2014 2:08 PM
To: Robinson, Paul
Cc: DWARF (dwarf-discuss at lists.dwarfstd.org)
Subject: Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"

Looking back through old email and DWARF drafts, I find:
The constant/variable null reference implies no default verbiage existed in V2 (as others have noted). Al Grant (by way of David Anderson) first raised the issue of why a reference to an otherwise unnecessary constant should be needed to handle the simple case of a constant in about Sept 2004. This eventually became Issue 040909.1 (Matthew Gretton-Dann was the champion). The allowance of constant forms first shows up in DW3 draft 9.5 in July 2005.
The matter of calling a function was discussed only once that I can find. One suggestion was to allow a form string to specify text that the debugger was to evaluate (including making a function call). This achieved no traction (issues of scope and closures abound). Someone else noted that in one implementation the compiler creates an anonymous function that just contains the full call, with arguments as needed. This was thought "too complicated". And there the matter was dropped.
The summary appears to be: Back in 2005, the reference to subroutine problem was noted and discussed with no action taken. And here we are nine years later...
Ron,
Your editor and historian

On Tue, Sep 16, 2014 at 3:32 PM, Robinson, Paul <Paul_Robinson at playstation.sony.com<mailto:Paul_Robinson at playstation.sony.com>> wrote:
The DW_AT_default_value attribute on a formal_parameter DIE can be used to
express a default argument for the parameter; C++ allows this, for example.
    int foo(int a, int b = 2);
    int bar(int x = foo(3)); // default for x is foo(3,2)
The description of the attribute in DWARF 4 (section 4.1 item 9, p.70)
says it can be a reference to "a variable or subroutine" as well as a
constant. What it means for a variable or constant is pretty obvious; but
it's not really clear about subroutines.  DWARF 4 says it's "the value
returned by the referenced subroutine."

Is this "subroutine" actually a DW_TAG_subprogram DIE?  That's not
expressive enough for the full glory of C++ default arguments.  It's
not even expressive enough to allow the debugger to call a single
arbitrary compiled function, as there's no way to express what
parameters to pass to the compiled function.

Is this "subroutine" actually a DWARF procedure?  That suggests it
should be evaluated like DW_OP_call_ref, which allows executing an
arbitrary DWARF expression, but a DWARF expression can't actually
describe calling a compiled function.

Any old-timers out there who can shed light on the intent of this
terminology?  I see similar verbiage all the way back to DWARF 2.
Thanks,
--paulr

_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss at lists.dwarfstd.org<mailto:Dwarf-Discuss at lists.dwarfstd.org>
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20140917/44e5b549/attachment.htm>



More information about the Dwarf-discuss mailing list