Page MenuHomeFreeBSD

hwt(8) utility added
Needs ReviewPublic

Authored by br on Jun 23 2023, 6:56 PM.
Tags
None
Referenced Files
F101981188: D40728.diff
Wed, Nov 6, 3:22 AM
Unknown Object (File)
Wed, Oct 30, 5:02 PM
Unknown Object (File)
Mon, Oct 28, 7:38 AM
Unknown Object (File)
Mon, Oct 28, 7:38 AM
Unknown Object (File)
Mon, Oct 28, 7:38 AM
Unknown Object (File)
Mon, Oct 28, 7:38 AM
Unknown Object (File)
Tue, Oct 22, 8:53 PM
Unknown Object (File)
Mon, Oct 14, 8:20 AM

Details

Summary

This instrumentation tool is a part of hwt(4) framework. It controls tracing units.

hwt(8) tool takes a path to an executable as an argument, creates kernel tracing context, then runs the application with tracing unit enabled.
Once some traces collected, hwt(8) decodes data using OpenCSD framework (on arm64) and prints the trace results in human readable format to standard output.

Test Plan

Tested with ARM Coresight on ARM Morello board.

Example usage, thread mode.

  1. In this scenario we will be tracing all the threads of "test" executable, but decode only thread 0.
sudo ./hwt -t 0 ./test/test
  1. In this scenario we will be tracing main() fuction of test executable only.
sudo ./hwt -t 0 ./test/test -i test -f main
  1. In this scenario we will be tracing strlen() function of test executable only.
sudo ./hwt -t 0 ./test/test -i libc.so.7 -f strlen

CPU mode. In this scenario tracing context collects information for CPUs number 1 and 3 */

sudo ./hwt -s 3,1 -i kernel -f cpu_switch

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

br requested review of this revision.Jun 23 2023, 6:56 PM
br added a parent revision: D40477: HWT: ARM CoreSight support.
br edited the test plan for this revision. (Show Details)

Add '-t' argument allowing to specify thread index we want to read trace for.

ip range filtering added

suspend a single thread on mmap, not entire proc

Abstract tracing devices

br edited the summary of this revision. (Show Details)
br edited the test plan for this revision. (Show Details)

Add kernel-mode tracing support.

allow tracing multiple cpus in system mode

decode multiple cpus at the same time

br edited the summary of this revision. (Show Details)

cleanup

Allow attaching to an existed proc;
Add support for libxo

obtain ETM IDR registers from sysctl. This is needed for Juno

usr.sbin/hwt/hwt.c
59 ↗(On Diff #126228)

What's hwt_libxo.h?

remove hwt_libxo.h as not needed

usr.sbin/hwt/hwt.c
59 ↗(On Diff #126228)

That is not needed (Leftovers from libxo integration)

usr.sbin/hwt/Makefile
1 ↗(On Diff #127773)

#FreeBSD$

usr.sbin/hwt/hwt.c
171 ↗(On Diff #127773)

This needs to be updated after making cpu_map a pointer.

202 ↗(On Diff #127773)

Debug printf? And %#p isn't valid outsize of CheriBSD.

Intel PT support added by Bojan Novković

Regenerate for Intel PT