Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | // Copyright (c) FIRST and other WPILib contributors. |
| 2 | // Open Source Software; you can modify and/or share it under the terms of |
| 3 | // the WPILib BSD license file in the root directory of this project. |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 4 | |
| 5 | #include "wpi/StackTrace.h" |
| 6 | |
| 7 | #include "StackWalker.h" |
| 8 | #include "wpi/ConvertUTF.h" |
| 9 | #include "wpi/SmallString.h" |
| 10 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 11 | #if defined(_MSC_VER) |
| 12 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 13 | namespace { |
| 14 | class StackTraceWalker : public StackWalker { |
| 15 | public: |
| 16 | explicit StackTraceWalker(std::string& output) : m_output(output) {} |
| 17 | |
| 18 | void OnOutput(LPCTSTR szText) override; |
| 19 | |
| 20 | private: |
| 21 | std::string& m_output; |
| 22 | }; |
| 23 | } // namespace |
| 24 | |
| 25 | void StackTraceWalker::OnOutput(LPCTSTR szText) { |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 26 | m_output.append(szText); |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | namespace wpi { |
| 30 | |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 31 | std::string GetStackTraceDefault(int offset) { |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 32 | // TODO: implement offset |
| 33 | std::string output; |
| 34 | StackTraceWalker walker(output); |
| 35 | return output; |
| 36 | } |
| 37 | |
| 38 | } // namespace wpi |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 39 | |
| 40 | #endif // defined(_MSC_VER) |