diff options
author | Vasiliy Fofanov <fofanov@adacore.com> | 2007-06-06 12:30:04 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-06-06 12:30:04 +0200 |
commit | 8cc39ff26bdd6d6b5dc8bc62b5db504f22e50a1b (patch) | |
tree | dc2de52c5511689fb3b3a03be8ed6fcae9c92368 /gcc/ada/gmem.c | |
parent | 9fd79385825a2ff47101383be84d72bd6792a197 (diff) | |
download | gcc-8cc39ff26bdd6d6b5dc8bc62b5db504f22e50a1b.zip gcc-8cc39ff26bdd6d6b5dc8bc62b5db504f22e50a1b.tar.gz gcc-8cc39ff26bdd6d6b5dc8bc62b5db504f22e50a1b.tar.bz2 |
gmem.c: Add support for timestamps on memory operations.
2007-04-20 Vasiliy Fofanov <fofanov@adacore.com>
* gmem.c: Add support for timestamps on memory operations.
* memtrack.adb, gnatmem.adb: Add support for timestamps on memory
operations (not used currently, just foundation for future
enhancements). Add possibility to perform full dump of gmem.out file.
(Print_Back_Traces): Declare accesses to root arrays constants since
they aren't modified.
(Print_Back_Traces): allocate root arrays on the heap rather than stack.
From-SVN: r125419
Diffstat (limited to 'gcc/ada/gmem.c')
-rw-r--r-- | gcc/ada/gmem.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/gcc/ada/gmem.c b/gcc/ada/gmem.c index e45e12c..508d18d 100644 --- a/gcc/ada/gmem.c +++ b/gcc/ada/gmem.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 2000-2006, Free Software Foundation, Inc. * + * Copyright (C) 2000-2007, 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- * @@ -31,7 +31,7 @@ ****************************************************************************/ /* This unit reads the allocation tracking log produced by augmented - __gnat_malloc and __gnat_free procedures (see file a-raise.c) and + __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. @@ -43,9 +43,11 @@ 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. + */ #include <stdio.h> @@ -65,6 +67,7 @@ struct struct_storage_elmt { char Elmt; void * Address; size_t Size; + long long Timestamp; }; static void @@ -108,14 +111,15 @@ gmem_read_backtrace (void) cur_tb_pos = 0; } -/* initialize gmem feature from the dumpname file. It returns 1 if the - dumpname has been generated by GMEM (instrumented malloc/free) and 0 if not - (i.e. probably a GDB generated file). +/* 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. */ -int __gnat_gmem_initialize (char *dumpname) +long long __gnat_gmem_initialize (char *dumpname) { char header [10]; + long long t0; gmemfile = fopen (dumpname, "rb"); fread (header, 10, 1, gmemfile); @@ -127,7 +131,9 @@ int __gnat_gmem_initialize (char *dumpname) return 0; } - return 1; + fread (&t0, sizeof (long long), 1, gmemfile); + + return t0; } /* initialize addr2line library */ @@ -163,10 +169,12 @@ __gnat_gmem_read_next (struct struct_storage_elmt *buf) 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"); |