Hi,

I was trying to retrieve stack traces from tracepoint probe by modifying 
offcputime.py


The original code is in blue and the changed code is in yellow.


//int oncpu(struct pt_regs *ctx, struct task_struct *prev) {
TRACEPOINT_PROBE(sched, sched_switch){

    //u32 pid = prev->pid;
    //u32 tgid = prev->tgid;

    u32 pid = args->prev_pid, tgid;
    u64 ts, *tsp;
    // record previous thread sleep time
    if ((THREAD_FILTER) && (STATE_FILTER)) {
        ts = bpf_ktime_get_ns();
        start.update(&pid, &ts);
    }
    // get the current thread's start time
    //pid = bpf_get_current_pid_tgid();

    pid = args->next_pid;
    tgid = bpf_get_current_pid_tgid() >> 32;

...
...
...

I also replaced 'ctx' with 'args'

kernel_stack_get = "stack_traces.get_stackid(args, BPF_F_REUSE_STACKID)"
user_stack_get = \
    "stack_traces.get_stackid(args, BPF_F_REUSE_STACKID | BPF_F_USER_STACK)"

However, no stack traces, kernel/ user, were returned. Is it not possible to 
get stack traces from tracepoint probes?

I came across this link:
https://patchwork.kernel.org/patch/8747201/

Do we have any functions to access the pt_regs from tracepoint probes? I am 
running the probes in kernel version 4.8.

Thanks,
Reena.



_______________________________________________
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Reply via email to