From: Julian Seward Date: Wed, 17 Apr 2002 19:35:12 +0000 (+0000) Subject: Show backtraces for all threads in vg_assert, VG_(panic) and X-Git-Tag: svn/VALGRIND_1_0_3~358 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fda47ff9106ad07b86ed30194958d44a2b0b02e5;p=thirdparty%2Fvalgrind.git Show backtraces for all threads in vg_assert, VG_(panic) and VG_(unimplemented). In future this will not be enabled by default due to the danger of recursion of assertion failures. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@92 --- diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index cd831c8d24..c4ba60310b 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -550,6 +550,7 @@ extern VgSchedReturnCode VG_(scheduler) ( void ); extern void VG_(scheduler_init) ( void ); +extern void VG_(pp_sched_status) ( void ); /* vg_oursignalhandler() might longjmp(). Here's the jmp_buf. */ extern jmp_buf VG_(scheduler_jmpbuf); diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 06b2e978f1..7c7f61219e 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -1152,6 +1152,7 @@ extern void VG_(unimplemented) ( Char* msg ) "Valgrind has to exit now. Sorry. Bye!"); VG_(message)(Vg_UserMsg, ""); + VG_(pp_sched_status)(); VG_(exit)(1); } diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index c8ff2cb8dc..2b92a8b664 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -843,6 +843,7 @@ void VG_(assert_fail) ( Char* expr, Char* file, Int line, Char* fn ) { VG_(printf)("\n%s: %s:%d (%s): Assertion `%s' failed.\n", "valgrind", file, line, fn, expr ); + VG_(pp_sched_status)(); VG_(printf)("Please report this bug to me at: %s\n\n", EMAIL_ADDR); VG_(shutdown_logging)(); VG_(exit)(1); @@ -852,6 +853,7 @@ void VG_(panic) ( Char* str ) { VG_(printf)("\nvalgrind: the `impossible' happened:\n %s\n", str); VG_(printf)("Basic block ctr is approximately %llu\n", VG_(bbs_done) ); + VG_(pp_sched_status)(); VG_(printf)("Please report this bug to me at: %s\n\n", EMAIL_ADDR); VG_(shutdown_logging)(); VG_(exit)(1); diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 770fbd3782..b2aa9dda58 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -127,14 +127,14 @@ static void do_nontrivial_clientreq ( ThreadId tid ); Helper functions for the scheduler. ------------------------------------------------------------------ */ -static -void pp_sched_status ( void ) +/* Print the scheduler status. */ +void VG_(pp_sched_status) ( void ) { Int i; VG_(printf)("\nsched status:\n"); for (i = 0; i < VG_N_THREADS; i++) { if (vg_threads[i].status == VgTs_Empty) continue; - VG_(printf)("tid %d: ", i); + VG_(printf)("\nThread %d: status = ", i); switch (vg_threads[i].status) { case VgTs_Runnable: VG_(printf)("Runnable\n"); break; case VgTs_WaitFD: VG_(printf)("WaitFD\n"); break; @@ -144,6 +144,9 @@ void pp_sched_status ( void ) case VgTs_Sleeping: VG_(printf)("Sleeping\n"); break; default: VG_(printf)("???"); break; } + VG_(pp_ExeContext)( + VG_(get_ExeContext)( False, vg_threads[i].m_eip, + vg_threads[i].m_ebp )); } VG_(printf)("\n"); } @@ -992,7 +995,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) /* No runnable threads and no prospect of any appearing even if we wait for an arbitrary length of time. In short, we have a deadlock. */ - pp_sched_status(); + VG_(pp_sched_status)(); return VgSrc_Deadlock; } @@ -1098,7 +1101,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) VG_(message)(Vg_DebugMsg, "thread %d: %ld bbs, event %s", tid, VG_(bbs_done), name_of_sched_event(trc) ); - + vg_assert(VG_(bbs_done) < 1000000); /* Examine the thread's return code to figure out why it stopped, and handle requests. */ diff --git a/vg_include.h b/vg_include.h index cd831c8d24..c4ba60310b 100644 --- a/vg_include.h +++ b/vg_include.h @@ -550,6 +550,7 @@ extern VgSchedReturnCode VG_(scheduler) ( void ); extern void VG_(scheduler_init) ( void ); +extern void VG_(pp_sched_status) ( void ); /* vg_oursignalhandler() might longjmp(). Here's the jmp_buf. */ extern jmp_buf VG_(scheduler_jmpbuf); diff --git a/vg_main.c b/vg_main.c index 06b2e978f1..7c7f61219e 100644 --- a/vg_main.c +++ b/vg_main.c @@ -1152,6 +1152,7 @@ extern void VG_(unimplemented) ( Char* msg ) "Valgrind has to exit now. Sorry. Bye!"); VG_(message)(Vg_UserMsg, ""); + VG_(pp_sched_status)(); VG_(exit)(1); } diff --git a/vg_mylibc.c b/vg_mylibc.c index c8ff2cb8dc..2b92a8b664 100644 --- a/vg_mylibc.c +++ b/vg_mylibc.c @@ -843,6 +843,7 @@ void VG_(assert_fail) ( Char* expr, Char* file, Int line, Char* fn ) { VG_(printf)("\n%s: %s:%d (%s): Assertion `%s' failed.\n", "valgrind", file, line, fn, expr ); + VG_(pp_sched_status)(); VG_(printf)("Please report this bug to me at: %s\n\n", EMAIL_ADDR); VG_(shutdown_logging)(); VG_(exit)(1); @@ -852,6 +853,7 @@ void VG_(panic) ( Char* str ) { VG_(printf)("\nvalgrind: the `impossible' happened:\n %s\n", str); VG_(printf)("Basic block ctr is approximately %llu\n", VG_(bbs_done) ); + VG_(pp_sched_status)(); VG_(printf)("Please report this bug to me at: %s\n\n", EMAIL_ADDR); VG_(shutdown_logging)(); VG_(exit)(1); diff --git a/vg_scheduler.c b/vg_scheduler.c index 770fbd3782..b2aa9dda58 100644 --- a/vg_scheduler.c +++ b/vg_scheduler.c @@ -127,14 +127,14 @@ static void do_nontrivial_clientreq ( ThreadId tid ); Helper functions for the scheduler. ------------------------------------------------------------------ */ -static -void pp_sched_status ( void ) +/* Print the scheduler status. */ +void VG_(pp_sched_status) ( void ) { Int i; VG_(printf)("\nsched status:\n"); for (i = 0; i < VG_N_THREADS; i++) { if (vg_threads[i].status == VgTs_Empty) continue; - VG_(printf)("tid %d: ", i); + VG_(printf)("\nThread %d: status = ", i); switch (vg_threads[i].status) { case VgTs_Runnable: VG_(printf)("Runnable\n"); break; case VgTs_WaitFD: VG_(printf)("WaitFD\n"); break; @@ -144,6 +144,9 @@ void pp_sched_status ( void ) case VgTs_Sleeping: VG_(printf)("Sleeping\n"); break; default: VG_(printf)("???"); break; } + VG_(pp_ExeContext)( + VG_(get_ExeContext)( False, vg_threads[i].m_eip, + vg_threads[i].m_ebp )); } VG_(printf)("\n"); } @@ -992,7 +995,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) /* No runnable threads and no prospect of any appearing even if we wait for an arbitrary length of time. In short, we have a deadlock. */ - pp_sched_status(); + VG_(pp_sched_status)(); return VgSrc_Deadlock; } @@ -1098,7 +1101,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) VG_(message)(Vg_DebugMsg, "thread %d: %ld bbs, event %s", tid, VG_(bbs_done), name_of_sched_event(trc) ); - + vg_assert(VG_(bbs_done) < 1000000); /* Examine the thread's return code to figure out why it stopped, and handle requests. */