File: pmcpp.1

package info (click to toggle)
pcp 6.3.8-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 235,180 kB
  • sloc: ansic: 1,253,622; sh: 173,998; xml: 160,490; cpp: 83,331; python: 20,482; perl: 18,302; yacc: 6,886; makefile: 2,955; lex: 2,862; fortran: 60; java: 52
file content (405 lines) | stat: -rw-r--r-- 8,779 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
'\"! tbl | mmdoc
'\"macro stdmacro
.\"
.\" Copyright (c) 2011 Ken McDonell.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMCPP 1 "" "Performance Co-Pilot"
.SH NAME
\f3pmcpp\f1 \- simple preprocessor for the Performance Co-Pilot
.SH SYNOPSIS
.B pmcpp
[\f3\-Prs?\f1]
[\f3\-D\f1 \f2name\f1[=\f2value\f1] ...]
[\f3\-I\f1 \f2dir\f1 ...]
[[\f2infile\f1] [\f2outfile\f1]]
.SH DESCRIPTION
.B pmcpp
provides a very simple pre-processor originally designed for manipulating Performance
Metric Name Space (PMNS) files for the
Performance Co-Pilot (PCP), but later generalized to provide conditional
blocks, include file processing, in-line shell command execution
and macro substitution for arbitrary files.
It is most commonly used internally
to process the PMNS file(s) after
.BR pmLoadNameSpace (3)
or
.BR pmLoadASCIINameSpace (3)
is called and to pre-process the configuration files for
.BR pmlogger (1).
.PP
Input lines are read from
.I infile
(or standard input if
.I infile
is not specified), processed and written to
.I outfile
(standard output if
.I outfile
is not specified).
.PP
All C-style comments of the form /* ... */ are stripped from the
input stream.
.PP
There are no predefined macros for
.B pmcpp
although macros may be defined on the command line using the
.B \-D
option, where
.I name
and
.I value
must follow the same rules as described below for the
.B #define
directive.
.PP
.B pmcpp
accepts the following directives in the input stream (like
.BR cpp (1)):
.IP \(bu 3n
\fB#include "\fIfilename\fB"\fR
.br
or
.br
\fB#include <\fIfilename\fB>\fR
.br
In either case the directory search path for
.I filename
tries
.I filename
first, then the directory for the command line
.I infile
(if any),
followed by any directories named in
.B \-I
command line arguments, and finally the
.B $PCP_VAR_DIR/pmns
directory (the latter is for backwards compatibility with
earlier versions of
.B pmcpp
and the implied used from
.BR pmLoadASCIINameSpace (3)).
.B #include
directives may be nested, up to a maximum depth of 5.
.IP \(bu 3n
\fB#shell "\fIcommand\fB"\fR
.br
or
.br
\fB#shell '\fIcommand\fB'
.br
The shell
.I command
will be executed and the standard output is inserted into the
stream of data to be processed by
.BR pmcpp .
Functionally this is similar to a
.B #include
directive, except input lines are read from a
.I command
rather than a file.
The
.B #shell
directive is most useful for including or excluding
.B #define
or
.B #undef
directives based on run-time logic in the
.IR command .
.IP \(bu 3n
\fB#define \fIname value\fR
.br
or
.br
\fB#define \fIname \fB"\fIvalue\fB"\fR
.br
or
.br
\fB#define \fIname \fB'\fIvalue\fB'\fR
.br
Defines a value for the macro
.I name
which must be a valid C-style name, so leading alphabetic or underscore
followed by
zero or more alphanumerics or underscores.
.I value
is optional (and defaults to an empty string).
There is no character escape mechanism, but either single quotes or
double quotes may be used to define a
.I value
with special characters or embedded horizontal white space (no newlines).
.IP \(bu 3n
\fB#undef \fIname\fR
.br
Removes the macro definition, if any, for
.IR name .
.IP \(bu 3n
\fB#ifdef \fIname\fR
.br
\&...
.br
\fB#endif\fR
.br
or
.br
\fB#ifndef \fIname\fR
.br
\&...
.br
\fB#endif\fR
.br
The enclosing lines will be stripped or included, depending if the
macro
.I name
is defined or not.
.IP \(bu 3n
\fB#else\fR
.br
Within a
.B #ifdef
or
.B #ifndef
block,
.B #else
may be used to delimit lines to be included if the preceding ``if'' condition
is false.
.PP
Macro substitution is achieved by breaking the input stream into words
separated by white space or characters that are not valid in a macro
name, i.e. not alphanumeric and not underscore.
Each word is checked and if it matches a macro name, the word is
replaced by the macro value, otherwise the word is unchanged.
.PP
There is generally one output line for each input line, although the line
may be empty if the text has been stripped due to the handling of
comments or conditional directives.
When there is a change in the input
stream, an additional output line is generated of the form:
.PP
.ti +10n
# lineno "filename"
.PP
to indicate the
.I following
line of output corresponds to line number
.I lineno
of the input file
.IR filename .
.SH OPTIONS
The available command line options are:
.TP 5
\fB\-D\fR \fIname[=value]\fR, \fB\-\-define\fR=\fIname[=value]\fR
Defines a macro with an optional value, as described earlier.
.TP
\fB\-I\fR \fIdir\fR, \fB\-\-include\fR=\fIdir\fR
An additional directory to search for include files.
.TP
\fB\-P\fR
Suppresses the generation of the linemarker lines, described above.
.TP
\fB\-s\fR, \fB\-\-shell\fR
Changes the expected input style from C-like to shell-like
(where # is a comment prefix).
This forces the following changes in
.B pmcpp
behaviour:
.RS 5
.PD 0
.IP \(bu 3n
The control prefix character changes from
.B #
to
.BR % ,
so for example
.B %include
instead of
.BR #include ,
and
.B %ifdef
instead of
.BR #ifdef .
.IP \(bu 3n
No C-style comment stripping is performed.
.PD
.RE
.TP
\fB\-r\fR, \fB\-\-restrict\fR
Provide finer control of macro expansion \- this
option restricts macro substitution to words that match the patterns
.BR # name
or
.BR #{ name }
or if
.B \-s
is specified, then
.BR % name
or
.BR %{ name } .
In this mode, the macro
.I name
alone in the input stream will never be expanded, however in control
lines (like
.BR #ifdef )
the macro
.I name
should appear alone with out the prefix character or the
curly braces (refer to the EXAMPLES below).
.TP
\fB\-?\fR, \fB\-\-help\fR
Display usage message and exit.
.PP
Important
.BR cpp (1)
features that are
.B not
supported by
.B pmcpp
include:
.PD 0
.IP \(bu 3n
Macros with parameters \- the
.B pmcpp
macros support only parameterless string substitution.
.IP \(bu 3n
\fB#if \fIexpr\fR
.br
\&...
.br
\fB#endif\fR
.IP \(bu 3n
Nested use of
.B #ifdef
or
.BR #ifndef .
.IP \(bu 3n
Stripping C++ style comments, as in // comment.
.IP \(bu 3n
Error recovery - the first error encountered by
.B pmcpp
will be fatal.
.IP \(bu 3n
.BR cpp (1)
command line options like
.BR \-o ,
.BR \-W ,
.BR \-U ,
and
.BR \-x .
.PD
.SH EXAMPLES
.\" man.1.in from src dir
.TS
box;
lR s
lB | lB
lf(CR) | lf(CR).
Command: \fBpmcpp\fP
_
Input	Output
_
	# 1 "<stdin>"
#define MYDOMAIN 27

root {	root {
    foo   MYDOMAIN:0:0	   foo   27:0:0
}	}
.TE
.PP
For the following examples, the file
.I frequencies
contains the lines:
.nf
.ft CR
.in +8n
%define dk_freq 1minute
%define cpu_freq '15 sec'
.in
.ft
.fi
.PP
.\" man.2.in from src dir
.TS
box;
lR s
lB | lB
lf(CR) | lf(CR).
Command: \fBpmcpp -rs\fP
_
Input	Output
_
# get logging frequencies	# get logging frequencies
# e.g. dk_freq macro	# e.g. dk_freq macro
%include "frequencies"

log mandatory on %dk_freq {	log mandatory on 1minute {
    disk.dev	   disk.dev
}	}

# note no %want_cpu here	# note no %want_cpu here
%ifdef want_cpu
%define cpu_pfx 'kernel.all.cpu.'
log mandatory on %cpu_freq {
    %{cpu_pfx}user
    %{cpu_pfx}sys
}
%endif
.TE
.PP
.TS
box;
lR s
lB | lB
lf(CR) | lf(CR).
Command: \fBpmcpp -rs -D want_cpu\fP
_
Input	Output
_
# get logging frequencies	# get logging frequencies
# e.g. dk_freq macro	# e.g. dk_freq macro
%include "frequencies"

log mandatory on %dk_freq {	log mandatory on 1min {
    disk.dev	   disk.dev
}	}

# note no %want_cpu here	# note no %want_cpu here
%ifdef want_cpu
%define cpu_pfx 'kernel.all.cpu.'
log mandatory on %cpu_freq {	log mandatory on 15 sec {
    %{cpu_pfx}user	   kernel.all.cpu.user
    %{cpu_pfx}sys	   kernel.all.cpu.sys
}	}
%endif
.TE
.SH PCP ENVIRONMENT
Environment variables with the prefix \fBPCP_\fP are used to parameterize
the file and directory names used by PCP.
On each installation, the
file \fI/etc/pcp.conf\fP contains the local values for these variables.
The \fB$PCP_CONF\fP variable may be used to specify an alternative
configuration file, as described in \fBpcp.conf\fP(5).
.PP
For environment variables affecting PCP tools, see \fBpmGetOptions\fP(3).
.SH SEE ALSO
.BR cpp (1),
.BR pmLoadASCIINameSpace (3),
.BR pmLoadNameSpace (3),
.BR pcp.conf (5),
.BR pcp.env (5)
and
.BR PMNS (5).

.\" control lines for scripts/man-spell
.\" +ok+ MYDOMAIN cpu_freq cpu_pfx dk_freq infile linemarker
.\" +ok+ lineno pre sys want_cpu