diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 89a8d33955d..5227d68774b 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -691,6 +691,14 @@ pub fn build_session_options(binary: @str, let extra_debuginfo = debugging_opts & session::extra_debug_info != 0; let debuginfo = debugging_opts & session::debug_info != 0 || extra_debuginfo; + + // If debugging info is generated, do not collapse monomorphized function instances. + // Functions with equivalent llvm code still need separate debugging descriptions because names + // might differ. + if debuginfo { + debugging_opts |= session::no_monomorphic_collapse; + } + let statik = debugging_opts & session::statik != 0; let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s)); diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 307b691a56e..4c204b908bc 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -2086,6 +2086,16 @@ pub mod llvm { #[fast_ffi] pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool); + + #[fast_ffi] + pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef, + Scope: ValueRef, + Name: *c_char, + Ty: ValueRef, + File: ValueRef, + LineNo: c_uint, + ColumnNo: c_uint) + -> ValueRef; } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 8fd5f770367..6640ed0f38d 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -133,7 +133,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt { fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool { match fcx.span { - None => true, + None => false, Some(span) => *span.lo != 0 || *span.hi != 0 } } @@ -1739,6 +1739,10 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext, fcx.llself = Some(ValSelfData {v: self_val, ..slf}); add_clean(bcx, self_val, slf.t); + + if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) { + debuginfo::create_self_argument_metadata(bcx, slf.t, self_val); + } } _ => {} } @@ -1859,6 +1863,10 @@ pub fn trans_closure(ccx: @mut CrateContext, set_fixed_stack_segment(fcx.llfn); } + if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) { + debuginfo::create_function_metadata(fcx); + } + // Create the first basic block in the function and keep a handle on it to // pass to finish_fn later. let bcx_top = fcx.entry_bcx.unwrap(); @@ -1929,12 +1937,7 @@ pub fn trans_fn(ccx: @mut CrateContext, id, attrs, output_type, - |fcx| { - if ccx.sess.opts.debuginfo - && fcx_has_nonzero_span(fcx) { - debuginfo::create_function_metadata(fcx); - } - }); + |_fcx| { }); } fn insert_synthetic_type_entries(bcx: @mut Block, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d23c009ac15..f5073cc71e5 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -51,7 +51,7 @@ This file consists of three conceptual sections: use driver::session; use lib::llvm::llvm; -use lib::llvm::{ModuleRef, ContextRef}; +use lib::llvm::{ModuleRef, ContextRef, ValueRef}; use lib::llvm::debuginfo::*; use middle::trans::common::*; use middle::trans::machine; @@ -69,7 +69,8 @@ use std::libc::{c_uint, c_ulonglong, c_longlong}; use std::ptr; use std::vec; use syntax::codemap::span; -use syntax::{ast, codemap, ast_util, ast_map}; +use syntax::{ast, codemap, ast_util, ast_map, opt_vec}; +use syntax::parse::token::special_idents; static DW_LANG_RUST: int = 0x9000; @@ -97,7 +98,7 @@ pub struct DebugContext { priv builder: DIBuilderRef, priv curr_loc: (uint, uint), priv created_files: HashMap<~str, DIFile>, - priv created_functions: HashMap, + priv created_functions: HashMap, priv created_blocks: HashMap, priv created_types: HashMap } @@ -121,21 +122,25 @@ impl DebugContext { } } +#[deriving(Eq,IterBytes)] +struct FunctionCacheKey { + // Use the address of the llvm function (FunctionContext::llfn) as key for the cache. This + // nicely takes care of monomorphization, where two specializations will have the same + // ast::NodeId but different llvm functions (each needing its own debug description). + priv llfn: ValueRef +} + +impl FunctionCacheKey { + fn for_function_context(fcx: &FunctionContext) -> FunctionCacheKey { + FunctionCacheKey { llfn: fcx.llfn } + } +} pub struct FunctionDebugContext { priv scope_map: HashMap, priv argument_counter: uint, } -impl FunctionDebugContext { - fn new() -> FunctionDebugContext { - return FunctionDebugContext { - scope_map: HashMap::new(), - argument_counter: 1, - }; - } -} - /// Create any deferred debug metadata nodes pub fn finalize(cx: @mut CrateContext) { debug!("finalize"); @@ -162,6 +167,9 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: &ast::Local) { } } +/// Creates debug information for a local variable introduced in the head of a match-statement arm. +/// +/// Adds the created metadata nodes directly to the crate's IR. pub fn create_match_binding_metadata(bcx: @mut Block, variable_ident: ast::ident, node_id: ast::NodeId, @@ -170,6 +178,52 @@ pub fn create_match_binding_metadata(bcx: @mut Block, declare_local(bcx, variable_ident, node_id, variable_type, span); } +/// Creates debug information for the self argument of a method. +/// +/// Adds the created metadata nodes directly to the crate's IR. +pub fn create_self_argument_metadata(bcx: @mut Block, + variable_type: ty::t, + llptr: ValueRef) { + assert_fcx_has_span(bcx.fcx); + let span = bcx.fcx.span.unwrap(); + + let cx = bcx.ccx(); + + let filename = span_start(cx, span).file.name; + let file_metadata = file_metadata(cx, filename); + + let loc = span_start(cx, span); + let type_metadata = type_metadata(cx, variable_type, span); + let scope = create_function_metadata(bcx.fcx); + + let var_metadata = do cx.sess.str_of(special_idents::self_).to_c_str().with_ref |name| { + unsafe { + llvm::LLVMDIBuilderCreateLocalVariable( + DIB(cx), + DW_TAG_arg_variable, + scope, + name, + file_metadata, + loc.line as c_uint, + type_metadata, + false, + 0, + 1) + } + }; + + set_debug_location(cx, scope, loc.line, loc.col.to_uint()); + unsafe { + let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd( + DIB(cx), + llptr, + var_metadata, + bcx.llbb); + + llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr); + } +} + /// Creates debug information for the given function argument. /// /// Adds the created metadata nodes directly to the crate's IR. @@ -243,9 +297,10 @@ pub fn create_argument_metadata(bcx: @mut Block, } } -/// Sets the current debug location at the beginning of the span +/// Sets the current debug location at the beginning of the span. /// -/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...) +/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...). The node_id parameter is used to +/// reliably find the correct visibility scope for the code position. pub fn update_source_pos(fcx: &FunctionContext, node_id: ast::NodeId, span: span) { @@ -269,13 +324,24 @@ pub fn update_source_pos(fcx: &FunctionContext, /// The return value should be ignored if called from outside of the debuginfo module. pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { let cx = fcx.ccx; + let cache_key = FunctionCacheKey::for_function_context(fcx); + + match dbg_cx(cx).created_functions.find_copy(&cache_key) { + Some(fn_metadata) => { + assert!(fcx.debug_context.is_some()); + return fn_metadata; + } + None => { /* fallthrough */} + } + + let empty_generics = ast::Generics { lifetimes: opt_vec::Empty, ty_params: opt_vec::Empty }; let fnitem = cx.tcx.items.get_copy(&fcx.id); - let (ident, fn_decl, id) = match fnitem { + let (ident, fn_decl, generics, span) = match fnitem { ast_map::node_item(ref item, _) => { match item.node { - ast::item_fn(ref fn_decl, _, _, _, _) => { - (item.ident, fn_decl, item.id) + ast::item_fn(ref fn_decl, _, _, ref generics, _) => { + (item.ident, fn_decl, generics, item.span) } _ => fcx.ccx.sess.span_bug(item.span, "create_function_metadata: item bound to non-function") @@ -284,19 +350,24 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { ast_map::node_method( @ast::method { decl: ref fn_decl, - id: id, ident: ident, + generics: ref generics, + span: span, _ }, _, _) => { - (ident, fn_decl, id) + (ident, fn_decl, generics, span) } ast_map::node_expr(ref expr) => { match expr.node { ast::expr_fn_block(ref fn_decl, _) => { let name = gensym_name("fn"); - (name, fn_decl, expr.id) + (name, fn_decl, + // This is not quite right. It should actually inherit the generics of the + // enclosing function. + &empty_generics, + expr.span) } _ => fcx.ccx.sess.span_bug(expr.span, "create_function_metadata: expected an expr_fn_block here") @@ -306,27 +377,18 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { @ast::provided( @ast::method { decl: ref fn_decl, - id: id, ident: ident, + generics: ref generics, + span: span, _ }), _, _) => { - (ident, fn_decl, id) + (ident, fn_decl, generics, span) } _ => fcx.ccx.sess.bug(fmt!("create_function_metadata: unexpected sort of node: %?", fnitem)) }; - match dbg_cx(cx).created_functions.find_copy(&id) { - Some(fn_metadata) => return fn_metadata, - None => () - } - - let span = match fcx.span { - Some(value) => value, - None => codemap::dummy_sp() - }; - debug!("create_function_metadata: %s, %s", cx.sess.str_of(ident), cx.sess.codemap.span_to_str(span)); @@ -334,68 +396,210 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { let loc = span_start(cx, span); let file_metadata = file_metadata(cx, loc.file.name); - let return_type_metadata = if cx.sess.opts.extra_debuginfo { - match fn_decl.output.node { - ast::ty_nil => ptr::null(), - _ => type_metadata(cx, ty::node_id_to_type(cx.tcx, id), fn_decl.output.span) + let function_type_metadata = unsafe { + let fn_signature = get_function_signature(fcx, fn_decl); + llvm::LLVMDIBuilderCreateSubroutineType(DIB(cx), file_metadata, fn_signature) + }; + + // get_template_parameters() will append a `<...>` clause to the function name if necessary. + let mut function_name = cx.sess.str_of(ident).to_owned(); + let template_parameters = get_template_parameters(fcx, + generics, + file_metadata, + &mut function_name); + + let fn_metadata = do function_name.to_c_str().with_ref |function_name| { + unsafe { + llvm::LLVMDIBuilderCreateFunction( + DIB(cx), + file_metadata, + function_name, + function_name, + file_metadata, + loc.line as c_uint, + function_type_metadata, + false, + true, + loc.line as c_uint, + FlagPrototyped as c_uint, + cx.sess.opts.optimize != session::No, + fcx.llfn, + template_parameters, + ptr::null()) } - } else { - ptr::null() }; - let fn_ty = unsafe { - llvm::LLVMDIBuilderCreateSubroutineType( - DIB(cx), - file_metadata, - create_DIArray(DIB(cx), [return_type_metadata])) - }; + dbg_cx(cx).created_functions.insert(cache_key, fn_metadata); - let fn_metadata = - do cx.sess.str_of(ident).with_c_str |name| { - do cx.sess.str_of(ident).with_c_str |linkage| { - unsafe { - llvm::LLVMDIBuilderCreateFunction( - DIB(cx), - file_metadata, - name, - linkage, - file_metadata, - loc.line as c_uint, - fn_ty, - false, - true, - loc.line as c_uint, - FlagPrototyped as c_uint, - cx.sess.opts.optimize != session::No, - fcx.llfn, - ptr::null(), - ptr::null()) + // Initialize fn debug context (including scope map) + { + assert!(fcx.debug_context.is_none()); + + let mut fn_debug_context = ~FunctionDebugContext { + scope_map: HashMap::new(), + argument_counter: if fcx.llself.is_some() { 2 } else { 1 } + }; + + let entry_block_id = fcx.entry_bcx.get_ref().node_info.get_ref().id; + let entry_block = cx.tcx.items.get(&entry_block_id); + + match *entry_block { + ast_map::node_block(ref block) => { + let scope_map = &mut fn_debug_context.scope_map; + let arg_pats = do fn_decl.inputs.map |arg_ref| { arg_ref.pat }; + + populate_scope_map(cx, arg_pats, block, fn_metadata, scope_map); } - }}; - - assert!(fcx.debug_context.is_none()); - - let mut fn_debug_context = ~FunctionDebugContext::new(); - let entry_block_id = fcx.entry_bcx.get_ref().node_info.get_ref().id; - let entry_block = cx.tcx.items.get(&entry_block_id); - - match *entry_block { - ast_map::node_block(ref block) => { - let scope_map = &mut fn_debug_context.scope_map; - let arg_pats = do fn_decl.inputs.map |arg_ref| { arg_ref.pat }; - - populate_scope_map(cx, arg_pats, block, fn_metadata, scope_map); + _ => cx.sess.span_bug(span, + fmt!("debuginfo::create_function_metadata() - \ + FunctionContext::entry_bcx::node_info points to wrong type of ast_map \ + entry. Expected: ast_map::node_block, actual: %?", *entry_block)) } - _ => cx.sess.span_bug(span, - fmt!("debuginfo::create_function_metadata() - \ - FunctionContext::entry_bcx::node_info points to wrong type of ast_map entry. \ - Expected: ast_map::node_block, actual: %?", *entry_block)) + + fcx.debug_context = Some(fn_debug_context); } - fcx.debug_context = Some(fn_debug_context); - - dbg_cx(cx).created_functions.insert(id, fn_metadata); return fn_metadata; + + fn get_function_signature(fcx: &FunctionContext, fn_decl: &ast::fn_decl) -> DIArray { + let cx = fcx.ccx; + + if !cx.sess.opts.extra_debuginfo { + return create_DIArray(DIB(cx), []); + } + + let mut signature = vec::with_capacity(fn_decl.inputs.len() + 1); + + // Return type -- llvm::DIBuilder wants this at index 0 + match fn_decl.output.node { + ast::ty_nil => { + signature.push(ptr::null()); + } + _ => { + let return_type = ty::node_id_to_type(cx.tcx, fcx.id); + let return_type = match fcx.param_substs { + None => return_type, + Some(substs) => { + ty::subst_tps(cx.tcx, substs.tys, substs.self_ty, return_type) + } + }; + + signature.push(type_metadata(cx, return_type, codemap::dummy_sp())); + } + } + + // arguments types + for arg in fn_decl.inputs.iter() { + let arg_type = ty::node_id_to_type(cx.tcx, arg.pat.id); + let arg_type = match fcx.param_substs { + None => arg_type, + Some(substs) => { + ty::subst_tps(cx.tcx, substs.tys, substs.self_ty, arg_type) + } + }; + + signature.push(type_metadata(cx, arg_type, codemap::dummy_sp())); + } + + return create_DIArray(DIB(cx), signature); + } + + fn get_template_parameters(fcx: &FunctionContext, + generics: &ast::Generics, + file_metadata: DIFile, + name_to_append_suffix_to: &mut ~str) + -> DIArray { + let cx = fcx.ccx; + + let self_type = match fcx.param_substs { + Some(@param_substs{ self_ty: self_type, _ }) => self_type, + _ => None + }; + + // Only true for static default methods: + let has_self_type = self_type.is_some(); + + if !generics.is_type_parameterized() && !has_self_type { + return ptr::null(); + } + + name_to_append_suffix_to.push_char('<'); + + // The list to be filled with template parameters: + let mut template_params: ~[DIDescriptor] = vec::with_capacity(generics.ty_params.len() + 1); + + // Handle self type + if has_self_type { + let actual_self_type = self_type.unwrap(); + let actual_self_type_metadata = type_metadata(cx, + actual_self_type, + codemap::dummy_sp()); + + // Add self type name to <...> clause of function name + let actual_self_type_name = ty_to_str(cx.tcx, actual_self_type); + name_to_append_suffix_to.push_str(actual_self_type_name); + if generics.is_type_parameterized() { + name_to_append_suffix_to.push_str(","); + } + + let ident = special_idents::type_self; + + let param_metadata = do cx.sess.str_of(ident).to_c_str().with_ref |name| { + unsafe { + llvm::LLVMDIBuilderCreateTemplateTypeParameter( + DIB(cx), + file_metadata, + name, + actual_self_type_metadata, + ptr::null(), + 0, + 0) + } + }; + + template_params.push(param_metadata); + } + + // Handle other generic parameters + let actual_types = match fcx.param_substs { + Some(@param_substs { tys: ref types, _ }) => types, + None => { + return create_DIArray(DIB(cx), template_params); + } + }; + + for (index, &ast::TyParam{ ident: ident, _ }) in generics.ty_params.iter().enumerate() { + let actual_type = actual_types[index]; + let actual_type_metadata = type_metadata(cx, actual_type, codemap::dummy_sp()); + + // Add actual type name to <...> clause of function name + let actual_type_name = ty_to_str(cx.tcx, actual_type); + name_to_append_suffix_to.push_str(actual_type_name); + + if index != generics.ty_params.len() - 1 { + name_to_append_suffix_to.push_str(","); + } + + let param_metadata = do cx.sess.str_of(ident).to_c_str().with_ref |name| { + unsafe { + llvm::LLVMDIBuilderCreateTemplateTypeParameter( + DIB(cx), + file_metadata, + name, + actual_type_metadata, + ptr::null(), + 0, + 0) + } + }; + + template_params.push(param_metadata); + } + + name_to_append_suffix_to.push_char('>'); + + return create_DIArray(DIB(cx), template_params); + } } @@ -611,7 +815,13 @@ fn struct_metadata(cx: &mut CrateContext, let struct_llvm_type = type_of::type_of(cx, struct_type); let field_llvm_types = do fields.map |field| { type_of::type_of(cx, field.mt.ty) }; - let field_names = do fields.map |field| { cx.sess.str_of(field.ident).to_owned() }; + let field_names = do fields.map |field| { + if field.ident == special_idents::unnamed_field { + ~"" + } else { + cx.sess.str_of(field.ident).to_owned() + } + }; let field_types_metadata = do fields.map |field| { type_metadata(cx, field.mt.ty, span) }; @@ -1271,6 +1481,13 @@ fn DIB(cx: &CrateContext) -> DIBuilderRef { cx.dbg_cx.get_ref().builder } +fn assert_fcx_has_span(fcx: &FunctionContext) { + if fcx.span.is_none() { + fcx.ccx.sess.bug(fmt!("debuginfo: Encountered function %s with invalid source span. \ + This function should have been ignored by debuginfo generation.", + ast_map::path_to_str(fcx.path, fcx.ccx.sess.intr()))); + } +} // This procedure builds the *scope map* for a given function, which maps any given ast::NodeId in // the function's AST to the correct DIScope metadata instance. diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 7f2e61092ee..61ea0d549b3 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -838,3 +838,21 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType( extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) { unwrap(Value)->setUnnamedAddr(Unnamed); } + +extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter( + DIBuilderRef Builder, + LLVMValueRef Scope, + const char* Name, + LLVMValueRef Ty, + LLVMValueRef File = 0, + unsigned LineNo = 0, + unsigned ColumnNo = 0) +{ + return wrap(Builder->createTemplateTypeParameter( + unwrapDI(Scope), + Name, + unwrapDI(Ty), + unwrapDI(File), + LineNo, + ColumnNo)); +} diff --git a/src/rustllvm/rustllvm.def.in b/src/rustllvm/rustllvm.def.in index a2af7a18b4f..0b777abfb87 100644 --- a/src/rustllvm/rustllvm.def.in +++ b/src/rustllvm/rustllvm.def.in @@ -613,4 +613,5 @@ LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderCreateEnumerator LLVMDIBuilderCreateEnumerationType LLVMDIBuilderCreateUnionType +LLVMDIBuilderCreateTemplateTypeParameter LLVMSetUnnamedAddr diff --git a/src/test/debug-info/by-value-struct-argument.rs b/src/test/debug-info/by-value-struct-argument.rs new file mode 100644 index 00000000000..052b3c6994a --- /dev/null +++ b/src/test/debug-info/by-value-struct-argument.rs @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Does not work yet, see issue #8512 +// xfail-test + +// compile-flags:-Z extra-debug-info +// debugger:break zzz +// debugger:run + +// debugger:finish +// debugger:print s +// check:$1 = {a = 1, b = 2.5} +// debugger:continue + +#[deriving(Clone)] +struct Struct { + a: int, + b: float +} + +fn fun(s: Struct) { + zzz(); +} + +fn main() { + fun(Struct { a: 1, b: 2.5 }); +} + +fn zzz() {()} diff --git a/src/test/debug-info/closure-in-generic-function.rs b/src/test/debug-info/closure-in-generic-function.rs new file mode 100644 index 00000000000..b6cf6afff1e --- /dev/null +++ b/src/test/debug-info/closure-in-generic-function.rs @@ -0,0 +1,46 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print x +// check:$1 = 0.5 +// debugger:print y +// check:$2 = 10 +// debugger:continue + +// debugger:finish +// debugger:print *x +// check:$3 = 29 +// debugger:print *y +// check:$4 = 110 +// debugger:continue + +fn some_generic_fun(a: T1, b: T2) -> (T2, T1) { + + let closure = |x, y| { + zzz(); + (y, x) + }; + + closure(a, b) +} + +fn main() { + some_generic_fun(0.5, 10); + some_generic_fun(&29, ~110); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-function.rs b/src/test/debug-info/generic-function.rs new file mode 100644 index 00000000000..c3b48f27b73 --- /dev/null +++ b/src/test/debug-info/generic-function.rs @@ -0,0 +1,63 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print *t0 +// check:$1 = 1 +// debugger:print *t1 +// check:$2 = 2.5 +// debugger:print ret +// check:$3 = {{1, 2.5}, {2.5, 1}} +// debugger:continue + +// debugger:finish +// debugger:print *t0 +// check:$4 = 3.5 +// debugger:print *t1 +// check:$5 = 4 +// debugger:print ret +// check:$6 = {{3.5, 4}, {4, 3.5}} +// debugger:continue + +// debugger:finish +// debugger:print *t0 +// check:$7 = 5 +// debugger:print *t1 +// check:$8 = {a = 6, b = 7.5} +// debugger:print ret +// check:$9 = {{5, {a = 6, b = 7.5}}, {{a = 6, b = 7.5}, 5}} +// debugger:continue + +#[deriving(Clone)] +struct Struct { + a: int, + b: float +} + +fn dup_tup(t0: &T0, t1: &T1) -> ((T0, T1), (T1, T0)) { + let ret = ((t0.clone(), t1.clone()), (t1.clone(), t0.clone())); + zzz(); + ret +} + +fn main() { + + let _ = dup_tup(&1, &2.5); + let _ = dup_tup(&3.5, &4_u16); + let _ = dup_tup(&5, &Struct { a: 6, b: 7.5 }); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-functions-nested.rs b/src/test/debug-info/generic-functions-nested.rs new file mode 100644 index 00000000000..1d883b5ab4d --- /dev/null +++ b/src/test/debug-info/generic-functions-nested.rs @@ -0,0 +1,59 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print x +// check:$1 = -1 +// debugger:print y +// check:$2 = 1 +// debugger:continue + +// debugger:finish +// debugger:print x +// check:$3 = -1 +// debugger:print y +// check:$4 = 2.5 +// debugger:continue + +// debugger:finish +// debugger:print x +// check:$5 = -2.5 +// debugger:print y +// check:$6 = 1 +// debugger:continue + +// debugger:finish +// debugger:print x +// check:$7 = -2.5 +// debugger:print y +// check:$8 = 2.5 +// debugger:continue + +fn outer(a: TA) { + inner(a.clone(), 1); + inner(a.clone(), 2.5); + + fn inner(x: TX, y: TY) { + zzz(); + } +} + +fn main() { + outer(-1); + outer(-2.5); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-method-on-generic-struct.rs b/src/test/debug-info/generic-method-on-generic-struct.rs new file mode 100644 index 00000000000..20569691fd4 --- /dev/null +++ b/src/test/debug-info/generic-method-on-generic-struct.rs @@ -0,0 +1,140 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = {8888, -8888}} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print/d arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = {8888, -8888}} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 1234.5} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 1234.5} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 1234.5} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10.5 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = -1} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12.5 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = -1} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print *arg2 +// check:$18 = {-14, 14} +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = -1} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print *arg2 +// check:$21 = {-16, 16.5} +// debugger:continue + +struct Struct { + x: T +} + +impl Struct { + + fn self_by_ref(&self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_by_val(self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_owned(~self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_managed(@self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } +} + +fn main() { + let stack = Struct { x: (8888_u32, -8888_i32) }; + let _ = stack.self_by_ref(-1, -2_i8); + let _ = stack.self_by_val(-3, -4_i16); + + let owned = ~Struct { x: 1234.5 }; + let _ = owned.self_by_ref(-5, -6_i32); + let _ = owned.self_by_val(-7, -8_i64); + let _ = owned.self_owned(-9, -10.5_f32); + + let managed = @Struct { x: -1_i16 }; + let _ = managed.self_by_ref(-11, -12.5_f64); + let _ = managed.self_by_val(-13, &(-14, 14)); + let _ = managed.self_managed(-15, &(-16, 16.5)); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-static-method-on-struct-and-enum.rs b/src/test/debug-info/generic-static-method-on-struct-and-enum.rs new file mode 100644 index 00000000000..3a5380b8ab2 --- /dev/null +++ b/src/test/debug-info/generic-static-method-on-struct-and-enum.rs @@ -0,0 +1,67 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STRUCT +// debugger:finish +// debugger:print arg1 +// check:$1 = 1 +// debugger:print arg2 +// check:$2 = 2 +// debugger:continue + +// ENUM +// debugger:finish +// debugger:print arg1 +// check:$3 = -3 +// debugger:print arg2 +// check:$4 = 4.5 +// debugger:print arg3 +// check:$5 = 5 +// debugger:continue + + +struct Struct { + x: int +} + +impl Struct { + + fn static_method(arg1: T1, arg2: T2) -> int { + zzz(); + return 0; + } +} + +enum Enum { + Variant1 { x: int }, + Variant2, + Variant3(float, int, char), +} + +impl Enum { + + fn static_method(arg1: T1, arg2: T2, arg3: T3) -> int { + zzz(); + return 1; + } +} + +fn main() { + Struct::static_method(1, 2); + Enum::static_method(-3, 4.5, 5); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-struct-style-enum.rs b/src/test/debug-info/generic-struct-style-enum.rs new file mode 100644 index 00000000000..77ac7895366 --- /dev/null +++ b/src/test/debug-info/generic-struct-style-enum.rs @@ -0,0 +1,77 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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:set print union on +// debugger:break zzz +// debugger:run +// debugger:finish + +// debugger:print case1 +// check:$1 = {{Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {Case1, a = 0, b = 2088533116, c = 2088533116}, {Case1, a = 0, b = 8970181431921507452}} + +// debugger:print case2 +// check:$2 = {{Case2, a = 0, b = 4369, c = 4369, d = 4369, e = 4369}, {Case2, a = 0, b = 286331153, c = 286331153}, {Case2, a = 0, b = 1229782938247303441}} + +// debugger:print case3 +// check:$3 = {{Case3, a = 0, b = 22873, c = 22873, d = 22873, e = 22873}, {Case3, a = 0, b = 1499027801, c = 1499027801}, {Case3, a = 0, b = 6438275382588823897}} + +// debugger:print univariant +// check:$4 = {a = -1} + +// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// substituted with something of size `xx` bits and the same alignment as an integer type of the +// same size. + +// The first element is to ensure proper alignment, irrespective of the machines word size. Since +// the size of the discriminant value is machine dependent, this has be taken into account when +// datatype layout should be predictable as in this case. +enum Regular { + Case1 { a: T64, b: T16, c: T16, d: T16, e: T16}, + Case2 { a: T64, b: T32, c: T32}, + Case3 { a: T64, b: T64 } +} + +enum Univariant { + TheOnlyCase { a: T } +} + +fn main() { + + // In order to avoid endianess trouble all of the following test values consist of a single + // repeated byte. This way each interpretation of the union should look the same, no matter if + // this is a big or little endian machine. + + // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 + // 0b01111100011111000111110001111100 = 2088533116 + // 0b0111110001111100 = 31868 + // 0b01111100 = 124 + let case1: Regular = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 }; + + // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 + // 0b00010001000100010001000100010001 = 286331153 + // 0b0001000100010001 = 4369 + // 0b00010001 = 17 + let case2: Regular = Case2 { a: 0, b: 286331153, c: 286331153 }; + + // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897 + // 0b01011001010110010101100101011001 = 1499027801 + // 0b0101100101011001 = 22873 + // 0b01011001 = 89 + let case3: Regular = Case3 { a: 0, b: 6438275382588823897 }; + + let univariant = TheOnlyCase { a: -1 }; + + zzz(); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-struct.rs b/src/test/debug-info/generic-struct.rs new file mode 100644 index 00000000000..0044def2707 --- /dev/null +++ b/src/test/debug-info/generic-struct.rs @@ -0,0 +1,42 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print int_int +// check:$1 = {key = 0, value = 1} +// debugger:print int_float +// check:$2 = {key = 2, value = 3.5} +// debugger:print float_int +// check:$3 = {key = 4.5, value = 5} +// debugger:print float_int_float +// check:$4 = {key = 6.5, value = {key = 7, value = 8.5}} + +struct AGenericStruct { + key: TKey, + value: TValue +} + +fn main() { + + let int_int = AGenericStruct { key: 0, value: 1 }; + let int_float = AGenericStruct { key: 2, value: 3.5 }; + let float_int = AGenericStruct { key: 4.5, value: 5 }; + let float_int_float = AGenericStruct { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } }; + + zzz(); +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-trait-generic-static-default-method.rs b/src/test/debug-info/generic-trait-generic-static-default-method.rs new file mode 100644 index 00000000000..ef75c93a56b --- /dev/null +++ b/src/test/debug-info/generic-trait-generic-static-default-method.rs @@ -0,0 +1,53 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print arg1 +// check:$1 = 1000 +// debugger:print *arg2 +// check:$2 = {1, 2.5} +// debugger:continue + +// debugger:finish +// debugger:print arg1 +// check:$3 = 2000 +// debugger:print *arg2 +// check:$4 = {3.5, {4, 5, 6}} +// debugger:continue + + +struct Struct { + x: int +} + +trait Trait { + fn generic_static_default_method(arg1: int, arg2: &(T1, T2)) -> int { + zzz(); + arg1 + } +} + +impl Trait for Struct; + +fn main() { + + // Is this really how to use these? + Trait::generic_static_default_method::(1000, &(1, 2.5)); + Trait::generic_static_default_method::(2000, &(3.5, (4, 5, 6))); + +} + +fn zzz() {()} diff --git a/src/test/debug-info/generic-tuple-style-enum.rs b/src/test/debug-info/generic-tuple-style-enum.rs new file mode 100644 index 00000000000..d6350e033f0 --- /dev/null +++ b/src/test/debug-info/generic-tuple-style-enum.rs @@ -0,0 +1,78 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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:set print union on +// debugger:break zzz +// debugger:run +// debugger:finish + +// debugger:print case1 +// check:$1 = {{Case1, 0, 31868, 31868, 31868, 31868}, {Case1, 0, 2088533116, 2088533116}, {Case1, 0, 8970181431921507452}} + +// debugger:print case2 +// check:$2 = {{Case2, 0, 4369, 4369, 4369, 4369}, {Case2, 0, 286331153, 286331153}, {Case2, 0, 1229782938247303441}} + +// debugger:print case3 +// check:$3 = {{Case3, 0, 22873, 22873, 22873, 22873}, {Case3, 0, 1499027801, 1499027801}, {Case3, 0, 6438275382588823897}} + +// debugger:print univariant +// check:$4 = {-1} + + +// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be +// substituted with something of size `xx` bits and the same alignment as an integer type of the +// same size. + +// The first element is to ensure proper alignment, irrespective of the machines word size. Since +// the size of the discriminant value is machine dependent, this has be taken into account when +// datatype layout should be predictable as in this case. +enum Regular { + Case1(T64, T16, T16, T16, T16), + Case2(T64, T32, T32), + Case3(T64, T64) +} + +enum Univariant { + TheOnlyCase(T64) +} + +fn main() { + + // In order to avoid endianess trouble all of the following test values consist of a single + // repeated byte. This way each interpretation of the union should look the same, no matter if + // this is a big or little endian machine. + + // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 + // 0b01111100011111000111110001111100 = 2088533116 + // 0b0111110001111100 = 31868 + // 0b01111100 = 124 + let case1: Regular = Case1(0_u64, 31868_u16, 31868_u16, 31868_u16, 31868_u16); + + // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 + // 0b00010001000100010001000100010001 = 286331153 + // 0b0001000100010001 = 4369 + // 0b00010001 = 17 + let case2: Regular = Case2(0_i64, 286331153_i32, 286331153_i32); + + // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897 + // 0b01011001010110010101100101011001 = 1499027801 + // 0b0101100101011001 = 22873 + // 0b01011001 = 89 + let case3: Regular = Case3(0_i64, 6438275382588823897_i64); + + let univariant = TheOnlyCase(-1_i64); + + zzz(); +} + +fn zzz() {()} diff --git a/src/test/debug-info/lexical-scope-in-parameterless-closure.rs b/src/test/debug-info/lexical-scope-in-parameterless-closure.rs new file mode 100644 index 00000000000..11b142b3d23 --- /dev/null +++ b/src/test/debug-info/lexical-scope-in-parameterless-closure.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 debug-info +// debugger:run + +// Nothing to do here really, just make sure it compiles. See issue #8513. +fn main() { + let _ = ||(); + let _ = range(1u,3).map(|_| 5); +} + diff --git a/src/test/debug-info/method-on-enum.rs b/src/test/debug-info/method-on-enum.rs new file mode 100644 index 00000000000..07481011df3 --- /dev/null +++ b/src/test/debug-info/method-on-enum.rs @@ -0,0 +1,141 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {{Variant1, x = 1799, y = 1799}, {Variant1, 117901063}} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {{Variant2, x = 1799, y = 1799}, {Variant2, 117901063}} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +enum Enum { + Variant1 { x: u16, y: u16 }, + Variant2 (u32) +} + +impl Enum { + + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } +} + +fn main() { + let stack = Variant2(117901063); + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~Variant1{ x: 1799, y: 1799 }; + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @Variant2(117901063); + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/method-on-generic-struct.rs b/src/test/debug-info/method-on-generic-struct.rs new file mode 100644 index 00000000000..f482846027e --- /dev/null +++ b/src/test/debug-info/method-on-generic-struct.rs @@ -0,0 +1,140 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = {8888, -8888}} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = {8888, -8888}} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 1234.5} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 1234.5} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 1234.5} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = -1} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = -1} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = -1} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +struct Struct { + x: T +} + +impl Struct { + + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } +} + +fn main() { + let stack = Struct { x: (8888_u32, -8888_i32) }; + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~Struct { x: 1234.5 }; + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @Struct { x: -1_i16 }; + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/method-on-struct.rs b/src/test/debug-info/method-on-struct.rs new file mode 100644 index 00000000000..211f83e6107 --- /dev/null +++ b/src/test/debug-info/method-on-struct.rs @@ -0,0 +1,140 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = 100} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 100} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 200} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 200} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 200} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = 300} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 300} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = 300} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +struct Struct { + x: int +} + +impl Struct { + + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } +} + +fn main() { + let stack = Struct { x: 100 }; + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~Struct { x: 200 }; + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @Struct { x: 300 }; + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/method-on-trait.rs b/src/test/debug-info/method-on-trait.rs new file mode 100644 index 00000000000..ad6c9a1cada --- /dev/null +++ b/src/test/debug-info/method-on-trait.rs @@ -0,0 +1,147 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = 100} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 100} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 200} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 200} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 200} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = 300} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 300} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = 300} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +struct Struct { + x: int +} + +trait Trait { + fn self_by_ref(&self, arg1: int, arg2: int) -> int; + fn self_by_val(self, arg1: int, arg2: int) -> int; + fn self_owned(~self, arg1: int, arg2: int) -> int; + fn self_managed(@self, arg1: int, arg2: int) -> int; +} + +impl Trait for Struct { + + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + self.x + arg1 + arg2 + } +} + +fn main() { + let stack = Struct { x: 100 }; + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~Struct { x: 200 }; + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @Struct { x: 300 }; + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/method-on-tuple-struct.rs b/src/test/debug-info/method-on-tuple-struct.rs new file mode 100644 index 00000000000..03d7c44059f --- /dev/null +++ b/src/test/debug-info/method-on-tuple-struct.rs @@ -0,0 +1,138 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {100, -100.5} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {100, -100.5} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {200, -200.5} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {200, -200.5} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {200, -200.5} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {300, -300.5} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {300, -300.5} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {300, -300.5} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +struct TupleStruct(int, float); + +impl TupleStruct { + + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } +} + +fn main() { + let stack = TupleStruct(100, -100.5); + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~TupleStruct(200, -200.5); + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @TupleStruct(300, -300.5); + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/option-like-enum.rs b/src/test/debug-info/option-like-enum.rs index 3bf3507faba..02fd294a0bd 100644 --- a/src/test/debug-info/option-like-enum.rs +++ b/src/test/debug-info/option-like-enum.rs @@ -9,7 +9,6 @@ // except according to those terms. // xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249 -// xfail-test broken in newrt? // compile-flags:-Z extra-debug-info // debugger:break zzz @@ -25,31 +24,47 @@ // debugger:print full // check:$3 = {454545, 0x87654321, 9988} -// debugger:print empty -// check:$4 = {0, 0x0, 0} +// debugger:print empty->discr +// check:$4 = (int *) 0x0 // debugger:print droid // check:$5 = {id = 675675, range = 10000001, internals = 0x43218765} -// debugger:print void_droid -// check:$6 = {id = 0, range = 0, internals = 0x0} +// debugger:print void_droid->internals +// check:$6 = (int *) 0x0 +// debugger:continue // If a struct has exactly two variants, one of them is empty, and the other one // contains a non-nullable pointer, then this value is used as the discriminator. // The test cases in this file make sure that something readable is generated for // this kind of types. +// Unfortunately (for these test cases) the content of the non-discriminant fields +// in the null-case is not defined. So we just read the discriminator field in +// this case (by casting the value to a memory-equivalent struct). enum MoreFields<'self> { Full(u32, &'self int, i16), Empty } +struct MoreFieldsRepr<'self> { + a: u32, + discr: &'self int, + b: i16 +} + enum NamedFields<'self> { Droid { id: i32, range: i64, internals: &'self int }, Void } +struct NamedFieldsRepr<'self> { + id: i32, + range: i64, + internals: &'self int +} + fn main() { let some: Option<&u32> = Some(unsafe { std::cast::transmute(0x12345678) }); @@ -58,15 +73,17 @@ fn main() { let full = Full(454545, unsafe { std::cast::transmute(0x87654321) }, 9988); let int_val = 0; - let mut empty = Full(0, &int_val, 0); - empty = Empty; + let empty: &MoreFieldsRepr = unsafe { std::cast::transmute(&Empty) }; - let droid = Droid { id: 675675, range: 10000001, internals: unsafe { std::cast::transmute(0x43218765) } }; + let droid = Droid { + id: 675675, + range: 10000001, + internals: unsafe { std::cast::transmute(0x43218765) } + }; - let mut void_droid = Droid { id: 0, range: 0, internals: &int_val }; - void_droid = Void; + let void_droid: &NamedFieldsRepr = unsafe { std::cast::transmute(&Void) }; zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/self-in-default-method.rs b/src/test/debug-info/self-in-default-method.rs new file mode 100644 index 00000000000..cc7cab39593 --- /dev/null +++ b/src/test/debug-info/self-in-default-method.rs @@ -0,0 +1,141 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = 100} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 100} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 200} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 200} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 200} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = 300} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 300} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print arg2 +// check:$18 = -14 +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = 300} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print arg2 +// check:$21 = -16 +// debugger:continue + +struct Struct { + x: int +} + +trait Trait { + fn self_by_ref(&self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_by_val(self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_owned(~self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } + + fn self_managed(@self, arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } +} + +impl Trait for Struct; + +fn main() { + let stack = Struct { x: 100 }; + let _ = stack.self_by_ref(-1, -2); + let _ = stack.self_by_val(-3, -4); + + let owned = ~Struct { x: 200 }; + let _ = owned.self_by_ref(-5, -6); + let _ = owned.self_by_val(-7, -8); + let _ = owned.self_owned(-9, -10); + + let managed = @Struct { x: 300 }; + let _ = managed.self_by_ref(-11, -12); + let _ = managed.self_by_val(-13, -14); + let _ = managed.self_managed(-15, -16); +} + +fn zzz() {()} diff --git a/src/test/debug-info/self-in-generic-default-method.rs b/src/test/debug-info/self-in-generic-default-method.rs new file mode 100644 index 00000000000..57068df7c0b --- /dev/null +++ b/src/test/debug-info/self-in-generic-default-method.rs @@ -0,0 +1,142 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STACK BY REF +// debugger:finish +// debugger:print *self +// check:$1 = {x = 987} +// debugger:print arg1 +// check:$2 = -1 +// debugger:print/d arg2 +// check:$3 = -2 +// debugger:continue + +// STACK BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 987} +// debugger:print arg1 +// check:$4 = -3 +// debugger:print arg2 +// check:$5 = -4 +// debugger:continue + +// OWNED BY REF +// debugger:finish +// debugger:print *self +// check:$6 = {x = 879} +// debugger:print arg1 +// check:$7 = -5 +// debugger:print arg2 +// check:$8 = -6 +// debugger:continue + +// OWNED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 879} +// debugger:print arg1 +// check:$9 = -7 +// debugger:print arg2 +// check:$10 = -8 +// debugger:continue + +// OWNED MOVED +// debugger:finish +// debugger:print *self +// check:$11 = {x = 879} +// debugger:print arg1 +// check:$12 = -9 +// debugger:print arg2 +// check:$13 = -10.5 +// debugger:continue + +// MANAGED BY REF +// debugger:finish +// debugger:print *self +// check:$14 = {x = 897} +// debugger:print arg1 +// check:$15 = -11 +// debugger:print arg2 +// check:$16 = -12.5 +// debugger:continue + +// MANAGED BY VAL +// debugger:finish +// d ebugger:print self -- ignored for now because of issue #8512 +// c heck:$X = {x = 897} +// debugger:print arg1 +// check:$17 = -13 +// debugger:print *arg2 +// check:$18 = {-14, 14} +// debugger:continue + +// MANAGED SELF +// debugger:finish +// debugger:print self->val +// check:$19 = {x = 897} +// debugger:print arg1 +// check:$20 = -15 +// debugger:print *arg2 +// check:$21 = {-16, 16.5} +// debugger:continue + +struct Struct { + x: int +} + +trait Trait { + + fn self_by_ref(&self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_by_val(self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_owned(~self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_managed(@self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } +} + +impl Trait for Struct; + +fn main() { + let stack = Struct { x: 987 }; + let _ = stack.self_by_ref(-1, -2_i8); + let _ = stack.self_by_val(-3, -4_i16); + + let owned = ~Struct { x: 879 }; + let _ = owned.self_by_ref(-5, -6_i32); + let _ = owned.self_by_val(-7, -8_i64); + let _ = owned.self_owned(-9, -10.5_f32); + + let managed = @Struct { x: 897 }; + let _ = managed.self_by_ref(-11, -12.5_f64); + let _ = managed.self_by_val(-13, &(-14, 14)); + let _ = managed.self_managed(-15, &(-16, 16.5)); +} + +fn zzz() {()} diff --git a/src/test/debug-info/static-method-on-struct-and-enum.rs b/src/test/debug-info/static-method-on-struct-and-enum.rs new file mode 100644 index 00000000000..ecc74e442d0 --- /dev/null +++ b/src/test/debug-info/static-method-on-struct-and-enum.rs @@ -0,0 +1,67 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// STRUCT +// debugger:finish +// debugger:print arg1 +// check:$1 = 1 +// debugger:print arg2 +// check:$2 = 2 +// debugger:continue + +// ENUM +// debugger:finish +// debugger:print arg1 +// check:$3 = -3 +// debugger:print arg2 +// check:$4 = 4.5 +// debugger:print arg3 +// check:$5 = 5 +// debugger:continue + + +struct Struct { + x: int +} + +impl Struct { + + fn static_method(arg1: int, arg2: int) -> int { + zzz(); + arg1 + arg2 + } +} + +enum Enum { + Variant1 { x: int }, + Variant2, + Variant3(float, int, char), +} + +impl Enum { + + fn static_method(arg1: int, arg2: float, arg3: uint) -> int { + zzz(); + arg1 + } +} + +fn main() { + Struct::static_method(1, 2); + Enum::static_method(-3, 4.5, 5); +} + +fn zzz() {()} diff --git a/src/test/debug-info/trait-generic-static-default-method.rs b/src/test/debug-info/trait-generic-static-default-method.rs new file mode 100644 index 00000000000..33468c974eb --- /dev/null +++ b/src/test/debug-info/trait-generic-static-default-method.rs @@ -0,0 +1,53 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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 + +// debugger:finish +// debugger:print arg1 +// check:$1 = 1000 +// debugger:print arg2 +// check:$2 = 0.5 +// debugger:continue + +// debugger:finish +// debugger:print arg1 +// check:$3 = 2000 +// debugger:print *arg2 +// check:$4 = {1, 2, 3} +// debugger:continue + + +struct Struct { + x: int +} + +trait Trait { + fn generic_static_default_method(arg1: int, arg2: T) -> int { + zzz(); + arg1 + } +} + +impl Trait for Struct; + +fn main() { + + // Is this really how to use these? + Trait::generic_static_default_method::(1000, 0.5); + Trait::generic_static_default_method::(2000, &(1, 2, 3)); + +} + +fn zzz() {()} diff --git a/src/test/debug-info/tuple-struct.rs b/src/test/debug-info/tuple-struct.rs new file mode 100644 index 00000000000..ada3802e15d --- /dev/null +++ b/src/test/debug-info/tuple-struct.rs @@ -0,0 +1,60 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// 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:set print pretty off +// debugger:break zzz +// debugger:run +// debugger:finish + +// debugger:print no_padding16 +// check:$1 = {10000, -10001} + +// debugger:print no_padding32 +// check:$2 = {-10002, -10003.5, 10004} + +// debugger:print no_padding64 +// check:$3 = {-10005.5, 10006, 10007} + +// debugger:print no_padding163264 +// check:$4 = {-10008, 10009, 10010, 10011} + +// debugger:print internal_padding +// check:$5 = {10012, -10013} + +// debugger:print padding_at_end +// check:$6 = {-10014, 10015} + + +// This test case mainly makes sure that no field names are generated for tuple structs (as opposed +// to all fields having the name "__field__"). Otherwise they are handled the same a normal structs. + +struct NoPadding16(u16, i16); +struct NoPadding32(i32, f32, u32); +struct NoPadding64(f64, i64, u64); +struct NoPadding163264(i16, u16, i32, u64); +struct InternalPadding(u16, i64); +struct PaddingAtEnd(i64, u16); + +fn main() { + let no_padding16 = NoPadding16(10000, -10001); + let no_padding32 = NoPadding32(-10002, -10003.5, 10004); + let no_padding64 = NoPadding64(-10005.5, 10006, 10007); + let no_padding163264 = NoPadding163264(-10008, 10009, 10010, 10011); + + let internal_padding = InternalPadding(10012, -10013); + let padding_at_end = PaddingAtEnd(-10014, 10015); + + zzz(); +} + +fn zzz() {()}