-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Move ambient gdb discovery from compiletest to bootstrap #149710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,42 @@ | ||
| use std::borrow::Cow; | ||
| use std::path::Path; | ||
|
|
||
| use crate::core::android; | ||
| use crate::core::builder::Builder; | ||
| use crate::utils::exec::BootstrapCommand; | ||
|
|
||
| pub(crate) struct Gdb<'a> { | ||
| pub(crate) gdb: &'a Path, | ||
| pub(crate) gdb: Cow<'a, Path>, | ||
| } | ||
|
|
||
| pub(crate) fn discover_gdb<'a>(builder: &'a Builder<'_>) -> Option<Gdb<'a>> { | ||
| let gdb = builder.config.gdb.as_deref()?; | ||
| pub(crate) fn discover_gdb<'a>( | ||
| builder: &'a Builder<'_>, | ||
| android: Option<&android::Android>, | ||
| ) -> Option<Gdb<'a>> { | ||
| // If there's an explicitly-configured gdb, use that. | ||
| if let Some(gdb) = builder.config.gdb.as_deref() { | ||
| // FIXME(Zalathar): Consider returning None if gdb is an empty string, | ||
| // as a way to explicitly disable ambient gdb discovery. | ||
| let gdb = Cow::Borrowed(gdb); | ||
| return Some(Gdb { gdb }); | ||
| } | ||
|
|
||
| Some(Gdb { gdb }) | ||
| // Otherwise, fall back to whatever gdb is sitting around in PATH. | ||
| // (That's the historical behavior, but maybe we should require opt-in?) | ||
|
|
||
| let gdb: Cow<'_, Path> = match android { | ||
| Some(android::Android { android_cross_path, .. }) => { | ||
| android_cross_path.join("bin/gdb").into() | ||
| } | ||
| None => Path::new("gdb").into(), | ||
| }; | ||
|
|
||
| // Check whether an ambient gdb exists, by running `gdb --version`. | ||
| let output = { | ||
| let mut gdb_command = BootstrapCommand::new(gdb.as_ref()).allow_failure(); | ||
| gdb_command.arg("--version"); | ||
| gdb_command.run_capture(builder) | ||
| }; | ||
|
|
||
| if output.is_success() { Some(Gdb { gdb }) } else { None } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| //! Code for discovering debuggers and debugger-related configuration, so that | ||
| //! it can be passed to compiletest when running debuginfo tests. | ||
|
|
||
| pub(crate) use self::android::{Android, discover_android}; | ||
| pub(crate) use self::gdb::{Gdb, discover_gdb}; | ||
| pub(crate) use self::lldb::{Lldb, discover_lldb}; | ||
|
|
||
| mod android; | ||
| mod gdb; | ||
| mod lldb; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| pub(crate) mod android; | ||
| pub(crate) mod build_steps; | ||
| pub(crate) mod builder; | ||
| pub(crate) mod config; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I'm 100% in favor of opt-in, but that's a separate change.