aboutsummaryrefslogtreecommitdiff
path: root/gcc/mem-stats.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/mem-stats.h')
-rw-r--r--gcc/mem-stats.h87
1 files changed, 57 insertions, 30 deletions
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index 641f7c1..7524ff7 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -18,17 +18,20 @@ class hash_map;
struct mem_location
{
/* Default constructor. */
- inline mem_location () {}
+ inline
+ mem_location () {}
/* Constructor. */
- inline mem_location (mem_alloc_origin origin, bool ggc,
+ inline
+ mem_location (mem_alloc_origin origin, bool ggc,
const char *filename = NULL, int line = 0,
const char *function = NULL):
m_filename (filename), m_function (function), m_line (line), m_origin
(origin), m_ggc (ggc) {}
/* Copy constructor. */
- inline mem_location (mem_location &other): m_filename (other.m_filename),
+ inline
+ mem_location (mem_location &other): m_filename (other.m_filename),
m_function (other.m_function), m_line (other.m_line),
m_origin (other.m_origin), m_ggc (other.m_ggc) {}
@@ -36,7 +39,8 @@ struct mem_location
source code. As there is just a single pointer registered for every
constant that points to e.g. the same file name, we can use hash
of the pointer. */
- hashval_t hash ()
+ hashval_t
+ hash ()
{
inchash::hash hash;
@@ -48,14 +52,16 @@ struct mem_location
}
/* Return true if the memory location is equal to OTHER. */
- int equal (mem_location &other)
+ int
+ equal (mem_location &other)
{
return m_filename == other.m_filename && m_function == other.m_function
&& m_line == other.m_line;
}
/* Return trimmed filename for the location. */
- inline const char *get_trimmed_filename ()
+ inline const char *
+ get_trimmed_filename ()
{
const char *s1 = m_filename;
const char *s2;
@@ -66,7 +72,8 @@ struct mem_location
return s1;
}
- inline char *to_string ()
+ inline char *
+ to_string ()
{
unsigned l = strlen (get_trimmed_filename ()) + strlen (m_function)
+ LOCATION_LINE_EXTRA_SPACE;
@@ -81,7 +88,8 @@ struct mem_location
}
/* Return display name associated to ORIGIN type. */
- static const char *get_origin_name (mem_alloc_origin origin)
+ static const char *
+ get_origin_name (mem_alloc_origin origin)
{
return mem_alloc_origin_names[(unsigned) origin];
}
@@ -110,7 +118,8 @@ struct mem_usage
m_instances (instances) {}
/* Register overhead of SIZE bytes. */
- inline void register_overhead (size_t size)
+ inline void
+ register_overhead (size_t size)
{
m_allocated += size;
m_times++;
@@ -120,7 +129,8 @@ struct mem_usage
}
/* Release overhead of SIZE bytes. */
- inline void release_overhead (size_t size)
+ inline void
+ release_overhead (size_t size)
{
gcc_assert (size <= m_allocated);
@@ -128,7 +138,8 @@ struct mem_usage
}
/* Sum the usage with SECOND usage. */
- mem_usage operator+ (const mem_usage &second)
+ mem_usage
+ operator+ (const mem_usage &second)
{
return mem_usage (m_allocated + second.m_allocated,
m_times + second.m_times,
@@ -137,7 +148,8 @@ struct mem_usage
}
/* Comparison operator. */
- inline bool operator< (const mem_usage &second) const
+ inline bool
+ operator< (const mem_usage &second) const
{
return (m_allocated == second.m_allocated ?
(m_peak == second.m_peak ? m_times < second.m_times
@@ -145,7 +157,8 @@ struct mem_usage
}
/* Compare wrapper used by qsort method. */
- static int compare (const void *first, const void *second)
+ static int
+ compare (const void *first, const void *second)
{
typedef std::pair<mem_location *, mem_usage *> mem_pair_t;
@@ -156,7 +169,8 @@ struct mem_usage
}
/* Dump usage coupled to LOC location, where TOTAL is sum of all rows. */
- inline void dump (mem_location *loc, mem_usage &total) const
+ inline void
+ dump (mem_location *loc, mem_usage &total) const
{
char *location_string = loc->to_string ();
@@ -170,7 +184,8 @@ struct mem_usage
}
/* Dump footer. */
- inline void dump_footer () const
+ inline void
+ dump_footer () const
{
print_dash_line ();
fprintf (stderr, "%s%54li%27li\n", "Total", (long)m_allocated,
@@ -179,19 +194,22 @@ struct mem_usage
}
/* Return fraction of NOMINATOR and DENOMINATOR in percent. */
- static inline float get_percent (size_t nominator, size_t denominator)
+ static inline float
+ get_percent (size_t nominator, size_t denominator)
{
return denominator == 0 ? 0.0f : nominator * 100.0 / denominator;
}
/* Print line made of dashes. */
- static inline void print_dash_line (size_t count = 140)
+ static inline void
+ print_dash_line (size_t count = 140)
{
fprintf (stderr, "%s\n", std::string (count, '-').c_str ());
}
/* Dump header with NAME. */
- static inline void dump_header (const char *name)
+ static inline void
+ dump_header (const char *name)
{
fprintf (stderr, "%-48s %11s%16s%10s%17s\n", name, "Leak", "Peak",
"Times", "Type");
@@ -262,50 +280,59 @@ public:
~mem_alloc_description ();
/* Returns true if instance PTR is registered by the memory description. */
- bool contains_descriptor_for_instance (const void *ptr);
+ bool
+ contains_descriptor_for_instance (const void *ptr);
/* Return descriptor for instance PTR. */
- T *get_descriptor_for_instance (const void *ptr);
+ T *
+ get_descriptor_for_instance (const void *ptr);
/* Register memory allocation descriptor for container PTR which is
described by a memory LOCATION. */
- T *register_descriptor (const void *ptr, mem_location *location);
+ T *
+ register_descriptor (const void *ptr, mem_location *location);
/* Register memory allocation descriptor for container PTR. ORIGIN identifies
type of container and GGC identifes if the allocation is handled in GGC
memory. Each location is identified by file NAME, LINE in source code and
FUNCTION name. */
- T *register_descriptor (const void *ptr, mem_alloc_origin origin,
+ T *
+ register_descriptor (const void *ptr, mem_alloc_origin origin,
bool ggc, const char *name, int line,
const char *function);
/* Register instance overhead identified by PTR pointer. Allocation takes
SIZE bytes. */
- T *register_instance_overhead (size_t size, const void *ptr);
+ T *
+ register_instance_overhead (size_t size, const void *ptr);
/* For containers (and GGC) where we want to track every instance object,
we register allocation of SIZE bytes, identified by PTR pointer, belonging
to USAGE descriptor. */
- void register_object_overhead (T *usage, size_t size, const void *ptr);
+ void
+ register_object_overhead (T *usage, size_t size, const void *ptr);
/* Release PTR pointer of SIZE bytes. If REMOVE_FROM_MAP is set to true,
remove the instance from reverse map. */
- void release_instance_overhead (void *ptr, size_t size,
+ void
+ release_instance_overhead (void *ptr, size_t size,
bool remove_from_map = false);
/* Release intance object identified by PTR pointer. */
- void release_object_overhead (void *ptr);
+ void
+ release_object_overhead (void *ptr);
/* Get sum value for ORIGIN type of allocation for the descriptor. */
- T get_sum (mem_alloc_origin origin);
+ T
+ get_sum (mem_alloc_origin origin);
/* Get all tracked instances registered by the description. Items
are filtered by ORIGIN type, LENGTH is return value where we register
the number of elements in the list. If we want to process custom order,
CMP comparator can be provided. */
- mem_list_t *get_list (mem_alloc_origin origin, unsigned *length,
- int (*cmp) (const void *first, const void *second)
- = NULL);
+ mem_list_t *
+ get_list (mem_alloc_origin origin, unsigned *length,
+ int (*cmp) (const void *first, const void *second) = NULL);
/* Dump all tracked instances of type ORIGIN. If we want to process custom
order, CMP comparator can be provided. */