Skip to content

Commit 1938e87

Browse files
debuginfo: Re-introduce the notion of line-table-only debuginfo.
1 parent ea71a08 commit 1938e87

File tree

9 files changed

+39
-23
lines changed

9 files changed

+39
-23
lines changed

src/librustc/back/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use back::archive::{Archive, METADATA_FILENAME};
1212
use back::rpath;
1313
use back::svh::Svh;
1414
use driver::driver::{CrateTranslation, OutputFilenames};
15-
use driver::session::Session;
15+
use driver::session::{NoDebugInfo, Session};
1616
use driver::session;
1717
use lib::llvm::llvm;
1818
use lib::llvm::ModuleRef;
@@ -92,7 +92,7 @@ pub mod write {
9292
use back::link::{OutputTypeExe, OutputTypeLlvmAssembly};
9393
use back::link::{OutputTypeObject};
9494
use driver::driver::{CrateTranslation, OutputFilenames};
95-
use driver::session::Session;
95+
use driver::session::{NoDebugInfo, Session};
9696
use driver::session;
9797
use lib::llvm::llvm;
9898
use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
@@ -148,7 +148,7 @@ pub mod write {
148148

149149
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a parameter.
150150
// FIXME: #11954: mac64 unwinding may not work with fp elim
151-
let no_fp_elim = sess.opts.debuginfo ||
151+
let no_fp_elim = (sess.opts.debuginfo != NoDebugInfo) ||
152152
(sess.targ_cfg.os == abi::OsMacos &&
153153
sess.targ_cfg.arch == abi::X86_64);
154154

@@ -1052,7 +1052,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
10521052

10531053
// On OSX, debuggers need this utility to get run to do some munging of
10541054
// the symbols
1055-
if sess.targ_cfg.os == abi::OsMacos && sess.opts.debuginfo {
1055+
if sess.targ_cfg.os == abi::OsMacos && (sess.opts.debuginfo != NoDebugInfo) {
10561056
// FIXME (#9639): This needs to handle non-utf8 paths
10571057
match Process::status("dsymutil",
10581058
[out_filename.as_str().unwrap().to_owned()]) {

src/librustc/driver/driver.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use back::link;
1313
use back::{arm, x86, x86_64, mips};
14-
use driver::session::{Aggressive, CrateTypeExecutable};
14+
use driver::session::{Aggressive, CrateTypeExecutable, FullDebugInfo, NoDebugInfo};
1515
use driver::session::{Session, Session_, No, Less, Default};
1616
use driver::session;
1717
use front;
@@ -865,7 +865,11 @@ pub fn build_session_options(matches: &getopts::Matches)
865865
} else { No }
866866
};
867867
let gc = debugging_opts & session::GC != 0;
868-
let debuginfo = matches.opt_present("g") || matches.opt_present("debuginfo");
868+
let debuginfo = if matches.opt_present("g") || matches.opt_present("debuginfo") {
869+
FullDebugInfo
870+
} else {
871+
NoDebugInfo
872+
};
869873

870874
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
871875
Path::new(s.as_slice())

src/librustc/driver/session.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ pub enum OptLevel {
114114
Aggressive // -O3
115115
}
116116

117+
#[deriving(Clone, Eq)]
118+
pub enum DebugInfoLevel {
119+
NoDebugInfo,
120+
LimitedDebugInfo,
121+
FullDebugInfo,
122+
}
123+
117124
#[deriving(Clone)]
118125
pub struct Options {
119126
// The crate config requested for the session, which may be combined
@@ -122,7 +129,7 @@ pub struct Options {
122129

123130
gc: bool,
124131
optimize: OptLevel,
125-
debuginfo: bool,
132+
debuginfo: DebugInfoLevel,
126133
lint_opts: ~[(lint::Lint, lint::level)],
127134
output_types: ~[back::link::OutputType],
128135
// This was mutable for rustpkg, which updates search paths based on the
@@ -314,7 +321,7 @@ pub fn basic_options() -> @Options {
314321
crate_types: ~[],
315322
gc: false,
316323
optimize: No,
317-
debuginfo: false,
324+
debuginfo: NoDebugInfo,
318325
lint_opts: ~[],
319326
output_types: ~[],
320327
addl_lib_search_paths: @RefCell::new(HashSet::new()),

src/librustc/middle/trans/_match.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
#[allow(non_camel_case_types)];
196196

197197
use back::abi;
198+
use driver::session::FullDebugInfo;
198199
use lib::llvm::{llvm, ValueRef, BasicBlockRef};
199200
use middle::const_eval;
200201
use middle::borrowck::root_map_key;
@@ -1393,7 +1394,7 @@ fn insert_lllocals<'a>(bcx: &'a Block<'a>,
13931394
llmap.get().insert(binding_info.id, datum);
13941395
}
13951396

1396-
if bcx.sess().opts.debuginfo {
1397+
if bcx.sess().opts.debuginfo == FullDebugInfo {
13971398
debuginfo::create_match_binding_metadata(bcx,
13981399
ident,
13991400
binding_info.id,
@@ -2052,7 +2053,7 @@ pub fn store_arg<'a>(mut bcx: &'a Block<'a>,
20522053
// like `x: T`
20532054
let arg_ty = node_id_type(bcx, pat.id);
20542055
if type_of::arg_is_indirect(bcx.ccx(), arg_ty)
2055-
&& !bcx.ccx().sess.opts.debuginfo {
2056+
&& bcx.ccx().sess.opts.debuginfo != FullDebugInfo {
20562057
// Don't copy an indirect argument to an alloca, the caller
20572058
// already put it in a temporary alloca and gave it up, unless
20582059
// we emit extra-debug-info, which requires local allocas :(.

src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use back::link::{mangle_exported_name};
2929
use back::{link, abi};
3030
use driver::session;
31-
use driver::session::Session;
31+
use driver::session::{Session, NoDebugInfo, FullDebugInfo};
3232
use driver::driver::OutputFilenames;
3333
use driver::driver::{CrateAnalysis, CrateTranslation};
3434
use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
@@ -1367,7 +1367,7 @@ fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>,
13671367

13681368
bcx = _match::store_arg(bcx, args[i].pat, arg_datum, arg_scope_id);
13691369

1370-
if fcx.ccx.sess.opts.debuginfo {
1370+
if fcx.ccx.sess.opts.debuginfo == FullDebugInfo {
13711371
debuginfo::create_argument_metadata(bcx, &args[i]);
13721372
}
13731373
}
@@ -2678,7 +2678,7 @@ pub fn trans_crate(sess: session::Session,
26782678
}
26792679
26802680
glue::emit_tydescs(ccx);
2681-
if ccx.sess.opts.debuginfo {
2681+
if ccx.sess.opts.debuginfo != NoDebugInfo {
26822682
debuginfo::finalize(ccx);
26832683
}
26842684

src/librustc/middle/trans/closure.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use back::abi;
1313
use back::link::mangle_internal_name_by_path_and_seq;
14+
use driver::session::FullDebugInfo;
1415
use lib::llvm::ValueRef;
1516
use middle::moves;
1617
use middle::trans::base::*;
@@ -299,7 +300,7 @@ fn load_environment<'a>(bcx: &'a Block<'a>, cdata_ty: ty::t,
299300

300301
// Store the pointer to closure data in an alloca for debug info because that's what the
301302
// llvm.dbg.declare intrinsic expects
302-
let env_pointer_alloca = if bcx.ccx().sess.opts.debuginfo {
303+
let env_pointer_alloca = if bcx.ccx().sess.opts.debuginfo == FullDebugInfo {
303304
let alloc = alloc_ty(bcx, ty::mk_mut_ptr(bcx.tcx(), cdata_ty), "__debuginfo_env_ptr");
304305
Store(bcx, llcdata, alloc);
305306
Some(alloc)

src/librustc/middle/trans/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
use driver::session;
13+
use driver::session::NoDebugInfo;
1314
use lib::llvm::{ContextRef, ModuleRef, ValueRef};
1415
use lib::llvm::{llvm, TargetData, TypeNames};
1516
use lib::llvm::mk_target_data;
@@ -151,7 +152,7 @@ impl CrateContext {
151152
let tn = TypeNames::new();
152153

153154
let mut intrinsics = base::declare_intrinsics(llmod);
154-
if sess.opts.debuginfo {
155+
if sess.opts.debuginfo != NoDebugInfo {
155156
base::declare_dbg_intrinsics(llmod, &mut intrinsics);
156157
}
157158
let int_type = Type::int(targ_cfg.arch);
@@ -165,7 +166,7 @@ impl CrateContext {
165166
tn.associate_type("str_slice", &str_slice_ty);
166167

167168
let (crate_map_name, crate_map) = decl_crate_map(sess, link_meta.clone(), llmod);
168-
let dbg_cx = if sess.opts.debuginfo {
169+
let dbg_cx = if sess.opts.debuginfo != NoDebugInfo {
169170
Some(debuginfo::CrateDebugContext::new(llmod))
170171
} else {
171172
None

src/librustc/middle/trans/controlflow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use lib::llvm::*;
12+
use driver::session::FullDebugInfo;
1213
use middle::lang_items::{FailFnLangItem, FailBoundsCheckFnLangItem};
1314
use middle::trans::base::*;
1415
use middle::trans::build::*;
@@ -54,7 +55,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
5455
match d.node {
5556
ast::DeclLocal(ref local) => {
5657
bcx = init_local(bcx, *local);
57-
if cx.sess().opts.debuginfo {
58+
if cx.sess().opts.debuginfo == FullDebugInfo {
5859
debuginfo::create_local_var_metadata(bcx, *local);
5960
}
6061
}

src/librustc/middle/trans/debuginfo.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ is still disabled, so there is no need to do anything special with source locati
126126

127127

128128
use driver::session;
129+
use driver::session::{FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
129130
use lib::llvm::llvm;
130131
use lib::llvm::{ModuleRef, ContextRef, ValueRef};
131132
use lib::llvm::debuginfo::*;
@@ -530,7 +531,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
530531
fn_ast_id: ast::NodeId,
531532
param_substs: Option<@param_substs>,
532533
llfn: ValueRef) -> FunctionDebugContext {
533-
if !cx.sess.opts.debuginfo {
534+
if cx.sess.opts.debuginfo == NoDebugInfo {
534535
return DebugInfoDisabled;
535536
}
536537

@@ -706,7 +707,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
706707
fn_decl: &ast::FnDecl,
707708
param_substs: Option<@param_substs>,
708709
error_span: Span) -> DIArray {
709-
if !cx.sess.opts.debuginfo {
710+
if cx.sess.opts.debuginfo == LimitedDebugInfo {
710711
return create_DIArray(DIB(cx), []);
711712
}
712713

@@ -783,8 +784,8 @@ pub fn create_function_debug_context(cx: &CrateContext,
783784
name_to_append_suffix_to.push_str(",");
784785
}
785786

786-
// Only create type information if debuginfo is enabled
787-
if cx.sess.opts.debuginfo {
787+
// Only create type information if full debuginfo is enabled
788+
if cx.sess.opts.debuginfo == FullDebugInfo {
788789
let actual_self_type_metadata = type_metadata(cx,
789790
actual_self_type,
790791
codemap::DUMMY_SP);
@@ -827,8 +828,8 @@ pub fn create_function_debug_context(cx: &CrateContext,
827828
name_to_append_suffix_to.push_str(",");
828829
}
829830

830-
// Again, only create type information if debuginfo is enabled
831-
if cx.sess.opts.debuginfo {
831+
// Again, only create type information if full debuginfo is enabled
832+
if cx.sess.opts.debuginfo == FullDebugInfo {
832833
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
833834
let param_metadata = token::get_ident(ident).get()
834835
.with_c_str(|name| {

0 commit comments

Comments
 (0)