valgrind: r3831 - trunk/coregrind

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

valgrind: r3831 - trunk/coregrind

svn-2
Author: njn
Date: 2005-06-01 01:00:46 +0100 (Wed, 01 Jun 2005)
New Revision: 3831

Modified:
   trunk/coregrind/core.h
   trunk/coregrind/m_signals.c
   trunk/coregrind/pub_core_execontext.h
   trunk/coregrind/vg_mylibc.c
Log:

Modularised vg_signals.c as m_signals.c.


Modified: trunk/coregrind/core.h
===================================================================
--- trunk/coregrind/core.h 2005-05-31 22:15:14 UTC (rev 3830)
+++ trunk/coregrind/core.h 2005-06-01 00:00:46 UTC (rev 3831)
@@ -41,7 +41,6 @@
 
 #include "pub_core_mallocfree.h"  // for type 'ArenaId'
 #include "pub_core_scheduler.h"   // for types 'ThreadState', 'ThreadArchState'
-#include "pub_core_stacktrace.h"  // for type 'StackTrace'
 
 /* ---------------------------------------------------------------------
    Global macros.
@@ -50,10 +49,6 @@
 /* Max length of a text fragment used to construct error messages. */
 #define VG_ERRTXT_LEN 4096
 
-/* The maximum number of calls we're prepared to save in a
-   backtrace. */
-#define VG_DEEPEST_BACKTRACE 50
-
 /* Useful macros */
 /* a - alignment - must be a power of 2 */
 #define ROUNDDN(p, a) ((Addr)(p) & ~((Addr)(a)-1))
@@ -166,7 +161,7 @@
 __attribute__ ((__noreturn__))
 extern void  VG_(core_panic)      ( Char* str );
 __attribute__ ((__noreturn__))
-extern void  VG_(core_panic_at)   ( Char* str, StackTrace ips );
+extern void  VG_(core_panic_at)   ( Char* str, Addr ip, Addr sp, Addr fp );
 
 /* Called when some unhandleable client behaviour is detected.
    Prints a msg and aborts. */

Modified: trunk/coregrind/m_signals.c
===================================================================
--- trunk/coregrind/m_signals.c 2005-05-31 22:15:14 UTC (rev 3830)
+++ trunk/coregrind/m_signals.c 2005-06-01 00:00:46 UTC (rev 3831)
@@ -87,6 +87,7 @@
 #include "pub_core_options.h"
 #include "pub_core_signals.h"
 #include "pub_core_sigframe.h"
+#include "pub_core_stacktrace.h"
 #include "pub_core_syscalls.h"
 #include "pub_core_tooliface.h"
 
@@ -1845,7 +1846,6 @@
       from the client's code, then we can jump back into the scheduler
       and have it delivered.  Otherwise it's a Valgrind bug. */
    {  
-      Addr ips[ VG_(clo_backtrace_size) ];
       ThreadState *tst = VG_(get_ThreadState)(VG_(get_lwp_tid)(VG_(gettid)()));
 
       if (VG_(sigismember)(&tst->sig_mask, sigNo)) {
@@ -1889,15 +1889,10 @@
       //  tid = VG_(master_tid);
       vg_assert(tid != 0);
 
-      tst = VG_(get_ThreadState)(tid);
-      VG_(get_StackTrace2)(ips, VG_(clo_backtrace_size),
-                           VGP_UCONTEXT_INSTR_PTR(uc),
-                           VGP_UCONTEXT_STACK_PTR(uc),
-                           VGP_UCONTEXT_FRAME_PTR(uc),
-                           VGP_UCONTEXT_STACK_PTR(uc),
-                           tst->os_state.valgrind_stack_base +
-                           tst->os_state.valgrind_stack_szB);
-      VG_(core_panic_at)("Killed by fatal signal", ips);
+      VG_(core_panic_at)("Killed by fatal signal",
+                         VGP_UCONTEXT_INSTR_PTR(uc),
+                         VGP_UCONTEXT_STACK_PTR(uc),
+                         VGP_UCONTEXT_FRAME_PTR(uc));
    }
 }
 

Modified: trunk/coregrind/pub_core_execontext.h
===================================================================
--- trunk/coregrind/pub_core_execontext.h 2005-05-31 22:15:14 UTC (rev 3830)
+++ trunk/coregrind/pub_core_execontext.h 2005-06-01 00:00:46 UTC (rev 3831)
@@ -41,6 +41,9 @@
 
 #include "pub_core_stacktrace.h"
 
+/* The maximum number of calls we're prepared to save in an ExeContext. */
+#define VG_DEEPEST_BACKTRACE 50
+
 // Print stats (informational only).
 extern void VG_(print_ExeContext_stats) ( void );
 

Modified: trunk/coregrind/vg_mylibc.c
===================================================================
--- trunk/coregrind/vg_mylibc.c 2005-05-31 22:15:14 UTC (rev 3830)
+++ trunk/coregrind/vg_mylibc.c 2005-06-01 00:00:46 UTC (rev 3831)
@@ -941,39 +941,29 @@
 #  error Unknown platform
 #endif
 
