diff --git a/util/grind/main.c b/util/grind/main.c index 2bf826634..9a08590f9 100644 --- a/util/grind/main.c +++ b/util/grind/main.c @@ -10,6 +10,7 @@ #include "symbol.h" #include "scope.h" #include "Lpars.h" +#include "type.h" static char *usage = "Usage: %s [] []"; char *progname; @@ -52,11 +53,29 @@ main(argc, argv) while (p = strindex(progname, '/')) { progname = p + 1; } - if (argv[1] && argv[1][0] == '-') { + while (argv[1] && argv[1][0] == '-') { switch(argv[1][1]) { - case 'd': + case 'v': debug++; 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: fatal(usage, progname); } diff --git a/util/grind/message.h b/util/grind/message.h index cf4b96dd5..6e71a517c 100644 --- a/util/grind/message.h +++ b/util/grind/message.h @@ -9,13 +9,8 @@ #define m_type m_buf[0] -#ifdef DEBUGGEE -#define PS sizeof(char *) -#define LS sizeof(long) -#else -#define PS pointer_size -#define LS long_size -#endif +#define PS 4 +#define LS 4 struct message_hdr { char m_buf[BUFLEN]; diff --git a/util/grind/print.c b/util/grind/print.c index a5f12a39d..e9f9a9b04 100644 --- a/util/grind/print.c +++ b/util/grind/print.c @@ -13,7 +13,6 @@ #include "expr.h" extern FILE *db_out; -extern long float_size, pointer_size, int_size; extern char *strindex(); static diff --git a/util/grind/rd.c b/util/grind/rd.c index 40c292d58..a4c5cc30d 100644 --- a/util/grind/rd.c +++ b/util/grind/rd.c @@ -4,7 +4,10 @@ #include "rd.h" +#if (defined(sun) && defined(mc68020)) || defined(vax) #if defined(sun) && defined(mc68020) +#define relocation_info reloc_info_68k +#endif #include #include @@ -34,18 +37,24 @@ rd_ohead(h) h->oh_stamp = 0; h->oh_nsect = 4; 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; +#if defined(sun) if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec); +#endif h->oh_nemit = bh.a_text + bh.a_data; +#if defined(sun) if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec); +#endif fseek(inf, N_STROFF(bh), 0); h->oh_nchar = getw(inf) + 6 + 6 + 5 - 4; /* ".text", ".data", ".bss", minus the size word */ seg_strings = h->oh_nchar - 17; - if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec); - fseek(inf, sizeof(struct exec) + bh.a_text + bh.a_data, 0); + fseek(inf, N_TXTOFF(bh)+bh.a_text+bh.a_data, 0); hh = *h; +#if defined(sun) + if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec); +#endif } /*ARGSUSED1*/ @@ -117,7 +126,9 @@ rd_string(strings, count) register char *strings; long count; { +#if defined(sun) if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec); +#endif fseek(inf, N_STROFF(bh)+4, 0); if (! readf(strings, (int)count-17, 1)) rd_fatal(); strings += count-17; diff --git a/util/grind/run.c b/util/grind/run.c index 7c6aaac44..82e27e7d0 100644 --- a/util/grind/run.c +++ b/util/grind/run.c @@ -220,7 +220,7 @@ start_child(p) init_run(); 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); } perform_items(); @@ -407,7 +407,7 @@ could_send(m, stop_message) if (! level) { child_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; } @@ -428,7 +428,7 @@ could_send(m, stop_message) level--; return 1; } - a = BUFTOI(answer.m_buf+1, (int)PS); + a = BUFTOI(answer.m_buf+1, PS); type = answer.m_type & 0377; if (type == M_END_SS) type = 0; 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; m.m_type = kind; - ITOBUF(m.m_buf+1, size, (int) LS); - ITOBUF(m.m_buf+LS+1, (long)from, (int) PS); + ITOBUF(m.m_buf+1, size, LS); + ITOBUF(m.m_buf+LS+1, (long)from, PS); if (! could_send(&m, 0)) { return 0; @@ -490,7 +490,7 @@ getbytes(size, from, to, kind, errmess) if (errmess) error("interrupted"); return 0; case M_DATA: - return ureceive(to, BUFTOI(answer.m_buf+1, (int)LS)); + return ureceive(to, BUFTOI(answer.m_buf+1, LS)); default: assert(0); } @@ -514,7 +514,7 @@ get_string(size, from, to) { 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; } @@ -527,8 +527,8 @@ set_bytes(size, from, to) struct message_hdr m; m.m_type = M_SETBYTES; - ITOBUF(m.m_buf+1, size, (int) LS); - ITOBUF(m.m_buf+LS+1, (long) to, (int) PS); + ITOBUF(m.m_buf+1, size, LS); + ITOBUF(m.m_buf+LS+1, (long) to, PS); if (! uputm(&m) || ! usend(from, size) || ! ugetm(&m)) { return; @@ -572,7 +572,7 @@ get_dump(globbuf, stackbuf) 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))); if (! *globbuf || ! ureceive(*globbuf+sizeof(struct message_hdr), sz) @@ -585,7 +585,7 @@ get_dump(globbuf, stackbuf) *globm = answer; 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)); if (! *stackbuf || ! ureceive(*stackbuf+sizeof(struct message_hdr), sz)) { free(*globbuf); @@ -595,8 +595,8 @@ get_dump(globbuf, stackbuf) } stackm = (struct message_hdr *) *stackbuf; *stackm = m; - ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, (int)PS), (int) PS); - return BUFTOI(globm->m_buf+PC_OFF, (int)PS); + ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, PS), PS); + return BUFTOI(globm->m_buf+PC_OFF, PS); } int @@ -615,11 +615,11 @@ put_dump(globbuf, stackbuf) restoring = 0; } return uputm(globm) - && usend(globbuf, BUFTOI(globm->m_buf+1, (int) LS)) + && usend(globbuf, BUFTOI(globm->m_buf+1, LS)) && uputm(stackm) - && usend(stackbuf, BUFTOI(stackm->m_buf+1, (int) LS)) + && usend(stackbuf, BUFTOI(stackm->m_buf+1, LS)) && ugetm(&m) - && stopped("restored", BUFTOI(m.m_buf+1, (int) PS), 0); + && stopped("restored", BUFTOI(m.m_buf+1, PS), 0); } t_addr * @@ -631,7 +631,7 @@ get_EM_regs(level) register t_addr *to = &buf[0]; 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)) { return 0; @@ -648,11 +648,11 @@ get_EM_regs(level) default: assert(0); } - *to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, (int)PS); - *to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, (int)PS); - *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS); - *to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, (int)PS); - *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS); + *to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, PS); + *to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, PS); + *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS); + *to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, PS); + *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS); return buf; } @@ -663,7 +663,7 @@ set_pc(PC) struct message_hdr m; 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; switch(answer.m_type) { case M_FAIL: @@ -698,7 +698,7 @@ singlestep(type, count) struct message_hdr m; 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; if (could_send(&m, 1) && child_pid) return 1; single_stepping = 0; @@ -713,7 +713,7 @@ set_or_clear_breakpoint(a, type) struct message_hdr m; 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 (child_pid && ! could_send(&m, 0)) { } @@ -729,8 +729,8 @@ set_or_clear_trace(start, end, type) struct message_hdr m; m.m_type = type ? M_SETTRACE : M_CLRTRACE; - ITOBUF(m.m_buf+1, (long)start, (int) PS); - ITOBUF(m.m_buf+PS+1, (long)end, (int) PS); + ITOBUF(m.m_buf+1, (long)start, 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 (child_pid && ! could_send(&m, 0)) { return 0; diff --git a/util/grind/type.c b/util/grind/type.c index 9ba6867ac..8b08cc86e 100644 --- a/util/grind/type.c +++ b/util/grind/type.c @@ -7,7 +7,6 @@ #include "idf.h" #include "type.h" -#include "sizes.h" #include "symbol.h" #include "scope.h" #include "langdep.h" @@ -19,14 +18,14 @@ p_type void_type; p_type float_type, double_type; p_type string_type, address_type; -long int_size = SZ_INT, +long int_size = sizeof(int), char_size = 1, - short_size = SZ_SHORT, - long_size = SZ_LONG, - pointer_size = SZ_POINTER; + short_size = sizeof(short), + long_size = sizeof(long), + pointer_size = sizeof(char *); -long float_size = SZ_FLOAT, - double_size = SZ_DOUBLE; +long float_size = sizeof(float), + double_size = sizeof(double); struct bounds { long low, high; diff --git a/util/grind/type.hh b/util/grind/type.hh index 9baeb9169..24400ff34 100644 --- a/util/grind/type.hh +++ b/util/grind/type.hh @@ -119,5 +119,6 @@ extern long extern p_type char_type, uchar_type, bool_type, int_type, long_type, double_type, string_type, address_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;