Some more changes

This commit is contained in:
ceriel 1990-09-26 17:32:42 +00:00
parent bc6df29be8
commit a6d0f40fc8
2 changed files with 24 additions and 10 deletions

View file

@ -23,10 +23,13 @@ struct dump {
do_dump(p) do_dump(p)
p_tree p; p_tree p;
{ {
struct dump *d = (struct dump *) Malloc(sizeof(struct dump)); struct dump *d = (struct dump *) malloc(sizeof(struct dump));
if (! d) {
error("could not allocate enough memory");
return;
}
if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) { if (! get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack)) {
error("no debuggee");
free((char *) d); free((char *) d);
return; return;
} }

View file

@ -212,16 +212,18 @@ ureceive(p, c)
long c; long c;
{ {
int i; int i;
char buf[0x1000];
if (! child_pid) return 0; if (! child_pid) return 0;
if (! p) p = buf;
while (c >= 0x1000) { while (c >= 0x1000) {
i = read(from_child, p, 0x1000); i = read(from_child, p, 0x1000);
if (i <= 0) { if (i <= 0) {
if (i == 0) child_pid = 0; if (i == 0) child_pid = 0;
return 0; return 0;
} }
p += i; if (p != buf) p += i;
c -= i; c -= i;
} }
while (c > 0) { while (c > 0) {
@ -317,12 +319,12 @@ could_send(m, stop_message)
init_run(); init_run();
if (child_status & 0177) { if (child_status & 0177) {
fprintf(db_out, fprintf(db_out,
"Child died with signal %d\n", "child died with signal %d\n",
child_status & 0177); child_status & 0177);
} }
else { else {
fprintf(db_out, fprintf(db_out,
"Child terminated, exit status %d\n", "child terminated, exit status %d\n",
child_status >> 8); child_status >> 8);
} }
return 1; return 1;
@ -414,25 +416,34 @@ get_dump(globmessage, globbuf, stackmessage, stackbuf)
m.m_type = DUMP; m.m_type = DUMP;
if (! could_send(&m, 0)) { if (! could_send(&m, 0)) {
error("no debuggee");
return 0; return 0;
} }
if (answer.m_type == FAIL) return 0; if (answer.m_type == FAIL) return 0;
assert(answer.m_type == DGLOB); assert(answer.m_type == DGLOB);
*globmessage = answer; *globmessage = answer;
*globbuf = Malloc((unsigned) answer.m_size); *globbuf = malloc((unsigned) answer.m_size);
if (! ureceive(*globbuf, answer.m_size) || ! ugetm(stackmessage)) { if (! ureceive(*globbuf, answer.m_size) || ! ugetm(stackmessage)) {
free(*globbuf); if (*globbuf) free(*globbuf);
error("no debuggee");
return 0; return 0;
} }
assert(stackmessage->m_type == DSTACK); assert(stackmessage->m_type == DSTACK);
*stackbuf = Malloc((unsigned) stackmessage->m_size); *stackbuf = malloc((unsigned) stackmessage->m_size);
if (! ureceive(*stackbuf, stackmessage->m_size)) { if (! ureceive(*stackbuf, stackmessage->m_size)) {
free(*globbuf); if (*globbuf) free(*globbuf);
free(*stackbuf); if (*stackbuf) free(*stackbuf);
error("no debuggee");
return 0; return 0;
} }
put_int(globmessage->m_buf+SP_OFF*pointer_size, pointer_size, put_int(globmessage->m_buf+SP_OFF*pointer_size, pointer_size,
get_int(stackmessage->m_buf+SP_OFF*pointer_size, pointer_size, T_UNSIGNED)); get_int(stackmessage->m_buf+SP_OFF*pointer_size, pointer_size, T_UNSIGNED));
if (! *globbuf || ! *stackbuf) {
error("could not allocate enough memory");
if (*globbuf) free(*globbuf);
if (*stackbuf) free(*stackbuf);
return 0;
}
return 1; return 1;
} }