|
From: Paul F. <pa...@so...> - 2025-12-07 07:55:17
|
https://sourceware.org/cgit/valgrind/commit/?id=a779c501550173dbee98a6713402fafb161e59a7 commit a779c501550173dbee98a6713402fafb161e59a7 Author: Paul Floyd <pj...@wa...> Date: Sun Dec 7 08:50:32 2025 +0100 Darwin mach_msg_host: move assign_port_name to post There's a GrP comment saying that assign_port_name should only be called on success. And indeed when it is called in the PRE and it can't find the info for the port then the code will assert. Diff: --- coregrind/m_syswrap/syswrap-darwin.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 13ca4eb722..3bbfb76e61 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -5407,7 +5407,8 @@ PRE(host_request_notification) } // GrP fixme only do this on success - assign_port_name(req->notify_port.name, "host_notify-%p"); + // PJF moved to POST(mach_msg_post) + //assign_port_name(req->notify_port.name, "host_notify-%p"); } @@ -8771,6 +8772,7 @@ PRE(mach_msg) else if (mh->msgh_request_port == vg_host_port) { // message sent to mach_host_self() CALL_PRE(mach_msg_host); + AFTER = POST_FN(mach_msg_host); return; } else if (is_task_port(mh->msgh_request_port)) { @@ -8971,6 +8973,34 @@ POST(mach_msg_unhandled_check) PRINT("mach_msg_unhandled_check tid:%d missed mapping change()", tid); } +POST(mach_msg_host) +{ + mach_msg_header_t *mh = (mach_msg_header_t *)ARG1; + + // FIXME PJF put this in a header rather than have a copy and paste duplicate +#pragma pack(4) + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t notify_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + host_flavor_t notify_type; + } Request; +#pragma pack() + + switch (mh->msgh_id) { + case 217: { + Request *req = (Request *)ARG1; + assign_port_name(req->notify_port.name, "host_notify-%p"); + } + break; + default: + break; + } +} + /* --------------------------------------------------------------------- other Mach traps |