1// Copyright 2019 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Package protocol defines the types used to represent calls to the debug server. 16package protocol 17 18import ( 19 "encoding/gob" 20 21 "cloud.google.com/go/cmd/go-cloud-debug-agent/internal/debug" 22) 23 24func init() { 25 // Register implementations of debug.Value with gob. 26 gob.Register(debug.Pointer{}) 27 gob.Register(debug.Array{}) 28 gob.Register(debug.Struct{}) 29 gob.Register(debug.Slice{}) 30 gob.Register(debug.Map{}) 31 gob.Register(debug.String{}) 32 gob.Register(debug.Channel{}) 33 gob.Register(debug.Func{}) 34 gob.Register(debug.Interface{}) 35} 36 37// For regularity, each method has a unique Request and a Response type even 38// when not strictly necessary. 39 40// File I/O, at the top because they're simple. 41 42type ReadAtRequest struct { 43 FD int 44 Len int 45 Offset int64 46} 47 48type ReadAtResponse struct { 49 Data []byte 50} 51 52type WriteAtRequest struct { 53 FD int 54 Data []byte 55 Offset int64 56} 57 58type WriteAtResponse struct { 59 Len int 60} 61 62type CloseRequest struct { 63 FD int 64} 65 66type CloseResponse struct { 67} 68 69// Program methods. 70 71type OpenRequest struct { 72 Name string 73 Mode string 74} 75 76type OpenResponse struct { 77 FD int 78} 79 80type RunRequest struct { 81 Args []string 82} 83 84type RunResponse struct { 85 Status debug.Status 86} 87 88type ResumeRequest struct { 89} 90 91type ResumeResponse struct { 92 Status debug.Status 93} 94 95type BreakpointRequest struct { 96 Address uint64 97} 98 99type BreakpointAtFunctionRequest struct { 100 Function string 101} 102 103type BreakpointAtLineRequest struct { 104 File string 105 Line uint64 106} 107 108type BreakpointResponse struct { 109 PCs []uint64 110} 111 112type DeleteBreakpointsRequest struct { 113 PCs []uint64 114} 115 116type DeleteBreakpointsResponse struct { 117} 118 119type EvalRequest struct { 120 Expr string 121} 122 123type EvalResponse struct { 124 Result []string 125} 126 127type EvaluateRequest struct { 128 Expression string 129} 130 131type EvaluateResponse struct { 132 Result debug.Value 133} 134 135type FramesRequest struct { 136 Count int 137} 138 139type FramesResponse struct { 140 Frames []debug.Frame 141} 142 143type VarByNameRequest struct { 144 Name string 145} 146 147type VarByNameResponse struct { 148 Var debug.Var 149} 150 151type ValueRequest struct { 152 Var debug.Var 153} 154 155type ValueResponse struct { 156 Value debug.Value 157} 158 159type MapElementRequest struct { 160 Map debug.Map 161 Index uint64 162} 163 164type MapElementResponse struct { 165 Key debug.Var 166 Value debug.Var 167} 168 169type GoroutinesRequest struct { 170} 171 172type GoroutinesResponse struct { 173 Goroutines []*debug.Goroutine 174} 175