HPCToolkit
fmt.c
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //*****************************************************************************
48 // global includes
49 //*****************************************************************************
50 
51 #include <stdarg.h>
52 #include <stdbool.h>
53 #include <stdint.h>
54 #include <stdlib.h>
55 #include <stdio.h>
56 #include <string.h>
57 #include <limits.h>
58 #include <float.h>
59 #include <ctype.h>
60 #include <math.h>
61 
62 //*****************************************************************************
63 // local includes
64 //*****************************************************************************
65 
66 #include "fmt.h"
67 
68 //*****************************************************************************
69 // macros
70 //*****************************************************************************
71 
72 #define T Fmt_T
73 
74 #define pad(n,c) do { int nn = (n); \
75  while (nn-- > 0) \
76  put((c), cl); } while (0)
77 
78 //
79 // Useful constants for floating point manipulation
80 //
81 //
82 
83 //
84 // 308 decimal digits = max # of digits to left of decimal point (when not using scientific notation
85 //
86 //
87 #define MAXEXP 308
88 
89 //
90 // 128 bit fraction takes up 39 decimal digits; max reasonable precision
91 //
92 #define MAXFRACT 39
93 
94 //
95 // default precisions
96 //
97 #define DEFPREC 6
98 #define DEFLPREC 14
99 
100 // max digits to left + max digits to right + decimal point
101 #define FPBUF_LEN (MAXEXP+MAXFRACT+1)
102 
103 //***********************************
104 // structures and data types
105 //***********************************
106 
107 
108 struct buf {
109  char *buf;
110  char *bp;
111  int size;
112 };
113 
114 //***********************************
115 // local data
116 //***********************************
117 
118 static const char *Fmt_flags = "-+ 0";
119 
120 //***********************************
121 // private operations
122 //***********************************
123 
124 static void
125 cvt_s(int code, va_list_box *box,
126  int put(int c, void *cl), void *cl,
127  unsigned char flags[], int width, int precision)
128 {
129  char *str = va_arg(box->ap, char *);
130  if (str == NULL) { str = "(null)"; }
131 
132  hpcrun_msg_puts(str, strlen(str), put, cl, flags,
133  width, precision);
134 }
135 
136 static void
137 cvt_d(int code, va_list_box *box,
138  int put(int c, void *cl), void *cl,
139  unsigned char flags[], int width, int precision)
140 {
141  long val;
142 
143  if ( flags['l'] ) {
144  val = va_arg(box->ap, long);
145  }
146  else {
147  val = va_arg(box->ap, int);
148  }
149  unsigned long m;
150  char buf[86];
151 
152  char *p = buf + sizeof buf;
153  if (val == INT_MIN)
154  m = INT_MAX + 1U;
155  else if (val < 0)
156  m = -val;
157  else
158  m = val;
159  do
160  *--p = m%10 + '0';
161  while ((m /= 10) > 0);
162  if (val < 0)
163  *--p = '-';
164  hpcrun_msg_putd(p, (buf + sizeof buf) - p, put, cl, flags,
165  width, precision);
166 }
167 
168 static void
169 cvt_u(int code, va_list_box *box,
170  int put(int c, void *cl), void *cl,
171  unsigned char flags[], int width, int precision)
172 {
173  unsigned long m;
174 
175  if ( flags['l'] ) {
176  m = va_arg(box->ap, unsigned long);
177  }
178  else {
179  m = va_arg(box->ap, unsigned int);
180  }
181  char buf[143];
182  char *p = buf + sizeof buf;
183  do
184  *--p = m%10 + '0';
185  while ((m /= 10) > 0);
186  hpcrun_msg_putd(p, (buf + sizeof buf) - p, put, cl, flags,
187  width, precision);
188 }
189 
190 static void
191 cvt_o(int code, va_list_box *box,
192  int put(int c, void *cl), void *cl,
193  unsigned char flags[], int width, int precision)
194 {
195  unsigned long m;
196 
197  if ( flags['l'] ) {
198  m = va_arg(box->ap, unsigned long);
199  }
200  else {
201  m = va_arg(box->ap, unsigned int);
202  }
203  char buf[143];
204 
205  char *p = buf + sizeof buf;
206  do
207  *--p = (m&0x7) + '0';
208  while ((m>>= 3) != 0);
209  hpcrun_msg_putd(p, (buf + sizeof buf) - p, put, cl, flags,
210  width, precision);
211 }
212 
213 static void
214 cvt_x(int code, va_list_box *box,
215  int put(int c, void *cl), void *cl,
216  unsigned char flags[], int width, int precision)
217 {
218  unsigned long m;
219 
220  if ( flags['l'] ) {
221  m = va_arg(box->ap, unsigned long);
222  }
223  else {
224  m = va_arg(box->ap, unsigned int);
225  }
226  char buf[143];
227 
228  char *p = buf + sizeof buf;
229  do
230  *--p = "0123456789abcdef"[m&0xf];
231  while ((m>>= 4) != 0);
232  hpcrun_msg_putd(p, (buf + sizeof buf) - p, put, cl, flags,
233  width, precision);
234 }
235 
236 static void
237 cvt_p(int code, va_list_box *box,
238  int put(int c, void *cl), void *cl,
239  unsigned char flags[], int width, int precision)
240 {
241  uintptr_t m = (uintptr_t)va_arg(box->ap, void*);
242  char buf[43];
243  char* p = buf + sizeof buf;
244  precision = INT_MIN;
245  do
246  *--p = "0123456789abcdef"[m&0xf];
247  while ((m>>= 4) != 0);
248  put('0', cl);
249  put('x', cl);
250  hpcrun_msg_putd(p, (buf + sizeof buf) - p, put, cl, flags,
251  width, precision);
252 }
253 
254 static void
255 cvt_c(int code, va_list_box *box,
256  int put(int c, void *cl), void *cl,
257  unsigned char flags[], int width, int precision)
258 {
259  if (width == INT_MIN)
260  width = 0;
261  if (width < 0) {
262  flags['-'] = 1;
263  width = -width;
264  }
265  if (!flags['-'])
266  pad(width - 1, ' ');
267  put((unsigned char)va_arg(box->ap, int), cl);
268  if ( flags['-'])
269  pad(width - 1, ' ');
270 }
271 
272 //
273 // rounding routine used by f.p. conversion
274 // NOTE: this routine rounds up by using BCD arithmetic (digits are characters).
275 //
276 static void
277 roundit_f(double num, char* start, char* end, bool* neg)
278 {
279  double tmp;
280  modf(num * 10., &tmp);
281 
282  if (tmp > 4.) {
283  for (;; --end) {
284  if (*end == '.') {
285  --end;
286  }
287  if (++*end <= '9') {
288  break;
289  }
290  *end = '0';
291  if (end == start) {
292  *--end = '1';
293  --start;
294  break;
295  }
296  }
297  }
298  else if (*neg) {
299  for (;; --end) {
300  if (*end == '.') {
301  --end;
302  }
303  if (*end != '0') {
304  break;
305  }
306  if (end == start) {
307  *neg = false;
308  }
309  }
310  }
311 }
312 
313 //
314 // char string rep of double
315 // buf[buflen] gets rep of num to specified precision
316 //
317 static int
318 help_cvt_f(char* buf, size_t buflen, double num, int prec, bool* neg)
319 {
320  static char digits[] = "0123456789";
321 
322  double integer;
323  int expnt = 0;
324  char* bufend = buf+buflen-1;
325  buf[0] = '\0';
326 
327  char* p = bufend;
328  char* t = buf+1; // allow 1st slot for rounding: 9.9 rounds up to 10.
329 
330  double frac = modf(num, &integer);
331  for (; integer; ++expnt) {
332  double tmp = modf(integer / 10., &integer);
333  *p-- = digits[(int) ((tmp + .01) * 10.)];
334  }
335  // case f
336  if (expnt) {
337  memmove(t, p+1, bufend-p);
338  t += bufend-p;
339  }
340  else {
341  *t++ = '0';
342  }
343  if (prec) {
344  *t++ = '.';
345  }
346  if (frac) {
347  if (prec) {
348  do {
349  frac = modf(frac * 10., &integer);
350  *t++ = digits[(int) integer];
351  } while (--prec && frac);
352  }
353  if (frac) {
354  roundit_f(frac, buf+1, t-1, neg);
355  }
356  }
357  memset(t, '0', prec);
358  t += prec;
359  return t - buf - 1;
360 }
361 
362 static void
363 cvt_f(int code, va_list_box* box,
364  int put(int c, void* cl), void* cl,
365  unsigned char flags[], int width, int precision)
366 {
367  char _nbuf[FPBUF_LEN+1]; // add 1 for sign
368  bool neg = false;
369 
370  if (precision < 0){
371  precision = 6;
372  }
373  double num = va_arg(box->ap, double);
374  if (num < 0) {
375  neg = true;
376  num = - num;
377  }
378  char* nbuf = _nbuf+1;
379  int rv = help_cvt_f(nbuf, FPBUF_LEN, num, precision, &neg);
380  char* _t = *nbuf ? nbuf : nbuf+1;
381  _t[rv] = '\0';
382  if (neg) {
383  _t--;
384  _t[0] = '-';
385  rv++;
386  }
387  hpcrun_msg_putd(_t, strlen(_t), put, cl, flags,
388  width, precision);
389 }
390 
391 static int
392 fixed_len_insert(int c, void* cl)
393 {
394  struct buf* p = (struct buf*) cl;
395  if (! (p->bp >= p->buf + p->size)) {
396  *p->bp++ = (char) c;
397  }
398 
399  return c;
400 }
401 
402 //*****************************************************************************
403 // local conversion character table
404 //*****************************************************************************
405 
406 static T cvt[256] = {
407  /* 0- 7 */ 0, 0, 0, 0, 0, 0, 0, 0,
408  /* 8- 15 */ 0, 0, 0, 0, 0, 0, 0, 0,
409  /* 16- 23 */ 0, 0, 0, 0, 0, 0, 0, 0,
410  /* 24- 31 */ 0, 0, 0, 0, 0, 0, 0, 0,
411  /* 32- 39 */ 0, 0, 0, 0, 0, 0, 0, 0,
412  /* 40- 47 */ 0, 0, 0, 0, 0, 0, 0, 0,
413  /* 48- 55 */ 0, 0, 0, 0, 0, 0, 0, 0,
414  /* 56- 63 */ 0, 0, 0, 0, 0, 0, 0, 0,
415  /* 64- 71 */ 0, 0, 0, 0, 0, 0, 0, 0,
416  /* 72- 79 */ 0, 0, 0, 0, 0, 0, 0, 0,
417  /* 80- 87 */ 0, 0, 0, 0, 0, 0, 0, 0,
418  /* 88- 95 */ 0, 0, 0, 0, 0, 0, 0, 0,
419  /* 96-103 */ 0, 0, 0, cvt_c, cvt_d, cvt_f, cvt_f, cvt_f,
420  /* 104-111 */ 0, 0, 0, 0, 0, 0, 0, cvt_o,
421  /* 112-119 */ cvt_p, 0, 0, cvt_s, 0, cvt_u, 0, 0,
422  /* 120-127 */ cvt_x, 0, 0, 0, 0, 0, 0, 0
423 };
424 
425 //*****************************************************************************
426 // interface operations
427 //*****************************************************************************
428 
429 void
430 hpcrun_msg_puts(const char *str, int len,
431  int put(int c, void *cl), void *cl,
432  unsigned char flags[], int width, int precision)
433 {
434  if (width == INT_MIN)
435  width = 0;
436  if (width < 0) {
437  flags['-'] = 1;
438  width = -width;
439  }
440  if (precision >= 0)
441  flags['0'] = 0;
442  if (precision >= 0 && precision < len)
443  len = precision;
444  if (!flags['-'])
445  pad(width - len, ' ');
446  {
447  int i;
448  for (i = 0; i < len; i++)
449  put((unsigned char)*str++, cl);
450  }
451  if ( flags['-'])
452  pad(width - len, ' ');
453 }
454 
455 void
456 hpcrun_msg_fmt(int put(int c, void *), void *cl,
457  const char *fmt, ...)
458 {
459  va_list_box box;
460  va_start(box.ap, fmt);
461  hpcrun_msg_vfmt(put, cl, fmt, &box);
462  va_end(box.ap);
463 }
464 
465 int
466 hpcrun_msg_ns(char* buf, size_t len, const char* fmt, ...)
467 {
468  int nchars;
469  va_list_box box;
470  va_list_box_start(box, fmt);
471  nchars = hpcrun_msg_vns(buf, len, fmt, &box);
472  va_list_box_end(box);
473  return nchars;
474 }
475 
476 int
477 hpcrun_msg_vns(char* buf, size_t len, const char* fmt, va_list_box* box)
478 {
479  struct buf cl = {
480  .buf = buf,
481  .bp = buf,
482  .size = len,
483  };
484 
485  hpcrun_msg_vfmt(fixed_len_insert, &cl, fmt, box);
486  fixed_len_insert((int) '\0', &cl);
487  return cl.bp - cl.buf -1;
488 }
489 
490 void
491 hpcrun_msg_vfmt(int put(int c, void *cl), void *cl,
492  const char *fmt, va_list_box *box)
493 {
494  while (*fmt)
495  if (*fmt != '%' || *++fmt == '%')
496  put((unsigned char)*fmt++, cl);
497  else
498  {
499  unsigned char c, flags[256];
500  int width = INT_MIN, precision = INT_MIN;
501  memset(flags, '\0', sizeof flags);
502  if (Fmt_flags) {
503  unsigned char c = *fmt;
504  for ( ; c && strchr(Fmt_flags, c); c = *++fmt) {
505  flags[c]++;
506  }
507  }
508  if (*fmt == '*' || isdigit(*fmt)) {
509  int n;
510  if (*fmt == '*') {
511  n = va_arg(box->ap, int);
512  fmt++;
513  } else
514  for (n = 0; isdigit(*fmt); fmt++) {
515  int d = *fmt - '0';
516  n = 10*n + d;
517  }
518  width = n;
519  }
520  if (*fmt == '.' && (*++fmt == '*' || isdigit(*fmt))) {
521  int n;
522  if (*fmt == '*') {
523  n = va_arg(box->ap, int);
524  fmt++;
525  } else
526  for (n = 0; isdigit(*fmt); fmt++) {
527  int d = *fmt - '0';
528  n = 10*n + d;
529  }
530  precision = n;
531  }
532  c = *fmt++;
533  if (c == 'l') {
534  flags[c] = 1;
535  c = *fmt++;
536  }
537  if (cvt[c]){
538  (*cvt[c])(c, box, put, cl, flags, width, precision);
539  }
540  }
541 }
542 
543 T
544 hpcrun_msg_register(int code, T newcvt)
545 {
546  T old;
547 
548  old = cvt[code];
549  cvt[code] = newcvt;
550  return old;
551 }
552 
553 void
554 hpcrun_msg_putd(const char *str, int len,
555  int put(int c, void *cl), void *cl,
556  unsigned char flags[], int width, int precision)
557 {
558  int sign;
559 
560  if (width == INT_MIN)
561  width = 0;
562  if (width < 0) {
563  flags['-'] = 1;
564  width = -width;
565  }
566  if (precision >= 0)
567  flags['0'] = 0;
568  if (len > 0 && (*str == '-' || *str == '+')) {
569  sign = *str++;
570  len--;
571  } else if (flags['+'])
572  sign = '+';
573  else if (flags[' '])
574  sign = ' ';
575  else
576  sign = 0;
577  { int n;
578  if (precision < 0)
579  precision = 1;
580  if (len < precision)
581  n = precision;
582  else if (precision == 0 && len == 1 && str[0] == '0')
583  n = 0;
584  else
585  n = len;
586  if (sign)
587  n++;
588  if (flags['-']) {
589  if (sign)
590  put(sign, cl);
591  } else if (flags['0']) {
592  if (sign)
593  put(sign, cl);
594  pad(width - n, '0');
595  } else {
596  pad(width - n, ' ');
597  if (sign)
598  put(sign, cl);
599  }
600  pad(precision - len, '0');
601  {
602  int i;
603  for (i = 0; i < len; i++)
604  put((unsigned char)*str++, cl);
605  }
606  if (flags['-'])
607  pad(width - n, ' '); }
608 }
#define va_list_box_end(box)
Definition: fmt.h:57
static void cvt_f(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:363
char * bp
Definition: fmt.c:110
static char * tmp
Definition: tokenize.c:63
static int fixed_len_insert(int c, void *cl)
Definition: fmt.c:392
int hpcrun_msg_vns(char *buf, size_t len, const char *fmt, va_list_box *box)
Definition: fmt.c:477
static int help_cvt_f(char *buf, size_t buflen, double num, int prec, bool *neg)
Definition: fmt.c:318
static void cvt_x(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:214
static void roundit_f(double num, char *start, char *end, bool *neg)
Definition: fmt.c:277
static void cvt_p(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:237
#define va_list_box_start(box, arg)
Definition: fmt.h:56
Definition: fmt.c:108
#define T
Definition: fmt.c:72
#define FPBUF_LEN
Definition: fmt.c:101
static void cvt_u(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:169
static void cvt_o(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:191
static void cvt_s(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:125
va_list ap
Definition: fmt.h:53
int hpcrun_msg_ns(char *buf, size_t len, const char *fmt,...)
Definition: fmt.c:466
char * buf
Definition: fmt.c:109
#define pad(n, c)
Definition: fmt.c:74
static void cvt_c(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:255
int size
Definition: fmt.c:111
void hpcrun_msg_putd(const char *str, int len, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:554
T hpcrun_msg_register(int code, T newcvt)
Definition: fmt.c:544
void hpcrun_msg_vfmt(int put(int c, void *cl), void *cl, const char *fmt, va_list_box *box)
Definition: fmt.c:491
#define NULL
Definition: ElfHelper.cpp:85
void hpcrun_msg_puts(const char *str, int len, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:430
static const char * Fmt_flags
Definition: fmt.c:118
static void cvt_d(int code, va_list_box *box, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
Definition: fmt.c:137
<!-- ********************************************************************--> n<!-- HPCToolkit Experiment DTD --> n<!-- Version 2.1 --> n<!-- ********************************************************************--> n<!ELEMENT HPCToolkitExperiment(Header,(SecCallPathProfile|SecFlatProfile) *)> n<!ATTLIST HPCToolkitExperiment\n version CDATA #REQUIRED > n n<!-- ******************************************************************--> n n<!-- Info/NV:flexible name-value pairs:(n) ame;(t) ype;(v) alue --> n<!ELEMENT Info(NV *)> n<!ATTLIST Info\n n CDATA #IMPLIED > n<!ELEMENT NV EMPTY > n<!ATTLIST NV\n n CDATA #REQUIRED\n t CDATA #IMPLIED\n v CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Header --> n<!-- ******************************************************************--> n<!ELEMENT Header(Info *)> n<!ATTLIST Header\n n CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Section Header --> n<!-- ******************************************************************--> n<!ELEMENT SecHeader(MetricTable?, MetricDBTable?, TraceDBTable?, LoadModuleTable?, FileTable?, ProcedureTable?, Info *)> n n<!-- MetricTable:--> n<!ELEMENT MetricTable(Metric) * > n n<!-- Metric:(i) d;(n) ame --> n<!--(v) alue-type:transient type of values --> n<!--(t) ype:persistent type of metric --> n<!-- fmt:format;show;--> n<!ELEMENT Metric(MetricFormula *, Info?)> n<!ATTLIST Metric\n i CDATA #REQUIRED\n n CDATA #REQUIRED\n es CDATA #IMPLIED\n em CDATA #IMPLIED\n ep CDATA #IMPLIED\n v(raw|final|derived-incr|derived) \"raw\\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ fmt CDATA #IMPLIED\ show (1|0) \1\\ show-percent (1|0) \1> n n<!-- MetricFormula represents derived metrics: (t)ype; (frm): formula --> n<!ELEMENT MetricFormula (Info?)> n<!ATTLIST MetricFormula\ t (combine|finalize) \finalize\\ i CDATA #IMPLIED\ frm CDATA #REQUIRED> n n<!-- Metric data, used in sections: (n)ame [from Metric]; (v)alue --> n<!ELEMENT M EMPTY> n<!ATTLIST M\ n CDATA #REQUIRED\ v CDATA #REQUIRED> n n<!-- MetricDBTable: --> n<!ELEMENT MetricDBTable (MetricDB)*> n n<!-- MetricDB: (i)d; (n)ame --> n<!-- (t)ype: persistent type of metric --> n<!-- db-glob: file glob describing files in metric db --> n<!-- db-id: id within metric db --> n<!-- db-num-metrics: number of metrics in db --> n<!-- db-header-sz: size (in bytes) of a db file header --> n<!ELEMENT MetricDB EMPTY> n<!ATTLIST MetricDB\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ db-glob CDATA #IMPLIED\ db-id CDATA #IMPLIED\ db-num-metrics CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- TraceDBTable: --> n<!ELEMENT TraceDBTable (TraceDB)> n n<!-- TraceDB: (i)d --> n<!-- db-min-time: min beginning time stamp (global) --> n<!-- db-max-time: max ending time stamp (global) --> n<!ELEMENT TraceDB EMPTY> n<!ATTLIST TraceDB\ i CDATA #REQUIRED\ db-glob CDATA #IMPLIED\ db-min-time CDATA #IMPLIED\ db-max-time CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- LoadModuleTable assigns a short name to a load module --> n<!ELEMENT LoadModuleTable (LoadModule)*> n n<!ELEMENT LoadModule (Info?)> n<!ATTLIST LoadModule\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- FileTable assigns a short name to a file --> n<!ELEMENT FileTable (File)*> n n<!ELEMENT File (Info?)> n<!ATTLIST File\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- ProcedureTable assigns a short name to a procedure --> n<!ELEMENT ProcedureTable (Procedure)*> n n<!-- Info/NV: flexible name-value pairs: (n)ame; (t)ype; (v)alue --> n<!-- f: family of the procedure (fake, root, ...)--> n<!ELEMENT Procedure (Info?)> n<!ATTLIST Procedure\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ f CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Call path profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecCallPathProfile (SecHeader, SecCallPathProfileData)> n<!ATTLIST SecCallPathProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecCallPathProfileData (PF|M)*> n<!-- Procedure frame --> n<!-- (i)d: unique identifier for cross referencing --> n<!-- (s)tatic scope id --> n<!-- (n)ame: a string or an id in ProcedureTable --> n<!-- (lm) load module: a string or an id in LoadModuleTable --> n<!-- (f)ile name: a string or an id in LoadModuleTable --> n<!-- (l)ine range: \beg-end\ (inclusive range) --> n<!-- (a)lien: whether frame is alien to enclosing P --> n<!-- (str)uct: hpcstruct node id --> n<!-- (t)ype: hpcrun node type: memory access, variable declaration, ... --> n<!-- (v)ma-range-set: \{[beg-end), [beg-end)...}\ --> n<!ELEMENT PF (PF|Pr|L|C|S|M)*> n<!ATTLIST PF\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Procedure (static): GOAL: replace with 'P' --> n<!ELEMENT Pr (Pr|L|C|S|M)*> n<!ATTLIST Pr\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ a (1|0) \0\\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Callsite (a special StatementRange) --> n<!ELEMENT C (PF|M)*> n<!ATTLIST C\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Flat profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecFlatProfile (SecHeader, SecFlatProfileData)> n<!ATTLIST SecFlatProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecFlatProfileData (LM|M)*> n<!-- Load module: (i)d; (n)ame; (v)ma-range-set --> n<!ELEMENT LM (F|P|M)*> n<!ATTLIST LM\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ v CDATA #IMPLIED> n<!-- File --> n<!ELEMENT F (P|L|S|M)*> n<!ATTLIST F\ i CDATA #IMPLIED\ n CDATA #REQUIRED> n<!-- Procedure (Note 1) --> n<!ELEMENT P (P|A|L|S|C|M)*> n<!ATTLIST P\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Alien (Note 1) --> n<!ELEMENT A (A|L|S|C|M)*> n<!ATTLIST A\ i CDATA #IMPLIED\ f CDATA #IMPLIED\ n CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Loop (Note 1,2) --> n<!ELEMENT L (A|Pr|L|S|C|M)*> n<!ATTLIST L\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ f CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Statement (Note 2) --> n<!-- (it): trace record identifier --> n<!ELEMENT S (S|M)*> n<!ATTLIST S\ i CDATA #IMPLIED\ it CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Note 1: Contained Cs may not contain PFs --> n<!-- Note 2: The 's' attribute is not used for flat profiles --> n
static T cvt[256]
Definition: fmt.c:406
void hpcrun_msg_fmt(int put(int c, void *), void *cl, const char *fmt,...)
Definition: fmt.c:456