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 (47 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (3)
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
// logging tapset -- BPF version
// Copyright (C) 2005-2021 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.

function log (msg:string) { /* unprivileged */ /* bpf */
  printf("%s\n", msg)
}

function warn (msg:string) { /* unprivileged */ /* bpf */
  // TODO: _stp_warn intelligently determines whether msg has a newline
  printf("WARNING: %s\n", msg)
}

function exit () { /* unprivileged */ /* bpf */
  _set_exit_status()
  _send_exit_msg()
}

%(systemtap_v >= "4.0" %?
function abort () { /* unprivileged */ /* bpf */
  // TODO PR27820: There may be a delay between setting exit status
  // and stapbpf.cxx disabling the probes. This could be solved
  // at the cost of setting a global var and adding a check to the
  // start of every probe.
  _set_exit_status()
  _send_exit_msg()
  _terminate()
}
%)

function error (msg:string) { /* unprivileged */ /* bpf */
  // If error is called within a try block, the instruction flow
  // will switch to the corresponding catch block.
  _jump_to_catch(msg)   

  // Execution will reach here if error was called outside a try
  // block. In this case, the error message will be stored for
  // printing and the error status will be set.
  _register_error(msg)   

  // Short-circuit the program to its exit.
  _terminate()
}