Accept -gdb option

This commit is contained in:
ceriel 1992-03-27 17:36:49 +00:00
parent ea2e95a627
commit b2cca56e16
14 changed files with 188 additions and 33 deletions

View file

@ -158,6 +158,21 @@ regreturn()
} }
#endif /* REGVARS */ #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 ; { mes(type) word type ; {
int argt, a1, a2 ; int argt, a1, a2 ;
@ -186,6 +201,16 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); 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); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
argt = getarg(end_ptyp); argt = getarg(end_ptyp);
break; break;
@ -197,7 +222,11 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
if (argval == N_SLINE) { if (argval == N_SLINE
#ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
fputs("call ___u_LiB\n", codefile); fputs("call ___u_LiB\n", codefile);
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }

View file

@ -31,3 +31,4 @@
#define fmt_id(fr,to) sprintf(to, "_%s", fr) #define fmt_id(fr,to) sprintf(to, "_%s", fr)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS

View file

@ -178,7 +178,20 @@ prolog(n) full n; {
nlocals = 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 ; { mes(type) word type ; {
int argt, a1, a2 ; int argt, a1, a2 ;
@ -208,9 +221,14 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef DBX #ifdef MACH_OPTIONS
if (a1 == N_PSYM) { if (gdb_flag) {
argval += 8; if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
} }
#endif #endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
@ -224,8 +242,11 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
#ifndef DBX if (argval == N_SLINE
if (argval == N_SLINE) { #ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef TBL68020 #ifdef TBL68020
fputs("jsr (___u_LiB)\n", codefile); fputs("jsr (___u_LiB)\n", codefile);
#else #else
@ -233,7 +254,6 @@ mes(type) word type ; {
#endif #endif
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }
#endif
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval); fprintf(codefile, "%d\n", (int) argval);

View file

@ -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 fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS

View file

@ -178,7 +178,20 @@ prolog(n) full n; {
nlocals = 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 ; { mes(type) word type ; {
int argt, a1, a2 ; int argt, a1, a2 ;
@ -208,9 +221,14 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef DBX #ifdef MACH_OPTIONS
if (a1 == N_PSYM) { if (gdb_flag) {
argval += 8; if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
} }
#endif #endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
@ -224,8 +242,11 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
#ifndef DBX if (argval == N_SLINE
if (argval == N_SLINE) { #ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef TBL68020 #ifdef TBL68020
fputs("jsr (___u_LiB)\n", codefile); fputs("jsr (___u_LiB)\n", codefile);
#else #else
@ -233,7 +254,6 @@ mes(type) word type ; {
#endif #endif
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }
#endif
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval); fprintf(codefile, "%d\n", (int) argval);

View file

@ -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 fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS

View file

@ -178,7 +178,20 @@ prolog(n) full n; {
nlocals = 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 ; { mes(type) word type ; {
int argt, a1, a2 ; int argt, a1, a2 ;
@ -208,9 +221,14 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef DBX #ifdef MACH_OPTIONS
if (a1 == N_PSYM) { if (gdb_flag) {
argval += 8; if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
} }
#endif #endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
@ -224,8 +242,11 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
#ifndef DBX if (argval == N_SLINE
if (argval == N_SLINE) { #ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef TBL68020 #ifdef TBL68020
fputs("jsr (___u_LiB)\n", codefile); fputs("jsr (___u_LiB)\n", codefile);
#else #else
@ -233,7 +254,6 @@ mes(type) word type ; {
#endif #endif
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }
#endif
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval); fprintf(codefile, "%d\n", (int) argval);

View file

@ -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 fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS

View file

@ -178,7 +178,20 @@ prolog(n) full n; {
nlocals = 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 ; { mes(type) word type ; {
int argt, a1, a2 ; int argt, a1, a2 ;
@ -208,9 +221,14 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef DBX #ifdef MACH_OPTIONS
if (a1 == N_PSYM) { if (gdb_flag) {
argval += 8; if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
} }
#endif #endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
@ -224,8 +242,11 @@ mes(type) word type ; {
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
#ifndef DBX if (argval == N_SLINE
if (argval == N_SLINE) { #ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef TBL68020 #ifdef TBL68020
fputs("jsr (___u_LiB)\n", codefile); fputs("jsr (___u_LiB)\n", codefile);
#else #else
@ -233,7 +254,6 @@ mes(type) word type ; {
#endif #endif
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }
#endif
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval); fprintf(codefile, "%d\n", (int) argval);

View file

@ -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 fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS

View file

@ -306,13 +306,17 @@ C_mes_end()
} }
} }
extern int __gdb_flag;
C_cst( l) C_cst( l)
arith l; arith l;
{ {
static int correct_offset;
if (db_mes) { if (db_mes) {
if (! db_str) { if (! db_str) {
switchseg( SEGTXT); switchseg( SEGTXT);
if (l == N_SLINE) { if (l == N_SLINE && ! __gdb_flag) {
flush_cache(); flush_cache();
fprintf(codefile, "call ___uX_LiB\nnop\n"); fprintf(codefile, "call ___uX_LiB\nnop\n");
} }
@ -323,8 +327,17 @@ arith l;
db_str = 1; db_str = 1;
db_nul = 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) { if (! db_nul) {
correct_offset = 0;
if (l == N_PSYM && __gdb_flag) {
correct_offset = -2;
}
fprint(codefile, ",0"); fprint(codefile, ",0");
db_nul = 1; db_nul = 1;
} }

View file

@ -29,6 +29,7 @@ char *filename; /* Name of input file */
char *out_file; /* Name of output file */ char *out_file; /* Name of output file */
int errors; /* Number of errors */ int errors; /* Number of errors */
int debug; int debug;
int __gdb_flag;
extern char *C_error; extern char *C_error;
main(argc,argv) main(argc,argv)
@ -49,6 +50,10 @@ main(argc,argv)
debug= 1; debug= 1;
continue; continue;
} }
if (! strcmp(av[0], "-gdb")) {
__gdb_flag = 1;
continue;
}
if (!filename) if (!filename)
{ {
if (strcmp(*av, "-")) if (strcmp(*av, "-"))

View file

@ -47,6 +47,21 @@ con_mult(sz)
fprintf(codefile,".data4\t%s\n",str); 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) mes(mesno)
word mesno; word mesno;
{ {
@ -77,9 +92,14 @@ mes(mesno)
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
a2 = argval; a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp); argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef DBX #ifdef MACH_OPTIONS
if (a1 == N_PSYM) { if (gdb_flag) {
argval += 4; if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer (ab).
*/
argval += 4;
}
} }
#endif #endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2); fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
@ -93,12 +113,14 @@ mes(mesno)
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
} }
swtxt(); swtxt();
#ifndef DBX if (argval == N_SLINE
if (argval == N_SLINE) { #ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
fputs("calls $0,___u_LiB\n", codefile); fputs("calls $0,___u_LiB\n", codefile);
cleanregs(); /* debugger might change variables */ cleanregs(); /* debugger might change variables */
} }
#endif
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval); fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp); argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval); fprintf(codefile, "%d\n", (int) argval);

View file

@ -27,5 +27,6 @@
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x) #define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
#define BSS_INIT 0 #define BSS_INIT 0
#define MACH_OPTIONS
#define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n" #define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n"