Re: [PATCH v4] infcall: Add support for integer literals as reference function paramters

Keith Seitz
2026-02-02T16:58:59Z

On 1/30/26 12:59 PM, Tom Tromey wrote:
>>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
>
> Keith> - Allocate to stack instead of heap
>
> I'm curious why this change was made.
> Often I think gdb just coerces to memory via malloc.

I was persuaded by another reviewer's comments[1]:

> This uses malloc to allocate the space. I was wondering if allocating
> space on the stack wouldn't be better. That's how arguments that are
> implicitly pass-by-reference are passed. Also struct return values
> are forced to lval in stack-allocated memory.
>
> Furthermore, malloc would not be possible everywhere (e.g. on GPUs);
> stack allocation would be supported by more platforms.

I was unable to conceive of a counterpoint to this last argument,
hence the change.

> Also other calls in this area seem to check
> thread_stack_temporaries_enabled_p. Not sure if that's needed?
> Maybe it's expected to be set and this can just be asserted?
>
> This is not really an area I know much about.

That makes two of us. I will look into the use of
thread_stack_temporaries_enabled_p.

> Keith> + if (new_value->lval () != lval_memory
> Keith> + && language_pass_by_reference (new_value->type ())
> Keith> + .trivially_copyable)
>
> This subexpression should be parenthesized and the '.' lined up with the
> 'l'.

Will do.

Thank you for taking a look,
Keith

[1]
https://inbox.sourceware.org/gdb-patches/92575c2eb6805095b41ebbe62ba99b81e4e5dd63.1760629738.git.keiths@redhat.com/T/#mc60c810be7d4054faa7699a453c00cdf6b21fc15