Debian Codegraph @

tapset/linux/logging.stp

raw
1 // logging tapset
2 // Copyright (C) 2005-2011 Red Hat Inc.
3 //
4 // This file is part of systemtap, and is free software. You can
5 // redistribute it and/or modify it under the terms of the GNU General
6 // Public License (GPL); either version 2, or (at your option) any
7 // later version.
8
9
10 /**
11 * sfunction ftrace - Send a message to the ftrace ring-buffer
12 *
13 * @msg: The formatted message string
14 *
15 * Description: If the ftrace ring-buffer is configured & available,
16 * see /debugfs/tracing/trace for the message. Otherwise, the
17 * message may be quietly dropped. An implicit end-of-line is added.
18 */
19 function ftrace (msg:string) %{ /* unmodified-fnargs */
20 #ifdef STAPCONF_TRACE_PRINTK
21 static char *fmt = "%s\n";
22 trace_printk (fmt, STAP_ARG_msg);
23
24 /* The "fmt" is designed to be non __builtin_constant_p(), so as
25 to defeat trace_printk -> __trace_bprintk optimization. That's
26 because bprintk doesn't save the incoming strings, only their
27 addresses. */
28 #else
29 #error "trace_printk not supported"
30 #endif
31 %}
32
33
34
35 /**
36 * sfunction printk - Send a message to the kernel trace buffer
37 *
38 * @level: an integer for the severity level (0=KERN_EMERG ... 7=KERN_DEBUG)
39 * @msg: The formatted message string
40 *
41 * Description: Print a line of text to the kernel dmesg/console with the
42 * given severity. An implicit end-of-line is added. This function may
43 * not be safely called from all kernel probe contexts, so is restricted
44 * to guru mode only.
45 */
46 function printk (level:long,msg:string) %{ /* guru */ /* unmodified-fnargs */
47 printk (STAP_ARG_level == 0 ? KERN_EMERG "%s\n":
48 STAP_ARG_level == 1 ? KERN_ALERT "%s\n":
49 STAP_ARG_level == 2 ? KERN_CRIT "%s\n":
50 STAP_ARG_level == 3 ? KERN_ERR "%s\n":
51 STAP_ARG_level == 4 ? KERN_WARNING "%s\n":
52 STAP_ARG_level == 5 ? KERN_NOTICE "%s\n":
53 STAP_ARG_level == 6 ? KERN_INFO "%s\n":
54 STAP_ARG_level == 7 ? KERN_DEBUG "%s\n":
55 #ifdef KERN_DEFAULT
56 KERN_DEFAULT "%s\n"
57 #else
58 KERN_INFO "%s\n"
59 #endif
60 , STAP_ARG_msg);
61 %}
62
63
64 /**
65 * sfunction dump_stack - Send the kernel backtrace to the kernel trace buffer
66 *
67 * Description: Print the current kernel backtrace to the kernel trace buffer.
68 This function may * not be safely called from all kernel probe contexts, so
69 * is restricted to guru mode only. Under the hood, it calls the kernel C API
70 * function dump_stack directly.
71 */
72 function dump_stack () %{ /* guru */
73 dump_stack();
74 %}