Skip to content

Commit 00b1e88

Browse files
committed
Added a shim around rust_panic to update panic counter
1 parent 221000a commit 00b1e88

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/libstd/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,5 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
340340
/// ```
341341
#[stable(feature = "resume_unwind", since = "1.9.0")]
342342
pub fn resume_unwind(payload: Box<Any + Send>) -> ! {
343-
panicking::rust_panic(payload)
343+
panicking::update_count_then_panic(payload)
344344
}

src/libstd/panicking.rs

+10
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ fn rust_panic_with_hook(msg: Box<Any + Send>,
398398
rust_panic(msg)
399399
}
400400

401+
/// Shim around rust_panic. Called by resume_unwind.
402+
pub fn update_count_then_panic(msg: Box<Any + Send>) -> ! {
403+
PANIC_COUNT.with(|c| {
404+
let prev = c.get();
405+
c.set(prev + 1);
406+
});
407+
408+
rust_panic(msg)
409+
}
410+
401411
/// A private no-mangle function on which to slap yer breakpoints.
402412
#[no_mangle]
403413
#[allow(private_no_mangle_fns)] // yes we get it, but we like breakpoints

0 commit comments

Comments
 (0)