vg_symtab2.c:
    Discovered sometimes a SLINE stabs entry is the last one (which broke an
    assertion).  In such a case, we must guess the line's instruction address
    range -- I've guessed 4, arbitrarily.

vg_cachegen.in, vg_cachesim_{I1,D1,L2}.c:
    Discovered a bad bug in the cache simulation:  when determining if a
    references straddles two memory blocks, to find the end of the range I was
    adding 'size' to the base address, rather than 'size - 1'.  This was
    causing way too many straddled references, which would inflate the miss
    counts.

vg_cachesim.c:
    Minor stuff


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@176 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_symtab2.c b/coregrind/vg_symtab2.c
index d9da8ff..0136ba3 100644
--- a/coregrind/vg_symtab2.c
+++ b/coregrind/vg_symtab2.c
@@ -34,6 +34,7 @@
 #include <elf.h>          /* ELF defns                      */
 #include <a.out.h>        /* stabs defns                    */
 
+
 /* Majorly rewritten Sun 3 Feb 02 to enable loading symbols from
    dlopen()ed libraries, which is something that KDE3 does a lot.
    Still kludgey, though less than before:
@@ -929,45 +930,50 @@
             Int this_addr = (UInt)stab[i].n_value;
 
             LOOP:
-            vg_assert(i+1 < n_stab_entries);    /* Haven't reached end */
-            switch (stab[i+1].n_type) {
-               /* Easy, common case: use address of next entry */
-               case N_SLINE: case N_SO:
-                  next_addr = (UInt)stab[i+1].n_value;
-                  break;
-
-               /* Boring one: skip, look for something more useful. */
-               case N_RSYM: case N_LSYM: case N_LBRAC: case N_RBRAC: 
-               case N_STSYM: case N_LCSYM:
-                  i++;
-                  goto LOOP;
-                  
-               /* Should be an end of fun entry, use its address */
-               case N_FUN: 
-                  if ('\0' == * (stabstr + stab[i+1].n_un.n_strx) ) {
+            if (i+1 >= n_stab_entries) {
+               /* If it's the last entry, just guess the range is four;  can't
+                * do any better */
+               next_addr = 4;
+            } else {    
+               switch (stab[i+1].n_type) {
+                  /* Easy, common case: use address of next entry */
+                  case N_SLINE: case N_SO:
                      next_addr = (UInt)stab[i+1].n_value;
-                  } else {
-                     VG_(printf)("unhandled stabs case: N_FUN start %d %s\n",
-                                i, (stabstr + stab[i+1].n_un.n_strx) );
-                     VG_(panic)("argh");
-                  }
-                  break;
-
-               /* N_SOL should be followed by an N_SLINE which can be used */
-               case N_SOL:
-                  if (i+2 < n_stab_entries && N_SLINE == stab[i+2].n_type) {
-                     next_addr = (UInt)stab[i+2].n_value;
                      break;
-                  } else {
-                     VG_(printf)("unhandled N_SOL stabs case: %d %d %d", 
-                                 stab[i+1].n_type, i, n_stab_entries);
-                     VG_(panic)("argh");
-                  }
 
-               default:
-                  VG_(printf)("unhandled stabs case: %d %d", 
-                              stab[i+1].n_type,i);
-                  VG_(panic)("argh");
+                  /* Boring one: skip, look for something more useful. */
+                  case N_RSYM: case N_LSYM: case N_LBRAC: case N_RBRAC: 
+                  case N_STSYM: case N_LCSYM:
+                     i++;
+                     goto LOOP;
+                     
+                  /* Should be an end of fun entry, use its address */
+                  case N_FUN: 
+                     if ('\0' == * (stabstr + stab[i+1].n_un.n_strx) ) {
+                        next_addr = (UInt)stab[i+1].n_value;
+                     } else {
+                        VG_(printf)("unhandled stabs case: N_FUN start %d %s\n",
+                                   i, (stabstr + stab[i+1].n_un.n_strx) );
+                        VG_(panic)("argh");
+                     }
+                     break;
+
+                  /* N_SOL should be followed by an N_SLINE which can be used */
+                  case N_SOL:
+                     if (i+2 < n_stab_entries && N_SLINE == stab[i+2].n_type) {
+                        next_addr = (UInt)stab[i+2].n_value;
+                        break;
+                     } else {
+                        VG_(printf)("unhandled N_SOL stabs case: %d %d %d", 
+                                    stab[i+1].n_type, i, n_stab_entries);
+                        VG_(panic)("argh");
+                     }
+
+                  default:
+                     VG_(printf)("unhandled stabs case: %d %d", 
+                                 stab[i+1].n_type,i);
+                     VG_(panic)("argh");
+               }
             }
             
             //Int offset2 = (i+1 < n_stab_entries && 68 == stab[i+1].n_type