Replies: 1 comment 7 replies
-
Found #1147 which sounds like getting a string slice is not possible at the moment, so that answers the second point. Keeping this open if anyone else has a better idea :) On a side note, if/when I'm happy with connectsnoop.bt I might post a PR to add it to existing tools as I didn't see any such tool in bpftrace nor bcc EDIT: ah, string manipulation would still really be great, skipping the first NUL byte is way harder than it should be... |
Beta Was this translation helpful? Give feedback.
-
Hello,
I wanted to make a 'connectsnoop' (like opensnoop, but for sys_enter/exit_connect, printing the process and details from the sockaddr; at least address for AF_INET{,6} or unix path)... But I can't seem to figure how to print the unix path, even if I don't do anything else:
Looking at resources about printf allocates a variable on the stack for each element it prints, here sun_path is a
string[108]
so we can seealloca [108 x i8]
in the assembly dump when running in debug... But even considering we pay that a couple of times if there are intermediate buffers we're still quite a bit off the 512 max.Here's the assembly I get:
So a couple of questions:
@addr[tid] = ...->sun_path
but printf does the same with it and print would mean printing the whole map (it refuses@addr[tid]
) -- OTOH if I'm happy with something not thread-safe as a first approximation assigning to@addr
works with print. It's not perfect as I can't combine it with the rest of a printf in the same line, but it's better than nothing at all...Thanks!
Beta Was this translation helpful? Give feedback.
All reactions