コード例 #1
0
        public static DebugCompilerContext CreateLocalsContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, bool argumentsOnly)
        {
            MemoryStream input;
            StreamReader reader;

            CreateInputStream(string.Empty, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
            InspectionScope   scope   = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(LocalVariablesTranslator),
                null /* Method name is not applicable because we create multiple methods for Locals. */,
                new List <DkmClrLocalVariableInfo>(),
                null /* Assignment L-Value only applies to assigments */,
                argumentsOnly);

            context.InitializeSymbols();

            return(context);
        }
コード例 #2
0
        /// <summary>
        /// This method is called by the debug engine to compile an expression that the user wants
        /// to evaluate.  Before the call, we have the text of the expression and information about
        /// the context we want to evaluate in (code location, evaluation flags, etc.).  The result
        /// of the call is a &quot;query&quot; containing IL the debugger will execute to get the
        /// result of the expression.
        /// </summary>
        /// <param name="expression">This is the raw expression to compile</param>
        /// <param name="instructionAddress">Instruction address or code location to use as the
        /// context of the compilation.</param>
        /// <param name="inspectionContext">Context of the evaluation.  This contains options/flags
        /// to be used during compilation. It also contains the InspectionSession.  The inspection
        /// session is the object that provides lifetime management for our objects.  When the user
        /// steps or continues the process, the debug engine will dispose of the inspection session</param>
        /// <param name="error">[Out] If the there are any compile errors, this parameter is set to
        /// the error message to display to the user</param>
        /// <param name="result">[Out] If compilation was successful, this is the output query.</param>
        void IDkmClrExpressionCompiler.CompileExpression(
            DkmLanguageExpression expression,
            DkmClrInstructionAddress instructionAddress,
            DkmInspectionContext inspectionContext,
            out string error,
            out DkmCompiledClrInspectionQuery result)
        {
            error  = null;
            result = null;
            using (DebugCompilerContext context = ContextFactory.CreateExpressionContext(inspectionContext, instructionAddress, expression.Text))
            {
                context.GenerateQuery();

                error = context.FirstError;
                if (string.IsNullOrEmpty(error))
                {
                    result = DkmCompiledClrInspectionQuery.Create(
                        instructionAddress.RuntimeInstance,
                        null,
                        expression.Language.Id,
                        new ReadOnlyCollection <byte>(context.GetPeBytes()),
                        context.ClassName,
                        context.MethodName,
                        new ReadOnlyCollection <string>(context.FormatSpecifiers),
                        context.ResultFlags,
                        DkmEvaluationResultCategory.Data,
                        DkmEvaluationResultAccessType.None,
                        DkmEvaluationResultStorageType.None,
                        DkmEvaluationResultTypeModifierFlags.None,
                        null);
                }
            }
        }
コード例 #3
0
        public static DebugCompilerContext CreateAssignmentContext(DkmEvaluationResult lValue, DkmClrInstructionAddress address, string expression)
        {
            MemoryStream input;
            StreamReader reader;

            CreateInputStream(expression, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(lValue.InspectionSession);
            InspectionScope   scope   = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(AssignmentTranslator),
                "$.M1",
                null /* Generated locals is not applicable for assigments */,
                lValue.FullName,
                false /* "ArgumentsOnly" only applies to local variable query */);

            context.InitializeSymbols();

            return(context);
        }
コード例 #4
0
        /// <summary>
        /// This method is called by the debug engine to retrieve the current local variables.
        /// The result of this call will be a query containing the names of the local variables
        /// as well as IL code to retrieve each variable value.
        /// </summary>
        /// <param name="inspectionContext">Context of the evaluation.  This contains options/flags
        /// to be used during compilation. It also contains the InspectionSession.  The inspection
        /// session is the object that provides lifetime management for our objects.  When the user
        /// steps or continues the process, the debug engine will dispose of the inspection session</param>
        /// <param name="instructionAddress">Instruction address or code location to use as the
        /// reference point for where we need to retrieve the local variables</param>
        /// <param name="argumentsOnly">True if only arguments are needed</param>
        /// <returns>A local variables query</returns>
        DkmCompiledClrLocalsQuery IDkmClrExpressionCompiler.GetClrLocalVariableQuery(DkmInspectionContext inspectionContext, DkmClrInstructionAddress instructionAddress, bool argumentsOnly)
        {
            using (DebugCompilerContext context = ContextFactory.CreateLocalsContext(inspectionContext, instructionAddress, argumentsOnly))
            {
                context.GenerateQuery();

                return(DkmCompiledClrLocalsQuery.Create(
                           inspectionContext.RuntimeInstance,
                           null,
                           inspectionContext.Language.Id,
                           new ReadOnlyCollection <byte>(context.GetPeBytes()),
                           context.ClassName,
                           new ReadOnlyCollection <DkmClrLocalVariableInfo>(context.GeneratedLocals)));
            }
        }
コード例 #5
0
        public static DebugCompilerContext CreateExpressionContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, string expression)
        {
            InspectionSession ownedSession = null;
            InspectionScope   scope;

            if (inspectionContext != null)
            {
                InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
                scope = session.GetScope(address);
            }
            else
            {
                // There is no inspection context when compiling breakpoint conditions.  Create a
                // new temporary session.  The context will need to dispose of this new session
                // when it is disposed.
                ownedSession = new InspectionSession();
                scope        = ownedSession.GetScope(address);
            }

            MemoryStream input;
            StreamReader reader;

            CreateInputStream(expression, out input, out reader);

            DebugCompilerContext context = new DebugCompilerContext(
                ownedSession,
                scope,
                input,
                reader,
                typeof(ExpressionTranslator),
                "$.M1",
                null /* Generated locals is not applicable for compiling expressions */,
                null /* Assignment L-Value only applies to assigments */,
                false /* "ArgumentsOnly" only applies to local variable query */);

            context.InitializeSymbols();

            return(context);
        }
コード例 #6
0
        public static DebugCompilerContext CreateAssignmentContext(DkmEvaluationResult lValue, DkmClrInstructionAddress address, string expression)
        {
            MemoryStream input;
            StreamReader reader;
            CreateInputStream(expression, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(lValue.InspectionSession);
            InspectionScope scope = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(AssignmentTranslator),
                "$.M1",
                null /* Generated locals is not applicable for assigments */,
                lValue.FullName,
                false /* "ArgumentsOnly" only applies to local variable query */);
            context.InitializeSymbols();

            return context;
        }
コード例 #7
0
        public static DebugCompilerContext CreateExpressionContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, string expression)
        {
            InspectionSession ownedSession = null;
            InspectionScope scope;
            if (inspectionContext != null)
            {
                InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
                scope = session.GetScope(address);
            }
            else
            {
                // There is no inspection context when compiling breakpoint conditions.  Create a
                // new temporary session.  The context will need to dispose of this new session
                // when it is disposed.
                ownedSession = new InspectionSession();
                scope = ownedSession.GetScope(address);
            }

            MemoryStream input;
            StreamReader reader;
            CreateInputStream(expression, out input, out reader);

            DebugCompilerContext context = new DebugCompilerContext(
                ownedSession,
                scope,
                input,
                reader,
                typeof(ExpressionTranslator),
                "$.M1",
                null /* Generated locals is not applicable for compiling expressions */,
                null /* Assignment L-Value only applies to assigments */,
                false /* "ArgumentsOnly" only applies to local variable query */);
            context.InitializeSymbols();

            return context;
        }
コード例 #8
0
 public LocalVariablesTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
 }
コード例 #9
0
 public AssignmentTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
 }
コード例 #10
0
 public ExpressionTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
     _lexer = context.Lexer;
 }
コード例 #11
0
 public ExpressionTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
     _lexer   = context.Lexer;
 }
コード例 #12
0
 public AssignmentTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
 }
コード例 #13
0
        public static DebugCompilerContext CreateLocalsContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, bool argumentsOnly)
        {
            MemoryStream input;
            StreamReader reader;
            CreateInputStream(string.Empty, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
            InspectionScope scope = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(LocalVariablesTranslator),
                null /* Method name is not applicable because we create multiple methods for Locals. */,
                new List<DkmClrLocalVariableInfo>(),
                null /* Assignment L-Value only applies to assigments */,
                argumentsOnly);
            context.InitializeSymbols();

            return context;
        }
コード例 #14
0
 public LocalVariablesTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
 }