]> gcc.gnu.org Git - gcc.git/commit - gcc/ada/sinput.ads
[Ada] Make debug printouts more robust
authorBob Duff <duff@adacore.com>
Thu, 10 Feb 2022 19:55:32 +0000 (14:55 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 12 May 2022 12:38:38 +0000 (12:38 +0000)
commit3b4ae9b98b07764b074110ba7215428df9efe320
tree49ce9e36e9cb09d1df770cdc97d958a047293ae6
parent86c7b1617f0ae0da828d1107795f57c96c848d8f
[Ada] Make debug printouts more robust

This patch improves some debug printouts so that they avoid crashing on
invalid data.

In addition, the relevant code uses Global_Name_Buffer all over the
place. This patch cleans up some of those uses, in particular ones in
the same code as the robustness changes, and code called by that code.

gcc/ada/

* namet.ads, namet.adb (Write_Name_For_Debug): New more-robust
version of Write_Name.
(Destroy_Global_Name_Buffer): New procedure to help detect bugs
related to use of Global_Name_Buffer.  Misc cleanup and comment
improvements. E.g. we don't need to document every detail of
debugging printouts, especially since they can change.
* uname.ads, uname.adb (Write_Unit_Name_For_Debug): New
more-robust version of Write_Unit_Name.
(Get_Unit_Name_String): Pass buffer in, instead of using the
global variable. Misc cleanup. Remove the "special fudge", which
is apparently not needed, and anyway the comment "the %s or %b
has already been eliminated" seems wrong.
(Write_Unit_Name): Call the new version of Get_Unit_Name_String.
* errout.adb (Set_Msg_Insertion_Unit_Name): Call the new version
of Get_Unit_Name_String. We pass the global variable here,
because it's too much trouble to disentangle such uses in
Errout.
* sem_util.ads, sem_util.adb, sem_dist.adb
(Get_Library_Unit_Name): New version of
Get_Library_Unit_Name_String that avoids usage of the global
variable.
* casing.ads, casing.adb, exp_prag.adb, exp_util.adb
(Set_All_Upper_Case): Remove. There is no need for a wrapper
here -- code is clearer without it.
* treepr.adb (Print_Name): Call Write_Name_For_Debug, which
deals with No_Name (etc), rather than duplicating that here.
Note that the call to Get_Name_String was superfluous.
(Tree_Dump): Call Write_Unit_Name_For_Debug instead of
Write_Unit_Name, which crashes if not Is_Valid_Name.
* erroutc.ads: Improve comments.
* erroutc.adb (Set_Msg_Name_Buffer): Call
Destroy_Global_Name_Buffer to detect potential bugs where it
incorrectly looks at the global variable.
* sinput.adb (Write_Location): Call Write_Name_For_Debug instead
of Write_Name, so it won't blow up on invalid data.
* sinput.ads: Improve comments; remove some verbosity.
* libgnat/s-imagef.adb: Fix typo in comment.
18 files changed:
gcc/ada/casing.adb
gcc/ada/casing.ads
gcc/ada/errout.adb
gcc/ada/erroutc.adb
gcc/ada/erroutc.ads
gcc/ada/exp_prag.adb
gcc/ada/exp_util.adb
gcc/ada/libgnat/s-imagef.adb
gcc/ada/namet.adb
gcc/ada/namet.ads
gcc/ada/sem_dist.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/ada/sinput.adb
gcc/ada/sinput.ads
gcc/ada/treepr.adb
gcc/ada/uname.adb
gcc/ada/uname.ads
This page took 0.061719 seconds and 5 git commands to generate.