Previous: Examples of gnatxref Usage, Up: The Cross-Referencing Tools gnatxref and gnatfind


12.6 Examples of gnatfind Usage

gnatfind -f xyz:main.adb
Find declarations for all entities xyz referenced at least once in main.adb. The references are search in every library file in the search path.

The directories will be printed as well (as the `-f' switch is set)

The output will look like:

          directory/main.ads:106:14: xyz <= declaration
          directory/main.adb:24:10: xyz <= body
          directory/foo.ads:45:23: xyz <= declaration
     

that is to say, one of the entities xyz found in main.adb is declared at line 12 of main.ads (and its body is in main.adb), and another one is declared at line 45 of foo.ads

gnatfind -fs xyz:main.adb
This is the same command as the previous one, instead gnatfind will display the content of the Ada source file lines.

The output will look like:

          directory/main.ads:106:14: xyz <= declaration
             procedure xyz;
          directory/main.adb:24:10: xyz <= body
             procedure xyz is
          directory/foo.ads:45:23: xyz <= declaration
             xyz : Integer;
     

This can make it easier to find exactly the location your are looking for.

gnatfind -r "*x*":main.ads:123 foo.adb
Find references to all entities containing an x that are referenced on line 123 of main.ads. The references will be searched only in main.ads and foo.adb.
gnatfind main.ads:123
Find declarations and bodies for all entities that are referenced on line 123 of main.ads.

This is the same as gnatfind "*":main.adb:123.

gnatfind mydir/main.adb:123:45
Find the declaration for the entity referenced at column 45 in line 123 of file main.adb in directory mydir. Note that it is usual to omit the identifier name when the column is given, since the column position identifies a unique reference.

The column has to be the beginning of the identifier, and should not point to any character in the middle of the identifier.