Commit 027dbed8 by Arnaud Charlet

[multiple changes]

2010-10-21  Robert Dewar  <dewar@adacore.com>

	* sem_ch3.adb: Minor reformatting.

2010-10-21  Thomas Quinot  <quinot@adacore.com>

	* einfo.ads (Next_Girder_Discriminant): Remove obsolete description for
	removed routine.

2010-10-21  Nicolas Roche  <roche@adacore.com>

	* gnatmem.adb, memroot.adb, memroot.ads, gmem.c,
	gcc-interface/Makefile.in: Remove gnatmem specific files.

From-SVN: r165776
parent 8e4dac80
2010-10-21 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb: Minor reformatting.
2010-10-21 Thomas Quinot <quinot@adacore.com>
* einfo.ads (Next_Girder_Discriminant): Remove obsolete description for
removed routine.
2010-10-21 Nicolas Roche <roche@adacore.com>
* gnatmem.adb, memroot.adb, memroot.ads, gmem.c,
gcc-interface/Makefile.in: Remove gnatmem specific files.
2010-10-21 Thomas Quinot <quinot@adacore.com>
* sem_res.adb, exp_ch13.adb: Minor reformatting.
......
......@@ -3055,12 +3055,6 @@ package Einfo is
-- Empty if there are no more formals. The list returned includes
-- all the extra formals (see description of Extra_Formal field)
-- Next_Girder_Discriminant (synthesized)
-- Applies to discriminants. Set only for a discriminant returned by
-- a call to First/Next_Girder_Discriminant. Returns next girder
-- discriminant, if there are more (see complete description in
-- First_Girder_Discriminant), or Empty if there are no more.
-- Next_Index (synthesized)
-- Applies to array types and subtypes and to string types and
-- subtypes. Yields the next index. The first index is obtained by
......
......@@ -2756,7 +2756,6 @@ errno.o : errno.c
exit.o : adaint.h exit.c
expect.o : expect.c
final.o : final.c
gmem.o : gmem.c
link.o : link.c
mkdir.o : mkdir.c
socket.o : socket.c gsocket.h
......
/****************************************************************************
* *
* GNATMEM COMPONENTS *
* *
* G M E M *
* *
* C Implementation File *
* *
* Copyright (C) 2000-2009, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
* ware Foundation; either version 3, or (at your option) any later ver- *
* sion. GNAT is distributed in the hope that it will be useful, but WITH- *
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* As a special exception under Section 7 of GPL version 3, you are granted *
* additional permissions described in the GCC Runtime Library Exception, *
* version 3.1, as published by the Free Software Foundation. *
* *
* You should have received a copy of the GNU General Public License and *
* a copy of the GCC Runtime Library Exception along with this program; *
* see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* GNAT was originally developed by the GNAT team at New York University. *
* Extensive contributions were provided by Ada Core Technologies Inc. *
* *
****************************************************************************/
/* This unit reads the allocation tracking log produced by augmented
__gnat_malloc and __gnat_free procedures (see file memtrack.adb) and
provides GNATMEM tool with gdb-compliant output. The output is
processed by GNATMEM to detect dynamic memory allocation errors.
See GNATMEM section in GNAT User's Guide for more information.
NOTE: This capability is currently supported on the following targets:
DEC Unix
GNU/Linux x86
Solaris (sparc and x86) (*)
Windows 98/95/NT (x86)
Alpha OpenVMS
(*) on these targets, the compilation must be done with -funwind-tables to
be able to build the stack backtrace.
*/
#ifdef VMS
#include <string.h>
#define xstrdup32(S) strcpy ((__char_ptr32) _malloc32 (strlen (S) + 1), S)
#else
#define xstrdup32(S) S
#endif
#include <stdio.h>
static FILE *gmemfile;
/* tb_len is the number of call level supported by this module */
#define tb_len 200
static void * tracebk [tb_len];
static int cur_tb_len, cur_tb_pos;
#define LOG_EOF '*'
#define LOG_ALLOC 'A'
#define LOG_DEALL 'D'
struct struct_storage_elmt {
char Elmt;
void * Address;
size_t Size;
long long Timestamp;
};
static void
__gnat_convert_addresses (void *addrs[], int n_addrs, void *buf, int *len);
/* Place in BUF a string representing the symbolic translation of N_ADDRS raw
addresses provided in ADDRS. LEN is filled with the result length.
This is a GNAT specific interface to the libaddr2line convert_addresses
routine. The latter examines debug info from a provided executable file
name to perform the translation into symbolic form of an input sequence of
raw binary addresses. It attempts to open the file from the provided name
"as is", so an absolute path must be provided to ensure the file is
always found. We compute this name once, at initialization time. */
static const char * exename = 0;
extern void convert_addresses (const char * , void *[], int, void *, int *);
extern char *__gnat_locate_exec_on_path (char *);
/* ??? Both of these extern functions are prototyped in adaint.h, which
also refers to "time_t" hence needs complex extra header inclusions to
be satisfied on every target. */
static void
__gnat_convert_addresses (void *addrs[], int n_addrs, void *buf, int *len)
{
if (exename != 0)
convert_addresses (exename, addrs, n_addrs, buf, len);
else
*len = 0;
}
/* reads backtrace information from gmemfile placing them in tracebk
array. cur_tb_len is the size of this array
*/
static void
gmem_read_backtrace (void)
{
fread (&cur_tb_len, sizeof (int), 1, gmemfile);
fread (tracebk, sizeof (void *), cur_tb_len, gmemfile);
cur_tb_pos = 0;
}
/* initialize gmem feature from the dumpname file. It returns t0 timestamp
if the dumpname has been generated by GMEM (instrumented malloc/free)
and 0 if not.
*/
long long __gnat_gmem_initialize (char *dumpname)
{
char header [10];
long long t0;
gmemfile = fopen (dumpname, "rb");
fread (header, 10, 1, gmemfile);
/* check for GMEM magic-tag */
if (memcmp (header, "GMEM DUMP\n", 10))
{
fclose (gmemfile);
return 0;
}
fread (&t0, sizeof (long long), 1, gmemfile);
return t0;
}
/* initialize addr2line library */
void __gnat_gmem_a2l_initialize (char *exearg)
{
/* Resolve the executable filename to use in later invocations of
the libaddr2line symbolization service. Ensure that on VMS
exename is allocated in 32 bit memory for compatibility
with libaddr2line. */
exename = xstrdup32 (__gnat_locate_exec_on_path (exearg));
}
/* Read next allocation of deallocation information from the GMEM file and
write an alloc/free information in buf to be processed by gnatmem */
void
__gnat_gmem_read_next (struct struct_storage_elmt *buf)
{
void *addr;
size_t size;
int j;
j = fgetc (gmemfile);
if (j == EOF)
{
fclose (gmemfile);
buf->Elmt = LOG_EOF;
}
else
{
switch (j)
{
case 'A' :
buf->Elmt = LOG_ALLOC;
fread (&(buf->Address), sizeof (void *), 1, gmemfile);
fread (&(buf->Size), sizeof (size_t), 1, gmemfile);
fread (&(buf->Timestamp), sizeof (long long), 1, gmemfile);
break;
case 'D' :
buf->Elmt = LOG_DEALL;
fread (&(buf->Address), sizeof (void *), 1, gmemfile);
fread (&(buf->Timestamp), sizeof (long long), 1, gmemfile);
break;
default:
puts ("GNATMEM dump file corrupt");
__gnat_os_exit (1);
}
gmem_read_backtrace ();
}
}
/* Read the next frame from the current traceback, and move the cursor to the
next frame */
void __gnat_gmem_read_next_frame (void** addr)
{
if (cur_tb_pos >= cur_tb_len) {
*addr = NULL;
} else {
*addr = (void*)*(tracebk + cur_tb_pos);
++cur_tb_pos;
}
}
/* Converts addr into a symbolic traceback, and stores the result in buf
with a format suitable for gnatmem */
void __gnat_gmem_symbolic (void * addr, char* buf, int* length)
{
void * addresses [] = { addr };
__gnat_convert_addresses (addresses, 1, buf, length);
}
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M E M R O O T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-2008, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package offers basic types that deal with gdb backtraces related
-- to memory allocation. A memory root (root_id) is a backtrace
-- referencing the actual point of allocation along with counters
-- recording various information concerning allocation at this root.
-- A back trace is composed of Frames (Frame_Id) which themselves are
-- nothing else than a subprogram call at a source location which can be
-- represented by three strings: subprogram name, file name and line
-- number. All the needed strings are entered in a table and referenced
-- through a Name_Id in order to avoid duplication.
with System.Storage_Elements; use System.Storage_Elements;
package Memroot is
-- Simple abstract type for names. A name is a sequence of letters
type Name_Id is new Natural;
No_Name_Id : constant Name_Id := 0;
function Enter_Name (S : String) return Name_Id;
function Image (N : Name_Id) return String;
-- Simple abstract type for a backtrace frame. A frame is composed by
-- a subprogram name, a file name and a line reference.
type Frame_Id is new Natural;
No_Frame_Id : constant Frame_Id := 0;
function Enter_Frame
(Addr : System.Address;
Name : Name_Id;
File : Name_Id;
Line : Name_Id)
return Frame_Id;
type Frame_Array is array (Natural range <>) of Frame_Id;
-- Simple abstract type for an allocation root. It is composed by a set
-- of frames, the number of allocation, the total size of allocated
-- memory, and the high water mark. An iterator is also provided to
-- iterate over all the entered allocation roots.
type Root_Id is new Natural;
No_Root_Id : constant Root_Id := 0;
function Read_BT (BT_Depth : Integer) return Root_Id;
-- Reads a backtrace whose maximum frame number is given by
-- BT_Depth and returns the corresponding Allocation root.
function Enter_Root (Fr : Frame_Array) return Root_Id;
-- Create an allocation root from the frames that compose it
function Frames_Of (B : Root_Id) return Frame_Array;
-- Retrieves the Frames of the root's backtrace
procedure Print_BT (B : Root_Id; Short : Boolean := False);
-- Prints on standard out the backtrace associated with the root B
-- When Short is set to True, only the filename & line info is printed.
-- When it is set to false, the subprogram name is also printed.
function Get_First return Root_Id;
function Get_Next return Root_Id;
-- Iterator to iterate over roots
procedure Set_Nb_Alloc (B : Root_Id; V : Integer);
function Nb_Alloc (B : Root_Id) return Integer;
-- Access and modify the number of allocation counter associated with
-- this allocation root. If the value is negative, it means that this is
-- not an allocation root but a deallocation root (this can only happen
-- in erroneous situations where there are more frees than allocations).
procedure Set_Alloc_Size (B : Root_Id; V : Storage_Count);
function Alloc_Size (B : Root_Id) return Storage_Count;
-- Access and modify the total allocated memory counter associated with
-- this allocation root.
procedure Set_High_Water_Mark (B : Root_Id; V : Storage_Count);
function High_Water_Mark (B : Root_Id) return Storage_Count;
-- Access and modify the high water mark associated with this
-- allocation root. The high water mark is the maximum value, over
-- time, of the Alloc_Size.
end Memroot;
......@@ -9607,9 +9607,8 @@ package body Sem_Ch3 is
-- on the partial view. Make them visible to component declarations.
declare
D : Entity_Id;
-- Discriminant on T (full view) referencing expression on partial
-- view.
D : Entity_Id;
-- Discriminant on T (full view) referencing expr on partial view
Prev_D : Entity_Id;
-- Entity of corresponding discriminant on partial view
......@@ -9619,10 +9618,10 @@ package body Sem_Ch3 is
-- syntactic copy on full view (which has been checked for
-- conformance with partial view), only used here to post error
-- message.
begin
D := First_Discriminant (T);
D := First_Discriminant (T);
New_D := First (Discriminant_Specifications (N));
while Present (D) loop
Prev_D := Current_Entity (D);
Set_Current_Entity (D);
......@@ -9639,8 +9638,7 @@ package body Sem_Ch3 is
and then not Error_Posted (Expression (Parent (D)))
then
Error_Msg_N
("discriminants of tagged type "
& "cannot have defaults",
("discriminants of tagged type cannot have defaults",
Expression (New_D));
end if;
......@@ -10765,7 +10763,7 @@ package body Sem_Ch3 is
Next_Elmt (E);
end loop;
-- The corresponding_Discriminant mechanism is incomplete, because
-- The Corresponding_Discriminant mechanism is incomplete, because
-- the correspondence between new and old discriminants is not one
-- to one: one new discriminant can constrain several old ones. In
-- that case, scan sequentially the stored_constraint, the list of
......@@ -16387,16 +16385,15 @@ package body Sem_Ch3 is
Expression (Discr));
elsif Is_Tagged_Type (Current_Scope)
and then Comes_From_Source (N)
and then Comes_From_Source (N)
then
-- Note: see also similar test in Check_Or_Process_
-- Discriminants, to handle the (illegal) case of the
-- completion of an untagged view with discriminants
-- with defaults by a tagged full view. We skip the check if
-- Discr does not come from source to account for the case of
-- an untagged derived type providing defaults for a renamed
-- discriminant from a private nontagged ancestor with a tagged
-- full view (ACATS B460006).
-- Note: see similar test in Check_Or_Process_Discriminants, to
-- handle the (illegal) case of the completion of an untagged
-- view with discriminants with defaults by a tagged full view.
-- We skip the check if Discr does not come from source to
-- account for the case of an untagged derived type providing
-- defaults for a renamed discriminant from a private nontagged
-- ancestor with a tagged full view (ACATS B460006).
Error_Msg_N
("discriminants of tagged type cannot have defaults",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment