[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / compiler-rt / lib / sanitizer_common / sanitizer_stoptheworld.h
blob7891c1081fe714b5f346261ed87e502205b7faa0
1 //===-- sanitizer_stoptheworld.h --------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Defines the StopTheWorld function which suspends the execution of the current
10 // process and runs the user-supplied callback in the same address space.
12 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_STOPTHEWORLD_H
14 #define SANITIZER_STOPTHEWORLD_H
16 #include "sanitizer_internal_defs.h"
17 #include "sanitizer_common.h"
19 namespace __sanitizer {
21 enum PtraceRegistersStatus {
22 REGISTERS_UNAVAILABLE_FATAL = -1,
23 REGISTERS_UNAVAILABLE = 0,
24 REGISTERS_AVAILABLE = 1
27 // Holds the list of suspended threads and provides an interface to dump their
28 // register contexts.
29 class SuspendedThreadsList {
30 public:
31 SuspendedThreadsList() = default;
33 // Can't declare pure virtual functions in sanitizer runtimes:
34 // __cxa_pure_virtual might be unavailable. Use UNIMPLEMENTED() instead.
35 virtual PtraceRegistersStatus GetRegistersAndSP(
36 uptr index, InternalMmapVector<uptr> *buffer, uptr *sp) const {
37 UNIMPLEMENTED();
40 virtual uptr ThreadCount() const { UNIMPLEMENTED(); }
41 virtual tid_t GetThreadID(uptr index) const { UNIMPLEMENTED(); }
43 protected:
44 ~SuspendedThreadsList() {}
46 private:
47 // Prohibit copy and assign.
48 SuspendedThreadsList(const SuspendedThreadsList &) = delete;
49 void operator=(const SuspendedThreadsList &) = delete;
52 typedef void (*StopTheWorldCallback)(
53 const SuspendedThreadsList &suspended_threads_list,
54 void *argument);
56 // Suspend all threads in the current process and run the callback on the list
57 // of suspended threads. This function will resume the threads before returning.
58 // The callback should not call any libc functions. The callback must not call
59 // exit() nor _exit() and instead return to the caller.
60 // This function should NOT be called from multiple threads simultaneously.
61 void StopTheWorld(StopTheWorldCallback callback, void *argument);
63 } // namespace __sanitizer
65 #endif // SANITIZER_STOPTHEWORLD_H