[Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
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@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
On 09/16/2014 12:32 PM, Robinson, Paul wrote: > 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, Paul, could you be more specific about where the 'similar verbiage' is? Thanks. DavidA. ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
DWARF v2, Section 4.1: 8. A formal parameter entry describing a formal parameter that has a default value may have a DW_AT_default_value attribute. The value of this attribute is a reference to the debugging information entry for a variable or subroutine. The default value of the parameter is the value of the variable (which may be constant) or the value returned by the subroutine. If the value of the DW_AT_default_value attribute is 0, it means that no default value has been specified. DWARF v3, Section 4.1: 9. A formal parameter entry may have a DW_AT_default_value attribute. The value of this attribute is a reference to the debugging information entry for a variable or subroutine, or the value may be a constant. If it is a reference, the default value of the parameter is the value of the variable (which may be constant) or the value returned by the subroutine. If the value of the DW_AT_default_value attribute is 0, it means that no default value has been specified. If the value is of form constant, that constant is interpreted as a value of the type of the formal parameter. For a constant form there is no way to express the absence of a default value. DWARF v4, Section 4.1: 9. A DW_AT_default_value attribute for a formal parameter entry. The value of this attribute is a reference to the debugging information entry for a variable or subroutine, or the value may be a constant. If the attribute form is of class reference, the default value of the parameter is the value of the referenced variable (which may be constant) or the value returned by the referenced subroutine; a reference value of 0 means that no default value has been specified. If the value is of class constant, that constant is interpreted as a default value of the type of the formal parameter. For a constant form there is no way to express the absence of a default value. -cary On Tue, Sep 16, 2014 at 1:32 PM, David Anderson wrote: > On 09/16/2014 12:32 PM, Robinson, Paul wrote: >> 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, > > > Paul, could you be more specific about where the 'similar verbiage' is? > Thanks. > DavidA. > > > ___ > Dwarf-Discuss mailing list > Dwarf-Discuss@lists.dwarfstd.org > http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
> Paul, could you be more specific about where the 'similar verbiage' is? > Thanks. > DavidA. In DWARF 2, section 4.1 item 8 on p.34. In DWARF 3, section 4.1 item 9 on p.60. In DWARF 4, section 4.1 item 9 on p.70. DWARF 2 did not say the attribute could be a constant; that appeared in DWARF 3. Each edition had some editorial massaging that doesn't affect the semantics; for example the first sentence evolved as follows. v2: A formal parameter entry describing a formal parameter that has a default value may have a DW_AT_default_value attribute. v3: A formal parameter entry may have a DW_AT_default_value attribute. v4: A DW_AT_default_value attribute for a formal parameter entry. ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
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_robin...@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@lists.dwarfstd.org > http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org > ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
On 09/16/14 12:32, Robinson, Paul 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. See issue 040909.1 (DWARF Version 3): http://dwarfstd.org/ShowIssue.php?issue=040909.1 -- Michael Eagerea...@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
Re: [Dwarf-Discuss] DW_AT_default_value reference to "subroutine"
On 09/16/2014 01:50 PM, Robinson, Paul wrote: >> Paul, could you be more specific about where the 'similar verbiage' is? >> Thanks. >> DavidA. > > In DWARF 2, section 4.1 item 8 on p.34. > In DWARF 3, section 4.1 item 9 on p.60. > In DWARF 4, section 4.1 item 9 on p.70. > My bad. Did not occur to me that you meant across versions, not within a version. Thank you Ron B and Mike E for the history! DavidA. ___ Dwarf-Discuss mailing list Dwarf-Discuss@lists.dwarfstd.org http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org