diff options
Diffstat (limited to 'gdb/python/py-symbol.c')
-rw-r--r-- | gdb/python/py-symbol.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index e072dc8..390d612 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -236,6 +236,7 @@ sympy_dealloc (PyObject *obj) A tuple with 2 elements is always returned. The first is the symbol object or None, the second is a boolean with the value of is_a_field_of_this (see comment in lookup_symbol_in_language). */ + PyObject * gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) { @@ -294,6 +295,39 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) return ret_tuple; } +/* Implementation of + gdb.lookup_global_symbol (name [, domain]) -> symbol or None. */ + +PyObject * +gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) +{ + int domain = VAR_DOMAIN; + const char *name; + static char *keywords[] = { "name", "domain", NULL }; + struct symbol *symbol; + PyObject *sym_obj; + + if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name, + &domain)) + return NULL; + + symbol = lookup_symbol_global (name, NULL, domain); + + if (symbol) + { + sym_obj = symbol_to_symbol_object (symbol); + if (!sym_obj) + return NULL; + } + else + { + sym_obj = Py_None; + Py_INCREF (Py_None); + } + + return sym_obj; +} + /* This function is called when an objfile is about to be freed. Invalidate the symbol as further actions on the symbol would result in bad data. All access to obj->symbol should be gated by |