|
From: <sv...@va...> - 2005-07-20 05:37:41
|
Author: njn
Date: 2005-07-20 03:41:31 +0100 (Wed, 20 Jul 2005)
New Revision: 4205
Log:
Reinstate stack trace printing on assertion failures. It's terrible
for the module dependency graph, but it's very useful.
Modified:
trunk/coregrind/m_libcassert.c
trunk/coregrind/m_stacktrace.c
trunk/coregrind/pub_core_stacktrace.h
Modified: trunk/coregrind/m_libcassert.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_libcassert.c 2005-07-19 23:46:08 UTC (rev 4204)
+++ trunk/coregrind/m_libcassert.c 2005-07-20 02:41:31 UTC (rev 4205)
@@ -29,12 +29,12 @@
*/
=20
#include "pub_core_basics.h"
-//zz hash include "pub_core_threadstate.h"
+#include "pub_core_threadstate.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
-//zz hash inklood "pub_cor_libcproc.h" // For VG_(gettid)()
-//zz hash inklood "pub_cor_stacktrace.h"
+#include "pub_core_libcproc.h" // For VG_(gettid)()
+#include "pub_core_stacktrace.h"
#include "pub_core_syscall.h"
#include "pub_core_tooliface.h" // For VG_(details).{name,bug_report=
s_to}
#include "vki_unistd.h"
@@ -43,7 +43,6 @@
Assertery.
------------------------------------------------------------------ */
=20
-#if 0 //zz
#if defined(VGP_x86_linux)
# define GET_REAL_SP_AND_FP(sp, fp) \
asm("movl %%esp, %0;" \
@@ -67,7 +66,6 @@
#endif
=20
#define BACKTRACE_DEPTH 100 // nice and deep!
-#endif //zz
=20
/* Pull down the entire world */
void VG_(exit)( Int status )
@@ -81,48 +79,46 @@
}
=20
// Print the scheduler status.
-//zz static void pp_sched_status ( void )
-//zz {
-//zz Int i;=20
-//zz VG_(printf)("\nsched status:\n");=20
-//zz VG_(printf)(" running_tid=3D%d\n", VG_(get_running_tid)());
-//zz for (i =3D 1; i < VG_N_THREADS; i++) {
-//zz if (VG_(threads)[i].status =3D=3D VgTs_Empty) continue;
-//zz VG_(printf)( "\nThread %d: status =3D %s\n", i,=20
-//zz VG_(name_of_ThreadStatus)(VG_(threads)[i].status=
) );
-//zz VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH );
-//zz }
-//zz VG_(printf)("\n");
-//zz }
+static void pp_sched_status ( void )
+{
+ Int i;=20
+ VG_(printf)("\nsched status:\n");=20
+ VG_(printf)(" running_tid=3D%d\n", VG_(get_running_tid)());
+ for (i =3D 1; i < VG_N_THREADS; i++) {
+ if (VG_(threads)[i].status =3D=3D VgTs_Empty) continue;
+ VG_(printf)( "\nThread %d: status =3D %s\n", i,=20
+ VG_(name_of_ThreadStatus)(VG_(threads)[i].status) );
+ VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH );
+ }
+ VG_(printf)("\n");
+}
=20
__attribute__ ((noreturn))
static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr=
fp )
{
-//zz Addr stacktop;
-//zz Addr ips[BACKTRACE_DEPTH];
-//zz ThreadState *tst;
-//zz=20
-//zz tst =3D VG_(get_ThreadState)( VG_(get_lwp_tid)(VG_(gettid)()) );
-//zz=20
-//zz // If necessary, fake up an ExeContext which is of our actual re=
al CPU
-//zz // state. Could cause problems if we got the panic/exception wi=
thin the
-//zz // execontext/stack dump/symtab code. But it's better than noth=
ing.
-//zz if (0 =3D=3D ip && 0 =3D=3D sp && 0 =3D=3D fp) {
-//zz ip =3D (Addr)__builtin_return_address(0);
-//zz GET_REAL_SP_AND_FP(sp, fp);
-//zz }
-//zz=20
-//zz stacktop =3D tst->os_state.valgrind_stack_base +=20
-//zz tst->os_state.valgrind_stack_szB;
-//zz=20
-//zz VG_(get_StackTrace2)(ips, BACKTRACE_DEPTH, ip, sp, fp, sp, stack=
top);
-//zz VG_(pp_StackTrace) (ips, BACKTRACE_DEPTH);
-//zz=20
-//zz // Don't print this, as it's not terribly interesting and avoids=
a
-//zz // dependence on m_scheduler/, which would be crazy.
-//zz //VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(b=
bs_done) );
-//zz=20
-//zz pp_sched_status();
+ Addr stacktop;
+ Addr ips[BACKTRACE_DEPTH];
+ ThreadState *tst =3D VG_(get_ThreadState)( VG_(get_lwp_tid)(VG_(getti=
d)()) );
+=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);
+ }
+=20
+ stacktop =3D tst->os_state.valgrind_stack_base +=20
+ tst->os_state.valgrind_stack_szB;
+=20
+ VG_(get_StackTrace2)(ips, BACKTRACE_DEPTH, ip, sp, fp, sp, stacktop);
+ VG_(pp_StackTrace) (ips, BACKTRACE_DEPTH);
+=20
+ // Don't print this, as it's not terribly interesting and avoids a
+ // dependence on m_scheduler/, which would be crazy.
+ //VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_do=
ne) );
+=20
+ pp_sched_status();
VG_(printf)("\n");
VG_(printf)("Note: see also the FAQ.txt in the source distribution.\n=
");
VG_(printf)("It contains workarounds to several common problems.\n");
@@ -196,8 +192,7 @@
panic(VG_(details).name, VG_(details).bug_reports_to, str, 0,0,0);
}
=20
-/* Print some helpful-ish text about unimplemented things, and give
- up. */
+/* Print some helpful-ish text about unimplemented things, and give up. =
*/
void VG_(unimplemented) ( Char* msg )
{
VG_(message)(Vg_UserMsg, "");
@@ -220,12 +215,10 @@
"Valgrind has to exit now. Sorry. Bye!");
VG_(message)(Vg_UserMsg,
"");
-//zz pp_sched_status();
+ pp_sched_status();
VG_(exit)(1);
}
=20
-
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_stacktrace.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_stacktrace.c 2005-07-19 23:46:08 UTC (rev 4204)
+++ trunk/coregrind/m_stacktrace.c 2005-07-20 02:41:31 UTC (rev 4205)
@@ -65,7 +65,6 @@
/* Take a snapshot of the client's stack, putting the up to 'n_ips' IPs=20
into 'ips'. In order to be thread-safe, we pass in the thread's IP
and FP. Returns number of IPs put in 'ips'. */
-static
UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips,=20
Addr ip, Addr sp, Addr fp,
Addr fp_min, Addr fp_max_orig )
Modified: trunk/coregrind/pub_core_stacktrace.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_stacktrace.h 2005-07-19 23:46:08 UTC (rev 42=
04)
+++ trunk/coregrind/pub_core_stacktrace.h 2005-07-20 02:41:31 UTC (rev 42=
05)
@@ -38,10 +38,10 @@
=20
#include "pub_tool_stacktrace.h"
=20
-//zz // Variant that gives a little more control over the stack-walking.
-//zz extern UInt VG_(get_StackTrace2) ( StackTrace ips, UInt n_ips,=20
-//zz Addr ip, Addr sp, Addr fp,=20
-//zz Addr fp_min, Addr fp_max );
+// Variant that gives a little more control over the stack-walking.
+extern UInt VG_(get_StackTrace2) ( StackTrace ips, UInt n_ips,=20
+ Addr ip, Addr sp, Addr fp,=20
+ Addr fp_min, Addr fp_max );
=20
#endif // __PUB_CORE_STACKTRACE_H
=20
|
|
From: Josef W. <Jos...@gm...> - 2005-07-20 08:44:42
|
On Wednesday 20 July 2005 04:41, sv...@va... wrote:
> Author: njn
> Date: 2005-07-20 03:41:31 +0100 (Wed, 20 Jul 2005)
> New Revision: 4205
>
> Log:
> Reinstate stack trace printing on assertion failures. It's terrible
> for the module dependency graph, but it's very useful.
I suppose this can be solved by using callbacks ("interface") without
disturbing the module dependency graph: m_libcassert.c would signal via the
interface that the action of "pp_sched_status" is needed at some point in
time, but would not have the implementation, and thus no dependency.
The user of m_libcassert can register the correct handler when it also uses
m_stacktrace.
Josef
|
|
From: Tom H. <to...@co...> - 2005-07-20 08:49:20
|
In message <200...@gm...>
Josef Weidendorfer <Jos...@gm...> wrote:
> On Wednesday 20 July 2005 04:41, sv...@va... wrote:
>> Author: njn
>> Date: 2005-07-20 03:41:31 +0100 (Wed, 20 Jul 2005)
>> New Revision: 4205
>>
>> Log:
>> Reinstate stack trace printing on assertion failures. It's terrible
>> for the module dependency graph, but it's very useful.
>
> I suppose this can be solved by using callbacks ("interface") without
> disturbing the module dependency graph: m_libcassert.c would signal via the
> interface that the action of "pp_sched_status" is needed at some point in
> time, but would not have the implementation, and thus no dependency.
> The user of m_libcassert can register the correct handler when it also uses
> m_stacktrace.
You don't even need to go that far - making all users of assert pass
a callback function is a bit nasty.
Better is to have a static callback function in m_libcassert and a
routine to register it - then when an assertion fires the callback is
called if there is one. During startup the callback can be registered
once the point has been reached where is it possible.
That way assertions get stack traces when possible and the loops in
the dependency graph are broken.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|