ack/util/grind/dump.c
1990-08-31 18:22:53 +00:00

66 lines
1.1 KiB
C

/* $Header$ */
#include <assert.h>
#include <alloc.h>
#include "operator.h"
#include "position.h"
#include "tree.h"
#include "message.h"
extern long pointer_size;
extern p_tree get_from_item_list();
struct dump {
char *globals, *stack;
struct message_hdr mglobal, mstack;
};
/* dumping and restoring of child process.
*/
do_dump(p)
p_tree p;
{
struct dump *d = (struct dump *) Malloc(sizeof(struct dump));
if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) {
error("no debuggee");
free((char *) d);
return;
}
p->t_args[0] = (struct tree *) d;
p->t_address = (t_addr) BUFTOA(d->mglobal.m_buf+PC_OFF*pointer_size);
add_to_item_list(p);
}
/* dumping and restoring of child process.
*/
do_restore(p)
p_tree p;
{
struct dump *d;
p = get_from_item_list((int) p->t_ival);
if (!p || p->t_oper != OP_DUMP) {
error("no such dump");
return;
}
d = (struct dump *) p->t_args[0];
if (! put_dump(&d->mglobal, d->globals, &d->mstack, d->stack)) {
error("no debuggee");
}
do_items();
}
free_dump(p)
p_tree p;
{
struct dump *d = (struct dump *) p->t_args[0];
free(d->globals);
free(d->stack);
free((char *) d);
}