Implement bpftrace workaround for receive_request
usdt::h2o:receive_request takes `unsigned` for the 3rd parameter (arg2),
thus this patch adds a bitmasking workaround for it as a safeguard.
@@ -51,12 +51,15 @@ if ($tracer_pid == 0) {
or die "failed to create temporary file:$tempdir/trace.out:$!";
if ($^O eq 'linux') {
exec qw(bpftrace -v -B none -p), $server->{pid}, "-e", <<'EOT';
-usdt::h2o:receive_request {printf("*** %llu:%llu version %d.%d ***\n", arg0, arg1, arg2 / 256, arg2 % 256)}
+/* arg2: unsigned int
+ * Workarond for an issue that bpftrace always grabs 64-bit integer from memory regardless of
+ * the datatype declared in h2o-probes.d. Ignore the upper bits by masking. */
+usdt::h2o:receive_request {printf("*** %llu:%llu version %d.%d ***\n", arg0, arg1, (arg2 & 0xffffffff) / 256, (arg2 & 0xffffffff) % 256)}
usdt::h2o:receive_request_header {printf("%s: %s\n", str(arg2, arg3), str(arg4, arg5))}
usdt::h2o:send_response {printf("%llu:%llu status:%u\n", arg0, arg1, arg2)}
usdt::h2o:send_response_header {printf("%s: %s\n", str(arg2, arg3), str(arg4, arg5))}
-/* &0xff: Workarond for an issue that bpftrace always grabs 64-bit integer from memory regardless of
- * the datatype declared in h2o-probes.d. Ignore the upper 56 bits by masking with 0xff. */
+/* arg1: uint8_t
+ * Same workaround for bpftrace */
usdt::h2o:h2_unknown_frame_type {printf("Unknown HTTP/2 frame type: %d\n", (arg1 & 0xff))
}
EOT
