1 /* SystemTap probe support for GDB.
3 Copyright (C) 2012-2022 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "stap-probe.h"
25 #include "arch-utils.h"
28 #include "filenames.h"
32 #include "complaints.h"
33 #include "cli/cli-utils.h"
35 #include "user-regs.h"
36 #include "parser-defs.h"
40 #include <unordered_map>
41 #include "gdbsupport/hash_enum.h"
45 /* The name of the SystemTap section where we will find information about
48 #define STAP_BASE_SECTION_NAME ".stapsdt.base"
50 /* Should we display debug information for the probe's argument expression
53 static unsigned int stap_expression_debug
= 0;
55 /* The various possibilities of bitness defined for a probe's argument.
59 - STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
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@'.
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@'. */
71 STAP_ARG_BITNESS_UNDEFINED
,
72 STAP_ARG_BITNESS_8BIT_UNSIGNED
,
73 STAP_ARG_BITNESS_8BIT_SIGNED
,
74 STAP_ARG_BITNESS_16BIT_UNSIGNED
,
75 STAP_ARG_BITNESS_16BIT_SIGNED
,
76 STAP_ARG_BITNESS_32BIT_UNSIGNED
,
77 STAP_ARG_BITNESS_32BIT_SIGNED
,
78 STAP_ARG_BITNESS_64BIT_UNSIGNED
,
79 STAP_ARG_BITNESS_64BIT_SIGNED
,
82 /* The following structure represents a single argument for the probe. */
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_
))
92 /* The bitness of this argument. */
93 enum stap_arg_bitness bitness
;
95 /* The corresponding `struct type *' to the bitness. */
98 /* The argument converted to an internal GDB expression. */
102 /* Class that implements the static probe methods for "stap" probes. */
104 class stap_static_probe_ops
: public static_probe_ops
107 /* We need a user-provided constructor to placate some compilers.
108 See PR build/24937. */
109 stap_static_probe_ops ()
114 bool is_linespec (const char **linespecp
) const override
;
117 void get_probes (std::vector
<std::unique_ptr
<probe
>> *probesp
,
118 struct objfile
*objfile
) const override
;
121 const char *type_name () const override
;
124 std::vector
<struct info_probe_column
> gen_info_probes_table_header
128 /* SystemTap static_probe_ops. */
130 const stap_static_probe_ops stap_static_probe_ops
{};
132 class stap_probe
: public probe
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
)
144 CORE_ADDR
get_relocated_address (struct objfile
*objfile
) override
;
147 unsigned get_argument_count (struct gdbarch
*gdbarch
) override
;
150 bool can_evaluate_arguments () const override
;
153 struct value
*evaluate_argument (unsigned n
,
154 struct frame_info
*frame
) override
;
157 void compile_to_ax (struct agent_expr
*aexpr
,
158 struct axs_value
*axs_value
,
159 unsigned n
) override
;
162 void set_semaphore (struct objfile
*objfile
,
163 struct gdbarch
*gdbarch
) override
;
166 void clear_semaphore (struct objfile
*objfile
,
167 struct gdbarch
*gdbarch
) override
;
170 const static_probe_ops
*get_static_ops () const override
;
173 std::vector
<const char *> gen_info_probes_table_values () const override
;
175 /* Return argument N of probe.
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
)
183 if (!m_have_parsed_args
)
184 this->parse_arguments (gdbarch
);
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
);
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"
199 this->get_name ().c_str (),
200 (int) m_parsed_args
.size (), n
);
202 return &m_parsed_args
[n
];
205 /* Function which parses an argument string from the probe,
206 correctly splitting the arguments and storing their information
209 Consider the following argument string (x86 syntax):
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
);
219 /* If the probe has a semaphore associated, then this is the value of
220 it, relative to SECT_OFF_DATA. */
221 CORE_ADDR m_sem_addr
;
223 /* True if the arguments have been parsed. */
224 bool m_have_parsed_args
;
226 /* The text version of the probe's arguments, unparsed. */
227 const char *m_unparsed_args_text
;
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
;
235 /* When parsing the arguments, we have to establish different precedences
236 for the various kinds of asm operators. This enumeration represents those
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'". */
243 enum stap_operand_prec
245 /* Lowest precedence, used for non-recognized operands or for the beginning
246 of the parsing process. */
247 STAP_OPERAND_PREC_NONE
= 0,
249 /* Precedence of logical OR. */
250 STAP_OPERAND_PREC_LOGICAL_OR
,
252 /* Precedence of logical AND. */
253 STAP_OPERAND_PREC_LOGICAL_AND
,
255 /* Precedence of additive (plus, minus) and comparative (equal, less,
256 greater-than, etc) operands. */
257 STAP_OPERAND_PREC_ADD_CMP
,
259 /* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND,
261 STAP_OPERAND_PREC_BITWISE
,
263 /* Precedence of multiplicative operands (multiplication, division,
264 remainder, left shift and right shift). */
265 STAP_OPERAND_PREC_MUL
268 static 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
;
273 static expr::operation_up stap_parse_argument_conditionally
274 (struct stap_parse_info
*p
) ATTRIBUTE_UNUSED_RESULT
;
276 /* Returns true if *S is an operator, false otherwise. */
278 static bool stap_is_operator (const char *op
);
281 show_stapexpressiondebug (struct ui_file
*file
, int from_tty
,
282 struct cmd_list_element
*c
, const char *value
)
284 gdb_printf (file
, _("SystemTap Probe expression debugging is %s.\n"),
288 /* Returns the operator precedence level of OP, or STAP_OPERAND_PREC_NONE
289 if the operator code was not recognized. */
291 static enum stap_operand_prec
292 stap_get_operator_prec (enum exp_opcode op
)
296 case BINOP_LOGICAL_OR
:
297 return STAP_OPERAND_PREC_LOGICAL_OR
;
299 case BINOP_LOGICAL_AND
:
300 return STAP_OPERAND_PREC_LOGICAL_AND
;
310 return STAP_OPERAND_PREC_ADD_CMP
;
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
;
323 return STAP_OPERAND_PREC_MUL
;
326 return STAP_OPERAND_PREC_NONE
;
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
334 static enum exp_opcode
335 stap_get_opcode (const char **s
)
390 op
= BINOP_BITWISE_IOR
;
394 op
= BINOP_LOGICAL_OR
;
399 op
= BINOP_BITWISE_AND
;
403 op
= BINOP_LOGICAL_AND
;
408 op
= BINOP_BITWISE_XOR
;
412 op
= UNOP_LOGICAL_NOT
;
424 gdb_assert (**s
== '=');
429 error (_("Invalid opcode in expression `%s' for SystemTap"
436 typedef 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. */
440 static std::unordered_map
<exp_opcode
, binop_maker_ftype
*,
441 gdb::hash_enum
<exp_opcode
>> stap_maker_map
;
443 /* Helper function to create a binary operation. */
444 static expr::operation_up
445 stap_make_binop (enum exp_opcode opcode
, expr::operation_up
&&lhs
,
446 expr::operation_up
&&rhs
)
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
));
453 /* Given the bitness of the argument, represented by B, return the
454 corresponding `struct type *', or throw an error if B is
458 stap_get_expected_argument_type (struct gdbarch
*gdbarch
,
459 enum stap_arg_bitness b
,
460 const char *probe_name
)
464 case STAP_ARG_BITNESS_UNDEFINED
:
465 if (gdbarch_addr_bit (gdbarch
) == 32)
466 return builtin_type (gdbarch
)->builtin_uint32
;
468 return builtin_type (gdbarch
)->builtin_uint64
;
470 case STAP_ARG_BITNESS_8BIT_UNSIGNED
:
471 return builtin_type (gdbarch
)->builtin_uint8
;
473 case STAP_ARG_BITNESS_8BIT_SIGNED
:
474 return builtin_type (gdbarch
)->builtin_int8
;
476 case STAP_ARG_BITNESS_16BIT_UNSIGNED
:
477 return builtin_type (gdbarch
)->builtin_uint16
;
479 case STAP_ARG_BITNESS_16BIT_SIGNED
:
480 return builtin_type (gdbarch
)->builtin_int16
;
482 case STAP_ARG_BITNESS_32BIT_SIGNED
:
483 return builtin_type (gdbarch
)->builtin_int32
;
485 case STAP_ARG_BITNESS_32BIT_UNSIGNED
:
486 return builtin_type (gdbarch
)->builtin_uint32
;
488 case STAP_ARG_BITNESS_64BIT_SIGNED
:
489 return builtin_type (gdbarch
)->builtin_int64
;
491 case STAP_ARG_BITNESS_64BIT_UNSIGNED
:
492 return builtin_type (gdbarch
)->builtin_uint64
;
495 error (_("Undefined bitness for probe '%s'."), probe_name
);
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.
505 This function does a case-insensitive match.
507 Return true if any prefix has been found, false otherwise. */
510 stap_is_generic_prefix (struct gdbarch
*gdbarch
, const char *s
,
511 const char **r
, const char *const *prefixes
)
513 const char *const *p
;
515 if (prefixes
== NULL
)
523 for (p
= prefixes
; *p
!= NULL
; ++p
)
524 if (strncasecmp (s
, *p
, strlen (*p
)) == 0)
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. */
539 stap_is_register_prefix (struct gdbarch
*gdbarch
, const char *s
,
542 const char *const *t
= gdbarch_stap_register_prefixes (gdbarch
);
544 return stap_is_generic_prefix (gdbarch
, s
, r
, t
);
547 /* Return true if S points to a register indirection prefix, false
548 otherwise. For a description of the arguments, look at
549 stap_is_generic_prefix. */
552 stap_is_register_indirection_prefix (struct gdbarch
*gdbarch
, const char *s
,
555 const char *const *t
= gdbarch_stap_register_indirection_prefixes (gdbarch
);
557 return stap_is_generic_prefix (gdbarch
, s
, r
, t
);
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.
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. */
569 stap_is_integer_prefix (struct gdbarch
*gdbarch
, const char *s
,
572 const char *const *t
= gdbarch_stap_integer_prefixes (gdbarch
);
573 const char *const *p
;
577 /* A NULL value here means that integers do not have a prefix.
578 We just check for a digit then. */
582 return isdigit (*s
) > 0;
585 for (p
= t
; *p
!= NULL
; ++p
)
587 size_t len
= strlen (*p
);
589 if ((len
== 0 && isdigit (*s
))
590 || (len
> 0 && strncasecmp (s
, *p
, len
) == 0))
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
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
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
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
617 stap_generic_check_suffix (struct gdbarch
*gdbarch
, const char *s
,
618 const char **r
, const char *const *suffixes
)
620 const char *const *p
;
623 if (suffixes
== NULL
)
631 for (p
= suffixes
; *p
!= NULL
; ++p
)
632 if (strncasecmp (s
, *p
, strlen (*p
)) == 0)
644 /* Return true if S points to an integer suffix, false otherwise. For
645 a description of the arguments, look at
646 stap_generic_check_suffix. */
649 stap_check_integer_suffix (struct gdbarch
*gdbarch
, const char *s
,
652 const char *const *p
= gdbarch_stap_integer_suffixes (gdbarch
);
654 return stap_generic_check_suffix (gdbarch
, s
, r
, p
);
657 /* Return true if S points to a register suffix, false otherwise. For
658 a description of the arguments, look at
659 stap_generic_check_suffix. */
662 stap_check_register_suffix (struct gdbarch
*gdbarch
, const char *s
,
665 const char *const *p
= gdbarch_stap_register_suffixes (gdbarch
);
667 return stap_generic_check_suffix (gdbarch
, s
, r
, p
);
670 /* Return true if S points to a register indirection suffix, false
671 otherwise. For a description of the arguments, look at
672 stap_generic_check_suffix. */
675 stap_check_register_indirection_suffix (struct gdbarch
*gdbarch
, const char *s
,
678 const char *const *p
= gdbarch_stap_register_indirection_suffixes (gdbarch
);
680 return stap_generic_check_suffix (gdbarch
, s
, r
, p
);
683 /* Function responsible for parsing a register operand according to
684 SystemTap parlance. Assuming:
688 RIP = register indirection prefix
689 RIS = register indirection suffix
691 Then a register operand can be:
693 [RIP] [RP] REGISTER [RS] [RIS]
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. */
702 static expr::operation_up
703 stap_parse_register_operand (struct stap_parse_info
*p
)
705 /* Simple flag to indicate whether we have seen a minus signal before
707 bool got_minus
= false;
708 /* Flag to indicate whether this register access is being
710 bool indirect_p
= false;
711 struct gdbarch
*gdbarch
= p
->gdbarch
;
712 /* Variables used to extract the register name from the probe's
715 const char *gdb_reg_prefix
= gdbarch_stap_gdb_register_prefix (gdbarch
);
716 const char *gdb_reg_suffix
= gdbarch_stap_gdb_register_suffix (gdbarch
);
717 const char *reg_prefix
;
718 const char *reg_ind_prefix
;
719 const char *reg_suffix
;
720 const char *reg_ind_suffix
;
722 using namespace expr
;
724 /* Checking for a displacement argument. */
727 /* If it's a plus sign, we don't need to do anything, just advance the
731 else if (*p
->arg
== '-')
737 struct type
*long_type
= builtin_type (gdbarch
)->builtin_long
;
738 operation_up disp_op
;
739 if (isdigit (*p
->arg
))
741 /* The value of the displacement. */
745 displacement
= strtol (p
->arg
, &endp
, 10);
748 /* Generating the expression for the displacement. */
750 displacement
= -displacement
;
751 disp_op
= make_operation
<long_const_operation
> (long_type
, displacement
);
754 /* Getting rid of register indirection prefix. */
755 if (stap_is_register_indirection_prefix (gdbarch
, p
->arg
, ®_ind_prefix
))
758 p
->arg
+= strlen (reg_ind_prefix
);
761 if (disp_op
!= nullptr && !indirect_p
)
762 error (_("Invalid register displacement syntax on expression `%s'."),
765 /* Getting rid of register prefix. */
766 if (stap_is_register_prefix (gdbarch
, p
->arg
, ®_prefix
))
767 p
->arg
+= strlen (reg_prefix
);
769 /* Now we should have only the register name. Let's extract it and get
770 the associated number. */
773 /* We assume the register name is composed by letters and numbers. */
774 while (isalnum (*p
->arg
))
777 std::string
regname (start
, p
->arg
- start
);
779 /* We only add the GDB's register prefix/suffix if we are dealing with
780 a numeric register. */
781 if (isdigit (*start
))
783 if (gdb_reg_prefix
!= NULL
)
784 regname
= gdb_reg_prefix
+ regname
;
786 if (gdb_reg_suffix
!= NULL
)
787 regname
+= gdb_reg_suffix
;
790 int regnum
= user_reg_map_name_to_regnum (gdbarch
, regname
.c_str (),
793 /* Is this a valid register name? */
795 error (_("Invalid register name `%s' on expression `%s'."),
796 regname
.c_str (), p
->saved_arg
);
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
))
802 std::string newregname
803 = gdbarch_stap_adjust_register (gdbarch
, p
, regname
, regnum
);
805 if (regname
!= newregname
)
807 /* This is just a check we perform to make sure that the
808 arch-dependent code has provided us with a valid
810 regnum
= user_reg_map_name_to_regnum (gdbarch
, newregname
.c_str (),
814 internal_error (__FILE__
, __LINE__
,
815 _("Invalid register name '%s' after replacing it"
816 " (previous name was '%s')"),
817 newregname
.c_str (), regname
.c_str ());
819 regname
= std::move (newregname
);
823 operation_up reg
= make_operation
<register_operation
> (std::move (regname
));
825 /* If the argument has been placed into a vector register then (for most
826 architectures), the type of this register will be a union of arrays.
827 As a result, attempting to cast from the register type to the scalar
828 argument type will not be possible (GDB will throw an error during
829 expression evaluation).
831 The solution is to extract the scalar type from the value contents of
832 the entire register value. */
833 if (!is_scalar_type (gdbarch_register_type (gdbarch
, regnum
)))
835 gdb_assert (is_scalar_type (p
->arg_type
));
836 reg
= make_operation
<unop_extract_operation
> (std::move (reg
),
842 if (disp_op
!= nullptr)
843 reg
= make_operation
<add_operation
> (std::move (disp_op
),
846 /* Casting to the expected type. */
847 struct type
*arg_ptr_type
= lookup_pointer_type (p
->arg_type
);
848 reg
= make_operation
<unop_cast_operation
> (std::move (reg
),
850 reg
= make_operation
<unop_ind_operation
> (std::move (reg
));
853 /* Getting rid of the register name suffix. */
854 if (stap_check_register_suffix (gdbarch
, p
->arg
, ®_suffix
))
855 p
->arg
+= strlen (reg_suffix
);
857 error (_("Missing register name suffix on expression `%s'."),
860 /* Getting rid of the register indirection suffix. */
863 if (stap_check_register_indirection_suffix (gdbarch
, p
->arg
,
865 p
->arg
+= strlen (reg_ind_suffix
);
867 error (_("Missing indirection suffix on expression `%s'."),
874 /* This function is responsible for parsing a single operand.
876 A single operand can be:
878 - an unary operation (e.g., `-5', `~2', or even with subexpressions
880 - a register displacement, which will be treated as a register
881 operand (e.g., `-4(%eax)' on x86)
882 - a numeric constant, or
883 - a register operand (see function `stap_parse_register_operand')
885 The function also calls special-handling functions to deal with
886 unrecognized operands, allowing arch-specific parsers to be
889 static expr::operation_up
890 stap_parse_single_operand (struct stap_parse_info
*p
)
892 struct gdbarch
*gdbarch
= p
->gdbarch
;
893 const char *int_prefix
= NULL
;
895 using namespace expr
;
897 /* We first try to parse this token as a "special token". */
898 if (gdbarch_stap_parse_special_token_p (gdbarch
))
900 operation_up token
= gdbarch_stap_parse_special_token (gdbarch
, p
);
901 if (token
!= nullptr)
905 struct type
*long_type
= builtin_type (gdbarch
)->builtin_long
;
907 if (*p
->arg
== '-' || *p
->arg
== '~' || *p
->arg
== '+' || *p
->arg
== '!')
910 /* We use this variable to do a lookahead. */
911 const char *tmp
= p
->arg
;
912 bool has_digit
= false;
914 /* Skipping signal. */
917 /* This is an unary operation. Here is a list of allowed tokens
921 - number (from register displacement)
922 - subexpression (beginning with `(')
924 We handle the register displacement here, and the other cases
926 if (p
->inside_paren_p
)
927 tmp
= skip_spaces (tmp
);
929 while (isdigit (*tmp
))
931 /* We skip the digit here because we are only interested in
932 knowing what kind of unary operation this is. The digit
933 will be handled by one of the functions that will be
934 called below ('stap_parse_argument_conditionally' or
935 'stap_parse_register_operand'). */
940 if (has_digit
&& stap_is_register_indirection_prefix (gdbarch
, tmp
,
943 /* If we are here, it means it is a displacement. The only
944 operations allowed here are `-' and `+'. */
945 if (c
!= '-' && c
!= '+')
946 error (_("Invalid operator `%c' for register displacement "
947 "on expression `%s'."), c
, p
->saved_arg
);
949 result
= stap_parse_register_operand (p
);
953 /* This is not a displacement. We skip the operator, and
954 deal with it when the recursion returns. */
956 result
= stap_parse_argument_conditionally (p
);
958 result
= make_operation
<unary_neg_operation
> (std::move (result
));
960 result
= (make_operation
<unary_complement_operation
>
961 (std::move (result
)));
963 result
= (make_operation
<unary_logical_not_operation
>
964 (std::move (result
)));
967 else if (isdigit (*p
->arg
))
969 /* A temporary variable, needed for lookahead. */
970 const char *tmp
= p
->arg
;
974 /* We can be dealing with a numeric constant, or with a register
976 number
= strtol (tmp
, &endp
, 10);
979 if (p
->inside_paren_p
)
980 tmp
= skip_spaces (tmp
);
982 /* If "stap_is_integer_prefix" returns true, it means we can
983 accept integers without a prefix here. But we also need to
984 check whether the next token (i.e., "tmp") is not a register
985 indirection prefix. */
986 if (stap_is_integer_prefix (gdbarch
, p
->arg
, NULL
)
987 && !stap_is_register_indirection_prefix (gdbarch
, tmp
, NULL
))
989 const char *int_suffix
;
991 /* We are dealing with a numeric constant. */
992 result
= make_operation
<long_const_operation
> (long_type
, number
);
996 if (stap_check_integer_suffix (gdbarch
, p
->arg
, &int_suffix
))
997 p
->arg
+= strlen (int_suffix
);
999 error (_("Invalid constant suffix on expression `%s'."),
1002 else if (stap_is_register_indirection_prefix (gdbarch
, tmp
, NULL
))
1003 result
= stap_parse_register_operand (p
);
1005 error (_("Unknown numeric token on expression `%s'."),
1008 else if (stap_is_integer_prefix (gdbarch
, p
->arg
, &int_prefix
))
1010 /* We are dealing with a numeric constant. */
1013 const char *int_suffix
;
1015 p
->arg
+= strlen (int_prefix
);
1016 number
= strtol (p
->arg
, &endp
, 10);
1019 result
= make_operation
<long_const_operation
> (long_type
, number
);
1021 if (stap_check_integer_suffix (gdbarch
, p
->arg
, &int_suffix
))
1022 p
->arg
+= strlen (int_suffix
);
1024 error (_("Invalid constant suffix on expression `%s'."),
1027 else if (stap_is_register_prefix (gdbarch
, p
->arg
, NULL
)
1028 || stap_is_register_indirection_prefix (gdbarch
, p
->arg
, NULL
))
1029 result
= stap_parse_register_operand (p
);
1031 error (_("Operator `%c' not recognized on expression `%s'."),
1032 *p
->arg
, p
->saved_arg
);
1037 /* This function parses an argument conditionally, based on single or
1038 non-single operands. A non-single operand would be a parenthesized
1039 expression (e.g., `(2 + 1)'), and a single operand is anything that
1040 starts with `-', `~', `+' (i.e., unary operators), a digit, or
1041 something recognized by `gdbarch_stap_is_single_operand'. */
1043 static expr::operation_up
1044 stap_parse_argument_conditionally (struct stap_parse_info
*p
)
1046 gdb_assert (gdbarch_stap_is_single_operand_p (p
->gdbarch
));
1048 expr::operation_up result
;
1049 if (*p
->arg
== '-' || *p
->arg
== '~' || *p
->arg
== '+' || *p
->arg
== '!'
1050 || isdigit (*p
->arg
)
1051 || gdbarch_stap_is_single_operand (p
->gdbarch
, p
->arg
))
1052 result
= stap_parse_single_operand (p
);
1053 else if (*p
->arg
== '(')
1055 /* We are dealing with a parenthesized operand. It means we
1056 have to parse it as it was a separate expression, without
1057 left-side or precedence. */
1059 p
->arg
= skip_spaces (p
->arg
);
1060 ++p
->inside_paren_p
;
1062 result
= stap_parse_argument_1 (p
, {}, STAP_OPERAND_PREC_NONE
);
1064 p
->arg
= skip_spaces (p
->arg
);
1066 error (_("Missing close-parenthesis on expression `%s'."),
1069 --p
->inside_paren_p
;
1071 if (p
->inside_paren_p
)
1072 p
->arg
= skip_spaces (p
->arg
);
1075 error (_("Cannot parse expression `%s'."), p
->saved_arg
);
1080 /* Helper function for `stap_parse_argument'. Please, see its comments to
1081 better understand what this function does. */
1083 static expr::operation_up ATTRIBUTE_UNUSED_RESULT
1084 stap_parse_argument_1 (struct stap_parse_info
*p
,
1085 expr::operation_up
&&lhs_in
,
1086 enum stap_operand_prec prec
)
1088 /* This is an operator-precedence parser.
1090 We work with left- and right-sides of expressions, and
1091 parse them depending on the precedence of the operators
1094 gdb_assert (p
->arg
!= NULL
);
1096 if (p
->inside_paren_p
)
1097 p
->arg
= skip_spaces (p
->arg
);
1099 using namespace expr
;
1100 operation_up lhs
= std::move (lhs_in
);
1103 /* We were called without a left-side, either because this is the
1104 first call, or because we were called to parse a parenthesized
1105 expression. It doesn't really matter; we have to parse the
1106 left-side in order to continue the process. */
1107 lhs
= stap_parse_argument_conditionally (p
);
1110 if (p
->inside_paren_p
)
1111 p
->arg
= skip_spaces (p
->arg
);
1113 /* Start to parse the right-side, and to "join" left and right sides
1114 depending on the operation specified.
1116 This loop shall continue until we run out of characters in the input,
1117 or until we find a close-parenthesis, which means that we've reached
1118 the end of a sub-expression. */
1119 while (*p
->arg
!= '\0' && *p
->arg
!= ')' && !isspace (*p
->arg
))
1121 const char *tmp_exp_buf
;
1122 enum exp_opcode opcode
;
1123 enum stap_operand_prec cur_prec
;
1125 if (!stap_is_operator (p
->arg
))
1126 error (_("Invalid operator `%c' on expression `%s'."), *p
->arg
,
1129 /* We have to save the current value of the expression buffer because
1130 the `stap_get_opcode' modifies it in order to get the current
1131 operator. If this operator's precedence is lower than PREC, we
1132 should return and not advance the expression buffer pointer. */
1133 tmp_exp_buf
= p
->arg
;
1134 opcode
= stap_get_opcode (&tmp_exp_buf
);
1136 cur_prec
= stap_get_operator_prec (opcode
);
1137 if (cur_prec
< prec
)
1139 /* If the precedence of the operator that we are seeing now is
1140 lower than the precedence of the first operator seen before
1141 this parsing process began, it means we should stop parsing
1146 p
->arg
= tmp_exp_buf
;
1147 if (p
->inside_paren_p
)
1148 p
->arg
= skip_spaces (p
->arg
);
1150 /* Parse the right-side of the expression.
1152 We save whether the right-side is a parenthesized
1153 subexpression because, if it is, we will have to finish
1154 processing this part of the expression before continuing. */
1155 bool paren_subexp
= *p
->arg
== '(';
1157 operation_up rhs
= stap_parse_argument_conditionally (p
);
1158 if (p
->inside_paren_p
)
1159 p
->arg
= skip_spaces (p
->arg
);
1162 lhs
= stap_make_binop (opcode
, std::move (lhs
), std::move (rhs
));
1166 /* While we still have operators, try to parse another
1167 right-side, but using the current right-side as a left-side. */
1168 while (*p
->arg
!= '\0' && stap_is_operator (p
->arg
))
1170 enum exp_opcode lookahead_opcode
;
1171 enum stap_operand_prec lookahead_prec
;
1173 /* Saving the current expression buffer position. The explanation
1174 is the same as above. */
1175 tmp_exp_buf
= p
->arg
;
1176 lookahead_opcode
= stap_get_opcode (&tmp_exp_buf
);
1177 lookahead_prec
= stap_get_operator_prec (lookahead_opcode
);
1179 if (lookahead_prec
<= prec
)
1181 /* If we are dealing with an operator whose precedence is lower
1182 than the first one, just abandon the attempt. */
1186 /* Parse the right-side of the expression, using the current
1187 right-hand-side as the left-hand-side of the new
1189 rhs
= stap_parse_argument_1 (p
, std::move (rhs
), lookahead_prec
);
1190 if (p
->inside_paren_p
)
1191 p
->arg
= skip_spaces (p
->arg
);
1194 lhs
= stap_make_binop (opcode
, std::move (lhs
), std::move (rhs
));
1200 /* Parse a probe's argument.
1204 LP = literal integer prefix
1205 LS = literal integer suffix
1207 RP = register prefix
1208 RS = register suffix
1210 RIP = register indirection prefix
1211 RIS = register indirection suffix
1213 This routine assumes that arguments' tokens are of the form:
1216 - [RP] REGISTER [RS]
1217 - [RIP] [RP] REGISTER [RS] [RIS]
1218 - If we find a number without LP, we try to parse it as a literal integer
1219 constant (if LP == NULL), or as a register displacement.
1220 - We count parenthesis, and only skip whitespaces if we are inside them.
1221 - If we find an operator, we skip it.
1223 This function can also call a special function that will try to match
1224 unknown tokens. It will return the expression_up generated from
1225 parsing the argument. */
1227 static expression_up
1228 stap_parse_argument (const char **arg
, struct type
*atype
,
1229 struct gdbarch
*gdbarch
)
1231 /* We need to initialize the expression buffer, in order to begin
1232 our parsing efforts. We use language_c here because we may need
1233 to do pointer arithmetics. */
1234 struct stap_parse_info
p (*arg
, atype
, language_def (language_c
),
1237 using namespace expr
;
1238 operation_up result
= stap_parse_argument_1 (&p
, {}, STAP_OPERAND_PREC_NONE
);
1240 gdb_assert (p
.inside_paren_p
== 0);
1242 /* Casting the final expression to the appropriate type. */
1243 result
= make_operation
<unop_cast_operation
> (std::move (result
), atype
);
1244 p
.pstate
.set_operation (std::move (result
));
1246 p
.arg
= skip_spaces (p
.arg
);
1249 return p
.pstate
.release ();
1252 /* Implementation of 'parse_arguments' method. */
1255 stap_probe::parse_arguments (struct gdbarch
*gdbarch
)
1259 gdb_assert (!m_have_parsed_args
);
1260 cur
= m_unparsed_args_text
;
1261 m_have_parsed_args
= true;
1263 if (cur
== NULL
|| *cur
== '\0' || *cur
== ':')
1266 while (*cur
!= '\0')
1268 enum stap_arg_bitness bitness
;
1269 bool got_minus
= false;
1271 /* We expect to find something like:
1275 Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so
1276 we check it here. If we don't find it, go to the next
1278 if ((cur
[0] == '-' && isdigit (cur
[1]) && cur
[2] == '@')
1279 || (isdigit (cur
[0]) && cur
[1] == '@'))
1283 /* Discard the `-'. */
1288 /* Defining the bitness. */
1292 bitness
= (got_minus
? STAP_ARG_BITNESS_8BIT_SIGNED
1293 : STAP_ARG_BITNESS_8BIT_UNSIGNED
);
1297 bitness
= (got_minus
? STAP_ARG_BITNESS_16BIT_SIGNED
1298 : STAP_ARG_BITNESS_16BIT_UNSIGNED
);
1302 bitness
= (got_minus
? STAP_ARG_BITNESS_32BIT_SIGNED
1303 : STAP_ARG_BITNESS_32BIT_UNSIGNED
);
1307 bitness
= (got_minus
? STAP_ARG_BITNESS_64BIT_SIGNED
1308 : STAP_ARG_BITNESS_64BIT_UNSIGNED
);
1313 /* We have an error, because we don't expect anything
1314 except 1, 2, 4 and 8. */
1315 warning (_("unrecognized bitness %s%c' for probe `%s'"),
1316 got_minus
? "`-" : "`", *cur
,
1317 this->get_name ().c_str ());
1321 /* Discard the number and the `@' sign. */
1325 bitness
= STAP_ARG_BITNESS_UNDEFINED
;
1328 = stap_get_expected_argument_type (gdbarch
, bitness
,
1329 this->get_name ().c_str ());
1331 expression_up expr
= stap_parse_argument (&cur
, atype
, gdbarch
);
1333 if (stap_expression_debug
)
1334 dump_prefix_expression (expr
.get (), gdb_stdlog
);
1336 m_parsed_args
.emplace_back (bitness
, atype
, std::move (expr
));
1338 /* Start it over again. */
1339 cur
= skip_spaces (cur
);
1343 /* Helper function to relocate an address. */
1346 relocate_address (CORE_ADDR address
, struct objfile
*objfile
)
1348 return address
+ objfile
->text_section_offset ();
1351 /* Implementation of the get_relocated_address method. */
1354 stap_probe::get_relocated_address (struct objfile
*objfile
)
1356 return relocate_address (this->get_address (), objfile
);
1359 /* Given PROBE, returns the number of arguments present in that probe's
1363 stap_probe::get_argument_count (struct gdbarch
*gdbarch
)
1365 if (!m_have_parsed_args
)
1367 if (this->can_evaluate_arguments ())
1368 this->parse_arguments (gdbarch
);
1371 static bool have_warned_stap_incomplete
= false;
1373 if (!have_warned_stap_incomplete
)
1376 "The SystemTap SDT probe support is not fully implemented on this target;\n"
1377 "you will not be able to inspect the arguments of the probes.\n"
1378 "Please report a bug against GDB requesting a port to this target."));
1379 have_warned_stap_incomplete
= true;
1382 /* Marking the arguments as "already parsed". */
1383 m_have_parsed_args
= true;
1387 gdb_assert (m_have_parsed_args
);
1388 return m_parsed_args
.size ();
1391 /* Return true if OP is a valid operator inside a probe argument, or
1395 stap_is_operator (const char *op
)
1420 /* We didn't find any operator. */
1427 /* Implement the `can_evaluate_arguments' method. */
1430 stap_probe::can_evaluate_arguments () const
1432 struct gdbarch
*gdbarch
= this->get_gdbarch ();
1434 /* For SystemTap probes, we have to guarantee that the method
1435 stap_is_single_operand is defined on gdbarch. If it is not, then it
1436 means that argument evaluation is not implemented on this target. */
1437 return gdbarch_stap_is_single_operand_p (gdbarch
);
1440 /* Evaluate the probe's argument N (indexed from 0), returning a value
1441 corresponding to it. Assertion is thrown if N does not exist. */
1444 stap_probe::evaluate_argument (unsigned n
, struct frame_info
*frame
)
1446 struct stap_probe_arg
*arg
;
1447 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1449 arg
= this->get_arg_by_number (n
, gdbarch
);
1450 return evaluate_expression (arg
->aexpr
.get (), arg
->atype
);
1453 /* Compile the probe's argument N (indexed from 0) to agent expression.
1454 Assertion is thrown if N does not exist. */
1457 stap_probe::compile_to_ax (struct agent_expr
*expr
, struct axs_value
*value
,
1460 struct stap_probe_arg
*arg
;
1462 arg
= this->get_arg_by_number (n
, expr
->gdbarch
);
1464 arg
->aexpr
->op
->generate_ax (arg
->aexpr
.get (), expr
, value
);
1466 require_rvalue (expr
, value
);
1467 value
->type
= arg
->atype
;
1471 /* Set or clear a SystemTap semaphore. ADDRESS is the semaphore's
1472 address. SET is zero if the semaphore should be cleared, or one if
1473 it should be set. This is a helper function for
1474 'stap_probe::set_semaphore' and 'stap_probe::clear_semaphore'. */
1477 stap_modify_semaphore (CORE_ADDR address
, int set
, struct gdbarch
*gdbarch
)
1479 gdb_byte bytes
[sizeof (LONGEST
)];
1480 /* The ABI specifies "unsigned short". */
1481 struct type
*type
= builtin_type (gdbarch
)->builtin_unsigned_short
;
1484 /* Swallow errors. */
1485 if (target_read_memory (address
, bytes
, TYPE_LENGTH (type
)) != 0)
1487 warning (_("Could not read the value of a SystemTap semaphore."));
1491 enum bfd_endian byte_order
= type_byte_order (type
);
1492 value
= extract_unsigned_integer (bytes
, TYPE_LENGTH (type
), byte_order
);
1493 /* Note that we explicitly don't worry about overflow or
1500 store_unsigned_integer (bytes
, TYPE_LENGTH (type
), byte_order
, value
);
1502 if (target_write_memory (address
, bytes
, TYPE_LENGTH (type
)) != 0)
1503 warning (_("Could not write the value of a SystemTap semaphore."));
1506 /* Implementation of the 'set_semaphore' method.
1508 SystemTap semaphores act as reference counters, so calls to this
1509 function must be paired with calls to 'clear_semaphore'.
1511 This function and 'clear_semaphore' race with another tool
1512 changing the probes, but that is too rare to care. */
1515 stap_probe::set_semaphore (struct objfile
*objfile
, struct gdbarch
*gdbarch
)
1517 if (m_sem_addr
== 0)
1519 stap_modify_semaphore (relocate_address (m_sem_addr
, objfile
), 1, gdbarch
);
1522 /* Implementation of the 'clear_semaphore' method. */
1525 stap_probe::clear_semaphore (struct objfile
*objfile
, struct gdbarch
*gdbarch
)
1527 if (m_sem_addr
== 0)
1529 stap_modify_semaphore (relocate_address (m_sem_addr
, objfile
), 0, gdbarch
);
1532 /* Implementation of the 'get_static_ops' method. */
1534 const static_probe_ops
*
1535 stap_probe::get_static_ops () const
1537 return &stap_static_probe_ops
;
1540 /* Implementation of the 'gen_info_probes_table_values' method. */
1542 std::vector
<const char *>
1543 stap_probe::gen_info_probes_table_values () const
1545 const char *val
= NULL
;
1547 if (m_sem_addr
!= 0)
1548 val
= print_core_address (this->get_gdbarch (), m_sem_addr
);
1550 return std::vector
<const char *> { val
};
1553 /* Helper function that parses the information contained in a
1554 SystemTap's probe. Basically, the information consists in:
1556 - Probe's PC address;
1557 - Link-time section address of `.stapsdt.base' section;
1558 - Link-time address of the semaphore variable, or ZERO if the
1559 probe doesn't have an associated semaphore;
1560 - Probe's provider name;
1562 - Probe's argument format. */
1565 handle_stap_probe (struct objfile
*objfile
, struct sdt_note
*el
,
1566 std::vector
<std::unique_ptr
<probe
>> *probesp
,
1569 bfd
*abfd
= objfile
->obfd
.get ();
1570 int size
= bfd_get_arch_size (abfd
) / 8;
1571 struct gdbarch
*gdbarch
= objfile
->arch ();
1572 struct type
*ptr_type
= builtin_type (gdbarch
)->builtin_data_ptr
;
1574 /* Provider and the name of the probe. */
1575 const char *provider
= (const char *) &el
->data
[3 * size
];
1576 const char *name
= ((const char *)
1577 memchr (provider
, '\0',
1578 (char *) el
->data
+ el
->size
- provider
));
1579 /* Making sure there is a name. */
1582 complaint (_("corrupt probe name when reading `%s'"),
1583 objfile_name (objfile
));
1585 /* There is no way to use a probe without a name or a provider, so
1586 returning here makes sense. */
1592 /* Retrieving the probe's address. */
1593 CORE_ADDR address
= extract_typed_address (&el
->data
[0], ptr_type
);
1595 /* Link-time sh_addr of `.stapsdt.base' section. */
1596 CORE_ADDR base_ref
= extract_typed_address (&el
->data
[size
], ptr_type
);
1598 /* Semaphore address. */
1599 CORE_ADDR sem_addr
= extract_typed_address (&el
->data
[2 * size
], ptr_type
);
1601 address
+= base
- base_ref
;
1603 sem_addr
+= base
- base_ref
;
1605 /* Arguments. We can only extract the argument format if there is a valid
1606 name for this probe. */
1607 const char *probe_args
= ((const char*)
1609 (char *) el
->data
+ el
->size
- name
));
1611 if (probe_args
!= NULL
)
1614 if (probe_args
== NULL
1615 || (memchr (probe_args
, '\0', (char *) el
->data
+ el
->size
- name
)
1616 != el
->data
+ el
->size
- 1))
1618 complaint (_("corrupt probe argument when reading `%s'"),
1619 objfile_name (objfile
));
1620 /* If the argument string is NULL, it means some problem happened with
1621 it. So we return. */
1625 stap_probe
*ret
= new stap_probe (std::string (name
), std::string (provider
),
1626 address
, gdbarch
, sem_addr
, probe_args
);
1628 /* Successfully created probe. */
1629 probesp
->emplace_back (ret
);
1632 /* Helper function which iterates over every section in the BFD file,
1633 trying to find the base address of the SystemTap base section.
1634 Returns 1 if found (setting BASE to the proper value), zero otherwise. */
1637 get_stap_base_address (bfd
*obfd
, bfd_vma
*base
)
1639 asection
*ret
= NULL
;
1641 for (asection
*sect
: gdb_bfd_sections (obfd
))
1642 if ((sect
->flags
& (SEC_DATA
| SEC_ALLOC
| SEC_HAS_CONTENTS
))
1643 && sect
->name
&& !strcmp (sect
->name
, STAP_BASE_SECTION_NAME
))
1648 complaint (_("could not obtain base address for "
1649 "SystemTap section on objfile `%s'."),
1650 bfd_get_filename (obfd
));
1660 /* Implementation of the 'is_linespec' method. */
1663 stap_static_probe_ops::is_linespec (const char **linespecp
) const
1665 static const char *const keywords
[] = { "-pstap", "-probe-stap", NULL
};
1667 return probe_is_linespec_by_keyword (linespecp
, keywords
);
1670 /* Implementation of the 'get_probes' method. */
1673 stap_static_probe_ops::get_probes
1674 (std::vector
<std::unique_ptr
<probe
>> *probesp
,
1675 struct objfile
*objfile
) const
1677 /* If we are here, then this is the first time we are parsing the
1678 SystemTap probe's information. We basically have to count how many
1679 probes the objfile has, and then fill in the necessary information
1681 bfd
*obfd
= objfile
->obfd
.get ();
1683 struct sdt_note
*iter
;
1684 unsigned save_probesp_len
= probesp
->size ();
1686 if (objfile
->separate_debug_objfile_backlink
!= NULL
)
1688 /* This is a .debug file, not the objfile itself. */
1692 if (elf_tdata (obfd
)->sdt_note_head
== NULL
)
1694 /* There isn't any probe here. */
1698 if (!get_stap_base_address (obfd
, &base
))
1700 /* There was an error finding the base address for the section.
1701 Just return NULL. */
1705 /* Parsing each probe's information. */
1706 for (iter
= elf_tdata (obfd
)->sdt_note_head
;
1710 /* We first have to handle all the information about the
1711 probe which is present in the section. */
1712 handle_stap_probe (objfile
, iter
, probesp
, base
);
1715 if (save_probesp_len
== probesp
->size ())
1717 /* If we are here, it means we have failed to parse every known
1719 complaint (_("could not parse SystemTap probe(s) from inferior"));
1724 /* Implementation of the type_name method. */
1727 stap_static_probe_ops::type_name () const
1732 /* Implementation of the 'gen_info_probes_table_header' method. */
1734 std::vector
<struct info_probe_column
>
1735 stap_static_probe_ops::gen_info_probes_table_header () const
1737 struct info_probe_column stap_probe_column
;
1739 stap_probe_column
.field_name
= "semaphore";
1740 stap_probe_column
.print_name
= _("Semaphore");
1742 return std::vector
<struct info_probe_column
> { stap_probe_column
};
1745 /* Implementation of the `info probes stap' command. */
1748 info_probes_stap_command (const char *arg
, int from_tty
)
1750 info_probes_for_spops (arg
, from_tty
, &stap_static_probe_ops
);
1753 void _initialize_stap_probe ();
1755 _initialize_stap_probe ()
1757 all_static_probe_ops
.push_back (&stap_static_probe_ops
);
1759 add_setshow_zuinteger_cmd ("stap-expression", class_maintenance
,
1760 &stap_expression_debug
,
1761 _("Set SystemTap expression debugging."),
1762 _("Show SystemTap expression debugging."),
1763 _("When non-zero, the internal representation "
1764 "of SystemTap expressions will be printed."),
1766 show_stapexpressiondebug
,
1767 &setdebuglist
, &showdebuglist
);
1769 add_cmd ("stap", class_info
, info_probes_stap_command
,
1771 Show information about SystemTap static probes.\n\
1772 Usage: info probes stap [PROVIDER [NAME [OBJECT]]]\n\
1773 Each argument is a regular expression, used to select probes.\n\
1774 PROVIDER matches probe provider names.\n\
1775 NAME matches the probe names.\n\
1776 OBJECT matches the executable or shared library name."),
1777 info_probes_cmdlist_get ());
1780 using namespace expr
;
1781 stap_maker_map
[BINOP_ADD
] = make_operation
<add_operation
>;
1782 stap_maker_map
[BINOP_BITWISE_AND
] = make_operation
<bitwise_and_operation
>;
1783 stap_maker_map
[BINOP_BITWISE_IOR
] = make_operation
<bitwise_ior_operation
>;
1784 stap_maker_map
[BINOP_BITWISE_XOR
] = make_operation
<bitwise_xor_operation
>;
1785 stap_maker_map
[BINOP_DIV
] = make_operation
<div_operation
>;
1786 stap_maker_map
[BINOP_EQUAL
] = make_operation
<equal_operation
>;
1787 stap_maker_map
[BINOP_GEQ
] = make_operation
<geq_operation
>;
1788 stap_maker_map
[BINOP_GTR
] = make_operation
<gtr_operation
>;
1789 stap_maker_map
[BINOP_LEQ
] = make_operation
<leq_operation
>;
1790 stap_maker_map
[BINOP_LESS
] = make_operation
<less_operation
>;
1791 stap_maker_map
[BINOP_LOGICAL_AND
] = make_operation
<logical_and_operation
>;
1792 stap_maker_map
[BINOP_LOGICAL_OR
] = make_operation
<logical_or_operation
>;
1793 stap_maker_map
[BINOP_LSH
] = make_operation
<lsh_operation
>;
1794 stap_maker_map
[BINOP_MUL
] = make_operation
<mul_operation
>;
1795 stap_maker_map
[BINOP_NOTEQUAL
] = make_operation
<notequal_operation
>;
1796 stap_maker_map
[BINOP_REM
] = make_operation
<rem_operation
>;
1797 stap_maker_map
[BINOP_RSH
] = make_operation
<rsh_operation
>;
1798 stap_maker_map
[BINOP_SUB
] = make_operation
<sub_operation
>;