-
Notifications
You must be signed in to change notification settings - Fork 499
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
feat(layers/dtrace): Support User Statically-Defined Tracing(aka USDT) on Linux #4053
Conversation
c48eab7
to
c2f0679
Compare
6716317
to
653d889
Compare
…) on Linux Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
0964c56
to
ffe0794
Compare
Signed-off-by: Manjusaka <me@manjusaka.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All our probe names should follow the same rule. I raised some of them but not all. I feel like it's better to follow the same rules across the whole project.
core/src/layers/dtrace.rs
Outdated
n | ||
}) | ||
.map_err(|e| { | ||
probe_lazy!(opendal, blocking_read_complete_error, c_path.as_ptr()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking_reader_read_error
Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
This feature is an experimental feature
TL;DR;
The PR will make the debug and tracing the opendal process easier in the Linux platform. The people can use so many modern tools like bpftrace to trace the internal state in the process
USDT is a way to allow people to pre-define some static hooks. Those hooks could be used to fetch some internal information when the process runs.
I will use this PR to describe the detailed behavior of the DTrace in the OpenDAL.
When people enabled
layers-dtrace
feature and added the layer to their code like the following code:Then we compile the code, and use
readelf -n ${target_binary}
to get the binary detail, we will find some information like following belowWe describe the offset, the argument of hook, and so many information else in each section of the text. For example, the
write_start
hook, we can find the offset is0x00000000000fc6e5
and we can use gdb to verify it.We will figure out the asm in 0x5555556506e5 is
NOP
(the process virtual address started at 0x555555554000 on my machine, and 0x555555554000+0x00000000000fc6e5=0x5555556506e5). TheNOP
instruction code will be replaced by the interrupt code when the hook is attached (In x86_64, the interrupt code is INT3)We can also set a breakpoint at this address.
We will find the code paused on line 146 in dtrace.rs. This is exactly what we want
The USDT can help us debug it more easily and make it easier to trace it.
We can use many other tools to trace it.