Skip to content

Commit 0756a0f

Browse files
committed
hot llm garbage
1 parent 1bc505f commit 0756a0f

12 files changed

Lines changed: 1007 additions & 2 deletions

File tree

.cargo/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ rustflags = [
2525
"-Wclippy::option_option",
2626
"-Wclippy::ref_option_ref",
2727
"-Wclippy::rest_pat_in_fully_bound_structs",
28-
"-Wclippy::string_to_string",
2928
"-Wclippy::suboptimal_flops",
3029
"-Wclippy::verbose_file_reads",
3130
# "-Wclippy::unused_self", # might be interesting to explore this...

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ name = "armv4t_multicore"
4949
required-features = ["std"]
5050

5151
[workspace]
52-
members = ["gdbstub_arch"]
52+
members = ["gdbstub_arch", "gdbstub_test", "gdbstub_test/macros", "gdbstub_tests"]
5353
exclude = ["example_no_std"]

gdbstub_test/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "gdbstub_test"
3+
version = "0.1.0"
4+
edition = "2018"
5+
publish = false
6+
7+
[dependencies]
8+
anyhow = "1.0"
9+
crossbeam-channel = "0.5"
10+
libc = "0.2"
11+
serde = { version = "1.0", features = ["derive"] }
12+
serde_gdbmi = "0.1"
13+
tempfile = "3.6"
14+
gdbstub_test_macros = { path = "macros" }
15+
log = "0.4"

gdbstub_test/macros/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "gdbstub_test_macros"
3+
version = "0.1.0"
4+
edition = "2018"
5+
publish = false
6+
7+
[lib]
8+
proc-macro = true
9+
10+
[dependencies]
11+
proc-macro2 = "1.0"
12+
quote = "1.0"
13+
syn = { version = "2.0", features = ["full"] }

gdbstub_test/macros/src/lib.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//! Procedural macros for gdbstub regression testing.
2+
3+
use proc_macro::TokenStream;
4+
use quote::quote;
5+
use syn::{parse_macro_input, ItemFn};
6+
7+
/// Attribute macro to wrap a test function with gdbstub regression testing boilerplate.
8+
#[proc_macro_attribute]
9+
pub fn gdbstub_test(args: TokenStream, input: TokenStream) -> TokenStream {
10+
let args_str = args.to_string().replace(" ", "");
11+
let mut parts = args_str.split(',');
12+
let target = parts.next().unwrap().to_string();
13+
let is_extended = parts.next() == Some("extended");
14+
15+
let input = parse_macro_input!(input as ItemFn);
16+
17+
let name = &input.sig.ident;
18+
let body = &input.block;
19+
let attrs = &input.attrs;
20+
let vis = &input.vis;
21+
22+
let result = quote! {
23+
#[test]
24+
#(#attrs)*
25+
#vis fn #name() -> anyhow::Result<()> {
26+
use anyhow::Context;
27+
let target = #target;
28+
let test_elf = gdbstub_test::find_test_elf(target);
29+
if !test_elf.exists() {
30+
anyhow::bail!("Test ELF not found at {:?}. Did you build the examples?", test_elf);
31+
}
32+
33+
let emu = gdbstub_test::EmulatorProcess::spawn(target).context("failed to spawn emulator")?;
34+
let mut gdb = gdbstub_test::GdbMiClient::spawn(None, test_elf.to_str().unwrap()).context("failed to spawn gdb")?;
35+
36+
if #is_extended {
37+
gdb.connect_extended_uds(emu.uds_path().to_str().unwrap()).context("failed to connect gdb to emulator in extended mode")?;
38+
} else {
39+
gdb.connect_uds(emu.uds_path().to_str().unwrap()).context("failed to connect gdb to emulator")?;
40+
}
41+
42+
let mut func = |mut gdb: gdbstub_test::GdbMiClient| -> anyhow::Result<()> {
43+
#body
44+
};
45+
46+
func(gdb)
47+
}
48+
};
49+
50+
result.into()
51+
}

0 commit comments

Comments
 (0)