]>
Commit | Line | Data |
---|---|---|
d48df0cf | 1 | // probe-name tapset |
ef36f781 | 2 | // Copyright (C) 2010, 2014 Red Hat Inc. |
d48df0cf JS |
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. | |
dc575eac MW |
8 | %{ |
9 | #ifndef STP_NEED_PROBE_NAME | |
10 | #define STP_NEED_PROBE_NAME 1 | |
11 | #endif | |
12 | %} | |
d48df0cf JS |
13 | |
14 | /** | |
86518ac5 | 15 | * sfunction pn - Returns the active probe name |
d48df0cf JS |
16 | * |
17 | * Description: This function returns the script-level probe point | |
18 | * associated with a currently running probe handler, including | |
19 | * wild-card expansion effects. Context: The current probe point. | |
20 | */ | |
21 | function pn:string () | |
22 | %{ /* pure */ /* unprivileged */ | |
d48df0cf | 23 | const char* name = CONTEXT->probe_name ?: CONTEXT->probe_point; |
b7b482fb | 24 | strlcpy (STAP_RETVALUE, name, MAXSTRINGLEN); |
d48df0cf | 25 | %} |
887d4fe1 JL |
26 | |
27 | /** | |
2aee1644 | 28 | * sfunction pnlabel - Returns the label name parsed from the probe name |
887d4fe1 | 29 | * |
2aee1644 JL |
30 | * Description: This returns the label name as parsed from the |
31 | * script-level probe point. This function will only work if called | |
32 | * directly from the body of a '.label' probe point (i.e. no aliases). | |
33 | * Context: The current probe point. | |
887d4fe1 | 34 | */ |
2aee1644 | 35 | function pnlabel:string () |
887d4fe1 JL |
36 | %{ /* pure */ /* unprivileged */ |
37 | char *ptr, *start; | |
38 | ||
39 | if (!CONTEXT->probe_name) { | |
40 | STAP_RETURN(""); | |
41 | } | |
42 | ||
43 | /* This function is modelled after ppfunc() */ | |
44 | STAP_RETVALUE[0] = '\0'; | |
45 | start = strstr(CONTEXT->probe_name, "label(\""); /* XXX: could be smarter */ | |
46 | ptr = start + 7; | |
47 | ||
48 | if (start) { | |
49 | int len = MAXSTRINGLEN; | |
50 | char *dst = STAP_RETVALUE; | |
51 | while (*ptr != '"' && --len > 0 && *ptr) | |
52 | *dst++ = *ptr++; | |
53 | *dst = 0; | |
54 | } | |
55 | %} |