CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
96 lines
3.4 KiB
C++
96 lines
3.4 KiB
C++
// Check that we can install an implementation associated with a mode.
|
|
//
|
|
// RUN: rm -f xray-log.logging-modes*
|
|
// RUN: %clangxx_xray -std=c++11 %s -o %t -fxray-modes=none
|
|
// RUN: %run %t | FileCheck %s
|
|
//
|
|
// UNSUPPORTED: target-is-mips64,target-is-mips64el
|
|
|
|
#include "xray/xray_interface.h"
|
|
#include "xray/xray_log_interface.h"
|
|
#include <cassert>
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
[[clang::xray_never_instrument]] void printing_handler(int32_t fid,
|
|
XRayEntryType) {
|
|
thread_local volatile bool printing = false;
|
|
if (printing)
|
|
return;
|
|
printing = true;
|
|
std::printf("printing %d\n", fid);
|
|
printing = false;
|
|
}
|
|
|
|
[[clang::xray_never_instrument]] XRayBuffer next_buffer(XRayBuffer buffer) {
|
|
static const char data[10] = {};
|
|
static const XRayBuffer first_and_last{data, 10};
|
|
if (buffer.Data == nullptr)
|
|
return first_and_last;
|
|
if (buffer.Data == first_and_last.Data)
|
|
return XRayBuffer{nullptr, 0};
|
|
assert(false && "Invalid buffer provided.");
|
|
}
|
|
|
|
static constexpr char Options[] = "additional_flags";
|
|
|
|
[[clang::xray_never_instrument]] XRayLogInitStatus
|
|
printing_init(size_t BufferSize, size_t MaxBuffers, void *Config,
|
|
size_t ArgsSize) {
|
|
// We require that the printing init is called through the
|
|
// __xray_log_init_mode(...) implementation, and that the promised contract is
|
|
// enforced.
|
|
assert(BufferSize == 0);
|
|
assert(MaxBuffers == 0);
|
|
assert(Config != nullptr);
|
|
assert(ArgsSize == 0 || ArgsSize == sizeof(Options));
|
|
__xray_log_set_buffer_iterator(next_buffer);
|
|
return XRayLogInitStatus::XRAY_LOG_INITIALIZED;
|
|
}
|
|
|
|
[[clang::xray_never_instrument]] XRayLogInitStatus printing_finalize() {
|
|
return XRayLogInitStatus::XRAY_LOG_FINALIZED;
|
|
}
|
|
|
|
[[clang::xray_never_instrument]] XRayLogFlushStatus printing_flush_log() {
|
|
__xray_log_remove_buffer_iterator();
|
|
return XRayLogFlushStatus::XRAY_LOG_FLUSHED;
|
|
}
|
|
|
|
[[clang::xray_always_instrument]] void callme() { std::printf("called me!\n"); }
|
|
|
|
static auto buffer_counter = 0;
|
|
|
|
void process_buffer(const char *, XRayBuffer) { ++buffer_counter; }
|
|
|
|
int main(int argc, char **argv) {
|
|
assert(__xray_log_register_mode("custom",
|
|
{printing_init, printing_finalize,
|
|
printing_handler, printing_flush_log}) ==
|
|
XRayLogRegisterStatus::XRAY_REGISTRATION_OK);
|
|
assert(__xray_log_select_mode("custom") ==
|
|
XRayLogRegisterStatus::XRAY_REGISTRATION_OK);
|
|
assert(__xray_log_get_current_mode() != nullptr);
|
|
std::string current_mode = __xray_log_get_current_mode();
|
|
assert(current_mode == "custom");
|
|
assert(__xray_patch() == XRayPatchingStatus::SUCCESS);
|
|
assert(__xray_log_init_mode("custom", "flags_config_here=true") ==
|
|
XRayLogInitStatus::XRAY_LOG_INITIALIZED);
|
|
|
|
// Also test that we can use the "binary" version of the
|
|
// __xray_log_niit_mode(...) API.
|
|
assert(__xray_log_init_mode_bin("custom", Options, sizeof(Options)) ==
|
|
XRayLogInitStatus::XRAY_LOG_INITIALIZED);
|
|
|
|
// CHECK: printing {{.*}}
|
|
callme(); // CHECK: called me!
|
|
// CHECK: printing {{.*}}
|
|
assert(__xray_log_finalize() == XRayLogInitStatus::XRAY_LOG_FINALIZED);
|
|
assert(__xray_log_process_buffers(process_buffer) ==
|
|
XRayLogFlushStatus::XRAY_LOG_FLUSHED);
|
|
assert(buffer_counter == 1);
|
|
assert(__xray_log_flushLog() == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
|
|
assert(__xray_log_select_mode("not-found") ==
|
|
XRayLogRegisterStatus::XRAY_MODE_NOT_FOUND);
|
|
}
|