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

13.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/ xyz <= declaration
          directory/main.adb:24:10: xyz <= body
          directory/ xyz <= declaration

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

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/ xyz <= declaration
             procedure xyz;
          directory/main.adb:24:10: xyz <= body
             procedure xyz is
          directory/ xyz <= declaration
             xyz : Integer;

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

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

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.