-
-/* Fake up an ExeContext which is of our actual real CPU state, so we
-   can print a stack trace.  This isn't terribly useful in the case
-   where we were killed by a signal, since we just get a backtrace
-   into the signal handler.  Also, it could be somewhat risky if we
-   actully got the panic/exception within the execontext/stack
-   dump/symtab code.  But it's better than nothing. */
-static inline void get_and_pp_real_StackTrace(Addr ret)
+__attribute__ ((noreturn))
+static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr fp )
 {
-   Addr ips[VG_DEEPEST_BACKTRACE];
-   Addr sp, fp;
-   Addr stacktop;
-   ThreadId tid = VG_(get_lwp_tid)(VG_(gettid)());
-   ThreadState *tst = VG_(get_ThreadState)(tid);
+   #define BACKTRACE_DEPTH    100         // nice and deep!
+   Addr stacktop, ips[BACKTRACE_DEPTH];
+   ThreadState *tst;
 
-   GET_REAL_SP_AND_FP(sp, fp);
+   tst = VG_(get_ThreadState)( VG_(get_lwp_tid)(VG_(gettid)()) );
 
+   // If necessary, fake up an ExeContext which is of our actual real CPU
+   // state.  Could cause problems if we got the panic/exception within the
+   // execontext/stack dump/symtab code.  But it's better than nothing.
+   if (0 == ip && 0 == sp && 0 == fp) {
+       ip = (Addr)__builtin_return_address(0);
+       GET_REAL_SP_AND_FP(sp, fp);
+   }
+
    stacktop = tst->os_state.valgrind_stack_base +
               tst->os_state.valgrind_stack_szB;
 
-   VG_(get_StackTrace2)(ips, VG_(clo_backtrace_size),
-                        ret, sp, fp, sp, stacktop);
-   VG_(pp_StackTrace)  (ips, VG_(clo_backtrace_size));
-}
+   VG_(get_StackTrace2)(ips, BACKTRACE_DEPTH, ip, sp, fp, sp, stacktop);
+   VG_(pp_StackTrace)  (ips, BACKTRACE_DEPTH);
 
-__attribute__ ((noreturn))
-static void report_and_quit ( const Char* report, StackTrace ips )
-{
-   if (ips == NULL)
-      get_and_pp_real_StackTrace((Addr)__builtin_return_address(0));
-   else
-      VG_(pp_StackTrace)(ips, VG_(clo_backtrace_size));
-  
    VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_done) );
 
    VG_(pp_sched_status)();
@@ -986,6 +976,8 @@
    VG_(printf)("In the bug report, send all the above text, the valgrind\n");
    VG_(printf)("version, and what Linux distro you are using.  Thanks.\n\n");
    VG_(exit)(1);
+
+   #undef BACKTRACE_DEPTH
 }
 
 void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file,
@@ -1002,9 +994,8 @@
      VG_(exit)(2);
    entered = True;
 
-   va_start(vargs,format);
+   va_start(vargs, format);
    VG_(vsprintf) ( bufptr, format, vargs );
-   add_to_vg_sprintf_buf('\0', &bufptr);
    va_end(vargs);
 
    if (isCore) {
@@ -1026,29 +1017,30 @@
    if (!VG_STREQ(buf, ""))
       VG_(printf)("%s: %s\n", component, buf );
 
-   report_and_quit(bugs_to, NULL);
+   report_and_quit(bugs_to, 0,0,0);
 }
 
 __attribute__ ((noreturn))
-static void panic ( Char* name, Char* report, Char* str, StackTrace ips )
+static void panic ( Char* name, Char* report, Char* str,
+                    Addr ip, Addr sp, Addr fp )
 {
    VG_(printf)("\n%s: the 'impossible' happened:\n   %s\n", name, str);
-   report_and_quit(report, ips);
+   report_and_quit(report, ip, sp, fp);
 }
 
-void VG_(core_panic) ( Char* str )
+void VG_(core_panic_at) ( Char* str, Addr ip, Addr sp, Addr fp )
 {
-   panic("valgrind", VG_BUGS_TO, str, NULL);
+   panic("valgrind", VG_BUGS_TO, str, ip, sp, fp);
 }
 
-void VG_(core_panic_at) ( Char* str, StackTrace ips )
+void VG_(core_panic) ( Char* str )
 {
-   panic("valgrind", VG_BUGS_TO, str, ips);
+   VG_(core_panic_at)(str, 0,0,0);
 }
 
 void VG_(tool_panic) ( Char* str )
 {
-   panic(VG_(details).name, VG_(details).bug_reports_to, str, NULL);
+   panic(VG_(details).name, VG_(details).bug_reports_to, str, 0,0,0);
 }
 
 /* Print some helpful-ish text about unimplemented things, and give



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Valgrind-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers