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
105 lines
3.9 KiB
C++
105 lines
3.9 KiB
C++
//===-- xray_s390x.cpp ------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of XRay, a dynamic runtime instrumentation system.
|
|
//
|
|
// Implementation of s390x routines.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
#include "xray_defs.h"
|
|
#include "xray_interface_internal.h"
|
|
#include <cassert>
|
|
#include <cstring>
|
|
|
|
bool __xray::patchFunctionEntry(const bool Enable, const uint32_t FuncId,
|
|
const XRaySledEntry &Sled,
|
|
const XRayTrampolines &Trampolines,
|
|
bool LogArgs) XRAY_NEVER_INSTRUMENT {
|
|
uint32_t *Address = reinterpret_cast<uint32_t *>(Sled.address());
|
|
// TODO: Trampoline addresses are currently inserted at compile-time, using
|
|
// __xray_FunctionEntry and __xray_FunctionExit only.
|
|
// To support DSO instrumentation, trampolines have to be written during
|
|
// patching (see implementation on X86_64, e.g.).
|
|
if (Enable) {
|
|
// The resulting code is:
|
|
// stmg %r2, %r15, 16(%r15)
|
|
// llilf %2, FuncID
|
|
// brasl %r14, __xray_FunctionEntry@GOT
|
|
// The FuncId and the stmg instruction must be written.
|
|
|
|
// Write FuncId into llilf.
|
|
Address[2] = FuncId;
|
|
// Write last part of stmg.
|
|
reinterpret_cast<uint16_t *>(Address)[2] = 0x24;
|
|
// Write first part of stmg.
|
|
Address[0] = 0xeb2ff010;
|
|
} else {
|
|
// j +16 instructions.
|
|
Address[0] = 0xa7f4000b;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool __xray::patchFunctionExit(
|
|
const bool Enable, const uint32_t FuncId, const XRaySledEntry &Sled,
|
|
const XRayTrampolines &Trampolines) XRAY_NEVER_INSTRUMENT {
|
|
uint32_t *Address = reinterpret_cast<uint32_t *>(Sled.address());
|
|
// TODO: Trampoline addresses are currently inserted at compile-time, using
|
|
// __xray_FunctionEntry and __xray_FunctionExit only.
|
|
// To support DSO instrumentation, trampolines have to be written during
|
|
// patching (see implementation on X86_64, e.g.).
|
|
if (Enable) {
|
|
// The resulting code is:
|
|
// stmg %r2, %r15, 24(%r15)
|
|
// llilf %2,FuncID
|
|
// j __xray_FunctionEntry@GOT
|
|
// The FuncId and the stmg instruction must be written.
|
|
|
|
// Write FuncId into llilf.
|
|
Address[2] = FuncId;
|
|
// Write last part of of stmg.
|
|
reinterpret_cast<uint16_t *>(Address)[2] = 0x24;
|
|
// Write first part of stmg.
|
|
Address[0] = 0xeb2ff010;
|
|
} else {
|
|
// br %14 instruction.
|
|
reinterpret_cast<uint16_t *>(Address)[0] = 0x07fe;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool __xray::patchFunctionTailExit(
|
|
const bool Enable, const uint32_t FuncId, const XRaySledEntry &Sled,
|
|
const XRayTrampolines &Trampolines) XRAY_NEVER_INSTRUMENT {
|
|
return patchFunctionExit(Enable, FuncId, Sled, Trampolines);
|
|
}
|
|
|
|
bool __xray::patchCustomEvent(const bool Enable, const uint32_t FuncId,
|
|
const XRaySledEntry &Sled) XRAY_NEVER_INSTRUMENT {
|
|
// TODO Implement.
|
|
return false;
|
|
}
|
|
|
|
bool __xray::patchTypedEvent(const bool Enable, const uint32_t FuncId,
|
|
const XRaySledEntry &Sled) XRAY_NEVER_INSTRUMENT {
|
|
// TODO Implement.
|
|
return false;
|
|
}
|
|
|
|
extern "C" void __xray_ArgLoggerEntry() XRAY_NEVER_INSTRUMENT {
|
|
// TODO this will have to be implemented in the trampoline assembly file.
|
|
}
|
|
|
|
extern "C" void __xray_FunctionTailExit() XRAY_NEVER_INSTRUMENT {
|
|
// For PowerPC, calls to __xray_FunctionEntry and __xray_FunctionExit
|
|
// are statically inserted into the sled. Tail exits are handled like normal
|
|
// function exits. This trampoline is therefore not implemented.
|
|
// This stub is placed here to avoid linking issues.
|
|
}
|