qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/9] contrib/plugins: uftrace
@ 2025-08-08 20:41 Pierrick Bouvier
  2025-08-08 20:41 ` [PATCH v6 1/9] contrib/plugins/uftrace: skeleton file Pierrick Bouvier
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Pierrick Bouvier @ 2025-08-08 20:41 UTC (permalink / raw)
  To: qemu-devel, pierrick.bouvier
  Cc: Manos Pitsidianakis, Peter Maydell, rowan Hart,
	Philippe Mathieu-Daudé, Gustavo Romero, Alex Bennée,
	Alexandre Iooss, Mahmoud Mandour, Richard Henderson

This plugin generates a binary trace compatible with the excellent uftrace:
https://github.com/namhyung/uftrace

In short, it tracks all function calls performed during execution, based on
frame pointer analysis. A big advantage over "uftrace record" is that it works
in system mode, allowing to trace a full system execution, which was the
original goal. It works as well in user mode, but uftrace itself already does
this. It's implemented for aarch64 and x86_64.

Let's start with concrete examples of the result.

First, in system mode, booting a stack using TF-A + U-boot + Linux:
- Two first stages of boot sequence in Arm Trusted Firmware (EL3 and S-EL1)
https://fileserver.linaro.org/s/kkxBS552W7nYESX/preview
- Stat and open syscalls in kernel
https://fileserver.linaro.org/s/dXe4MfraKg2F476/preview
- Poweroff sequence (from kernel back to firmware, NS-EL2 to EL3)
https://fileserver.linaro.org/s/oR2PtyGKJrqnfRf/preview

Full trace is available here:
https://fileserver.linaro.org/s/WsemLboPEzo24nw/download/aarch64_boot.json.gz
You can download and open it on https://ui.perfetto.dev/ to explore it.

Second, in user mode, tracing qemu-aarch64 (itself) running git --help:
- Loading program and its interpreter
https://fileserver.linaro.org/s/fie8JgX76yyL5cq/preview
- TB creation
https://fileserver.linaro.org/s/GXY6NKMw5EeRCew/preview

Full trace is available here:
https://fileserver.linaro.org/s/N8X8fnZ5yGRZLsT/download/qemu_aarch64_git_help.json.gz

If you had curiosity and now you're ready to give some attention, most of the
details you want to read are included in the documentation patch (final one).

Overhead is around x5-x15, and long traces can be directly filtered with uftrace
if needed.

I hope this plugin can help people trying to understand what happens out of the
user space, and get a better grasp of how firmwares, bootloader, and kernel
interact behind the curtain.

v6
--

- fix types and spelling mistakes
- use _MAX for privilege level enums
- uftrace info file: use empty strings
- trace flush: assert we wrote all data
- doc: added style for keyboard keys
- added URL to document uftrace entry format
- updated comment in vcpu_tb_trans to explain why we always instrument the first
  instruction in tb

v5
--

- addressed Alex comments
- split plugin implementation in several commits
- removed instruction based timestamps (only use time based timestamps)
- removed sampling implementation

v4
--

- add support for x64

v3
--

- fix missing include unistd.h (build failed on MacOS only)

v2
--

- trace active stacks on exit
- do not erase map generated in system_emulation
- add documentation to generate restricted visual traces around specific events
  of execution

Pierrick Bouvier (9):
  contrib/plugins/uftrace: skeleton file
  contrib/plugins/uftrace: define cpu operations and implement aarch64
  contrib/plugins/uftrace: track callstack
  contrib/plugins/uftrace: implement tracing
  contrib/plugins/uftrace: implement privilege level tracing
  contrib/plugins/uftrace: generate additional files for uftrace
  contrib/plugins/uftrace: implement x64 support
  contrib/plugins/uftrace_symbols.py
  contrib/plugins/uftrace: add documentation

 docs/about/emulation.rst           | 199 +++++++
 contrib/plugins/uftrace.c          | 876 +++++++++++++++++++++++++++++
 contrib/plugins/meson.build        |   3 +-
 contrib/plugins/uftrace_symbols.py | 152 +++++
 4 files changed, 1229 insertions(+), 1 deletion(-)
 create mode 100644 contrib/plugins/uftrace.c
 create mode 100755 contrib/plugins/uftrace_symbols.py

-- 
2.47.2



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-09-02  7:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 20:41 [PATCH v6 0/9] contrib/plugins: uftrace Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 1/9] contrib/plugins/uftrace: skeleton file Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 2/9] contrib/plugins/uftrace: define cpu operations and implement aarch64 Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 3/9] contrib/plugins/uftrace: track callstack Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 4/9] contrib/plugins/uftrace: implement tracing Pierrick Bouvier
2025-08-08 21:45   ` Philippe Mathieu-Daudé
2025-08-08 22:05     ` Pierrick Bouvier
2025-08-09 11:58       ` Philippe Mathieu-Daudé
2025-08-08 20:41 ` [PATCH v6 5/9] contrib/plugins/uftrace: implement privilege level tracing Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 6/9] contrib/plugins/uftrace: generate additional files for uftrace Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 7/9] contrib/plugins/uftrace: implement x64 support Pierrick Bouvier
2025-08-08 20:41 ` [PATCH v6 8/9] contrib/plugins/uftrace_symbols.py Pierrick Bouvier
2025-08-08 21:33   ` Philippe Mathieu-Daudé
2025-08-08 20:41 ` [PATCH v6 9/9] contrib/plugins/uftrace: add documentation Pierrick Bouvier
2025-08-08 20:46 ` [PATCH v6 0/9] contrib/plugins: uftrace Pierrick Bouvier
2025-08-22 14:32 ` Pierrick Bouvier
2025-09-01 17:07   ` Alex Bennée
2025-09-02  7:57     ` Pierrick Bouvier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).