tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Interface to retrieve LWPs via ptrace(2)

On 03.11.2016 14:10, Joerg Sonnenberger wrote:
> On Tue, Nov 01, 2016 at 03:58:10PM +0100, Kamil Rytarowski wrote:
>> Which one is preferred for NetBSD?
> I'd go with neither, but base the new interface on FreeBSD's.
> PT_GETLWPS takes as argument:
> struct ptrace_getinfos_request {
>   size_t allocated_lwps;
>   size_t current_lwps;
>   struct ptrace_lwpinfo[];
> }
> The caller provides allocated_lwps and promises that the buffer can hold
> sizeof(ptrace_getinfos_request) + allocated_lwps * sizeof(ptrace_lwpinfo)
> byte. The kernel writes up to allocated_lwps entries and sets
> current_lwps to the current total number of lwps. The caller can then
> easily check how many entries it has to allocate and maybe repeat the
> request.
> Joerg

For the reference ptrace_lwpinfo[] is a flexible array member from C99.
This construct will play well with reallocarr(3)-like functions.

I will prepare a prototype of this.

Attachment: signature.asc
Description: OpenPGP digital signature

Home | Main Index | Thread Index | Old Index