74 #define pad(n,c) do { int nn = (n); \ 76 put((c), cl); } while (0) 101 #define FPBUF_LEN (MAXEXP+MAXFRACT+1) 126 int put(
int c,
void *cl),
void *cl,
127 unsigned char flags[],
int width,
int precision)
129 char *str = va_arg(box->
ap,
char *);
130 if (str ==
NULL) { str =
"(null)"; }
138 int put(
int c,
void *cl),
void *cl,
139 unsigned char flags[],
int width,
int precision)
144 val = va_arg(box->
ap,
long);
147 val = va_arg(box->
ap,
int);
152 char *p = buf +
sizeof buf;
161 while ((m /= 10) > 0);
170 int put(
int c,
void *cl),
void *cl,
171 unsigned char flags[],
int width,
int precision)
176 m = va_arg(box->
ap,
unsigned long);
179 m = va_arg(box->
ap,
unsigned int);
182 char *p = buf +
sizeof buf;
185 while ((m /= 10) > 0);
192 int put(
int c,
void *cl),
void *cl,
193 unsigned char flags[],
int width,
int precision)
198 m = va_arg(box->
ap,
unsigned long);
201 m = va_arg(box->
ap,
unsigned int);
205 char *p = buf +
sizeof buf;
207 *--p = (m&0x7) +
'0';
208 while ((m>>= 3) != 0);
215 int put(
int c,
void *cl),
void *cl,
216 unsigned char flags[],
int width,
int precision)
221 m = va_arg(box->
ap,
unsigned long);
224 m = va_arg(box->
ap,
unsigned int);
228 char *p = buf +
sizeof buf;
230 *--p =
"0123456789abcdef"[m&0xf];
231 while ((m>>= 4) != 0);
238 int put(
int c,
void *cl),
void *cl,
239 unsigned char flags[],
int width,
int precision)
241 uintptr_t m = (uintptr_t)va_arg(box->
ap,
void*);
243 char* p = buf +
sizeof buf;
246 *--p =
"0123456789abcdef"[m&0xf];
247 while ((m>>= 4) != 0);
256 int put(
int c,
void *cl),
void *cl,
257 unsigned char flags[],
int width,
int precision)
259 if (width == INT_MIN)
267 put((
unsigned char)va_arg(box->
ap,
int), cl);
277 roundit_f(
double num,
char* start,
char* end,
bool* neg)
280 modf(num * 10., &tmp);
320 static char digits[] =
"0123456789";
324 char* bufend = buf+buflen-1;
330 double frac = modf(num, &integer);
331 for (; integer; ++expnt) {
332 double tmp = modf(integer / 10., &integer);
333 *p-- = digits[(int) ((tmp + .01) * 10.)];
337 memmove(t, p+1, bufend-p);
349 frac = modf(frac * 10., &integer);
350 *t++ = digits[(int) integer];
351 }
while (--prec && frac);
357 memset(t,
'0', prec);
364 int put(
int c,
void* cl),
void* cl,
365 unsigned char flags[],
int width,
int precision)
373 double num = va_arg(box->
ap,
double);
378 char* nbuf = _nbuf+1;
380 char* _t = *nbuf ? nbuf : nbuf+1;
394 struct buf* p = (
struct buf*) cl;
407 0, 0, 0, 0, 0, 0, 0, 0,
408 0, 0, 0, 0, 0, 0, 0, 0,
409 0, 0, 0, 0, 0, 0, 0, 0,
410 0, 0, 0, 0, 0, 0, 0, 0,
411 0, 0, 0, 0, 0, 0, 0, 0,
412 0, 0, 0, 0, 0, 0, 0, 0,
413 0, 0, 0, 0, 0, 0, 0, 0,
414 0, 0, 0, 0, 0, 0, 0, 0,
415 0, 0, 0, 0, 0, 0, 0, 0,
416 0, 0, 0, 0, 0, 0, 0, 0,
417 0, 0, 0, 0, 0, 0, 0, 0,
418 0, 0, 0, 0, 0, 0, 0, 0,
420 0, 0, 0, 0, 0, 0, 0,
cvt_o,
422 cvt_x, 0, 0, 0, 0, 0, 0, 0
431 int put(
int c,
void *cl),
void *cl,
432 unsigned char flags[],
int width,
int precision)
434 if (width == INT_MIN)
442 if (precision >= 0 && precision < len)
445 pad(width - len,
' ');
448 for (i = 0; i < len; i++)
449 put((
unsigned char)*str++, cl);
452 pad(width - len,
' ');
457 const char *fmt, ...)
460 va_start(box.
ap, fmt);
487 return cl.
bp - cl.
buf -1;
495 if (*fmt !=
'%' || *++fmt ==
'%')
496 put((
unsigned char)*fmt++, cl);
499 unsigned char c, flags[256];
500 int width = INT_MIN, precision = INT_MIN;
501 memset(flags,
'\0',
sizeof flags);
503 unsigned char c = *fmt;
504 for ( ; c && strchr(
Fmt_flags, c); c = *++fmt) {
508 if (*fmt ==
'*' || isdigit(*fmt)) {
511 n = va_arg(box->
ap,
int);
514 for (n = 0; isdigit(*fmt); fmt++) {
520 if (*fmt ==
'.' && (*++fmt ==
'*' || isdigit(*fmt))) {
523 n = va_arg(box->
ap,
int);
526 for (n = 0; isdigit(*fmt); fmt++) {
538 (*cvt[c])(c, box, put, cl, flags, width, precision);
555 int put(
int c,
void *cl),
void *cl,
556 unsigned char flags[],
int width,
int precision)
560 if (width == INT_MIN)
568 if (len > 0 && (*str ==
'-' || *str ==
'+')) {
571 }
else if (flags[
'+'])
582 else if (precision == 0 && len == 1 && str[0] ==
'0')
591 }
else if (flags[
'0']) {
600 pad(precision - len,
'0');
603 for (i = 0; i < len; i++)
604 put((
unsigned char)*str++, cl);
607 pad(width - n,
' '); }
#define va_list_box_end(box)
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)
static int fixed_len_insert(int c, void *cl)
int hpcrun_msg_vns(char *buf, size_t len, const char *fmt, va_list_box *box)
static int help_cvt_f(char *buf, size_t buflen, double num, int prec, bool *neg)
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)
static void roundit_f(double num, char *start, char *end, bool *neg)
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)
#define va_list_box_start(box, arg)
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)
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)
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)
int hpcrun_msg_ns(char *buf, size_t len, const char *fmt,...)
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)
void hpcrun_msg_putd(const char *str, int len, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
T hpcrun_msg_register(int code, T newcvt)
void hpcrun_msg_vfmt(int put(int c, void *cl), void *cl, const char *fmt, va_list_box *box)
void hpcrun_msg_puts(const char *str, int len, int put(int c, void *cl), void *cl, unsigned char flags[], int width, int precision)
static const char * Fmt_flags
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)
<!-- ********************************************************************--> 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
void hpcrun_msg_fmt(int put(int c, void *), void *cl, const char *fmt,...)