annotate libsanitizer/sanitizer_common/sanitizer_stoptheworld.h @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 04ced10e8804
children 1830386684a0
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 //
kono
parents:
diff changeset
3 // This file is distributed under the University of Illinois Open Source
kono
parents:
diff changeset
4 // License. See LICENSE.TXT for details.
kono
parents:
diff changeset
5 //
kono
parents:
diff changeset
6 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
7 //
kono
parents:
diff changeset
8 // Defines the StopTheWorld function which suspends the execution of the current
kono
parents:
diff changeset
9 // process and runs the user-supplied callback in the same address space.
kono
parents:
diff changeset
10 //
kono
parents:
diff changeset
11 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
12 #ifndef SANITIZER_STOPTHEWORLD_H
kono
parents:
diff changeset
13 #define SANITIZER_STOPTHEWORLD_H
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 #include "sanitizer_internal_defs.h"
kono
parents:
diff changeset
16 #include "sanitizer_common.h"
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 namespace __sanitizer {
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 enum PtraceRegistersStatus {
kono
parents:
diff changeset
21 REGISTERS_UNAVAILABLE_FATAL = -1,
kono
parents:
diff changeset
22 REGISTERS_UNAVAILABLE = 0,
kono
parents:
diff changeset
23 REGISTERS_AVAILABLE = 1
kono
parents:
diff changeset
24 };
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 // Holds the list of suspended threads and provides an interface to dump their
kono
parents:
diff changeset
27 // register contexts.
kono
parents:
diff changeset
28 class SuspendedThreadsList {
kono
parents:
diff changeset
29 public:
kono
parents:
diff changeset
30 SuspendedThreadsList() = default;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 // Can't declare pure virtual functions in sanitizer runtimes:
kono
parents:
diff changeset
33 // __cxa_pure_virtual might be unavailable. Use UNIMPLEMENTED() instead.
kono
parents:
diff changeset
34 virtual PtraceRegistersStatus GetRegistersAndSP(uptr index, uptr *buffer,
kono
parents:
diff changeset
35 uptr *sp) const {
kono
parents:
diff changeset
36 UNIMPLEMENTED();
kono
parents:
diff changeset
37 }
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 // The buffer in GetRegistersAndSP should be at least this big.
kono
parents:
diff changeset
40 virtual uptr RegisterCount() const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
41 virtual uptr ThreadCount() const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
42 virtual tid_t GetThreadID(uptr index) const { UNIMPLEMENTED(); }
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 private:
kono
parents:
diff changeset
45 // Prohibit copy and assign.
kono
parents:
diff changeset
46 SuspendedThreadsList(const SuspendedThreadsList&);
kono
parents:
diff changeset
47 void operator=(const SuspendedThreadsList&);
kono
parents:
diff changeset
48 };
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 typedef void (*StopTheWorldCallback)(
kono
parents:
diff changeset
51 const SuspendedThreadsList &suspended_threads_list,
kono
parents:
diff changeset
52 void *argument);
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 // Suspend all threads in the current process and run the callback on the list
kono
parents:
diff changeset
55 // of suspended threads. This function will resume the threads before returning.
kono
parents:
diff changeset
56 // The callback should not call any libc functions. The callback must not call
kono
parents:
diff changeset
57 // exit() nor _exit() and instead return to the caller.
kono
parents:
diff changeset
58 // This function should NOT be called from multiple threads simultaneously.
kono
parents:
diff changeset
59 void StopTheWorld(StopTheWorldCallback callback, void *argument);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 } // namespace __sanitizer
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 #endif // SANITIZER_STOPTHEWORLD_H