Package: GNAT.Source_Info

Description

This package provides some useful utility subprograms that provide access to source code information known at compile time. These subprograms are intrinsic operations that provide information known to the compiler in a form that can be embedded into the source program for identification and logging purposes. For example, an exception handler can print out the name of the source file in which the exception is handled.

Header

package GNAT.Source_Info is
 
pragma Pure (Source_Info);

Other Items:

function File return String;
Return the name of the current file, not including the path information. The result is considered to be a static string constant.

function Line return Positive;
Return the current input line number. The result is considered to be a static expression.

function Source_Location return String;
Return a string literal of the form "name:line", where name is the current source file name without path information, and line is the current line number. In the event that instantiations are involved, additional suffixes of the same form are appended after the separating string " instantiated at ". The result is considered to be a static string constant.

function Enclosing_Entity return String;
Return the name of the current subprogram, package, task, entry or protected subprogram. The string is in exactly the form used for the declaration of the entity (casing and encoding conventions), and is considered to be a static string constant.

Note: if this function is used at the outer level of a generic package, the string returned will be the name of the instance, not the generic package itself. This is useful in identifying and logging information from within generic templates.


private

   --  Implementation-defined ...
end GNAT.Source_Info;