[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 25 Feb 2014 15:45:54 +0000 (16:45 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 25 Feb 2014 15:45:54 +0000 (16:45 +0100)
2014-02-25  Eric Botcazou  <ebotcazou@adacore.com>

* sigtramp.h: Fix minor inaccuracy.

2014-02-25  Ben Brosgol  <brosgol@adacore.com>

* gnat_ugn.texi: Added description of kill command.

2014-02-25  Robert Dewar  <dewar@adacore.com>

* gnat_rm.texi (Address_Clauses): Add a section discussing the
problem of address clauses causing unexpected initialization,
including the effect of Initialize_Scalars.

From-SVN: r208144

gcc/ada/ChangeLog
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/sigtramp.h

index d401ee557bd3a90d2f8ead42135cbf540e22e0be..2cedac3d86db6d984031d57c6327ef4043139cba 100644 (file)
@@ -1,3 +1,17 @@
+2014-02-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * sigtramp.h: Fix minor inaccuracy.
+
+2014-02-25  Ben Brosgol  <brosgol@adacore.com>
+
+       * gnat_ugn.texi: Added description of kill command.
+
+2014-02-25  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_rm.texi (Address_Clauses): Add a section discussing the
+       problem of address clauses causing unexpected initialization,
+       including the effect of Initialize_Scalars.
+
 2014-02-25  Robert Dewar  <dewar@adacore.com>
 
        * errout.adb: Various changes for better msgs for anonmous access
index a815b3b03dd21e66297930a639cd96d8b6758b22..a3f1217b9814b9a0ac85746b73fa3075ba75563d 100644 (file)
@@ -6684,6 +6684,11 @@ is expected when a value of this type is read from the stream. Note that the
 value written always includes the bounds, even for Unbounded_String'Write,
 since Unbounded_String is not an array type.
 
+Note that the @code{Stream_Convert} pragma is not effective in the case of
+a derived type of a non-limited tagged type. If such a type is specified then
+the pragma is silently ignored, and the default implementation of the stream
+attributes is used instead.
+
 @node Pragma Style_Checks
 @unnumberedsec Pragma Style_Checks
 @findex Style_Checks
@@ -15557,6 +15562,103 @@ in the above example) in this case. This means that the overlay
 works "as expected", in that a modification to one of the variables
 will affect the value of the other.
 
+Note that when address clause overlays are used in this way, there is an
+issue of unintentional initialization, as shown by this example:
+
+@smallexample @c ada
+package Overwrite_Record is
+   type R is record
+      A : Character := 'C';
+      B : Character := 'A';
+   end record;
+   X : Short_Integer := 3;
+   Y : R;
+   for Y'Address use X'Address;
+       |
+>>> warning: default initialization of "Y" may
+    modify "X", use pragma Import for "Y" to
+    suppress initialization (RM B.1(24))
+
+end Overwrite_Record;
+@end smallexample
+
+@noindent
+Here the default initialization of @code{Y} will clobber the value
+of @code{X}, which justifies the warning. The warning notes that
+this effect can be eliminated by adding a @code{pragma Import}
+which suppresses the initialization:
+
+@smallexample @c ada
+package Overwrite_Record is
+   type R is record
+      A : Character := 'C';
+      B : Character := 'A';
+   end record;
+   X : Short_Integer := 3;
+   Y : R;
+   for Y'Address use X'Address;
+   pragma Import (Ada, Y);
+end Overwrite_Record;
+@end smallexample
+
+@noindent
+Note that the use of @code{pragma Initialize_Scalars} may cause variables to
+be initialized when they would not otherwise have been in the absence
+of the use of this pragma. This may cause an overlay to have this
+unintended clobbering effect. The compiler avoids this for scalar
+types, but not for composite objects (where in general the effect
+of @code{Initialize_Scalars} is part of the initialization routine
+for the composite object:
+
+@smallexample @c ada
+pragma Initialize_Scalars;
+with Ada.Text_IO;  use Ada.Text_IO;
+procedure Overwrite_Array is
+   type Arr is array (1 .. 5) of Integer;
+   X : Arr := (others => 1);
+   A : Arr;
+   for A'Address use X'Address;
+       |
+>>> warning: default initialization of "A" may
+    modify "X", use pragma Import for "A" to
+    suppress initialization (RM B.1(24))
+
+begin
+   if X /= Arr'(others => 1) then
+      Put_Line ("X was clobbered");
+   else
+      Put_Line ("X was not clobbered");
+   end if;
+end Overwrite_Array;
+@end smallexample
+
+@noindent
+The above program generates the warning as shown, and at execution
+time, prints @code{X was clobbered}. If the @code{pragma Import} is
+added as suggested:
+
+@smallexample @c ada
+pragma Initialize_Scalars;
+with Ada.Text_IO;  use Ada.Text_IO;
+procedure Overwrite_Array is
+   type Arr is array (1 .. 5) of Integer;
+   X : Arr := (others => 1);
+   A : Arr;
+   for A'Address use X'Address;
+   pragma Import (Ada, A);
+begin
+   if X /= Arr'(others => 1) then
+      Put_Line ("X was clobbered");
+   else
+      Put_Line ("X was not clobbered");
+   end if;
+end Overwrite_Array;
+@end smallexample
+
+@noindent
+then the program compiles without the waraning and when run will generate
+the output @code{X was not clobbered}.
+
 @node Effect of Convention on Representation
 @section Effect of Convention on Representation
 @cindex Convention, effect on representation
index 8ce48bd8aa657e7db45c32904ef74abf50d8d540..b484665eab495f6286e3b3cb425b9dc4c757281b 100644 (file)
@@ -21299,6 +21299,20 @@ examined to the frame of its callee (the reverse of the previous command),
 Inspect the frame with the given number. The value 0 denotes the frame
 of the current breakpoint, that is to say the top of the call stack.
 
+@item kill
+Kills the child process in which the program is running under GDB.
+This may be useful for several purposes:
+@itemize @bullet
+@item
+It allows you to recompile and relink your program, since on many systems
+you cannot regenerate an executable file while it is running in a process.
+@item
+You can run your program outside the debugger, on systems that do not
+permit executing a program outside GDB while breakpoints are set
+within GDB.
+@item
+It allows you to debug a core dump rather than a running process.
+@end itemize
 @end table
 
 @noindent
index 59287f157fee850013319678ebf16d8e566a939f..cf5f4707ee340c679aed62f1dc286d46720499d5 100644 (file)
@@ -66,7 +66,7 @@ extern "C" {
      The unwinder will unwind frames 0, 1 and 2 as usual. But the CFI of frame
      3 is set up as if the caller of frame 3 was frame 6 so, when frame 3 is
      unwound, the unwinder ends up in frame 6 directly. It's possible to do so
-     since the kernel has saved the context of frame 3 and passed it on to
+     since the kernel has saved the context of frame 6 and passed it on to
      __gnat_sigtramp.  */
 
 #ifdef __cplusplus