]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When dieing because a fatal signal was received, print a stack trace for
authorTom Hughes <tom@compton.nu>
Sun, 26 Sep 2004 18:44:06 +0000 (18:44 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 26 Sep 2004 18:44:06 +0000 (18:44 +0000)
the location where the signal was received rather then the signal handler.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2725

coregrind/core.h
coregrind/vg_mylibc.c
coregrind/vg_signals.c

index 6b001128a2e57bcbfaeef99123c9fe98bf0b734e..0084d8daa51e4afd2fc8daab9990777a2ddff587 100644 (file)
@@ -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);
index fa64220bf5fa1349a7f2c8d65220e59cf4ea32cb..3f0d50e82bffaaec503a205d1bd2dad8cefd05c7 100644 (file)
@@ -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);
 }
 
 
index 29e7d4c6b151313f2ba17f9a52cd34e2e1b4fa74..b1a4ac1a57e45985012456982ddce80e650e51f2 100644 (file)
@@ -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)));
    }
 }