1PMCPP(1)                    General Commands Manual                   PMCPP(1)
2
3
4

NAME

6       pmcpp - simple preprocessor for the Performance Co-Pilot
7

SYNOPSIS

9       pmcpp [-Prs] [-D name[=value] ...]  [-I dir ...]  [infile]
10

DESCRIPTION

12       pmcpp  provides  a  very  simple  pre-processor originally designed for
13       manipulating Performance Metric Name Space (PMNS) files for the Perfor‐
14       mance  Co-Pilot  (PCP),  but  later  generalized to provide conditional
15       blocks, include file processing, in-line shell  command  execution  and
16       macro  substitution  for  arbitrary  files.   It  is most commonly used
17       internally to process the  PMNS  file(s)  after  pmLoadNameSpace(3)  or
18       pmLoadASCIINameSpace(3)  is called and to pre-process the configuration
19       files for pmlogger(1).
20
21       Input lines are read from infile (or standard input if  infile  is  not
22       specified), processed and written to standard output.
23
24       All  C-style comments of the form /* ... */ are stripped from the input
25       stream.
26
27       There are no predefined macros for pmcpp although macros may be defined
28       on the command line using the -D option, where name and value must fol‐
29       low the same rules as described below for the #define directive.
30
31       pmcpp accepts the  following  directives  in  the  input  stream  (like
32       cpp(1)):
33
34       ·  #include "filename"
35          or
36          #include <filename>
37          In either case the directory search path for filename tries filename
38          first, then the directory for the command line infile (if any), fol‐
39          lowed  by  any  directories  named in -I command line arguments, and
40          finally the $PCP_VAR_DIR/pmns directory (the latter is for backwards
41          compatibility  with  earlier  versions of pmcpp and the implied used
42          from pmLoadASCIINameSpace(3)).  #include directives may  be  nested,
43          up to a maximum depth of 5.
44
45       ·  #shell "command"
46          or
47          #shell 'command'
48          The  shell  command  will  be  executed  and  the standard output is
49          inserted into the stream of data to be processed  by  pmcpp.   Func‐
50          tionally this is similar to a #include directive, except input lines
51          are read from a command rather than a file.  The #shell directive is
52          most  useful for including or excluding #define or #undef directives
53          based on run-time logic in the command.
54
55       ·  #define name value
56          or
57          #define name "value"
58          or
59          #define name 'value'
60          Defines a value for the macro name which must  be  a  valid  C-style
61          name,  so  leading alphabetic or underscore followed by zero or more
62          alphanumerics or underscores.  value is optional (and defaults to an
63          empty  string).   There is no character escape mechanism, but either
64          single quotes or double quotes may be used to define  a  value  with
65          special characters or embedded horizontal white space (no newlines).
66
67       ·  #undef name
68          Removes the macro definition, if any, for name.
69
70       ·  #ifdef name
71          ...
72          #endif
73          or
74          #ifndef name
75          ...
76          #endif
77          The  enclosing  lines will be stripped or included, depending if the
78          macro name is defined or not.
79
80       ·  #else
81          Within a #ifdef or #ifndef block, #else may be used to delimit lines
82          to be included if the preceding ``if'' condition is false.
83
84       Macro  substitution is achieved by breaking the input stream into words
85       separated by white space or characters that are not valid  in  a  macro
86       name,  i.e.  not alphanumeric and not underscore.  Each word is checked
87       and if it matches a macro name, the  word  is  replaced  by  the  macro
88       value, otherwise the word is unchanged.
89
90       There  is  generally  one output line for each input line, although the
91       line may be empty if the text has been stripped due to the handling  of
92       comments  or  conditional  directives.   When  there is a change in the
93       input stream, an additional output line is generated of the form:
94
95                 # lineno "filename"
96
97       to indicate the following line of output  corresponds  to  line  number
98       lineno of the input file filename.
99
100       The -P argument suppresses the generation of these linemarker lines.
101
102       The  -s argument changes the expected input style from C-like to shell-
103       like (where # is a comment prefix).  This forces the following  changes
104       in pmcpp behaviour:
105       ·  The  control  prefix  character changes from # to %, so %include for
106          example.
107       ·  No comment stripping is performed.
108
109       To provide finer control of macro expansion, the  -r  option  restricts
110       macro substitution to words that match the patterns #name or #{name} or
111       if -s is specified, then %name or %{name}.  In  this  mode,  the  macro
112       name  alone in the input stream will never be expanded, however in con‐
113       trol lines (like #ifdef) the macro name should appear  alone  with  out
114       the prefix character or the curly braces (refer to the EXAMPLES below).
115
116       Important cpp(1) features that are not supported by pmcpp include:
117       ·  Macros with parameters - the pmcpp macros support only parameterless
118          string substitution.
119       ·  #if expr
120          ...
121          #endif
122       ·  Nested use of #ifdef or #ifndef.
123       ·  Stripping C++ style comments, as in // comment.
124       ·  Error recovery - the first error encountered by pmcpp will be fatal.
125       ·  cpp(1) command line options like -o, -W, -U, and -x.
126

EXAMPLES

128       ┌─────────────────────────────────────────────┐
129       │Command: pmcpp                               
130       ├───────────────────────┬─────────────────────┤
131Input                  Output              
132       ├───────────────────────┼─────────────────────┤
133       │                       │ # 1 "<stdin>"       │
134       │#define MYDOMAIN 27    │                     │
135       │                       │                     │
136       │root {                 │ root {              │
137       │    foo   MYDOMAIN:0:0 │    foo   27:0:0     │
138       │}                      │ }                   │
139       └───────────────────────┴─────────────────────┘
140       For the following examples, the file frequencies contains the lines:
141               %define dk_freq 1minute
142               %define cpu_freq '15 sec'
143
144       ┌──────────────────────────────────────────────────────────────────────┐
145       │Command: pmcpp -rs                                                    
146       ├──────────────────────────────────┬───────────────────────────────────┤
147Input                             Output                            
148       ├──────────────────────────────────┼───────────────────────────────────┤
149       │# get logging frequencies         │ # get logging frequencies         │
150       │# e.g. dk_freq macro              │ # e.g. dk_freq macro              │
151       │%include "frequencies"            │                                   │
152       │                                  │                                   │
153       │log mandatory on %dk_freq {       │ log mandatory on 1minute {        │
154       │    disk.dev                      │    disk.dev                       │
155       │}                                 │ }                                 │
156       │                                  │                                   │
157       │# note no % for want_cpu here     │ # note no % for want_cpu here     │
158       │%ifdef want_cpu                   │                                   │
159       │%define cpu_pfx 'kernel.all.cpu.' │                                   │
160       │log mandatory on %cpu_freq {      │                                   │
161       │    %{cpu_pfx}user                │                                   │
162       │    %{cpu_pfx}sys                 │                                   │
163       │}                                 │                                   │
164       │%endif                            │                                   │
165       └──────────────────────────────────┴───────────────────────────────────┘
166       ┌──────────────────────────────────────────────────────────────────────┐
167       │Command: pmcpp -rs -Dwant_cpu                                         
168       ├──────────────────────────────────┬───────────────────────────────────┤
169Input                             Output                            
170       ├──────────────────────────────────┼───────────────────────────────────┤
171       │# get logging frequencies         │ # get logging frequencies         │
172       │# e.g. dk_freq macro              │ # e.g. dk_freq macro              │
173       │%include "frequencies"            │                                   │
174       │                                  │                                   │
175       │log mandatory on %dk_freq {       │ log mandatory on 1minute {        │
176       │    disk.dev                      │    disk.dev                       │
177       │}                                 │ }                                 │
178       │                                  │                                   │
179       │# note no % for want_cpu here     │ # note no % for want_cpu here     │
180       │%ifdef want_cpu                   │                                   │
181       │%define cpu_pfx 'kernel.all.cpu.' │                                   │
182       │log mandatory on %cpu_freq {      │ log mandatory on 15 sec {         │
183       │    %{cpu_pfx}user                │    kernel.all.cpu.user            │
184       │    %{cpu_pfx}sys                 │    kernel.all.cpu.sys             │
185       │}                                 │ }                                 │
186       │%endif                            │                                   │
187       └──────────────────────────────────┴───────────────────────────────────┘

PCP ENVIRONMENT

189       Environment variables with the prefix PCP_ are used to parameterize the
190       file  and  directory names used by PCP.  On each installation, the file
191       /etc/pcp.conf contains the  local  values  for  these  variables.   The
192       $PCP_CONF  variable may be used to specify an alternative configuration
193       file, as described in pcp.conf(5).
194

SEE ALSO

196       cpp(1),    pmLoadASCIINameSpace(3),    pmLoadNameSpace(3),     pmns(5),
197       pcp.conf(5) and pcp.env(5).
198
199
200
201Performance Co-Pilot                                                  PMCPP(1)
Impressum