[libcxx-commits] [libcxx] [libc++] Add std::stacktrace (P0881R7) (PR #136528)

Steve O'Brien via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 8 08:42:04 PDT 2026


================
@@ -0,0 +1,295 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(_WIN32)
+
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+//
+#  include <dbghelp.h>
+#  include <psapi.h>
+//
+#  include <__stacktrace/basic_stacktrace.h>
+#  include <__stacktrace/stacktrace_entry.h>
+#  include <cstring>
+#  include <mutex>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace __stacktrace {
+
+namespace {
+
+namespace __dll {
+
+template <typename F>
+bool get_func(HMODULE module, F** func, char const* name) {
+  return ((*func = reinterpret_cast<F*>(reinterpret_cast<void*>(GetProcAddress(module, name)))) != nullptr);
+}
+
+// clang-format off
+bool(WINAPI* EnumProcessModules)(HANDLE, HMODULE*, DWORD, DWORD*);
----------------
elsteveogrande wrote:

ah, could explain why I had crashes when I tested this on windows way back when :)

https://github.com/llvm/llvm-project/pull/136528


More information about the libcxx-commits mailing list