I have to admit it's been a long while (a few years) since I looked deeply
into our tracepoint implementation, so I'm quite rusty.
I thought that in the past OSv tracepoints *did* work in modules - a good
example is the test tests/tst-tracepoint - but I'm not sure this test
actually tests everything you want to work (such as dynamically enabling or
disabling specific tracepoints?) - can you please clarify what did you try
and didn't work?

On Mon, Sep 21, 2020 at 1:32 PM Wonsup Yoon <[email protected]> wrote:

> This is my example code.
>
> #include <stdio.h>
> #include <osv/trace.hh>
>
>
> TRACEPOINT(trace_hello, "i=%d", int);
>
> int main(){
> printf("Hello from C code\n");
> printf("enabled: %lx\n", trace_hello.enabled());
> for(int i =0; i<128;++i){
> trace_hello(i);
> }
> return 0;
> }
>
> It seems that TRACEPOINT use tracepoint_patch_sites sections which are
> linked to loader. (arch/x64/arch-trace.hh)
> However, application or modules are dynamically linked, so their
> tracepoint are not visible to GDB.
>

How is GDB relevant here?
If you haven't seen this already, check out
https://github.com/cloudius-systems/osv/wiki/Debugging-OSv#tracepoints
explaining how to use tracepoints.

When an executable is loaded (either the main OSv kernel or a loadable
object), the constructors of all the global objects
it has are run. The tracepoint's constructor,
tracepoint_base::tracepoint_base(), adds itself to a global list of trace
points
(tp_list) and also considers whether to enable this tracepoint. The reverse
happens when the object is unloaded.

What kind of problems do you experience when you try to enable or use such
tracepoints?
I wonder if the problem is that the tracepoints *code* (so-called "text
segment") is marked read-only so we can't modify it. I don't remember what
we did about this in the past. If this is the problem you should expect
segfaults when trying to enable the tracepoints. Is this what you are
seeing?


> loader.ld's tracepoint_patch_sites:
>   .tracepoint_patch_sites ALIGN(8) : AT(ADDR(.tracepoint_patch_sites) -
> OSV_KERNEL_VM_SHIFT) {
>         __tracepoint_patch_sites_start = .;
>         *(.tracepoint_patch_sites)
>         __tracepoint_patch_sites_end = .;
>     } : text
>


loader.ld only applies to the main Scylla executable, not to shared
objects.
The only thing this loader.ld thing does is to create the
__tracepoint_patch_sites_start, __tracepoint_patch_sites_end variables. I
don't remember why we actually need those...

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjsSMvO2z1wKsCJ-gtwOUf5LkshHquyG%2B_hoSKHHAKpnSQ%40mail.gmail.com.

Reply via email to