Preserve, clarify, and extend debug information
`-Cdebuginfo=1` was never line tables only and can't be due to backwards compatibility issues. This was clarified and an option for line tables only was added. Additionally an option for line info directives only was added, which is well needed for some targets. The debug info options should now behave the same as clang's debug info options.
This commit is contained in:
parent
eb3e9c1f45
commit
0504a33383
13 changed files with 126 additions and 54 deletions
|
@ -260,6 +260,8 @@ pub enum SymbolManglingVersion {
|
|||
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
|
||||
pub enum DebugInfo {
|
||||
None,
|
||||
LineDirectivesOnly,
|
||||
LineTablesOnly,
|
||||
Limited,
|
||||
Full,
|
||||
}
|
||||
|
@ -1979,11 +1981,7 @@ fn parse_opt_level(
|
|||
}
|
||||
}
|
||||
|
||||
fn select_debuginfo(
|
||||
matches: &getopts::Matches,
|
||||
cg: &CodegenOptions,
|
||||
error_format: ErrorOutputType,
|
||||
) -> DebugInfo {
|
||||
fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInfo {
|
||||
let max_g = matches.opt_positions("g").into_iter().max();
|
||||
let max_c = matches
|
||||
.opt_strs_pos("C")
|
||||
|
@ -1993,24 +1991,7 @@ fn select_debuginfo(
|
|||
if let Some("debuginfo") = s.split('=').next() { Some(i) } else { None }
|
||||
})
|
||||
.max();
|
||||
if max_g > max_c {
|
||||
DebugInfo::Full
|
||||
} else {
|
||||
match cg.debuginfo {
|
||||
0 => DebugInfo::None,
|
||||
1 => DebugInfo::Limited,
|
||||
2 => DebugInfo::Full,
|
||||
arg => {
|
||||
early_error(
|
||||
error_format,
|
||||
&format!(
|
||||
"debug info level needs to be between \
|
||||
0-2 (instead was `{arg}`)"
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
|
||||
}
|
||||
|
||||
pub(crate) fn parse_assert_incr_state(
|
||||
|
@ -2498,7 +2479,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
|||
// to use them interchangeably. See the note above (regarding `-O` and `-C opt-level`)
|
||||
// for more details.
|
||||
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
|
||||
let debuginfo = select_debuginfo(matches, &cg, error_format);
|
||||
let debuginfo = select_debuginfo(matches, &cg);
|
||||
|
||||
let mut search_paths = vec![];
|
||||
for s in &matches.opt_strs("L") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue