Skip to content

Commit ef14b3b

Browse files
committed
Use manual definitions for ThrowInfo/CatchableType/CatchableTypeArray always
1 parent 58285ef commit ef14b3b

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

src/from_current.cpp

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -92,42 +92,37 @@ namespace detail {
9292
// - https://github.com/ecatmur/stacktrace-from-exception/blob/main/stacktrace-from-exception.cpp
9393
// - https://github.com/catboost/catboost/blob/master/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
9494
// - https://www.geoffchappell.com/studies/msvc/language/predefined/index.htm
95-
#ifdef _WIN64
96-
#pragma pack(push, 4)
97-
struct CatchableType {
98-
std::uint32_t properties;
99-
std::int32_t pType;
100-
std::uint32_t non_virtual_adjustment; // these next three are from _PMD
101-
std::uint32_t offset_to_virtual_base_ptr;
102-
std::uint32_t virtual_base_table_index;
103-
std::uint32_t sizeOrOffset;
104-
std::int32_t copyFunction;
105-
};
106-
struct ThrowInfo {
107-
std::uint32_t attributes;
108-
std::int32_t pmfnUnwind;
109-
std::int32_t pForwardCompat;
110-
std::int32_t pCatchableTypeArray;
111-
};
112-
#pragma warning(disable:4200)
113-
#if IS_CLANG
114-
#pragma clang diagnostic push
115-
#pragma clang diagnostic ignored "-Wc99-extensions"
116-
#endif
117-
struct CatchableTypeArray {
118-
uint32_t nCatchableTypes;
119-
int32_t arrayOfCatchableTypes[];
120-
};
121-
#if IS_CLANG
122-
#pragma clang diagnostic pop
123-
#endif
124-
#pragma warning (pop)
125-
#pragma pack(pop)
126-
#else
127-
using CatchableTypeArray = ::_CatchableTypeArray;
128-
using CatchableType = ::_CatchableType;
129-
using ThrowInfo = ::_ThrowInfo;
95+
#pragma pack(push, 4)
96+
struct CatchableType {
97+
std::uint32_t properties;
98+
std::int32_t pType;
99+
std::uint32_t non_virtual_adjustment; // these next three are from _PMD
100+
std::uint32_t offset_to_virtual_base_ptr;
101+
std::uint32_t virtual_base_table_index;
102+
std::uint32_t sizeOrOffset;
103+
std::int32_t copyFunction;
104+
};
105+
struct ThrowInfo {
106+
std::uint32_t attributes;
107+
std::int32_t pmfnUnwind;
108+
std::int32_t pForwardCompat;
109+
std::int32_t pCatchableTypeArray;
110+
};
111+
#pragma warning(push)
112+
#pragma warning(disable:4200)
113+
#if IS_CLANG
114+
#pragma clang diagnostic push
115+
#pragma clang diagnostic ignored "-Wc99-extensions"
116+
#endif
117+
struct CatchableTypeArray {
118+
uint32_t nCatchableTypes;
119+
int32_t arrayOfCatchableTypes[];
120+
};
121+
#if IS_CLANG
122+
#pragma clang diagnostic pop
130123
#endif
124+
#pragma warning(pop)
125+
#pragma pack(pop)
131126

132127
static constexpr unsigned EH_MAGIC_NUMBER1 = 0x19930520; // '?msc' version magic, see ehdata.h
133128
static constexpr unsigned EH_EXCEPTION_NUMBER = 0xE06D7363; // '?msc', 'msc' | 0xE0000000
@@ -174,6 +169,7 @@ namespace detail {
174169
#ifdef _WIN64
175170
return reinterpret_cast<T>((uintptr_t)module_pointer + (uintptr_t)address);
176171
#else
172+
(void)module_pointer;
177173
return reinterpret_cast<T>(address);
178174
#endif
179175
}

test/unit/tracing/raw_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ CPPTRACE_FORCE_NO_INLINE static void raw_trace_multi_2(
7171
auto raw_trace = cpptrace::generate_raw_trace();
7272
ASSERT_GE(raw_trace.frames.size(), 2);
7373
EXPECT_GE(raw_trace.frames[0], reinterpret_cast<uintptr_t>(raw_trace_multi_2));
74-
EXPECT_LE(raw_trace.frames[0], reinterpret_cast<uintptr_t>(raw_trace_multi_2) + 90);
74+
EXPECT_LE(raw_trace.frames[0], reinterpret_cast<uintptr_t>(raw_trace_multi_2) + 100);
7575
EXPECT_GE(raw_trace.frames[1], parent_low_bound);
7676
EXPECT_LE(raw_trace.frames[1], parent_high_bound);
7777
}

0 commit comments

Comments
 (0)