[Ada] Strip too long expressions in debug routines
authorArnaud Charlet <charlet@adacore.com>
Fri, 25 May 2018 09:04:32 +0000 (09:04 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Fri, 25 May 2018 09:04:32 +0000 (09:04 +0000)
2018-05-25  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* pprint.adb (Expression_Name): Strip too long expressions to avoid
carrying very large strings.

From-SVN: r260732

gcc/ada/ChangeLog
gcc/ada/pprint.adb

index f3a0f38..256ecb8 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-25  Arnaud Charlet  <charlet@adacore.com>
+
+       * pprint.adb (Expression_Name): Strip too long expressions to avoid
+       carrying very large strings.
+
 2018-05-25  Patrick Bernardi  <bernardi@adacore.com>
 
        * switch-b.adb (Scan_Binder_Switches): binder switch -Q accepts Natural
index 24c9aa1..230a3d3 100644 (file)
@@ -883,6 +883,7 @@ package body Pprint is
          end if;
 
          declare
+            Threshold        : constant := 256;
             Buffer           : String (1 .. Natural (End_Sloc - Scn));
             Index            : Natural := 0;
             Skipping_Comment : Boolean := False;
@@ -935,6 +936,12 @@ package body Pprint is
                         end if;
                   end case;
 
+                  --  Give up on too long strings
+
+                  if Index >= Threshold then
+                     return Buffer (1 .. Index) & "...";
+                  end if;
+
                   Scn := Scn + 1;
                end loop;
             end if;