|
From: <sv...@va...> - 2005-06-01 00:00:54
|
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 @@
=20
#include "pub_core_mallocfree.h" // for type 'ArenaId'
#include "pub_core_scheduler.h" // for types 'ThreadState', 'ThreadArc=
hState'
-#include "pub_core_stacktrace.h" // for type 'StackTrace'
=20
/* ---------------------------------------------------------------------
Global macros.
@@ -50,10 +49,6 @@
/* Max length of a text fragment used to construct error messages. */
#define VG_ERRTXT_LEN 4096
=20
-/* 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=
);
=20
/* Called when some unhandleable client behaviour is detected.
Prints a msg and aborts. */
Modified: trunk/coregrind/m_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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"
=20
@@ -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. */
{ =20
- Addr ips[ VG_(clo_backtrace_size) ];
ThreadState *tst =3D VG_(get_ThreadState)(VG_(get_lwp_tid)(VG_(get=
tid)()));
=20
if (VG_(sigismember)(&tst->sig_mask, sigNo)) {
@@ -1889,15 +1889,10 @@
// tid =3D VG_(master_tid);
vg_assert(tid !=3D 0);
=20
- tst =3D VG_(get_ThreadState)(tid);
- VG_(get_StackTrace2)(ips, VG_(clo_backtrace_size),=20
- 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 +=20
- 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));
}
}
=20
Modified: trunk/coregrind/pub_core_execontext.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_execontext.h 2005-05-31 22:15:14 UTC (rev 38=
30)
+++ trunk/coregrind/pub_core_execontext.h 2005-06-01 00:00:46 UTC (rev 38=
31)
@@ -41,6 +41,9 @@
=20
#include "pub_core_stacktrace.h"
=20
+/* 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 );
=20
Modified: trunk/coregrind/vg_mylibc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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
=20
-
-/* 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 =3D VG_(get_lwp_tid)(VG_(gettid)());
- ThreadState *tst =3D VG_(get_ThreadState)(tid);
+ #define BACKTRACE_DEPTH 100 // nice and deep!
+ Addr stacktop, ips[BACKTRACE_DEPTH];
+ ThreadState *tst;
=20
- GET_REAL_SP_AND_FP(sp, fp);
+ tst =3D VG_(get_ThreadState)( VG_(get_lwp_tid)(VG_(gettid)()) );
=20
+ // If necessary, fake up an ExeContext which is of our actual real CP=
U
+ // 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 =3D=3D ip && 0 =3D=3D sp && 0 =3D=3D fp) {
+ ip =3D (Addr)__builtin_return_address(0);
+ GET_REAL_SP_AND_FP(sp, fp);
+ }
+
stacktop =3D tst->os_state.valgrind_stack_base +=20
tst->os_state.valgrind_stack_szB;
=20
- 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);
=20
-__attribute__ ((noreturn))
-static void report_and_quit ( const Char* report, StackTrace ips )
-{
- if (ips =3D=3D NULL)
- get_and_pp_real_StackTrace((Addr)__builtin_return_address(0));
- else
- VG_(pp_StackTrace)(ips, VG_(clo_backtrace_size));
- =20
VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_done=
) );
=20
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
}
=20
void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file,=
=20
@@ -1002,9 +994,8 @@
VG_(exit)(2);
entered =3D True;
=20
- va_start(vargs,format);
+ va_start(vargs, format);
VG_(vsprintf) ( bufptr, format, vargs );
- add_to_vg_sprintf_buf('\0', &bufptr);
va_end(vargs);
=20
if (isCore) {
@@ -1026,29 +1017,30 @@
if (!VG_STREQ(buf, ""))
VG_(printf)("%s: %s\n", component, buf );
=20
- report_and_quit(bugs_to, NULL);
+ report_and_quit(bugs_to, 0,0,0);
}
=20
__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);
}
=20
-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);
}
=20
-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);
}
=20
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);
}
=20
/* Print some helpful-ish text about unimplemented things, and give
|