Accept -gdb option
authorceriel <none@none>
Fri, 27 Mar 1992 17:36:49 +0000 (17:36 +0000)
committerceriel <none@none>
Fri, 27 Mar 1992 17:36:49 +0000 (17:36 +0000)
14 files changed:
mach/i386/ncg/mach.c
mach/i386/ncg/mach.h
mach/m68020/ncg/mach.c
mach/m68020/ncg/mach.h
mach/m68k2/ncg/mach.c
mach/m68k2/ncg/mach.h
mach/m68k4/ncg/mach.c
mach/m68k4/ncg/mach.h
mach/moon3/ncg/mach.c
mach/moon3/ncg/mach.h
mach/sparc/ce/ce.src/ms_reg.c
mach/sparc/ce_cg/convert.c
mach/vax4/cg/mach.c
mach/vax4/cg/mach.h

index 6b08565..3388c66 100644 (file)
@@ -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 */
                }
index 62c007e..40c9c63 100644 (file)
@@ -31,3 +31,4 @@
 #define fmt_id(fr,to)  sprintf(to, "_%s", fr)
 
 #define BSS_INIT        0
+#define MACH_OPTIONS
index 5651cac..a7eb6eb 100644 (file)
@@ -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);
index c9c975a..c78d087 100644 (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 BSS_INIT       0
+#define MACH_OPTIONS
index 5651cac..a7eb6eb 100644 (file)
@@ -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);
index c9c975a..c78d087 100644 (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 BSS_INIT       0
+#define MACH_OPTIONS
index 5651cac..a7eb6eb 100644 (file)
@@ -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);
index c9c975a..c78d087 100644 (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 BSS_INIT       0
+#define MACH_OPTIONS
index 5651cac..a7eb6eb 100644 (file)
@@ -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);
index c9c975a..c78d087 100644 (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 BSS_INIT       0
+#define MACH_OPTIONS
index 9f1e3f0..771b907 100644 (file)
@@ -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;
                }
index 1db46e3..0713068 100644 (file)
@@ -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, "-"))
index 6edd361..f434aaa 100644 (file)
@@ -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);
index 3c7442d..fbd29a6 100644 (file)
@@ -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"