2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
22 #include "../../stdafx.h"
24 #include "../stack_trace.h"
25 #include "../../utf.h"
27 #include "../../compiler/vs/StackWalker.h"
31 #include <tbb/enumerable_thread_specific.h>
35 std::wstring get_call_stack()
37 class log_call_stack_walker : public StackWalker
41 log_call_stack_walker() : StackWalker() {}
45 return std::move(str_);
48 virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName) override
51 virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion) override
54 virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr) override
57 virtual void OnOutput(LPCSTR szText) override
59 std::string str = szText;
61 if(str.find("caspar::get_call_stack") == std::string::npos && str.find("StackWalker::ShowCallstack") == std::string::npos)
62 str_ += std::move(str);
66 static tbb::enumerable_thread_specific<log_call_stack_walker> walkers;
69 auto& walker = walkers.local();
70 walker.ShowCallstack();
71 return u16(walker.flush());