Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Draft: Start a GDB server with --gdblisten 127.0.0.1:1337 #388

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- [#380] Add `--erase-all` flag
- [#379] Update to `probe-rs v0.17`
- [#378] Update to `probe-rs v0.16`
- [#86] Add GDB server support

[#384]: https://github.com/knurling-rs/probe-run/pull/384
[#381]: https://github.com/knurling-rs/probe-run/pull/381
[#380]: https://github.com/knurling-rs/probe-run/pull/380
[#379]: https://github.com/knurling-rs/probe-run/pull/379
[#378]: https://github.com/knurling-rs/probe-run/pull/378
[#86]: https://github.com/knurling-rs/probe-run/pull/388

## [v0.3.6] - 2023-01-23

Expand Down
55 changes: 55 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 @@ -27,6 +27,7 @@ log = "0.4"
object = { version = "0.30", default-features = false }
probe-rs = "0.17"
signal-hook = "0.3"
gdb-server = "0.17"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the alphabetical ordering. Makes it easier to scan through it.


[dev-dependencies]
dirs = "4"
Expand Down
17 changes: 17 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ pub struct Opts {
#[arg(long)]
pub verify: bool,

/// Sets which port we bind the GDB Server to.
///
/// Note: doesn't necessarily start the GDB Server. See `--gdb-on-start` and
/// `--gdb-on-crash`.
#[arg(long, env = "PROBE_RUN_GDB_PORT")]
pub gdb_port: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered if this should be Option<SocketAddr> instead? This will give users a suitable error message if they provide an invalid address.

$ cargo run -- --gdbport 127.0.0:3333
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/krate --gdbport '127.0.0:3333'`
error: invalid value '127.0.0:3333' for '--gdbport <GDBPORT>': invalid socket address syntax

For more information, try '--help'.

But, since GdbInstanceConfiguration::from_session takes a Option<impl Into<String>>, I am unsure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. We can always turn the valid socket address back into a string before giving it to the GDB server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we should warn if they provide a gdb-port but fail to activate either of the GDB options (-on-start or -on-fault)


/// Starts the GDB Server right after flashing.
///
/// You must use GDB to start the processor or it won't run.
#[arg(long, conflicts_with = "gdb_on_fault")]
pub gdb_on_start: bool,

/// Starts the GDB Server only if the chip faults.
#[arg(long, conflicts_with = "gdb_on_start")]
pub gdb_on_fault: bool,

/// Prints version information
#[arg(short = 'V', long)]
version: bool,
Expand Down
Loading