Hi,
Thank you for your detailed answers Mike! i appreciate it!
1) I have surfed the c_api_pkt_print_test.c, and went on from process_trace_data(). The only thing that was missing as far as i understood from my previous message in the steps for creating a decoder, is registering a bin file at a certain linear address. I did not add all of the executed libraries bin files, i assumed this will make me get only executed instructions in the given bin file. I extracted the text section from my elf file(which is loaded at a certain virtual address), and added this:
/* add binfile containing opcodes */
ocsd_err = ocsd_dt_add_binfile_mem_acc(decoder_tree, 0x400280,
OCSD_MEM_SPACE_ANY, "./check.bin");
/* add mem access callback*/ ocsd_err = ocsd_dt_add_callback_mem_acc(decoder_tree, 0,
(uint64_t) -1,
OCSD_MEM_SPACE_ANY, decoder_mem_callback, NULL);
/* add packet callback */
ocsd_err = ocsd_dt_attach_packet_callback(decoder_tree, csid,
OCSD_C_API_CB_PKT_MON,
packet_monitor, NULL);
Now, i get no error when decoding the trace, but my callback for processed elements is never called, and my packet callback is only called once with "op=OCSD_OP_RESET". I should get a element callback with element type = "OCSD_GEN_TRC_ELEM_INSTR_RANGE", this didn't happen. I dived into the trace packets using this tool: https://github.com/hwang cc23/ptm2human and honestly the packets look valid(i sometimes get "ADDRESSS" packets that claim they ran on 32bit.. even though the CPU is 64bit[ARMv8], and the ELF is 64bit, i don't think it's the issue) I can see the "ADDRESS" packets with expected executed addresses though.
2) To be sure the lack of elements isn't because i didn't add all the binfiles, i tried to make my perf recording as minimal as possible, and tried to filter userspace addresses only, and more specifcally, addresses that belong to my program only, but this fails with the following error:
sudo ./perf record -e cs_etm/@826000.etr/u --filter 'filter
0x4002b4/0x48' --per-thread ./check
* failed to set filter "filter 0x4002b4/0x48" on event cs_etm/@826000.etr/u with 22 (Invalid argument)"*
*kernel address filtering do work though:*
sudo ./perf record -e cs_etm/@826000.etr/k --filter 'filter
0xffffff8008562d0c/0x48' --per-thread ./check
* Sleep[ perf record: Woken up 1 times to write data ]* * [ perf record: Captured and wrote 0.006 MB perf.data ]*
Any thoughts on my questions? Thank you!