From b2cca56e16e4a1fa0516186bdbac0ae6feadc55d Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 27 Mar 1992 17:36:49 +0000 Subject: [PATCH] Accept -gdb option --- mach/i386/ncg/mach.c | 31 ++++++++++++++++++++++++++++++- mach/i386/ncg/mach.h | 1 + mach/m68020/ncg/mach.c | 32 ++++++++++++++++++++++++++------ mach/m68020/ncg/mach.h | 1 + mach/m68k2/ncg/mach.c | 32 ++++++++++++++++++++++++++------ mach/m68k2/ncg/mach.h | 1 + mach/m68k4/ncg/mach.c | 32 ++++++++++++++++++++++++++------ mach/m68k4/ncg/mach.h | 1 + mach/moon3/ncg/mach.c | 32 ++++++++++++++++++++++++++------ mach/moon3/ncg/mach.h | 1 + mach/sparc/ce/ce.src/ms_reg.c | 17 +++++++++++++++-- mach/sparc/ce_cg/convert.c | 5 +++++ mach/vax4/cg/mach.c | 34 ++++++++++++++++++++++++++++------ mach/vax4/cg/mach.h | 1 + 14 files changed, 188 insertions(+), 33 deletions(-) diff --git a/mach/i386/ncg/mach.c b/mach/i386/ncg/mach.c index 6b08565d8..3388c6696 100644 --- a/mach/i386/ncg/mach.c +++ b/mach/i386/ncg/mach.c @@ -158,6 +158,21 @@ regreturn() } #endif /* REGVARS */ +#ifdef MACH_OPTIONS +static int gdb_flag = 0; + +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ + mes(type) word type ; { int argt, a1, a2 ; @@ -186,6 +201,16 @@ mes(type) word type ; { argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer (bp). + */ + argval += 8; + } + } +#endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); argt = getarg(end_ptyp); break; @@ -197,7 +222,11 @@ mes(type) word type ; { argt = getarg(cst_ptyp); } swtxt(); - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { fputs("call ___u_LiB\n", codefile); cleanregs(); /* debugger might change variables */ } diff --git a/mach/i386/ncg/mach.h b/mach/i386/ncg/mach.h index 62c007e4c..40c9c6321 100644 --- a/mach/i386/ncg/mach.h +++ b/mach/i386/ncg/mach.h @@ -31,3 +31,4 @@ #define fmt_id(fr,to) sprintf(to, "_%s", fr) #define BSS_INIT 0 +#define MACH_OPTIONS diff --git a/mach/m68020/ncg/mach.c b/mach/m68020/ncg/mach.c index 5651cac4f..a7eb6ebf3 100644 --- a/mach/m68020/ncg/mach.c +++ b/mach/m68020/ncg/mach.c @@ -178,7 +178,20 @@ prolog(n) full n; { nlocals = n; } +#ifdef MACH_OPTIONS +static int gdb_flag = 0; +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ mes(type) word type ; { int argt, a1, a2 ; @@ -208,9 +221,14 @@ mes(type) word type ; { argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); -#ifdef DBX - if (a1 == N_PSYM) { - argval += 8; +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer. + */ + argval += 8; + } } #endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); @@ -224,8 +242,11 @@ mes(type) word type ; { argt = getarg(cst_ptyp); } swtxt(); -#ifndef DBX - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { #ifdef TBL68020 fputs("jsr (___u_LiB)\n", codefile); #else @@ -233,7 +254,6 @@ mes(type) word type ; { #endif cleanregs(); /* debugger might change variables */ } -#endif fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); argt = getarg(cst_ptyp); fprintf(codefile, "%d\n", (int) argval); diff --git a/mach/m68020/ncg/mach.h b/mach/m68020/ncg/mach.h index c9c975a3e..c78d0873e 100644 --- a/mach/m68020/ncg/mach.h +++ b/mach/m68020/ncg/mach.h @@ -46,3 +46,4 @@ You must specify the appropriate word size, then REMOVE tables.c #define fmt_id(sf,st) sprintf(st,"_%s",sf) #define BSS_INIT 0 +#define MACH_OPTIONS diff --git a/mach/m68k2/ncg/mach.c b/mach/m68k2/ncg/mach.c index 5651cac4f..a7eb6ebf3 100644 --- a/mach/m68k2/ncg/mach.c +++ b/mach/m68k2/ncg/mach.c @@ -178,7 +178,20 @@ prolog(n) full n; { nlocals = n; } +#ifdef MACH_OPTIONS +static int gdb_flag = 0; +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ mes(type) word type ; { int argt, a1, a2 ; @@ -208,9 +221,14 @@ mes(type) word type ; { argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); -#ifdef DBX - if (a1 == N_PSYM) { - argval += 8; +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer. + */ + argval += 8; + } } #endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); @@ -224,8 +242,11 @@ mes(type) word type ; { argt = getarg(cst_ptyp); } swtxt(); -#ifndef DBX - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { #ifdef TBL68020 fputs("jsr (___u_LiB)\n", codefile); #else @@ -233,7 +254,6 @@ mes(type) word type ; { #endif cleanregs(); /* debugger might change variables */ } -#endif fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); argt = getarg(cst_ptyp); fprintf(codefile, "%d\n", (int) argval); diff --git a/mach/m68k2/ncg/mach.h b/mach/m68k2/ncg/mach.h index c9c975a3e..c78d0873e 100644 --- a/mach/m68k2/ncg/mach.h +++ b/mach/m68k2/ncg/mach.h @@ -46,3 +46,4 @@ You must specify the appropriate word size, then REMOVE tables.c #define fmt_id(sf,st) sprintf(st,"_%s",sf) #define BSS_INIT 0 +#define MACH_OPTIONS diff --git a/mach/m68k4/ncg/mach.c b/mach/m68k4/ncg/mach.c index 5651cac4f..a7eb6ebf3 100644 --- a/mach/m68k4/ncg/mach.c +++ b/mach/m68k4/ncg/mach.c @@ -178,7 +178,20 @@ prolog(n) full n; { nlocals = n; } +#ifdef MACH_OPTIONS +static int gdb_flag = 0; +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ mes(type) word type ; { int argt, a1, a2 ; @@ -208,9 +221,14 @@ mes(type) word type ; { argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); -#ifdef DBX - if (a1 == N_PSYM) { - argval += 8; +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer. + */ + argval += 8; + } } #endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); @@ -224,8 +242,11 @@ mes(type) word type ; { argt = getarg(cst_ptyp); } swtxt(); -#ifndef DBX - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { #ifdef TBL68020 fputs("jsr (___u_LiB)\n", codefile); #else @@ -233,7 +254,6 @@ mes(type) word type ; { #endif cleanregs(); /* debugger might change variables */ } -#endif fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); argt = getarg(cst_ptyp); fprintf(codefile, "%d\n", (int) argval); diff --git a/mach/m68k4/ncg/mach.h b/mach/m68k4/ncg/mach.h index c9c975a3e..c78d0873e 100644 --- a/mach/m68k4/ncg/mach.h +++ b/mach/m68k4/ncg/mach.h @@ -46,3 +46,4 @@ You must specify the appropriate word size, then REMOVE tables.c #define fmt_id(sf,st) sprintf(st,"_%s",sf) #define BSS_INIT 0 +#define MACH_OPTIONS diff --git a/mach/moon3/ncg/mach.c b/mach/moon3/ncg/mach.c index 5651cac4f..a7eb6ebf3 100644 --- a/mach/moon3/ncg/mach.c +++ b/mach/moon3/ncg/mach.c @@ -178,7 +178,20 @@ prolog(n) full n; { nlocals = n; } +#ifdef MACH_OPTIONS +static int gdb_flag = 0; +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ mes(type) word type ; { int argt, a1, a2 ; @@ -208,9 +221,14 @@ mes(type) word type ; { argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); -#ifdef DBX - if (a1 == N_PSYM) { - argval += 8; +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer. + */ + argval += 8; + } } #endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); @@ -224,8 +242,11 @@ mes(type) word type ; { argt = getarg(cst_ptyp); } swtxt(); -#ifndef DBX - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { #ifdef TBL68020 fputs("jsr (___u_LiB)\n", codefile); #else @@ -233,7 +254,6 @@ mes(type) word type ; { #endif cleanregs(); /* debugger might change variables */ } -#endif fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); argt = getarg(cst_ptyp); fprintf(codefile, "%d\n", (int) argval); diff --git a/mach/moon3/ncg/mach.h b/mach/moon3/ncg/mach.h index c9c975a3e..c78d0873e 100644 --- a/mach/moon3/ncg/mach.h +++ b/mach/moon3/ncg/mach.h @@ -46,3 +46,4 @@ You must specify the appropriate word size, then REMOVE tables.c #define fmt_id(sf,st) sprintf(st,"_%s",sf) #define BSS_INIT 0 +#define MACH_OPTIONS diff --git a/mach/sparc/ce/ce.src/ms_reg.c b/mach/sparc/ce/ce.src/ms_reg.c index 9f1e3f061..771b907ad 100644 --- a/mach/sparc/ce/ce.src/ms_reg.c +++ b/mach/sparc/ce/ce.src/ms_reg.c @@ -306,13 +306,17 @@ C_mes_end() } } +extern int __gdb_flag; + C_cst( l) arith l; { + static int correct_offset; + if (db_mes) { if (! db_str) { switchseg( SEGTXT); - if (l == N_SLINE) { + if (l == N_SLINE && ! __gdb_flag) { flush_cache(); fprintf(codefile, "call ___uX_LiB\nnop\n"); } @@ -323,8 +327,17 @@ arith l; db_str = 1; db_nul = 1; } - else fprint(codefile, ",0x%lx", (long) l); + else { + if (correct_offset++ == -1) { + l += EM_BSIZE; + } + fprint(codefile, ",0x%lx", (long) l); + } if (! db_nul) { + correct_offset = 0; + if (l == N_PSYM && __gdb_flag) { + correct_offset = -2; + } fprint(codefile, ",0"); db_nul = 1; } diff --git a/mach/sparc/ce_cg/convert.c b/mach/sparc/ce_cg/convert.c index 1db46e34f..07130686d 100644 --- a/mach/sparc/ce_cg/convert.c +++ b/mach/sparc/ce_cg/convert.c @@ -29,6 +29,7 @@ char *filename; /* Name of input file */ char *out_file; /* Name of output file */ int errors; /* Number of errors */ int debug; +int __gdb_flag; extern char *C_error; main(argc,argv) @@ -49,6 +50,10 @@ main(argc,argv) debug= 1; continue; } + if (! strcmp(av[0], "-gdb")) { + __gdb_flag = 1; + continue; + } if (!filename) { if (strcmp(*av, "-")) diff --git a/mach/vax4/cg/mach.c b/mach/vax4/cg/mach.c index 6edd36128..f434aaaa3 100644 --- a/mach/vax4/cg/mach.c +++ b/mach/vax4/cg/mach.c @@ -47,6 +47,21 @@ con_mult(sz) fprintf(codefile,".data4\t%s\n",str); } +#ifdef MACH_OPTIONS +static int gdb_flag = 0; + +mach_option(s) + char *s; +{ + if (! strcmp(s, "-gdb")) { + gdb_flag = 1; + } + else { + error("Unknown flag %s", s); + } +} +#endif /* MACH_OPTIONS */ + mes(mesno) word mesno; { @@ -77,9 +92,14 @@ mes(mesno) argt = getarg(cst_ptyp); a2 = argval; argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); -#ifdef DBX - if (a1 == N_PSYM) { - argval += 4; +#ifdef MACH_OPTIONS + if (gdb_flag) { + if (a1 == N_PSYM) { + /* Change offset from AB into offset from + the frame pointer (ab). + */ + argval += 4; + } } #endif fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); @@ -93,12 +113,14 @@ mes(mesno) argt = getarg(cst_ptyp); } swtxt(); -#ifndef DBX - if (argval == N_SLINE) { + if (argval == N_SLINE +#ifdef MACH_OPTIONS + && ! gdb_flag +#endif + ) { fputs("calls $0,___u_LiB\n", codefile); cleanregs(); /* debugger might change variables */ } -#endif fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); argt = getarg(cst_ptyp); fprintf(codefile, "%d\n", (int) argval); diff --git a/mach/vax4/cg/mach.h b/mach/vax4/cg/mach.h index 3c7442d93..fbd29a679 100644 --- a/mach/vax4/cg/mach.h +++ b/mach/vax4/cg/mach.h @@ -27,5 +27,6 @@ #define con_dlb(x) fprintf(codefile,".data4\t%s\n",x) #define BSS_INIT 0 +#define MACH_OPTIONS #define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n" -- 2.34.1