| 1 |
// logging tapset -- BPF version |
| 2 |
// Copyright (C) 2005-2021 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 |
function log (msg:string) { /* unprivileged */ /* bpf */ |
| 10 |
printf("%s\n", msg) |
| 11 |
} |
| 12 |
|
| 13 |
function warn (msg:string) { /* unprivileged */ /* bpf */ |
| 14 |
// TODO: _stp_warn intelligently determines whether msg has a newline |
| 15 |
printf("WARNING: %s\n", msg) |
| 16 |
} |
| 17 |
|
| 18 |
function exit () { /* unprivileged */ /* bpf */ |
| 19 |
_set_exit_status() |
| 20 |
_send_exit_msg() |
| 21 |
} |
| 22 |
|
| 23 |
%(systemtap_v >= "4.0" %? |
| 24 |
function abort () { /* unprivileged */ /* bpf */ |
| 25 |
// TODO PR27820: There may be a delay between setting exit status |
| 26 |
// and stapbpf.cxx disabling the probes. This could be solved |
| 27 |
// at the cost of setting a global var and adding a check to the |
| 28 |
// start of every probe. |
| 29 |
_set_exit_status() |
| 30 |
_send_exit_msg() |
| 31 |
_terminate() |
| 32 |
} |
| 33 |
%) |
| 34 |
|
| 35 |
function error (msg:string) { /* unprivileged */ /* bpf */ |
| 36 |
// If error is called within a try block, the instruction flow |
| 37 |
// will switch to the corresponding catch block. |
| 38 |
_jump_to_catch(msg) |
| 39 |
|
| 40 |
// Execution will reach here if error was called outside a try |
| 41 |
// block. In this case, the error message will be stored for |
| 42 |
// printing and the error status will be set. |
| 43 |
_register_error(msg) |
| 44 |
|
| 45 |
// Short-circuit the program to its exit. |
| 46 |
_terminate() |
| 47 |
} |