Click here to Skip to main content
15,891,981 members
Articles / Programming Languages / C#

Using PDB files and symbols to debug your application

Rate me:
Please Sign up or sign in to vote.
4.83/5 (5 votes)
18 Apr 2011CPOL13 min read 59.5K   1.1K   25  
With the help of PDB files, you are able to recover the source code as it was before compilation from the bits and bytes at runtime.
#pragma once

enum BasicType;

class FunctionObject
{
	VARIANT m_value;
	std::string m_objName;
	std::string m_typeName;
	HANDLE m_hProcess;
	enum SymTagEnum m_tag;
	std::string m_enumValue;
	bool m_isReturnObj;

	PSYMBOL_INFO m_symbol;

	// Loads the name of the object
	void LoadName(PSYMBOL_INFO sym);

	// Loads the name of the type of that symbol
	void LoadType(PSYMBOL_INFO sym);

	// Try to load the actual value of that object if possible
	void LoadValue(STACKFRAME64 frame, ULONG64 address);

	// Tries to match an enum's members to a given value
	void LoadEnumValue(int value);

	// Loads a basic type (int, float, char, ...)
	void LoadBasicType(BasicType bt, ULONG64 byteSize);

	// Loads the type pointed to
	void LoadPointerType(PSYMBOL_INFO sym, DWORD subType);

	// Returns a string that represents the value
	std::string GetValueString();

public:
	// With the stack frame its interpreted as a local variable or a parameter
	FunctionObject(PSYMBOL_INFO symbol, STACKFRAME64 frame);

	// Without the stack frame its interpreted as a return value
	FunctionObject(PSYMBOL_INFO symbol);

	// Returns the current function object represented as a string
	std::string ToString();
};

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)


Written By
Software Developer
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions