You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

175 lines
2.9 KiB

  1. // Copyright 2018 Google Inc. All Rights Reserved.
  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. // Package protocol defines the types used to represent calls to the debug server.
  15. package protocol
  16. import (
  17. "encoding/gob"
  18. "cloud.google.com/go/cmd/go-cloud-debug-agent/internal/debug"
  19. )
  20. func init() {
  21. // Register implementations of debug.Value with gob.
  22. gob.Register(debug.Pointer{})
  23. gob.Register(debug.Array{})
  24. gob.Register(debug.Struct{})
  25. gob.Register(debug.Slice{})
  26. gob.Register(debug.Map{})
  27. gob.Register(debug.String{})
  28. gob.Register(debug.Channel{})
  29. gob.Register(debug.Func{})
  30. gob.Register(debug.Interface{})
  31. }
  32. // For regularity, each method has a unique Request and a Response type even
  33. // when not strictly necessary.
  34. // File I/O, at the top because they're simple.
  35. type ReadAtRequest struct {
  36. FD int
  37. Len int
  38. Offset int64
  39. }
  40. type ReadAtResponse struct {
  41. Data []byte
  42. }
  43. type WriteAtRequest struct {
  44. FD int
  45. Data []byte
  46. Offset int64
  47. }
  48. type WriteAtResponse struct {
  49. Len int
  50. }
  51. type CloseRequest struct {
  52. FD int
  53. }
  54. type CloseResponse struct {
  55. }
  56. // Program methods.
  57. type OpenRequest struct {
  58. Name string
  59. Mode string
  60. }
  61. type OpenResponse struct {
  62. FD int
  63. }
  64. type RunRequest struct {
  65. Args []string
  66. }
  67. type RunResponse struct {
  68. Status debug.Status
  69. }
  70. type ResumeRequest struct {
  71. }
  72. type ResumeResponse struct {
  73. Status debug.Status
  74. }
  75. type BreakpointRequest struct {
  76. Address uint64
  77. }
  78. type BreakpointAtFunctionRequest struct {
  79. Function string
  80. }
  81. type BreakpointAtLineRequest struct {
  82. File string
  83. Line uint64
  84. }
  85. type BreakpointResponse struct {
  86. PCs []uint64
  87. }
  88. type DeleteBreakpointsRequest struct {
  89. PCs []uint64
  90. }
  91. type DeleteBreakpointsResponse struct {
  92. }
  93. type EvalRequest struct {
  94. Expr string
  95. }
  96. type EvalResponse struct {
  97. Result []string
  98. }
  99. type EvaluateRequest struct {
  100. Expression string
  101. }
  102. type EvaluateResponse struct {
  103. Result debug.Value
  104. }
  105. type FramesRequest struct {
  106. Count int
  107. }
  108. type FramesResponse struct {
  109. Frames []debug.Frame
  110. }
  111. type VarByNameRequest struct {
  112. Name string
  113. }
  114. type VarByNameResponse struct {
  115. Var debug.Var
  116. }
  117. type ValueRequest struct {
  118. Var debug.Var
  119. }
  120. type ValueResponse struct {
  121. Value debug.Value
  122. }
  123. type MapElementRequest struct {
  124. Map debug.Map
  125. Index uint64
  126. }
  127. type MapElementResponse struct {
  128. Key debug.Var
  129. Value debug.Var
  130. }
  131. type GoroutinesRequest struct {
  132. }
  133. type GoroutinesResponse struct {
  134. Goroutines []*debug.Goroutine
  135. }