Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:jeff_mahoney:crash-python:devel
gdb
0009-pyblock-add-dictionary-browsing-for-symbol...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0009-pyblock-add-dictionary-browsing-for-symbols.patch of Package gdb
From 8f53295ba39e5ddf8839464e97bedffde721efd3 Mon Sep 17 00:00:00 2001 From: Ales Novak <alnovak@suse.cz> Date: Wed, 2 Sep 2015 11:17:24 +0200 Subject: [PATCH 09/17] pyblock: add dictionary browsing for symbols --- gdb/python/py-block.c | 111 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index cf543c79484..b8637e02e5a 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -102,6 +102,115 @@ blpy_iter (PyObject *self) return (PyObject *) block_iter_obj; } + +typedef struct { + PyObject_HEAD + struct mdict_iterator iter; + int finished; + void *value; + PyObject *(*func)(void *); +} DictIter; + +PyObject* DictIter_iter(PyObject *self); +PyObject* DictIter_iter(PyObject *self) +{ + Py_INCREF(self); + return self; +} + +static PyObject *obj_to_sym(void *val) +{ + PyObject *v = symbol_to_symbol_object ((struct symbol*)val); + return v; +} + +PyObject* DictIter_iternext(PyObject *self); +PyObject* DictIter_iternext(PyObject *self) +{ + DictIter *p = (DictIter *)self; + PyObject *v; + void *n; + + if (p->finished == 1) + return NULL; + + v = p->func((struct symbol*)p->value); + + n = mdict_iterator_next(&p->iter); + + if (!n) + p->finished = 1; + else p->value = n; + + return v; +} + +static PyTypeObject DictIterType = { + PyVarObject_HEAD_INIT(NULL, 0) + "gdb._DictIter", /* tp_name */ + sizeof(DictIter), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "gdb dictionary iterator object.", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + DictIter_iter, /* tp_iter */ + DictIter_iternext, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +static PyObject * +blpy_get_symbols(PyObject *self, void *closure) +{ + PyObject *tmp; + const struct block *block = NULL; + struct symbol *s; + + BLPY_REQUIRE_VALID (self, block); + + tmp = (PyObject*)PyObject_New(DictIter, &DictIterType); + if (!tmp) return NULL; + + if (!PyObject_Init((PyObject *)tmp, &DictIterType)) { + Py_DECREF(tmp); + return NULL; + } + + s = mdict_iterator_first(block->multidict, &((DictIter*)tmp)->iter); + + ((DictIter*)tmp)->value = s; + ((DictIter*)tmp)->func = obj_to_sym; + + return tmp; +} + static PyObject * blpy_get_start (PyObject *self, void *closure) { @@ -449,6 +558,7 @@ gdbpy_initialize_blocks (void) if (PyType_Ready (&block_syms_iterator_object_type) < 0) return -1; + if (PyType_Ready(&DictIterType) < 0) return -1; if (gdb_pymodule_addobject (gdb_module, "Block", (PyObject *) &block_object_type) < 0) return -1; @@ -467,6 +577,7 @@ Return true if this block is valid, false if not." }, }; static gdb_PyGetSetDef block_object_getset[] = { + { "symbols", blpy_get_symbols, NULL, "Get symbols", NULL }, { "start", blpy_get_start, NULL, "Start address of the block.", NULL }, { "end", blpy_get_end, NULL, "End address of the block.", NULL }, { "function", blpy_get_function, NULL, -- 2.37.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor