示例#1
0
        public override async Task <IEnumerable <ulong> > SetExceptionBreakpoints(Guid exceptionCategory, /*OPTIONAL*/ IEnumerable <string> exceptionNames, ExceptionBreakpointState exceptionBreakpointState)
        {
            List <string> commandTokens = new List <string>();

            commandTokens.Add("-break-exception-insert");

            if (exceptionCategory == s_exceptionCategory_MDA)
            {
                commandTokens.Add("--mda");
            }
            else if (exceptionCategory != s_exceptionCategory_CLR)
            {
                throw new ArgumentOutOfRangeException("exceptionCategory");
            }

            if (exceptionBreakpointState.HasFlag(ExceptionBreakpointState.BreakThrown))
            {
                if (exceptionBreakpointState.HasFlag(ExceptionBreakpointState.BreakUserHandled))
                {
                    commandTokens.Add("throw+user-unhandled");
                }
                else
                {
                    commandTokens.Add("throw");
                }
            }
            else
            {
                if (exceptionBreakpointState.HasFlag(ExceptionBreakpointState.BreakUserHandled))
                {
                    commandTokens.Add("user-unhandled");
                }
                else
                {
                    commandTokens.Add("unhandled");
                }
            }

            if (exceptionNames == null)
            {
                commandTokens.Add("*");
            }
            else
            {
                commandTokens.AddRange(exceptionNames);
            }

            string command = string.Join(" ", commandTokens);

            Results results = await _debugger.CmdAsync(command, ResultClass.done);

            ResultValue bkpt;

            if (results.TryFind("bkpt", out bkpt))
            {
                if (bkpt is ValueListValue)
                {
                    MICore.ValueListValue list = bkpt as MICore.ValueListValue;
                    return(list.Content.Select((x) => x.FindAddr("number")));
                }
                else
                {
                    return(new ulong[1] {
                        bkpt.FindAddr("number")
                    });
                }
            }
            else
            {
                return(new ulong[0]);
            }
        }