[GME-commit] GMESRC/GME/ExtractCrashDumpXML ExtractCrashDumpXML.cpp, NONE, 1.1 ExtractCrashDumpXML.vcproj, NONE, 1.1 ReadMe.txt, NONE, 1.1 stdafx.cpp, NONE, 1.1 stdafx.h, NONE, 1.1

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Tue Apr 8 16:30:47 CDT 2008


Update of /project/gme-repository/GMESRC/GME/ExtractCrashDumpXML
In directory escher:/tmp/cvs-serv25064/ExtractCrashDumpXML

Added Files:
	ExtractCrashDumpXML.cpp ExtractCrashDumpXML.vcproj ReadMe.txt 
	stdafx.cpp stdafx.h 
Log Message:
Foundations of Exception handling code and MiniDump writing.
Currently disabled.


CVS User:  (csaba)

--- NEW FILE: stdafx.h ---
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once


#include <iostream>
#include <tchar.h>

// TODO: reference additional headers your program requires here

--- NEW FILE: stdafx.cpp ---
// stdafx.cpp : source file that includes just the standard includes
// ExtractCrashDumpXML.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

--- NEW FILE: ExtractCrashDumpXML.cpp ---
///////////////////////////////////////////////////////////////////////////////
//
// ExtractCrashDumpXML.cpp
//
// Read user data streams from the minidump
//
// Original code by: Oleg Starodumov (www.debuginfo.com)
//
//


///////////////////////////////////////////////////////////////////////////////
// Include files
//

#include <stdafx.h>

#include <windows.h>
#include <tchar.h>
#include <dbghelp.h>
#include <crtdbg.h>

#include <stdio.h>


///////////////////////////////////////////////////////////////////////////////
// Directives
//

#pragma comment(lib, "dbghelp.lib")


///////////////////////////////////////////////////////////////////////////////
// Stream identifiers
//

// Stream identifiers
// (LastReservedStream constant is defined in MINIDUMP_STREAM_TYPE
// enumeration in DbgHelp.h; all user data stream identifiers
// must be larger than LastReservedStream)
const ULONG32 cUserStreamID = LastReservedStream + 1;


///////////////////////////////////////////////////////////////////////////////
// main() function 
//

int _tmain(int argc, TCHAR* argv[])
{
	// Check parameters

	if (argc < 2) {
		_tprintf(_T("Usage: ExtractCrashDumpXML <MiniDumpFile>\n"));
		_tprintf(_T("\tThe output is the user XML stream in the MiniDump file\n"));
		_tprintf(_T("\twith the same name as the minidump but with xml extension\n"));
		return 0;
	}

	const TCHAR* pMiniDumpFileName = argv[1];
	_tprintf(_T("Minidump: %s\n"), pMiniDumpFileName);

	TCHAR pCrashDumpXMLName[MAX_PATH + 1];
	_tcscpy(pCrashDumpXMLName, pMiniDumpFileName);
	PTSTR p = _tcsrchr(pCrashDumpXMLName, _T('.'));
	if (p) {
		p++;
		if (_tcslen(p) >= 3)
			_tcscpy(p, _T("xml"));
	}
	_tprintf(_T("XML dump: %s\n"), pCrashDumpXMLName);

	// Read the user data streams and display their contents

	HANDLE hMiniDumpFile = NULL;
	HANDLE hMapFile = NULL;
	PVOID pViewOfFile = NULL;
	HANDLE hXMLDumpFile = NULL;

	hXMLDumpFile = CreateFile(pCrashDumpXMLName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
	if ((hXMLDumpFile == NULL) || (hXMLDumpFile == INVALID_HANDLE_VALUE)) {
		_tprintf(_T("Error: CreateFile failed. Error: %lu \n"), GetLastError());
		return -1;
	}

	// Map the minidump into memory

	hMiniDumpFile = CreateFile(pMiniDumpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);

	if ((hMiniDumpFile == NULL) || (hMiniDumpFile == INVALID_HANDLE_VALUE)) {
		_tprintf(_T("Error: CreateFile failed. Error: %lu\n"), GetLastError());
		return -1;
	}

	hMapFile = CreateFileMapping(hMiniDumpFile, NULL, PAGE_READONLY, 0, 0, NULL);

	if (hMapFile == NULL) {
		_tprintf(_T("Error: CreateFileMapping failed. Error: %lu\n"), GetLastError());
		return -1;
	}

	pViewOfFile = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);

	if(pViewOfFile == NULL) {
		_tprintf(_T("Error: MapViewOfFile failed. Error: %lu\n"), GetLastError());
		return -1;
	}

	// Show the contents of user data stream

	ULONG StreamID = cUserStreamID;

	PMINIDUMP_DIRECTORY	pMiniDumpDir	= 0;
	PVOID				pStream			= 0;
	ULONG				StreamSize		= 0;

	if (!MiniDumpReadDumpStream(pViewOfFile, StreamID, &pMiniDumpDir, &pStream, &StreamSize)) {
		DWORD ErrCode = GetLastError();
		if (ErrCode != 0)	// 0 -> no such stream in the dump 
			_tprintf(_T("Error: MiniDumpReadDumpStream failed. Error: %lu \n"), ErrCode);
		else
			_tprintf(_T("Stream (id %lu) not found in the minidump.\n"), StreamID);
	} else {
		// Show the contents

		if ((pStream == 0) || (StreamSize == 0)) {
			_tprintf(_T("Invalid stream (id %lu).\n"), StreamID);
		} else if (IsBadStringPtrA((LPCSTR)pStream, StreamSize)) {
			_tprintf(_T("Invalid stream data (id %lu).\n"), StreamID);
		} else {
			DWORD bytesWritten;
			WriteFile(hXMLDumpFile, pStream, StreamSize, &bytesWritten, NULL);

			CloseHandle(hXMLDumpFile);

			if (bytesWritten < StreamSize)
				_tprintf(_T("Less data written: %lu < %lu.\n"), bytesWritten, StreamSize);
		}
	}

	// Cleanup

	if (hMapFile != NULL)
		CloseHandle(hMapFile);

	if (hMiniDumpFile != NULL)
		CloseHandle(hMiniDumpFile);

	// Complete

	return 0;
}


