summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/directoryentry.cpp2
-rw-r--r--src/shared/directoryentry.h1
-rw-r--r--src/shared/util.cpp36
-rw-r--r--src/shared/util.h3
4 files changed, 40 insertions, 2 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index eaba91a6..abf9affb 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -155,7 +155,7 @@ void FilesOrigin::setPriority(int priority)
{
m_OriginConnection->changePriorityLookup(m_Priority, priority);
- m_Priority = priority;
+ m_Priority = priority;
}
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index e292861d..c6d155de 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -31,6 +31,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <boost/shared_ptr.hpp>
#include "util.h"
+
namespace MOShared {
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index c256e959..a6378a74 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -19,8 +19,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "windows_error.h"
+#include "error_report.h"
+
#include <sstream>
#include <algorithm>
+#include <DbgHelp.h>
namespace MOShared {
@@ -119,4 +122,35 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
}
}
-} // namespace MOShared
+
+
+
+std::string GetStack()
+{
+#ifdef DEBUG
+ HANDLE process = ::GetCurrentProcess();
+ static bool firstCall = true;
+ if (firstCall) {
+ ::SymInitialize(process, NULL, TRUE);
+ firstCall = false;
+ }
+
+ LPVOID stack[32];
+ WORD frames = ::CaptureStackBackTrace(0, 100, stack, NULL);
+ SYMBOL_INFO_PACKAGE symbol;
+ symbol.si.SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol.si.MaxNameLen = MAX_SYM_NAME;
+
+ std::ostringstream stackStream;
+ for(unsigned int i = 0; i < frames; ++i) {
+ ::SymFromAddr(process, (DWORD64)(stack[i]), 0, &symbol.si);
+ stackStream << frames - i - 1 << ": " << symbol.si.Name << "\n";
+ }
+ return stackStream.str();
+#else
+ return "";
+#endif
+}
+
+
+} // namespace MOShared
diff --git a/src/shared/util.h b/src/shared/util.h
index 4faf0a30..9c59f6db 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -45,6 +45,9 @@ std::wstring ToLower(const std::wstring &text);
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName);
+/// Get a stack trace as a line-break separated list of function names. This only works in debug builds
+std::string GetStack();
+
} // namespace MOShared
#endif // UTIL_H