blob: 5df8a6af7ac3494bfc8ab6d77f2b7c4b7e5ff678 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// 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 Silverman8fce7482020-01-05 13:18:21 -08004
5#include "wpi/StackTrace.h"
6
7#include "StackWalker.h"
8#include "wpi/ConvertUTF.h"
9#include "wpi/SmallString.h"
10
James Kuszmaulcf324122023-01-14 14:07:17 -080011#if defined(_MSC_VER)
12
Brian Silverman8fce7482020-01-05 13:18:21 -080013namespace {
14class 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
25void StackTraceWalker::OnOutput(LPCTSTR szText) {
Brian Silverman8fce7482020-01-05 13:18:21 -080026 m_output.append(szText);
Brian Silverman8fce7482020-01-05 13:18:21 -080027}
28
29namespace wpi {
30
Austin Schuh75263e32022-02-22 18:05:32 -080031std::string GetStackTraceDefault(int offset) {
Brian Silverman8fce7482020-01-05 13:18:21 -080032 // TODO: implement offset
33 std::string output;
34 StackTraceWalker walker(output);
35 return output;
36}
37
38} // namespace wpi
James Kuszmaulcf324122023-01-14 14:07:17 -080039
40#endif // defined(_MSC_VER)