xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/common/hwcentry.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos    Contributed by Oracle.
34f645668Schristos 
44f645668Schristos    This file is part of GNU Binutils.
54f645668Schristos 
64f645668Schristos    This program is free software; you can redistribute it and/or modify
74f645668Schristos    it under the terms of the GNU General Public License as published by
84f645668Schristos    the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos    any later version.
104f645668Schristos 
114f645668Schristos    This program is distributed in the hope that it will be useful,
124f645668Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144f645668Schristos    GNU General Public License for more details.
154f645668Schristos 
164f645668Schristos    You should have received a copy of the GNU General Public License
174f645668Schristos    along with this program; if not, write to the Free Software
184f645668Schristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos    MA 02110-1301, USA.  */
204f645668Schristos 
214f645668Schristos #ifndef _HWCENTRY_H
224f645668Schristos #define _HWCENTRY_H
234f645668Schristos 
244f645668Schristos #ifndef LIBCOLLECTOR_SRC /* not running in libcollector */
254f645668Schristos #include <stdio.h>  /* FILE */
264f645668Schristos #endif  /* --- LIBCOLLECTOR_SRC --- */
274f645668Schristos #include <stdlib.h> /* size_t */
284f645668Schristos #include "hwc_cpus.h"
294f645668Schristos #include "gp-time.h"
304f645668Schristos 
314f645668Schristos #ifdef __cplusplus
324f645668Schristos extern "C"
334f645668Schristos {
344f645668Schristos #endif
354f645668Schristos 
364f645668Schristos   /* ABS backtrack types */
374f645668Schristos   typedef enum
384f645668Schristos   {
394f645668Schristos     /* !! Lowest 2 bits are used to indicate load and store, respectively !! */
404f645668Schristos     /* Example: On SPARC, backtrack.c did this: if (ABS_memop & inst_type) ... */
414f645668Schristos     ABST_NONE               = 0x0,
424f645668Schristos     ABST_LOAD               = 0x1,
434f645668Schristos     ABST_STORE              = 0x2,
444f645668Schristos     ABST_LDST               = 0x3,
454f645668Schristos     ABST_COUNT              = 0x4,
464f645668Schristos     ABST_US_DTLBM           = 0xF,
474f645668Schristos     ABST_NOPC               = 0x100,
484f645668Schristos     ABST_CLKDS              = 0x103,     // Obsolete
494f645668Schristos     ABST_EXACT              = 0x203,
504f645668Schristos     ABST_LDST_SPARC64       = 0x303,
514f645668Schristos     ABST_EXACT_PEBS_PLUS1   = 0x403
524f645668Schristos     /* full description below... */
534f645668Schristos   } ABST_type;
544f645668Schristos 
554f645668Schristos #define ABST_PLUS_BY_DEFAULT(n) ((n)==ABST_EXACT || (n)==ABST_EXACT_PEBS_PLUS1)
564f645668Schristos #define ABST_BACKTRACK_ENABLED(n) ((n)!=ABST_NONE && (n)!=ABST_NOPC)
574f645668Schristos #define ABST_MEMSPACE_ENABLED(n)  ((n)!=ABST_NONE && (n)!=ABST_NOPC && (n)!=ABST_COUNT)
584f645668Schristos 
594f645668Schristos   /* ABS determines the type of backtracking available for a particular metric.
604f645668Schristos    * Backtracking is enabled with the "+" in "-h +<countername>...".
614f645668Schristos    *
624f645668Schristos    * When Backtracking is not possible:
634f645668Schristos    *
644f645668Schristos    *  ABST_NONE=0:     Either the user did not specify "+", or backtracking
654f645668Schristos    *                   is not applicable to the metric, for example:
664f645668Schristos    *                     clk cycles,
674f645668Schristos    *                     instruct counts (dispatch + branch + prefetch),
684f645668Schristos    *                     i$,
694f645668Schristos    *                     FP ops
704f645668Schristos    *  ABST_NOPC=0x100  Used for non-program-related external events, for example:
714f645668Schristos    *                     system interface events,
724f645668Schristos    *                     memory controller counters
734f645668Schristos    *                   Of all ABST_type options, only ABST_NOPC prevents hwprofile.c
744f645668Schristos    *                     from recording PC/stack information.
754f645668Schristos    *
764f645668Schristos    * When backtracking is allowed:
774f645668Schristos    *
784f645668Schristos    *  ABST_LOAD=1:     data read events, used with metrics like:
794f645668Schristos    *                     D$, E$, P$ read misses and hits.
804f645668Schristos    *                     [DC+EC+PC]_rd*, Re_*_miss*,
814f645668Schristos    *                     EC_snoop_cb(?)
824f645668Schristos    *  ABST_STORE=2:    data write events, used with metrics like:
834f645668Schristos    *                     D$ writes and write related misses
844f645668Schristos    *                     DC_wr/wr-miss, EC_wb, WC=writecache, Rstall_storeQ
854f645668Schristos    *                     [EC+PC=pcache]_snoop_inv(?), WC_snoop_cb(?),
864f645668Schristos    *  ABST_LDST=3:     data reads/writes, used with metrics like:
874f645668Schristos    *                     E$ references, misses.
884f645668Schristos    *  ABST_COUNT=4:    dedicated assembly instruction: '%hi(0xfc000)'
894f645668Schristos    *                     See SW_count_n metric on sparc.
904f645668Schristos    *  ABST_US_DTLBM=0xF: for load-store on Sparc -- seems to be used only
914f645668Schristos    *                     for "unskidded DTLB_miss" with DTLB_miss metric.
924f645668Schristos    *                     Checks two adjacent instructions for Data access.
934f645668Schristos    *  ABST_CLKDS=0x103: data reads/writes, used with Clock-based Dataspace
944f645668Schristos    *                     profiling.  Ultrasparc T2 and earlier.
954f645668Schristos    *  ABST_EXACT=0x203: data reads/writes, precise trap with no skid
964f645668Schristos    *  ABST_LDST_SPARC64=0x303: Fujitsu SPARC64 load/store
974f645668Schristos    *  ABST_EXACT_PEBS_PLUS1=0x403: data reads/writes, precise sampling with 1 instr. skid
984f645668Schristos    */
994f645668Schristos 
1004f645668Schristos   /* Hwcentry - structure for defining a counter.
1014f645668Schristos    *   Some fields have different usage when returned from
1024f645668Schristos    *   hwc_lookup(), hwc_post_lookup(), or hwc_scan_*().
1034f645668Schristos    *   Each function will describe its return values in more detail.
1044f645668Schristos    */
1054f645668Schristos   typedef struct
1064f645668Schristos   {
1074f645668Schristos     char *name;         /* user HWC specification */
1084f645668Schristos     char *int_name;     /* internal HWC specification */
1094f645668Schristos     regno_t reg_num;    /* register in CPU, aka picnum, or REGNO_ANY */
1104f645668Schristos     char *metric;       /* descriptive name, for well-known counters only */
1114f645668Schristos     volatile int val;   /* default or actual overflow value */
1124f645668Schristos     int timecvt;        /* multiplier to convert metric to time, 0 if N/A */
1134f645668Schristos     ABST_type memop;    /* type of backtracking allowed */
1144f645668Schristos     char *short_desc;   /* optional one-liner description, or NULL */
1154f645668Schristos     /* the fields above this line are expected, in order, by the tables in hwctable.c */
1164f645668Schristos     /* ================================================== */
1174f645668Schristos     /* the fields below this line are more flexible */
118*cb63e24eSchristos     unsigned int use_perf_event_type : 16; /* Set 1 to use two fields below */
119*cb63e24eSchristos     unsigned int type : 16; /* Type of perf_event_attr */
120*cb63e24eSchristos     long long config;   /* perf_event_type -specific configuration */
1214f645668Schristos     int sort_order;     /* "tag" to associate experiment record with HWC def */
1224f645668Schristos     regno_t *reg_list;  /* if not NULL, legal values for <reg_num> field above */
1234f645668Schristos     /* Note: reg_list will be terminated by REGNO_ANY */
1244f645668Schristos     /* Max size of array is MAX_PICS */
1254f645668Schristos     hrtime_t min_time;  /* target minimum time between overflow events.  0 is off.  See HWCTIME_* macros */
1264f645668Schristos     hrtime_t min_time_default; /* if min_time==HWCTIME_AUTO, use this value instead.  0 is off. */
1274f645668Schristos     int ref_val;    /* if min_time==HWCTIME_AUTO, use this time.  0 is off. */
1284f645668Schristos     int lval, hval; /* temporary to allow DBX to build until dbx glue.cc fixed */
1294f645668Schristos   } Hwcentry;
1304f645668Schristos 
1314f645668Schristos   // Hwcentry.min_time canned values
1324f645668Schristos #define HWCTIME_TBD ((hrtime_t)( -1LL)) /* self-adjusting enabled but nsecs not yet selected */
1334f645668Schristos #define HWCTIME_HI  (   1 * 1000 * 1000LL ) /*   1 msec represented in nsecs */
1344f645668Schristos #define HWCTIME_ON  (  10 * 1000 * 1000LL ) /*  10 msec represented in nsecs */
1354f645668Schristos #define HWCTIME_LO  ( 100 * 1000 * 1000LL ) /* 100 msec represented in nsecs */
1364f645668Schristos 
1374f645668Schristos #define HWC_VAL_HI(refVal) (((refVal)/10) + 1)
1384f645668Schristos #define HWC_VAL_ON(refVal) (refVal)
1394f645668Schristos #define HWC_VAL_LO(refVal) (((refVal)*10)/100*100 + 1)  // zero's out lower digits, add 1
1404f645668Schristos #define HWC_VAL_CUSTOM(refVal, targetNanoSec) ((double)(refVal)*(targetNanoSec)/HWCTIME_ON)
1414f645668Schristos 
1424f645668Schristos #define HWCENTRY_USES_SAMPLING(h)   ((h)->memop==ABST_EXACT_PEBS_PLUS1)
1434f645668Schristos 
1444f645668Schristos   extern int hwc_lookup (int forKernel, hrtime_t min_time_default,
1454f645668Schristos 			 const char *uname, Hwcentry *list[], unsigned listsz,
1464f645668Schristos 			 char **emsg, char **wmsg);
1474f645668Schristos   /* Parses counter cmdline string.  Returns counter definitions.
1484f645668Schristos    * Input:
1494f645668Schristos    *   <forKernel> lookup using which table: 0-collect or 1-er_kernel
1504f645668Schristos    *   <min_time_default> minimum nseconds between events if Hwcentry.min_time == HWCTIME_TBD.  0 to disable.
1514f645668Schristos    *   <uname> command line HWC definition of format:
1524f645668Schristos    *           <ctr_def>...[{','|(whitespace)}<ctr_n_def>] where
1534f645668Schristos    *           <ctr_def> == [+]<ctr>[/<reg#>][,<interval>]
1544f645668Schristos    *   <list> array of pointers to store counter definitions
1554f645668Schristos    *   <listsz> number of elements in <list>
1564f645668Schristos    * Returns:
1574f645668Schristos    *   Success:
1584f645668Schristos    *     Returns number of valid counters in <list> and <list>'s elements
1594f645668Schristos    *     will be initialized as follows:
1604f645668Schristos    *
1614f645668Schristos    *     <list[]->name>:
1624f645668Schristos    *       Copy of the <uname> with the following modification:
1634f645668Schristos    *         if backtracking is not supported, the + will be removed.
1644f645668Schristos    *     <list[]->int_name>:
1654f645668Schristos    *       For well-known and convenience ctrs, the internal HWC specification,
1664f645668Schristos    *         e.g. BSQ_cache_reference~emask=0x0100.
1674f645668Schristos    *       For raw ctrs, this will be a copy of <name>.
1684f645668Schristos    *     <list[]->reg_num>:
1694f645668Schristos    *       Register number if specified by user or table, REGNO_ANY otherwise.
1704f645668Schristos    *     <list[]->metric>:
1714f645668Schristos    *       For well-known counters, descriptive name, e.g. "D$ Read Misses".
1724f645668Schristos    *       NULL otherwise.
1734f645668Schristos    *     <list[]->val>:
1744f645668Schristos    *       Overflow value selected by user, default value otherwise.
1754f645668Schristos    *     <list[]->timecvt>:
1764f645668Schristos    *       Value from tables.
1774f645668Schristos    *     <list[]->memop>:
1784f645668Schristos    *       If + is selected and backtracking is allowed, value from table.
1794f645668Schristos    *       ABST_NONE or ABST_NOPC otherwise.
1804f645668Schristos    *
1814f645668Schristos    *     It is the responsibility of the caller to free 'name' and 'int_name'.
1824f645668Schristos    *     'metric' is a static string and shouldn't be freed.
1834f645668Schristos    *     'emsg' will point to NULL
1844f645668Schristos    *
1854f645668Schristos    *   Failure:
1864f645668Schristos    *     Frees all allocated elements.
1874f645668Schristos    *     emsg will point to a string with an error message to print
1884f645668Schristos    *     returns -1
1894f645668Schristos    */
1904f645668Schristos 
1914f645668Schristos   extern char *hwc_validate_ctrs (int forKernel, Hwcentry *list[], unsigned listsz);
1924f645668Schristos   /* Validates that the vector of specified HW counters can be loaded (more-or-less)
1934f645668Schristos    *   Some invalid combinations, especially on Linux will not be detected
1944f645668Schristos    */
1954f645668Schristos 
1964f645668Schristos   extern int hwc_get_cpc_cpuver ();
1974f645668Schristos   /* Return the cpc_cpuver for this system.  Other possible values:
1984f645668Schristos    *   CPUVER_GENERIC=0,           CPU could not be determined, but HWCs are ok.
1994f645668Schristos    *   CPUVER_UNDEFINED=-1,        HWCs are not available.
2004f645668Schristos    */
2014f645668Schristos 
2024f645668Schristos   extern char *hwc_get_docref (char *buf, size_t buflen);
2034f645668Schristos   /* Return a CPU HWC document reference, or NULL. */
2044f645668Schristos 
2054f645668Schristos   // TBR
2064f645668Schristos   extern char *hwc_get_default_cntrs ();
2074f645668Schristos   /* Return a default HW counter string; may be NULL, or zero-length */
2084f645668Schristos   /* NULL means none is defined in the table; or zero-length means string defined could not be loaded */
2094f645668Schristos 
2104f645668Schristos   extern char *hwc_get_default_cntrs2 (int forKernel, int style);
2114f645668Schristos   /* like hwc_get_default_cntrs() for style==1 */
2124f645668Schristos   /* but allows other styles of formatting as well */
2134f645668Schristos   /* deprecate and eventually remove hwc_get_default_cntrs() */
2144f645668Schristos 
2154f645668Schristos   extern char *hwc_get_orig_default_cntrs ();
2164f645668Schristos   /* Get the default HW counter string as set in the table */
2174f645668Schristos   /* NULL means none is defined in the table */
2184f645668Schristos 
2194f645668Schristos   extern void hwc_update_val (Hwcentry *ctr);
2204f645668Schristos   /* Check time-based intervals and update Hwcentry.val as needed */
2214f645668Schristos 
2224f645668Schristos   extern char *hwc_get_cpuname (char *buf, size_t buflen);
2234f645668Schristos   /* Return the cpc cpu name for this system, or NULL. */
2244f645668Schristos 
2254f645668Schristos   extern unsigned hwc_get_max_regs ();
2264f645668Schristos   /* Return number of counters registers for this system. */
2274f645668Schristos 
2284f645668Schristos   extern unsigned hwc_get_max_concurrent (int forKernel);
2294f645668Schristos   /* Return the max number of simultaneous counters for this system. */
2304f645668Schristos 
2314f645668Schristos   extern char **hwc_get_attrs (int forKernel);
2324f645668Schristos   /* Return:
2334f645668Schristos    *   Array of attributes (strings) supported by this system.
2344f645668Schristos    *   Last element in array is null.
2354f645668Schristos    *   Array and its elements should NOT be freed by the caller.
2364f645668Schristos    */
2374f645668Schristos 
2384f645668Schristos   extern unsigned hwc_scan_attrs (void (*action)(const char *attr,
2394f645668Schristos 						 const char *desc));
2404f645668Schristos   /* Scan the HW counter attributes, and call function for each attribute.
2414f645668Schristos    * Input:
2424f645668Schristos    *   <action>:
2434f645668Schristos    *     If NULL, no action is performed, but count is still returned.
2444f645668Schristos    *     Otherwise called for each type of attributes, or if none exist,
2454f645668Schristos    *       called once with NULL parameter.
2464f645668Schristos    * Return: count of times <action> would have been called w/ non-NULL data.
2474f645668Schristos    */
2484f645668Schristos 
2494f645668Schristos   extern Hwcentry *hwc_post_lookup (Hwcentry * pret_ctr, char *uname,
2504f645668Schristos 				    char * int_name, int cpc_cpuver);
2514f645668Schristos   /* When post-processing a run, look up a Hwcentry for given type of system.
2524f645668Schristos    * Input:
2534f645668Schristos    *   <pret_ctr>: storage for counter definition
2544f645668Schristos    *   <uname>: well-known name, convenience name, or complete HWC defintion.
2554f645668Schristos    *   <int_name>: Hwcentry->int_name or NULL for don't care
2564f645668Schristos    *   <cpc_cpuver>: version of cpu used for experiment.
2574f645668Schristos    * Return:
2584f645668Schristos    *   <pret_ctr>'s elements set as follows:
2594f645668Schristos    *
2604f645668Schristos    *     <pret_ctr->name>:
2614f645668Schristos    *       Copy of <uname> with the following modifications:
2624f645668Schristos    *         1) + and /<regnum> will be stripped off
2634f645668Schristos    *         2) attributes will be sorted and values will shown in hex.
2644f645668Schristos    *     <pret_ctr->int_name>:
2654f645668Schristos    *       For well-known/convenience counters, the internal HWC specification
2664f645668Schristos    *         from the table, e.g. BSQ_cache_reference~emask=0x0100.
2674f645668Schristos    *       Otherwise, a copy of <uname>.
2684f645668Schristos    *     <pret_ctr->reg_num>:
2694f645668Schristos    *       Register number if specified by user or table,
2704f645668Schristos    *       REGNO_ANY othewise.
2714f645668Schristos    *     <pret_ctr->metric>:
2724f645668Schristos    *       For well-known counters, descriptive name, e.g. "D$ Read Misses".
2734f645668Schristos    *       NULL otherwise.
2744f645668Schristos    *     <pret_ctr->timecvt>:
2754f645668Schristos    *       For well-known/convenience/hidden counters, value from table.
2764f645668Schristos    *       0 otherwise.
2774f645668Schristos    *     <pret_ctr->memop>:
2784f645668Schristos    *       For well-known/convenience/hidden counters, value from table.
2794f645668Schristos    *       ABST_NONE otherwise.
2804f645668Schristos    *     <pret_ctr->sort_order>:
2814f645668Schristos    *       Set to 0.
2824f645668Schristos    *
2834f645668Schristos    *     It is the responsibility of the caller to free 'name' and 'int_name'.
2844f645668Schristos    *     'metric' is a static string and shouldn't be freed.
2854f645668Schristos    */
2864f645668Schristos 
2874f645668Schristos   extern Hwcentry **hwc_get_std_ctrs (int forKernel);
2884f645668Schristos   /* Return:
2894f645668Schristos    *   Array of well-known counters supported by this system.
2904f645668Schristos    *   Last element in array will be NULL.
2914f645668Schristos    *   Array and its elements should NOT be freed by the caller.
2924f645668Schristos    */
2934f645668Schristos 
2944f645668Schristos   extern unsigned hwc_scan_std_ctrs (void (*action)(const Hwcentry *));
2954f645668Schristos   /* Call <action> for each well-known counter.
2964f645668Schristos    * Input:
2974f645668Schristos    *   <action>:
2984f645668Schristos    *     If NULL, no action is performed, but count is still returned.
2994f645668Schristos    *     Otherwise called for each type of attributes, or if none exist,
3004f645668Schristos    *       called once with NULL parameter.
3014f645668Schristos    * Return:
3024f645668Schristos    *   Count of times <action> would have been called w/ non-NULL data.
3034f645668Schristos    *   If <action> is not NULL, Hwcentry fields will be set as follows:
3044f645668Schristos    *     <ctr->name>:
3054f645668Schristos    *       HWC alias name, e.g. dcrm.
3064f645668Schristos    *     <ctr->int_name>:
3074f645668Schristos    *       The internal HWC specification, e.g. BSQ_cache_reference~emask=0x0100.
3084f645668Schristos    *     <ctr->reg_num>:
3094f645668Schristos    *       Register number if specified by the table, REGNO_ANY otherwise.
3104f645668Schristos    *     <ctr->metric>:
3114f645668Schristos    *       Descriptive name, e.g. "D$ Read Misses".
3124f645668Schristos    *     <ctr->lval>:
3134f645668Schristos    *       Low-resolution overflow value.
3144f645668Schristos    *     <ctr->val>:
3154f645668Schristos    *       Default overflow value.
3164f645668Schristos    *     <ctr->hval>:
3174f645668Schristos    *       High-resolution overflow value.
3184f645668Schristos    *     <ctr->timecvt>:
3194f645668Schristos    *       multiplier to convert metric to time, 0 otherwise.
3204f645668Schristos    *     <ctr->memop>:
3214f645668Schristos    *       ABST_* type for this counter.
3224f645668Schristos    *     <ctr->reg_list>:
3234f645668Schristos    *       Array of legal <reg_num> values.  Terminated by REGNO_ANY.
3244f645668Schristos    *
3254f645668Schristos    *     Note: All fields point to static data, none should be freed.
3264f645668Schristos    */
3274f645668Schristos 
3284f645668Schristos   extern Hwcentry **hwc_get_raw_ctrs (int forKernel);
3294f645668Schristos   /* Return:
3304f645668Schristos    *   Table of raw (not well-known) counters supported by this system.
3314f645668Schristos    *   Last element in array will be NULL.
3324f645668Schristos    *   Table and its elements should NOT be freed by the caller.
3334f645668Schristos    */
3344f645668Schristos 
3354f645668Schristos   extern unsigned hwc_scan_raw_ctrs (void (*action)(const Hwcentry *));
3364f645668Schristos   /* Call <action> for each raw counter.
3374f645668Schristos    * Input:
3384f645668Schristos    *   <action>:
3394f645668Schristos    *     If NULL, no action is performed, but count is still returned.
3404f645668Schristos    *     Otherwise called for each type of attributes, or if none exist,
3414f645668Schristos    *       called once with NULL parameter.
3424f645668Schristos    * Return:
3434f645668Schristos    *   Count of times <action> would have been called w/ non-NULL data.
3444f645668Schristos    *   If <action> is not NULL, Hwcentry fields will be set as follows:
3454f645668Schristos    *     <ctr->name>:
3464f645668Schristos    *       HWC raw name without attributes, e.g. BSQ_cache_reference.
3474f645668Schristos    *     <ctr->int_name>:
3484f645668Schristos    *       NULL.
3494f645668Schristos    *     <ctr->metric>:
3504f645668Schristos    *       NULL.
3514f645668Schristos    *     The remainder of the fields are the same as for
3524f645668Schristos    *       hwc_scan_std_ctrs().
3534f645668Schristos    *
3544f645668Schristos    *     Note: All fields point to static data, none should be freed.
3554f645668Schristos    */
3564f645668Schristos 
3574f645668Schristos   extern void
3584f645668Schristos   hwc_usage (int forKernel, const char *cmd, const char *dataspace_msg);
3594f645668Schristos   /* Print an i18n'd description of "-h" usage, used by collect and er_kernel.
3604f645668Schristos    */
3614f645668Schristos 
3624f645668Schristos   extern void hwc_usage_f (int forKernel, FILE *f, const char *cmd,
3634f645668Schristos 			   const char *dataspace_msg, int show_syntax,
3644f645668Schristos 			   int show_short_desc);
3654f645668Schristos   /* Print an i18n'd description of "-h" usage to a FILE.  Used by GUI. */
3664f645668Schristos 
3674f645668Schristos   extern char *hwc_rate_string (const Hwcentry *pctr, int force_numeric_format);
3684f645668Schristos   /* Returns {"on"|"hi"|"lo"|""|<value>}.  Return value must be freed by caller. */
3694f645668Schristos 
3704f645668Schristos   extern char *hwc_i18n_metric (const Hwcentry *ctr);
3714f645668Schristos   /* Get a basic lable for a counter, properly i18n'd.
3724f645668Schristos    *   Note: NOT MT SAFE.
3734f645668Schristos    * Examples:
3744f645668Schristos    *   CPU Cycles
3754f645668Schristos    *   DC_rd Events
3764f645668Schristos    * Pseudocode:
3774f645668Schristos    *   if(ctr->metric != NULL) {
3784f645668Schristos    *	    sprintf(metricbuf, PTXT(ctr->metric) );
3794f645668Schristos    *   } else if (ctr->name != NULL) {
3804f645668Schristos    *	    sprintf(metricbuf, GTXT("%s Events"), ctr->name );
3814f645668Schristos    *   } else if (ctr->int_name != NULL) {
3824f645668Schristos    *	    sprintf(metricbuf, GTXT("%s Events"), ctr->int_name );
3834f645668Schristos    *   }
3844f645668Schristos    * Return: pointer to a buffer containing the above description.
3854f645668Schristos    */
3864f645668Schristos 
3874f645668Schristos   extern char *hwc_hwcentry_string (char *buf, size_t buflen, const Hwcentry *ctr);
3884f645668Schristos   /* Get a i18n'd description of a HW counter's options.
3894f645668Schristos    *   Examples of well-known counters:
3904f645668Schristos    *     cycles[/{0|1}],9999991 ('CPU Cycles', alias for Cycle_cnt; CPU-cycles)
3914f645668Schristos    *     dcr[/0],1000003 ('D$ Read Refs', alias for DC_rd; load events)
3924f645668Schristos    *   Examples of raw counters:
3934f645668Schristos    *     Cycle_cnt[/{0|1}],1000003 (CPU-cycles)
3944f645668Schristos    *     DC_rd[/0],1000003 (load events)
3954f645668Schristos    * Return: <buf>, filled in.
3964f645668Schristos    */
3974f645668Schristos 
3984f645668Schristos   extern char *hwc_hwcentry_specd_string (char *buf, size_t buflen, const Hwcentry *ctr);
3994f645668Schristos   /* Get a i18n'd description of a HW counter's specific configuration.
4004f645668Schristos    *   Examples of well-known counters:
4014f645668Schristos    *     cycles,9999991 ('CPU Cycles')
4024f645668Schristos    *     +dcr/0,1000003 ('D$ Read Refs')
4034f645668Schristos    *   Examples of raw counters:
4044f645668Schristos    *     Cycle_cnt,1000003
4054f645668Schristos    *     +DC_rd/0,1000003
4064f645668Schristos    * Return: <buf>, filled in.
4074f645668Schristos    */
4084f645668Schristos 
4094f645668Schristos   extern const char *hwc_memop_string (ABST_type memop);
4104f645668Schristos   /* Get a i18n'd description of a variable of type ABST_type.
4114f645668Schristos    * Return: pointer to static string.
4124f645668Schristos    */
4134f645668Schristos 
4144f645668Schristos #ifdef __cplusplus
4154f645668Schristos }
4164f645668Schristos #endif
4174f645668Schristos 
4184f645668Schristos #endif
419