* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_stoptheworld.h
blob8c3d2c055571ec65c686b7bd72ca20cad85af084
1 //===-- sanitizer_stoptheworld.h --------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Defines the StopTheWorld function which suspends the execution of the current
9 // process and runs the user-supplied callback in the same address space.
11 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_STOPTHEWORLD_H
13 #define SANITIZER_STOPTHEWORLD_H
15 #include "sanitizer_internal_defs.h"
16 #include "sanitizer_common.h"
18 namespace __sanitizer {
20 enum PtraceRegistersStatus {
21 REGISTERS_UNAVAILABLE_FATAL = -1,
22 REGISTERS_UNAVAILABLE = 0,
23 REGISTERS_AVAILABLE = 1
26 // Holds the list of suspended threads and provides an interface to dump their
27 // register contexts.
28 class SuspendedThreadsList {
29 public:
30 SuspendedThreadsList() = default;
32 // Can't declare pure virtual functions in sanitizer runtimes:
33 // __cxa_pure_virtual might be unavailable. Use UNIMPLEMENTED() instead.
34 virtual PtraceRegistersStatus GetRegistersAndSP(uptr index, uptr *buffer,
35 uptr *sp) const {
36 UNIMPLEMENTED();
39 // The buffer in GetRegistersAndSP should be at least this big.
40 virtual uptr RegisterCount() const { UNIMPLEMENTED(); }
41 virtual uptr ThreadCount() const { UNIMPLEMENTED(); }
42 virtual tid_t GetThreadID(uptr index) const { UNIMPLEMENTED(); }
44 private:
45 // Prohibit copy and assign.
46 SuspendedThreadsList(const SuspendedThreadsList&);
47 void operator=(const SuspendedThreadsList&);
50 typedef void (*StopTheWorldCallback)(
51 const SuspendedThreadsList &suspended_threads_list,
52 void *argument);
54 // Suspend all threads in the current process and run the callback on the list
55 // of suspended threads. This function will resume the threads before returning.
56 // The callback should not call any libc functions. The callback must not call
57 // exit() nor _exit() and instead return to the caller.
58 // This function should NOT be called from multiple threads simultaneously.
59 void StopTheWorld(StopTheWorldCallback callback, void *argument);
61 } // namespace __sanitizer
63 #endif // SANITIZER_STOPTHEWORLD_H