Skip to content

Commit

Permalink
debuginfo: Re-introduce the notion of line-table-only debuginfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 6, 2014
1 parent ea71a08 commit 1938e87
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/librustc/back/link.rs
Expand Up @@ -12,7 +12,7 @@ use back::archive::{Archive, METADATA_FILENAME};
use back::rpath;
use back::svh::Svh;
use driver::driver::{CrateTranslation, OutputFilenames};
use driver::session::Session;
use driver::session::{NoDebugInfo, Session};
use driver::session;
use lib::llvm::llvm;
use lib::llvm::ModuleRef;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub mod write {
use back::link::{OutputTypeExe, OutputTypeLlvmAssembly};
use back::link::{OutputTypeObject};
use driver::driver::{CrateTranslation, OutputFilenames};
use driver::session::Session;
use driver::session::{NoDebugInfo, Session};
use driver::session;
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub mod write {

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

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

// On OSX, debuggers need this utility to get run to do some munging of
// the symbols
if sess.targ_cfg.os == abi::OsMacos && sess.opts.debuginfo {
if sess.targ_cfg.os == abi::OsMacos && (sess.opts.debuginfo != NoDebugInfo) {
// FIXME (#9639): This needs to handle non-utf8 paths
match Process::status("dsymutil",
[out_filename.as_str().unwrap().to_owned()]) {
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/driver/driver.rs
Expand Up @@ -11,7 +11,7 @@

use back::link;
use back::{arm, x86, x86_64, mips};
use driver::session::{Aggressive, CrateTypeExecutable};
use driver::session::{Aggressive, CrateTypeExecutable, FullDebugInfo, NoDebugInfo};
use driver::session::{Session, Session_, No, Less, Default};
use driver::session;
use front;
Expand Down Expand Up @@ -865,7 +865,11 @@ pub fn build_session_options(matches: &getopts::Matches)
} else { No }
};
let gc = debugging_opts & session::GC != 0;
let debuginfo = matches.opt_present("g") || matches.opt_present("debuginfo");
let debuginfo = if matches.opt_present("g") || matches.opt_present("debuginfo") {
FullDebugInfo
} else {
NoDebugInfo
};

let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
Path::new(s.as_slice())
Expand Down
11 changes: 9 additions & 2 deletions src/librustc/driver/session.rs
Expand Up @@ -114,6 +114,13 @@ pub enum OptLevel {
Aggressive // -O3
}

#[deriving(Clone, Eq)]
pub enum DebugInfoLevel {
NoDebugInfo,
LimitedDebugInfo,
FullDebugInfo,
}

#[deriving(Clone)]
pub struct Options {
// The crate config requested for the session, which may be combined
Expand All @@ -122,7 +129,7 @@ pub struct Options {

gc: bool,
optimize: OptLevel,
debuginfo: bool,
debuginfo: DebugInfoLevel,
lint_opts: ~[(lint::Lint, lint::level)],
output_types: ~[back::link::OutputType],
// This was mutable for rustpkg, which updates search paths based on the
Expand Down Expand Up @@ -314,7 +321,7 @@ pub fn basic_options() -> @Options {
crate_types: ~[],
gc: false,
optimize: No,
debuginfo: false,
debuginfo: NoDebugInfo,
lint_opts: ~[],
output_types: ~[],
addl_lib_search_paths: @RefCell::new(HashSet::new()),
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/trans/_match.rs
Expand Up @@ -195,6 +195,7 @@
#[allow(non_camel_case_types)];

use back::abi;
use driver::session::FullDebugInfo;
use lib::llvm::{llvm, ValueRef, BasicBlockRef};
use middle::const_eval;
use middle::borrowck::root_map_key;
Expand Down Expand Up @@ -1393,7 +1394,7 @@ fn insert_lllocals<'a>(bcx: &'a Block<'a>,
llmap.get().insert(binding_info.id, datum);
}

if bcx.sess().opts.debuginfo {
if bcx.sess().opts.debuginfo == FullDebugInfo {
debuginfo::create_match_binding_metadata(bcx,
ident,
binding_info.id,
Expand Down Expand Up @@ -2052,7 +2053,7 @@ pub fn store_arg<'a>(mut bcx: &'a Block<'a>,
// like `x: T`
let arg_ty = node_id_type(bcx, pat.id);
if type_of::arg_is_indirect(bcx.ccx(), arg_ty)
&& !bcx.ccx().sess.opts.debuginfo {
&& bcx.ccx().sess.opts.debuginfo != FullDebugInfo {
// Don't copy an indirect argument to an alloca, the caller
// already put it in a temporary alloca and gave it up, unless
// we emit extra-debug-info, which requires local allocas :(.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -28,7 +28,7 @@
use back::link::{mangle_exported_name};
use back::{link, abi};
use driver::session;
use driver::session::Session;
use driver::session::{Session, NoDebugInfo, FullDebugInfo};
use driver::driver::OutputFilenames;
use driver::driver::{CrateAnalysis, CrateTranslation};
use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
Expand Down Expand Up @@ -1367,7 +1367,7 @@ fn copy_args_to_allocas<'a>(fcx: &FunctionContext<'a>,

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

if fcx.ccx.sess.opts.debuginfo {
if fcx.ccx.sess.opts.debuginfo == FullDebugInfo {
debuginfo::create_argument_metadata(bcx, &args[i]);
}
}
Expand Down Expand Up @@ -2678,7 +2678,7 @@ pub fn trans_crate(sess: session::Session,
}

glue::emit_tydescs(ccx);
if ccx.sess.opts.debuginfo {
if ccx.sess.opts.debuginfo != NoDebugInfo {
debuginfo::finalize(ccx);
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/closure.rs
Expand Up @@ -11,6 +11,7 @@

use back::abi;
use back::link::mangle_internal_name_by_path_and_seq;
use driver::session::FullDebugInfo;
use lib::llvm::ValueRef;
use middle::moves;
use middle::trans::base::*;
Expand Down Expand Up @@ -299,7 +300,7 @@ fn load_environment<'a>(bcx: &'a Block<'a>, cdata_ty: ty::t,

// Store the pointer to closure data in an alloca for debug info because that's what the
// llvm.dbg.declare intrinsic expects
let env_pointer_alloca = if bcx.ccx().sess.opts.debuginfo {
let env_pointer_alloca = if bcx.ccx().sess.opts.debuginfo == FullDebugInfo {
let alloc = alloc_ty(bcx, ty::mk_mut_ptr(bcx.tcx(), cdata_ty), "__debuginfo_env_ptr");
Store(bcx, llcdata, alloc);
Some(alloc)
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/trans/context.rs
Expand Up @@ -10,6 +10,7 @@


use driver::session;
use driver::session::NoDebugInfo;
use lib::llvm::{ContextRef, ModuleRef, ValueRef};
use lib::llvm::{llvm, TargetData, TypeNames};
use lib::llvm::mk_target_data;
Expand Down Expand Up @@ -151,7 +152,7 @@ impl CrateContext {
let tn = TypeNames::new();

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

let (crate_map_name, crate_map) = decl_crate_map(sess, link_meta.clone(), llmod);
let dbg_cx = if sess.opts.debuginfo {
let dbg_cx = if sess.opts.debuginfo != NoDebugInfo {
Some(debuginfo::CrateDebugContext::new(llmod))
} else {
None
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/controlflow.rs
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use lib::llvm::*;
use driver::session::FullDebugInfo;
use middle::lang_items::{FailFnLangItem, FailBoundsCheckFnLangItem};
use middle::trans::base::*;
use middle::trans::build::*;
Expand Down Expand Up @@ -54,7 +55,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
match d.node {
ast::DeclLocal(ref local) => {
bcx = init_local(bcx, *local);
if cx.sess().opts.debuginfo {
if cx.sess().opts.debuginfo == FullDebugInfo {
debuginfo::create_local_var_metadata(bcx, *local);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -126,6 +126,7 @@ is still disabled, so there is no need to do anything special with source locati


use driver::session;
use driver::session::{FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, ContextRef, ValueRef};
use lib::llvm::debuginfo::*;
Expand Down Expand Up @@ -530,7 +531,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
fn_ast_id: ast::NodeId,
param_substs: Option<@param_substs>,
llfn: ValueRef) -> FunctionDebugContext {
if !cx.sess.opts.debuginfo {
if cx.sess.opts.debuginfo == NoDebugInfo {
return DebugInfoDisabled;
}

Expand Down Expand Up @@ -706,7 +707,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
fn_decl: &ast::FnDecl,
param_substs: Option<@param_substs>,
error_span: Span) -> DIArray {
if !cx.sess.opts.debuginfo {
if cx.sess.opts.debuginfo == LimitedDebugInfo {
return create_DIArray(DIB(cx), []);
}

Expand Down Expand Up @@ -783,8 +784,8 @@ pub fn create_function_debug_context(cx: &CrateContext,
name_to_append_suffix_to.push_str(",");
}

// Only create type information if debuginfo is enabled
if cx.sess.opts.debuginfo {
// Only create type information if full debuginfo is enabled
if cx.sess.opts.debuginfo == FullDebugInfo {
let actual_self_type_metadata = type_metadata(cx,
actual_self_type,
codemap::DUMMY_SP);
Expand Down Expand Up @@ -827,8 +828,8 @@ pub fn create_function_debug_context(cx: &CrateContext,
name_to_append_suffix_to.push_str(",");
}

// Again, only create type information if debuginfo is enabled
if cx.sess.opts.debuginfo {
// Again, only create type information if full debuginfo is enabled
if cx.sess.opts.debuginfo == FullDebugInfo {
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
let param_metadata = token::get_ident(ident).get()
.with_c_str(|name| {
Expand Down

0 comments on commit 1938e87

Please sign in to comment.