Skip to content

Basic debugging information support #1331

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

Merged
merged 21 commits into from
Dec 19, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
10030a3
Generate basic debug info for files, functions and compile units.
jdm Nov 10, 2011
e383004
Add debug info for local vars, basic fundamental types, and lexical b…
jdm Nov 16, 2011
fa6d871
Build fix.
jdm Nov 16, 2011
544bcfe
Fix LLVM assertions when lowering log statements.
jdm Nov 17, 2011
e95c56f
Fix up subprogram composite type nodes, and lexical block context nodes.
jdm Nov 18, 2011
0b30352
Fix up local variable support so it actually works.
jdm Nov 18, 2011
1da4b3b
Fix build error after rebasing.
jdm Nov 18, 2011
0752252
Use proper size and alignment of types for debuginfo.
jdm Dec 3, 2011
6c26b89
Add argument metadata and aborted return value code.
jdm Dec 6, 2011
064d757
Handle inferred basic types when generating debug information for types.
jdm Dec 6, 2011
e25f6d0
Remove rebase error.
jdm Dec 7, 2011
134585b
Add debug information for boxed and unique values.
jdm Dec 7, 2011
f43ed8f
Fix up ast types after literal changes.
jdm Dec 8, 2011
30d019d
Add record debug information.
jdm Dec 9, 2011
61e8b44
Add support for vectors.
jdm Dec 11, 2011
8597077
Clean up some names and factor out some common code.
jdm Dec 14, 2011
c6f16ed
Hide extended, unfinished debug information behind --xg compiler flag.
jdm Dec 14, 2011
df6052c
Remove source line generation craziness. Ensure incorrect subprogram …
jdm Dec 19, 2011
52dbe4c
Fix merge error and rebasing changes for debug information.
jdm Dec 19, 2011
1d3d28b
Long lines.
jdm Dec 19, 2011
6637340
Properly calculate base working dir for compile units.
jdm Dec 19, 2011
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
16 changes: 9 additions & 7 deletions src/comp/driver/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ fn build_session_options(match: getopts::match)
let libcore = !opt_present(match, "no-core");
let verify = !opt_present(match, "no-verify");
let save_temps = opt_present(match, "save-temps");
let debuginfo = opt_present(match, "g");
let extra_debuginfo = opt_present(match, "xg");
let debuginfo = opt_present(match, "g") || extra_debuginfo;
let stats = opt_present(match, "stats");
let time_passes = opt_present(match, "time-passes");
let time_llvm_passes = opt_present(match, "time-llvm-passes");
Expand Down Expand Up @@ -468,6 +469,7 @@ fn build_session_options(match: getopts::match)
libcore: libcore,
optimize: opt_level,
debuginfo: debuginfo,
extra_debuginfo: extra_debuginfo,
verify: verify,
save_temps: save_temps,
stats: stats,
Expand All @@ -487,7 +489,7 @@ fn build_session_options(match: getopts::match)
ret sopts;
}

