Changed LS/PS, ported to DEC VAX

This commit is contained in:
ceriel 1990-12-19 11:17:06 +00:00
parent c747f1c1c0
commit 6cc07a7651
7 changed files with 72 additions and 48 deletions

View file

@ -10,6 +10,7 @@
#include "symbol.h" #include "symbol.h"
#include "scope.h" #include "scope.h"
#include "Lpars.h" #include "Lpars.h"
#include "type.h"
static char *usage = "Usage: %s [<ack.out>] [<a.out>]"; static char *usage = "Usage: %s [<ack.out>] [<a.out>]";
char *progname; char *progname;
@ -52,11 +53,29 @@ main(argc, argv)
while (p = strindex(progname, '/')) { while (p = strindex(progname, '/')) {
progname = p + 1; progname = p + 1;
} }
if (argv[1] && argv[1][0] == '-') { while (argv[1] && argv[1][0] == '-') {
switch(argv[1][1]) { switch(argv[1][1]) {
case 'd': case 'v':
debug++; debug++;
break; break;
case 'i':
int_size = atoi(&argv[1][2]);
break;
case 's':
short_size = atoi(&argv[1][2]);
break;
case 'l':
long_size = atoi(&argv[1][2]);
break;
case 'f':
float_size = atoi(&argv[1][2]);
break;
case 'd':
double_size = atoi(&argv[1][2]);
break;
case 'p':
pointer_size = atoi(&argv[1][2]);
break;
default: default:
fatal(usage, progname); fatal(usage, progname);
} }

View file

@ -9,13 +9,8 @@
#define m_type m_buf[0] #define m_type m_buf[0]
#ifdef DEBUGGEE #define PS 4
#define PS sizeof(char *) #define LS 4
#define LS sizeof(long)
#else
#define PS pointer_size
#define LS long_size
#endif
struct message_hdr { struct message_hdr {
char m_buf[BUFLEN]; char m_buf[BUFLEN];

View file

@ -13,7 +13,6 @@
#include "expr.h" #include "expr.h"
extern FILE *db_out; extern FILE *db_out;
extern long float_size, pointer_size, int_size;
extern char *strindex(); extern char *strindex();
static static

View file

@ -4,7 +4,10 @@
#include "rd.h" #include "rd.h"
#if (defined(sun) && defined(mc68020)) || defined(vax)
#if defined(sun) && defined(mc68020) #if defined(sun) && defined(mc68020)
#define relocation_info reloc_info_68k
#endif
#include <a.out.h> #include <a.out.h>
#include <stdio.h> #include <stdio.h>
@ -34,18 +37,24 @@ rd_ohead(h)
h->oh_stamp = 0; h->oh_stamp = 0;
h->oh_nsect = 4; h->oh_nsect = 4;
h->oh_nname = 3 + bh.a_syms / sizeof(struct nlist); h->oh_nname = 3 + bh.a_syms / sizeof(struct nlist);
h->oh_nrelo = (bh.a_trsize + bh.a_drsize) / sizeof(struct reloc_info_68k); h->oh_nrelo = (bh.a_trsize + bh.a_drsize) / sizeof(struct relocation_info);
h->oh_flags = h->oh_nrelo ? HF_LINK : 0; h->oh_flags = h->oh_nrelo ? HF_LINK : 0;
#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec); if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec);
#endif
h->oh_nemit = bh.a_text + bh.a_data; h->oh_nemit = bh.a_text + bh.a_data;
#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec); if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec);
#endif
fseek(inf, N_STROFF(bh), 0); fseek(inf, N_STROFF(bh), 0);
h->oh_nchar = getw(inf) + 6 + 6 + 5 - 4; /* ".text", ".data", ".bss", h->oh_nchar = getw(inf) + 6 + 6 + 5 - 4; /* ".text", ".data", ".bss",
minus the size word */ minus the size word */
seg_strings = h->oh_nchar - 17; seg_strings = h->oh_nchar - 17;
if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec); fseek(inf, N_TXTOFF(bh)+bh.a_text+bh.a_data, 0);
fseek(inf, sizeof(struct exec) + bh.a_text + bh.a_data, 0);
hh = *h; hh = *h;
#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec);
#endif
} }
/*ARGSUSED1*/ /*ARGSUSED1*/
@ -117,7 +126,9 @@ rd_string(strings, count)
register char *strings; register char *strings;
long count; long count;
{ {
#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec); if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec);
#endif
fseek(inf, N_STROFF(bh)+4, 0); fseek(inf, N_STROFF(bh)+4, 0);
if (! readf(strings, (int)count-17, 1)) rd_fatal(); if (! readf(strings, (int)count-17, 1)) rd_fatal();
strings += count-17; strings += count-17;

View file

@ -220,7 +220,7 @@ start_child(p)
init_run(); init_run();
return; return;
} }
curr_stop = BUFTOI(m.m_buf+1, (int) PS); curr_stop = BUFTOI(m.m_buf+1, PS);
CurrentScope = get_scope_from_addr(curr_stop); CurrentScope = get_scope_from_addr(curr_stop);
} }
perform_items(); perform_items();
@ -407,7 +407,7 @@ could_send(m, stop_message)
if (! level) { if (! level) {
child_interrupted = 0; child_interrupted = 0;
interrupted = 0; interrupted = 0;
return stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, (int)PS), 0); return stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, PS), 0);
} }
return 1; return 1;
} }
@ -428,7 +428,7 @@ could_send(m, stop_message)
level--; level--;
return 1; return 1;
} }
a = BUFTOI(answer.m_buf+1, (int)PS); a = BUFTOI(answer.m_buf+1, PS);
type = answer.m_type & 0377; type = answer.m_type & 0377;
if (type == M_END_SS) type = 0; if (type == M_END_SS) type = 0;
else if (type == M_OK || type == M_DB_SS) type = 1; else if (type == M_OK || type == M_DB_SS) type = 1;
@ -475,8 +475,8 @@ getbytes(size, from, to, kind, errmess)
struct message_hdr m; struct message_hdr m;
m.m_type = kind; m.m_type = kind;
ITOBUF(m.m_buf+1, size, (int) LS); ITOBUF(m.m_buf+1, size, LS);
ITOBUF(m.m_buf+LS+1, (long)from, (int) PS); ITOBUF(m.m_buf+LS+1, (long)from, PS);
if (! could_send(&m, 0)) { if (! could_send(&m, 0)) {
return 0; return 0;
@ -490,7 +490,7 @@ getbytes(size, from, to, kind, errmess)
if (errmess) error("interrupted"); if (errmess) error("interrupted");
return 0; return 0;
case M_DATA: case M_DATA:
return ureceive(to, BUFTOI(answer.m_buf+1, (int)LS)); return ureceive(to, BUFTOI(answer.m_buf+1, LS));
default: default:
assert(0); assert(0);
} }
@ -514,7 +514,7 @@ get_string(size, from, to)
{ {
int retval = getbytes(size, from, to, M_GETSTR, 0); int retval = getbytes(size, from, to, M_GETSTR, 0);
to[(int)BUFTOI(answer.m_buf+1, (int)LS)] = 0; to[(int)BUFTOI(answer.m_buf+1, LS)] = 0;
return retval; return retval;
} }
@ -527,8 +527,8 @@ set_bytes(size, from, to)
struct message_hdr m; struct message_hdr m;
m.m_type = M_SETBYTES; m.m_type = M_SETBYTES;
ITOBUF(m.m_buf+1, size, (int) LS); ITOBUF(m.m_buf+1, size, LS);
ITOBUF(m.m_buf+LS+1, (long) to, (int) PS); ITOBUF(m.m_buf+LS+1, (long) to, PS);
if (! uputm(&m) || ! usend(from, size) || ! ugetm(&m)) { if (! uputm(&m) || ! usend(from, size) || ! ugetm(&m)) {
return; return;
@ -572,7 +572,7 @@ get_dump(globbuf, stackbuf)
assert(0); assert(0);
} }
sz = BUFTOI(answer.m_buf+1, (int)LS); sz = BUFTOI(answer.m_buf+1, LS);
*globbuf = malloc((unsigned) (sz+sizeof(struct message_hdr))); *globbuf = malloc((unsigned) (sz+sizeof(struct message_hdr)));
if (! *globbuf if (! *globbuf
|| ! ureceive(*globbuf+sizeof(struct message_hdr), sz) || ! ureceive(*globbuf+sizeof(struct message_hdr), sz)
@ -585,7 +585,7 @@ get_dump(globbuf, stackbuf)
*globm = answer; *globm = answer;
assert(m.m_type == M_DSTACK); assert(m.m_type == M_DSTACK);
sz = BUFTOI(m.m_buf+1, (int)LS); sz = BUFTOI(m.m_buf+1, LS);
*stackbuf = malloc((unsigned) sz+sizeof(struct message_hdr)); *stackbuf = malloc((unsigned) sz+sizeof(struct message_hdr));
if (! *stackbuf || ! ureceive(*stackbuf+sizeof(struct message_hdr), sz)) { if (! *stackbuf || ! ureceive(*stackbuf+sizeof(struct message_hdr), sz)) {
free(*globbuf); free(*globbuf);
@ -595,8 +595,8 @@ get_dump(globbuf, stackbuf)
} }
stackm = (struct message_hdr *) *stackbuf; stackm = (struct message_hdr *) *stackbuf;
*stackm = m; *stackm = m;
ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, (int)PS), (int) PS); ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, PS), PS);
return BUFTOI(globm->m_buf+PC_OFF, (int)PS); return BUFTOI(globm->m_buf+PC_OFF, PS);
} }
int int
@ -615,11 +615,11 @@ put_dump(globbuf, stackbuf)
restoring = 0; restoring = 0;
} }
return uputm(globm) return uputm(globm)
&& usend(globbuf, BUFTOI(globm->m_buf+1, (int) LS)) && usend(globbuf, BUFTOI(globm->m_buf+1, LS))
&& uputm(stackm) && uputm(stackm)
&& usend(stackbuf, BUFTOI(stackm->m_buf+1, (int) LS)) && usend(stackbuf, BUFTOI(stackm->m_buf+1, LS))
&& ugetm(&m) && ugetm(&m)
&& stopped("restored", BUFTOI(m.m_buf+1, (int) PS), 0); && stopped("restored", BUFTOI(m.m_buf+1, PS), 0);
} }
t_addr * t_addr *
@ -631,7 +631,7 @@ get_EM_regs(level)
register t_addr *to = &buf[0]; register t_addr *to = &buf[0];
m.m_type = M_GETEMREGS; m.m_type = M_GETEMREGS;
ITOBUF(m.m_buf+1, (long) level, (int) LS); ITOBUF(m.m_buf+1, (long) level, LS);
if (! could_send(&m, 0)) { if (! could_send(&m, 0)) {
return 0; return 0;
@ -648,11 +648,11 @@ get_EM_regs(level)
default: default:
assert(0); assert(0);
} }
*to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, (int)PS); *to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, PS);
*to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, (int)PS); *to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, PS);
*to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS); *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS);
*to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, (int)PS); *to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, PS);
*to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS); *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS);
return buf; return buf;
} }
@ -663,7 +663,7 @@ set_pc(PC)
struct message_hdr m; struct message_hdr m;
m.m_type = M_SETEMREGS; m.m_type = M_SETEMREGS;
ITOBUF(m.m_buf+PC_OFF, (long)PC, (int)PS); ITOBUF(m.m_buf+PC_OFF, (long)PC, PS);
if (! could_send(&m, 0)) return 0; if (! could_send(&m, 0)) return 0;
switch(answer.m_type) { switch(answer.m_type) {
case M_FAIL: case M_FAIL:
@ -698,7 +698,7 @@ singlestep(type, count)
struct message_hdr m; struct message_hdr m;
m.m_type = (type ? M_SETSSF : M_SETSS) | (db_ss ? M_DB_SS : 0); m.m_type = (type ? M_SETSSF : M_SETSS) | (db_ss ? M_DB_SS : 0);
ITOBUF(m.m_buf+1, count, (int) LS); ITOBUF(m.m_buf+1, count, LS);
single_stepping = 1; single_stepping = 1;
if (could_send(&m, 1) && child_pid) return 1; if (could_send(&m, 1) && child_pid) return 1;
single_stepping = 0; single_stepping = 0;
@ -713,7 +713,7 @@ set_or_clear_breakpoint(a, type)
struct message_hdr m; struct message_hdr m;
m.m_type = type ? M_SETBP : M_CLRBP; m.m_type = type ? M_SETBP : M_CLRBP;
ITOBUF(m.m_buf+1, (long) a, (int) PS); ITOBUF(m.m_buf+1, (long) a, PS);
if (debug) printf("%s breakpoint at 0x%lx\n", type ? "setting" : "clearing", (long) a); if (debug) printf("%s breakpoint at 0x%lx\n", type ? "setting" : "clearing", (long) a);
if (child_pid && ! could_send(&m, 0)) { if (child_pid && ! could_send(&m, 0)) {
} }
@ -729,8 +729,8 @@ set_or_clear_trace(start, end, type)
struct message_hdr m; struct message_hdr m;
m.m_type = type ? M_SETTRACE : M_CLRTRACE; m.m_type = type ? M_SETTRACE : M_CLRTRACE;
ITOBUF(m.m_buf+1, (long)start, (int) PS); ITOBUF(m.m_buf+1, (long)start, PS);
ITOBUF(m.m_buf+PS+1, (long)end, (int) PS); ITOBUF(m.m_buf+PS+1, (long)end, PS);
if (debug) printf("%s trace at [0x%lx,0x%lx]\n", type ? "setting" : "clearing", (long) start, (long) end); if (debug) printf("%s trace at [0x%lx,0x%lx]\n", type ? "setting" : "clearing", (long) start, (long) end);
if (child_pid && ! could_send(&m, 0)) { if (child_pid && ! could_send(&m, 0)) {
return 0; return 0;

View file

@ -7,7 +7,6 @@
#include "idf.h" #include "idf.h"
#include "type.h" #include "type.h"
#include "sizes.h"
#include "symbol.h" #include "symbol.h"
#include "scope.h" #include "scope.h"
#include "langdep.h" #include "langdep.h"
@ -19,14 +18,14 @@ p_type void_type;
p_type float_type, double_type; p_type float_type, double_type;
p_type string_type, address_type; p_type string_type, address_type;
long int_size = SZ_INT, long int_size = sizeof(int),
char_size = 1, char_size = 1,
short_size = SZ_SHORT, short_size = sizeof(short),
long_size = SZ_LONG, long_size = sizeof(long),
pointer_size = SZ_POINTER; pointer_size = sizeof(char *);
long float_size = SZ_FLOAT, long float_size = sizeof(float),
double_size = SZ_DOUBLE; double_size = sizeof(double);
struct bounds { struct bounds {
long low, high; long low, high;

View file

@ -119,5 +119,6 @@ extern long
extern p_type char_type, uchar_type, bool_type, int_type, extern p_type char_type, uchar_type, bool_type, int_type,
long_type, double_type, string_type, address_type; long_type, double_type, string_type, address_type;
extern p_type void_type; extern p_type void_type;
extern long int_size, pointer_size, long_size, double_size; extern long int_size, short_size, pointer_size, long_size,
float_size, double_size;