+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
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;
+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
"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
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,
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 += " ]";
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
/* 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. */