about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorNikhil Shagrithaya <nikhilshagri@gmail.com>2016-07-20 18:35:25 +0530
committerNikhil Shagrithaya <nikhilshagri@gmail.com>2016-08-10 22:04:41 +0530
commit00b1e8868053fda34114cef901c88574ab2fdf69 (patch)
tree338b0322c0937a4a6de5646bb8260a844fe12c22 /src/libstd
parent221000abbeb233edafff2a00b9b10c2d13f4ad05 (diff)
downloadrust-00b1e8868053fda34114cef901c88574ab2fdf69.tar.gz
rust-00b1e8868053fda34114cef901c88574ab2fdf69.zip
Added a shim around rust_panic to update panic counter
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/panic.rs2
-rw-r--r--src/libstd/panicking.rs10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs
index ba18d15f5c4..2f67081e0d7 100644
--- a/src/libstd/panic.rs
+++ b/src/libstd/panic.rs
@@ -340,5 +340,5 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
 /// ```
 #[stable(feature = "resume_unwind", since = "1.9.0")]
 pub fn resume_unwind(payload: Box<Any + Send>) -> ! {
-    panicking::rust_panic(payload)
+    panicking::update_count_then_panic(payload)
 }
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index 4473e79a294..a22e2004a6b 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -398,6 +398,16 @@ fn rust_panic_with_hook(msg: Box<Any + Send>,
     rust_panic(msg)
 }
 
+/// Shim around rust_panic. Called by resume_unwind.
+pub fn update_count_then_panic(msg: Box<Any + Send>) -> ! {
+    PANIC_COUNT.with(|c| {
+        let prev = c.get();
+        c.set(prev + 1);
+    });
+
+    rust_panic(msg)
+}
+
 /// A private no-mangle function on which to slap yer breakpoints.
 #[no_mangle]
 #[allow(private_no_mangle_fns)] // yes we get it, but we like breakpoints