-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display entity and location with Block_Logger traces as additional info
The source location and the enclosing entity are always displayed by GNATCOLL.Traces.Block_Logger, as part of the message: ``` [PKG] Entering Foo:pkg.adb:5 ``` Obtaining the same piece of information with a GNATCOLL.Traces.Trace_Handle can be achieved with the DEBUG.ENTITY_ENCLOSING and DEBUG.LOCATION in a .gnatdebug configuration file: ``` [PKG] ... (loc: main.adb:12)(entity:Main.Foo) ``` To avoid duplication, this information was not displayed for Block_Logger traces, but an empty field was still present: ``` [PKG] Entering Main.Foo:main.adb:10 (loc:)(entity:) ``` To keep the logs consistent, the location and entity enclosing information so are also displayed in the (loc:) and (entity:) fields if the debug configuration variables ENCLOSING_ENTITY and LOCATION are set.
- Loading branch information
Showing
11 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
testsuite/tests/traces/debug_config_parsing/.gnatdebug_enclosing_entity_no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PKG=yes | ||
DEBUG.ENCLOSING_ENTITY=no |
2 changes: 2 additions & 0 deletions
2
testsuite/tests/traces/debug_config_parsing/.gnatdebug_enclosing_entity_yes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PKG=yes | ||
DEBUG.ENCLOSING_ENTITY=yes |
2 changes: 2 additions & 0 deletions
2
testsuite/tests/traces/debug_config_parsing/.gnatdebug_location_no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PKG=yes | ||
DEBUG.LOCATION=no |
2 changes: 2 additions & 0 deletions
2
testsuite/tests/traces/debug_config_parsing/.gnatdebug_location_yes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PKG=yes | ||
DEBUG.LOCATION=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
with GNATCOLL.Traces; use GNATCOLL.Traces; | ||
with Ada.Command_Line; | ||
|
||
procedure Test is | ||
|
||
Log : constant Logger := Create ("PKG"); | ||
|
||
procedure Foo (A : Integer); | ||
-- Recursive function that decrement A and that traces its value | ||
-- until it reaches 1 (included). | ||
|
||
procedure Foo (A : Integer) is | ||
Block_Log : constant Block_Logger := Create (Log); | ||
begin | ||
Trace (Log, "A =" & A'Img); | ||
if A > 1 then | ||
Foo (A - 1); | ||
end if; | ||
end Foo; | ||
|
||
begin | ||
Parse_Config_File (Ada.Command_Line.Argument (1)); | ||
Foo (3); | ||
end Test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
with "gnatcoll"; | ||
|
||
project Test is | ||
for Object_Dir use "obj"; | ||
for Exec_Dir use "."; | ||
for Main use ("test.adb"); | ||
end Test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
== DEBUG.LOCATION=yes | ||
[PKG] Entering Test.Foo:test.adb:13 (loc:test.adb:13) | ||
[PKG] A = 3 (loc:test.adb:15) | ||
[PKG] Entering Test.Foo:test.adb:13 (loc:test.adb:13) | ||
[PKG] A = 2 (loc:test.adb:15) | ||
[PKG] Entering Test.Foo:test.adb:13 (loc:test.adb:13) | ||
[PKG] A = 1 (loc:test.adb:15) | ||
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13) | ||
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13) | ||
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13) | ||
|
||
== DEBUG.LOCATION=no | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 3 | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 2 | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 1 | ||
[PKG] Leaving Test.Foo:test.adb:13 | ||
[PKG] Leaving Test.Foo:test.adb:13 | ||
[PKG] Leaving Test.Foo:test.adb:13 | ||
|
||
== DEBUG.ENCLOSING_ENTITY=yes | ||
[PKG] Entering Test.Foo:test.adb:13 (entity:Test.Foo) | ||
[PKG] A = 3 (entity:Test.Foo) | ||
[PKG] Entering Test.Foo:test.adb:13 (entity:Test.Foo) | ||
[PKG] A = 2 (entity:Test.Foo) | ||
[PKG] Entering Test.Foo:test.adb:13 (entity:Test.Foo) | ||
[PKG] A = 1 (entity:Test.Foo) | ||
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo) | ||
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo) | ||
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo) | ||
|
||
== DEBUG.ENCLOSING_ENTITY=no | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 3 | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 2 | ||
[PKG] Entering Test.Foo:test.adb:13 | ||
[PKG] A = 1 | ||
[PKG] Leaving Test.Foo:test.adb:13 | ||
[PKG] Leaving Test.Foo:test.adb:13 | ||
[PKG] Leaving Test.Foo:test.adb:13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
echo "== DEBUG.LOCATION=yes" | ||
./test .gnatdebug_location_yes | ||
|
||
echo "" | ||
echo "== DEBUG.LOCATION=no" | ||
./test .gnatdebug_location_no | ||
|
||
echo "" | ||
echo "== DEBUG.ENCLOSING_ENTITY=yes" | ||
./test .gnatdebug_enclosing_entity_yes | ||
|
||
echo "" | ||
echo "== DEBUG.ENCLOSING_ENTITY=no" | ||
./test .gnatdebug_enclosing_entity_no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
driver: build_run_diff | ||
description: Check behavior of DEBUG configuration variants | ||
control: | ||
- [SKIP, "env.is_cross", "Tests using test.sh currently not supported on cross targets, see T616-039"] |