38 lines · cpp
1// Allow having both the no-arg and arg1 logging implementation live together,2// and be called in the correct cases.3//4// RUN: rm -f arg0-arg1-logging-*5// RUN: %clangxx_xray -std=c++11 %s -o %t6// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=arg0-arg1-logging-" %run %t7 8// REQUIRES: target={{(aarch64|x86_64)-.*}}9 10#include "xray/xray_interface.h"11#include <cassert>12#include <cstdio>13 14using namespace std;15 16bool arg0loggercalled = false;17void arg0logger(int32_t, XRayEntryType) { arg0loggercalled = true; }18 19[[clang::xray_always_instrument]] void arg0fn() { printf("hello, arg0!\n"); }20 21bool arg1loggercalled = false;22void arg1logger(int32_t, XRayEntryType, uint64_t) { arg1loggercalled = true; }23 24[[ clang::xray_always_instrument, clang::xray_log_args(1) ]] void25arg1fn(uint64_t arg1) {26 printf("hello, arg1!\n");27}28 29int main(int argc, char *argv[]) {30 __xray_set_handler(arg0logger);31 __xray_set_handler_arg1(arg1logger);32 arg0fn();33 arg1fn(0xcafef00d);34 __xray_remove_handler_arg1();35 __xray_remove_handler();36 assert(arg0loggercalled && arg1loggercalled);37}38