GDB (xrefs)
Loading...
Searching...
No Matches
memory.py
Go to the documentation of this file.
1# Copyright 2023 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16import base64
17import gdb
18
19from .server import request, capability
20
21
22@request("readMemory")
23@capability("supportsReadMemoryRequest")
24def read_memory(*, memoryReference: str, offset: int = 0, count: int, **extra):
25 addr = int(memoryReference, 0) + offset
26 buf = gdb.selected_inferior().read_memory(addr, count)
27 return {
28 "address": hex(addr),
29 "data": base64.b64encode(buf).decode("ASCII"),
30 }
31
32
33@request("writeMemory")
34@capability("supportsWriteMemoryRequest")
35def write_memory(*, memoryReference: str, offset: int = 0, data: str, **extra):
36 addr = int(memoryReference, 0) + offset
37 buf = base64.b64decode(data)
38 gdb.selected_inferior().write_memory(addr, buf)
write_memory(*str memoryReference, int offset=0, str data, **extra)
Definition memory.py:35
read_memory(*str memoryReference, int offset=0, int count, **extra)
Definition memory.py:24