Instrument x86 page faults
[lttng-modules.git] / instrumentation / events / lttng-module / arch / x86 / exceptions.h
diff --git a/instrumentation/events/lttng-module/arch/x86/exceptions.h b/instrumentation/events/lttng-module/arch/x86/exceptions.h
new file mode 100644 (file)
index 0000000..222841e
--- /dev/null
@@ -0,0 +1,52 @@
+#if !defined(LTTNG_TRACE_EXCEPTIONS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define LTTNG_TRACE_EXCEPTIONS_H
+
+#include "../../../../../probes/lttng-tracepoint-event.h"
+#include <linux/version.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM x86_exceptions
+
+LTTNG_TRACEPOINT_EVENT_CLASS(x86_exceptions_class,
+
+       TP_PROTO(unsigned long address, struct pt_regs *regs,
+               unsigned long error_code),
+
+       TP_ARGS(address, regs, error_code),
+
+       TP_FIELDS(
+               ctf_integer_hex(unsigned long, address, address)
+               ctf_integer_hex(unsigned long, ip, regs->ip)
+               /*
+                * Note: we cast error_code from unsigned long
+                * to unsigned char to save space in the trace.
+                * Currently, only 5 low bits are used. Should be made
+                * larger if error codes are added to the kernel.
+                */
+               ctf_integer_hex(unsigned char, error_code, error_code)
+       )
+)
+
+#define LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(name, map)      \
+LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(x86_exceptions_class,              \
+       name,                                                           \
+       map,                                                            \
+       TP_PROTO(unsigned long address, struct pt_regs *regs,           \
+               unsigned long error_code),                              \
+       TP_ARGS(address, regs, error_code)                              \
+)
+
+LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_user,
+               x86_exceptions_page_fault_user)
+LTTNG_EXCEPTIONS_TRACEPOINT_EVENT_INSTANCE_MAP(page_fault_kernel,
+               x86_exceptions_page_fault_kernel)
+
+#endif /* LTTNG_TRACE_EXCEPTIONS_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE exceptions
+
+/* This part must be outside protection */
+#include "../../../../../probes/define_trace.h"
This page took 0.023492 seconds and 4 git commands to generate.