fn build_session(sopts: @session::options) -> session::session {
fn build_session(sopts: @session::options, input: str) -> session::session {
let target_cfg = build_target_config(sopts);
let cstore = cstore::mk_cstore();
let filesearch = filesearch::mk_filesearch(
Expand All @@ -496,7 +498,7 @@ fn build_session(sopts: @session::options) -> session::session {
sopts.addl_lib_search_paths);
ret session::session(target_cfg, sopts, cstore,
@{cm: codemap::new_codemap(), mutable next_id: 1},
none, 0u, filesearch, false);
none, 0u, filesearch, false, fs::dirname(input));
}

fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {
Expand All @@ -516,7 +518,7 @@ fn opts() -> [getopts::opt] {
optflag("emit-llvm"), optflagopt("pretty"),
optflag("ls"), optflag("parse-only"), optflag("no-trans"),
optflag("O"), optopt("opt-level"), optmulti("L"), optflag("S"),
optopt("o"), optopt("out-dir"),
optopt("o"), optopt("out-dir"), optflag("xg"),
optflag("c"), optflag("g"), optflag("save-temps"),
optopt("sysroot"), optopt("target"), optflag("stats"),
optflag("time-passes"), optflag("time-llvm-passes"),
Expand Down Expand Up @@ -642,7 +644,7 @@ fn main(args: [str]) {
};

let sopts = build_session_options(match);
let sess = build_session(sopts);
let sess = build_session(sopts, ifile);
let odir = getopts::opt_maybe_str(match, "out-dir");
let ofile = getopts::opt_maybe_str(match, "o");
let cfg = build_configuration(sess, binary, ifile);
Expand Down Expand Up @@ -674,7 +676,7 @@ mod test {
ok(m) { m }
};
let sessopts = build_session_options(match);
let sess = build_session(sessopts);
let sess = build_session(sessopts, "");
let cfg = build_configuration(sess, "whatever", "whatever");
assert (attr::contains_name(cfg, "test"));
}
Expand All @@ -688,7 +690,7 @@ mod test {
ok(m) { m }
};
let sessopts = build_session_options(match);
let sess = build_session(sessopts);
let sess = build_session(sessopts, "");
let cfg = build_configuration(sess, "whatever", "whatever");
let test_items = attr::find_meta_items_by_name(cfg, "test");
assert (vec::len(test_items) == 1u);
Expand Down
7 changes: 6 additions & 1 deletion src/comp/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type options =
libcore: bool,
optimize: uint,
debuginfo: bool,
extra_debuginfo: bool,
verify: bool,
save_temps: bool,
stats: bool,
Expand Down Expand Up @@ -59,7 +60,8 @@ obj session(targ_cfg: @config,
mutable main_fn: option::t<node_id>,
mutable err_count: uint,
filesearch: filesearch::filesearch,
mutable building_library: bool) {
mutable building_library: bool,
working_dir: str) {
fn get_targ_cfg() -> @config { ret targ_cfg; }
fn get_opts() -> @options { ret opts; }
fn get_cstore() -> metadata::cstore::cstore { cstore }
Expand Down Expand Up @@ -122,6 +124,9 @@ obj session(targ_cfg: @config,
fn set_building_library(crate: @ast::crate) {
building_library = session::building_library(opts.crate_type, crate);
}
fn get_working_dir() -> str {
ret working_dir;
}
}

fn building_library(req_crate_type: crate_type, crate: @ast::crate) -> bool {
Expand Down
5 changes: 5 additions & 0 deletions src/comp/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ native mod llvm {
/* Operations on other types */
fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;

fn LLVMVoidType() -> TypeRef;
fn LLVMLabelType() -> TypeRef;
fn LLVMMetadataType() -> TypeRef;

/* Operations on all values */
fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
Expand All @@ -256,6 +258,7 @@ native mod llvm {

/* Operations on Users */
fn LLVMGetOperand(Val: ValueRef, Index: uint) -> ValueRef;
fn LLVMSetOperand(Val: ValueRef, Index: uint, Op: ValueRef);

/* Operations on constants of any type */
fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
Expand All @@ -275,6 +278,8 @@ native mod llvm {
fn LLVMMDNodeInContext(C: ContextRef, Vals: *ValueRef, Count: uint) ->
ValueRef;
fn LLVMMDNode(Vals: *ValueRef, Count: uint) -> ValueRef;
fn LLVMAddNamedMetadataOperand(M: ModuleRef, Str: sbuf, SLen: uint,
Val: ValueRef);

/* Operations on scalar constants */
fn LLVMConstInt(IntTy: TypeRef, N: ULongLong, SignExtend: Bool) ->
Expand Down
13 changes: 12 additions & 1 deletion src/comp/middle/ast_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import syntax::{visit, codemap};
tag ast_node {
node_item(@item);
node_obj_ctor(@item);
node_obj_method(@method);
node_native_item(@native_item);
node_method(@method);
node_expr(@expr);
// Locals are numbered, because the alias analysis needs to know in which
// order they are introduced.
node_arg(arg, uint);
node_local(uint);
node_res_ctor(@item);
}

type map = std::map::hashmap<node_id, ast_node>;
Expand Down Expand Up @@ -63,10 +65,19 @@ fn map_arm(cx: ctx, arm: arm) {
fn map_item(cx: ctx, i: @item) {
cx.map.insert(i.id, node_item(i));
alt i.node {
item_obj(_, _, ctor_id) { cx.map.insert(ctor_id, node_obj_ctor(i)); }
item_obj(ob, _, ctor_id) {
cx.map.insert(ctor_id, node_obj_ctor(i));
for m in ob.methods {
cx.map.insert(m.node.id, node_obj_method(m));
}
}
item_impl(_, _, ms) {
for m in ms { cx.map.insert(m.node.id, node_method(m)); }
}
item_res(_, dtor_id, _, ctor_id) {
cx.map.insert(ctor_id, node_res_ctor(i));
cx.map.insert(dtor_id, node_item(i));
}
_ { }
}
}
Expand Down
Loading