BSD 4_3_Tahoe development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 4 Oct 1982 05:51:25 +0000 (21:51 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 4 Oct 1982 05:51:25 +0000 (21:51 -0800)
Work on file usr/src/old/sdb/TESTS/t.c
Work on file usr/src/old/sdb/TESTS/z.c
Work on file usr/src/old/sdb/TESTS/y.c
Work on file usr/src/old/sdb/TESTS/x.c
Work on file usr/src/old/sdb/TESTS/zz.c
Work on file usr/src/old/sdb/TESTS/new
Work on file usr/src/old/sdb/TESTS/test.c

Synthesized-from: CSRG/cd2/4.3tahoe

usr/src/old/sdb/TESTS/new [new file with mode: 0644]
usr/src/old/sdb/TESTS/t.c [new file with mode: 0644]
usr/src/old/sdb/TESTS/test.c [new file with mode: 0644]
usr/src/old/sdb/TESTS/x.c [new file with mode: 0644]
usr/src/old/sdb/TESTS/y.c [new file with mode: 0644]
usr/src/old/sdb/TESTS/z.c [new file with mode: 0644]
usr/src/old/sdb/TESTS/zz.c [new file with mode: 0644]

diff --git a/usr/src/old/sdb/TESTS/new b/usr/src/old/sdb/TESTS/new
new file mode 100644 (file)
index 0000000..211adb6
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * These macros are used to speak ``offsets'' to the outside world,
+ * so that we can use the other source files for sdb essentially
+ * unchanged, even though they believe that we work with symbol
+ * table offsets, and we really have the whole symbol table in
+ * core and would prefer to just work with pointers into it.
+ */
+#define        sptooff(sp)     (ststart + (int)(sp) - (int)(symtab))
+#define        offtosp(off)    (&symtab[((off) - ststart) / sizeof (struct nlist))
+
+/*
+ * Initialize the file and procedure tables.
+ *
+ * This routine rummages through the symbol table and builds tables
+ * of the files and procedures referenced there, sorting the latter
+ * table into address order.  These tables are used in the other
+ * routines defined here.
+ *
+ * NB:
+ *
+ * In this version of sdb we could well dispense with most of the
+ * fields of these tables, since we have the symbol table in core,
+ * but for compatibility for the time being we duplicate the information
+ * so older code in other sdb files will work unchanged.
+ */
+initfp()
+{
+       register struct nlist *sp;
+       register struct proct *procp;
+       register struct filet *filep;
+       struct stat stb;
+       int nfile, nproc;
+       int class;
+       extern int compar();            /* Sort routine for procedure table */
+       
+       firstdata = MAXPOS;
+       /*
+        * Since the symbol table is in core, we can afford
+        * two passes over it to avoid messy allocation strategies
+        * for these tables, who sizes are as yet unknown.
+        */
+       nfile = 0;
+       nproc = 0;
+       for (sp = symtab; sp < esymtab; sp++) switch (sp->n_type & STABMASK) {
+
+       case N_SO:
+       case N_SOL:
+               nfile++;
+               continue;
+       case N_TEXT:
+               if (sp->n_name[0] == '_')
+                       nfile++;
+               continue;
+       case N_FUN:
+       case N_ENTRY:
+               nfile++;
+               continue;
+       }
+       files = calloc(nfile+1, sizeof (struct filet));
+       procs = calloc(nfile+1, sizeof (struct filet));
+       if (files == 0 || procs == 0) {
+               printf("Couldn't get space for file/procedure tables\n");
+               exit(1);
+       }
+       if (nfiles == 0)
+               printf("Warning: `%s' not compiled with -g\n", symfil);
+       procp = procs;
+       filep = files;
+       for (sp = symtab; sp < esymtab; sp++) {
+               class = sp->n_type & STABMASK;
+               switch (class) {
+
+               case N_SO:
+               case N_SOL:
+                       filep->faddr = sp->n_value;
+                       filep->lineflag = (class == N_SOL);
+                       filep->stf_offset = sptooff(sp);
+                       filep->sfilename = sp->n_name;
+                       strcpy(fp, filep->sfilename);
+                       if (stat(filework, &stb) == -1)
+                               printf("Warning: `%s' not found\n",
+                                   filep->sfilename);
+                       else if (stb.st_mtime > symtime)
+                               printf("Warning: `%s' newer than `%s'\n",
+                                   filep->sfilename, symfil);
+                       filep++;
+                       break;
+
+               case N_TEXT:
+                       if (stentry.n_name[0] != '_')
+                               break;
+               case N_FUN:
+               case N_ENTRY:
+                       procp->pname = sp->n_name;
+                       procp->paddr = sp->n_value;
+                       procp->st_offset = sptooff(sp);
+                       if (class != N_TEXT) {
+                               procp->sfptr = filep - 1;
+                               procp->lineno = so->n_desc;
+                       } else {
+                               procp->sfptr = badfile;
+                               procp->lineno = 0;
+                       }
+                       procp->entrypt = class == N_ENTRY;
+                       procp++;
+                       break;
+               }
+               if (sp->n_type & N_EXT) {
+                       if (!extstart)
+                               extstart = sp;
+                       /* THIS LOOKS WRONG !!! SHOULD BE (x || y) && z ??? */
+                       if (sp->n_type == (N_DATA+N_EXT) ||
+                           sp->n_type == (N_BSS+N_EXT) ||
+                           sp->n_value < firstdata)
+                               firstdata = sp->n_value;
+               }
+       }
+       if (filep != &files[nfile] || procp != &procs[nproc]) {
+               printf("initfp botch - tell someone\n");
+               exit(1);
+       }
+       /*
+        * Now have the file and procedure tables.
+        * Sort the procedure table, and initialize the boundary
+        * elements of the tables.
+        */
+       qsort(procs, procp-procs, sizeof procs[0], compar);
+       badproc = procp;
+       badfile = filep;
+       badproc->st_offset = esymtab;
+       badproc->sfptr = badfile;
+       badproc->pname = badfile->sfilename = "";
+       setcur(1);
+}
diff --git a/usr/src/old/sdb/TESTS/t.c b/usr/src/old/sdb/TESTS/t.c
new file mode 100644 (file)
index 0000000..a2f3787
--- /dev/null
@@ -0,0 +1,47 @@
+struct {
+       char cc;
+       int aa;
+} s1, s2, s3[2];
+
+main(argc,argv,envp)
+char **argv, **envp; {
+       s1.cc = 'a';
+       s2.cc = 'b';
+       s3[0].cc = 'c';
+       s3[1].cc = 'd';
+       
+       s1.aa = 22;
+       s2.aa = 33;
+       s3[0].aa = 44;
+       
+       sub(s1.cc);
+       
+       abort();
+}
+
+sub(c)
+char c;
+{
+       register char d;
+       
+       d = c;
+       inner(&c);
+}
+
+inner(s)
+char *s; {
+       char c;
+       
+       c = *s;
+       core(s);
+}
+
+core(s)
+register char *s; {
+       char *p;
+       char c;
+
+       p = s;
+       c = *p;
+}
+
diff --git a/usr/src/old/sdb/TESTS/test.c b/usr/src/old/sdb/TESTS/test.c
new file mode 100644 (file)
index 0000000..30e16b0
--- /dev/null
@@ -0,0 +1,54 @@
+int r = 22;
+int array[] = { 5, 4, 3, 2, 1};
+char s[] = "abcdefg";
+
+ignore(){
+       int i;
+       i++;
+}
+
+main(argc, argv) 
+char **argv; {
+       char *p;
+       p = s;
+       test();
+}
+
+test() {
+       int a,b,c;
+       a = 1;
+       b = 2;
+       c = 3;
+       sub (a,b, 14);
+}
+sub(x,y) {
+       x = 2;
+       r = 22;
+       final(y);
+}
+
+final(z) 
+register int z; {
+       register p,q,a;
+       int f,g;
+       int x[10];
+       struct {
+               int aa;
+               int bb;
+       } d, *pd;
+       pd = &d;
+       d.aa=23;
+       d.bb=34;
+       p = 1;
+       q = 2;
+       a = 3;
+       f = 4; 
+       {
+               int i, j, k;
+               i = 2;
+               g = 5;
+               x[10000] = 2;
+               g = 0;
+       }
+       g = 1;
+}
diff --git a/usr/src/old/sdb/TESTS/x.c b/usr/src/old/sdb/TESTS/x.c
new file mode 100644 (file)
index 0000000..2c385db
--- /dev/null
@@ -0,0 +1,18 @@
+main() {
+       foo(123456);
+}
+
+foo(){
+       register        int     f_a, f_b;
+       f_a = 37;
+       f_b = 38;
+       bar();
+};
+
+bar(){
+       register        int     b_a, b_b, b_c;
+       b_a = 2;
+       b_b = 3;
+       b_c = 4;
+       abort();
+}
diff --git a/usr/src/old/sdb/TESTS/y.c b/usr/src/old/sdb/TESTS/y.c
new file mode 100644 (file)
index 0000000..e5bea0d
--- /dev/null
@@ -0,0 +1,19 @@
+
+main() {
+       int i = 0;
+       int j = 0;
+       register a, b, c, d, e, f, g, h;
+
+       for (;;) {
+               i++;
+               j++;
+               printf("Hello sailor\n");
+               a = 1;
+               b = 3;
+               c = 5;
+               d = 7; 
+               e = 9; f = 11;
+               g = 12;
+               h = 13;
+       }
+}
diff --git a/usr/src/old/sdb/TESTS/z.c b/usr/src/old/sdb/TESTS/z.c
new file mode 100644 (file)
index 0000000..5b4ec97
--- /dev/null
@@ -0,0 +1,21 @@
+struct z{
+       int i,j,k;
+} ;
+
+main() {
+       struct z a;
+
+       a.i = 3;
+       a.j = 4;
+       a.k = 5;
+
+       sub(a,12);
+
+       printf("Hello sailor\n");
+       abort();
+}
+
+sub(y,m)
+struct z y; {
+       y.i++;
+}
diff --git a/usr/src/old/sdb/TESTS/zz.c b/usr/src/old/sdb/TESTS/zz.c
new file mode 100644 (file)
index 0000000..c9f5353
--- /dev/null
@@ -0,0 +1,6 @@
+int    i = 2;
+int    j = 3;
+main()
+{
+       int k = 4;
+}