diff mbox series

Add various constants to malloc_info output.

Message ID xnef55euz3.fsf@greed.delorie.com
State New
Headers show
Series Add various constants to malloc_info output. | expand

Commit Message

DJ Delorie May 10, 2019, 11:43 p.m. UTC
It was easier to add this than do manually figure these out... ;-)

I'm not an XML expert so if there's a better choice of schema for
these, speak up.

	* malloc/malloc.c (__malloc_info): Add various constants to the
	output.

Comments

Florian Weimer May 11, 2019, 6:20 a.m. UTC | #1
* DJ Delorie:

> It was easier to add this than do manually figure these out... ;-)
>
> I'm not an XML expert so if there's a better choice of schema for
> these, speak up.
>
> 	* malloc/malloc.c (__malloc_info): Add various constants to the
> 	output.
>
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index b8baaa2706..0ec0dcc8cf 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -5387,6 +5387,16 @@ __malloc_info (int options, FILE *fp)
>  
>    fputs ("<malloc version=\"1\">\n", fp);
>  
> +  fprintf (fp, "<malloc_alignment bytes=\"%ld\" />\n", (long) MALLOC_ALIGNMENT);
> +  fprintf (fp, "<min_chunk_size bytes=\"%ld\" />\n", (long) MIN_CHUNK_SIZE);
> +  fprintf (fp, "<max_fast_alloc bytes=\"%ld\" />\n", (long) MAX_FAST_SIZE);

> +  fprintf (fp, "<max_tcache_alloc bytes=\"%ld\" />\n", (long) MAX_TCACHE_SIZE);

I think this needs to be conditional on USE_TCACHE.

By the way, do you know if MALLOC_ALIGNMENT is visible in debugging
information somewhere (without -g3)?
diff mbox series

Patch

diff --git a/malloc/malloc.c b/malloc/malloc.c
index b8baaa2706..0ec0dcc8cf 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5387,6 +5387,16 @@  __malloc_info (int options, FILE *fp)
 
   fputs ("<malloc version=\"1\">\n", fp);
 
+  fprintf (fp, "<malloc_alignment bytes=\"%ld\" />\n", (long) MALLOC_ALIGNMENT);
+  fprintf (fp, "<min_chunk_size bytes=\"%ld\" />\n", (long) MIN_CHUNK_SIZE);
+  fprintf (fp, "<max_fast_alloc bytes=\"%ld\" />\n", (long) MAX_FAST_SIZE);
+  fprintf (fp, "<max_tcache_alloc bytes=\"%ld\" />\n", (long) MAX_TCACHE_SIZE);
+  fprintf (fp, "<min_large_alloc bytes=\"%ld\" />\n", (long) MIN_LARGE_SIZE);
+  fprintf (fp, "<default_mmap_threshold bytes=\"%ld\" />\n", (long) DEFAULT_MMAP_THRESHOLD);
+  fprintf (fp, "<max_mmap_threshold bytes=\"%ld\" />\n", (long) DEFAULT_MMAP_THRESHOLD_MAX);
+  fprintf (fp, "<heap_min_size bytes=\"%ld\" />\n", (long) HEAP_MIN_SIZE);
+  fprintf (fp, "<heap_max_size bytes=\"%ld\" />\n", (long) HEAP_MAX_SIZE);
+
   /* Iterate over all arenas currently in use.  */
   mstate ar_ptr = &main_arena;
   do