Re: [PATCH v2 38/49] perf python: Port arm-cs-trace-disasm to perf module
From: Leo Yan
Date: Thu Sep 24 2026 - 12:06:04 EST
On Wed, Sep 23, 2026 at 06:40:57AM -0700, Ian Rogers wrote:
[...]
> > > @@ -44,8 +56,8 @@ branch_search='[[:space:]](bl|b(\.(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al)
> > > if [ "$(id -u)" == 0 ] && [ -e /proc/kcore ]; then
> > > echo "Testing kernel disassembly"
> > > perf record -o ${perfdata} -e cs_etm//k --kcore -Se -m,64K -- touch $file > /dev/null 2>&1
> > > - perf script -i ${perfdata} --itrace=b -s python:${script_path} -- \
> > > - -d --stop-sample=2 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file}
> > > + $PYTHON ${script_path} -i ${perfdata} --itrace=b -d --stop-sample=2 \
> > > + -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file}
> > > grep -q -E ${branch_search} ${file}
> > > echo "Found kernel branches"
> > > else
> > > @@ -56,8 +68,8 @@ fi
> > > ## Test user ##
> > > echo "Testing userspace disassembly"
> > > perf record -o ${perfdata} -e cs_etm//u -Se -m,64K -- touch $file > /dev/null 2>&1
> > > -perf script -i ${perfdata} --itrace=b -s python:${script_path} -- \
> > > - -d --stop-sample=2 2> /dev/null > ${file}
> > > +perf inject --itrace=b -i ${perfdata} -o ${perfdata2}
> > > +$PYTHON ${script_path} -i ${perfdata2} -d --stop-sample=2 2> /dev/null > ${file}
> >
> > The perf script command is replaced with perf inject and a Python
> > command. I learned from the above that we can pass the itrace option to
> > the Python script.
> >
> > This is fine with me. I'm just curious why we don't use a single Python
> > command here.
>
> A single Python command that would handle both the itrace and file
> processing? We could. Having the script command also perform an
> inject-like rewrite of the data seemed less obvious to me than just
> having perf inject do the work and then running the script. It does
> mean a change for people using the script, and two commands could be
> less convenient than one. We could expand the Python module "session"
> code to include the ability to rewrite itrace data specifically for
> this script. I'm hoping that we can have more composable perf_tools in
> the code, similar to the ASLR code.
> It would be nice to add itrace support to the Python code with
> composing tools in mind. I was just putting off worrying about this
> for now.
Sorry for the confusion. I should have made this clearer in my previous
reply.
I was referring to this change:
+ $PYTHON ${script_path} -i ${perfdata} --itrace=b -d --stop-sample=2 \
+ -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file}
If itrace processing is not currently supported by the Python code,
wouldn't adding --itrace=b here break the test?
Thanks,
Leo