zend_call_stack.c: AIX backend - #22906
Conversation
Uses pthread_getthrds_np (so requires pthread linked, by default on ZTS, needs to be added for NTS). The stack size part is weird, but works in testing. An alternative approach is using procfs, but I didn't bother with this due to it not working on PASE (and the pthread approach works for the main thread too).
| * pthread->pt_stk.st_base is __pi_stackaddr, | ||
| * below that is the red zone | ||
| */ | ||
| stack->base = thread_info.__pi_stackend; |
There was a problem hiding this comment.
for me the calculation is right but I wonder why you need a buffer of 256, for example the openjdk only sets to 1.
There was a problem hiding this comment.
WRT registers/size param, I think it may just be unnecessary, the man page on the register size argument:
The pointer to the size of the regbuf buffer. On input, it identifies the maximum size of the buffer in bytes. On output, it identifies the number of bytes of register save data and pass the TLS information. If the thread is not in a system call, there is no register save data returned from the kernel, and regbufsize is 0. If the size of the register save data is larger than the input value of regbufsize, the number of bytes specified by the input value of regbufsize is copied to regbuf, pthread_getthrds_np() returns ERANGE, and the output value of regbufsize specifies the number of bytes required to hold all of the register save data.
Since we call this function only on our own thread, and not on a different one, we never need to save the registers. In a test program, I was able to set the register buffer to NULL and the size buffer to 0 (this can't be a null pointer sadly).
...and pass a NULL register buffer, since this is only used with suspended threads. something that'll never happen if we invoke it on ourself. We still need to pass the size though.
Uses pthread_getthrds_np (so requires pthread linked, by default on ZTS, needs to be added for NTS). The stack size part is weird, but works in testing.
An alternative approach is using procfs, but I didn't bother with this due to it not working on PASE (and the pthread approach works for the main thread too).