nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.58k stars 133 forks source link

Klibs: add strace #2028

Closed francescolavra closed 2 months ago

francescolavra commented 3 months ago

This change adds a new "strace" klib which implements the main functionality of the Linux strace tool, i.e. can output records for each syscall invoked by the user program, and can calculate relevant statistics such as number of occurrences and execution time. Most of the thread_log() macro calls in the Unix code in the kernel are being removed because they are redundant with the corresponding strace output records; likewise, the code that implements collection and reporting of syscall statistics is being moved from the core syscall code to the strace klib. These changes, together with the removal of several related variables and struct fields, bring a reduction of the kernel binary size by 2.5%. The manifest options that are used to confgure syscall tracing and statistics collection (namely, debugsyscalls, notrace, tracelist, and syscall_summary) remain the same, but are now acted upon by the strace klib instead of the main kernel, thus they take effect only if the strace klib is included in an image. The trace manifest option is still handled in the main kernel code, but now it only controls tracing of kernel internals.

The first commit removes the futex_trace manifest option, which is now redundant because the strace klib provides equivalent functionality for tracing futex syscalls.