本文整理汇总了C#中Results.TryFindString方法的典型用法代码示例。如果您正苦于以下问题:C# Results.TryFindString方法的具体用法?C# Results.TryFindString怎么用?C# Results.TryFindString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Results
的用法示例。
在下文中一共展示了Results.TryFindString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecodeTelemetryEvent
public bool DecodeTelemetryEvent(Results results, out string eventName, out KeyValuePair<string, object>[] properties)
{
properties = null;
// NOTE: the message event is an MI Extension from clrdbg, though we could use in it the future for other debuggers
eventName = results.TryFindString("event-name");
if (string.IsNullOrEmpty(eventName) || !char.IsLetter(eventName[0]) || !eventName.Contains('/'))
{
Debug.Fail("Bogus telemetry event. 'Event-name' property is missing or invalid.");
return false;
}
TupleValue tuple;
if (!results.TryFind("properties", out tuple))
{
Debug.Fail("Bogus message event, missing 'properties' property");
return false;
}
List<KeyValuePair<string, object>> propertyList = new List<KeyValuePair<string, object>>(tuple.Content.Count);
foreach (NamedResultValue pair in tuple.Content)
{
ConstValue resultValue = pair.Value as ConstValue;
if (resultValue == null)
continue;
string content = resultValue.Content;
if (string.IsNullOrEmpty(content))
continue;
object value = content;
int numericValue;
if (content.Length >= 3 && content.StartsWith("0x", StringComparison.OrdinalIgnoreCase) && int.TryParse(content.Substring(2), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out numericValue))
{
value = numericValue;
}
else if (int.TryParse(content, NumberStyles.None, CultureInfo.InvariantCulture, out numericValue))
{
value = numericValue;
}
if (value != null)
{
propertyList.Add(new KeyValuePair<string, object>(pair.Name, value));
}
}
properties = propertyList.ToArray();
// If we are processing a clrdbg ProcessCreate event, save the event properties so we can use them to send other events
if (eventName == "VS/Diagnostics/Debugger/clrdbg/ProcessCreate")
{
_clrdbgProcessCreateProperties = properties;
}
return true;
}
示例2: IsAsyncBreakSignal
public virtual bool IsAsyncBreakSignal(Results results)
{
return (results.TryFindString("reason") == "signal-received" && results.TryFindString("signal-name") == "SIGINT");
}
示例3: DecodeOutputEvent
private OutputMessage DecodeOutputEvent(Results results)
{
// NOTE: the message event is an MI Extension from clrdbg, though we could use in it the future for other debuggers
string text = results.TryFindString("text");
if (string.IsNullOrEmpty(text))
{
Debug.Fail("Bogus message event. Missing 'text' property.");
return null;
}
string sendTo = results.TryFindString("send-to");
if (string.IsNullOrEmpty(sendTo))
{
Debug.Fail("Bogus message event, missing 'send-to' property");
return null;
}
enum_MESSAGETYPE messageType;
switch (sendTo)
{
case "message-box":
messageType = enum_MESSAGETYPE.MT_MESSAGEBOX;
break;
case "output-window":
messageType = enum_MESSAGETYPE.MT_OUTPUTSTRING;
break;
default:
Debug.Fail("Bogus message event. Unexpected 'send-to' property. Ignoring.");
return null;
}
OutputMessage.Severity severity = OutputMessage.Severity.Warning;
switch (results.TryFindString("severity"))
{
case "error":
severity = OutputMessage.Severity.Error;
break;
case "warning":
severity = OutputMessage.Severity.Warning;
break;
}
switch (results.TryFindString("source"))
{
case "target-exception":
messageType |= enum_MESSAGETYPE.MT_REASON_EXCEPTION;
break;
case "jmc-prompt":
messageType |= (enum_MESSAGETYPE)enum_MESSAGETYPE90.MT_REASON_JMC_PROMPT;
break;
case "step-filter":
messageType |= (enum_MESSAGETYPE)enum_MESSAGETYPE90.MT_REASON_STEP_FILTER;
break;
case "fatal-error":
messageType |= (enum_MESSAGETYPE)enum_MESSAGETYPE120.MT_FATAL_ERROR;
break;
}
uint errorCode = results.TryFindUint("error-code") ?? 0;
return new OutputMessage(text, messageType, severity, errorCode);
}
示例4: IsAsyncBreakSignal
public virtual bool IsAsyncBreakSignal(Results results)
{
bool isAsyncBreak = false;
if (results.TryFindString("reason") == "signal-received")
{
if (results.TryFindString("signal-name") == "SIGINT")
{
isAsyncBreak = true;
}
}
return isAsyncBreak;
}
示例5: OnStopped
private async void OnStopped(Results results)
{
string reason = results.TryFindString("reason");
if (reason.StartsWith("exited") || reason.StartsWith("disconnected"))
{
if (this.ProcessState != ProcessState.Exited)
{
this.ProcessState = ProcessState.Exited;
if (ProcessExitEvent != null)
{
ProcessExitEvent(this, new ResultEventArgs(results));
}
}
return;
}
//if this is an exception reported from LLDB, it will not currently contain a frame object in the MI
//if we don't have a frame, check if this is an exception and retrieve the frame
if (!results.Contains("frame") &&
(string.Compare(reason, "exception-received", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(reason, "signal-received", StringComparison.OrdinalIgnoreCase) == 0)
)
{
//get the info for the current frame
Results frameResult = await MICommandFactory.StackInfoFrame();
//add the frame to the stopping results
results = results.Add("frame", frameResult.Find("frame"));
}
bool fIsAsyncBreak = MICommandFactory.IsAsyncBreakSignal(results);
if (await DoInternalBreakActions(fIsAsyncBreak))
{
return;
}
this.ProcessState = ProcessState.Stopped;
FlushBreakStateData();
if (!results.Contains("frame"))
{
if (ModuleLoadEvent != null)
{
ModuleLoadEvent(this, new ResultEventArgs(results));
}
}
else if (BreakModeEvent != null)
{
BreakRequest request = _requestingRealAsyncBreak;
_requestingRealAsyncBreak = BreakRequest.None;
BreakModeEvent(this, new StoppingEventArgs(results, request));
}
}
示例6: HandleThreadGroupExited
private void HandleThreadGroupExited(Results results)
{
string threadGroupId = results.TryFindString("id");
bool isThreadGroupEmpty = false;
if (!String.IsNullOrEmpty(threadGroupId))
{
lock (_debuggeePids)
{
if (_debuggeePids.Remove(threadGroupId))
{
isThreadGroupEmpty = _debuggeePids.Count == 0;
}
}
}
if (isThreadGroupEmpty)
{
ScheduleStdOutProcessing(@"*stopped,reason=""exited""");
if (!IsUnixDebuggerRunning())
{
// Processing the fake "stopped" event sent above will normally cause the debugger to close, but if
// the debugger process is already gone (e.g. because the terminal window was closed), we won't get
// a response, so queue a fake "exit" event for processing as well.
ScheduleStdOutProcessing("^exit");
}
}
}
示例7: OnStopped
private async void OnStopped(Results results)
{
string reason = results.TryFindString("reason");
if (reason.StartsWith("exited"))
{
string threadGroupId = results.TryFindString("id");
if (!String.IsNullOrEmpty(threadGroupId))
{
lock (_debuggeePids)
{
_debuggeePids.Remove(threadGroupId);
}
}
if (IsLocalGdbAttach())
{
CmdExitAsync();
}
this.ProcessState = ProcessState.Exited;
if (ProcessExitEvent != null)
{
ProcessExitEvent(this, new ResultEventArgs(results));
}
return;
}
//if this is an exception reported from LLDB, it will not currently contain a frame object in the MI
//if we don't have a frame, check if this is an excpetion and retrieve the frame
if (!results.Contains("frame") &&
string.Compare(reason, "exception-received", StringComparison.OrdinalIgnoreCase) == 0
)
{
//get the info for the current frame
Results frameResult = await MICommandFactory.StackInfoFrame();
//add the frame to the stopping results
results.Add("frame", frameResult.Find("frame"));
}
bool fIsAsyncBreak = MICommandFactory.IsAsyncBreakSignal(results);
if (await DoInternalBreakActions(fIsAsyncBreak))
{
return;
}
this.ProcessState = ProcessState.Stopped;
FlushBreakStateData();
if (!results.Contains("frame"))
{
if (ModuleLoadEvent != null)
{
ModuleLoadEvent(this, new ResultEventArgs(results));
}
}
else if (BreakModeEvent != null)
{
if (fIsAsyncBreak) { _requestingRealAsyncBreak = false; }
BreakModeEvent(this, new ResultEventArgs(results));
}
}
示例8: Stopped
public async Task<bool> Stopped(Results results, int tid)
{
string reason = results.TryFindString("reason");
ThreadProgress s = StateFromTid(tid);
if (reason == "fork")
{
s = new ThreadProgress();
s.State = State.AtFork;
s.Newpid = results.FindInt("newpid");
_threadStates[tid] = s;
await _process.Step(tid, VisualStudio.Debugger.Interop.enum_STEPKIND.STEP_OUT, VisualStudio.Debugger.Interop.enum_STEPUNIT.STEP_LINE);
return true;
}
else if (reason == "vfork")
{
s = new ThreadProgress();
s.State = State.AtVfork;
s.Newpid = results.FindInt("newpid");
_threadStates[tid] = s;
await _process.MICommandFactory.SetOption("schedule-multiple", "on");
await _process.MICommandFactory.Catch("exec", onlyOnce: true);
var thread = await _process.ThreadCache.GetThread(tid);
await _process.Continue(thread);
return true;
}
if (s == null)
{
return false; // no activity being tracked on this thread
}
switch (s.State)
{
case State.AtFork:
await ProcessChild(s);
break;
case State.AtVfork:
await _process.MICommandFactory.SetOption("schedule-multiple", "off");
if ("exec" == results.TryFindString("reason"))
{
// The process doesn't handle the SIGSTOP correctly (just ignores it) when the process is at the start of program
// (after exec). Let it run some code so that it will correctly respond to the SIGSTOP.
s.Exe = results.TryFindString("new-exec");
await RunChildToMain(s);
}
else
{
// sometimes gdb misses the breakpoint at exec and execution will proceed to a breakpoint in the child
_process.Logger.WriteLine("Missed catching the exec after vfork. Spawning the child's debugger.");
s.State = State.AtExec;
goto missedExec;
}
break;
case State.AtSignal: // both child and parent are stopped
s.State = State.Complete;
return await DetachAndContinue(s);
case State.AtExec:
missedExec:
if (tid == s.Newtid) // stopped in the child
{
await ProcessChild(s);
}
else // sometime the parent will get a spurious signal before the child hits main
{
await ContinueTheChild(s);
}
break;
case State.Complete:
_threadStates.Remove(tid);
if (reason == "signal-received" && results.TryFindString("signal-name") == "SIGSTOP")
{
// SIGSTOP was propagated to the parent
await _process.MICommandFactory.Signal("SIGCONT");
return true;
}
return false;
default:
return false;
}
return true;
}