1 // Function names are formatted differently in old versions of GDB
2 // min-gdb-version: 10.1
6 // === GDB TESTS ===================================================================================
9 // gdb-command:info functions -q function_names::main
10 // gdb-check:[...]static fn function_names::main();
11 // gdb-command:info functions -q function_names::generic_func<*
12 // gdb-check:[...]static fn function_names::generic_func<i32>(i32) -> i32;
15 // gdb-command:info functions -q function_names::.*::impl_function.*
16 // gdb-check:[...]static fn function_names::GenericStruct<i32, i32>::impl_function<i32, i32>();
17 // gdb-check:[...]static fn function_names::Mod1::TestStruct2::impl_function();
18 // gdb-check:[...]static fn function_names::TestStruct1::impl_function();
20 // Trait implementations
21 // gdb-command:info functions -q function_names::.*::trait_function.*
22 // gdb-check:[...]static fn function_names::Mod1::{impl#1}::trait_function();
23 // gdb-check:[...]static fn function_names::{impl#1}::trait_function();
24 // gdb-check:[...]static fn function_names::{impl#3}::trait_function<i32>();
25 // gdb-check:[...]static fn function_names::{impl#5}::trait_function3<function_names::TestStruct1>();
26 // gdb-check:[...]static fn function_names::{impl#6}::trait_function<i32, 1>();
29 // gdb-command:info functions -q function_names::.*::{closure.*
30 // gdb-check:[...]static fn function_names::generic_func::{closure#0}<i32>(*mut function_names::generic_func::{closure_env#0}<i32>);
31 // gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0});
32 // gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure_env#0}<i32, i32>);
35 // Generators don't seem to appear in GDB's symbol table.
37 // Const generic parameter
38 // gdb-command:info functions -q function_names::const_generic_fn.*
39 // gdb-check:[...]static fn function_names::const_generic_fn_bool<false>();
40 // gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#3fcd7c34c1555be6}>();
41 // gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>();
42 // gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>();
44 // === CDB TESTS ===================================================================================
47 // cdb-command:x a!function_names::main
48 // cdb-check:[...] a!function_names::main (void)
49 // cdb-command:x a!function_names::generic_func<*
50 // cdb-check:[...] a!function_names::generic_func<i32> (int)
53 // cdb-command:x a!function_names::*::impl_function*
54 // cdb-check:[...] a!function_names::Mod1::TestStruct2::impl_function (void)
55 // cdb-check:[...] a!function_names::TestStruct1::impl_function (void)
56 // cdb-check:[...] a!function_names::GenericStruct<i32,i32>::impl_function<i32,i32> (void)
58 // Trait implementations
59 // cdb-command:x a!function_names::*::trait_function*
60 // cdb-check:[...] a!function_names::impl$3::trait_function<i32> (void)
61 // cdb-check:[...] a!function_names::impl$6::trait_function<i32,1> (void)
62 // cdb-check:[...] a!function_names::impl$1::trait_function (void)
63 // cdb-check:[...] a!function_names::impl$5::trait_function3<function_names::TestStruct1> (void)
64 // cdb-check:[...] a!function_names::Mod1::impl$1::trait_function (void)
67 // cdb-command:x a!function_names::*::closure*
68 // cdb-check:[...] a!function_names::impl$2::impl_function::closure$0<i32,i32> (void)
69 // cdb-check:[...] a!function_names::main::closure$0 (void)
70 // cdb-check:[...] a!function_names::generic_func::closure$0<i32> (void)
73 // cdb-command:x a!function_names::*::generator*
74 // cdb-check:[...] a!function_names::main::generator$1 (void)
76 // Const generic parameter
77 // cdb-command:x a!function_names::const_generic_fn*
78 // cdb-check:[...] a!function_names::const_generic_fn_bool<false> (void)
79 // cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST$3fcd7c34c1555be6> (void)
80 // cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void)
81 // cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void)
83 #![allow(unused_variables)]
84 #![feature(omit_gdb_pretty_printer_section)]
85 #![omit_gdb_pretty_printer_section]
86 #![feature(adt_const_params, generators, generator_trait)]
87 #![allow(incomplete_features)]
89 use std::ops::Generator;
95 TestStruct1::impl_function();
96 Mod1::TestStruct2::impl_function();
97 GenericStruct::<i32, i32>::impl_function();
99 // Trait implementations
100 TestStruct1::trait_function();
101 Mod1::TestStruct2::trait_function();
102 GenericStruct::<i32, i32>::trait_function();
103 GenericStruct::<[i32; 1], f32>::trait_function();
104 GenericStruct::<TestStruct1, usize>::trait_function3();
107 let _ = generic_func(42i32);
110 let closure = || TestStruct1;
114 let mut generator = || {
118 Pin::new(&mut generator).resume(());
120 // Const generic functions
121 const_generic_fn_bool::<false>();
122 const_generic_fn_non_int::<{ () }>();
123 const_generic_fn_signed_int::<-7>();
124 const_generic_fn_unsigned_int::<14>();
134 pub fn impl_function() {}
137 // Implementation for a trait
138 impl TestTrait1 for TestStruct1 {
139 fn trait_function() {}
142 // Implementation and implementation within a mod
144 pub struct TestStruct2;
145 pub trait TestTrait2 {
150 pub fn impl_function() {}
153 impl TestTrait2 for TestStruct2 {
154 fn trait_function() {}
158 struct GenericStruct<T1, T2>(std::marker::PhantomData<(T1, T2)>);
160 // Generic implementation
161 impl<T1, T2> GenericStruct<T1, T2> {
162 pub fn impl_function() {
163 // Closure in a generic implementation
164 let closure = || TestStruct1;
169 // Generic trait implementation
170 impl<T> TestTrait1 for GenericStruct<T, i32> {
171 fn trait_function() {}
174 // Implementation based on associated type
177 fn trait_function3();
179 impl TestTrait3 for TestStruct1 {
180 type AssocType = usize;
181 fn trait_function3() {}
183 impl<T: TestTrait3> TestTrait3 for GenericStruct<T, T::AssocType> {
184 type AssocType = T::AssocType;
185 fn trait_function3() {}
188 // Generic trait implementation with const generics
189 impl<T, const N: usize> TestTrait1 for GenericStruct<[T; N], f32> {
190 fn trait_function() {}
194 fn generic_func<T>(value: T) -> T {
195 // Closure in a generic function
196 let closure = || TestStruct1;
202 fn const_generic_fn_bool<const C: bool>() {}
203 fn const_generic_fn_non_int<const C: ()>() {}
204 fn const_generic_fn_signed_int<const C: i64>() {}
205 fn const_generic_fn_unsigned_int<const C: u32>() {}