mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Improve abort/panic messages to be more distinctive.
This commit is contained in:
parent
883d5aaade
commit
34e1c90c32
@ -2648,7 +2648,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
||||
// HACK(eddyb) redirect any possible panic call to an abort, to avoid
|
||||
// needing to materialize `&core::panic::Location` or `format_args!`.
|
||||
// FIXME(eddyb) find a way to extract the original message.
|
||||
self.abort_with_message("panic!(...)".into());
|
||||
self.abort_with_message("panicked: <unknown message>".into());
|
||||
self.undef(result_type)
|
||||
} else if let Some(mode) = buffer_load_intrinsic {
|
||||
self.codegen_buffer_load_intrinsic(result_type, args, mode)
|
||||
|
@ -339,7 +339,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn abort(&mut self) {
|
||||
self.abort_with_message("intrinsics::abort()".into());
|
||||
self.abort_with_message("aborted: intrinsics::abort() called".into());
|
||||
}
|
||||
|
||||
fn assume(&mut self, _val: Self::Value) {
|
||||
|
@ -330,13 +330,17 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points(
|
||||
let mut fmt = String::new();
|
||||
|
||||
// HACK(eddyb) this improves readability w/ very verbose Vulkan loggers.
|
||||
fmt += "\n ";
|
||||
fmt += "\n";
|
||||
|
||||
if let Some((file, line, col)) = current_debug_src_loc.take() {
|
||||
fmt += &format!("{file}:{line}:{col}: ").replace('%', "%%");
|
||||
}
|
||||
fmt += "[RUST-GPU] ";
|
||||
fmt += &cx[const_str(message)].replace('%', "%%");
|
||||
|
||||
// FIXME(eddyb) deduplicate with "called at" form below
|
||||
// (not trivial becasue both closures would borrow `fmt`).
|
||||
if let Some((file, line, col)) = current_debug_src_loc.take() {
|
||||
fmt += &format!("\n at {file}:{line}:{col}").replace('%', "%%");
|
||||
}
|
||||
|
||||
let mut innermost = true;
|
||||
let mut append_call = |callsite_debug_src_loc, callee: &str| {
|
||||
if innermost {
|
||||
@ -360,6 +364,8 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points(
|
||||
}
|
||||
append_call(None, &debug_printf_context_fmt_str);
|
||||
|
||||
fmt += "\n";
|
||||
|
||||
let abort_inst_def = &mut func_def_body.data_insts[abort_inst];
|
||||
abort_inst_def.kind = DataInstKind::SpvExtInst {
|
||||
ext_set: cx.intern("NonSemantic.DebugPrintf"),
|
||||
|
Loading…
Reference in New Issue
Block a user