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

Conversation

jonathanpallant
Copy link
Contributor

@jonathanpallant jonathanpallant commented Mar 8, 2023

TODO:

  • Turn down some warning logs
  • Stop the GDB server when probe-run exits (needs us to fork probe-rs-gdb-server)

TODO: Turn down some warning logs
TODO: Stop the GDB server when probe-run exits.
Adds separate argument/env var for GDB Server port. The default is 127.0.0.1:3333.
@@ -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.

/// 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)

@Urhengulas Urhengulas marked this pull request as draft May 15, 2023 16:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants