brintos

brintos / llvm-project-archived public Read only

0
0
Text · 730 B · 608564e Raw
32 lines · cpp
1// Intercept the implicit 'this' argument of class member functions.2//3// RUN: %clangxx_xray -g -std=c++11 %s -o %t4// RUN: rm -f log-args-this-*5// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=log-args-this-" %run %t6 7// REQUIRES: target={{(aarch64|x86_64)-.*}}8 9#include "xray/xray_interface.h"10#include <cassert>11 12class A {13 public:14  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void f() {15    // does nothing.16  }17};18 19volatile uint64_t captured = 0;20 21void handler(int32_t, XRayEntryType, uint64_t arg1) {22  captured = arg1;23}24 25int main() {26  __xray_set_handler_arg1(handler);27  A instance;28  instance.f();29  __xray_remove_handler_arg1();30  assert(captured == (uint64_t)&instance);31}32