MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / main

Function main

debugger/examples/testdata.rs:8–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7#[tokio::main]
8async fn main() -> Result<()> {
9 let file_path = "file://./testdata.ss";
10 let mut options = SeaConnectOptions::default();
11 options.set_file_connect_options(|options| {
12 options.set_end_with_eos(true);
13 });
14 let streamer = SeaStreamer::connect(file_path.parse()?, options).await?;
15 let stream_key = StreamKey::new(EVENT_STREAM)?;
16 let producer = streamer
17 .create_producer(stream_key, Default::default())
18 .await?;
19 let mut rand = random(12345678);
20 let mut state = State::new();
21
22 for i in 0..10000 {
23 let is_fn_call = i < 4 || rand.next().unwrap() % 10 < 6; // bias towards function call
24 let mut event = if is_fn_call {
25 let fid = state.i();
26 EventStream::function_call(
27 BpId(1),
28 1,
29 &ActiveFrame {
30 frame_id: fid,
31 stack_pointer: 0xffff,
32 program_counter: 0xffff,
33 function_name: format!("fn_{fid}"),
34 function_id: SBFunctionId(0), // don't care
35 },
36 )
37 } else {
38 let fid = state.o();
39 if fid.is_none() {
40 println!("oopps! seems like we ended early");
41 break;
42 }
43 let fid = fid.unwrap();
44 EventStream::function_return(
45 BpId(1),
46 1,
47 &ActiveFrame {
48 frame_id: fid,
49 stack_pointer: 0xffff,
50 program_counter: 0xffff,
51 function_name: format!("fn_{fid}"),
52 function_id: SBFunctionId(0), // don't care
53 },
54 )
55 };
56 if is_fn_call {
57 event.write_unit_v("value");
58 } else {
59 if state.i % 6 == 0 {
60 event.write_opaque_v("return_value");
61 } else {
62 event.write_unit_v("return_value");
63 }
64 }
65 producer.send(event)?;

Callers

nothing calls this directly

Calls 10

randomFunction · 0.85
BpIdClass · 0.85
SBFunctionIdClass · 0.85
parseMethod · 0.80
nextMethod · 0.80
oMethod · 0.80
write_unit_vMethod · 0.80
write_opaque_vMethod · 0.80
iMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected