本文整理汇总了C#中IDebugEventCallback2类的典型用法代码示例。如果您正苦于以下问题:C# IDebugEventCallback2类的具体用法?C# IDebugEventCallback2怎么用?C# IDebugEventCallback2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDebugEventCallback2类属于命名空间,在下文中一共展示了IDebugEventCallback2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoResetEvent
// This method evaluates the expression synchronously.
int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) {
AutoResetEvent completion = new AutoResetEvent(false);
PythonEvaluationResult result = null;
_frame.StackFrame.ExecuteText(_expression, (obj) => {
result = obj;
completion.Set();
});
while (!_frame.StackFrame.Thread.Process.HasExited && !completion.WaitOne(Math.Min((int)dwTimeout, 100))) {
if (dwTimeout <= 100) {
break;
}
dwTimeout -= 100;
}
if (_frame.StackFrame.Thread.Process.HasExited || result == null) {
ppResult = null;
return VSConstants.E_FAIL;
} else if (result == null) {
ppResult = null;
return DebuggerConstants.E_EVALUATE_TIMEOUT;
}
ppResult = new AD7Property(_frame, result, _writable);
return VSConstants.S_OK;
}
示例2: Attach
public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
{
if (celtPrograms == 0)
return VSConstants.S_OK;
if (pCallback == null)
throw new ArgumentNullException("pCallback");
if (rgpPrograms == null || rgpPrograms.Length < celtPrograms)
throw new ArgumentException();
if (rgpProgramNodes == null || rgpProgramNodes.Length < celtPrograms)
throw new ArgumentException();
if (celtPrograms > 1)
throw new NotImplementedException();
if (dwReason != enum_ATTACH_REASON.ATTACH_REASON_LAUNCH)
throw new NotImplementedException();
JavaDebugProgram program = rgpProgramNodes[0] as JavaDebugProgram;
if (program == null)
throw new NotSupportedException();
lock (_programs)
{
_programs.Add(program);
}
DebugEvent @event = new DebugEngineCreateEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this);
pCallback.Event(this, program.GetProcess(), program, null, @event);
program.InitializeDebuggerChannel(this, pCallback);
return VSConstants.S_OK;
}
示例3: Attach
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region IDebugProgram2 Members
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public int Attach (IDebugEventCallback2 pCallback)
{
//
// Attaches to this program.
//
LoggingUtils.PrintFunction ();
Exception rethrowable = null;
try
{
m_debugger.Engine.Broadcast (new JavaLangDebuggerEvent.AttachClient (), DebugProgram, null);
return Constants.S_OK;
}
catch (Exception e)
{
LoggingUtils.HandleException (e);
rethrowable = e;
return Constants.E_FAIL;
}
finally
{
if (rethrowable != null)
{
throw rethrowable;
}
}
}
示例4:
// Attach the debug engine to a program.
int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
{
int processId = EngineUtils.GetProcessId(rgpPrograms[0]);
if (processId == 0)
{
return VSConstants.E_NOTIMPL;
}
pID = (uint)processId;
events = ad7Callback;
EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out m_ad7ProgramId));
AD7EngineCreateEvent.Send(this);
AD7ProgramCreateEvent.Send(this);
debugThread = new AD7Thread(this);
AD7ThreadCreateEvent.Send(this);
// This event is optional
AD7LoadCompleteEvent.Send(this);
return VSConstants.S_OK;
}
示例5:
int IDebugExpression2.EvaluateAsync(
enum_EVALFLAGS dwFlags,
IDebugEventCallback2 pExprCallback)
{
// For now, no async evaluation supported.
return VSConstants.E_NOTIMPL;
}
示例6: CancellationTokenSource
// This method evaluates the expression asynchronously.
// This method should return immediately after it has started the expression evaluation.
// When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
// must be sent to the IDebugEventCallback2 event callback
int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) {
_tokenSource = new CancellationTokenSource();
_frame.StackFrame.ExecuteTextAsync(_expression, _tokenSource.Token)
.ContinueWith(p => {
try {
IDebugProperty2 property;
if (p.Exception != null && p.Exception.InnerException != null) {
property = new AD7EvalErrorProperty(p.Exception.InnerException.Message);
} else if (p.IsCanceled) {
property = new AD7EvalErrorProperty("Evaluation canceled");
} else if (p.IsFaulted || p.Result == null) {
property = new AD7EvalErrorProperty("Error");
} else {
property = new AD7Property(_frame, p.Result);
}
_tokenSource.Token.ThrowIfCancellationRequested();
_frame.Engine.Send(
new AD7ExpressionEvaluationCompleteEvent(this, property),
AD7ExpressionEvaluationCompleteEvent.IID,
_frame.Engine,
_frame.Thread);
} finally {
_tokenSource.Dispose();
_tokenSource = null;
}
}, _tokenSource.Token);
return VSConstants.S_OK;
}
示例7: Thread
// This method evaluates the expression asynchronously.
// This method should return immediately after it has started the expression evaluation.
// When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
// must be sent to the IDebugEventCallback2 event callback
//
// This is primarily used for the immediate window which this engine does not currently support.
int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
{
Thread m_processingThread;
m_processingThread = new Thread(evaluatingAsync);
m_processingThread.Start();
return VSConstants.S_OK;
}
示例8: Attach
/// <summary>
/// Attaches the session debug manager (SDM) to the process.
/// </summary>
/// <param name="pCallback">An IDebugEventCallback2 object that is used for debug event notification.</param>
/// <param name="rgguidSpecificEngines">An array of GUIDs of debug engines to be used to debug programs running in the process. This parameter can be a null value. See Remarks for details.</param>
/// <param name="celtSpecificEngines">The number of debug engines in the rgguidSpecificEngines array and the size of the rghrEngineAttach array.</param>
/// <param name="rghrEngineAttach">An array of HRESULT codes returned by the debug engines. The size of this array is specified in the celtSpecificEngines parameter. Each code is typically either S_OK or S_ATTACH_DEFERRED. The latter indicates that the DE is currently attached to no programs.</param>
/// <returns>
/// If successful, returns S_OK; otherwise, returns an error code. The following table shows other possible values.
///
/// Value Description
/// E_ATTACH_DEBUGGER_ALREADY_ATTACHED The specified process is already attached to the debugger.
/// E_ATTACH_DEBUGGEE_PROCESS_SECURITY_VIOLATION A security violation occurred during the attach procedure.
/// E_ATTACH_CANNOT_ATTACH_TO_DESKTOP A desktop process cannot be attached to the debugger.
/// </returns>
/// <remarks>
/// Attaching to a process attaches the SDM to all programs running in that process that can be debugged by the debug engines (DE) specified in the rgguidSpecificEngines array. Set the rgguidSpecificEngines parameter to a null value or include GUID_NULL in the array to attach to all programs in the process.
///
/// All debug events that occur in the process are sent to the given IDebugEventCallback2 object. This IDebugEventCallback2 object is provided when the SDM calls this method.
/// </remarks>
public virtual int Attach( IDebugEventCallback2 pCallback,
Guid[] rgguidSpecificEngines,
uint celtSpecificEngines,
int[] rghrEngineAttach)
{
Logger.Debug( string.Empty );
return VSConstants.E_NOTIMPL;
}
示例9: EvaluateSync
/// <summary>
/// This method evaluates the expression synchronously.
/// </summary>
public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
out IDebugProperty2 ppResult)
{
ppResult = null;
int idx = _index;
if (string.IsNullOrEmpty(_castExpr))
{
var reg = _stackFrame.GetRegistersAsync().Await((int) dwTimeout)
.FirstOrDefault(r => r.Name == _registerType + _index);
if (reg != null)
{
ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
return VSConstants.S_OK;
}
}
else
{
var tag = GetTagFromString(_castExpr);
if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
{
// this evaluation has "side effects" in that it might crash the VM
// if the cast is to "object" or "string", but the register does not
// hold an object or string.
ppResult = new DebugConstProperty(_expression, "(this cast might crash the VM if the register is not of the casted type)", _castExpr, null)
{ HasSideEffects = true };
return VSConstants.E_FAIL;
}
var isParam = _registerType == "p";
if (isParam)
{
var loc = _stackFrame.GetDocumentLocationAsync().Await((int) dwTimeout);
if (loc == null)
return VSConstants.E_FAIL;
var methodDiss = _stackFrame.Thread.Program.DisassemblyProvider.GetFromLocation(loc);
if (methodDiss == null)
return VSConstants.E_FAIL;
idx += methodDiss.Method.Body.Registers.Count - methodDiss.Method.Body.IncomingArguments;
}
var reg = _stackFrame.GetRegistersAsync(false, tag, idx).Await((int) dwTimeout);
if (reg != null && reg.Count > 0)
{
ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
{
HasSideEffects = !tag.IsPrimitive()
};
return VSConstants.S_OK;
}
}
return VSConstants.E_FAIL;
}
示例10: EvaluateSync
/// <summary>
/// This method evaluates the expression synchronously.
/// </summary>
/// <param name="dwFlags">A combination of flags from the EVALFLAGS enumeration that control expression evaluation.</param>
/// <param name="dwTimeout">Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait indefinitely.</param>
/// <param name="pExprCallback">This parameter is always a null value.</param>
/// <param name="ppResult">Returns the IDebugProperty2 object that contains the result of the expression evaluation.</param>
/// <returns>
/// If successful, returns S_OK; otherwise returns an error code. Some typical error codes are:
/// Error Description
/// E_EVALUATE_BUSY_WITH_EVALUATION Another expression is currently being evaluated, and simultaneous expression evaluation is not supported.
/// E_EVALUATE_TIMEOUT Evaluation timed out.
/// </returns>
/// <remarks>For synchronous evaluation, it is not necessary to send an event back to Visual Studio upon completion of the evaluation.</remarks>
public int EvaluateSync( enum_EVALFLAGS dwFlags,
uint dwTimeout,
IDebugEventCallback2 pExprCallback,
out IDebugProperty2 ppResult)
{
Logger.Debug( string.Empty );
ppResult = null;
return VSConstants.E_NOTIMPL;
}
示例11: Attach
/// <summary>
/// Attaches a debug DebugEngine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
/// </summary>
/// <param name="rgpPrograms">An array of IDebugProgram2 objects that represent programs to be attached to. These are port programs.</param>
/// <param name="rgpProgramNodes">An array of IDebugProgramNode2 objects that represent program nodes, one for each program. The program nodes in this array represent the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to.</param>
/// <param name="celtPrograms">Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays.</param>
/// <param name="pCallback">The IDebugEventCallback2 object to be used to send debug events to the SDM.</param>
/// <param name="dwReason">A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. For more information, see the Remarks section.</param>
/// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
/// <remarks>
/// There are three reasons for attaching to a program, as follows:
/// ATTACH_REASON_LAUNCH indicates that the DE is attaching to the program because the user launched the process that contains it.
/// ATTACH_REASON_USER indicates that the user has explicitly requested the DE to attach to a program (or the process that contains a program).
/// ATTACH_REASON_AUTO indicates the DE is attaching to a particular program because it is already debugging other programs in a particular process. This is also called auto-attach
///
/// When this method is called, the DE needs to send these events in sequence:
/// IDebugEngineCreateEvent2 (if it has not already been sent for a particular instance of the debug DebugEngine)
/// IDebugProgramCreateEvent2
/// IDebugLoadCompleteEvent2
///
/// In addition, if the reason for attaching is ATTACH_REASON_LAUNCH, the DE needs to send the IDebugEntryPointEvent2 event.
/// Once the DE gets the IDebugProgramNode2 object corresponding to the program being debugged, it can be queried for any private interface.
/// Before calling the methods of a program node in the array given by pProgram or rgpProgramNodes, impersonation, if required, should be enabled on the IDebugProgram2 interface that represents the program node. Normally, however, this step is not necessary. For more information, see Security Issues.
/// </remarks>
public virtual int Attach( IDebugProgram2[] rgpPrograms,
IDebugProgramNode2[] rgpProgramNodes,
uint celtPrograms,
IDebugEventCallback2 pCallback,
enum_ATTACH_REASON dwReason)
{
Logger.Debug( string.Empty );
return VSConstants.E_NOTIMPL;
}
示例12:
// This method evaluates the expression asynchronously.
// This method should return immediately after it has started the expression evaluation.
// When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
// must be sent to the IDebugEventCallback2 event callback
//
// This is primarily used for the immediate window which this engine does not currently support.
int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) {
_frame.StackFrame.ExecuteText(_expression, (obj) => {
_frame.Engine.Send(
new AD7ExpressionEvaluationCompleteEvent(this, new AD7Property(_frame, obj, _writable)),
AD7ExpressionEvaluationCompleteEvent.IID,
_frame.Engine,
_frame.Thread);
});
return VSConstants.S_OK;
}
示例13: EvaluateAsync
public int EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
{
// don't use pExprCallback!
IDebugEventCallback2 callback = _context.StackFrame.Thread.Program.Callback;
Task<IDebugProperty2> evaluateTask = Task.Factory.StartNew(() => EvaluateImpl(dwFlags)).HandleNonCriticalExceptions();
Task successCompletionTask = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(task, callback), TaskContinuationOptions.OnlyOnRanToCompletion).HandleNonCriticalExceptions();
Task failureCompletionTask = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(null, callback), TaskContinuationOptions.NotOnRanToCompletion).HandleNonCriticalExceptions();
return VSConstants.S_OK;
}
示例14: VSEventCallbackWrapper
internal VSEventCallbackWrapper(IDebugEventCallback2 ad7Callback)
{
// Obtain the GIT from COM, and store the event callback in it
Guid CLSID_StdGlobalInterfaceTable = new Guid("00000323-0000-0000-C000-000000000046");
Guid IID_IGlobalInterfaceTable = typeof(IGlobalInterfaceTable).GUID;
const int CLSCTX_INPROC_SERVER = 0x1;
_pGIT = NativeMethods.CoCreateInstance(ref CLSID_StdGlobalInterfaceTable, IntPtr.Zero, CLSCTX_INPROC_SERVER, ref IID_IGlobalInterfaceTable);
var git = GetGlobalInterfaceTable();
git.RegisterInterfaceInGlobal(ad7Callback, ref _IID_IDebugEventCallback2, out _cookie);
Marshal.ReleaseComObject(git);
}
示例15: catch
int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
{
Debug.WriteLine("AD7Engine Attach");
Guid id;
if (( DebuggerManager.Instance != null ) && ( DebuggerManager.Instance.Debugger.IsRunning))
{
// If already running, abort.
MessageBox.Show("Cannot start MySql Debugger. A MySql Debug session is already running", "Error");
return HRESULT.E_ATTACH_FAILED_ABORT_SILENTLY;
}
rgpPrograms[0].GetProgramId(out id);
if (id == Guid.Empty)
{
return VSConstants.E_NOTIMPL;
}
_events = new AD7Events(this, pCallback);
try
{
DebuggerManager.Init(_events, _node, _breakpoint);
}
catch (Exception ex)
{
MessageBox.Show(_node.ParentWindow, ex.GetBaseException().Message, "Debugger Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return HRESULT.E_ATTACH_FAILED_ABORT_SILENTLY;
}
System.Threading.Thread thread = new System.Threading.Thread(() =>
{
DebuggerManager debugger = DebuggerManager.Instance;
_node.Debugger = debugger;
debugger.SteppingType = SteppingTypeEnum.StepInto;
debugger.Breakpoint = new AD7Breakpoint(_node, _events);
debugger.OnEndDebugger += () => { _events.ProgramDestroyed(_node); };
debugger.Debugger.RestoreAtExit = true;
debugger.Run();
});
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();
_node.Id = id;
_events.EngineCreated();
_events.ProgramCreated(_node);
_events.EngineLoaded();
_events.DebugEntryPoint();
return VSConstants.S_OK;
}