Skip to content

bap-tracing: add M68K trace support - #48

Draft
b1llow wants to merge 4 commits into
BinaryAnalysisPlatform:trace-10.0from
b1llow:m68k-tracing-machine
Draft

bap-tracing: add M68K trace support#48
b1llow wants to merge 4 commits into
BinaryAnalysisPlatform:trace-10.0from
b1llow:m68k-tracing-machine

Conversation

@b1llow

@b1llow b1llow commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Add systematic M68K system-emulation support to the BAP tracing plugin.

  • Map every QEMU M68K CPU model to a BAP machine profile and require the machine plugin argument for M68K.
  • Keep the M68K architectural state observable at instruction boundaries, including condition flags, the PC, and FPIAR.
  • Capture memory-access values with the width and byte order expected by BAP frames.
  • Add tests for machine selection and memory-value conversion.

Atomic compare-exchange tracing

M68K is big-endian and normally runs on a little-endian host, so it uses the reverse-host-endian atomic helpers. Upstream QEMU currently passes the raw host-order cmpxchg return value to plugin callbacks and always reports newv as the write value, including when the comparison fails.

This PR converts the returned value to guest byte order and reports the actual post-operation value: newv after a successful comparison, or the unchanged old value after a failed comparison. This correction is not yet present in upstream QEMU master and is required for accurate M68K memory traces.

Validation

  • Full GitHub Actions build
  • tcg/libtcg_user.a and libbap_tracing.so builds
  • bap-tracing-machine
  • bap-tracing-mem-value

@Rot127 Rot127 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for fixing the many bugs I added there.

@moste00 Please take a look as well.

Comment thread contrib/plugins/bap-tracing/mem_value.c Outdated
Comment thread contrib/plugins/bap-tracing/tracing.c Outdated
@b1llow
b1llow force-pushed the m68k-tracing-machine branch from 18d8634 to 04a7779 Compare August 23, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants