From a2d62a17dd010703bcd8d9d73380ab8098316b76 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Tue, 22 Dec 2020 12:18:42 -0300 Subject: [PATCH] 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. --- gdbsupport/ChangeLog | 6 ++++++ gdbsupport/capability.cc | 29 ++++++++++++++++++----------- gdbsupport/capability.h | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index 4fe402fe109..d2a3b20099b 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,3 +1,9 @@ +2020-12-30 Luis Machado + + * capability.cc (capability::to_str): Fix compact printing + format and documentation. + * capability.h (capability::is_sealed): Fix wrong check. + 2020-12-16 Luis Machado * capability.cc (cap_short_perms_strings): Remove. 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. -- 2.47.3