Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: mtrace-reader.py: Add option to mark chunk starts in output #9520

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tools/mtrace/mtrace-reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@
import struct
import os
import sys
import argparse

READ_BUFFER = 16384
MTRACE_FILE = "/sys/kernel/debug/sof/mtrace/core0"

parser = argparse.ArgumentParser()
parser.add_argument('-m', '--mark-chunks',
action='store_true')

args = parser.parse_args()

chunk_idx = 0

fd = os.open(MTRACE_FILE, os.O_RDONLY)
while fd >= 0:
# direct unbuffered os.read() must be used to comply with
Expand All @@ -35,4 +44,10 @@
data_len = header[0]
data = read_bytes[4:4+data_len]

os.write(sys.stdout.fileno(), data)
if (args.mark_chunks):
chunk_msg = "\n--- Chunk #{} start (size: {}) ---\n" .format(chunk_idx, data_len)
sys.stdout.write(chunk_msg)

sys.stdout.buffer.write(data)
sys.stdout.flush()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi Paused for a moment on this. Not sure if this disables the buffering compared to old version, but I guess the flush is needed in practise here as the buffer.write() is used. Let's merge this version and return if this causes problems.

chunk_idx += 1
Loading