parse-events.y 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. %name-prefix "parse_events_"
  2. %parse-param {struct list_head *list}
  3. %parse-param {int *idx}
  4. %{
  5. #define YYDEBUG 1
  6. #include <linux/compiler.h>
  7. #include <linux/list.h>
  8. #include "types.h"
  9. #include "util.h"
  10. #include "parse-events.h"
  11. extern int parse_events_lex (void);
  12. #define ABORT_ON(val) \
  13. do { \
  14. if (val) \
  15. YYABORT; \
  16. } while (0)
  17. %}
  18. %token PE_VALUE PE_VALUE_SYM PE_RAW
  19. %token PE_NAME
  20. %token PE_MODIFIER_EVENT PE_MODIFIER_BP
  21. %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
  22. %token PE_PREFIX_MEM PE_PREFIX_RAW
  23. %token PE_ERROR
  24. %type <num> PE_VALUE
  25. %type <num> PE_VALUE_SYM
  26. %type <num> PE_RAW
  27. %type <str> PE_NAME
  28. %type <str> PE_NAME_CACHE_TYPE
  29. %type <str> PE_NAME_CACHE_OP_RESULT
  30. %type <str> PE_MODIFIER_EVENT
  31. %type <str> PE_MODIFIER_BP
  32. %union
  33. {
  34. char *str;
  35. unsigned long num;
  36. }
  37. %%
  38. events:
  39. events ',' event | event
  40. event:
  41. event_def PE_MODIFIER_EVENT
  42. {
  43. ABORT_ON(parse_events_modifier(list, $2));
  44. }
  45. |
  46. event_def
  47. event_def: event_legacy_symbol sep_dc |
  48. event_legacy_cache sep_dc |
  49. event_legacy_mem |
  50. event_legacy_tracepoint sep_dc |
  51. event_legacy_numeric sep_dc |
  52. event_legacy_raw sep_dc
  53. event_legacy_symbol:
  54. PE_VALUE_SYM
  55. {
  56. int type = $1 >> 16;
  57. int config = $1 & 255;
  58. ABORT_ON(parse_events_add_numeric(list, idx, type, config));
  59. }
  60. event_legacy_cache:
  61. PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
  62. {
  63. ABORT_ON(parse_events_add_cache(list, idx, $1, $3, $5));
  64. }
  65. |
  66. PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
  67. {
  68. ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL));
  69. }
  70. |
  71. PE_NAME_CACHE_TYPE
  72. {
  73. ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL));
  74. }
  75. event_legacy_mem:
  76. PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
  77. {
  78. ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4));
  79. }
  80. |
  81. PE_PREFIX_MEM PE_VALUE sep_dc
  82. {
  83. ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL));
  84. }
  85. event_legacy_tracepoint:
  86. PE_NAME ':' PE_NAME
  87. {
  88. ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3));
  89. }
  90. event_legacy_numeric:
  91. PE_VALUE ':' PE_VALUE
  92. {
  93. ABORT_ON(parse_events_add_numeric(list, idx, $1, $3));
  94. }
  95. event_legacy_raw:
  96. PE_RAW
  97. {
  98. ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1));
  99. }
  100. sep_dc: ':' |
  101. %%
  102. void parse_events_error(struct list_head *list __used, int *idx __used,
  103. char const *msg __used)
  104. {
  105. }