-
Notifications
You must be signed in to change notification settings - Fork 0
wider _GLIBCXX_DEBUG_BACKTRACE support #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||
| # Copyright (c) 2025 Pyarelal Knowles, MIT License | ||||||||||||||||
|
|
||||||||||||||||
| if(NOT DEFINED GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_SUPPORTED false) | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| # Try default build with no extra libraries | ||||||||||||||||
| if(NOT GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| try_compile( | ||||||||||||||||
| DEBUG_BACKTRACE_JUSTWORKS SOURCE_FROM_CONTENT | ||||||||||||||||
| stdc++_libbacktrace_test.cpp | ||||||||||||||||
| "#include <vector>\nint main() { std::vector<int> v{0}; return v[0]; }" | ||||||||||||||||
| COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE) | ||||||||||||||||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider adding more test cases. The test program only checks vector access. Consider adding more test cases that exercise different aspects of the debug functionality. - "#include <vector>\nint main() { std::vector<int> v{0}; return v[0]; }"
+ "#include <vector>\n#include <string>\nint main() {\n"
+ " std::vector<int> v{0};\n"
+ " std::string s;\n"
+ " s.at(0); // Should trigger debug assertion\n"
+ " return v[0];\n"
+ "}" |
||||||||||||||||
| if(DEBUG_BACKTRACE_JUSTWORKS) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_SUPPORTED true) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_LIBRARY) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_CXX_FEATURE) | ||||||||||||||||
| endif() | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| # Try C++23 with no extra libraries | ||||||||||||||||
| if(NOT GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| try_compile( | ||||||||||||||||
| DEBUG_BACKTRACE_NEEDCXX23 SOURCE_FROM_CONTENT | ||||||||||||||||
| stdc++_libbacktrace_test.cpp | ||||||||||||||||
| "#include <vector>\nint main() { std::vector<int> v{0}; return v[0]; }" | ||||||||||||||||
| COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE | ||||||||||||||||
| CXX_STANDARD 23 CXX_STANDARD_REQUIRED true) | ||||||||||||||||
| if(DEBUG_BACKTRACE_NEEDCXX23) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_SUPPORTED true) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_LIBRARY) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_CXX_FEATURE cxx_std_23) | ||||||||||||||||
| endif() | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| # Try with libstdc++exp | ||||||||||||||||
| if(NOT GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| try_compile( | ||||||||||||||||
| DEBUG_BACKTRACE_NEEDSTDEXP SOURCE_FROM_CONTENT | ||||||||||||||||
| stdc++_libbacktrace_test.cpp | ||||||||||||||||
| "#include <vector>\nint main() { std::vector<int> v{0}; return v[0]; }" | ||||||||||||||||
| COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE CXX_STANDARD | ||||||||||||||||
| 20 CXX_STANDARD_REQUIRED true | ||||||||||||||||
| LINK_LIBRARIES stdc++exp) | ||||||||||||||||
|
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Fix line continuation indentation. The line continuation indentation is inconsistent with other similar blocks in the file. - COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE CXX_STANDARD
- 20 CXX_STANDARD_REQUIRED true
- LINK_LIBRARIES stdc++exp)
+ COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE
+ CXX_STANDARD 20
+ CXX_STANDARD_REQUIRED true
+ LINK_LIBRARIES stdc++exp)📝 Committable suggestion
Suggested change
|
||||||||||||||||
| if(DEBUG_BACKTRACE_NEEDSTDEXP) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_SUPPORTED true) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_LIBRARY stdc++exp) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_CXX_FEATURE) | ||||||||||||||||
| endif() | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| # Try with libstdc++_libbacktrace | ||||||||||||||||
| if(NOT GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| try_compile( | ||||||||||||||||
| DEBUG_BACKTRACE_NEEDLIBBACKTRACE SOURCE_FROM_CONTENT | ||||||||||||||||
| stdc++_libbacktrace_test.cpp | ||||||||||||||||
| "#include <vector>\nint main() { std::vector<int> v{0}; return v[0]; }" | ||||||||||||||||
| COMPILE_DEFINITIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_BACKTRACE CXX_STANDARD | ||||||||||||||||
| 20 CXX_STANDARD_REQUIRED true | ||||||||||||||||
| LINK_LIBRARIES stdc++_libbacktrace) | ||||||||||||||||
| if(DEBUG_BACKTRACE_NEEDLIBBACKTRACE) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_SUPPORTED true) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_LIBRARY stdc++_libbacktrace) | ||||||||||||||||
| set(GLIBCXX_DEBUG_BACKTRACE_CXX_FEATURE) | ||||||||||||||||
| endif() | ||||||||||||||||
| endif() | ||||||||||||||||
|
|
||||||||||||||||
| # Issue a warning if none of the above worked | ||||||||||||||||
| if(NOT GLIBCXX_DEBUG_BACKTRACE_SUPPORTED) | ||||||||||||||||
| message( | ||||||||||||||||
| WARNING "No working try_compile configs with _GLIBCXX_DEBUG_BACKTRACE found" | ||||||||||||||||
| ) | ||||||||||||||||
|
Comment on lines
+70
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Enhance warning message. The warning message could be more informative by suggesting potential solutions. - WARNING "No working try_compile configs with _GLIBCXX_DEBUG_BACKTRACE found"
+ WARNING "No working try_compile configs with _GLIBCXX_DEBUG_BACKTRACE found. "
+ "Try installing libstdc++_libbacktrace or upgrading to a newer compiler." |
||||||||||||||||
| endif() | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Update copyright year.
The copyright year "2025" should be "2024-2025" to match other files.
📝 Committable suggestion