Skip to content

Commit

Permalink
Backed out macro attempt.
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Oct 1, 2023
1 parent 6c35a47 commit d65dea8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
10 changes: 5 additions & 5 deletions rust-support/chatdbg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chatdbg"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
description = "Rust-specific support for ChatDBG (https://github.com/plasma-umass/chatdbg)."
authors = ["Emery Berger <[email protected]>"]
Expand All @@ -11,8 +11,8 @@ repository = "https://github.com/plasma-umass/ChatDBG/"

[dependencies]
lazy_static = "1.4.0"
quote = "1.0.33"
syn = { version = "2.0.37", features = ["full"] }
# quote = "1.0.33"
# syn = { version = "2.0.37", features = ["full"] }

[lib]
proc-macro = true
# [lib]
# proc-macro = true
24 changes: 1 addition & 23 deletions rust-support/chatdbg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lazy_static::lazy_static! {
static ref FILE_CREATED: AtomicBool = AtomicBool::new(false);
}

fn chatdbg() {
pub fn chatdbg() {
// Set a custom panic hook.
panic::set_hook(Box::new(|info| {
let _guard = FILE_MUTEX.lock().unwrap(); // Lock Mutex to synchronize access.
Expand Down Expand Up @@ -50,25 +50,3 @@ fn chatdbg() {
}));
}

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn};

#[proc_macro_attribute]
pub fn startup(_attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as ItemFn);

let expanded = quote! {
#input // Repeat the original function

fn main() {
chatdbg(); // Call your startup function
// Call the original main function
::std::rt::resume_unwind(::std::panic::catch_unwind(|| {
#input
}));
}
};

TokenStream::from(expanded)
}

0 comments on commit d65dea8

Please sign in to comment.