annotate libsanitizer/sanitizer_common/sanitizer_stoptheworld.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 //===-- sanitizer_stoptheworld.h --------------------------------*- C++ -*-===//
kono
parents:
diff changeset
2 //
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
111
kono
parents:
diff changeset
6 //
kono
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
8 //
kono
parents:
diff changeset
9 // Defines the StopTheWorld function which suspends the execution of the current
kono
parents:
diff changeset
10 // process and runs the user-supplied callback in the same address space.
kono
parents:
diff changeset
11 //
kono
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
13 #ifndef SANITIZER_STOPTHEWORLD_H
kono
parents:
diff changeset
14 #define SANITIZER_STOPTHEWORLD_H
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 #include "sanitizer_internal_defs.h"
kono
parents:
diff changeset
17 #include "sanitizer_common.h"
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 namespace __sanitizer {
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 enum PtraceRegistersStatus {
kono
parents:
diff changeset
22 REGISTERS_UNAVAILABLE_FATAL = -1,
kono
parents:
diff changeset
23 REGISTERS_UNAVAILABLE = 0,
kono
parents:
diff changeset
24 REGISTERS_AVAILABLE = 1
kono
parents:
diff changeset
25 };
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 // Holds the list of suspended threads and provides an interface to dump their
kono
parents:
diff changeset
28 // register contexts.
kono
parents:
diff changeset
29 class SuspendedThreadsList {
kono
parents:
diff changeset
30 public:
kono
parents:
diff changeset
31 SuspendedThreadsList() = default;
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 // Can't declare pure virtual functions in sanitizer runtimes:
kono
parents:
diff changeset
34 // __cxa_pure_virtual might be unavailable. Use UNIMPLEMENTED() instead.
kono
parents:
diff changeset
35 virtual PtraceRegistersStatus GetRegistersAndSP(uptr index, uptr *buffer,
kono
parents:
diff changeset
36 uptr *sp) const {
kono
parents:
diff changeset
37 UNIMPLEMENTED();
kono
parents:
diff changeset
38 }
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 // The buffer in GetRegistersAndSP should be at least this big.
kono
parents:
diff changeset
41 virtual uptr RegisterCount() const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
42 virtual uptr ThreadCount() const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
43 virtual tid_t GetThreadID(uptr index) const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 private:
kono
parents:
diff changeset
46 // Prohibit copy and assign.
kono
parents:
diff changeset
47 SuspendedThreadsList(const SuspendedThreadsList&);
kono
parents:
diff changeset
48 void operator=(const SuspendedThreadsList&);
kono
parents:
diff changeset
49 };
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 typedef void (*StopTheWorldCallback)(
kono
parents:
diff changeset
52 const SuspendedThreadsList &suspended_threads_list,
kono
parents:
diff changeset
53 void *argument);
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 // Suspend all threads in the current process and run the callback on the list
kono
parents:
diff changeset
56 // of suspended threads. This function will resume the threads before returning.
kono
parents:
diff changeset
57 // The callback should not call any libc functions. The callback must not call
kono
parents:
diff changeset
58 // exit() nor _exit() and instead return to the caller.
kono
parents:
diff changeset
59 // This function should NOT be called from multiple threads simultaneously.
kono
parents:
diff changeset
60 void StopTheWorld(StopTheWorldCallback callback, void *argument);
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 } // namespace __sanitizer
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 #endif // SANITIZER_STOPTHEWORLD_H