本文整理汇总了C#中IDebugThread2.EnumFrameInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IDebugThread2.EnumFrameInfo方法的具体用法?C# IDebugThread2.EnumFrameInfo怎么用?C# IDebugThread2.EnumFrameInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDebugThread2
的用法示例。
在下文中一共展示了IDebugThread2.EnumFrameInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintFrames
public static ExceptionStackInformation PrintFrames(IDebugThread2 pThread)
{
int hr = 0;
uint threadID = 0;
ExceptionStackInformation exceptionStackInfo = null;
hr = pThread.GetThreadId(out threadID);
IEnumDebugFrameInfo2 enumDebugFrameInfo2;
hr = pThread.EnumFrameInfo(enum_FRAMEINFO_FLAGS.FIF_FRAME, 0, out enumDebugFrameInfo2);
if (hr == 0)
{
FRAMEINFO[] frameInfo = new FRAMEINFO[1];
uint fetched = 0;
hr = enumDebugFrameInfo2.Reset();
exceptionStackInfo = new ExceptionStackInformation();
while (enumDebugFrameInfo2.Next(1, frameInfo, ref fetched) == VSConstants.S_OK)
{
IDebugStackFrame3 stackFrame = frameInfo[0].m_pFrame as IDebugStackFrame3;
//IDebugThread2 debugThread;
IDebugThread2 debugThread;
hr = stackFrame.GetThread(out debugThread);
uint sfThreadID = 0;
hr = debugThread.GetThreadId(out sfThreadID);
if (sfThreadID == threadID)
{
System.Diagnostics.Debug.WriteLine("We got the right stackframe!!!");
if (stackFrame != null)
{
StackFrameInformation stackFrameInfo = new StackFrameInformation();
IDebugDocumentContext2 docContext;
hr = stackFrame.GetDocumentContext(out docContext);
TEXT_POSITION[] startPos = new TEXT_POSITION[1];
TEXT_POSITION[] endPos = new TEXT_POSITION[1];
if (docContext == null)
continue;
hr = docContext.GetStatementRange(startPos, endPos);
var advancedThread = pThread as IDebugThread3;
if (advancedThread != null && advancedThread.IsCurrentException() == 0)
{
var message = ExtractExceptionMessage(stackFrame);
if (message != null)
{
System.Diagnostics.Debug.WriteLine("EXCEPTION: " + message);
exceptionStackInfo.ExceptionMessage = message;
}
var type = ExtractExceptionType(stackFrame);
if (type != null)
{
System.Diagnostics.Debug.WriteLine("EXCEPTION TYPE: " + type);
type = type.Replace("\"", "");
exceptionStackInfo.ExceptionKind = type;
}
}
// not for cs...debugging js
//IDebugDocument2 document;
//docContext.GetDocument(out document);
//IDebugDocumentText2 documentText = document as IDebugDocumentText2;
//var line = GetDocumentText(documentText, startPos[0]);
var line = GetTextLine(docContext, startPos[0], endPos[0]);
System.Diagnostics.Debug.WriteLine(string.Format("Line {0}", line ));
string fileName = "";
stackFrame.GetName(out fileName);
System.Diagnostics.Debug.WriteLine(string.Format("File {0} Function {1}", fileName, frameInfo[0].m_bstrFuncName));
string t = string.Format("start: line({0}) col({1})", startPos[0].dwLine.ToString(), startPos[0].dwColumn.ToString());
System.Diagnostics.Debug.WriteLine(t);
t = string.Format("end: line({0}) col({1})", endPos[0].dwLine.ToString(), endPos[0].dwColumn.ToString());
System.Diagnostics.Debug.WriteLine(t);
stackFrameInfo.File = fileName;
stackFrameInfo.LineNumber = (int)startPos[0].dwLine;
stackFrameInfo.ColumnNumber = (int)startPos[0].dwColumn;
stackFrameInfo.FramePath = frameInfo[0].m_bstrFuncName;
stackFrameInfo.Line = line;
exceptionStackInfo.Frames.Add(stackFrameInfo);
}
}
}
}
return exceptionStackInfo;
}
示例2: ExtractFrameContent
private void ExtractFrameContent(IDebugThread2 pThread)
{
var props = new THREADPROPERTIES[1];
pThread.GetThreadProperties(enum_THREADPROPERTY_FIELDS.TPF_ALLFIELDS, props);
//IDebugThread2::EnumFrameInfo
IEnumDebugFrameInfo2 frame;
pThread.EnumFrameInfo(CreateMask(), 0, out frame);
uint frames;
frame.GetCount(out frames);
var frameInfo = new FRAMEINFO[1];
uint pceltFetched = 0;
while( frame.Next(1, frameInfo, ref pceltFetched) == VSConstants.S_OK && pceltFetched > 0)
{
var fr = frameInfo[0].m_pFrame as IDebugStackFrame3;
Trace.WriteLine( string.Format( "Frame func {0}", frameInfo[0].m_bstrFuncName));
continue;
IDebugExpressionContext2 expressionContext;
fr.GetExpressionContext(out expressionContext);
IDebugExpression2 de; string error; uint errorCode;
if (expressionContext != null)
{
expressionContext.ParseText("exception.InnerException.StackTrace", enum_PARSEFLAGS.PARSE_EXPRESSION, 0, out de, out error, out errorCode);
IDebugProperty2 dp2;
var res = de.EvaluateSync(enum_EVALFLAGS.EVAL_RETURNVALUE, 5000, null, out dp2);
var myInfo = new DEBUG_PROPERTY_INFO[1];
dp2.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, 5000, null, 0, myInfo);
var stackTrace = myInfo[0].bstrValue;
IDebugProperty2 dp;
fr.GetDebugProperty(out dp);
IEnumDebugPropertyInfo2 prop;
dp.EnumChildren(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, ref DebugFilterGuids.guidFilterAllLocals,
enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_ACCESS_ALL,
/*(uint)enum_DBGPROP_ATTRIB_FLAGS.DBGPROP_ATTRIB_ACCESS_PUBLIC,*/
null, 5000, out prop);
EnumerateDebugPropertyChildren(prop);
}
//Guid filter = dbgGuids.guidFilterAllLocals; uint pElements; IEnumDebugPropertyInfo2 prop;
//fr.EnumProperties(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, ref filter, 5000, out pElements, out prop);
//fr.GetUnwindCodeContext
//fr.EnumProperties(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL);
//fr.GetUnwindCodeContext
//ulong intCookie;
//fr.InterceptCurrentException(enum_INTERCEPT_EXCEPTION_ACTION.IEA_INTERCEPT, out intCookie);
//fr.GetExpressionContext(
//var s = fr.ToString();
}
}