* Copyright (c) 1980 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)frame.c 5.3 (Berkeley) 4/16/91";
* 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"
#include "process/process.rep"
* 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
];