[compiler-rt] r305545 - Add test for logging the implicit "this" argument for C++ member functions.

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 20:24:07 PDT 2017


Author: dberris
Date: Thu Jun 15 22:24:07 2017
New Revision: 305545

URL: http://llvm.org/viewvc/llvm-project?rev=305545&view=rev
Log:
Add test for logging the implicit "this" argument for C++ member functions.

Summary:
This allows us to do more interesting things with the data available to
C++ methods, to log the `this` pointer.

Depends on D34050.

Reviewers: pelikan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34051

Added:
    compiler-rt/trunk/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc

Added: compiler-rt/trunk/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc?rev=305545&view=auto
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc (added)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc Thu Jun 15 22:24:07 2017
@@ -0,0 +1,31 @@
+// Intercept the implicit 'this' argument of class member functions.
+//
+// RUN: %clangxx_xray -g -std=c++11 %s -o %t
+// RUN: rm log-args-this-* || true
+// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=log-args-this-" %run %t
+//
+// XFAIL: arm || aarch64 || mips
+// UNSUPPORTED: powerpc64le
+#include "xray/xray_interface.h"
+#include <cassert>
+
+class A {
+ public:
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void f() {
+    // does nothing.
+  }
+};
+
+volatile uint64_t captured = 0;
+
+void handler(int32_t, XRayEntryType, uint64_t arg1) {
+  captured = arg1;
+}
+
+int main() {
+  __xray_set_handler_arg1(handler);
+  A instance;
+  instance.f();
+  __xray_remove_handler_arg1();
+  assert(captured == (uint64_t)&instance);
+}




More information about the llvm-commits mailing list