Skip to content

Commit

Permalink
feature: watchpoints (part for #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
godzie44 committed May 17, 2024
1 parent 539ceb0 commit 2d3f6d2
Show file tree
Hide file tree
Showing 44 changed files with 2,955 additions and 325 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ sysinfo = "0.30.0"
indexmap = "2.1.0"
chumsky = { version = "1.0.0-alpha.6", features = ["default", "label"] }
ariadne = "0.4.0"
bit_field = "0.10.1"

[dev-dependencies]
serial_test = "3.0.0"
Expand Down
4 changes: 4 additions & 0 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 16 additions & 15 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[workspace]
members = [
"pastebin",
"todos",
"tokiotiker",
"calc",
"fizzbuzz",
"hello_world",
"vars",
"mt",
"recursion",
"sleeper",
"signals",
"shlib/calc_lib",
"shlib/calc_bin",
"shlib/printer_lib",
"panic",
"pastebin",
"todos",
"tokiotiker",
"calc",
"fizzbuzz",
"hello_world",
"vars",
"mt",
"recursion",
"sleeper",
"signals",
"shlib/calc_lib",
"shlib/calc_bin",
"shlib/printer_lib",
"panic",
"calculations"
]
resolver = "2"
13 changes: 9 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Examples

A list of applications for debugger testing.
A list of applications for debugger testing.

### hello_world

Expand Down Expand Up @@ -30,7 +30,7 @@ Used for test related to type polymorphism.
### sleeper

Long live application.
Used to test debugger attaching to external processes.
Used to test debugger attaching to external processes.

### recursion

Expand All @@ -39,7 +39,8 @@ Used for test debugger behavior with recursive code.

### Pastebin

Example application from [Rocket](https://github.com/SergioBenitez/Rocket) web framework.
Example application from [Rocket](https://github.com/SergioBenitez/Rocket) web
framework.

### Todos

Expand All @@ -56,4 +57,8 @@ Tick 5 seconds and exit. Useful for tokio oracle testing.
### Panic

Program that just panics.
Initiated by user or system panic (like divide by zero panic).
Initiated by user or system panic (like divide by zero panic).

### Calculations

Program that calculates some values. Useful for watchpoints testing.
12 changes: 12 additions & 0 deletions examples/calculations/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "calculations"
version = "0.0.0"
edition = "2021"
workspace = "./.."
publish = false

[[bin]]
name = "calculations"
path = "src/calculations.rs"

[dependencies]
107 changes: 107 additions & 0 deletions examples/calculations/src/calculations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
use std::sync::Mutex;
use std::thread;
use std::time::Duration;

#[allow(clippy::deref_addrof)]
fn calculation_single_value() {
let mut int8 = 1_i8;
int8 += 1;
int8 /= 3;
println!("{int8}");
*&mut int8 = -5;
int8 += 11;
println!("{int8}");
}

fn calculation_four_value() {
let mut a = 1_u64;
let mut b = 2_u64;
let mut c = 3_u64;
let mut d = 4_u64;

a += 5;
b += 1;
c -= 2;
d -= 1;

println!("{}", a + b + c + d);
}

static mut GLOBAL_1: i64 = 1;

fn calculation_global_value() {
unsafe {
GLOBAL_1 -= 1;
GLOBAL_1 += 3;
GLOBAL_1 /= 2;

println!("{GLOBAL_1}");
}
}

static GLOBAL_2: Mutex<u64> = Mutex::new(1);

fn calculation_global_value_2() {
let mut lock = GLOBAL_2.lock().unwrap();
*lock += 1;
thread::sleep(Duration::from_millis(100));
drop(lock);
let mut lock = GLOBAL_2.lock().unwrap();
*lock += 1;
thread::sleep(Duration::from_millis(100));
drop(lock);
}

fn calculation_global_value_mt() {
let t1 = thread::spawn(calculation_global_value_2);
let t2 = thread::spawn(calculation_global_value_2);

t1.join().unwrap();
t2.join().unwrap();

println!("{}", GLOBAL_2.lock().unwrap());
}

fn calculation_local_value_mt() {
let mut a = 1;
a += 1;
thread::scope(|t| {
t.spawn(|| {
a += 5;
});
});

println!("{a}");
}

#[allow(clippy::useless_vec)]
fn calculation_with_complex_types() {
let mut vector = vec![1, 2, 3, 4];
for v in vector.iter_mut() {
*v += 1;
}

struct S {
b: f64,
}
let mut s = S { b: 1_f64 };
s.b *= 2_f64;

let mut vector2 = vec![1, 2];
vector2.push(3);
vector2.push(4);

let mut string = "foo".to_string();
string += " bar";

println!("v[2] = {}, s.b = {}", vector[2], s.b)
}

pub fn main() {
calculation_single_value();
calculation_four_value();
calculation_global_value();
calculation_global_value_mt();
calculation_local_value_mt();
calculation_with_complex_types();
}
2 changes: 1 addition & 1 deletion src/debugger/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Display for RelocatedAddress {

/// Represent address in object files.
/// This address unique per object file but not per process.
#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Debug, Default)]
#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Debug, Default, Ord)]
pub struct GlobalAddress(usize);

impl GlobalAddress {
Expand Down
Loading

0 comments on commit 2d3f6d2

Please sign in to comment.