On Tue, Sep 5, 2017 at 7:43 AM, Nair, Reena via iovisor-dev <[email protected]> wrote: > 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)"
This won't work. get_stackid needs pt_regs so that it can walk through the frame to get stacks. Here for tracepoint, "args" is the tracepoint structure. > > 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 > [email protected] > https://lists.iovisor.org/mailman/listinfo/iovisor-dev > _______________________________________________ iovisor-dev mailing list [email protected] https://lists.iovisor.org/mailman/listinfo/iovisor-dev
