Skip to content
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

add emit_debug_gdb_scripts target option and .. #49728

Merged
merged 2 commits into from
Apr 7, 2018
Merged
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
1 change: 1 addition & 0 deletions src/librustc_back/target/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn opts() -> TargetOptions {
exe_allocation_crate: super::maybe_jemalloc(),
has_elf_tls: version >= (10, 7),
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
Copy link
Member

Choose a reason for hiding this comment

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

Is this really right? Does no one use gdb on macOS?

Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't directly answer your question but this is equivalent to the current logic. See the diff on src/librustc_trans/debuginfo/gdb.rs; it has !cx.sess().target.target.options.is_like_osx. So I assume the answer is that people mainly use lldb?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this makes sense!

Copy link
Contributor

Choose a reason for hiding this comment

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

@whitequark Locally gdb is a pain to use on macOS because it would need to be signed in order to have access to process information and no-one cares to actually sign it and it's not shipped with macOS. It is "usable" for target != host but not necessarily the best option.

.. Default::default()
}
}
6 changes: 6 additions & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ pub struct TargetOptions {

/// Whether or not bitcode is embedded in object files
pub embed_bitcode: bool,

/// Whether a .debug_gdb_scripts section will be added to the output object file
pub emit_debug_gdb_scripts: bool,
}

impl Default for TargetOptions {
Expand Down Expand Up @@ -550,6 +553,7 @@ impl Default for TargetOptions {
codegen_backend: "llvm".to_string(),
default_hidden_visibility: false,
embed_bitcode: false,
emit_debug_gdb_scripts: true,
}
}
}
Expand Down Expand Up @@ -799,6 +803,7 @@ impl Target {
key!(codegen_backend);
key!(default_hidden_visibility, bool);
key!(embed_bitcode, bool);
key!(emit_debug_gdb_scripts, bool);

if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) {
for name in array.iter().filter_map(|abi| abi.as_string()) {
Expand Down Expand Up @@ -1002,6 +1007,7 @@ impl ToJson for Target {
target_option_val!(codegen_backend);
target_option_val!(default_hidden_visibility);
target_option_val!(embed_bitcode);
target_option_val!(emit_debug_gdb_scripts);

if default.abi_blacklist != self.options.abi_blacklist {
d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_back/target/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub fn target() -> TargetResult {
// too much overhead for such small target.
trap_unreachable: false,

// See the thumb_base.rs file for an explanation of this value
emit_debug_gdb_scripts: false,

.. Default::default( )
}
})
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_back/target/thumb_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ pub fn opts() -> TargetOptions {
// costs it involves.
relocation_model: "static".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
// When this section is added a volatile load to its start address is also generated. This
// volatile load is a footgun as it can end up loading an invalid memory address, depending
// on how the user set up their linker scripts. This section adds pretty printer for stuff
// like std::Vec, which is not that used in no-std context, so it's best to left it out
// until we figure a way to add the pretty printers without requiring a volatile load cf.
// rust-lang/rust#44993.
emit_debug_gdb_scripts: false,
.. Default::default()
}
}
1 change: 1 addition & 0 deletions src/librustc_back/target/windows_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn opts() -> TargetOptions {
],
custom_unwind_resume: true,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,

.. Default::default()
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/target/windows_msvc_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn opts() -> TargetOptions {
crt_static_allows_dylibs: true,
crt_static_respected: true,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,

.. Default::default()
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_trans/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
"omit_gdb_pretty_printer_section");

!omit_gdb_pretty_printer_section &&
!cx.sess().target.target.options.is_like_osx &&
!cx.sess().target.target.options.is_like_windows &&
cx.sess().opts.debuginfo != NoDebugInfo
cx.sess().opts.debuginfo != NoDebugInfo &&
cx.sess().target.target.options.emit_debug_gdb_scripts
}