Hi, thank you for your answer I don't think the kernel symbols are related. I do see the segfault for the command "perf report --stdio" occurs in OpenCSD, and this is the callstack:
#0 TrcPktDecodeEtmV4I::decodePacket (this=this@entry=0x555555e9a650, Complete=@0x7fffffffbb67: true) at /home/mike/repo/OpenCSD/decoder/source/etmv4/trc_pkt_decode_ etmv4i.cpp:373 #1 0x00007ffff69b812b in TrcPktDecodeEtmV4I::processPacket (this=0x555555e9a650) at /home/mike/repo/OpenCSD/decoder/source/etmv4/trc_pkt_decode_ etmv4i.cpp:99 #2 0x00007ffff69b8b58 in TrcPktDecodeBase<EtmV4ITrcPacket, EtmV4Config>::PacketDataIn ( this=0x555555e9a650, op=OCSD_OP_DATA, index_sop=41, p_packet_in=0x555555e98cf8) at /home/mike/repo/OpenCSD/decoder/include/common/trc_pkt_ decode_base.h:247 #3 0x00007ffff69b4000 in EtmV4IPktProcImpl::processData (this=0x555555e98c70, index=<optimized out>, dataBlockSize=15, pDataBlock=0x555555e94869 "\177\201\177\377\377", numBytesProcessed=0x7fffffffbda4) at /home/mike/repo/OpenCSD/decoder/source/etmv4/trc_pkt_proc_ etmv4i_impl.cpp:115 #4 0x00007ffff69b036a in TrcPktProcBase<EtmV4ITrcPacket, _ocsd_etmv4_i_pkt_type, EtmV4Config>::TraceDataIn (this=0x555555e98aa0, op=<optimized out>, index=32, dataBlockSize=<optimized out>, pDataBlock=<optimized out>, numBytesProcessed=<optimized out>) at /home/mike/repo/OpenCSD/decoder/include/common/trc_pkt_proc_ base.h:238 #5 0x00007ffff69a18bd in TraceFmtDcdImpl::outputFrame (this=this@entry =0x555555e93780) at /home/mike/repo/OpenCSD/decoder/source/trc_frame_deformatter.cpp:700 #6 0x00007ffff69a1c24 in TraceFmtDcdImpl::processTraceData (this=0x555555e93780, index=<optimized out>, dataBlockSize=<optimized out>, pDataBlock=<optimized out>, numBytesProcessed=0x7fffffffbee4) at /home/mike/repo/OpenCSD/decoder/source/trc_frame_deformatter.cpp:272 #7 0x00005555558284b6 in cs_etm_decoder__process_data_block (decoder=0x555555e8b2d0, indx=0, buf=buf@entry=0x7ffff7ff25aa ")", len=len@entry=16640, consumed=consumed@entry=0x7fffffffbf68) at util/cs-etm-decoder/cs-etm-decoder.c:518 #8 0x0000555555826d22 in cs_etm__run_decoder (etmq=0x555555e7b150) at util/cs-etm.c:986 #9 cs_etm__process_timeless_queues (etm=0x555555e7a070, tid=2161, time_=18446744073709551615)
*This is the instruction that causes the segfault as far as i saw:*
Program received signal SIGSEGV, Segmentation fault. TrcPktDecodeEtmV4I::decodePacket (this=this@entry=0x555555e9a650, Complete=@0x7fffffffbb67: true) at /home/mike/repo/OpenCSD/decoder/source/etmv4/trc_pkt_decode_ etmv4i.cpp:373 372 std::vector<uint32_t> params; 373 params[0] = m_curr_packet_in->getCC();
This segfaults because accessing an element in a vector that doesn't exist causes undefined behavior.. this causes segfault on my system. Any OpenCSD contributor that can help?
Thanks, Mike.
On Mon, Mar 19, 2018 at 11:40 AM, Leo Yan leo.yan@linaro.org wrote:
Hi Mike,
On Mon, Mar 19, 2018 at 11:08:17AM +0200, Mike Bazov wrote:
Greetings, i was referred to this mailing list by Mathleu Poirler.
I'm recording Coresight using my Dragonboard 410c board, after compiling the perf-opencsd-master kernel.
I am using acme branch: https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
Recording seems to work on a simple program i did which does nothing but print a string to the screen.
Now, i use perf to hopefully decode the trace, but perf segfaults. I'll
let
you know that decoding using the sample trace given here: https://github.com/Linaro/OpenCSD/blob/master/HOWTO.md
Does work.
I dived into the cs-trace-disasm.py script to see why exactly it doesn't work and i noticed this command causes the segfault: $ ~/linux/tools/perf/perf script --show-mmap-events
/lib/aarch64-linux-gnu/ld-2.26.so with build id 6516ef8fa13fcb739834af9e87fb5fe9df612096 not found, con> Segmentation fault (core dumped)
This command also segfaults:
$ ~/linux/tools/perf/perf report --stdio
/lib/aarch64-linux-gnu/ld-2.26.so with build id 6516ef8fa13fcb739834af9e87fb5fe9df612096 not found, con> (END)Segmentation fault (core dumped)
I have not seen segmentation fault issue, but it's good to share some my finding:
I remembered if use kallsyms for kernel symbols, you need enable kernel configs:
CONFIG_PROC_KCORE=y CONFIG_PROC_VMCORE=y CONFIG_KALLSYMS=y CONFIG_KALLSYMS_ALL=y
Also please note that the userspace has permission to export the complete kernel address info; IIRC, you need set '0' or '1' to below entry: echo 0 > /proc/sys/kernel/kptr_restrict
If you want to specify kernel for importing kernel symbol table, like this command './perf report -k ./vmlinux --stdio', you might need notice this patch: https://www.spinics.net/lists/linux-perf-users/msg05576.html
If upper two methods work, I still think it might need root cause the segmentation fault issue and fix with extra patches.
Thanks, Leo Yan
But this command works:
$ ~/linux/tools/perf/perf report --stdio --dump
And i can see Coresight packets information when browsing the output.
My .debug directory looks like this:
~/.debug/ |-- [kernel.kallsyms] | `-- 1dc43d23817467d7717b19af07463af0d9a9bd83 | `-- kallsyms |-- [vdso] | `-- 18863444e4f3e2600f53e406421b2a0edd940888 | `-- vdso |-- bin | `-- check | `-- 31694f29996e06da12f63d6088ec6eb23b3079c4 | `-- elf `-- lib `-- aarch64-linux-gnu |-- ld-2.26.so | `-- 6516ef8fa13fcb739834af9e87fb5fe9df612096 | `-- elf `-- libc.so.6 `-- 06e99d8d6acabab0643e0f525ac561cf73db6498 `-- elf
Now, another need i wanted to ask is where can i find the code that uses OpenCSD to decode the trace and output instructions? eventually, i don't want to use perf, but rather use OpenCSD directly in my code to decode traces.
Not sure what to do here and how to proceed, i'll appreciate some help. Thank you all!
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight