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

Aktemur, Tankut Baris
2026-02-02T17:23:13Z

On Monday, February 2, 2026 5:58 PM, Keith Seitz wrote:
> 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]:

I'm sorry :/

> > 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.

To make this work for GPUs, we can delegate space allocation to
a gdbarch method, while defining the current malloc-based behavior
as the default hook. Architectures that cannot use malloc can
handle the request their way. If they are not able to make
the allocation, an error may be returned, which is not worse than
the state before your change.

For example, Intel's downstream debugger would be able to allocate
some space in an area in GPU that is specifically reserved for
debugger's use.

Regards
-Baris

Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928