Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pid with Systrace #5

Open
sammerry opened this issue Sep 1, 2021 · 3 comments
Open

Pid with Systrace #5

sammerry opened this issue Sep 1, 2021 · 3 comments

Comments

@sammerry
Copy link

sammerry commented Sep 1, 2021

Hey, I'm looking into using hstrace for a utility im working on but strugling tracing both parent and child processes. It seems like coupling pid with syscall in the crossbeam_chanel as a touple would keep things clearer when collecting calls from parent and child processes. You could simply forward each child into a central channel or chain iterators into a single match.

Is there an easier way to do this?

@sammerry
Copy link
Author

sammerry commented Sep 1, 2021

nevermind, looks like TraceOutput contains Pid so simply calling .iter() on it should get what i need. Still having trouble joining multiple crossbeam_channels into one.
https://github.com/blaind/hstrace/blob/master/src/trace/hstrace_impl.rs#L78

Is there any chance that hstrace will support child processes in the future?
https://github.com/blaind/hstrace/blob/master/src/trace/hstrace_impl.rs#L200

@blaind
Copy link
Owner

blaind commented Sep 2, 2021

Hi! This repo was more of a PoC/WIP, so not being actively developed.

If I remember correctly, https://github.com/blaind/hstrace/blob/master/src/trace/hstrace_impl.rs#L200 comment was added for future performance improvements where each thread could be traced in separate thread.

Forks are already detected. Added an example, check out https://github.com/blaind/hstrace/blob/master/examples/05_trace_child.rs

Output (notice the increasing pid after clone):

TRACE: pid=16430, call=Swapoff vars=["/tmp/__nonexistant"] out=Some(Err(EPERM))
TRACE: pid=16430, call=Mmap vars=[NULL, 1052672, 3, 34, 4294967295, 0] out=Some(Ok(0x7f192ad57000))
TRACE: pid=16430, call=Clone vars=[] out=Some(Ok(16431))
TRACE: pid=16431, call=Readlink vars=["/tmp/link_src_child_1", 0x7f192ae56ef0, 256] out=Some(Err(ENOENT))
TRACE: pid=16431, call=Mmap vars=[NULL, 1052672, 3, 34, 4294967295, 0] out=Some(Ok(0x7f192ac56000))
TRACE: pid=16431, call=Clone vars=[] out=Some(Ok(16432))
TRACE: pid=16432, call=Readlink vars=["/tmp/link_src_child_2", NULL, 256] out=Some(Err(ENOENT))
TRACE: pid=16431, call=Wait4 vars=[https://git.io/Jv49L] out=None
TRACE: pid=16431, call=Munmap vars=[0x7f192ac56000, 1052672] out=Some(Ok(0))
TRACE: pid=16430, call=Wait4 vars=[https://git.io/Jv49L] out=None
TRACE: pid=16430, call=Munmap vars=[0x7f192ad57000, 1052672] out=Some(Ok(0))
TRACE: pid=16430, call=ExitGroup vars=[0] out=None
TRACE: pid=16432, call=Exit vars=[https://git.io/Jv49L] out=None
TRACE: pid=16431, call=Exit vars=[https://git.io/Jv49L] out=None

@sammerry
Copy link
Author

sammerry commented Sep 2, 2021

Thanks! that example helps a lot.

I don't have a lot of time at the moment, but really like the premise of the project and would like to help move it out of PoC if you have a list of missing features of things that need work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants