]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix compact printing format and sealed check
authorLuis Machado <luis.machado@linaro.org>
Tue, 22 Dec 2020 15:18:42 +0000 (12:18 -0300)
committerLuis Machado <luis.machado@linaro.org>
Wed, 30 Dec 2020 19:12:40 +0000 (16:12 -0300)
Fix some erroneous interpretation of sealed capabilities and adjust the
code to print capability attributes correctly.

gdbsupport/ChangeLog:

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

* capability.cc (capability::to_str): Fix compact printing
format and documentation.
* capability.h (capability::is_sealed): Fix wrong check.

gdbsupport/ChangeLog
gdbsupport/capability.cc
gdbsupport/capability.h

index 4fe402fe1098871c5f2cd81d9667f7394120978d..d2a3b20099bc317513c40e3ea78bea9529baf50b 100644 (file)
@@ -1,3 +1,9 @@
+2020-12-30  Luis Machado  <luis.machado@arm.com>
+
+       * capability.cc (capability::to_str): Fix compact printing
+       format and documentation.
+       * capability.h (capability::is_sealed): Fix wrong check.
+
 2020-12-16  Luis Machado  <luis.machado@arm.com>
 
        * capability.cc (cap_short_perms_strings): Remove.
index 6fdd1c82cf8abcdf43d7844651c4dca5ebf99eb5..eb8f6980f781abdaa413938512780c91bb796a19 100644 (file)
@@ -547,6 +547,8 @@ capability::to_str (bool compact)
      - (2) - If the top 64 bits are non-zero and the representation is
        COMPACT, the capability has the following format:
 
+       <address> [<permissions>,<base>-<top>] (<attr>)
+
      - (3) - If the top 64 bits are non-zero and the representation is not
        COMPACT, the capability has the following format:
 
@@ -589,23 +591,28 @@ capability::to_str (bool compact)
       range_str += "-";
       range_str += core_addr_to_string_nz (get_limit ());
 
-      std::string attr_str ("");
+      std::string attr1_str ("");
+      std::string attr2_str ("");
+      std::string attr3_str ("");
 
       /* Handle attributes.  */
       if (get_tag () == false)
-       attr_str = "invalid ";
+       attr1_str = "invalid";
       if (get_otype () == CAP_SEAL_TYPE_RB)
-       attr_str += "sentry ";
+       {
+         if (!attr1_str.empty ())
+           attr2_str += ",";
+         attr2_str += "sentry";
+       }
       if (is_sealed ())
-       attr_str += "sealed ";
-
-      cap_str += "{";
-      cap_str = val_str + " [" + perm_str + "," + range_str + "]";
-
-      if (!attr_str.empty ())
-       cap_str += " ( " + attr_str + ")";
+       {
+         if (!attr1_str.empty () || !attr2_str.empty ())
+           attr3_str += ",";
+         attr3_str += "sealed";
+       }
 
-      cap_str += "}";
+      cap_str += val_str + " [" + perm_str + "," + range_str + "]";
+      cap_str += " (" + attr1_str + attr2_str + attr3_str + ")";
 
       return cap_str;
     }
index d77d8094a1a7da42b74749c7cf3d1c5b8cbd199e..9d518ac6dd09656779ffa6d02685da95aa6870e0 100644 (file)
@@ -568,7 +568,7 @@ public:
 
   inline bool is_sealed (void)
   {
-    return check_permissions (CAP_PERM_SEAL);
+    return get_otype () != 0;
   }
 
   /* Returns true if this is a system access capability.