* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)frame.c 5.1 (Berkeley) 6/6/85";
* Activation record handling.
* The routines curframe and nextframe cheat by using a global copy
* of the display. This means there can't be multiple instances of
* them active at the same time and nextframe won't work in arbitrary cases.
* This could be solved by putting the display copy into the FRAME structure,
* but I didn't feel like doing this. The idea is that they be used
* in looping through all frames, if I had generators I would use them.
#include "process/pxinfo.h"
* Return a pointer to the current activation record.
* Return NIL if currently in the main program.
#define dispblk(dp) ((dp - DISPLAY) / 2)
LOCAL ADDRESS
*display
[MAXDEPTH
];
if (dispblk(dp
) <= MAINBLK
) {
for (i
= 1; i
< MAXDEPTH
; i
++) {
* Return a pointer to the next activation record up the stack.
* Return NIL if there is none.
* Writes over space pointed to by given argument.
if (dispblk(frp
->save_dp
) <= MAINBLK
) {
display
[dispindex
] = frp
->save_disp
;
dispindex
= dispblk(frp
->save_dp
);
* Return the frame associated with the given function.
frame
.save_disp
= contents(frame
.save_dp
);
for (frp
= curframe(); frp
!= NIL
; frp
= nextframe(frp
)) {
if (whatblock(entry(frp
)) == f
) {
* Get the activation record associated with the given display pointer.
LOCAL
getframe(frp
, disp
)
panic("bad disp in getframe");
dread(frp
, disp
, sizeof(FRAME
));
* Return the address of the display in the px process for the given block.
dread(&r
, (ADDRESS
) (DISPLAY
+ 2*b
), sizeof(r
));
* Return the current display pointer.
dread(&r
, (ADDRESS
) DP
, sizeof(r
));
* Return the contents of the given display pointer.
dread(&r
, (ADDRESS
) dp
, sizeof(r
));
* Return the px stack address associated with a given frame pointer.
* Actually, to confuse the issue we want the stack address of the
* frame one up from the given one.
return (ADDRESS
) display
[b
];