--- NEW FILE: ReadMe.txt ---
========================================================================
    CONSOLE APPLICATION : ExtractCrashDumpXML Project Overview
========================================================================

AppWizard has created this ExtractCrashDumpXML application for you.  
This file contains a summary of what you will find in each of the files that
make up your ExtractCrashDumpXML application.


ExtractCrashDumpXML.vcproj
    This is the main project file for VC++ projects generated using an Application Wizard. 
    It contains information about the version of Visual C++ that generated the file, and 
    information about the platforms, configurations, and project features selected with the
    Application Wizard.

ExtractCrashDumpXML.cpp
    This is the main application source file.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
    These files are used to build a precompiled header (PCH) file
    named ExtractCrashDumpXML.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////

--- NEW FILE: ExtractCrashDumpXML.vcproj ---
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="7.10"
	Name="ExtractCrashDumpXML"
	ProjectGUID="{98DBF1AF-9678-4F70-958B-D63C0BAD5429}"
	Keyword="Win32Proj">
	<Platforms>
		<Platform
			Name="Win32"/>
	</Platforms>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory="Debug"
			IntermediateDirectory="Debug"
			ConfigurationType="1"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
				MinimalRebuild="TRUE"
				BasicRuntimeChecks="3"
				RuntimeLibrary="5"
				UsePrecompiledHeader="3"
				WarningLevel="3"
				Detect64BitPortabilityProblems="TRUE"
				DebugInformationFormat="4"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				OutputFile="$(OutDir)/ExtractCrashDumpXML.exe"
				LinkIncremental="2"
				GenerateDebugInformation="TRUE"
				ProgramDatabaseFile="$(OutDir)/ExtractCrashDumpXML.pdb"
				SubSystem="1"
				TargetMachine="1"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="Release"
			IntermediateDirectory="Release"
			ConfigurationType="1"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
				RuntimeLibrary="4"
				UsePrecompiledHeader="3"
				WarningLevel="3"
				Detect64BitPortabilityProblems="TRUE"
				DebugInformationFormat="3"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLinkerTool"
				OutputFile="$(OutDir)/ExtractCrashDumpXML.exe"
				LinkIncremental="1"
				GenerateDebugInformation="TRUE"
				SubSystem="1"
				OptimizeReferences="2"
				EnableCOMDATFolding="2"
				TargetMachine="1"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
			<Tool
				Name="VCXMLDataGeneratorTool"/>
			<Tool
				Name="VCWebDeploymentTool"/>
			<Tool
				Name="VCManagedWrapperGeneratorTool"/>
			<Tool
				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
			<File
				RelativePath=".\ExtractCrashDumpXML.cpp">
			</File>
			<File
				RelativePath=".\stdafx.cpp">
				<FileConfiguration
					Name="Debug|Win32">
					<Tool
						Name="VCCLCompilerTool"
						UsePrecompiledHeader="1"/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32">
					<Tool
						Name="VCCLCompilerTool"
						UsePrecompiledHeader="1"/>
				</FileConfiguration>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl;inc;xsd"
			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
			<File
				RelativePath=".\stdafx.h">
			</File>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
		</Filter>
		<File
			RelativePath=".\ReadMe.txt">
		</File>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>



More information about the GME-commit mailing list