File tree Expand file tree Collapse file tree 12 files changed +139
-0
lines changed Expand file tree Collapse file tree 12 files changed +139
-0
lines changed Original file line number Diff line number Diff line change
1
+ procedure Foo is
2
+
3
+ procedure Process (S : out String) is
4
+ begin
5
+ S := (S'Range => ' A' );
6
+ end Process ;
7
+
8
+ S : String (1 .. 2 ) := " AB" ;
9
+
10
+ begin
11
+ Process (S); -- BREAK
12
+ end Foo ;
Original file line number Diff line number Diff line change
1
+ import re
2
+
3
+ from gnatdbg .generics import Match
4
+
5
+
6
+ s = gdb .parse_and_eval ('s' )
7
+ char_type = s .type .target ()
8
+
9
+ # Only arrays can match
10
+ assert not Match .Array ().match (s .type .target ())
11
+ assert Match .Array ().match (s .type )
12
+
13
+ # The element type must match
14
+ assert not Match .Array (element = Match .Array ()).match (s .type )
15
+ assert Match .Array (element = Match .Char ()).match (s .type )
16
+
17
+ # The first bound must match
18
+ assert not Match .Array (first = 2 ).match (s .type )
19
+ assert Match .Array (first = 1 ).match (s .type )
20
+
21
+ # The last bound must match
22
+ assert not Match .Array (last = 1 ).match (s .type )
23
+ assert Match .Array (last = 2 ).match (s .type )
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' , '' )
Original file line number Diff line number Diff line change
1
+ driver : python
Original file line number Diff line number Diff line change
1
+ procedure Foo is
2
+ type My_Record is record
3
+ I : Integer;
4
+ N : Positive;
5
+ end record ;
6
+
7
+ R : My_Record := (1 , 2 );
8
+ begin
9
+ R.N := R.N + R.I; -- BREAK
10
+ end Foo ;
Original file line number Diff line number Diff line change
1
+ import re
2
+
3
+ from gnatdbg .generics import Match
4
+
5
+
6
+ value = gdb .parse_and_eval ('r' )
7
+ type_matcher = Match .Struct (
8
+ Match .Field ('i' ),
9
+ Match .Field ('n' , Match .TypeName (name = 'natural' )),
10
+ )
11
+ assert not type_matcher .match (value .type , debug = True )
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
+
9
+ gdb .test ('source script.py' , """\
10
+ Debug: mismatch:
11
+ Struct(2 fields) <-> TYPE_CODE_STRUCT (name=foo__my_record, 2 fields)
12
+ Field(name=n) <-> n
13
+ TypeName(name=natural) <-> TYPE_CODE_RANGE\
14
+ (name=positive___XDLU_1__@/.*/)""" )
Original file line number Diff line number Diff line change
1
+ driver : python
Original file line number Diff line number Diff line change
1
+ procedure Foo is
2
+
3
+ type Null_Rec is null record ;
4
+ type Rec is record
5
+ I : Integer;
6
+ end record ;
7
+
8
+ procedure Process (R : out Null_Rec) is
9
+ begin
10
+ R := (null record );
11
+ end Process ;
12
+
13
+ procedure Process (R : out Rec) is
14
+ begin
15
+ R := (I => 1 );
16
+ end Process ;
17
+
18
+ NR : Null_Rec;
19
+ R : Rec;
20
+ I : Integer;
21
+
22
+ begin
23
+ Process (NR); -- BREAK
24
+ Process (R); -- BREAK
25
+ I := I + 1 ;
26
+ end Foo ;
Original file line number Diff line number Diff line change
1
+ import re
2
+
3
+ from gnatdbg .generics import Match
4
+
5
+
6
+ nr = gdb .parse_and_eval ('nr' )
7
+ r = gdb .parse_and_eval ('r' )
8
+ i = gdb .parse_and_eval ('i' )
9
+
10
+ # Only structs can match
11
+ assert not Match .Struct ().match (i .type )
12
+ assert Match .Struct ().match (nr .type )
13
+
14
+ # The number of fields must match
15
+ assert not Match .Struct (Match .Field ('i' )).match (nr .type )
16
+ assert Match .Struct (Match .Field ('i' )).match (r .type )
17
+
18
+ # The field names must match
19
+ assert not Match .Struct (Match .Field ('o' )).match (r .type )
20
+ assert Match .Struct (Match .Field ('i' )).match (r .type )
21
+
22
+ # The field types must match
23
+ assert not Match .Struct (Match .Field ('i' , Match .Char ())).match (r .type )
24
+ assert Match .Struct (Match .Field ('i' , Match .Integer ())).match (r .type )
You can’t perform that action at this time.
0 commit comments