Commit f86f0538 authored by Sandipan Das's avatar Sandipan Das

Add powerpc64 support for some USDT related tests

This adds powerpc64-specific test cases in 'test_usdt_args'
and also updates the folly tracing headers to be able to
produce compatible USDT markers for 'test_usdt'. The folly
tracing ELF header now provides macros for all supported
architectures instead of just x86.
Signed-off-by: default avatarSandipan Das <sandipan@linux.vnet.ibm.com>
parent 1f0f7b66
......@@ -22,7 +22,7 @@
using std::experimental::optional;
using std::experimental::nullopt;
static void verify_register(USDT::ArgumentParser_x64 &parser, int arg_size,
static void verify_register(USDT::ArgumentParser &parser, int arg_size,
int constant) {
USDT::Argument arg;
REQUIRE(parser.parse(&arg));
......@@ -32,7 +32,7 @@ static void verify_register(USDT::ArgumentParser_x64 &parser, int arg_size,
REQUIRE(arg.constant() == constant);
}
static void verify_register(USDT::ArgumentParser_x64 &parser, int arg_size,
static void verify_register(USDT::ArgumentParser &parser, int arg_size,
const std::string &regname,
optional<int> deref_offset = nullopt,
optional<std::string> deref_ident = nullopt,
......@@ -54,7 +54,11 @@ static void verify_register(USDT::ArgumentParser_x64 &parser, int arg_size,
TEST_CASE("test usdt argument parsing", "[usdt]") {
SECTION("parse failure") {
#ifdef __powerpc64__
USDT::ArgumentParser_powerpc64 parser("4@-12(42)");
#elif defined(__x86_64__)
USDT::ArgumentParser_x64 parser("4@i%ra+1r");
#endif
USDT::Argument arg;
REQUIRE(!parser.parse(&arg));
int i;
......@@ -65,6 +69,51 @@ TEST_CASE("test usdt argument parsing", "[usdt]") {
REQUIRE(i < 10);
}
SECTION("argument examples from the Python implementation") {
#ifdef __powerpc64__
USDT::ArgumentParser_powerpc64 parser(
"-4@0 8@%r0 8@i0 4@0(%r0) -2@0(0) "
"1@0 -2@%r3 -8@i9 -1@0(%r4) -4@16(6) "
"2@7 4@%r11 4@i-67 8@-16(%r17) 1@-52(11) "
"-8@13 -8@%r25 2@i-11 -2@14(%r26) -8@-32(24) "
"4@29 2@%r17 -8@i-693 -1@-23(%r31) 4@28(30) "
"-2@31 -4@%r30 2@i1097 4@108(%r30) -2@-4(31)");
verify_register(parser, -4, "gpr[0]");
verify_register(parser, 8, "gpr[0]");
verify_register(parser, 8, 0);
verify_register(parser, 4, "gpr[0]", 0);
verify_register(parser, -2, "gpr[0]", 0);
verify_register(parser, 1, "gpr[0]");
verify_register(parser, -2, "gpr[3]");
verify_register(parser, -8, 9);
verify_register(parser, -1, "gpr[4]", 0);
verify_register(parser, -4, "gpr[6]", 16);
verify_register(parser, 2, "gpr[7]");
verify_register(parser, 4, "gpr[11]");
verify_register(parser, 4, -67);
verify_register(parser, 8, "gpr[17]", -16);
verify_register(parser, 1, "gpr[11]", -52);
verify_register(parser, -8, "gpr[13]");
verify_register(parser, -8, "gpr[25]");
verify_register(parser, 2, -11);
verify_register(parser, -2, "gpr[26]", 14);
verify_register(parser, -8, "gpr[24]", -32);
verify_register(parser, 4, "gpr[29]");
verify_register(parser, 2, "gpr[17]");
verify_register(parser, -8, -693);
verify_register(parser, -1, "gpr[31]", -23);
verify_register(parser, 4, "gpr[30]", 28);
verify_register(parser, -2, "gpr[31]");
verify_register(parser, -4, "gpr[30]");
verify_register(parser, 2, 1097);
verify_register(parser, 4, "gpr[30]", 108);
verify_register(parser, -2, "gpr[31]", -4);
#elif defined(__x86_64__)
USDT::ArgumentParser_x64 parser(
"-4@$0 8@$1234 %rdi %rax %rsi "
"-8@%rbx 4@%r12 8@-8(%rbp) 4@(%rax) "
......@@ -94,6 +143,7 @@ TEST_CASE("test usdt argument parsing", "[usdt]") {
verify_register(parser, 8, "ax", 0, nullopt, std::string("dx"), 8);
verify_register(parser, 4, "bx", 0, nullopt, std::string("cx"));
#endif
REQUIRE(parser.done());
}
......
......@@ -18,8 +18,12 @@
// Default constraint for the probe arguments as operands.
#ifndef FOLLY_SDT_ARG_CONSTRAINT
#if defined(__powerpc64__) || defined(__powerpc__)
#define FOLLY_SDT_ARG_CONSTRAINT "nQr"
#elif defined(__x86_64__) || defined(__i386__)
#define FOLLY_SDT_ARG_CONSTRAINT "nor"
#endif
#endif
// Instruction to emit for the probe.
#define FOLLY_SDT_NOP nop
......@@ -73,7 +77,14 @@
FOLLY_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7), FOLLY_SDT_ARG(8, _8)
// Templates to reference the arguments from operands in note section.
#define FOLLY_SDT_ARGFMT(no) %n[FOLLY_SDT_S##no]@%[FOLLY_SDT_A##no]
#if defined(__powerpc64__ ) || defined(__powerpc__)
#define FOLLY_SDT_ARGTMPL(id) %I[id]%[id]
#elif defined(__i386__)
#define FOLLY_SDT_ARGTMPL(id) %w[id]
#else
#define FOLLY_SDT_ARGTMPL(id) %[id]
#endif
#define FOLLY_SDT_ARGFMT(no) %n[FOLLY_SDT_S##no]@FOLLY_SDT_ARGTMPL(FOLLY_SDT_A##no)
#define FOLLY_SDT_ARG_TEMPLATE_0 /*No arguments*/
#define FOLLY_SDT_ARG_TEMPLATE_1 FOLLY_SDT_ARGFMT(1)
#define FOLLY_SDT_ARG_TEMPLATE_2 FOLLY_SDT_ARG_TEMPLATE_1 FOLLY_SDT_ARGFMT(2)
......
......@@ -16,8 +16,10 @@
#pragma once
#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__))
#include <folly/tracing/StaticTracepoint-ELFx86.h>
#if defined(__ELF__) && \
(defined(__powerpc64__) || defined(__powerpc__) || \
defined(__x86_64__) || defined(__i386__))
#include <folly/tracing/StaticTracepoint-ELF.h>
#define FOLLY_SDT(provider, name, ...) \
FOLLY_SDT_PROBE_N( \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment