Skip to content

VM instrumentation for third-party tools #1457

@MikePall

Description

@MikePall

There are multiple third-party tools for instrumentation (profiling, debugging) of a running LuaJIT VM. Most of these have to rummage around in the VM internals, they only work with very specific LuaJIT versions and some even have to disassemble the code to gather some constants. This is an unfortunate state of affairs.

I'm willing to add some (near-) zero-overhead instrumentation to help these tools gather the required information.

This will be a low-level abstraction! The tool still needs to have some understanding of the VM internals: it needs to know how stack frames are linked, what constitutes a trace, and so on. Inevitably, this knowledge is still limited to a certain range of LuaJIT version. However, I'm aiming for some ABI-like guarantees that hold at least for a minor version, e.g. 2.1.*.

I'm aiming for cross-OS, cross-arch and cross-toolchain compatibility without adding a dependency on third-party instrumentation libraries:

The idea is to provide some exported symbols pointing to constants and arrays of tiny lookup functions. Machine code patch points (a nop) inside certain VM functions can be added, too, if desired.

This is a call for all tool authors to tell me:

  • What kind of static information do you need from a linked LuaJIT library?
  • What kind of runtime information do you need from a running LuaJIT VM instance?

Please give both the 'why' and the 'what', so we can make an informed decision on the best way to provide you with this information. E.g. 'We want to show VM trace details in a stack backtrace' + 'We need to map a machine code address to a trace number' + 'We need to get specific infos for a trace, given its number'.

Please specify the name of the tool, a link to your existing code and an exhaustive list of the whys and whats. Please also point out which alternative approaches would work for you in each case, e.g. constant field offset vs. lookup function.

I'll gather and organize everything in this issue, after a sufficient number of responses came in.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions