[kernel] Add RAII profiler object

Added profiler.h which defines classes and macros for defining profiler
objects. Also added gdb command j6prof for printing profile data. Added
the syscall_profiles profiler class and auto wrapping of syscalls with
profile objects.

Other changes in this commit:

- Made the gdb command `j6threads` argument for specifying a CPU
  optional. Without an argument, it loops through all CPUs.
- Switched to -mcmodel=kernel for kernel code, which makes `call`
  instructions easier to follow when debugging / looking at disassembly.
This commit is contained in:
Justin C. Miller
2022-02-26 13:19:21 -08:00
parent a9f40cf608
commit a03804b09d
4 changed files with 112 additions and 12 deletions

View File

@@ -7,6 +7,7 @@
#include <j6/types.h>
#include <util/counted.h>
#include "profiler.h"
#include "syscalls/helpers.h"
/*[[[cog code generation
@@ -21,6 +22,12 @@ for obj in syscalls.exposes:
]]]*/
//[[[end]]]
/*[[[cog code generation
cog.outl(f'constexpr size_t syscall_count = {len(syscalls.methods)};')
]]]*/
//[[[end]]]
DECLARE_PROFILE_CLASS(syscall_profiles, syscall_count);
namespace {
enum class req { required, optional, zero_ok };
@@ -61,6 +68,8 @@ namespace {
}
}
DEFINE_PROFILE_CLASS(syscall_profiles);
namespace syscalls {
using util::buffer;
@@ -185,6 +194,7 @@ for id, scope, method in syscalls.methods:
if "noreturn" in method.options:
cog.outl(f""" {name}({", ".join(args)});""")
else:
cog.outl(f""" profiler<syscall_profiles, {id}> profile {{"{name}"}};""")
cog.outl(f""" return {name}({", ".join(args)});""")
cog.outl("}")
cog.outl("\n")