1990-08-31 18:22:53 +00:00
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <alloc.h>
|
|
|
|
|
|
|
|
#include "operator.h"
|
|
|
|
#include "position.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "message.h"
|
1990-09-25 17:40:47 +00:00
|
|
|
#include "type.h"
|
|
|
|
#include "expr.h"
|
1990-08-31 18:22:53 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
{
|
1990-09-26 17:32:42 +00:00
|
|
|
struct dump *d = (struct dump *) malloc(sizeof(struct dump));
|
1990-08-31 18:22:53 +00:00
|
|
|
|
1990-09-26 17:32:42 +00:00
|
|
|
if (! d) {
|
|
|
|
error("could not allocate enough memory");
|
|
|
|
return;
|
|
|
|
}
|
1990-08-31 18:22:53 +00:00
|
|
|
if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) {
|
|
|
|
free((char *) d);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p->t_args[0] = (struct tree *) d;
|
1990-09-25 17:40:47 +00:00
|
|
|
p->t_address = (t_addr) get_int(d->mglobal.m_buf+PC_OFF*pointer_size, pointer_size, T_UNSIGNED);
|
1990-08-31 18:22:53 +00:00
|
|
|
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);
|
|
|
|
}
|