The relationship is:
- STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
+ - STAP_ARG_BITNESS_8BIT_UNSIGNED: argument string starts with `1@'.
+ - STAP_ARG_BITNESS_8BIT_SIGNED: argument string starts with `-1@'.
+ - STAP_ARG_BITNESS_16BIT_UNSIGNED: argument string starts with `2@'.
+ - STAP_ARG_BITNESS_16BIT_SIGNED: argument string starts with `-2@'.
- STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'.
- STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'.
- STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'.
enum stap_arg_bitness
{
STAP_ARG_BITNESS_UNDEFINED,
+ STAP_ARG_BITNESS_8BIT_UNSIGNED,
+ STAP_ARG_BITNESS_8BIT_SIGNED,
+ STAP_ARG_BITNESS_16BIT_UNSIGNED,
+ STAP_ARG_BITNESS_16BIT_SIGNED,
STAP_ARG_BITNESS_32BIT_UNSIGNED,
STAP_ARG_BITNESS_32BIT_SIGNED,
STAP_ARG_BITNESS_64BIT_UNSIGNED,
else
return builtin_type (gdbarch)->builtin_uint64;
+ case STAP_ARG_BITNESS_8BIT_UNSIGNED:
+ return builtin_type (gdbarch)->builtin_uint8;
+
+ case STAP_ARG_BITNESS_8BIT_SIGNED:
+ return builtin_type (gdbarch)->builtin_int8;
+
+ case STAP_ARG_BITNESS_16BIT_UNSIGNED:
+ return builtin_type (gdbarch)->builtin_uint16;
+
+ case STAP_ARG_BITNESS_16BIT_SIGNED:
+ return builtin_type (gdbarch)->builtin_int16;
+
case STAP_ARG_BITNESS_32BIT_SIGNED:
return builtin_type (gdbarch)->builtin_int32;
N@OP
- Where `N' can be [+,-][4,8]. This is not mandatory, so
+ Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so
we check it here. If we don't find it, go to the next
state. */
if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@')
got_minus = 1;
}
- if (*cur == '4')
- b = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
- : STAP_ARG_BITNESS_32BIT_UNSIGNED);
- else if (*cur == '8')
- b = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
- : STAP_ARG_BITNESS_64BIT_UNSIGNED);
- else
+ /* Defining the bitness. */
+ switch (*cur)
{
- /* We have an error, because we don't expect anything
- except 4 and 8. */
- complaint (&symfile_complaints,
- _("unrecognized bitness `%c' for probe `%s'"),
- *cur, probe->p.name);
- return;
+ case '1':
+ b = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
+ : STAP_ARG_BITNESS_8BIT_UNSIGNED);
+ break;
+
+ case '2':
+ b = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
+ : STAP_ARG_BITNESS_16BIT_UNSIGNED);
+ break;
+
+ case '4':
+ b = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
+ : STAP_ARG_BITNESS_32BIT_UNSIGNED);
+ break;
+
+ case '8':
+ b = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
+ : STAP_ARG_BITNESS_64BIT_UNSIGNED);
+ break;
+
+ default:
+ {
+ /* We have an error, because we don't expect anything
+ except 1, 2, 4 and 8. */
+ warning (_("unrecognized bitness %s%c' for probe `%s'"),
+ got_minus ? "`-" : "`", *cur, probe->p.name);
+ return;
+ }
}
arg.bitness = b;
STAP_PROBE1(probe, foo_prefix, 8@(%rsp))
STAP_PROBE1(probe, bar_prefix, 8@-8(%rbp))
mov %rbp,%rsp
+ STAP_PROBE1(probe, uint8_probe, 1@$8)
+ STAP_PROBE1(probe, int8_probe, -1@$-8)
+ STAP_PROBE1(probe, uint16_probe, 2@$16)
+ STAP_PROBE1(probe, int16_probe, -2@$-16)
+ STAP_PROBE1(probe, uint32_probe, 4@$32)
+ STAP_PROBE1(probe, int32_probe, -4@$-32)
+ STAP_PROBE1(probe, uint64_probe, 8@$64)
+ STAP_PROBE1(probe, int64_probe, -8@$-64)
+ STAP_PROBE1(probe, fail_probe, -7@$16)
+ STAP_PROBE1(probe, fail2_probe, 23-@$16)
xor %rax,%rax
ret
gdb_test "print \$_probe_arg0 == *((unsigned int *) (${reg_val}))" "= 1"
}
+proc test_probe_value_without_reg { value } {
+ gdb_test "print \$_probe_argc" "= 1"
+ gdb_test "print \$_probe_arg0" "= $value"
+}
+
if { ![runto_main] } {
return -1
}
test_probe_value $probe_val $probe_reg_val
}
}
+
+# Testing normal probes, with several prefixes.
+
+set normal_probes_names { }
+
+foreach bit [list 8 16 32 64] {
+ lappend normal_probes_names "uint${bit}_probe"
+ lappend normal_probes_names "int${bit}_probe"
+}
+
+foreach probe_name $normal_probes_names \
+ probe_val [list 8 -8 16 -16 32 -32 64 -64] {
+ with_test_prefix $probe_name {
+ goto_probe $probe_name
+ test_probe_value_without_reg $probe_val
+ }
+}
+
+# Testing the fail probes.
+
+with_test_prefix "fail_probe" {
+ goto_probe "fail_probe"
+ gdb_test "print \$_probe_arg0" "warning: unrecognized bitness `-7' for probe `fail_probe'\r\nInvalid probe argument 0 -- probe has 0 arguments available"
+}
+
+with_test_prefix "fail2_probe" {
+ goto_probe "fail2_probe"
+ gdb_test "print \$_probe_arg0" "Unknown numeric token on expression `23-@\\\$16'."
+}