File: logging.stp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (74 lines) | stat: -rw-r--r-- 2,585 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// logging tapset
// Copyright (C) 2005-2011 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.


/**
 * sfunction ftrace - Send a message to the ftrace ring-buffer
 *
 * @msg: The formatted message string
 *
 * Description: If the ftrace ring-buffer is configured & available,
 * see /debugfs/tracing/trace for the message.  Otherwise, the
 * message may be quietly dropped.  An implicit end-of-line is added.
 */
function ftrace (msg:string) %{ /* unmodified-fnargs */
#ifdef STAPCONF_TRACE_PRINTK
       static char *fmt = "%s\n";
       trace_printk (fmt, STAP_ARG_msg);

       /* The "fmt" is designed to be non __builtin_constant_p(), so as
       to defeat trace_printk -> __trace_bprintk optimization.  That's
       because bprintk doesn't save the incoming strings, only their
       addresses. */
#else
  #error "trace_printk not supported"
#endif
%}



/**
 * sfunction printk - Send a message to the kernel trace buffer
 *
 * @level: an integer for the severity level (0=KERN_EMERG ... 7=KERN_DEBUG)
 * @msg: The formatted message string
 *
 * Description: Print a line of text to the kernel dmesg/console with the
 * given severity.  An implicit end-of-line is added.  This function may 
 * not be safely called from all kernel probe contexts, so is restricted
 * to guru mode only.
 */
function printk (level:long,msg:string) %{ /* guru */ /* unmodified-fnargs */
         printk (STAP_ARG_level == 0 ? KERN_EMERG "%s\n":
                 STAP_ARG_level == 1 ? KERN_ALERT "%s\n":
                 STAP_ARG_level == 2 ? KERN_CRIT "%s\n":
                 STAP_ARG_level == 3 ? KERN_ERR "%s\n":
                 STAP_ARG_level == 4 ? KERN_WARNING "%s\n":
                 STAP_ARG_level == 5 ? KERN_NOTICE "%s\n":
                 STAP_ARG_level == 6 ? KERN_INFO "%s\n":
                 STAP_ARG_level == 7 ? KERN_DEBUG "%s\n":
#ifdef KERN_DEFAULT
                 KERN_DEFAULT "%s\n"
#else
                 KERN_INFO "%s\n"
#endif
                 , STAP_ARG_msg);
%}


/**
 * sfunction dump_stack - Send the kernel backtrace to the kernel trace buffer
 *
 * Description: Print the current kernel backtrace to the kernel trace buffer.
 This function may * not be safely called from all kernel probe contexts, so
 * is restricted to guru mode only. Under the hood, it calls the kernel C API
 * function dump_stack directly.
 */
function dump_stack () %{ /* guru */
	dump_stack();
%}