Skip to content

Commit 8ca8c15

Browse files
Move stacktrace srcs out of experimental
1 parent 316e17c commit 8ca8c15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+233
-237
lines changed

libcxx/docs/UserDocumentation.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ when ``-fexperimental-library`` is passed:
7070

7171
* The parallel algorithms library (``<execution>`` and the associated algorithms)
7272
* ``std::chrono::tzdb`` and related time zone functionality
73-
* ``<stacktrace>``
7473
* ``<syncstream>``
7574

7675
.. note::

libcxx/include/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,10 @@ set(files
728728
__ranges/zip_view.h
729729
__split_buffer
730730
__stacktrace/basic_stacktrace.h
731-
__stacktrace/detail/alloc.h
732-
__stacktrace/detail/context.h
733-
__stacktrace/detail/entry.h
734-
__stacktrace/detail/to_string.h
731+
__stacktrace/alloc.h
732+
__stacktrace/context.h
733+
__stacktrace/entry.h
734+
__stacktrace/to_string.h
735735
__stacktrace/stacktrace_entry.h
736736
__std_mbstate_t.h
737737
__stop_token/atomic_unique_lock.h

libcxx/include/__stacktrace/detail/alloc.h renamed to libcxx/include/__stacktrace/alloc.h

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE_ALLOC
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE_ALLOC
10+
#ifndef _LIBCPP_STACKTRACE_ALLOC
11+
#define _LIBCPP_STACKTRACE_ALLOC
1212

1313
#include <__config>
1414
#include <__functional/function.h>
@@ -29,7 +29,7 @@ namespace __stacktrace {
2929
/** Per-stacktrace-invocation allocator which wraps a caller-provided allocator of any type.
3030
This is intended to be used with `std::pmr::` containers and strings throughout the stacktrace
3131
creation process. */
32-
struct alloc final : std::pmr::memory_resource {
32+
struct _LIBCPP_HIDDEN alloc final : std::pmr::memory_resource {
3333
template <class _Allocator>
3434
_LIBCPP_HIDE_FROM_ABI explicit alloc(_Allocator const& __a) {
3535
// Take the given allocator type, and rebind with a new type having <byte> as the template arg
@@ -38,28 +38,22 @@ struct alloc final : std::pmr::memory_resource {
3838
auto __ba = _BA(__a);
3939
__alloc_func_ = [__ba](size_t __sz) mutable { return __ba.allocate(__sz); };
4040
__dealloc_func_ = [__ba](void* __ptr, size_t __sz) mutable { return __ba.deallocate((std::byte*)__ptr, __sz); };
41-
__alloc_opaque_ = std::addressof(__a);
41+
__alloc_ptr = std::addressof(__a);
4242
}
4343

44-
_LIBCPP_HIDE_FROM_ABI_VIRTUAL ~alloc() override = default;
44+
_LIBCPP_HIDE_FROM_ABI ~alloc() override;
4545

46-
_LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void _anchor_vfunc();
47-
48-
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __size, size_t __align) override {
49-
// Avoiding "assert" in a system header, but we expect this to hold:
50-
// assert(__align <= alignof(std::max_align_t));
51-
(void)__align;
46+
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __size, size_t /*__align*/) override {
5247
return __alloc_func_(__size);
5348
}
5449

55-
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __ptr, size_t __size, size_t __align) override {
56-
(void)__align;
50+
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __ptr, size_t __size, size_t /*__align*/) override {
5751
__dealloc_func_((std::byte*)__ptr, __size);
5852
}
5953

6054
_LIBCPP_HIDE_FROM_ABI_VIRTUAL bool do_is_equal(std::pmr::memory_resource const& __rhs) const noexcept override {
6155
auto* __rhs_ba = dynamic_cast<alloc const*>(&__rhs);
62-
return __rhs_ba && (__rhs_ba->__alloc_opaque_ == __alloc_opaque_);
56+
return __rhs_ba && (__rhs_ba->__alloc_ptr == __alloc_ptr);
6357
}
6458

6559
_LIBCPP_HIDE_FROM_ABI std::pmr::string new_string(size_t __size = 0) {
@@ -93,11 +87,11 @@ struct alloc final : std::pmr::memory_resource {
9387
private:
9488
std::function<std::byte*(size_t)> __alloc_func_;
9589
std::function<void(std::byte*, size_t)> __dealloc_func_;
96-
/** Only used for equality */
97-
void const* __alloc_opaque_;
90+
/** Only used for checking equality */
91+
void const* __alloc_ptr;
9892
};
9993

10094
} // namespace __stacktrace
10195
_LIBCPP_END_NAMESPACE_STD
10296

103-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE_ALLOC
97+
#endif // _LIBCPP_STACKTRACE_ALLOC

libcxx/include/__stacktrace/basic_stacktrace.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_BASIC_STACKTRACE
11-
#define _LIBCPP_EXPERIMENTAL_BASIC_STACKTRACE
10+
#ifndef _LIBCPP_BASIC_STACKTRACE
11+
#define _LIBCPP_BASIC_STACKTRACE
1212

13-
#include <experimental/__stacktrace/detail/entry.h>
14-
#include <experimental/__stacktrace/stacktrace_entry.h>
13+
#include <__stacktrace/entry.h>
14+
#include <__stacktrace/stacktrace_entry.h>
1515

1616
#include <__config>
1717
#include <__format/formatter.h>
@@ -37,9 +37,9 @@
3737
#include <memory>
3838
#include <string>
3939

40-
#include <__stacktrace/detail/alloc.h>
41-
#include <__stacktrace/detail/context.h>
42-
#include <__stacktrace/detail/to_string.h>
40+
#include <__stacktrace/alloc.h>
41+
#include <__stacktrace/context.h>
42+
#include <__stacktrace/to_string.h>
4343

4444
_LIBCPP_BEGIN_NAMESPACE_STD
4545

@@ -303,4 +303,4 @@ struct _LIBCPP_EXPORTED_FROM_ABI hash<basic_stacktrace<_Allocator>> {
303303

304304
_LIBCPP_END_NAMESPACE_STD
305305

306-
#endif // _LIBCPP_EXPERIMENTAL_BASIC_STACKTRACE
306+
#endif // _LIBCPP_BASIC_STACKTRACE

libcxx/include/__stacktrace/detail/context.h renamed to libcxx/include/__stacktrace/context.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE_CONTEXT
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE_CONTEXT
10+
#ifndef _LIBCPP_STACKTRACE_CONTEXT
11+
#define _LIBCPP_STACKTRACE_CONTEXT
1212

1313
#include <__config>
1414
#include <__memory_resource/memory_resource.h>
@@ -18,20 +18,20 @@
1818
#include <cstddef>
1919
#include <string>
2020

21-
#include <experimental/__stacktrace/detail/alloc.h>
22-
#include <experimental/__stacktrace/detail/entry.h>
21+
#include <__stacktrace/alloc.h>
22+
#include <__stacktrace/entry.h>
2323

2424
_LIBCPP_BEGIN_NAMESPACE_STD
2525

26-
struct _LIBCPP_HIDE_FROM_ABI alloc;
27-
struct _LIBCPP_HIDE_FROM_ABI entry;
26+
struct _LIBCPP_HIDDEN alloc;
27+
struct _LIBCPP_HIDDEN entry;
2828

2929
namespace __stacktrace {
3030

3131
/** Represents the state of the current in-progress stacktrace operation. This includes
3232
the working list of `entry` objects, as well as the caller-provided allocator (wrapped
3333
in `polymorphic_allocator`) and a handful of utility functions involving that allocator. */
34-
struct _LIBCPP_HIDE_FROM_ABI context {
34+
struct _LIBCPP_HIDDEN context {
3535
/** Encapsulates and type-removes the caller's allocator. */
3636
alloc& __alloc_;
3737

@@ -41,13 +41,13 @@ struct _LIBCPP_HIDE_FROM_ABI context {
4141
/** Path to this process's main executable. */
4242
std::pmr::string __main_prog_path_;
4343

44-
_LIBCPP_HIDE_FROM_ABI explicit context(alloc& __byte_alloc)
44+
_LIBCPP_HIDDEN explicit context(alloc& __byte_alloc)
4545
: __alloc_(__byte_alloc), __entries_(&__alloc_), __main_prog_path_(__alloc_.new_string()) {}
4646

47-
_LIBCPP_NO_TAIL_CALLS _LIBCPP_NOINLINE void do_stacktrace(size_t __skip, size_t __max_depth);
47+
_LIBCPP_NO_TAIL_CALLS _LIBCPP_NOINLINE _LIBCPP_HIDDEN void do_stacktrace(size_t __skip, size_t __max_depth);
4848
};
4949

5050
} // namespace __stacktrace
5151
_LIBCPP_END_NAMESPACE_STD
5252

53-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE_CONTEXT
53+
#endif // _LIBCPP_STACKTRACE_CONTEXT

libcxx/include/__stacktrace/detail/entry.h renamed to libcxx/include/__stacktrace/entry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE_DETAIL_ENTRY
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE_DETAIL_ENTRY
10+
#ifndef _LIBCPP_STACKTRACE_DETAIL_ENTRY
11+
#define _LIBCPP_STACKTRACE_DETAIL_ENTRY
1212

1313
#include <__config>
1414
#include <cstdint>
@@ -41,4 +41,4 @@ struct _LIBCPP_HIDE_FROM_ABI entry {
4141
} // namespace __stacktrace
4242
_LIBCPP_END_NAMESPACE_STD
4343

44-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE_DETAIL_ENTRY
44+
#endif // _LIBCPP_STACKTRACE_DETAIL_ENTRY

libcxx/include/__stacktrace/stacktrace_entry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE_ENTRY
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE_ENTRY
10+
#ifndef _LIBCPP_STACKTRACE_ENTRY
11+
#define _LIBCPP_STACKTRACE_ENTRY
1212

1313
#include <__cstddef/byte.h>
1414
#include <__cstddef/ptrdiff_t.h>
@@ -33,7 +33,7 @@
3333
#include <cstdint>
3434
#include <string>
3535

36-
#include <__stacktrace/detail/entry.h>
36+
#include <__stacktrace/entry.h>
3737

3838
_LIBCPP_BEGIN_NAMESPACE_STD
3939

@@ -108,4 +108,4 @@ struct _LIBCPP_EXPORTED_FROM_ABI hash<stacktrace_entry> {
108108

109109
_LIBCPP_END_NAMESPACE_STD
110110

111-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE_ENTRY
111+
#endif // _LIBCPP_STACKTRACE_ENTRY

libcxx/include/__stacktrace/detail/to_string.h renamed to libcxx/include/__stacktrace/to_string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE_TO_STRING
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE_TO_STRING
10+
#ifndef _LIBCPP_STACKTRACE_TO_STRING
11+
#define _LIBCPP_STACKTRACE_TO_STRING
1212

1313
#include <__config>
1414
#include <__fwd/sstream.h>
@@ -43,4 +43,4 @@ struct _LIBCPP_HIDE_FROM_ABI __to_string {
4343

4444
_LIBCPP_END_NAMESPACE_STD
4545

46-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE_TO_STRING
46+
#endif // _LIBCPP_STACKTRACE_TO_STRING

libcxx/include/module.modulemap.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,10 +1987,10 @@ module std [system] {
19871987

19881988
module stacktrace {
19891989
module basic_stacktrace { header "__stacktrace/basic_stacktrace.h" }
1990-
module alloc { header "__stacktrace/detail/alloc.h" }
1991-
module context { header "__stacktrace/detail/context.h" }
1992-
module entry { header "__stacktrace/detail/entry.h" }
1993-
module to_string { header "__stacktrace/detail/to_string.h" }
1990+
module alloc { header "__stacktrace/alloc.h" }
1991+
module context { header "__stacktrace/context.h" }
1992+
module entry { header "__stacktrace/entry.h" }
1993+
module to_string { header "__stacktrace/to_string.h" }
19941994
module stacktrace_entry { header "__stacktrace/stacktrace_entry.h" }
19951995
header "stacktrace"
19961996
export *

libcxx/include/stacktrace

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP_EXPERIMENTAL_STACKTRACE
11-
#define _LIBCPP_EXPERIMENTAL_STACKTRACE
10+
#ifndef _LIBCPP_STACKTRACE
11+
#define _LIBCPP_STACKTRACE
1212

1313
/*
1414
Header <stacktrace> synopsis
@@ -188,4 +188,4 @@ _LIBCPP_POP_MACROS
188188
# endif // _LIBCPP_STD_VER >= 23
189189
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
190190

191-
#endif // _LIBCPP_EXPERIMENTAL_STACKTRACE
191+
#endif // _LIBCPP_STACKTRACE

libcxx/modules/std/stacktrace.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
export namespace std {
11-
// TODO(stacktrace23): update this when stacktrace is taken out of experimental
12-
#if 0 //_LIBCPP_STD_VER >= 23
11+
#if _LIBCPP_STD_VER >= 23
1312

1413
// [stacktrace.entry], class stacktrace_­entry
1514
using std::stacktrace_entry;

libcxx/src/CMakeLists.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ set(LIBCXX_SOURCES
4040
ryu/d2fixed.cpp
4141
ryu/d2s.cpp
4242
ryu/f2s.cpp
43+
stacktrace/alloc.cpp
44+
stacktrace/common/debug.cpp
45+
stacktrace/common/fd.cpp
46+
stacktrace/context.cpp
47+
stacktrace/linux/linux-dl.cpp
48+
stacktrace/linux/linux-elf.cpp
49+
stacktrace/linux/linux-sym.cpp
50+
stacktrace/osx/osx.cpp
51+
stacktrace/stacktrace.cpp
52+
stacktrace/tools/addr2line.cpp
53+
stacktrace/tools/atos.cpp
54+
stacktrace/tools/llvm_symbolizer.cpp
55+
stacktrace/tools/toolspawner.cpp
56+
stacktrace/unwind/unwind.cpp
57+
stacktrace/windows/dbghelp_dll.cpp
58+
stacktrace/windows/dll.cpp
59+
stacktrace/windows/psapi_dll.cpp
60+
stacktrace/windows/win_impl.cpp
4361
stdexcept.cpp
4462
string.cpp
4563
support/runtime/exception_fallback.ipp
@@ -309,24 +327,6 @@ add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
309327
# Build the experimental static library
310328
set(LIBCXX_EXPERIMENTAL_SOURCES
311329
experimental/keep.cpp
312-
experimental/stacktrace/alloc.cpp
313-
experimental/stacktrace/common/debug.cpp
314-
experimental/stacktrace/common/fd.cpp
315-
experimental/stacktrace/context.cpp
316-
experimental/stacktrace/linux/linux-dl.cpp
317-
experimental/stacktrace/linux/linux-elf.cpp
318-
experimental/stacktrace/linux/linux-sym.cpp
319-
experimental/stacktrace/osx/osx.cpp
320-
experimental/stacktrace/stacktrace.cpp
321-
experimental/stacktrace/tools/addr2line.cpp
322-
experimental/stacktrace/tools/atos.cpp
323-
experimental/stacktrace/tools/llvm_symbolizer.cpp
324-
experimental/stacktrace/tools/toolspawner.cpp
325-
experimental/stacktrace/unwind/unwind.cpp
326-
experimental/stacktrace/windows/dbghelp_dll.cpp
327-
experimental/stacktrace/windows/dll.cpp
328-
experimental/stacktrace/windows/psapi_dll.cpp
329-
experimental/stacktrace/windows/win_impl.cpp
330330
)
331331

332332
if (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch")

libcxx/src/stacktrace/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# C++23 `<stacktrace>`
2+
3+
# References
4+
5+
1. https://eel.is/c++draft/stacktrace

libcxx/src/experimental/stacktrace/alloc.cpp renamed to libcxx/src/stacktrace/alloc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#include <__config>
1010
#include <__config_site>
1111

12-
#include <experimental/__stacktrace/detail/alloc.h>
12+
#include <__stacktrace/alloc.h>
1313

1414
_LIBCPP_BEGIN_NAMESPACE_STD
1515
namespace __stacktrace {
1616

17-
void alloc::_anchor_vfunc() {}
17+
alloc::~alloc() {}
1818

1919
} // namespace __stacktrace
2020
_LIBCPP_END_NAMESPACE_STD

libcxx/src/experimental/stacktrace/context.cpp renamed to libcxx/src/stacktrace/context.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
#include <list>
1313

14-
#include <experimental/__stacktrace/basic_stacktrace.h>
15-
#include <experimental/__stacktrace/stacktrace_entry.h>
14+
#include <__stacktrace/basic_stacktrace.h>
15+
#include <__stacktrace/stacktrace_entry.h>
1616

17-
#include <experimental/__stacktrace/detail/alloc.h>
18-
#include <experimental/__stacktrace/detail/context.h>
19-
#include <experimental/__stacktrace/detail/entry.h>
20-
#include <experimental/__stacktrace/detail/to_string.h>
17+
#include <__stacktrace/alloc.h>
18+
#include <__stacktrace/context.h>
19+
#include <__stacktrace/entry.h>
20+
#include <__stacktrace/to_string.h>
2121

2222
#include "common/config.h"
2323

@@ -44,7 +44,7 @@
4444
_LIBCPP_BEGIN_NAMESPACE_STD
4545
namespace __stacktrace {
4646

47-
_LIBCPP_NO_TAIL_CALLS _LIBCPP_NOINLINE void context::do_stacktrace(size_t skip, size_t max_depth) {
47+
_LIBCPP_NO_TAIL_CALLS _LIBCPP_NOINLINE _LIBCPP_HIDDEN void context::do_stacktrace(size_t skip, size_t max_depth) {
4848
/*
4949
Here we declare stacktrace components or "backends" which will handle the different tasks:
5050

libcxx/src/experimental/stacktrace/linux/linux-dl.cpp renamed to libcxx/src/stacktrace/linux/linux-dl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
# include "../common/images.h"
2121

22-
# include <experimental/__stacktrace/detail/context.h>
23-
# include <experimental/__stacktrace/detail/entry.h>
22+
# include <__stacktrace/context.h>
23+
# include <__stacktrace/entry.h>
2424

2525
_LIBCPP_BEGIN_NAMESPACE_STD
2626
namespace __stacktrace {

0 commit comments

Comments
 (0)