On Wed Oct 19 09:44:30 2022 +0000, Rémi Bernon wrote:
Okay, while `.cfi_same_value` in the clean-up part technically worked
for the tested unwinders, it was actually still wrong to use. The content of the register can be computed by looking at the register itself and not at the value previously computed by the previous frame (which does not exist at that point in time as we are in leaf-code). I'm not completely sure to follow you here. Doesn't `.cfi_same_value x` mean "at this point the value of the register is the same as the returning frame, and doesn't need restoration (ie: it has been restored already)". Isn't that, in effect, the exact same thing as `.cfi_register x, x`, even though it's encoded differently?
Regarding the XMM registers. I added the instructions, to be the
register content during the execution of the function and being the "same value" as the previous computation (i.e. the callee, i.e. the syscall) during the call. I was mostly asking out of curiosity, maybe it's not worth adding them. Now, the `.cfi_register xmmX, xmmX` at the top of the procedure seem a bit weird to me. Isn't that the default already, do we need to make it explicit?
Looking at GDB source I believe my understanding is correct, and so `.cfi_same_value` was right (and as we're using it already elsewhere, probably better):
```c case DWARF2_FRAME_REG_SAVED_REG: realnum = dwarf_reg_to_regnum_or_error (gdbarch, cache->reg[regnum].loc.reg); return frame_unwind_got_register (this_frame, regnum, realnum);
/* ... */
case DWARF2_FRAME_REG_UNSPECIFIED: /* GCC, in its infinite wisdom decided to not provide unwind information for registers that are "same value". Since DWARF2 (3 draft 7) doesn't define such behavior, said registers are actually undefined (which is different to CFI "undefined"). Code above issues a complaint about this. Here just fudge the books, assume GCC, and that the value is more inner on the stack. */ return frame_unwind_got_register (this_frame, regnum, regnum);
case DWARF2_FRAME_REG_SAME_VALUE: return frame_unwind_got_register (this_frame, regnum, regnum); ```
As you can see, it implements `.cfi_same_value x` the same as `.cfi_register x, x` here. It also assumes unspecified registers have a default of `.cfi_same_value` too, so I'd say it's not required to specify that for xmm register at the top of the function.