debuginfo: Fixed a few things for PR.
This commit is contained in:
parent
af7b87f69d
commit
d54615528c
@ -1790,7 +1790,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
|
||||
bcx = _match::store_arg(bcx, args[arg_n].pat, llarg);
|
||||
|
||||
if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
|
||||
debuginfo::create_argument_metadata(bcx, &args[arg_n], args[arg_n].ty.span);
|
||||
debuginfo::create_argument_metadata(bcx, &args[arg_n]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,8 @@ pub struct DebugContext {
|
||||
priv created_functions: HashMap<ast::node_id, DISubprogram>,
|
||||
priv created_blocks: HashMap<ast::node_id, DILexicalBlock>,
|
||||
priv created_types: HashMap<uint, DIType>,
|
||||
priv argument_index_counters: HashMap<ast::node_id, uint>,
|
||||
priv last_function_context_id: ast::node_id,
|
||||
priv argument_counter: uint,
|
||||
}
|
||||
|
||||
impl DebugContext {
|
||||
@ -117,7 +118,8 @@ impl DebugContext {
|
||||
created_functions: HashMap::new(),
|
||||
created_blocks: HashMap::new(),
|
||||
created_types: HashMap::new(),
|
||||
argument_index_counters: HashMap::new(),
|
||||
last_function_context_id: -1, // magic value :(
|
||||
argument_counter: 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -196,25 +198,35 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: &ast::Local) {
|
||||
/// Creates debug information for the given function argument.
|
||||
///
|
||||
/// Adds the created metadata nodes directly to the crate's IR.
|
||||
pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
|
||||
pub fn create_argument_metadata(bcx: @mut Block,
|
||||
arg: &ast::arg) {
|
||||
let fcx = bcx.fcx;
|
||||
let cx = fcx.ccx;
|
||||
|
||||
let pattern = arg.pat;
|
||||
let filename = span_start(cx, pattern.span).file.name;
|
||||
|
||||
if fcx.id == -1 ||
|
||||
fcx.span.is_none() ||
|
||||
"<intrinsic>" == span_start(cx, span).file.name {
|
||||
"<intrinsic>" == filename {
|
||||
return;
|
||||
}
|
||||
|
||||
// Limited the scope within which `debug_context` is live,
|
||||
// otherwise => borrowing errors
|
||||
{
|
||||
let debug_context = dbg_cx(cx);
|
||||
|
||||
// If this is a new function, reset the counter. llvm::DIBuilder
|
||||
// wants arguments to be indexed starting from 1.
|
||||
if fcx.id != debug_context.last_function_context_id {
|
||||
debug_context.argument_counter = 1;
|
||||
}
|
||||
// Keep track of the function we are in
|
||||
debug_context.last_function_context_id = fcx.id;
|
||||
}
|
||||
|
||||
let def_map = cx.tcx.def_map;
|
||||
let pattern = arg.pat;
|
||||
|
||||
let mut argument_index = match dbg_cx(cx).argument_index_counters.find_copy(&fcx.id) {
|
||||
Some(value) => value,
|
||||
None => 0
|
||||
};
|
||||
|
||||
let filename = span_start(cx, span).file.name;
|
||||
let file_metadata = file_metadata(cx, filename);
|
||||
let scope = create_function_metadata(fcx);
|
||||
|
||||
@ -227,6 +239,13 @@ pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
|
||||
let name: &str = cx.sess.str_of(ident);
|
||||
debug!("create_argument_metadata: %s", name);
|
||||
|
||||
let argument_index = {
|
||||
let debug_context = dbg_cx(cx);
|
||||
let argument_index = debug_context.argument_counter;
|
||||
debug_context.argument_counter += 1;
|
||||
argument_index as c_uint
|
||||
};
|
||||
|
||||
let arg_metadata = do name.as_c_str |name| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateLocalVariable(
|
||||
@ -239,12 +258,10 @@ pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
|
||||
type_metadata,
|
||||
false,
|
||||
0,
|
||||
argument_index as c_uint)
|
||||
argument_index)
|
||||
}
|
||||
};
|
||||
|
||||
argument_index += 1;
|
||||
|
||||
let llptr = match bcx.fcx.llargs.find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
@ -263,8 +280,6 @@ pub fn create_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) {
|
||||
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
|
||||
}
|
||||
}
|
||||
|
||||
dbg_cx(cx).argument_index_counters.insert(fcx.id, argument_index);
|
||||
}
|
||||
|
||||
/// Sets the current debug location at the beginning of the span
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
|
||||
|
||||
// compile-flags:-Z extra-debug-info
|
||||
// debugger:break zzz
|
||||
// debugger:run
|
||||
@ -282,7 +284,7 @@ fn multiple_arguments((oo, pp): (int, int), qq : int) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
simple_tuple((1, false));
|
||||
simple_tuple((1, false));
|
||||
nested_tuple((2, (3, 4)));
|
||||
destructure_only_first_level((5, (6, 7)));
|
||||
struct_as_tuple_element((8, Struct { a: 9, b: 10 }, 11));
|
||||
@ -291,8 +293,8 @@ fn main() {
|
||||
ignored_struct_field(Struct { a: 17, b: 18 });
|
||||
one_struct_destructured_one_not((Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 }));
|
||||
different_order_of_struct_fields(Struct { a: 23, b: 24 });
|
||||
complex_nesting(((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33));
|
||||
managed_box(@(34, 35));
|
||||
complex_nesting(((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33));
|
||||
managed_box(@(34, 35));
|
||||
borrowed_pointer(&(36, 37));
|
||||
contained_borrowed_pointer((&38, 39));
|
||||
unique_pointer(~(40, 41, 42));
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
|
||||
|
||||
// compile-flags:-Z extra-debug-info
|
||||
// debugger:break zzz
|
||||
// debugger:run
|
||||
@ -125,8 +127,8 @@
|
||||
|
||||
|
||||
struct Struct {
|
||||
a: i64,
|
||||
b: i32
|
||||
a: i64,
|
||||
b: i32
|
||||
}
|
||||
|
||||
enum Univariant {
|
||||
@ -137,7 +139,7 @@ struct TupleStruct (float, int);
|
||||
|
||||
|
||||
fn main() {
|
||||
// simple tuple
|
||||
// simple tuple
|
||||
let (a, b) : (int, bool) = (1, false);
|
||||
|
||||
// nested tuple
|
||||
@ -162,14 +164,14 @@ fn main() {
|
||||
let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
|
||||
|
||||
// different order of struct fields
|
||||
let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
|
||||
let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
|
||||
|
||||
// complex nesting
|
||||
let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
|
||||
((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
|
||||
// complex nesting
|
||||
let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
|
||||
((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
|
||||
|
||||
// managed box
|
||||
let @aa = @(34, 35);
|
||||
// managed box
|
||||
let @aa = @(34, 35);
|
||||
|
||||
// borrowed pointer
|
||||
let &bb = &(36, 37);
|
||||
@ -192,7 +194,7 @@ fn main() {
|
||||
// univariant enum
|
||||
let Unit(ii) = Unit(51);
|
||||
|
||||
// univariant enum with ref binding
|
||||
// univariant enum with ref binding
|
||||
let Unit(ref jj) = Unit(52);
|
||||
|
||||
// tuple struct
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
|
||||
|
||||
// compile-flags:-Z extra-debug-info
|
||||
// debugger:break zzz
|
||||
// debugger:run
|
||||
|
Loading…
Reference in New Issue
Block a user