On Wed, Apr 03, 2024 at 07:01:50PM +0800, Kewen.Lin wrote:
> Thanks for the details on debugging support, but IIUC with this workaround
> being adopted, the debuggability on hidden args are already broken, aren't?

No.
In the correct program case, which should be the usual case, the caller will
pass the arguments and one should be able to see the values in the debugger
even if the function doesn't actually use those arguments.
If the caller is buggy and doesn't pass those arguments, one should be able
to see garbage values for those arguments and perhaps that way figure out
that the program is buggy and fix it.

> Since with a usual caller, the actual argument is passed in argument save
> area, but the callee debug information says the location is %r11 or some
> other stack slot.
> 
> I think the difficulty is that: with this workaround, for some arguments we
> are lying they are not passed in argument save area, then we have to pretend
> they are passed in r11,r12..., but in fact these registers are not valid to
> pass arguments, so it's unreasonable and confusing.  With your explanation,
> I agree that stripping DECL_ARGUMENTS chains isn't a good way to eliminate
> this confusion, maybe always using GP_ARG_MIN_REG/GP_ARG_MAX_REG for things
> exceeding GP_ARG_MAX_REG can reduce the unreasonableness (but still confusing
> IMHO).

If those arguments aren't passed in r11/r12, but in memory, the workaround
shouldn't pretend they are passed somewhere where they aren't actually
passed.
Instead, it should load them from the memory where they are actually
normally passed.
What needs to be ensured though is that those arguments are for -O0 loaded
from those stack slots and saved to different stack slots (inside of the
callee frame, rather than in caller's frame), for -O1+ just not loaded at
all and pretended to just live in the caller's frame, and most importantly
ensure that the callee doesn't try to think there is a parameter save area
in the caller's frame which it can use for random saving related or
unrelated data.  So, e.g. REG_EQUAL/REG_EQUIV shouldn't be used, nor tell
that the 1st-8th arguments could be saved to the parameter save area.
So, for the 1st-8th arguments it really should act as if there is no
parameter save area and for the DECL_HIDDEN_STRING_LENGTH ones after it
as it those are passed in memory, but as if that memory is owned by the
caller, not callee, so it is not correct to modify that memory.

        Jakub

Reply via email to