Commit a3ec35c 1 parent 4bc83a2 commit a3ec35c Copy full SHA for a3ec35c
File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 23
23
# include " V3Stats.h"
24
24
VL_DEFINE_DEBUG_FUNCTIONS;
25
25
#endif
26
+ #include < thread>
26
27
// clang-format on
27
28
28
29
// ======================================================================
@@ -88,11 +89,20 @@ void V3ErrorGuarded::vlAbortOrExit() VL_REQUIRES(m_mutex) {
88
89
if (V3Error::debugDefault ()) {
89
90
std::cerr << msgPrefix () << " Aborting since under --debug" << endl;
90
91
V3Error::vlAbort ();
91
- } else {
92
+ }
93
+ #ifndef V3ERROR_NO_GLOBAL_
94
+ else if (v3Global.opt .verilateJobs () > 1
95
+ && v3Global.mainThreadId () != std::this_thread::get_id ()) {
96
+ VL_GCOV_DUMP (); // No static destructors are called, thus must be called manually.
97
+
92
98
// Exit without triggering any global destructors.
93
99
// Used to prevent detached V3ThreadPool jobs accessing destroyed static objects.
94
100
::_exit (1 );
95
101
}
102
+ #endif
103
+ else {
104
+ std::exit (1 );
105
+ }
96
106
}
97
107
98
108
string V3ErrorGuarded::warnMore () VL_REQUIRES(m_mutex) { return string (msgPrefix ().size (), ' ' ); }
Original file line number Diff line number Diff line change 32
32
#include " V3Options.h"
33
33
34
34
#include < string>
35
+ #include < thread>
35
36
#include < unordered_map>
36
37
#include < unordered_set>
37
38
@@ -133,6 +134,9 @@ class V3Global final {
133
134
// Names of fields that were dumped by dumpJsonPtr()
134
135
std::unordered_set<std::string> m_jsonPtrNames;
135
136
137
+ // Id of the main thread
138
+ const std::thread::id m_mainThreadId = std::this_thread::get_id();
139
+
136
140
public:
137
141
// Options
138
142
V3Options opt; // All options; let user see them directly
@@ -203,6 +207,7 @@ class V3Global final {
203
207
void ptrNamesDumpJson (std::ostream& os);
204
208
void idPtrMapDumpJson (std::ostream& os);
205
209
const std::string& ptrToId (const void * p);
210
+ std::thread::id mainThreadId () const { return m_mainThreadId; }
206
211
};
207
212
208
213
extern V3Global v3Global;
You can’t perform that action at this time.
0 commit comments