From: Tom Hughes Date: Sun, 26 Sep 2004 18:44:06 +0000 (+0000) Subject: When dieing because a fatal signal was received, print a stack trace for X-Git-Tag: svn/VALGRIND_3_0_0~1563 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e340476ce0dd4a84cb1d5073566c1f2fa81e079d;p=thirdparty%2Fvalgrind.git When dieing because a fatal signal was received, print a stack trace for the location where the signal was received rather then the signal handler. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2725 --- diff --git a/coregrind/core.h b/coregrind/core.h index 6b001128a2..0084d8daa5 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -1018,6 +1018,8 @@ extern void VG_(core_assert_fail) ( const Char* expr, const Char* file, Int line, const Char* fn ); __attribute__ ((__noreturn__)) extern void VG_(core_panic) ( Char* str ); +__attribute__ ((__noreturn__)) +extern void VG_(core_panic_at) ( Char* str, ExeContext *ec ); /* Tools use VG_(strdup)() which doesn't expose ArenaId */ extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s); diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index fa64220bf5..3f0d50e82b 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -1104,9 +1104,11 @@ static inline ExeContext *get_real_execontext(Addr ret) } __attribute__ ((noreturn)) -static void report_and_quit ( const Char* report ) +static void report_and_quit ( const Char* report, ExeContext *ec ) { - ExeContext *ec = get_real_execontext((Addr)__builtin_return_address(0)); + if (ec == NULL) + ec = get_real_execontext((Addr)__builtin_return_address(0)); + VG_(pp_ExeContext)(ec); VG_(pp_sched_status)(); @@ -1131,7 +1133,7 @@ static void assert_fail ( const Char* expr, const Char* name, const Char* report entered = True; VG_(printf)("\n%s: %s:%d (%s): Assertion `%s' failed.\n", name, file, line, fn, expr ); - report_and_quit(report); + report_and_quit(report, NULL); } void VG_(skin_assert_fail) ( const Char* expr, const Char* file, Int line, const Char* fn ) @@ -1146,21 +1148,26 @@ void VG_(core_assert_fail) ( const Char* expr, const Char* file, Int line, const } __attribute__ ((noreturn)) -static void panic ( Char* name, Char* report, Char* str ) +static void panic ( Char* name, Char* report, Char* str, Addr addr ) { VG_(printf)("\n%s: the `impossible' happened:\n %s\n", name, str); VG_(printf)("Basic block ctr is approximately %llu\n", VG_(bbs_done) ); - report_and_quit(report); + report_and_quit(report, addr); } void VG_(core_panic) ( Char* str ) { - panic("valgrind", VG_BUGS_TO, str); + panic("valgrind", VG_BUGS_TO, str, NULL); +} + +void VG_(core_panic_at) ( Char* str, ExeContext *ec ) +{ + panic("valgrind", VG_BUGS_TO, str, ec); } void VG_(skin_panic) ( Char* str ) { - panic(VG_(details).name, VG_(details).bug_reports_to, str); + panic(VG_(details).name, VG_(details).bug_reports_to, str, NULL); } diff --git a/coregrind/vg_signals.c b/coregrind/vg_signals.c index 29e7d4c6b1..b1a4ac1a57 100644 --- a/coregrind/vg_signals.c +++ b/coregrind/vg_signals.c @@ -1851,7 +1851,11 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex if (0) VG_(kill_self)(sigNo); /* generate a core dump */ - VG_(core_panic)("Killed by fatal signal"); + VG_(core_panic_at)("Killed by fatal signal", + VG_(get_ExeContext2)(uc->uc_mcontext.eip, + uc->uc_mcontext.ebp, + uc->uc_mcontext.esp, + VG_(valgrind_last))); } }