Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / stap-probe.c
CommitLineData
55aa24fb
SDJ
1/* SystemTap probe support for GDB.
2
3666a048 3 Copyright (C) 2012-2021 Free Software Foundation, Inc.
55aa24fb
SDJ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "stap-probe.h"
22#include "probe.h"
55aa24fb
SDJ
23#include "ui-out.h"
24#include "objfiles.h"
25#include "arch-utils.h"
26#include "command.h"
27#include "gdbcmd.h"
28#include "filenames.h"
29#include "value.h"
55aa24fb
SDJ
30#include "ax.h"
31#include "ax-gdb.h"
32#include "complaints.h"
33#include "cli/cli-utils.h"
34#include "linespec.h"
35#include "user-regs.h"
36#include "parser-defs.h"
37#include "language.h"
38#include "elf-bfd.h"
4c5e7a93
TT
39#include "expop.h"
40#include <unordered_map>
675da9a5 41#include "gdbsupport/hash_enum.h"
55aa24fb
SDJ
42
43#include <ctype.h>
44
45/* The name of the SystemTap section where we will find information about
46 the probes. */
47
48#define STAP_BASE_SECTION_NAME ".stapsdt.base"
49
55aa24fb
SDJ
50/* Should we display debug information for the probe's argument expression
51 parsing? */
52
ccce17b0 53static unsigned int stap_expression_debug = 0;
55aa24fb
SDJ
54
55/* The various possibilities of bitness defined for a probe's argument.
56
57 The relationship is:
58
59 - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
30a1e6cc
SDJ
60 - STAP_ARG_BITNESS_8BIT_UNSIGNED: argument string starts with `1@'.
61 - STAP_ARG_BITNESS_8BIT_SIGNED: argument string starts with `-1@'.
62 - STAP_ARG_BITNESS_16BIT_UNSIGNED: argument string starts with `2@'.
63 - STAP_ARG_BITNESS_16BIT_SIGNED: argument string starts with `-2@'.
55aa24fb
SDJ
64 - STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'.
65 - STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'.
66 - STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'.
67 - STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */
68
69enum stap_arg_bitness
70{
71 STAP_ARG_BITNESS_UNDEFINED,
30a1e6cc
SDJ
72 STAP_ARG_BITNESS_8BIT_UNSIGNED,
73 STAP_ARG_BITNESS_8BIT_SIGNED,
74 STAP_ARG_BITNESS_16BIT_UNSIGNED,
75 STAP_ARG_BITNESS_16BIT_SIGNED,
55aa24fb
SDJ
76 STAP_ARG_BITNESS_32BIT_UNSIGNED,
77 STAP_ARG_BITNESS_32BIT_SIGNED,
78 STAP_ARG_BITNESS_64BIT_UNSIGNED,
79 STAP_ARG_BITNESS_64BIT_SIGNED,
80};
81
82/* The following structure represents a single argument for the probe. */
83
84struct stap_probe_arg
85{
0e9ae10f
SDJ
86 /* Constructor for stap_probe_arg. */
87 stap_probe_arg (enum stap_arg_bitness bitness_, struct type *atype_,
88 expression_up &&aexpr_)
89 : bitness (bitness_), atype (atype_), aexpr (std::move (aexpr_))
90 {}
91
55aa24fb
SDJ
92 /* The bitness of this argument. */
93 enum stap_arg_bitness bitness;
94
95 /* The corresponding `struct type *' to the bitness. */
96 struct type *atype;
97
98 /* The argument converted to an internal GDB expression. */
0e9ae10f 99 expression_up aexpr;
55aa24fb
SDJ
100};
101
0e9ae10f 102/* Class that implements the static probe methods for "stap" probes. */
55aa24fb 103
0e9ae10f 104class stap_static_probe_ops : public static_probe_ops
55aa24fb 105{
0e9ae10f 106public:
4212d509
TT
107 /* We need a user-provided constructor to placate some compilers.
108 See PR build/24937. */
109 stap_static_probe_ops ()
110 {
111 }
112
0e9ae10f
SDJ
113 /* See probe.h. */
114 bool is_linespec (const char **linespecp) const override;
55aa24fb 115
0e9ae10f 116 /* See probe.h. */
814cf43a 117 void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
0e9ae10f
SDJ
118 struct objfile *objfile) const override;
119
120 /* See probe.h. */
121 const char *type_name () const override;
122
123 /* See probe.h. */
124 std::vector<struct info_probe_column> gen_info_probes_table_header
125 () const override;
126};
127
128/* SystemTap static_probe_ops. */
129
3dcfdc58 130const stap_static_probe_ops stap_static_probe_ops {};
0e9ae10f
SDJ
131
132class stap_probe : public probe
133{
134public:
135 /* Constructor for stap_probe. */
136 stap_probe (std::string &&name_, std::string &&provider_, CORE_ADDR address_,
137 struct gdbarch *arch_, CORE_ADDR sem_addr, const char *args_text)
138 : probe (std::move (name_), std::move (provider_), address_, arch_),
139 m_sem_addr (sem_addr),
140 m_have_parsed_args (false), m_unparsed_args_text (args_text)
141 {}
142
143 /* See probe.h. */
144 CORE_ADDR get_relocated_address (struct objfile *objfile) override;
145
146 /* See probe.h. */
fe01123e 147 unsigned get_argument_count (struct gdbarch *gdbarch) override;
0e9ae10f
SDJ
148
149 /* See probe.h. */
150 bool can_evaluate_arguments () const override;
151
152 /* See probe.h. */
153 struct value *evaluate_argument (unsigned n,
154 struct frame_info *frame) override;
155
156 /* See probe.h. */
157 void compile_to_ax (struct agent_expr *aexpr,
158 struct axs_value *axs_value,
159 unsigned n) override;
160
161 /* See probe.h. */
162 void set_semaphore (struct objfile *objfile,
163 struct gdbarch *gdbarch) override;
164
165 /* See probe.h. */
166 void clear_semaphore (struct objfile *objfile,
167 struct gdbarch *gdbarch) override;
168
169 /* See probe.h. */
170 const static_probe_ops *get_static_ops () const override;
171
172 /* See probe.h. */
173 std::vector<const char *> gen_info_probes_table_values () const override;
174
175 /* Return argument N of probe.
176
177 If the probe's arguments have not been parsed yet, parse them. If
178 there are no arguments, throw an exception (error). Otherwise,
179 return the requested argument. */
180 struct stap_probe_arg *get_arg_by_number (unsigned n,
181 struct gdbarch *gdbarch)
182 {
183 if (!m_have_parsed_args)
184 this->parse_arguments (gdbarch);
185
186 gdb_assert (m_have_parsed_args);
187 if (m_parsed_args.empty ())
188 internal_error (__FILE__, __LINE__,
189 _("Probe '%s' apparently does not have arguments, but \n"
190 "GDB is requesting its argument number %u anyway. "
191 "This should not happen. Please report this bug."),
192 this->get_name ().c_str (), n);
193
194 if (n > m_parsed_args.size ())
195 internal_error (__FILE__, __LINE__,
196 _("Probe '%s' has %d arguments, but GDB is requesting\n"
197 "argument %u. This should not happen. Please\n"
198 "report this bug."),
199 this->get_name ().c_str (),
200 (int) m_parsed_args.size (), n);
201
202 return &m_parsed_args[n];
203 }
204
205 /* Function which parses an argument string from the probe,
206 correctly splitting the arguments and storing their information
207 in properly ways.
208
209 Consider the following argument string (x86 syntax):
210
211 `4@%eax 4@$10'
212
213 We have two arguments, `%eax' and `$10', both with 32-bit
214 unsigned bitness. This function basically handles them, properly
215 filling some structures with this information. */
216 void parse_arguments (struct gdbarch *gdbarch);
217
218private:
55aa24fb 219 /* If the probe has a semaphore associated, then this is the value of
729662a5 220 it, relative to SECT_OFF_DATA. */
0e9ae10f 221 CORE_ADDR m_sem_addr;
55aa24fb 222
0e9ae10f
SDJ
223 /* True if the arguments have been parsed. */
224 bool m_have_parsed_args;
97c2dca0 225
0e9ae10f
SDJ
226 /* The text version of the probe's arguments, unparsed. */
227 const char *m_unparsed_args_text;
55aa24fb 228
0e9ae10f
SDJ
229 /* Information about each argument. This is an array of `stap_probe_arg',
230 with each entry representing one argument. This is only valid if
231 M_ARGS_PARSED is true. */
232 std::vector<struct stap_probe_arg> m_parsed_args;
55aa24fb
SDJ
233};
234
235/* When parsing the arguments, we have to establish different precedences
236 for the various kinds of asm operators. This enumeration represents those
237 precedences.
238
239 This logic behind this is available at
240 <http://sourceware.org/binutils/docs/as/Infix-Ops.html#Infix-Ops>, or using
241 the command "info '(as)Infix Ops'". */
242
243enum stap_operand_prec
244{
245 /* Lowest precedence, used for non-recognized operands or for the beginning
246 of the parsing process. */
247 STAP_OPERAND_PREC_NONE = 0,
248
249 /* Precedence of logical OR. */
250 STAP_OPERAND_PREC_LOGICAL_OR,
251
252 /* Precedence of logical AND. */
253 STAP_OPERAND_PREC_LOGICAL_AND,
254
255 /* Precedence of additive (plus, minus) and comparative (equal, less,
256 greater-than, etc) operands. */
257 STAP_OPERAND_PREC_ADD_CMP,
258
259 /* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND,
260 logical NOT). */
261 STAP_OPERAND_PREC_BITWISE,
262
263 /* Precedence of multiplicative operands (multiplication, division,
264 remainder, left shift and right shift). */
265 STAP_OPERAND_PREC_MUL
266};
267
4c5e7a93
TT
268static expr::operation_up stap_parse_argument_1 (struct stap_parse_info *p,
269 expr::operation_up &&lhs,
270 enum stap_operand_prec prec)
271 ATTRIBUTE_UNUSED_RESULT;
55aa24fb 272
4c5e7a93
TT
273static expr::operation_up stap_parse_argument_conditionally
274 (struct stap_parse_info *p) ATTRIBUTE_UNUSED_RESULT;
55aa24fb 275
af2d9bee 276/* Returns true if *S is an operator, false otherwise. */
55aa24fb 277
af2d9bee 278static bool stap_is_operator (const char *op);
55aa24fb
SDJ
279
280static void
281show_stapexpressiondebug (struct ui_file *file, int from_tty,
282 struct cmd_list_element *c, const char *value)
283{
284 fprintf_filtered (file, _("SystemTap Probe expression debugging is %s.\n"),
285 value);
286}
287
288/* Returns the operator precedence level of OP, or STAP_OPERAND_PREC_NONE
289 if the operator code was not recognized. */
290
291static enum stap_operand_prec
292stap_get_operator_prec (enum exp_opcode op)
293{
294 switch (op)
295 {
296 case BINOP_LOGICAL_OR:
297 return STAP_OPERAND_PREC_LOGICAL_OR;
298
299 case BINOP_LOGICAL_AND:
300 return STAP_OPERAND_PREC_LOGICAL_AND;
301
302 case BINOP_ADD:
303 case BINOP_SUB:
304 case BINOP_EQUAL:
305 case BINOP_NOTEQUAL:
306 case BINOP_LESS:
307 case BINOP_LEQ:
308 case BINOP_GTR:
309 case BINOP_GEQ:
310 return STAP_OPERAND_PREC_ADD_CMP;
311
312 case BINOP_BITWISE_IOR:
313 case BINOP_BITWISE_AND:
314 case BINOP_BITWISE_XOR:
315 case UNOP_LOGICAL_NOT:
316 return STAP_OPERAND_PREC_BITWISE;
317
318 case BINOP_MUL:
319 case BINOP_DIV:
320 case BINOP_REM:
321 case BINOP_LSH:
322 case BINOP_RSH:
323 return STAP_OPERAND_PREC_MUL;
324
325 default:
326 return STAP_OPERAND_PREC_NONE;
327 }
328}
329
3ca58cde
SDJ
330/* Given S, read the operator in it. Return the EXP_OPCODE which
331 represents the operator detected, or throw an error if no operator
332 was found. */
55aa24fb 333
fcf57f19
SDJ
334static enum exp_opcode
335stap_get_opcode (const char **s)
55aa24fb
SDJ
336{
337 const char c = **s;
fcf57f19 338 enum exp_opcode op;
55aa24fb
SDJ
339
340 *s += 1;
341
342 switch (c)
343 {
344 case '*':
fcf57f19 345 op = BINOP_MUL;
55aa24fb
SDJ
346 break;
347
348 case '/':
fcf57f19 349 op = BINOP_DIV;
55aa24fb
SDJ
350 break;
351
352 case '%':
fcf57f19 353 op = BINOP_REM;
55aa24fb
SDJ
354 break;
355
356 case '<':
fcf57f19 357 op = BINOP_LESS;
55aa24fb
SDJ
358 if (**s == '<')
359 {
360 *s += 1;
fcf57f19 361 op = BINOP_LSH;
55aa24fb
SDJ
362 }
363 else if (**s == '=')
364 {
365 *s += 1;
fcf57f19 366 op = BINOP_LEQ;
55aa24fb
SDJ
367 }
368 else if (**s == '>')
369 {
370 *s += 1;
fcf57f19 371 op = BINOP_NOTEQUAL;
55aa24fb
SDJ
372 }
373 break;
374
375 case '>':
fcf57f19 376 op = BINOP_GTR;
55aa24fb
SDJ
377 if (**s == '>')
378 {
379 *s += 1;
fcf57f19 380 op = BINOP_RSH;
55aa24fb
SDJ
381 }
382 else if (**s == '=')
383 {
384 *s += 1;
fcf57f19 385 op = BINOP_GEQ;
55aa24fb
SDJ
386 }
387 break;
388
389 case '|':
fcf57f19 390 op = BINOP_BITWISE_IOR;
55aa24fb
SDJ
391 if (**s == '|')
392 {
393 *s += 1;
fcf57f19 394 op = BINOP_LOGICAL_OR;
55aa24fb
SDJ
395 }
396 break;
397
398 case '&':
fcf57f19 399 op = BINOP_BITWISE_AND;
55aa24fb
SDJ
400 if (**s == '&')
401 {
402 *s += 1;
fcf57f19 403 op = BINOP_LOGICAL_AND;
55aa24fb
SDJ
404 }
405 break;
406
407 case '^':
fcf57f19 408 op = BINOP_BITWISE_XOR;
55aa24fb
SDJ
409 break;
410
411 case '!':
fcf57f19 412 op = UNOP_LOGICAL_NOT;
55aa24fb
SDJ
413 break;
414
415 case '+':
fcf57f19 416 op = BINOP_ADD;
55aa24fb
SDJ
417 break;
418
419 case '-':
fcf57f19 420 op = BINOP_SUB;
55aa24fb
SDJ
421 break;
422
423 case '=':
fcf57f19
SDJ
424 gdb_assert (**s == '=');
425 op = BINOP_EQUAL;
55aa24fb
SDJ
426 break;
427
428 default:
f469e8ce
SDJ
429 error (_("Invalid opcode in expression `%s' for SystemTap"
430 "probe"), *s);
55aa24fb
SDJ
431 }
432
fcf57f19 433 return op;
55aa24fb
SDJ
434}
435
4c5e7a93
TT
436typedef expr::operation_up binop_maker_ftype (expr::operation_up &&,
437 expr::operation_up &&);
438/* Map from an expression opcode to a function that can create a
439 binary operation of that type. */
675da9a5
TT
440static std::unordered_map<exp_opcode, binop_maker_ftype *,
441 gdb::hash_enum<exp_opcode>> stap_maker_map;
4c5e7a93
TT
442
443/* Helper function to create a binary operation. */
444static expr::operation_up
445stap_make_binop (enum exp_opcode opcode, expr::operation_up &&lhs,
446 expr::operation_up &&rhs)
447{
448 auto iter = stap_maker_map.find (opcode);
449 gdb_assert (iter != stap_maker_map.end ());
450 return iter->second (std::move (lhs), std::move (rhs));
451}
452
55aa24fb 453/* Given the bitness of the argument, represented by B, return the
3ca58cde
SDJ
454 corresponding `struct type *', or throw an error if B is
455 unknown. */
55aa24fb
SDJ
456
457static struct type *
458stap_get_expected_argument_type (struct gdbarch *gdbarch,
f469e8ce 459 enum stap_arg_bitness b,
0e9ae10f 460 const char *probe_name)
55aa24fb
SDJ
461{
462 switch (b)
463 {
464 case STAP_ARG_BITNESS_UNDEFINED:
465 if (gdbarch_addr_bit (gdbarch) == 32)
466 return builtin_type (gdbarch)->builtin_uint32;
467 else
468 return builtin_type (gdbarch)->builtin_uint64;
469
30a1e6cc
SDJ
470 case STAP_ARG_BITNESS_8BIT_UNSIGNED:
471 return builtin_type (gdbarch)->builtin_uint8;
472
473 case STAP_ARG_BITNESS_8BIT_SIGNED:
474 return builtin_type (gdbarch)->builtin_int8;
475
476 case STAP_ARG_BITNESS_16BIT_UNSIGNED:
477 return builtin_type (gdbarch)->builtin_uint16;
478
479 case STAP_ARG_BITNESS_16BIT_SIGNED:
480 return builtin_type (gdbarch)->builtin_int16;
481
55aa24fb
SDJ
482 case STAP_ARG_BITNESS_32BIT_SIGNED:
483 return builtin_type (gdbarch)->builtin_int32;
484
485 case STAP_ARG_BITNESS_32BIT_UNSIGNED:
486 return builtin_type (gdbarch)->builtin_uint32;
487
488 case STAP_ARG_BITNESS_64BIT_SIGNED:
489 return builtin_type (gdbarch)->builtin_int64;
490
491 case STAP_ARG_BITNESS_64BIT_UNSIGNED:
492 return builtin_type (gdbarch)->builtin_uint64;
493
494 default:
0e9ae10f 495 error (_("Undefined bitness for probe '%s'."), probe_name);
55aa24fb
SDJ
496 break;
497 }
498}
499
05c0465e
SDJ
500/* Helper function to check for a generic list of prefixes. GDBARCH
501 is the current gdbarch being used. S is the expression being
502 analyzed. If R is not NULL, it will be used to return the found
503 prefix. PREFIXES is the list of expected prefixes.
504
505 This function does a case-insensitive match.
506
af2d9bee 507 Return true if any prefix has been found, false otherwise. */
05c0465e 508
af2d9bee 509static bool
05c0465e
SDJ
510stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
511 const char **r, const char *const *prefixes)
512{
513 const char *const *p;
514
515 if (prefixes == NULL)
516 {
517 if (r != NULL)
518 *r = "";
519
af2d9bee 520 return true;
05c0465e
SDJ
521 }
522
523 for (p = prefixes; *p != NULL; ++p)
97c2dca0
SDJ
524 if (strncasecmp (s, *p, strlen (*p)) == 0)
525 {
526 if (r != NULL)
527 *r = *p;
05c0465e 528
af2d9bee 529 return true;
97c2dca0 530 }
05c0465e 531
af2d9bee 532 return false;
05c0465e
SDJ
533}
534
af2d9bee
SDJ
535/* Return true if S points to a register prefix, false otherwise. For
536 a description of the arguments, look at stap_is_generic_prefix. */
05c0465e 537
af2d9bee 538static bool
05c0465e
SDJ
539stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
540 const char **r)
541{
542 const char *const *t = gdbarch_stap_register_prefixes (gdbarch);
543
544 return stap_is_generic_prefix (gdbarch, s, r, t);
545}
546
af2d9bee 547/* Return true if S points to a register indirection prefix, false
05c0465e
SDJ
548 otherwise. For a description of the arguments, look at
549 stap_is_generic_prefix. */
550
af2d9bee 551static bool
05c0465e
SDJ
552stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
553 const char **r)
554{
555 const char *const *t = gdbarch_stap_register_indirection_prefixes (gdbarch);
556
557 return stap_is_generic_prefix (gdbarch, s, r, t);
558}
559
af2d9bee
SDJ
560/* Return true if S points to an integer prefix, false otherwise. For
561 a description of the arguments, look at stap_is_generic_prefix.
05c0465e
SDJ
562
563 This function takes care of analyzing whether we are dealing with
564 an expected integer prefix, or, if there is no integer prefix to be
565 expected, whether we are dealing with a digit. It does a
566 case-insensitive match. */
567
af2d9bee 568static bool
05c0465e
SDJ
569stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
570 const char **r)
571{
572 const char *const *t = gdbarch_stap_integer_prefixes (gdbarch);
573 const char *const *p;
574
575 if (t == NULL)
576 {
577 /* A NULL value here means that integers do not have a prefix.
578 We just check for a digit then. */
579 if (r != NULL)
580 *r = "";
581
af2d9bee 582 return isdigit (*s) > 0;
05c0465e
SDJ
583 }
584
585 for (p = t; *p != NULL; ++p)
586 {
587 size_t len = strlen (*p);
588
589 if ((len == 0 && isdigit (*s))
590 || (len > 0 && strncasecmp (s, *p, len) == 0))
591 {
592 /* Integers may or may not have a prefix. The "len == 0"
593 check covers the case when integers do not have a prefix
594 (therefore, we just check if we have a digit). The call
595 to "strncasecmp" covers the case when they have a
596 prefix. */
597 if (r != NULL)
598 *r = *p;
599
af2d9bee 600 return true;
05c0465e
SDJ
601 }
602 }
603
af2d9bee 604 return false;
05c0465e
SDJ
605}
606
607/* Helper function to check for a generic list of suffixes. If we are
608 not expecting any suffixes, then it just returns 1. If we are
af2d9bee
SDJ
609 expecting at least one suffix, then it returns true if a suffix has
610 been found, false otherwise. GDBARCH is the current gdbarch being
05c0465e
SDJ
611 used. S is the expression being analyzed. If R is not NULL, it
612 will be used to return the found suffix. SUFFIXES is the list of
613 expected suffixes. This function does a case-insensitive
614 match. */
615
af2d9bee 616static bool
05c0465e
SDJ
617stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
618 const char **r, const char *const *suffixes)
619{
620 const char *const *p;
af2d9bee 621 bool found = false;
05c0465e
SDJ
622
623 if (suffixes == NULL)
624 {
625 if (r != NULL)
626 *r = "";
627
af2d9bee 628 return true;
05c0465e
SDJ
629 }
630
631 for (p = suffixes; *p != NULL; ++p)
632 if (strncasecmp (s, *p, strlen (*p)) == 0)
633 {
634 if (r != NULL)
635 *r = *p;
636
af2d9bee 637 found = true;
05c0465e
SDJ
638 break;
639 }
640
641 return found;
642}
643
af2d9bee
SDJ
644/* Return true if S points to an integer suffix, false otherwise. For
645 a description of the arguments, look at
05c0465e
SDJ
646 stap_generic_check_suffix. */
647
af2d9bee 648static bool
05c0465e
SDJ
649stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
650 const char **r)
651{
652 const char *const *p = gdbarch_stap_integer_suffixes (gdbarch);
653
654 return stap_generic_check_suffix (gdbarch, s, r, p);
655}
656
af2d9bee
SDJ
657/* Return true if S points to a register suffix, false otherwise. For
658 a description of the arguments, look at
05c0465e
SDJ
659 stap_generic_check_suffix. */
660
af2d9bee 661static bool
05c0465e
SDJ
662stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
663 const char **r)
664{
665 const char *const *p = gdbarch_stap_register_suffixes (gdbarch);
666
667 return stap_generic_check_suffix (gdbarch, s, r, p);
668}
669
af2d9bee 670/* Return true if S points to a register indirection suffix, false
05c0465e
SDJ
671 otherwise. For a description of the arguments, look at
672 stap_generic_check_suffix. */
673
af2d9bee 674static bool
05c0465e
SDJ
675stap_check_register_indirection_suffix (struct gdbarch *gdbarch, const char *s,
676 const char **r)
677{
678 const char *const *p = gdbarch_stap_register_indirection_suffixes (gdbarch);
679
680 return stap_generic_check_suffix (gdbarch, s, r, p);
681}
682
55aa24fb
SDJ
683/* Function responsible for parsing a register operand according to
684 SystemTap parlance. Assuming:
685
686 RP = register prefix
687 RS = register suffix
688 RIP = register indirection prefix
689 RIS = register indirection suffix
690
691 Then a register operand can be:
692
693 [RIP] [RP] REGISTER [RS] [RIS]
694
695 This function takes care of a register's indirection, displacement and
696 direct access. It also takes into consideration the fact that some
697 registers are named differently inside and outside GDB, e.g., PPC's
698 general-purpose registers are represented by integers in the assembly
699 language (e.g., `15' is the 15th general-purpose register), but inside
700 GDB they have a prefix (the letter `r') appended. */
701
4c5e7a93 702static expr::operation_up
55aa24fb
SDJ
703stap_parse_register_operand (struct stap_parse_info *p)
704{
705 /* Simple flag to indicate whether we have seen a minus signal before
706 certain number. */
af2d9bee 707 bool got_minus = false;
4c5e7a93 708 /* Flag to indicate whether this register access is being
55aa24fb 709 indirected. */
af2d9bee 710 bool indirect_p = false;
55aa24fb 711 struct gdbarch *gdbarch = p->gdbarch;
55aa24fb
SDJ
712 /* Variables used to extract the register name from the probe's
713 argument. */
714 const char *start;
55aa24fb 715 const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
55aa24fb 716 const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
05c0465e
SDJ
717 const char *reg_prefix;
718 const char *reg_ind_prefix;
719 const char *reg_suffix;
720 const char *reg_ind_suffix;
55aa24fb 721
4c5e7a93
TT
722 using namespace expr;
723
55aa24fb
SDJ
724 /* Checking for a displacement argument. */
725 if (*p->arg == '+')
726 {
727 /* If it's a plus sign, we don't need to do anything, just advance the
728 pointer. */
729 ++p->arg;
730 }
f1bb75ab 731 else if (*p->arg == '-')
55aa24fb 732 {
af2d9bee 733 got_minus = true;
55aa24fb
SDJ
734 ++p->arg;
735 }
736
4c5e7a93
TT
737 struct type *long_type = builtin_type (gdbarch)->builtin_long;
738 operation_up disp_op;
55aa24fb
SDJ
739 if (isdigit (*p->arg))
740 {
741 /* The value of the displacement. */
742 long displacement;
a0bcdaa7 743 char *endp;
55aa24fb 744
a0bcdaa7
PA
745 displacement = strtol (p->arg, &endp, 10);
746 p->arg = endp;
55aa24fb
SDJ
747
748 /* Generating the expression for the displacement. */
55aa24fb 749 if (got_minus)
4c5e7a93
TT
750 displacement = -displacement;
751 disp_op = make_operation<long_const_operation> (long_type, displacement);
55aa24fb
SDJ
752 }
753
754 /* Getting rid of register indirection prefix. */
05c0465e 755 if (stap_is_register_indirection_prefix (gdbarch, p->arg, &reg_ind_prefix))
55aa24fb 756 {
af2d9bee 757 indirect_p = true;
05c0465e 758 p->arg += strlen (reg_ind_prefix);
55aa24fb
SDJ
759 }
760
4c5e7a93 761 if (disp_op != nullptr && !indirect_p)
55aa24fb
SDJ
762 error (_("Invalid register displacement syntax on expression `%s'."),
763 p->saved_arg);
764
765 /* Getting rid of register prefix. */
05c0465e
SDJ
766 if (stap_is_register_prefix (gdbarch, p->arg, &reg_prefix))
767 p->arg += strlen (reg_prefix);
55aa24fb
SDJ
768
769 /* Now we should have only the register name. Let's extract it and get
770 the associated number. */
771 start = p->arg;
772
773 /* We assume the register name is composed by letters and numbers. */
774 while (isalnum (*p->arg))
775 ++p->arg;
776
677052f2 777 std::string regname (start, p->arg - start);
55aa24fb
SDJ
778
779 /* We only add the GDB's register prefix/suffix if we are dealing with
780 a numeric register. */
677052f2 781 if (isdigit (*start))
55aa24fb 782 {
677052f2
SDJ
783 if (gdb_reg_prefix != NULL)
784 regname = gdb_reg_prefix + regname;
55aa24fb 785
677052f2
SDJ
786 if (gdb_reg_suffix != NULL)
787 regname += gdb_reg_suffix;
55aa24fb 788 }
55aa24fb 789
7d7571f0
SDJ
790 int regnum = user_reg_map_name_to_regnum (gdbarch, regname.c_str (),
791 regname.size ());
792
55aa24fb 793 /* Is this a valid register name? */
7d7571f0 794 if (regnum == -1)
55aa24fb 795 error (_("Invalid register name `%s' on expression `%s'."),
677052f2 796 regname.c_str (), p->saved_arg);
55aa24fb 797
7d7571f0
SDJ
798 /* Check if there's any special treatment that the arch-specific
799 code would like to perform on the register name. */
800 if (gdbarch_stap_adjust_register_p (gdbarch))
801 {
6b78c3f8
AB
802 std::string newregname
803 = gdbarch_stap_adjust_register (gdbarch, p, regname, regnum);
7d7571f0 804
6b78c3f8 805 if (regname != newregname)
7d7571f0
SDJ
806 {
807 /* This is just a check we perform to make sure that the
808 arch-dependent code has provided us with a valid
809 register name. */
6b78c3f8
AB
810 regnum = user_reg_map_name_to_regnum (gdbarch, newregname.c_str (),
811 newregname.size ());
7d7571f0
SDJ
812
813 if (regnum == -1)
814 internal_error (__FILE__, __LINE__,
815 _("Invalid register name '%s' after replacing it"
816 " (previous name was '%s')"),
6b78c3f8
AB
817 newregname.c_str (), regname.c_str ());
818
4c5e7a93 819 regname = std::move (newregname);
7d7571f0
SDJ
820 }
821 }
822
4c5e7a93 823 operation_up reg = make_operation<register_operation> (std::move (regname));
55aa24fb
SDJ
824
825 if (indirect_p)
826 {
4c5e7a93
TT
827 if (disp_op != nullptr)
828 reg = make_operation<add_operation> (std::move (disp_op),
829 std::move (reg));
55aa24fb
SDJ
830
831 /* Casting to the expected type. */
4c5e7a93
TT
832 struct type *arg_ptr_type = lookup_pointer_type (p->arg_type);
833 reg = make_operation<unop_cast_operation> (std::move (reg),
834 arg_ptr_type);
835 reg = make_operation<unop_ind_operation> (std::move (reg));
55aa24fb
SDJ
836 }
837
838 /* Getting rid of the register name suffix. */
05c0465e
SDJ
839 if (stap_check_register_suffix (gdbarch, p->arg, &reg_suffix))
840 p->arg += strlen (reg_suffix);
841 else
842 error (_("Missing register name suffix on expression `%s'."),
843 p->saved_arg);
55aa24fb
SDJ
844
845 /* Getting rid of the register indirection suffix. */
05c0465e 846 if (indirect_p)
55aa24fb 847 {
05c0465e
SDJ
848 if (stap_check_register_indirection_suffix (gdbarch, p->arg,
849 &reg_ind_suffix))
850 p->arg += strlen (reg_ind_suffix);
851 else
852 error (_("Missing indirection suffix on expression `%s'."),
853 p->saved_arg);
55aa24fb 854 }
4c5e7a93
TT
855
856 return reg;
55aa24fb
SDJ
857}
858
859/* This function is responsible for parsing a single operand.
860
861 A single operand can be:
862
863 - an unary operation (e.g., `-5', `~2', or even with subexpressions
dda83cd7 864 like `-(2 + 1)')
55aa24fb 865 - a register displacement, which will be treated as a register
dda83cd7 866 operand (e.g., `-4(%eax)' on x86)
55aa24fb
SDJ
867 - a numeric constant, or
868 - a register operand (see function `stap_parse_register_operand')
869
870 The function also calls special-handling functions to deal with
871 unrecognized operands, allowing arch-specific parsers to be
872 created. */
873
4c5e7a93 874static expr::operation_up
55aa24fb
SDJ
875stap_parse_single_operand (struct stap_parse_info *p)
876{
877 struct gdbarch *gdbarch = p->gdbarch;
05c0465e 878 const char *int_prefix = NULL;
55aa24fb 879
4c5e7a93
TT
880 using namespace expr;
881
55aa24fb 882 /* We first try to parse this token as a "special token". */
4c5e7a93 883 if (gdbarch_stap_parse_special_token_p (gdbarch))
f1bb75ab 884 {
4c5e7a93
TT
885 operation_up token = gdbarch_stap_parse_special_token (gdbarch, p);
886 if (token != nullptr)
887 return token;
f1bb75ab 888 }
55aa24fb 889
4c5e7a93
TT
890 struct type *long_type = builtin_type (gdbarch)->builtin_long;
891 operation_up result;
6f52fdf4 892 if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!')
55aa24fb
SDJ
893 {
894 char c = *p->arg;
55aa24fb
SDJ
895 /* We use this variable to do a lookahead. */
896 const char *tmp = p->arg;
af2d9bee 897 bool has_digit = false;
55aa24fb 898
97c2dca0 899 /* Skipping signal. */
55aa24fb
SDJ
900 ++tmp;
901
902 /* This is an unary operation. Here is a list of allowed tokens
903 here:
904
905 - numeric literal;
906 - number (from register displacement)
907 - subexpression (beginning with `(')
908
909 We handle the register displacement here, and the other cases
910 recursively. */
911 if (p->inside_paren_p)
f1735a53 912 tmp = skip_spaces (tmp);
55aa24fb 913
474ca4f6 914 while (isdigit (*tmp))
a0bcdaa7 915 {
474ca4f6
SDJ
916 /* We skip the digit here because we are only interested in
917 knowing what kind of unary operation this is. The digit
918 will be handled by one of the functions that will be
919 called below ('stap_parse_argument_conditionally' or
920 'stap_parse_register_operand'). */
921 ++tmp;
af2d9bee 922 has_digit = true;
a0bcdaa7 923 }
55aa24fb 924
474ca4f6
SDJ
925 if (has_digit && stap_is_register_indirection_prefix (gdbarch, tmp,
926 NULL))
55aa24fb
SDJ
927 {
928 /* If we are here, it means it is a displacement. The only
929 operations allowed here are `-' and `+'. */
f1bb75ab 930 if (c != '-' && c != '+')
55aa24fb
SDJ
931 error (_("Invalid operator `%c' for register displacement "
932 "on expression `%s'."), c, p->saved_arg);
933
4c5e7a93 934 result = stap_parse_register_operand (p);
55aa24fb 935 }
474ca4f6
SDJ
936 else
937 {
938 /* This is not a displacement. We skip the operator, and
939 deal with it when the recursion returns. */
940 ++p->arg;
4c5e7a93 941 result = stap_parse_argument_conditionally (p);
474ca4f6 942 if (c == '-')
4c5e7a93 943 result = make_operation<unary_neg_operation> (std::move (result));
474ca4f6 944 else if (c == '~')
4c5e7a93
TT
945 result = (make_operation<unary_complement_operation>
946 (std::move (result)));
6f52fdf4 947 else if (c == '!')
4c5e7a93
TT
948 result = (make_operation<unary_logical_not_operation>
949 (std::move (result)));
474ca4f6 950 }
55aa24fb
SDJ
951 }
952 else if (isdigit (*p->arg))
953 {
954 /* A temporary variable, needed for lookahead. */
955 const char *tmp = p->arg;
a0bcdaa7 956 char *endp;
55aa24fb
SDJ
957 long number;
958
05c0465e
SDJ
959 /* We can be dealing with a numeric constant, or with a register
960 displacement. */
a0bcdaa7
PA
961 number = strtol (tmp, &endp, 10);
962 tmp = endp;
55aa24fb
SDJ
963
964 if (p->inside_paren_p)
f1735a53 965 tmp = skip_spaces (tmp);
05c0465e
SDJ
966
967 /* If "stap_is_integer_prefix" returns true, it means we can
968 accept integers without a prefix here. But we also need to
969 check whether the next token (i.e., "tmp") is not a register
970 indirection prefix. */
971 if (stap_is_integer_prefix (gdbarch, p->arg, NULL)
972 && !stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
55aa24fb 973 {
05c0465e
SDJ
974 const char *int_suffix;
975
55aa24fb 976 /* We are dealing with a numeric constant. */
4c5e7a93 977 result = make_operation<long_const_operation> (long_type, number);
55aa24fb
SDJ
978
979 p->arg = tmp;
980
05c0465e
SDJ
981 if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
982 p->arg += strlen (int_suffix);
983 else
984 error (_("Invalid constant suffix on expression `%s'."),
985 p->saved_arg);
55aa24fb 986 }
05c0465e 987 else if (stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
4c5e7a93 988 result = stap_parse_register_operand (p);
55aa24fb
SDJ
989 else
990 error (_("Unknown numeric token on expression `%s'."),
991 p->saved_arg);
992 }
05c0465e 993 else if (stap_is_integer_prefix (gdbarch, p->arg, &int_prefix))
55aa24fb
SDJ
994 {
995 /* We are dealing with a numeric constant. */
996 long number;
a0bcdaa7 997 char *endp;
05c0465e 998 const char *int_suffix;
55aa24fb 999
05c0465e 1000 p->arg += strlen (int_prefix);
a0bcdaa7
PA
1001 number = strtol (p->arg, &endp, 10);
1002 p->arg = endp;
55aa24fb 1003
4c5e7a93 1004 result = make_operation<long_const_operation> (long_type, number);
55aa24fb 1005
05c0465e
SDJ
1006 if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
1007 p->arg += strlen (int_suffix);
1008 else
1009 error (_("Invalid constant suffix on expression `%s'."),
1010 p->saved_arg);
55aa24fb 1011 }
05c0465e
SDJ
1012 else if (stap_is_register_prefix (gdbarch, p->arg, NULL)
1013 || stap_is_register_indirection_prefix (gdbarch, p->arg, NULL))
4c5e7a93 1014 result = stap_parse_register_operand (p);
55aa24fb
SDJ
1015 else
1016 error (_("Operator `%c' not recognized on expression `%s'."),
1017 *p->arg, p->saved_arg);
4c5e7a93
TT
1018
1019 return result;
55aa24fb
SDJ
1020}
1021
1022/* This function parses an argument conditionally, based on single or
1023 non-single operands. A non-single operand would be a parenthesized
1024 expression (e.g., `(2 + 1)'), and a single operand is anything that
1025 starts with `-', `~', `+' (i.e., unary operators), a digit, or
1026 something recognized by `gdbarch_stap_is_single_operand'. */
1027
4c5e7a93 1028static expr::operation_up
55aa24fb
SDJ
1029stap_parse_argument_conditionally (struct stap_parse_info *p)
1030{
97c2dca0
SDJ
1031 gdb_assert (gdbarch_stap_is_single_operand_p (p->gdbarch));
1032
4c5e7a93 1033 expr::operation_up result;
6f52fdf4 1034 if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!'
55aa24fb
SDJ
1035 || isdigit (*p->arg)
1036 || gdbarch_stap_is_single_operand (p->gdbarch, p->arg))
4c5e7a93 1037 result = stap_parse_single_operand (p);
55aa24fb
SDJ
1038 else if (*p->arg == '(')
1039 {
1040 /* We are dealing with a parenthesized operand. It means we
1041 have to parse it as it was a separate expression, without
1042 left-side or precedence. */
1043 ++p->arg;
f1735a53 1044 p->arg = skip_spaces (p->arg);
55aa24fb
SDJ
1045 ++p->inside_paren_p;
1046
4c5e7a93 1047 result = stap_parse_argument_1 (p, {}, STAP_OPERAND_PREC_NONE);
55aa24fb 1048
6f52fdf4 1049 p->arg = skip_spaces (p->arg);
55aa24fb 1050 if (*p->arg != ')')
9bb305b3 1051 error (_("Missing close-parenthesis on expression `%s'."),
55aa24fb
SDJ
1052 p->saved_arg);
1053
6f52fdf4 1054 --p->inside_paren_p;
55aa24fb
SDJ
1055 ++p->arg;
1056 if (p->inside_paren_p)
f1735a53 1057 p->arg = skip_spaces (p->arg);
55aa24fb
SDJ
1058 }
1059 else
1060 error (_("Cannot parse expression `%s'."), p->saved_arg);
4c5e7a93
TT
1061
1062 return result;
55aa24fb
SDJ
1063}
1064
1065/* Helper function for `stap_parse_argument'. Please, see its comments to
1066 better understand what this function does. */
1067
4c5e7a93
TT
1068static expr::operation_up ATTRIBUTE_UNUSED_RESULT
1069stap_parse_argument_1 (struct stap_parse_info *p,
1070 expr::operation_up &&lhs_in,
55aa24fb
SDJ
1071 enum stap_operand_prec prec)
1072{
1073 /* This is an operator-precedence parser.
1074
1075 We work with left- and right-sides of expressions, and
1076 parse them depending on the precedence of the operators
1077 we find. */
1078
97c2dca0
SDJ
1079 gdb_assert (p->arg != NULL);
1080
55aa24fb 1081 if (p->inside_paren_p)
f1735a53 1082 p->arg = skip_spaces (p->arg);
55aa24fb 1083
4c5e7a93
TT
1084 using namespace expr;
1085 operation_up lhs = std::move (lhs_in);
1086 if (lhs == nullptr)
55aa24fb
SDJ
1087 {
1088 /* We were called without a left-side, either because this is the
1089 first call, or because we were called to parse a parenthesized
1090 expression. It doesn't really matter; we have to parse the
1091 left-side in order to continue the process. */
4c5e7a93 1092 lhs = stap_parse_argument_conditionally (p);
55aa24fb
SDJ
1093 }
1094
6f52fdf4
SDJ
1095 if (p->inside_paren_p)
1096 p->arg = skip_spaces (p->arg);
1097
55aa24fb
SDJ
1098 /* Start to parse the right-side, and to "join" left and right sides
1099 depending on the operation specified.
1100
1101 This loop shall continue until we run out of characters in the input,
1102 or until we find a close-parenthesis, which means that we've reached
1103 the end of a sub-expression. */
97c2dca0 1104 while (*p->arg != '\0' && *p->arg != ')' && !isspace (*p->arg))
55aa24fb
SDJ
1105 {
1106 const char *tmp_exp_buf;
1107 enum exp_opcode opcode;
1108 enum stap_operand_prec cur_prec;
1109
fcf57f19 1110 if (!stap_is_operator (p->arg))
55aa24fb
SDJ
1111 error (_("Invalid operator `%c' on expression `%s'."), *p->arg,
1112 p->saved_arg);
1113
1114 /* We have to save the current value of the expression buffer because
1115 the `stap_get_opcode' modifies it in order to get the current
1116 operator. If this operator's precedence is lower than PREC, we
1117 should return and not advance the expression buffer pointer. */
1118 tmp_exp_buf = p->arg;
fcf57f19 1119 opcode = stap_get_opcode (&tmp_exp_buf);
55aa24fb
SDJ
1120
1121 cur_prec = stap_get_operator_prec (opcode);
1122 if (cur_prec < prec)
1123 {
1124 /* If the precedence of the operator that we are seeing now is
1125 lower than the precedence of the first operator seen before
1126 this parsing process began, it means we should stop parsing
1127 and return. */
1128 break;
1129 }
1130
1131 p->arg = tmp_exp_buf;
1132 if (p->inside_paren_p)
f1735a53 1133 p->arg = skip_spaces (p->arg);
55aa24fb 1134
6f52fdf4
SDJ
1135 /* Parse the right-side of the expression.
1136
1137 We save whether the right-side is a parenthesized
1138 subexpression because, if it is, we will have to finish
1139 processing this part of the expression before continuing. */
1140 bool paren_subexp = *p->arg == '(';
1141
4c5e7a93 1142 operation_up rhs = stap_parse_argument_conditionally (p);
6f52fdf4
SDJ
1143 if (p->inside_paren_p)
1144 p->arg = skip_spaces (p->arg);
1145 if (paren_subexp)
1146 {
4c5e7a93 1147 lhs = stap_make_binop (opcode, std::move (lhs), std::move (rhs));
6f52fdf4
SDJ
1148 continue;
1149 }
55aa24fb
SDJ
1150
1151 /* While we still have operators, try to parse another
1152 right-side, but using the current right-side as a left-side. */
97c2dca0 1153 while (*p->arg != '\0' && stap_is_operator (p->arg))
55aa24fb
SDJ
1154 {
1155 enum exp_opcode lookahead_opcode;
1156 enum stap_operand_prec lookahead_prec;
1157
1158 /* Saving the current expression buffer position. The explanation
1159 is the same as above. */
1160 tmp_exp_buf = p->arg;
fcf57f19 1161 lookahead_opcode = stap_get_opcode (&tmp_exp_buf);
55aa24fb
SDJ
1162 lookahead_prec = stap_get_operator_prec (lookahead_opcode);
1163
1164 if (lookahead_prec <= prec)
1165 {
1166 /* If we are dealing with an operator whose precedence is lower
1167 than the first one, just abandon the attempt. */
1168 break;
1169 }
1170
4c5e7a93
TT
1171 /* Parse the right-side of the expression, using the current
1172 right-hand-side as the left-hand-side of the new
1173 subexpression. */
1174 rhs = stap_parse_argument_1 (p, std::move (rhs), lookahead_prec);
6f52fdf4
SDJ
1175 if (p->inside_paren_p)
1176 p->arg = skip_spaces (p->arg);
55aa24fb
SDJ
1177 }
1178
4c5e7a93 1179 lhs = stap_make_binop (opcode, std::move (lhs), std::move (rhs));
55aa24fb 1180 }
4c5e7a93
TT
1181
1182 return lhs;
55aa24fb
SDJ
1183}
1184
1185/* Parse a probe's argument.
1186
1187 Assuming that:
1188
1189 LP = literal integer prefix
1190 LS = literal integer suffix
1191
1192 RP = register prefix
1193 RS = register suffix
1194
1195 RIP = register indirection prefix
1196 RIS = register indirection suffix
1197
1198 This routine assumes that arguments' tokens are of the form:
1199
1200 - [LP] NUMBER [LS]
1201 - [RP] REGISTER [RS]
1202 - [RIP] [RP] REGISTER [RS] [RIS]
1203 - If we find a number without LP, we try to parse it as a literal integer
1204 constant (if LP == NULL), or as a register displacement.
1205 - We count parenthesis, and only skip whitespaces if we are inside them.
1206 - If we find an operator, we skip it.
1207
1208 This function can also call a special function that will try to match
0e9ae10f
SDJ
1209 unknown tokens. It will return the expression_up generated from
1210 parsing the argument. */
55aa24fb 1211
0e9ae10f 1212static expression_up
55aa24fb
SDJ
1213stap_parse_argument (const char **arg, struct type *atype,
1214 struct gdbarch *gdbarch)
1215{
55aa24fb 1216 /* We need to initialize the expression buffer, in order to begin
f7088df3
SDJ
1217 our parsing efforts. We use language_c here because we may need
1218 to do pointer arithmetics. */
1201a264 1219 struct stap_parse_info p (*arg, atype, language_def (language_c),
e9d9f57e 1220 gdbarch);
55aa24fb 1221
4c5e7a93
TT
1222 using namespace expr;
1223 operation_up result = stap_parse_argument_1 (&p, {}, STAP_OPERAND_PREC_NONE);
55aa24fb 1224
55aa24fb
SDJ
1225 gdb_assert (p.inside_paren_p == 0);
1226
1227 /* Casting the final expression to the appropriate type. */
4c5e7a93
TT
1228 result = make_operation<unop_cast_operation> (std::move (result), atype);
1229 p.pstate.set_operation (std::move (result));
55aa24fb 1230
f1735a53 1231 p.arg = skip_spaces (p.arg);
55aa24fb
SDJ
1232 *arg = p.arg;
1233
e9d9f57e 1234 return p.pstate.release ();
55aa24fb
SDJ
1235}
1236
0e9ae10f 1237/* Implementation of 'parse_arguments' method. */
55aa24fb 1238
0e9ae10f
SDJ
1239void
1240stap_probe::parse_arguments (struct gdbarch *gdbarch)
55aa24fb
SDJ
1241{
1242 const char *cur;
55aa24fb 1243
0e9ae10f
SDJ
1244 gdb_assert (!m_have_parsed_args);
1245 cur = m_unparsed_args_text;
1246 m_have_parsed_args = true;
55aa24fb 1247
97c2dca0 1248 if (cur == NULL || *cur == '\0' || *cur == ':')
55aa24fb
SDJ
1249 return;
1250
97c2dca0 1251 while (*cur != '\0')
55aa24fb 1252 {
0e9ae10f
SDJ
1253 enum stap_arg_bitness bitness;
1254 bool got_minus = false;
55aa24fb
SDJ
1255
1256 /* We expect to find something like:
1257
1258 N@OP
1259
30a1e6cc 1260 Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so
55aa24fb
SDJ
1261 we check it here. If we don't find it, go to the next
1262 state. */
f33da99a
SDJ
1263 if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@')
1264 || (isdigit (cur[0]) && cur[1] == '@'))
55aa24fb
SDJ
1265 {
1266 if (*cur == '-')
1267 {
1268 /* Discard the `-'. */
1269 ++cur;
0e9ae10f 1270 got_minus = true;
55aa24fb
SDJ
1271 }
1272
30a1e6cc
SDJ
1273 /* Defining the bitness. */
1274 switch (*cur)
55aa24fb 1275 {
30a1e6cc 1276 case '1':
0e9ae10f
SDJ
1277 bitness = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
1278 : STAP_ARG_BITNESS_8BIT_UNSIGNED);
30a1e6cc
SDJ
1279 break;
1280
1281 case '2':
0e9ae10f
SDJ
1282 bitness = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
1283 : STAP_ARG_BITNESS_16BIT_UNSIGNED);
30a1e6cc
SDJ
1284 break;
1285
1286 case '4':
0e9ae10f
SDJ
1287 bitness = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
1288 : STAP_ARG_BITNESS_32BIT_UNSIGNED);
30a1e6cc
SDJ
1289 break;
1290
1291 case '8':
0e9ae10f
SDJ
1292 bitness = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
1293 : STAP_ARG_BITNESS_64BIT_UNSIGNED);
30a1e6cc
SDJ
1294 break;
1295
1296 default:
1297 {
1298 /* We have an error, because we don't expect anything
1299 except 1, 2, 4 and 8. */
1300 warning (_("unrecognized bitness %s%c' for probe `%s'"),
0e9ae10f
SDJ
1301 got_minus ? "`-" : "`", *cur,
1302 this->get_name ().c_str ());
30a1e6cc
SDJ
1303 return;
1304 }
55aa24fb 1305 }
55aa24fb
SDJ
1306 /* Discard the number and the `@' sign. */
1307 cur += 2;
1308 }
f33da99a 1309 else
0e9ae10f 1310 bitness = STAP_ARG_BITNESS_UNDEFINED;
f33da99a 1311
0e9ae10f
SDJ
1312 struct type *atype
1313 = stap_get_expected_argument_type (gdbarch, bitness,
1314 this->get_name ().c_str ());
55aa24fb 1315
0e9ae10f 1316 expression_up expr = stap_parse_argument (&cur, atype, gdbarch);
55aa24fb 1317
55aa24fb 1318 if (stap_expression_debug)
0e9ae10f 1319 dump_prefix_expression (expr.get (), gdb_stdlog);
55aa24fb 1320
0e9ae10f 1321 m_parsed_args.emplace_back (bitness, atype, std::move (expr));
55aa24fb
SDJ
1322
1323 /* Start it over again. */
f1735a53 1324 cur = skip_spaces (cur);
55aa24fb
SDJ
1325 }
1326}
1327
685de8c2
SDJ
1328/* Helper function to relocate an address. */
1329
1330static CORE_ADDR
1331relocate_address (CORE_ADDR address, struct objfile *objfile)
1332{
b3b3bada 1333 return address + objfile->data_section_offset ();
685de8c2
SDJ
1334}
1335
0e9ae10f 1336/* Implementation of the get_relocated_address method. */
729662a5 1337
0e9ae10f
SDJ
1338CORE_ADDR
1339stap_probe::get_relocated_address (struct objfile *objfile)
729662a5 1340{
685de8c2 1341 return relocate_address (this->get_address (), objfile);
729662a5
TT
1342}
1343
55aa24fb
SDJ
1344/* Given PROBE, returns the number of arguments present in that probe's
1345 argument string. */
1346
0e9ae10f 1347unsigned
fe01123e 1348stap_probe::get_argument_count (struct gdbarch *gdbarch)
55aa24fb 1349{
0e9ae10f 1350 if (!m_have_parsed_args)
25f9533e 1351 {
0e9ae10f
SDJ
1352 if (this->can_evaluate_arguments ())
1353 this->parse_arguments (gdbarch);
25f9533e
SDJ
1354 else
1355 {
af2d9bee 1356 static bool have_warned_stap_incomplete = false;
25f9533e
SDJ
1357
1358 if (!have_warned_stap_incomplete)
1359 {
1360 warning (_(
1361"The SystemTap SDT probe support is not fully implemented on this target;\n"
1362"you will not be able to inspect the arguments of the probes.\n"
1363"Please report a bug against GDB requesting a port to this target."));
af2d9bee 1364 have_warned_stap_incomplete = true;
25f9533e
SDJ
1365 }
1366
1367 /* Marking the arguments as "already parsed". */
0e9ae10f 1368 m_have_parsed_args = true;
25f9533e
SDJ
1369 }
1370 }
55aa24fb 1371
0e9ae10f
SDJ
1372 gdb_assert (m_have_parsed_args);
1373 return m_parsed_args.size ();
55aa24fb
SDJ
1374}
1375
af2d9bee
SDJ
1376/* Return true if OP is a valid operator inside a probe argument, or
1377 false otherwise. */
55aa24fb 1378
af2d9bee 1379static bool
fcf57f19 1380stap_is_operator (const char *op)
55aa24fb 1381{
af2d9bee 1382 bool ret = true;
fcf57f19
SDJ
1383
1384 switch (*op)
1385 {
1386 case '*':
1387 case '/':
1388 case '%':
1389 case '^':
1390 case '!':
1391 case '+':
1392 case '-':
1393 case '<':
1394 case '>':
1395 case '|':
1396 case '&':
1397 break;
1398
1399 case '=':
1400 if (op[1] != '=')
af2d9bee 1401 ret = false;
fcf57f19
SDJ
1402 break;
1403
1404 default:
1405 /* We didn't find any operator. */
af2d9bee 1406 ret = false;
fcf57f19
SDJ
1407 }
1408
1409 return ret;
55aa24fb
SDJ
1410}
1411
0e9ae10f 1412/* Implement the `can_evaluate_arguments' method. */
f469e8ce 1413
0e9ae10f
SDJ
1414bool
1415stap_probe::can_evaluate_arguments () const
25f9533e 1416{
0e9ae10f 1417 struct gdbarch *gdbarch = this->get_gdbarch ();
25f9533e
SDJ
1418
1419 /* For SystemTap probes, we have to guarantee that the method
1420 stap_is_single_operand is defined on gdbarch. If it is not, then it
1421 means that argument evaluation is not implemented on this target. */
1422 return gdbarch_stap_is_single_operand_p (gdbarch);
1423}
1424
55aa24fb
SDJ
1425/* Evaluate the probe's argument N (indexed from 0), returning a value
1426 corresponding to it. Assertion is thrown if N does not exist. */
1427
0e9ae10f
SDJ
1428struct value *
1429stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
55aa24fb 1430{
55aa24fb 1431 struct stap_probe_arg *arg;
0e9ae10f 1432 struct gdbarch *gdbarch = get_frame_arch (frame);
55aa24fb 1433
0e9ae10f 1434 arg = this->get_arg_by_number (n, gdbarch);
efd7ff14 1435 return evaluate_expression (arg->aexpr.get (), arg->atype);
55aa24fb
SDJ
1436}
1437
1438/* Compile the probe's argument N (indexed from 0) to agent expression.
1439 Assertion is thrown if N does not exist. */
1440
0e9ae10f
SDJ
1441void
1442stap_probe::compile_to_ax (struct agent_expr *expr, struct axs_value *value,
1443 unsigned n)
55aa24fb 1444{
55aa24fb 1445 struct stap_probe_arg *arg;
55aa24fb 1446
0e9ae10f 1447 arg = this->get_arg_by_number (n, expr->gdbarch);
55aa24fb 1448
1eaebe02 1449 arg->aexpr->op->generate_ax (arg->aexpr.get (), expr, value);
55aa24fb
SDJ
1450
1451 require_rvalue (expr, value);
1452 value->type = arg->atype;
1453}
55aa24fb
SDJ
1454\f
1455
55aa24fb 1456/* Set or clear a SystemTap semaphore. ADDRESS is the semaphore's
0e9ae10f
SDJ
1457 address. SET is zero if the semaphore should be cleared, or one if
1458 it should be set. This is a helper function for
1459 'stap_probe::set_semaphore' and 'stap_probe::clear_semaphore'. */
55aa24fb
SDJ
1460
1461static void
1462stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
1463{
1464 gdb_byte bytes[sizeof (LONGEST)];
1465 /* The ABI specifies "unsigned short". */
1466 struct type *type = builtin_type (gdbarch)->builtin_unsigned_short;
1467 ULONGEST value;
1468
55aa24fb
SDJ
1469 /* Swallow errors. */
1470 if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
1471 {
1472 warning (_("Could not read the value of a SystemTap semaphore."));
1473 return;
1474 }
1475
34877895
PJ
1476 enum bfd_endian byte_order = type_byte_order (type);
1477 value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order);
55aa24fb
SDJ
1478 /* Note that we explicitly don't worry about overflow or
1479 underflow. */
1480 if (set)
1481 ++value;
1482 else
1483 --value;
1484
34877895 1485 store_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order, value);
55aa24fb
SDJ
1486
1487 if (target_write_memory (address, bytes, TYPE_LENGTH (type)) != 0)
1488 warning (_("Could not write the value of a SystemTap semaphore."));
1489}
1490
0e9ae10f 1491/* Implementation of the 'set_semaphore' method.
55aa24fb 1492
0e9ae10f
SDJ
1493 SystemTap semaphores act as reference counters, so calls to this
1494 function must be paired with calls to 'clear_semaphore'.
55aa24fb 1495
0e9ae10f
SDJ
1496 This function and 'clear_semaphore' race with another tool
1497 changing the probes, but that is too rare to care. */
1498
1499void
1500stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
55aa24fb 1501{
7f0ae84c
GB
1502 if (m_sem_addr == 0)
1503 return;
685de8c2 1504 stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 1, gdbarch);
0e9ae10f 1505}
55aa24fb 1506
0e9ae10f 1507/* Implementation of the 'clear_semaphore' method. */
55aa24fb 1508
0e9ae10f
SDJ
1509void
1510stap_probe::clear_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
1511{
7f0ae84c
GB
1512 if (m_sem_addr == 0)
1513 return;
685de8c2 1514 stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 0, gdbarch);
55aa24fb
SDJ
1515}
1516
0e9ae10f 1517/* Implementation of the 'get_static_ops' method. */
55aa24fb 1518
0e9ae10f
SDJ
1519const static_probe_ops *
1520stap_probe::get_static_ops () const
1521{
1522 return &stap_static_probe_ops;
1523}
1524
1525/* Implementation of the 'gen_info_probes_table_values' method. */
1526
1527std::vector<const char *>
1528stap_probe::gen_info_probes_table_values () const
55aa24fb 1529{
0e9ae10f 1530 const char *val = NULL;
55aa24fb 1531
0e9ae10f
SDJ
1532 if (m_sem_addr != 0)
1533 val = print_core_address (this->get_gdbarch (), m_sem_addr);
55aa24fb 1534
0e9ae10f 1535 return std::vector<const char *> { val };
55aa24fb
SDJ
1536}
1537
55aa24fb
SDJ
1538/* Helper function that parses the information contained in a
1539 SystemTap's probe. Basically, the information consists in:
1540
1541 - Probe's PC address;
1542 - Link-time section address of `.stapsdt.base' section;
1543 - Link-time address of the semaphore variable, or ZERO if the
1544 probe doesn't have an associated semaphore;
1545 - Probe's provider name;
1546 - Probe's name;
3ca58cde 1547 - Probe's argument format. */
55aa24fb
SDJ
1548
1549static void
1550handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
814cf43a
TT
1551 std::vector<std::unique_ptr<probe>> *probesp,
1552 CORE_ADDR base)
55aa24fb
SDJ
1553{
1554 bfd *abfd = objfile->obfd;
1555 int size = bfd_get_arch_size (abfd) / 8;
08feed99 1556 struct gdbarch *gdbarch = objfile->arch ();
55aa24fb 1557 struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
55aa24fb
SDJ
1558
1559 /* Provider and the name of the probe. */
0e9ae10f
SDJ
1560 const char *provider = (const char *) &el->data[3 * size];
1561 const char *name = ((const char *)
1562 memchr (provider, '\0',
1563 (char *) el->data + el->size - provider));
55aa24fb 1564 /* Making sure there is a name. */
0e9ae10f 1565 if (name == NULL)
55aa24fb 1566 {
f3da9116 1567 complaint (_("corrupt probe name when reading `%s'"),
4262abfb 1568 objfile_name (objfile));
55aa24fb
SDJ
1569
1570 /* There is no way to use a probe without a name or a provider, so
f3da9116 1571 returning here makes sense. */
55aa24fb
SDJ
1572 return;
1573 }
1574 else
0e9ae10f 1575 ++name;
55aa24fb
SDJ
1576
1577 /* Retrieving the probe's address. */
0e9ae10f 1578 CORE_ADDR address = extract_typed_address (&el->data[0], ptr_type);
55aa24fb
SDJ
1579
1580 /* Link-time sh_addr of `.stapsdt.base' section. */
0e9ae10f 1581 CORE_ADDR base_ref = extract_typed_address (&el->data[size], ptr_type);
55aa24fb
SDJ
1582
1583 /* Semaphore address. */
0e9ae10f 1584 CORE_ADDR sem_addr = extract_typed_address (&el->data[2 * size], ptr_type);
55aa24fb 1585
0e9ae10f
SDJ
1586 address += base - base_ref;
1587 if (sem_addr != 0)
1588 sem_addr += base - base_ref;
55aa24fb
SDJ
1589
1590 /* Arguments. We can only extract the argument format if there is a valid
1591 name for this probe. */
0e9ae10f
SDJ
1592 const char *probe_args = ((const char*)
1593 memchr (name, '\0',
1594 (char *) el->data + el->size - name));
55aa24fb
SDJ
1595
1596 if (probe_args != NULL)
1597 ++probe_args;
1598
97c2dca0 1599 if (probe_args == NULL
0e9ae10f 1600 || (memchr (probe_args, '\0', (char *) el->data + el->size - name)
97c2dca0 1601 != el->data + el->size - 1))
55aa24fb 1602 {
f3da9116 1603 complaint (_("corrupt probe argument when reading `%s'"),
4262abfb 1604 objfile_name (objfile));
55aa24fb 1605 /* If the argument string is NULL, it means some problem happened with
f3da9116 1606 it. So we return. */
55aa24fb
SDJ
1607 return;
1608 }
1609
0e9ae10f
SDJ
1610 stap_probe *ret = new stap_probe (std::string (name), std::string (provider),
1611 address, gdbarch, sem_addr, probe_args);
55aa24fb
SDJ
1612
1613 /* Successfully created probe. */
814cf43a 1614 probesp->emplace_back (ret);
55aa24fb
SDJ
1615}
1616
55aa24fb
SDJ
1617/* Helper function which iterates over every section in the BFD file,
1618 trying to find the base address of the SystemTap base section.
1619 Returns 1 if found (setting BASE to the proper value), zero otherwise. */
1620
1621static int
1622get_stap_base_address (bfd *obfd, bfd_vma *base)
1623{
1624 asection *ret = NULL;
1625
3cabfd26
TT
1626 for (asection *sect : gdb_bfd_sections (obfd))
1627 if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
1628 && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
1629 ret = sect;
55aa24fb 1630
97c2dca0 1631 if (ret == NULL)
55aa24fb 1632 {
b98664d3 1633 complaint (_("could not obtain base address for "
55aa24fb 1634 "SystemTap section on objfile `%s'."),
c7e97679 1635 bfd_get_filename (obfd));
55aa24fb
SDJ
1636 return 0;
1637 }
1638
97c2dca0 1639 if (base != NULL)
55aa24fb
SDJ
1640 *base = ret->vma;
1641
1642 return 1;
1643}
1644
0e9ae10f 1645/* Implementation of the 'is_linespec' method. */
55aa24fb 1646
0e9ae10f
SDJ
1647bool
1648stap_static_probe_ops::is_linespec (const char **linespecp) const
1649{
1650 static const char *const keywords[] = { "-pstap", "-probe-stap", NULL };
1651
1652 return probe_is_linespec_by_keyword (linespecp, keywords);
1653}
1654
1655/* Implementation of the 'get_probes' method. */
1656
1657void
814cf43a
TT
1658stap_static_probe_ops::get_probes
1659 (std::vector<std::unique_ptr<probe>> *probesp,
1660 struct objfile *objfile) const
55aa24fb
SDJ
1661{
1662 /* If we are here, then this is the first time we are parsing the
1663 SystemTap probe's information. We basically have to count how many
1664 probes the objfile has, and then fill in the necessary information
1665 for each one. */
1666 bfd *obfd = objfile->obfd;
1667 bfd_vma base;
1668 struct sdt_note *iter;
aaa63a31 1669 unsigned save_probesp_len = probesp->size ();
55aa24fb 1670
d7333987
SDJ
1671 if (objfile->separate_debug_objfile_backlink != NULL)
1672 {
1673 /* This is a .debug file, not the objfile itself. */
1674 return;
1675 }
1676
97c2dca0 1677 if (elf_tdata (obfd)->sdt_note_head == NULL)
55aa24fb
SDJ
1678 {
1679 /* There isn't any probe here. */
1680 return;
1681 }
1682
1683 if (!get_stap_base_address (obfd, &base))
1684 {
1685 /* There was an error finding the base address for the section.
1686 Just return NULL. */
1687 return;
1688 }
1689
1690 /* Parsing each probe's information. */
97c2dca0
SDJ
1691 for (iter = elf_tdata (obfd)->sdt_note_head;
1692 iter != NULL;
1693 iter = iter->next)
55aa24fb
SDJ
1694 {
1695 /* We first have to handle all the information about the
1696 probe which is present in the section. */
1697 handle_stap_probe (objfile, iter, probesp, base);
1698 }
1699
aaa63a31 1700 if (save_probesp_len == probesp->size ())
55aa24fb
SDJ
1701 {
1702 /* If we are here, it means we have failed to parse every known
1703 probe. */
f3da9116 1704 complaint (_("could not parse SystemTap probe(s) from inferior"));
55aa24fb
SDJ
1705 return;
1706 }
1707}
1708
6f9b8491
JM
1709/* Implementation of the type_name method. */
1710
0e9ae10f
SDJ
1711const char *
1712stap_static_probe_ops::type_name () const
6f9b8491 1713{
6f9b8491
JM
1714 return "stap";
1715}
1716
0e9ae10f 1717/* Implementation of the 'gen_info_probes_table_header' method. */
55aa24fb 1718
0e9ae10f
SDJ
1719std::vector<struct info_probe_column>
1720stap_static_probe_ops::gen_info_probes_table_header () const
55aa24fb 1721{
0e9ae10f 1722 struct info_probe_column stap_probe_column;
55aa24fb
SDJ
1723
1724 stap_probe_column.field_name = "semaphore";
1725 stap_probe_column.print_name = _("Semaphore");
1726
0e9ae10f 1727 return std::vector<struct info_probe_column> { stap_probe_column };
55aa24fb
SDJ
1728}
1729
55aa24fb
SDJ
1730/* Implementation of the `info probes stap' command. */
1731
1732static void
884beb0c 1733info_probes_stap_command (const char *arg, int from_tty)
55aa24fb 1734{
0e9ae10f 1735 info_probes_for_spops (arg, from_tty, &stap_static_probe_ops);
55aa24fb
SDJ
1736}
1737
6c265988 1738void _initialize_stap_probe ();
55aa24fb 1739void
6c265988 1740_initialize_stap_probe ()
55aa24fb 1741{
0e9ae10f 1742 all_static_probe_ops.push_back (&stap_static_probe_ops);
55aa24fb 1743
ccce17b0
YQ
1744 add_setshow_zuinteger_cmd ("stap-expression", class_maintenance,
1745 &stap_expression_debug,
1746 _("Set SystemTap expression debugging."),
1747 _("Show SystemTap expression debugging."),
1748 _("When non-zero, the internal representation "
1749 "of SystemTap expressions will be printed."),
1750 NULL,
1751 show_stapexpressiondebug,
1752 &setdebuglist, &showdebuglist);
55aa24fb 1753
55aa24fb
SDJ
1754 add_cmd ("stap", class_info, info_probes_stap_command,
1755 _("\
1756Show information about SystemTap static probes.\n\
1757Usage: info probes stap [PROVIDER [NAME [OBJECT]]]\n\
1758Each argument is a regular expression, used to select probes.\n\
1759PROVIDER matches probe provider names.\n\
1760NAME matches the probe names.\n\
1761OBJECT matches the executable or shared library name."),
1762 info_probes_cmdlist_get ());
1763
4c5e7a93
TT
1764
1765 using namespace expr;
1766 stap_maker_map[BINOP_ADD] = make_operation<add_operation>;
1767 stap_maker_map[BINOP_BITWISE_AND] = make_operation<bitwise_and_operation>;
1768 stap_maker_map[BINOP_BITWISE_IOR] = make_operation<bitwise_ior_operation>;
1769 stap_maker_map[BINOP_BITWISE_XOR] = make_operation<bitwise_xor_operation>;
1770 stap_maker_map[BINOP_DIV] = make_operation<div_operation>;
1771 stap_maker_map[BINOP_EQUAL] = make_operation<equal_operation>;
1772 stap_maker_map[BINOP_GEQ] = make_operation<geq_operation>;
1773 stap_maker_map[BINOP_GTR] = make_operation<gtr_operation>;
1774 stap_maker_map[BINOP_LEQ] = make_operation<leq_operation>;
1775 stap_maker_map[BINOP_LESS] = make_operation<less_operation>;
1776 stap_maker_map[BINOP_LOGICAL_AND] = make_operation<logical_and_operation>;
1777 stap_maker_map[BINOP_LOGICAL_OR] = make_operation<logical_or_operation>;
1778 stap_maker_map[BINOP_LSH] = make_operation<lsh_operation>;
1779 stap_maker_map[BINOP_MUL] = make_operation<mul_operation>;
1780 stap_maker_map[BINOP_NOTEQUAL] = make_operation<notequal_operation>;
1781 stap_maker_map[BINOP_REM] = make_operation<rem_operation>;
1782 stap_maker_map[BINOP_RSH] = make_operation<rsh_operation>;
1783 stap_maker_map[BINOP_SUB] = make_operation<sub_operation>;
55aa24fb 1784}
This page took 1.370816 seconds and 4 git commands to generate.