]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Print shorter version of decoded capabilities
authorLuis Machado <luis.machado@arm.com>
Thu, 5 Nov 2020 16:10:08 +0000 (13:10 -0300)
committerLuis Machado <luis.machado@linaro.org>
Tue, 8 Dec 2020 18:02:58 +0000 (15:02 -0300)
In order to produce output that is not so verbose, we print the short version
of the decoded capabilities instead.

gdb/ChangeLog:

2020-11-11  Luis Machado  <luis.machado@arm.com>

* valprint.c (generic_value_print_capability): Use compact form.

gdbsupport/ChangeLog:

2020-11-11  Luis Machado  <luis.machado@arm.com>

* capability.cc (cap_short_perms_strings): New static global.
(capability::to_str): New argument COMPACT. Print contents based
on the new argument.
(capability::print): Update calls.
* capability.h (capability::to_str): Update prototype and
documentation.

gdb/ChangeLog
gdb/valprint.c
gdbsupport/ChangeLog
gdbsupport/capability.cc
gdbsupport/capability.h

index c1a4f45d9c829cec17cca860eb2ea7a5f7a02679..bf9ed064c910d6617f905a0c0abc4656d1bded69 100644 (file)
@@ -1,3 +1,7 @@
+2020-11-11  Luis Machado  <luis.machado@arm.com>
+
+       * valprint.c (generic_value_print_capability): Use compact form.
+
 2020-11-11  Luis Machado  <luis.machado@arm.com>
 
        * valops.c (value_cast): Handle casting from capabilities and
index 048512d31087f51ba89dc45780bc5207fc60d251..7e3170083603fa07c4d5e095d2013e30d2efda8c 100644 (file)
@@ -513,7 +513,7 @@ generic_value_print_capability (struct value *val, struct ui_file *stream,
       uint128_t dummy_cap;
       memcpy (&dummy_cap, contents, length);
       capability cap (dummy_cap, tag);
-      fprintf_filtered (stream, "%s", cap.to_str ().c_str ());
+      fprintf_filtered (stream, "%s", cap.to_str (true).c_str ());
     }
 
   return;
index 111581b8d5c918bb3b1ff7ca8c9b653a0470acfe..ddf010997381794d55cd4d0782549a2e6dd95746 100644 (file)
@@ -1,3 +1,12 @@
+2020-11-11  Luis Machado  <luis.machado@arm.com>
+
+       * capability.cc (cap_short_perms_strings): New static global.
+       (capability::to_str): New argument COMPACT. Print contents based
+       on the new argument.
+       (capability::print): Update calls.
+       * capability.h (capability::to_str): Update prototype and
+       documentation.
+
 2020-11-11  Luis Machado  <luis.machado@arm.com>
 
        * capability.cc (capability::to_str): Rename "attributes" to
index 1b01590d5cac812874d4d3aa7985608522462600..6551bab6784a5937c50d99416fe8aed763a87589 100644 (file)
@@ -76,6 +76,31 @@ static const char *cap_perms_strings[] =
   "Load"
 };
 
+/* Short version of permission string names, indexed by bit number from
+   permissions
+   Valid bits are 0 through 17.  */
+static const char *cap_short_perms_strings[] =
+{
+  "G",
+  "E",
+  "U0",
+  "U1",
+  "U2",
+  "U3",
+  "MLd",
+  "CID",
+  "BrUn",
+  "Sys",
+  "Un",
+  "Sl",
+  "StLoC",
+  "StC",
+  "LdC",
+  "X",
+  "St",
+  "Ld"
+};
+
 /* Returns a capability, derived from the input capability, with base address
    set to the value of the input capability and the length set to a given
    value.  If precise bounds setting is not possible, either the bounds are
@@ -523,10 +548,13 @@ capability::set_offset (uint64_t offset)
   set_value (get_base () + offset);
 }
 
-/* Returns a string representation of the capability.  */
+/* Returns a string representation of the capability.
+
+   If COMPACT is true, use a less verbose form.  Otherwise print
+   the more verbose version.  */
 
 std::string
-capability::to_str (void)
+capability::to_str (bool compact)
 {
   /* The printing format is the following:
      {tag = %d, address = 0x%016x, permissions = {[%s], otype = 0x%04x,
@@ -549,7 +577,11 @@ capability::to_str (void)
     if (check_permissions (1 << i))
       {
        perm_str += " ";
-       perm_str += cap_perms_strings [i];
+
+       if (compact)
+         perm_str += cap_short_perms_strings[i];
+       else
+         perm_str += cap_perms_strings[i];
       }
 
   perm_str += " ]";
@@ -581,7 +613,7 @@ capability::to_str (void)
 void
 capability::print (void)
 {
-  printf ("%s", to_str ().c_str ());
+  printf ("%s", to_str (true).c_str ());
 }
 
 /* UNIT TESTS - Exercise all the methods and primitives.  Some of the tests
index 817316ed0e3d4ecc495efaf97c8cf286035971bc..fd94768e432fc252ea78bc53069fd3cab297ed9b 100644 (file)
@@ -544,9 +544,12 @@ public:
 
   /* Printing functions.  */
 
-  /* Returns a string representation of the capability.  */
+  /* Returns a string representation of the capability.
 
-  std::string to_str (void);
+     If COMPACT is true, use a less verbose form.  Otherwise print
+     the more verbose version.  */
+
+  std::string to_str (bool compact);
 
   /* Print the capability.  */