Click here to Skip to main content
12,074,308 members (62,421 online)
Click here to Skip to main content

Stats

28.3K views
209 downloads
27 bookmarked
Posted

Post mortem C++ exception analysis in embedded applications

, 21 Aug 2009 CPOL
An article on analysing a program exception or software crash.
CallStackTest_src.zip
CallStackTest
CallStackTest
Ensor6 (x86)
Debug
Win32
Debug
Release
DiaTool
DiaTool
DiaTool.csproj.user
Properties
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include <iostream>
#include "C4.h"
#include "ex.h"

std::map<unsigned long, std::wstring> theExceptionTable;
std::wstring theRootPath;

void Test1()
{
	long data = -1;

	std::cout << "Running CallStackTest..." << std::endl;

	C4 c4;
	data = c4.Test4(100.200);

	std::cout << data << std::endl;
	std::cout << "CallStackTest finished." << std::endl;
}

DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
	Test1();

	return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
    // Prepare 
    wchar_t fullPath[512];
    wchar_t rootPath[512];
    wcscpy_s(fullPath, 512, argv[0]);
    wchar_t* dot = wcsrchr(fullPath, L'.');
    wchar_t* backslash = wcsrchr(fullPath, L'\\');
    wcscpy_s(dot, 512 - (wcslen(fullPath) - wcslen(L".exe")), L".map");
    int c = backslash - fullPath;
    wcsncpy_s(rootPath, 512, fullPath, c);

    theRootPath = rootPath;
    theExceptionTable = LoadAsm(fullPath);

    // Go ahead with test
    // Either in main() thread context or a new thread
#if 0
	DWORD threadID=0;
	CreateThread(NULL, 0, ThreadProc, NULL, 0, &threadID);
#else
    ThreadProc(NULL);
#endif

	Sleep(1000);

	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Werner Willemsens
Team Leader
Belgium Belgium
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160208.1 | Last Updated 21 Aug 2009
Article Copyright 2009 by Werner Willemsens
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid