[libcxx-commits] [libcxx] Add C++23 stacktrace (P0881R7) (PR #136528)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 1 01:29:57 PDT 2025


================
@@ -0,0 +1,248 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <cstring>
+#  include <iostream>
+#  include <mutex>
+#  include <stacktrace>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace __stacktrace {
+
+namespace {
+
+struct dll {
+  HMODULE module_{};
+  bool loaded_{};
+
+  explicit dll(char const* name) : module_(LoadLibraryA(name)) {}
+
+  ~dll() {
+    if (module_) {
+      FreeLibrary(module_);
+    }
+  }
+
+  template <typename F>
+  bool get_func(F** func, char const* name) {
+    return ((*func = (F*)(void*)GetProcAddress(module_, name)) != nullptr);
+  }
+};
+
+// clang-format off
+
+struct dbghelp_dll final : dll {
----------------
philnik777 wrote:

What doesthis do?

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


More information about the libcxx-commits mailing list