diff options
| author | Michael Woerister <michaelwoerister@gmail> | 2013-08-15 18:24:05 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@gmail> | 2013-08-16 22:30:43 +0200 |
| commit | 5abb7c3a67d2de15258ed99f4e16447a9a06698b (patch) | |
| tree | 3ec941f096e47eeaa9b75e16d8751481df1f630e | |
| parent | 0e7808c2e0d7b4c9f2526784566af2745adcf207 (diff) | |
| download | rust-5abb7c3a67d2de15258ed99f4e16447a9a06698b.tar.gz rust-5abb7c3a67d2de15258ed99f4e16447a9a06698b.zip | |
debuginfo: Test cases for [generic][default][static] methods and functions:
* closure-in-generic-function * generic-functions-nested * generic-method-on-generic-struct * generic-trait-generic-static-default-method * method-on-generic-struct * self-in-generic-default-method * trait-generic-static-default-method Also, fixed an 'unused variable' warning in debuginfo.rs
9 files changed, 635 insertions, 3 deletions
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 72af558e5e1..f5073cc71e5 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -406,7 +406,6 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { let template_parameters = get_template_parameters(fcx, generics, file_metadata, - span, &mut function_name); let fn_metadata = do function_name.to_c_str().with_ref |function_name| { @@ -508,7 +507,6 @@ pub fn create_function_metadata(fcx: &mut FunctionContext) -> DISubprogram { fn get_template_parameters(fcx: &FunctionContext, generics: &ast::Generics, file_metadata: DIFile, - span: span, name_to_append_suffix_to: &mut ~str) -> DIArray { let cx = fcx.ccx; 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T1, T2>(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-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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<TA: Clone>(a: TA) { + inner(a.clone(), 1); + inner(a.clone(), 2.5); + + fn inner<TX, TY>(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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> { + x: T +} + +impl<T1> Struct<T1> { + + fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int { + zzz(); + arg1 + } + + fn self_managed<T2>(@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-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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T1> { + fn generic_static_default_method<T2>(arg1: int, arg2: &(T1, T2)) -> int { + zzz(); + arg1 + } +} + +impl<T> Trait<T> for Struct; + +fn main() { + + // Is this really how to use these? + Trait::generic_static_default_method::<int, Struct, float>(1000, &(1, 2.5)); + Trait::generic_static_default_method::<float, Struct, (int, int, int)>(2000, &(3.5, (4, 5, 6))); + +} + +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 index a250c200425..11b142b3d23 100644 --- a/src/test/debug-info/lexical-scope-in-parameterless-closure.rs +++ b/src/test/debug-info/lexical-scope-in-parameterless-closure.rs @@ -10,11 +10,12 @@ // xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249 -// compile-flags:-Z extra-debug-info +// 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-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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> { + x: T +} + +impl<T> Struct<T> { + + 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/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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>(&self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_by_val<T>(self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_owned<T>(~self, arg1: int, arg2: T) -> int { + zzz(); + arg1 + } + + fn self_managed<T>(@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/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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>(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::<Struct, float>(1000, 0.5); + Trait::generic_static_default_method::<Struct, &(int, int, int)>(2000, &(1, 2, 3)); + +} + +fn zzz() {()} |
