packaging: update version to 1.4.0
[platform/upstream/oprofile.git] / utils / ophelp.c
1 /**
2  * @file ophelp.c
3  * Print out PMC event information
4  *
5  * @remark Copyright 2002 OProfile authors
6  * @remark Read the file COPYING
7  *
8  * @author John Levon
9  * @author Philippe Elie
10  */
11
12 #define _GNU_SOURCE
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <limits.h>
17
18 #include "op_version.h"
19 #include "op_events.h"
20 #include "op_popt.h"
21 #include "op_cpufreq.h"
22 #include "op_hw_config.h"
23 #include "op_string.h"
24 #include "op_alloc_counter.h"
25 #include "op_parse_event.h"
26 #include "op_libiberty.h"
27 #include "op_xml_events.h"
28
29 static char const ** chosen_events;
30 static int num_chosen_events;
31 struct parsed_event * parsed_events;
32 static op_cpu cpu_type = CPU_NO_GOOD;
33 static char * cpu_string;
34 static int callgraph_depth;
35 static int want_xml;
36 static int ignore_count;
37
38 static poptContext optcon;
39
40
41 /// return the Hamming weight (number of set bits)
42 static size_t hweight(size_t mask)
43 {
44         size_t count = 0;
45
46         while (mask) {
47                 mask &= mask - 1;
48                 count++;
49         }
50
51         return count;
52 }
53
54 #define LINE_LEN 99
55
56 static void word_wrap(int indent, int *column, char *msg)
57 {
58         while (*msg) {
59                 int wlen = strcspn(msg, " ");
60                 if (*column + wlen > LINE_LEN) {
61                         printf("\n%*s", indent, "");
62                         *column = indent;
63                 }
64                 printf("%.*s", wlen, msg);
65                 *column += wlen + 1;
66                 msg += wlen;
67                 wlen = strspn(msg, " ");
68                 msg += wlen;
69                 if (wlen != 0)
70                         putchar(' ');
71         }
72 }
73
74 /**
75  * help_for_event - output event name and description
76  * @param i  event number
77  *
78  * output an help string for the event @i
79  */
80 static void help_for_event(struct op_event * event)
81 {
82         int column;
83         uint i, j;
84         uint mask;
85         size_t nr_counters;
86         char buf[32];
87
88         nr_counters = op_get_nr_counters(cpu_type);
89
90         /* Sanity check */
91         if (!event)
92                 return;
93
94         printf("%s", event->name);
95
96         if(event->counter_mask != 0) {
97                 printf(": (counter: ");
98
99                 mask = event->counter_mask;
100                 if (hweight(mask) == nr_counters) {
101                         printf("all");
102                 } else {
103                         for (i = 0; i < CHAR_BIT * sizeof(event->counter_mask); ++i) {
104                                 if (mask & (1 << i)) {
105                                         printf("%d", i);
106                                         mask &= ~(1 << i);
107                                         if (mask)
108                                                 printf(", ");
109                                 }
110                         }
111                 }
112         } else  if (event->ext != NULL) {
113                 /* Handling extended feature interface */
114                 printf(": (ext: %s", event->ext);
115         } else {
116                 /* Handling arch_perfmon case */
117                 printf(": (counter: all");
118         }   
119
120         printf(")\n\t");
121         column = 8;
122         word_wrap(8, &column, event->desc);
123         snprintf(buf, sizeof buf, " (min count: %d)", event->min_count);
124         word_wrap(8, &column, buf);
125         putchar('\n');
126
127         if (strcmp(event->unit->name, "zero")) {
128
129                 if (event->unit->default_mask_name) {
130                         printf("\tUnit masks (default %s)\n",
131                                event->unit->default_mask_name);
132                 } else {
133                         printf("\tUnit masks (default 0x%x)\n",
134                                event->unit->default_mask);
135                 }
136                 printf("\t----------\n");
137
138                 for (j = 0; j < event->unit->num; j++) {
139                         printf("\t0x%.2x: ",
140                                event->unit->um[j].value);
141                         column = 14;
142
143                         /* Named mask */
144                         if (event->unit->um[j].name) {
145                                 word_wrap(14, &column, "(name=");
146                                 word_wrap(14, &column,
147                                         event->unit->um[j].name);
148                                 word_wrap(14, &column, ") ");
149                         }
150
151                         word_wrap(14, &column, event->unit->um[j].desc);
152                         putchar('\n');
153                 }
154         }
155 }
156
157
158 static void check_event(struct parsed_event * pev,
159                         struct op_event const * event)
160 {
161         int ret;
162         int min_count;
163         int const callgraph_min_count_scale = 15;
164
165         if (!event) {
166                 event = find_event_by_name(pev->name, 0, 0);
167                 if (event)
168                         fprintf(stderr, "Invalid unit mask %x for event %s\n",
169                                 pev->unit_mask, pev->name);
170                 else
171                         fprintf(stderr, "No event named %s is available.\n",
172                                 pev->name);
173                 exit(EXIT_FAILURE);
174         }
175
176         op_resolve_unit_mask(pev, NULL);
177
178         // If a named UM is passed, op_resolve_unit_mask will resolve that into a
179         // valid unit mask, so we don't need to call op_check_events.
180         if (pev->unit_mask_name)
181                 ret = 0;
182         else
183                 ret = op_check_events(pev->name, 0, event->val, pev->unit_mask, cpu_type);
184
185         if (ret & OP_INVALID_UM) {
186                 fprintf(stderr, "Invalid unit mask 0x%x for event %s\n",
187                         pev->unit_mask, pev->name);
188                 exit(EXIT_FAILURE);
189         }
190
191         min_count = event->min_count;
192         if (callgraph_depth)
193                 min_count *= callgraph_min_count_scale;
194         if (!ignore_count && pev->count < min_count) {
195                 fprintf(stderr, "Count %d for event %s is below the "
196                         "minimum %d\n", pev->count, pev->name, min_count);
197                 exit(EXIT_FAILURE);
198         }
199 }
200
201
202 static void resolve_events(void)
203 {
204         size_t count, count_events;
205         size_t i, j;
206         size_t * counter_map;
207         size_t nr_counters = op_get_nr_counters(cpu_type);
208         struct op_event const * selected_events[num_chosen_events];
209
210         count = parse_events(parsed_events, num_chosen_events, chosen_events,
211                              ignore_count ? 0 : 1);
212
213         for (i = 0; i < count; ++i) {
214                 op_resolve_unit_mask(&parsed_events[i], NULL);
215                 for (j = i + 1; j < count; ++j) {
216                         struct parsed_event * pev1 = &parsed_events[i];
217                         struct parsed_event * pev2 = &parsed_events[j];
218
219                         if (!strcmp(pev1->name, pev2->name) &&
220                             pev1->count == pev2->count &&
221                             pev1->unit_mask == pev2->unit_mask &&
222                             pev1->kernel == pev2->kernel &&
223                             pev1->user == pev2->user) {
224                                 fprintf(stderr, "All events must be distinct.\n");
225                                 exit(EXIT_FAILURE);
226                         }
227                 }
228         }
229
230         for (i = 0, count_events = 0; i < count; ++i) {
231                 struct parsed_event * pev = &parsed_events[i];
232
233                 /* For 0 unit mask always do wild card match */
234                 selected_events[i] = find_event_by_name(pev->name, pev->unit_mask,
235                                         pev->unit_mask ? pev->unit_mask_valid : 0);
236                 check_event(pev, selected_events[i]);
237
238                 if (selected_events[i]->ext == NULL) {
239                         count_events++;
240                 }
241         }
242         if (count_events > nr_counters) {
243                 fprintf(stderr, "Not enough hardware counters. "
244                                 "Need %lu counters but only has %lu.\n",
245                                 (unsigned long) count_events,
246                                 (unsigned long) nr_counters);
247                 exit(EXIT_FAILURE);
248         }
249
250         counter_map = map_event_to_counter(selected_events, count, cpu_type);
251
252         if (!counter_map) {
253                 fprintf(stderr, "Couldn't allocate hardware counters for the selected events.\n");
254                 exit(EXIT_FAILURE);
255         }
256
257         for (i = 0; i < count; ++i)
258                 if(counter_map[i] == (size_t)-1)
259                         if (selected_events[i]->ext != NULL)
260                                 printf("%s ", (char*) selected_events[i]->ext);
261                         else
262                                 printf("N/A ");
263                 else
264                         printf("%d ", (unsigned int) counter_map[i]);
265         printf("\n");
266
267         free(counter_map);
268 }
269
270
271 static void show_unit_mask(void)
272 {
273         size_t count;
274
275         count = parse_events(parsed_events, num_chosen_events, chosen_events, ignore_count ? 0 : 1);
276         if (count > 1) {
277                 fprintf(stderr, "More than one event specified.\n");
278                 exit(EXIT_FAILURE);
279         }
280
281         op_resolve_unit_mask(parsed_events, NULL);
282         if (parsed_events[0].unit_mask_name)
283                 printf("%s\n", parsed_events[0].unit_mask_name);
284         else
285                 printf("%d\n", parsed_events[0].unit_mask);
286 }
287
288 static void show_extra_mask(void)
289 {
290         size_t count;
291         unsigned extra = 0;
292
293         count = parse_events(parsed_events, num_chosen_events, chosen_events, ignore_count ? 0 : 1);
294         if (count > 1) {
295                 fprintf(stderr, "More than one event specified.\n");
296                 exit(EXIT_FAILURE);
297         }
298
299         op_resolve_unit_mask(parsed_events, &extra);
300         printf ("%d\n", extra);
301 }
302
303 static void show_default_event(void)
304 {
305         struct op_default_event_descr descr;
306
307         op_default_event(cpu_type, &descr);
308
309         if (descr.name[0] == '\0')
310                 return;
311
312         printf("%s:%lu:%lu:1:1\n", descr.name, descr.count, descr.um);
313 }
314
315
316 static int show_vers;
317 static int get_cpu_type;
318 static int check_events;
319 static int unit_mask;
320 static int get_default_event;
321 static int extra_mask;
322
323 static struct poptOption options[] = {
324         { "cpu-type", 'c', POPT_ARG_STRING, &cpu_string, 0,
325           "use the given CPU type", "cpu type", },
326         { "check-events", 'e', POPT_ARG_NONE, &check_events, 0,
327           "check the given event descriptions for validity", NULL, },
328         { "ignore-count", 'i', POPT_ARG_NONE, &ignore_count, 0,
329           "do not validate count value (used by ocount)", NULL},
330         { "unit-mask", 'u', POPT_ARG_NONE, &unit_mask, 0,
331           "default unit mask for the given event", NULL, },
332         { "get-cpu-type", 'r', POPT_ARG_NONE, &get_cpu_type, 0,
333           "show the auto-detected CPU type", NULL, },
334         { "get-default-event", 'd', POPT_ARG_NONE, &get_default_event, 0,
335           "get the default event", NULL, },
336         { "callgraph", '\0', POPT_ARG_INT, &callgraph_depth, 0,
337           "use this callgraph depth", "callgraph depth", },
338         { "version", 'v', POPT_ARG_NONE, &show_vers, 0,
339            "show version", NULL, },
340         { "xml", 'X', POPT_ARG_NONE, &want_xml, 0,
341            "list events as XML", NULL, },
342         { "extra-mask", 'E', POPT_ARG_NONE, &extra_mask, 0,
343           "print extra mask for event", NULL, },
344         POPT_AUTOHELP
345         { NULL, 0, 0, NULL, 0, NULL, NULL, },
346 };
347
348 /**
349  * get_options - process command line
350  * @param argc  program arg count
351  * @param argv  program arg array
352  *
353  * Process the arguments, fatally complaining on error.
354  */
355 static void get_options(int argc, char const * argv[])
356 {
357         optcon = op_poptGetContext(NULL, argc, argv, options, 0);
358
359         if (show_vers)
360                 show_version(argv[0]);
361
362         /* non-option, must be a valid event name or event specs */
363         chosen_events = poptGetArgs(optcon);
364
365         if(chosen_events) {
366                 num_chosen_events = 0;
367                 while (chosen_events[num_chosen_events] != NULL)
368                         num_chosen_events++;
369         }
370
371         /* don't free the context now, we need chosen_events */
372 }
373
374
375 /** make valgrind happy */
376 static void cleanup(void)
377 {
378         int i;
379         if (parsed_events) {
380                 for (i = 0; i < num_chosen_events; ++i) {
381                         if (parsed_events[i].name)
382                                 free(parsed_events[i].name);
383                 }
384         }
385         op_free_events();
386         if (optcon)
387                 poptFreeContext(optcon);
388         if (parsed_events)
389                 free(parsed_events);
390 }
391
392
393 #define MAX_LINE 256
394 int main(int argc, char const * argv[])
395 {
396         struct list_head * events;
397         struct list_head * pos;
398         char const * pretty;
399         char title[10 * MAX_LINE];
400         char const * event_doc = "";
401
402         atexit(cleanup);
403
404         get_options(argc, argv);
405
406         /* usefull for testing purpose to allow to force the cpu type
407          * with --cpu-type */
408         if (cpu_string) {
409                 cpu_type = op_get_cpu_number(cpu_string);
410         } else {
411                 cpu_type = op_get_cpu_type();
412         }
413
414         if (cpu_type == CPU_NO_GOOD) {
415                 fprintf(stderr, "cpu_type '%s' is not valid\n",
416                         cpu_string ? cpu_string : "unset");
417                 fprintf(stderr, "you should upgrade oprofile or force the "
418                         "use of timer mode\n");
419                 exit(EXIT_FAILURE);
420         }
421
422         parsed_events = (struct parsed_event *)xcalloc(num_chosen_events,
423                 sizeof(struct parsed_event));
424
425         pretty = op_get_cpu_type_str(cpu_type);
426
427         if (get_cpu_type) {
428                 printf("%s\n", pretty);
429                 exit(EXIT_SUCCESS);
430         }
431
432         if (get_default_event) {
433                 show_default_event();
434                 exit(EXIT_SUCCESS);
435         }
436
437         if (cpu_type == CPU_TIMER_INT) {
438                 if (!check_events) {
439                         printf("CPU type 'timer' was detected, but this is no longer a supported mode for oprofile.\n"
440                                "Ensure the obsolete opcontrol profiler (available in pre-1.0 oprofile releases)\n"
441                                "is not running on the system.  To check for this, look for the file\n"
442                                "/dev/oprofile/cpu_type; if this file exists, locate the pre-1.0 oprofile\n"
443                                "installation, and use its 'opcontrol' command with the --deinit option.\n");
444                 }
445                 exit(EXIT_SUCCESS);
446         }
447
448         events = op_events(cpu_type);
449
450         if (!chosen_events && (unit_mask || check_events || extra_mask)) {
451                 fprintf(stderr, "No events given.\n");
452                 exit(EXIT_FAILURE);
453         }
454
455         if (unit_mask) {
456                 show_unit_mask();
457                 exit(EXIT_SUCCESS);
458         }
459
460         if (extra_mask) {
461                 show_extra_mask();
462                 exit(EXIT_SUCCESS);
463         }
464
465         if (check_events) {
466                 resolve_events();
467                 exit(EXIT_SUCCESS);
468         }
469
470         /* without --check-events, the only argument must be an event name */
471         if (chosen_events && chosen_events[0]) {
472                 if (chosen_events[1]) {
473                         fprintf(stderr, "Too many arguments.\n");
474                         exit(EXIT_FAILURE);
475                 }
476
477                 list_for_each(pos, events) {
478                         struct op_event * event = list_entry(pos, struct op_event, event_next);
479
480                         if (strcmp(event->name, chosen_events[0]) == 0) {
481                                 char const * map = find_mapping_for_event(event->val, cpu_type);
482                                 if (map) {
483                                         printf("%d %s\n", event->val, map);
484                                 } else {
485                                         printf("%d\n", event->val);
486                                 }
487                                 exit(EXIT_SUCCESS);
488                         }
489                 }
490                 fprintf(stderr, "No such event \"%s\"\n", chosen_events[0]);
491                 exit(EXIT_FAILURE);
492         }
493
494         /* default: list all events */
495
496         switch (cpu_type) {
497         case CPU_HAMMER:
498                 event_doc =
499                         "See BIOS and Kernel Developer's Guide for AMD Athlon and AMD Opteron Processors\n"
500                         "(26094.pdf), Section 10.2\n\n";
501                 break;
502         case CPU_FAMILY10:
503                 event_doc =
504                         "See BIOS and Kernel Developer's Guide for AMD Family 10h Processors\n"
505                         "(31116.pdf), Section 3.14\n\n";
506                 break;
507         case CPU_FAMILY11H:
508                 event_doc =
509                         "See BIOS and Kernel Developer's Guide for AMD Family 11h Processors\n"
510                         "(41256.pdf), Section 3.14\n\n";
511                 break;
512         case CPU_FAMILY12H:
513                 event_doc =
514                         "See BIOS and Kernel Developer's Guide for AMD Family 12h Processors\n";
515                 break;
516         case CPU_FAMILY14H:
517                 event_doc =
518                         "See BIOS and Kernel Developer's Guide for AMD Family 14h Processors\n";
519                 break;
520         case CPU_FAMILY15H:
521                 event_doc =
522                         "See BIOS and Kernel Developer's Guide for AMD Family 15h Processors\n";
523                 break;
524         case CPU_AMD64_GENERIC:
525                 event_doc =
526                         "See BIOS and Kernel Developer's Guide for AMD Processors\n";
527                 break;
528         case CPU_ATHLON:
529                 event_doc =
530                         "See AMD Athlon Processor x86 Code Optimization Guide\n"
531                         "(22007.pdf), Appendix D\n\n";
532                 break;
533         case CPU_PPRO:
534         case CPU_PII:
535         case CPU_PIII:
536         case CPU_P6_MOBILE:
537         case CPU_P4:
538         case CPU_P4_HT2:
539         case CPU_CORE:
540         case CPU_CORE_2:
541         case CPU_CORE_I7:
542         case CPU_NEHALEM:
543         case CPU_HASWELL:
544         case CPU_BROADWELL:
545         case CPU_SKYLAKE:
546         case CPU_SILVERMONT:
547         case CPU_GOLDMONT:
548         case CPU_GOLDMONTPLUS:
549         case CPU_WESTMERE:
550         case CPU_SANDYBRIDGE:
551         case CPU_IVYBRIDGE:
552         case CPU_ATOM:
553                 event_doc =
554                         "See Intel Architecture Developer's Manual Volume 3B, Appendix A and\n"
555                         "Intel Architecture Optimization Reference Manual\n\n";
556                 break;
557
558         case CPU_KNIGHTSLANDING:
559                 event_doc =
560                         "See Intel Xeon Phi(TM) Processor Performance Monitoring Reference and\n"
561                         "Intel Architecture Optimization Reference Manual\n\n";
562                 break;
563
564         case CPU_ARCH_PERFMON:
565                 event_doc =
566                         "See Intel 64 and IA-32 Architectures Software Developer's Manual\n"
567                         "Volume 3B Chapter 18 for architectural perfmon events\n"
568                         "This is a limited set of fallback events because oprofile doesn't know your CPU\n";
569                 break;
570         
571         case CPU_AXP_EV67:
572                 event_doc =
573                         "See Alpha Architecture Reference Manual\n"
574                         "http://download.majix.org/dec/alpha_arch_ref.pdf\n";
575                 break;
576         case CPU_ARM_XSCALE1:
577         case CPU_ARM_XSCALE2:
578                 event_doc =
579                         "See Intel XScale Core Developer's Manual\n"
580                         "Chapter 8 Performance Monitoring\n";
581                 break;
582         case CPU_ARM_MPCORE:
583                 event_doc =
584                         "See ARM11 MPCore Processor Technical Reference Manual r1p0\n"
585                         "Page 3-70, performance counters\n";
586                 break;
587
588         case CPU_ARM_V6:
589                 event_doc = "See ARM11 Technical Reference Manual\n";
590                 break;
591
592         case CPU_ARM_V7:
593                 event_doc =
594                         "See Cortex-A8 Technical Reference Manual\n"
595                         "Cortex A8 DDI (ARM DDI 0344B, revision r1p1)\n";
596                 break;
597
598         case CPU_ARM_SCORPION:
599                 event_doc =
600                         "See ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition\n"
601                         "Scorpion Processor Family Programmer's Reference Manual (PRM)\n";
602                 break;
603
604         case CPU_ARM_SCORPIONMP:
605                 event_doc =
606                         "See ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition\n"
607                         "Scorpion Processor Family Programmer's Reference Manual (PRM)\n";
608                 break;
609
610         case CPU_ARM_KRAIT:
611                 event_doc =
612                         "See ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition\n"
613                         "Krait Processor Family Programmer's Reference Manual (PRM)\n";
614                 break;
615
616         case CPU_ARM_V7_CA9:
617                 event_doc =
618                         "See Cortex-A9 Technical Reference Manual\n"
619                         "Cortex A9 DDI (ARM DDI 0388E, revision r2p0)\n";
620                 break;
621
622         case CPU_ARM_V7_CA5:
623                 event_doc =
624                         "See Cortex-A5 Technical Reference Manual\n"
625                         "Cortex A5 DDI (ARM DDI 0433B, revision r0p1)\n";
626                 break;
627
628         case CPU_ARM_V7_CA7:
629                 event_doc =
630                         "See Cortex-A7 MPCore Technical Reference Manual\n"
631                         "Cortex A7 DDI (ARM DDI 0464D, revision r0p3)\n";
632                 break;
633
634         case CPU_ARM_V7_CA15:
635                 event_doc =
636                         "See Cortex-A15 MPCore Technical Reference Manual\n"
637                         "Cortex A15 DDI (ARM DDI 0438F, revision r3p1)\n";
638                 break;
639
640         case CPU_ARM_V7_CA17:
641                 event_doc =
642                         "See Cortex-A17 MPCore Technical Reference Manual\n"
643                         "Cortex A17 DDI (ARM DDI 0535C, revision r1p1)\n";
644                 break;
645
646         case CPU_ARM_V8_APM_XGENE:
647                 event_doc =
648                         "See ARM Architecture Reference Manual \n"
649                         "ARMv8, for ARMv8-A architecture profile\n"
650                         "DDI (ARM DDI0487A.a)\n";
651                 break;
652
653         case CPU_ARM_V8_CA57:
654                 event_doc =
655                         "See Cortex-A57 MPCore Technical Reference Manual\n"
656                         "Cortex A57 DDI (ARM DDI 0488D, revision r1p1)\n";
657                 break;
658
659         case CPU_ARM_V8_CA53:
660                 event_doc =
661                         "See Cortex-A53 MPCore Technical Reference Manual\n"
662                         "Cortex A57 DDI (ARM DDI 0500D, revision r0p2)\n";
663                 break;
664
665         case CPU_ARM_V8_CAVIUM_THUNDERX2:
666                 event_doc =
667                         "See ARM Architecture Reference Manual \n"
668                         "ARMv8, for ARMv8-A architecture profile\n"
669                         "DDI (ARM DDI0487D.a)\n";
670                 break;
671
672         case CPU_PPC64_POWER4:
673         case CPU_PPC64_POWER5:
674         case CPU_PPC64_POWER6:
675         case CPU_PPC64_POWER5p:
676         case CPU_PPC64_POWER5pp:
677         case CPU_PPC64_970:
678         case CPU_PPC64_970MP:
679         case CPU_PPC64_POWER7:
680                 event_doc =
681                         "When using operf, events may be specified without a '_GRP<n>' suffix.\n"
682                         "If _GRP<n> (i.e., group number) is not specified, one will be automatically\n"
683                         "selected for use by the profiler.  OProfile post-processing tools will\n"
684                         "always show real event names that include the group number suffix.\n\n"
685                         "Documentation for IBM POWER7 can be obtained at:\n"
686                         "http://www.power.org/events/Power7/\n"
687                         "No public performance monitoring doc available for older processors.\n";
688                 break;
689
690         case CPU_PPC64_ARCH_V1:
691         case CPU_PPC64_POWER8:
692                 event_doc =
693                         "This processor type is fully supported with operf.\n"
694                         "See Power ISA 3.0B at "
695                         "https://openpowerfoundation.org/?submit=Search&s=ISA \n"
696                         "And the P8 Users Manual at "
697                         "https://www-355.ibm.com/systems/power/openpower \n\n";
698                 break;
699
700         case CPU_PPC64_POWER9:
701                 event_doc =
702                         "This processor type is fully supported with operf.\n"
703                         "See Power ISA 3.0B at "
704                         "https://openpowerfoundation.org/?resource_lib=power-isa-version-3-0\n";
705                 break;
706
707         case CPU_MIPS_20K:
708                 event_doc =
709                         "See Programming the MIPS64 20Kc Processor Core User's "
710                 "manual available from www.mips.com\n";
711                 break;
712         case CPU_MIPS_24K:
713                 event_doc =
714                         "See Programming the MIPS32 24K Core "
715                         "available from www.mips.com\n";
716                 break;
717         case CPU_MIPS_25K:
718                 event_doc =
719                         "See Programming the MIPS64 25Kf Processor Core User's "
720                         "manual available from www.mips.com\n";
721                 break;
722         case CPU_MIPS_34K:
723                 event_doc =
724                         "See Programming the MIPS32 34K Core Family "
725                         "available from www.mips.com\n";
726                 break;
727         case CPU_MIPS_74K:
728                 event_doc =
729                         "See Programming the MIPS32 74K Core Family "
730                         "available from www.mips.com\n";
731                 break;
732         case CPU_MIPS_1004K:
733                 event_doc =
734                         "See Programming the MIPS32 1004K Core Family "
735                         "available from www.mips.com\n";
736                 break;
737         case CPU_MIPS_5K:
738                 event_doc =
739                         "See Programming the MIPS64 5K Processor Core Family "
740                         "Software User's manual available from www.mips.com\n";
741                 break;
742         case CPU_MIPS_R10000:
743         case CPU_MIPS_R12000:
744                 event_doc =
745                         "See NEC R10000 / R12000 User's Manual\n"
746                         "http://www.necelam.com/docs/files/U10278EJ3V0UM00.pdf\n";
747                 break;
748         case CPU_MIPS_RM7000:
749                 event_doc =
750                         "See RM7000 Family User Manual "
751                         "available from www.pmc-sierra.com\n";
752                 break;
753         case CPU_MIPS_RM9000:
754                 event_doc =
755                         "See RM9000x2 Family User Manual "
756                         "available from www.pmc-sierra.com\n";
757                 break;
758         case CPU_MIPS_SB1:
759         case CPU_MIPS_VR5432:
760                 event_doc =
761                         "See NEC VR5443 User's Manual, Volume 1\n"
762                         "http://www.necelam.com/docs/files/1375_V1.pdf\n";
763                 break;
764         case CPU_MIPS_VR5500:
765                 event_doc =
766                         "See NEC R10000 / R12000 User's Manual\n"
767                         "http://www.necel.com/nesdis/image/U16677EJ3V0UM00.pdf\n";
768                 break;
769
770         case CPU_MIPS_LOONGSON2:
771                 event_doc = 
772                         "See loongson2 RISC Microprocessor Family Reference Manual\n";
773                 break;
774
775         case CPU_PPC_E500:
776         case CPU_PPC_E500_2:
777         case CPU_PPC_E500MC:
778         case CPU_PPC_E6500:
779                 event_doc =
780                         "See PowerPC e500 Core Complex Reference Manual\n"
781                         "Chapter 7: Performance Monitor\n"
782                         "Downloadable from http://www.freescale.com\n";
783                 break;
784
785         case CPU_PPC_E300:
786                 event_doc =
787                         "See PowerPC e300 Core Reference Manual\n"
788                         "Downloadable from http://www.freescale.com\n";
789                 break;
790
791         case CPU_PPC_7450:
792                 event_doc =
793                         "See MPC7450 RISC Microprocessor Family Reference "
794                         "Manual\n"
795                         "Chapter 11: Performance Monitor\n"
796                         "Downloadable from http://www.freescale.com\n";
797                 break;
798
799         case CPU_TILE_TILE64:
800         case CPU_TILE_TILEPRO:
801         case CPU_TILE_TILEGX:
802                 event_doc =
803                         "See Tilera development doc: Multicore Development "
804                         "Environment Optimization Guide.\n"
805                         "Contact Tilera Corporation or visit "
806                         "http://www.tilera.com for more information.\n";
807                 break;
808
809         case CPU_S390_Z10:
810         case CPU_S390_Z196:
811         case CPU_S390_ZEC12:
812         case CPU_S390_Z13:
813                 event_doc = "IBM System z CPU Measurement Facility\n"
814                                 "http://www-01.ibm.com/support/docview.wss"
815                                 "?uid=isg26fcd1cc32246f4c8852574ce0044734a\n";
816                 break;
817
818         // don't use default, if someone add a cpu he wants a compiler warning
819         // if he forgets to handle it here.
820         case CPU_TIMER_INT:
821         case CPU_NO_GOOD:
822         case MAX_CPU_TYPE:
823                 printf("%d is not a valid processor type.\n", cpu_type);
824                 exit(EXIT_FAILURE);
825         }
826
827         sprintf(title, "oprofile: available events for CPU type \"%s\"\n\n", pretty);
828         if (want_xml)
829                 open_xml_events(title, event_doc, cpu_type);
830         else {
831                 printf("%s%s", title, event_doc);
832                 printf("For architectures using unit masks, you may be able to specify\n"
833                        "unit masks by name.  See 'operf' or 'ocount' man page for more details.\n\n");
834         }
835
836         list_for_each(pos, events) {
837                 struct op_event * event = list_entry(pos, struct op_event, event_next);
838                 if (want_xml) 
839                         xml_help_for_event(event);
840                 else
841                         help_for_event(event);
842         }
843
844         if (want_xml)
845                 close_xml_events();
846
847         return EXIT_SUCCESS;
848 }