Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Rusin committed Jan 19, 2024
1 parent 12a12fb commit 72c7c95
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions include/ioh/common/factory.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#pragma once

#if defined(_MSC_VER)
#include <Windows.h>
#include <DbgHelp.h>
#endif


#include <algorithm>
#include <cassert>
#include <cstdlib>
Expand All @@ -27,66 +21,6 @@
#include "container_utils.hpp"
#include "file.hpp"




#if defined(_MSC_VER)
void print_windows_backtrace() {
HANDLE process = GetCurrentProcess();
HANDLE thread = GetCurrentThread();

CONTEXT context = {};
context.ContextFlags = CONTEXT_FULL;
RtlCaptureContext(&context);

SymInitialize(process, NULL, TRUE);

STACKFRAME64 stackframe;
ZeroMemory(&stackframe, sizeof(STACKFRAME64));
DWORD image;

#ifdef _M_IX86
image = IMAGE_FILE_MACHINE_I386;
stackframe.AddrPC.Offset = context.Eip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Ebp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Esp;
stackframe.AddrStack.Mode = AddrModeFlat;
#elif _M_X64
image = IMAGE_FILE_MACHINE_AMD64;
stackframe.AddrPC.Offset = context.Rip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Rsp;
stackframe.AddrFrame.Mode = AddrModeFlat;
stackframe.AddrStack.Offset = context.Rsp;
stackframe.AddrStack.Mode = AddrModeFlat;
#else
#error "Platform not supported!"
#endif

for (size_t i = 0; i < 62; ++i) {
BOOL result = StackWalk64(
image, process, thread,
&stackframe, &context, NULL,
SymFunctionTableAccess64, SymGetModuleBase64, NULL);

if (!result) { break; }

std::cerr << "Frame " << i << ": ";
std::cerr << "PC = " << stackframe.AddrPC.Offset << ", ";
std::cerr << "Frame = " << stackframe.AddrFrame.Offset << ", ";
std::cerr << "Stack = " << stackframe.AddrStack.Offset << std::endl;
}

SymCleanup(process);
}
#endif





namespace ioh::problem
{
//! Defintion interface of problems that are defined in static files
Expand Down Expand Up @@ -209,11 +143,6 @@ namespace ioh::common

if (already_defined) {
std::cerr << "Error: The name '" << name << "' has already been defined in the factory.\n";

#if defined(_MSC_VER)
print_windows_backtrace();
#endif

assert(!already_defined && name.c_str());
}

Expand Down

0 comments on commit 72c7c95

Please sign in to comment.