Skip to content

Commit 1835667

Browse files
committed
auto merge of #12816 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
Fixes #12811 as described in the issue.
2 parents c2e5135 + 3ea50f0 commit 1835667

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

src/librustc/driver/driver.rs

+35-25
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ use std::os;
3939
use std::vec_ng::Vec;
4040
use std::vec_ng;
4141
use collections::HashMap;
42-
use getopts::{optopt, optmulti, optflag, optflagopt, opt};
43-
use MaybeHasArg = getopts::Maybe;
44-
use OccurOptional = getopts::Optional;
42+
use getopts::{optopt, optmulti, optflag, optflagopt};
4543
use getopts;
4644
use syntax::ast;
4745
use syntax::abi;
@@ -866,29 +864,41 @@ pub fn build_session_options(matches: &getopts::Matches)
866864
}
867865
Default
868866
} else if matches.opt_present("opt-level") {
869-
match matches.opt_str("opt-level").unwrap() {
870-
~"0" => No,
871-
~"1" => Less,
872-
~"2" => Default,
873-
~"3" => Aggressive,
874-
_ => {
875-
early_error("optimization level needs to be between 0-3")
876-
}
867+
match matches.opt_str("opt-level").as_ref().map(|s| s.as_slice()) {
868+
None |
869+
Some("0") => No,
870+
Some("1") => Less,
871+
Some("2") => Default,
872+
Some("3") => Aggressive,
873+
Some(arg) => {
874+
early_error(format!("optimization level needs to be between 0-3 \
875+
(instead was `{}`)", arg));
876+
}
877877
}
878-
} else { No }
878+
} else {
879+
No
880+
}
879881
};
880882
let gc = debugging_opts & session::GC != 0;
881883

882-
let debuginfo = match matches.opt_default("debuginfo", "2") {
883-
Some(level) => {
884-
match level {
885-
~"0" => NoDebugInfo,
886-
~"1" => LimitedDebugInfo,
887-
~"2" => FullDebugInfo,
888-
_ => early_error("debug info level needs to be between 0-2")
884+
let debuginfo = if matches.opt_present("g") {
885+
if matches.opt_present("debuginfo") {
886+
early_error("-g and --debuginfo both provided");
887+
}
888+
FullDebugInfo
889+
} else if matches.opt_present("debuginfo") {
890+
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
891+
Some("0") => NoDebugInfo,
892+
Some("1") => LimitedDebugInfo,
893+
None |
894+
Some("2") => FullDebugInfo,
895+
Some(arg) => {
896+
early_error(format!("optimization level needs to be between 0-3 \
897+
(instead was `{}`)", arg));
889898
}
890899
}
891-
None => NoDebugInfo
900+
} else {
901+
NoDebugInfo
892902
};
893903

894904
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
@@ -1045,11 +1055,11 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
10451055
optflag("", "crate-file-name", "Output the file(s) that would be written if compilation \
10461056
continued and exit"),
10471057
optflag("", "ls", "List the symbols defined by a library crate"),
1048-
opt("g", "debuginfo", "Emit DWARF debug info to the objects created:
1049-
0 = no debug info,
1050-
1 = line-tables only (for stacktraces),
1051-
2 = full debug info with variable, argument and type information",
1052-
"LEVEL", MaybeHasArg, OccurOptional),
1058+
optflag("g", "", "Equivalent to --debuginfo=2"),
1059+
optopt("", "debuginfo", "Emit DWARF debug info to the objects created:
1060+
0 = no debug info,
1061+
1 = line-tables only (for stacktraces and breakpoints),
1062+
2 = full debug info with variable and type information (same as -g)", "LEVEL"),
10531063
optflag("", "no-trans", "Run all passes except translation; no output"),
10541064
optflag("", "no-analysis", "Parse and expand the output, but run no analysis or produce output"),
10551065
optflag("O", "", "Equivalent to --opt-level=2"),

src/test/debug-info/issue7712.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags:-g1
11+
// compile-flags:--debuginfo=1
1212

1313
pub trait TraitWithDefaultMethod {
1414
fn method(self) {

src/test/debug-info/lexical-scope-in-parameterless-closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-android: FIXME(#10381)
1212

13-
// compile-flags:-g1
13+
// compile-flags:--debuginfo=1
1414
// debugger:run
1515

1616
// Nothing to do here really, just make sure it compiles. See issue #8513.

src/test/debug-info/limited-debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-android: FIXME(#10381)
1212

13-
// compile-flags:-g1
13+
// compile-flags:--debuginfo=1
1414

1515
// Make sure functions have proper names
1616
// debugger:info functions

0 commit comments

Comments
 (0)