aboutsummaryrefslogtreecommitdiff
path: root/memory/README.md
blob: a72861b9add1f28826ea5c98e0d7e9ca95d00cc0 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# memory
--
    import "android.googlesource.com/platform/tools/gpu/memory"

Package memory contains types used for representing and simulating memory
observed in the capture.

## Usage

```go
var Tmp = Range{
	Base: 0x00000000ff000000,
	Size: 0x0000000000ffffff,
}
```

#### func  Reader

```go
func Reader(s Slice, d database.Database, l log.Logger) io.Reader
```
Reader returns a binary reader for the specified Slice.

#### func  Write

```go
func Write(w binary.Writer, arch device.Architecture, v interface{}) error
```
Write writes the value v to the writer w. If v is an array or slice, then each
of the elements will be written, sequentially.

#### func  Writer

```go
func Writer(p *Pool, rng Range) io.Writer
```
Writer returns a binary writer for the specified memory pool and range.

#### type Pointer

```go
type Pointer uint64
```

Pointer is the type representing a memory pointer.

#### func (Pointer) Offset

```go
func (p Pointer) Offset(n uint64) Pointer
```
Offset returns the pointer offset by n bytes.

#### func (Pointer) Range

```go
func (p Pointer) Range(s uint64) Range
```
Range returns a Range of size s with the base of this pointer.

#### func (Pointer) String

```go
func (p Pointer) String() string
```

#### type Pool

```go
type Pool struct {
	binary.Generate `disable:"true"`
}
```

Pool represents an unbounded and isolated memory space. Pool can be used to
represent the application address space, or hidden GPU Pool.

Pool can be sliced into smaller regions which can be read or written to. All
writes to Pool or its slices do not actually perform binary data copies, but
instead all writes are stored as lightweight records. Only when a Pool slice has
Get called will any resolving, loading or copying of binary data occur.

#### func (*Pool) At

```go
func (m *Pool) At(p Pointer) Slice
```
At returns an unbounded Slice starting at p.

#### func (*Pool) Slice

```go
func (m *Pool) Slice(rng Range) Slice
```
Slice returns a Slice referencing the subset of the Pool range.

#### func (*Pool) String

```go
func (m *Pool) String() string
```
String returns the full history of writes performed to this pool.

#### func (*Pool) Write

```go
func (m *Pool) Write(dst Pointer, src Slice)
```
Write copies the slice src to dst.

#### type PoolID

```go
type PoolID uint32
```

PoolID is an indentifier of a Pool.

```go
const ApplicationPool PoolID = 0
```
ApplicationPool is the PoolID of Pool representing the application's memory
address space.

#### func (*PoolID) Parse

```go
func (v *PoolID) Parse(s string) error
```

#### func (PoolID) String

```go
func (v PoolID) String() string
```

#### type Range

```go
type Range struct {
	binary.Generate
	Base Pointer // A pointer to the first byte in the memory range.
	Size uint64  // The size in bytes of the memory range.
}
```

Range represents a region of memory.

#### func (*Range) Class

```go
func (*Range) Class() binary.Class
```

#### func (Range) Contains

```go
func (i Range) Contains(p Pointer) bool
```
Contains returns true if the pointer p is within the Range.

#### func (Range) End

```go
func (i Range) End() Pointer
```
End returns a Pointer to one byte beyond the end of the Range.

#### func (Range) Expand

```go
func (i Range) Expand(p Pointer) Range
```
Expand returns a new Range that is grown to include the pointer p.

#### func (Range) First

```go
func (i Range) First() Pointer
```
First returns a Pointer to the first byte in the Range.

#### func (Range) Intersect

```go
func (i Range) Intersect(other Range) Range
```
Intersect returns the Range that is common between this Range and other. If the
two memory ranges do not intersect, then this function panics.

#### func (Range) Last

```go
func (i Range) Last() Pointer
```
Last returns a Pointer to the last byte in the Range.

#### func (Range) Overlaps

```go
func (i Range) Overlaps(other Range) bool
```
Overlaps returns true if other overlaps this memory range.

#### func (Range) Span

```go
func (i Range) Span() interval.U64Span
```
Span returns the Range as a U64Span.

#### func (Range) String

```go
func (i Range) String() string
```

#### type RangeList

```go
type RangeList []Range
```


#### func (*RangeList) Copy

```go
func (l *RangeList) Copy(to, from, count int)
```
Copy performs a copy of ranges within the RangeList.

#### func (*RangeList) GetSpan

```go
func (l *RangeList) GetSpan(index int) interval.U64Span
```
GetSpan returns the span of the range with the specified index in the RangeList.

#### func (*RangeList) Length

```go
func (l *RangeList) Length() int
```
Length returns the number of ranges in the RangeList.

#### func (*RangeList) Resize

```go
func (l *RangeList) Resize(length int)
```
Resize resizes the RangeList to the specified length.

#### func (*RangeList) SetSpan

```go
func (l *RangeList) SetSpan(index int, span interval.U64Span)
```
SetSpan adjusts the range of the span with the specified index in the RangeList.

#### type Slice

```go
type Slice interface {
	// Get resolves all the bytes representing the slice.
	Get(d database.Database, l log.Logger) ([]byte, error)

	// ResourceID returns the identifier of the resource representing the slice,
	// creating a new resource if it isn't already backed by one.
	ResourceID(d database.Database, l log.Logger) (binary.ID, error)

	// Size returns the number of bytes that would be returned by calling Get.
	Size() uint64

	// Slice returns a new Slice referencing a subset range of the data.
	// The range r is relative to the base of the Slice. For example a slice of
	// [0, 4] would return a Slice referencing the first 5 bytes of this Slice.
	// Attempting to slice outside the range of this Slice will result in a
	// panic.
	Slice(r Range) Slice
}
```

Slice is the interface for a data source that can be resolved to a byte slice
with Get, or 'sliced' to a subset of the data source.

#### func  Blob

```go
func Blob(data []byte) Slice
```
Blob returns a read-only Slice that wraps data.

#### func  Data

```go
func Data(arch device.Architecture, data ...interface{}) Slice
```
Data returns a read-only Slice that contains the encoding of data.

#### func  Resource

```go
func Resource(resId binary.ID, size uint64) Slice
```
Resource returns a Slice that wraps a resource stored in the database. resId is
the identifier of the data and size is the size in bytes of the data.