Esempio n. 1
0
        private void ReceivedEvaluateResponse(DAPRequest request, DAPEvaulateRequest req, ThreadState state, BkEvaluateResponse response)
        {
            DAPEvaluateResponse evalResponse = new DAPEvaluateResponse
            {
                result             = "",
                namedVariables     = 0,
                indexedVariables   = 0,
                variablesReference = 0,
            };

            if (response.Result == null)
            {
                evalResponse.result = "(None)";
            }
            else
            {
                evalResponse.result = DbgValueToString(response.Result);

                if (response.Result.Variables != null)
                {
                    var varsRef = BackendVariableReference.FromDbg(state.Context, response.Result.Variables);
                    var varsIdx = NextVariableReference++;
                    VariableRefs.Add(varsIdx, varsRef);
                    evalResponse.variablesReference = MakeVariableRef(varsIdx);
                }
            }

            DAP.Stream.SendReply(request, evalResponse);
        }
Esempio n. 2
0
        private void OnVariablesReceived(DAPRequest request, DAPVariablesRequest msg, ThreadState state, BkGetVariablesResponse response)
        {
            int startIndex = msg.start == null ? 0 : (int)msg.start;
            int numVars    = (msg.count == null || msg.count == 0) ? response.Result.Count : (int)msg.count;
            int lastIndex  = Math.Min(startIndex + numVars, response.Result.Count);
            // TODO req.filter, format

            var variables = new List <DAPVariable>();

            for (var i = startIndex; i < startIndex + numVars; i++)
            {
                var variable = response.Result[i];
                var dapVar   = new DAPVariable
                {
                    value = DbgValueToString(variable.Value),
                    type  = variable.Value.TypeId.ToString()
                };

                if (variable.Type == MsgChildValue.Types.Type.Numeric)
                {
                    dapVar.name = variable.Index.ToString();
                }
                else
                {
                    dapVar.name = variable.Name;
                }


                if (variable.Value.Variables != null)
                {
                    var varsRef = BackendVariableReference.FromDbg(state.Context, variable.Value.Variables);
                    var varsIdx = NextVariableReference++;
                    VariableRefs.Add(varsIdx, varsRef);
                    dapVar.variablesReference = MakeVariableRef(varsIdx);
                }

                variables.Add(dapVar);
            }

            var reply = new DAPVariablesResponse
            {
                variables = variables
            };

            DAP.Stream.SendReply(request, reply);
        }