Hi Mike,
The c_api_pkt_print_test.c is probably a simpler example of how to create a valid decode tree.
This program sets up a decoder for a single trace source from a block of captured trace data. It uses the same snapshot data, but has a lot of the config parameters hard coded into the program, rather than use the snapshot library to read them from files. Start at process_trace_data() and work from there.
Mike
On 27 March 2018 at 15:18, Mike Leach mike.leach@linaro.org wrote:
Hi Mike,
You are correct - we do need additional documentation on how to create a program using the decoder.
To create a valid decode environment you need the following:-
- most obvious - some trace. Normally formatted in 16 byte coresight
trace frames.
- for each core traced, the configuration of the ETM attached to that core.
if full decode - rather than the packet dump seen in perf report --dump is required then...
- the memory images of the programs executed - with information on
addresses these images were loaded.
All the above appears in the perf.data file, and is extracted and added to the decode tree.
I suggest looking at the test programs to get an idea of how to use the decoder - especially trc_pkt_lister.cpp. This program processes trace snapshots, so uses the snapshot library to create a decode tree. [CreateDcdTreeFromSnapShot::createDecodeTree() in ss_to_dcdtree.cpp ] The c_api_pkt_print_test.c is similar but for the C-API wrapper.
The principles are the same though. The packet lister will...
- create an initial decode tree - normally with a CoreSight trace
frame demux working on aligned trace data .(OCSD_TRC_SRC_FRAME_FORMATTED | OCSD_DFRMTR_FRAME_MEM_ALIGN) 2) for each CPU/PE, call CreateDcdTreeFromSnapShot::createPEDecoder(), which calls a protocol specific function. 3)e.g. createETMv4Decoder() populates an ETMv4 config structure and passes it to the decode tree. 4) for the "dump" files - i.e. memory images, these are added in the CreateDcdTreeFromSnapShot::processDumpfiles() function, using addBinFileMemAcc(). These are added to the decode tree as file images - with a load address for the 1st byte in the file
For memory images, perf will actually add the saved elf files which it lists in perf.data as being loaded while the program is run, and it stores in .debug in the users home directory. In this case these are added to the memaccessor with both a load address, and the offset of the code section within the file. Thus if perf cannot find the programs in the .debug directory, an essential part of the decode process is missing.
Finally, sinks for the output of the trace decode can be added - in this case packet printers. For full decode a single printer is used as fully decoded trace is output at a single point with the trace ID associated. When printing raw trace packets, an output sink per decoder is used.
From the code you show, I can see 1), but no evidence that 2) or 3) are occurring.
Regards
Mike
On 27 March 2018 at 13:48, Mike Bazov mike@perception-point.io wrote:
Hi,
Thank you for your answers.
- I updated to the acme's "perf/core" branch, and it's still not solved. I
still don't get any events for my recorded traces, except if i record "uname -r".
- I'm trying to integrate directly with OpenCSD, and decode my own traces.
I took the "perf.data" file from the HOWTO.md, which contains a valid trace according to the HOWTO, and extracted the trace itself from the perf file. I have a raw trace file without any perf related data and structures. I'm trying to open my own decoder, and decode instructions, after taking examples from "tools/perf/util/cs-etm-decoder/cs-etm-decoder.c", "tools/perf/util/cs-etm.c". There is no documentation on how to use OpenCSD as a library, nothing(full, not partial like the docs in the repo) that i found at least.
This is a very short example of what i do(same order that they appear in
the code) to create a dcd tree, and create a decoder, ignore the error validation right now, they are there, i'm making sure this message is short as possible:
/* Open a decoder tree */ flags |= OCSD_DFRMTR_FRAME_MEM_ALIGN; flags |= OCSD_DFRMTR_RESET_ON_4X_FSYNC; decoder_tree = ocsd_create_dcd_tree(OCSD_TRC_SRC_FRAME_FORMATTED,
OCSD_DFRMTR_RESET_ON_4X_FSYNC);
/* Create a __full__ decoder */ config.arch_ver = ARCH_V8; config.core_prof = profile_CortexA; config.reg_traceidr = 18; /* specific hard coded trace id to be
indentical to perf, just to check if it works */ ocsd_err = ocsd_dt_create_decoder(decoder_tree, OCSD_BUILTIN_DCD_ETMV4I,
OCSD_CREATE_FLG_FULL_DECODER, &config, &csid);
/* Register my element callback */ ocsd_err = ocsd_dt_set_gen_elem_outfn(decoder_tree,
decoder_callback, NULL);
Now i mmap() my trace file.. and do the following:
/* Reset the decoder */
val = ocsd_dt_process_data(dcd_tree, OCSD_OP_RESET, 0, 0, NULL, NULL); if (OCSD_DATA_RESP_IS_FATAL(val)) { return -1; }
From here now, i call ocsd_dt_process_data() to fully decode the trace, just like the code in cs_etm_decoder__process_data_block() in "tools/perf/util/cs-etm-decoder/cs-etm-decoder.c:518". The problem is, the resetting of the decoder fails fatally in the "OCSD_DATA_RESP_IS_FATAL" macro with the error: "OCSD_RESP_FATAL_NOT_INIT". Not sure what i did wrong, as i followed the exact code like in perf.
Any suggestions? Thank you!
Cheers, Mike.
On Thu, Mar 22, 2018 at 4:21 PM, Leo Yan leo.yan@linaro.org wrote:
On Thu, Mar 22, 2018 at 05:03:48PM +0800, Kim Phillips wrote:
On Thu, 22 Mar 2018 07:52:15 +0000 Mike Leach mike.leach@linaro.org wrote:
Hi, sorry, just jumping in with a couple of extra recommendations...
On 20 March 2018 at 15:34, Mike Bazov mike@perception-point.io wrote:
Thank you for your answers. I fixed the issue by applying the patches in the pull-request. I'm not
If this means you cherry-picked them without rebasing them onto a very late version of perf, then please do that, too. Preferably this one:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
because it's perf/core branch contains some recent fixes in the area.
+1. Before I encountered quite similiar issue with you [1]; after I used acme branch, then kernel symbol issue can be fixed.
[1] https://patchwork.kernel.org/patch/10115523/
Thanks, Leo Yan
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight
-- Mike Leach Principal Engineer, ARM Ltd. Blackburn Design Centre. UK