]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/python/py-instruction.c
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / python / py-instruction.c
1 /* Python interface to instruction objects.
2
3 Copyright 2017-2022 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "py-instruction.h"
22
23 /* See py-instruction.h. */
24
25 PyTypeObject py_insn_type = {
26 PyVarObject_HEAD_INIT (NULL, 0)
27 };
28
29 /* Python instruction object. */
30
31 struct py_insn_obj {
32 PyObject_HEAD
33 };
34
35 /* Getter function for gdb.Instruction attributes. */
36
37 static PyObject *
38 py_insn_getter (PyObject *self, void *closure)
39 {
40 return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
41 }
42
43 /* Instruction members. */
44
45 static gdb_PyGetSetDef py_insn_getset[] =
46 {
47 { "pc", py_insn_getter, NULL, "instruction address", NULL},
48 { "data", py_insn_getter, NULL, "instruction memory", NULL},
49 { "decoded", py_insn_getter, NULL, "decoded instruction", NULL},
50 { "size", py_insn_getter, NULL, "instruction size in bytes", NULL},
51 {NULL}
52 };
53
54 /* Sets up the gdb.Instruction type. */
55
56 int
57 gdbpy_initialize_instruction (void)
58 {
59 py_insn_type.tp_new = PyType_GenericNew;
60 py_insn_type.tp_flags = Py_TPFLAGS_DEFAULT;
61 py_insn_type.tp_basicsize = sizeof (py_insn_obj);
62 py_insn_type.tp_name = "gdb.Instruction";
63 py_insn_type.tp_doc = "GDB instruction object";
64 py_insn_type.tp_getset = py_insn_getset;
65
66 return PyType_Ready (&py_insn_type);
67 }