This commit partly cleans up and modularises ExeContext usage.  It doesn't
look like that much, but it's a good first step;  there's more to come.

- vg_errcontext.c:gen_suppressions() and vg_symtab2.c:VG_(mini_stack_dump)()
  had very similar stack-trace-traversing loops.  I factored these out into
  the higher-order function VG_(apply_ExeContext)().  I put this into
  vg_execontext.c, which is the obvious spot.  This is good because before
  this change we had two functions, neither in vg_execontext.c, which were
  crawling all over ExeContexts -- they shouldn't have to do that.
  
- Removed VG_(mini_stack_dump)(), which was almost identical to
  VG_(pp_ExeContext)().

- Removed dead function VG_(get_EIP_from_ExeContext)().

- Replaced a call to VG_(get_ExeContext2)() with the simpler
  VG_(get_ExeContext)() in vg_scheduler.c.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3394 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c
index 339161c..ce55550 100644
--- a/coregrind/vg_errcontext.c
+++ b/coregrind/vg_errcontext.c
@@ -340,11 +340,22 @@
    vg_assert( tid < VG_N_THREADS );
 }
 
+static void printSuppForIp(UInt n, Addr ip)
+{
+   static UChar buf[M_VG_ERRTXT];
+
+   if ( VG_(get_fnname_nodemangle) (ip, buf,  M_VG_ERRTXT) ) {
+      VG_(printf)("   fun:%s\n", buf);
+   } else if ( VG_(get_objname)(ip, buf+7, M_VG_ERRTXT-7) ) {
+      VG_(printf)("   obj:%s\n", buf);
+   } else {
+      VG_(printf)("   ???:???       "
+                  "# unknown, suppression will not work, sorry\n");
+   }
+}
+
 static void gen_suppression(Error* err)
 {
-   Int         i;
-   static UChar buf[M_VG_ERRTXT];
-   Bool        main_done = False;
    ExeContext* ec      = VG_(get_error_where)(err);
    Int         stop_at = VG_(clo_backtrace_size);
 
@@ -369,30 +380,8 @@
       TL_(print_extra_suppression_info)(err);
    }
 
-   /* This loop condensed from VG_(mini_stack_dump)() */
-   i = 0;
-   do {
-      Addr eip = ec->ips[i];
-      if (i > 0) 
-         eip -= MIN_INSTR_SIZE;     // point to calling line
-      if ( VG_(get_fnname_nodemangle) (eip, buf,  M_VG_ERRTXT) ) {
-         // Stop after "main";  if main() is recursive, stop after last main().
-
-         if ( ! VG_(clo_show_below_main)) {
-            if (VG_STREQ(buf, "main"))
-               main_done = True;
-            else if (main_done)
-               break;
-         }
-         VG_(printf)("   fun:%s\n", buf);
-      } else if ( VG_(get_objname)(eip, buf, M_VG_ERRTXT) ) {
-         VG_(printf)("   obj:%s\n", buf);
-      } else {
-         VG_(printf)("   ???:???       "
-                     "# unknown, suppression will not work, sorry\n");
-      }
-      i++;
-   } while (i < stop_at && ec->ips[i] != 0);
+   // Print stack trace elements
+   VG_(apply_ExeContext)(printSuppForIp, ec, stop_at);
 
    VG_(printf)("}\n");
 }