Skip to content

Commit

Permalink
Add mc-sgx-panic-log
Browse files Browse the repository at this point in the history
Add a panic handler that will log the panic info from an SGX enclave to
the host
  • Loading branch information
nick-mobilecoin committed Dec 16, 2022
1 parent 7d70100 commit 01e877c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
]
exclude = [
"panic/abort",
"panic/log",
"test_enclave",
]

Expand Down
15 changes: 15 additions & 0 deletions panic/log/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "mc-sgx-panic-log"
version = "0.1.0"
edition = "2021"
authors = ["MobileCoin"]
rust-version = "1.62.1"
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/mobilecoinfoundation/sgx-std"
description = "Panic handler for an SGX enclave that logs to the untrusted (host)"
categories = ["hardware-support", "no-std"]
keywords = ["sgx", "no-std", "panic"]

[dependencies]
mc-sgx-io = { path = "../../io", version = "0.1.0" }
21 changes: 21 additions & 0 deletions panic/log/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MobileCoin SGX: Panic handler that logs to untrusted (host)

[![Project Chat][chat-image]][chat-link]<!--
-->![License][license-image]<!--
-->![Target][target-image]<!--
-->[![Crates.io][crate-image]][crate-link]<!--
-->[![Docs Status][docs-image]][docs-link]<!--
-->[![Dependency Status][deps-image]][deps-link]

Panic handler for an SGX enclave that logs to the untrusted (host)

[chat-image]: https://img.shields.io/discord/844353360348971068?style=flat-square
[chat-link]: https://mobilecoin.chat
[license-image]: https://img.shields.io/crates/l/mc-sgx-panic-log?style=flat-square
[target-image]: https://img.shields.io/badge/target-sgx-red?style=flat-square
[crate-image]: https://img.shields.io/crates/v/mc-sgx-panic-log.svg?style=flat-square
[crate-link]: https://crates.io/crates/mc-sgx-panic-log
[docs-image]: https://img.shields.io/docsrs/mc-sgx-panic-log?style=flat-square
[docs-link]: https://docs.rs/crate/mc-sgx-panic-log
[deps-image]: https://deps.rs/crate/mc-sgx-panic-log/0.1.0/status.svg?style=flat-square
[deps-link]: https://deps.rs/crate/mc-sgx-panic-log/0.1.0
21 changes: 21 additions & 0 deletions panic/log/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022 The MobileCoin Foundation

#![doc = include_str!("../README.md")]
#![deny(missing_docs, missing_debug_implementations)]
#![no_std]

extern crate alloc;
use alloc::string::ToString;
use core::panic::PanicInfo;
use mc_sgx_io::StdError;

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
let stderr = StdError;

// Ignore the result, we're already panicking we can't really do much if
// `write_all()` fails
let _ = stderr.write_all(info.to_string().as_bytes());

loop {}
}

0 comments on commit 01e877c

Please sign in to comment.