summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2024-01-21 23:35:40 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-01-23 01:03:23 +0100
commitcbe05b0f11169ee39d1213871f59c9f8154a4ee2 (patch)
tree9a7718a27c24c630c4902950fc6b396fa7708d94
parent5e4559ea2faebb482de51382ae5590a57083eda9 (diff)
Update rpctrace to use the new ABI for inlined port names
Message-ID: <Za3wnF34kVU0r1TS@jupiter.tail36e24.ts.net>
-rw-r--r--utils/rpctrace.c93
1 files changed, 59 insertions, 34 deletions
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index f7046a0b..3cc1f28e 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -801,6 +801,20 @@ rewrite_right (mach_port_t *right, mach_msg_type_name_t *type,
return 0;
}
+static mach_port_name_t *
+get_port_ref (void *data, const boolean_t is_inline, const int i) {
+ if (is_inline)
+ {
+ mach_port_name_inlined_t *const inlined_port_names = data;
+ return &inlined_port_names[i].name;
+ }
+ else
+ {
+ mach_port_t *const portnames = data;
+ return &portnames[i];
+ }
+}
+
static void
print_contents (mach_msg_header_t *inp,
void *msg_buf_ptr, struct req_info *req)
@@ -818,6 +832,7 @@ print_contents (mach_msg_header_t *inp,
mach_msg_type_number_t nelt; /* Number of data items. */
mach_msg_type_size_t eltsize; /* Bytes per item. */
mach_msg_type_name_t name; /* MACH_MSG_TYPE_* code */
+ boolean_t is_inline = type->msgt_inline;
if (!type->msgt_longform)
{
@@ -834,7 +849,7 @@ print_contents (mach_msg_header_t *inp,
data = msg_buf_ptr = lt + 1;
}
- if (!type->msgt_inline)
+ if (!is_inline)
{
/* This datum is out-of-line, meaning the message actually
contains a pointer to a vm_allocate'd region of data. */
@@ -857,35 +872,39 @@ print_contents (mach_msg_header_t *inp,
if (MACH_MSG_TYPE_PORT_ANY_RIGHT (name))
{
/* These are port rights. Translate them into wrappers. */
- mach_port_t *const portnames = data;
mach_msg_type_number_t i;
mach_msg_type_name_t newtypes[nelt ? : 1];
int poly;
assert_backtrace (inp->msgh_bits & MACH_MSGH_BITS_COMPLEX);
- assert_backtrace (eltsize == sizeof (mach_port_t));
+
+ if (is_inline)
+ assert_backtrace (eltsize == sizeof (mach_port_name_inlined_t));
+ else
+ assert_backtrace (eltsize == sizeof (mach_port_t));
poly = 0;
for (i = 0; i < nelt; ++i)
{
char *str;
+ mach_port_name_t *port_name = get_port_ref (data, is_inline, i);
newtypes[i] = name;
- str = rewrite_right (&portnames[i], &newtypes[i], req);
+ str = rewrite_right (port_name, &newtypes[i], req);
putc ((i == 0 && nelt > 1) ? '{' : ' ', ostream);
- if (portnames[i] == MACH_PORT_NULL)
+ if (*port_name == MACH_PORT_NULL)
fprintf (ostream, "(null)");
- else if (portnames[i] == MACH_PORT_DEAD)
+ else if (*port_name == MACH_PORT_DEAD)
fprintf (ostream, "(dead)");
else
{
if (str != 0)
fprintf (ostream, "%s", str);
else
- fprintf (ostream, "%3u", (unsigned int) portnames[i]);
+ fprintf (ostream, "%3u", (unsigned int) *port_name);
}
if (i > 0 && newtypes[i] != newtypes[0])
poly = 1;
@@ -900,39 +919,45 @@ print_contents (mach_msg_header_t *inp,
/* Some of the new rights are MAKE_SEND_ONCE.
Turn them all into MOVE_SEND_ONCE. */
for (i = 0; i < nelt; ++i)
- if (newtypes[i] == MACH_MSG_TYPE_MAKE_SEND_ONCE)
- {
- err = mach_port_insert_right (mach_task_self (),
- portnames[i],
- portnames[i],
- newtypes[i]);
- assert_perror_backtrace (err);
- }
- else
- assert_backtrace (newtypes[i] == MACH_MSG_TYPE_MOVE_SEND_ONCE);
+ {
+ mach_port_name_t *port_name = get_port_ref (data, is_inline, i);
+ if (newtypes[i] == MACH_MSG_TYPE_MAKE_SEND_ONCE)
+ {
+ err = mach_port_insert_right (mach_task_self (),
+ *port_name,
+ *port_name,
+ newtypes[i]);
+ assert_perror_backtrace (err);
+ }
+ else
+ assert_backtrace (newtypes[i] == MACH_MSG_TYPE_MOVE_SEND_ONCE);
+ }
}
else
{
for (i = 0; i < nelt; ++i)
- switch (newtypes[i])
+ {
+ mach_port_name_t *port_name = get_port_ref (data, is_inline, i);
+ switch (newtypes[i])
{
- case MACH_MSG_TYPE_COPY_SEND:
- err = mach_port_mod_refs (mach_task_self (),
- portnames[i],
- MACH_PORT_RIGHT_SEND, +1);
- assert_perror_backtrace (err);
- break;
- case MACH_MSG_TYPE_MAKE_SEND:
- err = mach_port_insert_right (mach_task_self (),
- portnames[i],
- portnames[i],
- newtypes[i]);
- assert_perror_backtrace (err);
- break;
- default:
- assert_backtrace (newtypes[i] == MACH_MSG_TYPE_MOVE_SEND);
- break;
+ case MACH_MSG_TYPE_COPY_SEND:
+ err = mach_port_mod_refs (mach_task_self (),
+ *port_name,
+ MACH_PORT_RIGHT_SEND, +1);
+ assert_perror_backtrace (err);
+ break;
+ case MACH_MSG_TYPE_MAKE_SEND:
+ err = mach_port_insert_right (mach_task_self (),
+ *port_name,
+ *port_name,
+ newtypes[i]);
+ assert_perror_backtrace (err);
+ break;
+ default:
+ assert_backtrace (newtypes[i] == MACH_MSG_TYPE_MOVE_SEND);
+ break;
}
+ }
name = MACH_MSG_TYPE_MOVE_SEND;
}