On 5/4/23 09:43, Bernd Oppolzer wrote:
Am 04.04.2023 um 23:37 schrieb Charles Mills:
I just had a similar problem: "how do you determine your entry R0 from C?" I asked here and got no answer.

with native C, this is not possible IMO;

It certainly is possible using inline "__asm" blocks. Check out IBM's zoslib which has a really load/call/delete functions that can also AMODE switch https://github.com/ibmruntimes/zoslib/blob/cc10b7c1d6211a2c28b10b540bf406c7148fbf4f/src/zos.cc#L1946



what I did: I wrote a (very small) ASSEMBLER routine which can be called from everywhere and simply stores the actual values of the registers 0 to 15 in a vector of 16 void pointers passed by the C caller.

something like

extern void ccregs (void **regs);

void *regtable [16];

...

ccregs (regtable);

this way, you get - for example - regtable [13], which is the content of GR 13 at the time of the ccregs call. GR 13 points to the current save area a.k.a. stack frame. From this save area, you can walk up to the save area of the caller and find the registers at the time of the call of the current function ... this can all be done using C. It is, BTW, even possible to analyse the whole save area chain this way, including the names and addresses etc. of the surrounding stack frames, and the entry point, return addresses and so on ... a complete stack trace, if you want. All this can be done during program run,
without interrupting or abending the current process or function.

Finding the R0 at the time of the call is very simple, once you have the current R13.

HTH, kind regards

Bernd

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to