File tree 4 files changed +99
-0
lines changed
testsuite/tests/misc/coerce-array
4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ procedure Foo is
2
+
3
+ type String_Access is access all String;
4
+
5
+ I : Integer := 0 ;
6
+
7
+ procedure Process (S : String) is
8
+ begin
9
+ null ;
10
+ end Process ;
11
+
12
+ function Null_String return String_Access is
13
+ begin
14
+ return null ;
15
+ end Null_String ;
16
+
17
+ function Alloc (S : String) return String_Access is
18
+ begin
19
+ return new String'(S);
20
+ end Alloc ;
21
+
22
+ procedure Run (Unc_Param : aliased String) is
23
+ Unc : constant String := Unc_Param & Unc_Param;
24
+ Con : constant String (1 .. 10 ) := (1 .. 10 => ' A' );
25
+ Acc : access constant String := Unc_Param'Access ;
26
+ Empty : constant String_Access := Alloc (" " );
27
+ Null_Str : constant String_Access := Null_String;
28
+ begin
29
+ Process (Unc_Param); -- BREAK
30
+ Process (Unc);
31
+ Process (Con);
32
+ Process (Acc.all );
33
+ Process (Empty.all );
34
+ Process (Null_Str.all );
35
+ I := I + 1 ;
36
+ end Run ;
37
+
38
+ S : aliased String := " Hello" ;
39
+ begin
40
+ Run (S);
41
+ end Foo ;
Original file line number Diff line number Diff line change
1
+ from gnatdbg .debug import print_type_tree
2
+ from gnatdbg .utils import coerce_array
3
+
4
+
5
+ def run (var ):
6
+ print ('== {} ==' .format (var ))
7
+ value = gdb .parse_and_eval (var )
8
+ try :
9
+ value = coerce_array (value )
10
+ except ValueError as exc :
11
+ value = '<ValueError: {}>' .format (exc )
12
+ else :
13
+ if value is not None :
14
+ print_type_tree (value .type )
15
+ value = str (value )
16
+ print (value )
Original file line number Diff line number Diff line change
1
+ from support .build import gnatmake
2
+ from support .gdb import GDBSession
3
+
4
+
5
+ gnatmake ('foo' )
6
+ gdb = GDBSession ('foo' )
7
+ gdb .run_to (gdb .find_loc ('foo.adb' , 'BREAK' ))
8
+ gdb .test ('source script.py' , '' )
9
+
10
+ tests = [
11
+ ('unc_param' ,
12
+ '== unc_param ==\n '
13
+ '%0 (None : TYPE_CODE_ARRAY)[1 .. 5]:\n '
14
+ ' %1 (character : TYPE_CODE_CHAR)\n '
15
+ '"Hello"' ),
16
+ ('unc' ,
17
+ '== unc ==\n '
18
+ '%0 (foo__run__T@/\\ d+/b : TYPE_CODE_ARRAY)[1 .. 10]:\n '
19
+ ' %1 (character : TYPE_CODE_CHAR)\n '
20
+ '"HelloHello"' ),
21
+ ('acc' ,
22
+ '== acc ==\n '
23
+ '%0 (None : TYPE_CODE_ARRAY)[1 .. 5]:\n '
24
+ ' %1 (character : TYPE_CODE_CHAR)\n '
25
+ '"Hello"' ),
26
+ ('empty' ,
27
+ '== empty ==\n '
28
+ '%0 (None : TYPE_CODE_ARRAY)[1 .. 0]:\n '
29
+ ' %1 (character : TYPE_CODE_CHAR)\n '
30
+ '""' ),
31
+ ('null_str' ,
32
+ '== null_str ==\n '
33
+ 'None' ),
34
+ ('i' ,
35
+ '== i ==\n '
36
+ '<ValueError: Invalid array value: 0 (TYPE_CODE_INT)>' ),
37
+ ]
38
+
39
+ for var , expected_output in tests :
40
+ gdb .test ('pi run({})' .format (repr (var )),
41
+ expected_output )
Original file line number Diff line number Diff line change
1
+ driver : python
You can’t perform that action at this time.
0 commit comments