-
Notifications
You must be signed in to change notification settings - Fork 327
/
cmdset_vm.go
107 lines (94 loc) · 3.52 KB
/
cmdset_vm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (C) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package jdwp
// Version describes the JDWP version
type Version struct {
Description string // Text information on the VM version
JDWPMajor int // Major JDWP Version number
JDWPMinor int // Minor JDWP Version number
Version string // Target VM JRE version, as in the java.version property
Name string // Target VM name, as in the java.vm.name property
}
// GetVersion returns the JDWP version from the server.
func (c *Connection) GetVersion() (Version, error) {
res := Version{}
err := c.get(cmdSetVirtualMachine, 1, struct{}{}, &res)
return res, err
}
// ClassInfo describes a loaded classes matching the requested signature.
type ClassInfo struct {
Kind TypeTag // Kind of reference type
TypeID ReferenceTypeID // Matching loaded reference type
Signature string // The class signature
Status ClassStatus // The class status
}
// ClassID returns the class identifier for the ClassBySignature.
func (c ClassInfo) ClassID() ClassID {
return ClassID(c.TypeID)
}
// GetClassesBySignature returns all the loaded classes matching the requested
// signature from the server.
func (c *Connection) GetClassesBySignature(signature string) ([]ClassInfo, error) {
res := []struct {
Kind TypeTag
TypeID ReferenceTypeID
Status ClassStatus
}{}
err := c.get(cmdSetVirtualMachine, 2, &signature, &res)
out := make([]ClassInfo, len(res))
for i, c := range res {
out[i] = ClassInfo{c.Kind, c.TypeID, signature, c.Status}
}
return out, err
}
// GetAllClasses returns all the active threads by ID.
func (c *Connection) GetAllClasses() ([]ClassInfo, error) {
res := []ClassInfo{}
err := c.get(cmdSetVirtualMachine, 3, struct{}{}, &res)
return res, err
}
// GetAllThreads returns all the active threads by ID.
func (c *Connection) GetAllThreads() ([]ThreadID, error) {
res := []ThreadID{}
err := c.get(cmdSetVirtualMachine, 4, struct{}{}, &res)
return res, err
}
// IDSizes describes the sizes of all the variably sized data types.
type IDSizes struct {
FieldIDSize int32 // FieldID size in bytes
MethodIDSize int32 // MethodID size in bytes
ObjectIDSize int32 // ObjectID size in bytes
ReferenceTypeIDSize int32 // ReferenceTypeID size in bytes
FrameIDSize int32 // FrameID size in bytes
}
// GetIDSizes returns the sizes of all the variably sized data types.
func (c *Connection) GetIDSizes() (IDSizes, error) {
res := IDSizes{}
err := c.get(cmdSetVirtualMachine, 7, struct{}{}, &res)
return res, err
}
// SuspendAll suspends all threads.
func (c *Connection) SuspendAll() error {
return c.get(cmdSetVirtualMachine, 8, struct{}{}, nil)
}
// ResumeAll resumes all threads.
func (c *Connection) ResumeAll() error {
return c.get(cmdSetVirtualMachine, 9, struct{}{}, nil)
}
// CreateString returns the StringID for the given string.
func (c *Connection) CreateString(str string) (StringID, error) {
res := StringID(0)
err := c.get(cmdSetVirtualMachine, 11, str, &res)
return res, err
}