about summary refs log tree commit diff
path: root/elf/dl-tunables.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-07-12 06:04:53 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-01-15 05:59:10 -0800
commit86f65dffc2396d408beb628f1cad2b8f63e197bd (patch)
tree70d71a492800a6b4838ff2232ecc315d353a469b /elf/dl-tunables.c
parentcc528f9a7e51f769ea79a9c413af417671bcc695 (diff)
downloadglibc-86f65dffc2396d408beb628f1cad2b8f63e197bd.tar.gz
glibc-86f65dffc2396d408beb628f1cad2b8f63e197bd.tar.xz
glibc-86f65dffc2396d408beb628f1cad2b8f63e197bd.zip
ld.so: Add --list-tunables to print tunable values
Pass --list-tunables to ld.so to print tunables with min and max values.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-tunables.c')
-rw-r--r--elf/dl-tunables.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 9b4d737fb8..33be00e447 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -26,6 +26,7 @@
 #include <sysdep.h>
 #include <fcntl.h>
 #include <ldsodefs.h>
+#include <array_length.h>
 
 #define TUNABLES_INTERNAL 1
 #include "dl-tunables.h"
@@ -398,6 +399,48 @@ __tunables_init (char **envp)
     }
 }
 
+void
+__tunables_print (void)
+{
+  for (int i = 0; i < array_length (tunable_list); i++)
+    {
+      const tunable_t *cur = &tunable_list[i];
+      if (cur->type.type_code == TUNABLE_TYPE_STRING
+	  && cur->val.strval == NULL)
+	_dl_printf ("%s:\n", cur->name);
+      else
+	{
+	  _dl_printf ("%s: ", cur->name);
+	  switch (cur->type.type_code)
+	    {
+	    case TUNABLE_TYPE_INT_32:
+	      _dl_printf ("%d (min: %d, max: %d)\n",
+			  (int) cur->val.numval,
+			  (int) cur->type.min,
+			  (int) cur->type.max);
+	      break;
+	    case TUNABLE_TYPE_UINT_64:
+	      _dl_printf ("0x%lx (min: 0x%lx, max: 0x%lx)\n",
+			  (long int) cur->val.numval,
+			  (long int) cur->type.min,
+			  (long int) cur->type.max);
+	      break;
+	    case TUNABLE_TYPE_SIZE_T:
+	      _dl_printf ("0x%Zx (min: 0x%Zx, max: 0x%Zx)\n",
+			  (size_t) cur->val.numval,
+			  (size_t) cur->type.min,
+			  (size_t) cur->type.max);
+	      break;
+	    case TUNABLE_TYPE_STRING:
+	      _dl_printf ("%s\n", cur->val.strval);
+	      break;
+	    default:
+	      __builtin_unreachable ();
+	    }
+	}
+    }
+}
+
 /* Set the tunable value.  This is called by the module that the tunable exists
    in. */
 void