From: Mathieu Desnoyers Date: Fri, 23 Oct 2015 23:29:34 +0000 (-0400) Subject: Instrument x86 page faults X-Git-Tag: v2.8.0-rc1~61 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=da0f6c58f715087f5091551070bf4350bf2768bf;p=lttng-modules.git Instrument x86 page faults Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/events/lttng-module/arch/x86/exceptions.h b/instrumentation/events/lttng-module/arch/x86/exceptions.h new file mode 100644 index 00000000..222841e3 --- /dev/null +++ b/instrumentation/events/lttng-module/arch/x86/exceptions.h @@ -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 + +#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" diff --git a/probes/Makefile b/probes/Makefile index 9fbae81f..8a068c16 100644 --- a/probes/Makefile +++ b/probes/Makefile @@ -49,10 +49,17 @@ endif endif ifneq ($(CONFIG_X86),) + x86_irq_vectors_dep = $(srctree)/arch/x86/include/asm/trace/irq_vectors.h ifneq ($(wildcard $(x86_irq_vectors_dep)),) obj-m += lttng-probe-x86-irq-vectors.o endif + +x86_exceptions_dep = $(srctree)/arch/x86/include/asm/trace/exceptions.h +ifneq ($(wildcard $(x86_exceptions_dep)),) +obj-m += lttng-probe-x86-exceptions.o +endif + endif obj-m += $(shell \ diff --git a/probes/lttng-probe-x86-exceptions.c b/probes/lttng-probe-x86-exceptions.c new file mode 100644 index 00000000..a8c9bf32 --- /dev/null +++ b/probes/lttng-probe-x86-exceptions.c @@ -0,0 +1,52 @@ +/* + * probes/lttng-probe-x86-exceptions.c + * + * LTTng x86 exceptions probes. + * + * Copyright (C) 2010-2015 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "../lttng-tracer.h" + +/* + * Create the tracepoint static inlines from the kernel to validate that our + * trace event macros match the kernel we run on. + */ +#include + +#include "../wrapper/tracepoint.h" + +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE + +/* + * Create LTTng tracepoint probes. + */ +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86 + +#include "../instrumentation/events/lttng-module/arch/x86/exceptions.h" + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers "); +MODULE_DESCRIPTION("LTTng x86 exceptions probes"); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) + LTTNG_MODULES_EXTRAVERSION);