From: Luis Machado Date: Tue, 22 Dec 2020 15:18:42 +0000 (-0300) Subject: Fix compact printing format and sealed check X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b414634f8d595e4386ab9732340aa2c389b3c86;p=thirdparty%2Fbinutils-gdb.git Fix compact printing format and sealed check Fix some erroneous interpretation of sealed capabilities and adjust the code to print capability attributes correctly. gdbsupport/ChangeLog: 2020-12-30 Luis Machado * capability.cc (capability::to_str): Fix compact printing format and documentation. * capability.h (capability::is_sealed): Fix wrong check. --- diff --git a/gdbsupport/capability.cc b/gdbsupport/capability.cc index 6fdd1c82cf8..eb8f6980f78 100644 --- a/gdbsupport/capability.cc +++ b/gdbsupport/capability.cc @@ -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: +
[,-] () + - (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; } diff --git a/gdbsupport/capability.h b/gdbsupport/capability.h index d77d8094a1a..9d518ac6dd0 100644 --- a/gdbsupport/capability.h +++ b/gdbsupport/capability.h @@ -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.