||CIE initial state
The CFI is broken down into two parts - a CIE and an FDE. The CIE,
which is shared by multiple FDEs provides the initial settings for all
the registers (in INITIAL_INSTRUCTIONS).
What happens if a compiler fails to provide that information, or if that
information is [very] incomplete? What is the initial state of any
undefined registers? Undefined, ABI committee defined, compiler
The example in D.5:
[ example omitted here to save space.]
strongly suggests that the intent was for the compiler to provide a
completly populated initial table row, however I'm struggling to find
any definitive language in the spec proper supporting this.
The DWARF2/3 spec says the state is unspecified. That is, the
spec does not answer your question. As far as I've been able to tell.
I found this unappealing (to say the least) and for SGI/MIPS
the default setting is 'same value', a setting that makes
sense for the MIPS instruction set. So initial-instructions
need only have the registers that one expects have changed
when we get to the initial instruction.
(Rather than repeating 'same-value' for the rest of the registers.)
Our tools have been assuming that, for a register with no explicit initial
state in the CIE, its value must be "undefined". (If it's undefined, it must
be "undefined". :) ) Although I've seen lots of code that has no need to
distinguish between "undefined" and "same value".
BTW, GCC assumes same-value. To cut past an e-mail I'm just sending to GDB:
> Moreover, the algorithm I suggested that you use -- assume saved --
> is also completely independant of the ABI, so its' not like GDB
> needs to hard code ABI specific information either.
It doesn't work in general.
On a register window machine, it could use a fairly complex starting
locals: where saved on stack
output: in input
(register windows give me a headache so don't assume this one is correct :-)
It is open to per compiler interpretation.
Unless clearly defined by the spec, GCC's interpretation is strictly
that - GCCs interpretation. An alternative toolchain is equally at
liberty to start with the assumption that registers are undefined.
A complete CIE can make for more compact CFI
If the initial state is preserve->same and scratch->undefined, the CFI
need only describe the preserved registers that get moved.
My current best guess is that this is should be defined by either dwarf2
or the relevant ABI committee.
Yes. From the debugger and users point of view, I think "undefined" is
Marking it as undefined is less likely to lead to a situtation where the
debugger displays incorrect values (at the price of occasionally
displaying ``value undefined'' when it really is). On the other hand,
assuming ``same value'' can easily lead to the debugger displaying
values that are wrong. From the users view point, wrong values are far
worse than no values.
PROPOSAL (not Andrew Cagney's words, David Anderson's words.
Andrew may wish to change this to one of his suggestions
Add the following sentence to 6.4.1, CIE,
8) initial instructions (array of ubyte)
after the existing sentence.
"Default values for the columns before applying the
initial instructions are not provided. The ABI authoring
body or a compilation system authoring body should
specify a default value. In DWARF2 the default
value was not mentioned."
ALTERNATIVE PROPOSAL (not proposed, but is one alternative)
Add, before 8) initial instructions (array of ubyte) in 6.4.1:
8) default state (uleb128 value)
A single value, which is the 'default state' of
all registers before 'initial instructions' are applied.
Normaly would be the value of either DW_CFA_undefined or
In italics then add
The ABI authoring body or a compilation system authoring body
may specify a default value that applies after the
default state (for example, saying that different
classes of registers have different defaults).
In DWARF2 the default value was not mentioned.
2ND ALTERNATIVE PROPOSAL:
6.4.1, CIE, 8) initial instructions (array of ubyte)
The default rule for all columns before interpretation of the initial
instructions is the undefined rule. However, an ABI authoring body or a
compilation system authoring body may specify an alternate default value
for any or all columns. In DWARF2, the default value was not
Accepted 2nd Alternative.