Skip to content

Commit

Permalink
Tidy up gdb_c_test.
Browse files Browse the repository at this point in the history
1) Make gdb_c_test.rs more lean by removing command line arguments
that simply set env vars. We can just set the vars directly, e.g.:

YKD_LOG_IR=aot bin/gdb_c_test simple.c

It's a bit more typing, but it means this tool is smaller and more
resilient to env var additions/removals/changes. I note it still
referenced the old YKD_LOG_JITSTATE var, which was renamed to YK_LOG.

2) Remove no longer working -b.

The JIT code generator broke this, but I haven't missed it to be honest.
  • Loading branch information
vext01 committed Dec 13, 2024
1 parent efd6661 commit 9c01317
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
14 changes: 1 addition & 13 deletions docs/src/dev/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,7 @@ This will automatically compile and run the `tests/c/simple.c` test under GDB.
This would be ideal if you have a crashing trace, as it will dump you into a
GDB shell at the time of the crash.

The tool has some other switches which are useful for other situations, e.g.:

```
bin/gdb_c_test -j -s -b10 simple.c
```

compiles and runs `tests/c/simple.c` test under GDB with [JIT state
debugging](runtime_config.md#ykd_print_jitstate)
enabled, with [compilation
serialised](runtime_config.md#ykd_serialise_compilation), setting a
breakpoint on the first 10 traces compiled.

For a list of all switches available, run:
To see what else you can do with `gdb_c_test`, run:

```
bin/gdb_c_test --help
Expand Down
35 changes: 0 additions & 35 deletions tests/src/bin/gdb_c_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ struct Args {
/// The test to attach gdb to.
test_file: PathBuf,

/// Run the test with `YKD_LOG_IR` set to the specified value.
#[arg(short, long)]
log_ir: Option<String>,

/// Run the test with `YKD_LOG_JITSTATE=-`
#[arg(short = 'j', long)]
log_jitstate: bool,

/// Run the test with `YKD_SERIALISE_COMPILATION=1`
#[arg(short, long)]
serialise_compilation: bool,

/// Set breakpoints at the first `N` compiled traces.
#[arg(short = 'b', long)]
num_breaks: Option<usize>,

/// Don't immediately run the program.
#[arg(short = 'n', long)]
wait_at_prompt: bool,
Expand Down Expand Up @@ -76,25 +60,6 @@ fn main() {
let mut gdb = Command::new("gdb");
gdb.arg(&binpath);

if args.serialise_compilation {
gdb.env("YKD_SERIALISE_COMPILATION", "1");
}

if args.log_jitstate {
gdb.env("YKD_LOG_JITSTATE", "1");
}

if let Some(irs) = args.log_ir {
gdb.env("YKD_LOG_IR", irs);
}

if let Some(num_breaks) = args.num_breaks {
gdb.args(["-ex", "set breakpoint pending on"]); // don't prompt for pending breaks.
for i in 0..num_breaks {
gdb.args(["-ex", &format!("b __yk_compiled_trace_{i}")]);
}
}

if !args.wait_at_prompt {
gdb.args(["-ex", "run"]);
}
Expand Down

0 comments on commit 9c01317

Please sign in to comment.