From 64e7d9dddc00228cdbcecdd4c053cf83cf6608b7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 7 Feb 2012 19:42:27 +0000 Subject: PR python/13599: * python/py-symbol.c (sympy_line): New function. (symbol_object_getset): Add "line". gdb/doc * gdb.texinfo (Symbols In Python): Document Symbol.line. gdb/testsuite * gdb.python/py-symbol.c (qq): New global. * gdb.python/py-symbol.exp: Add test for frame-less lookup_symbol. * gdb.python/py-symtab.exp: Fix line number. --- gdb/python/py-symbol.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gdb/python') diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 9d32a71..d44014c 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -183,6 +183,19 @@ sympy_is_variable (PyObject *self, void *closure) || class == LOC_OPTIMIZED_OUT)); } +/* Implementation of gdb.Symbol.line -> int. + Returns the line number at which the symbol was defined. */ + +static PyObject * +sympy_line (PyObject *self, void *closure) +{ + struct symbol *symbol = NULL; + + SYMPY_REQUIRE_VALID (self, symbol); + + return PyInt_FromLong (SYMBOL_LINE (symbol)); +} + /* Implementation of gdb.Symbol.is_valid (self) -> Boolean. Returns True if this Symbol still exists in GDB. */ @@ -460,6 +473,8 @@ to display demangled or mangled names.", NULL }, "True if the symbol is a function or method." }, { "is_variable", sympy_is_variable, NULL, "True if the symbol is a variable." }, + { "line", sympy_line, NULL, + "The source line number at which the symbol was defined." }, { NULL } /* Sentinel */ }; -- cgit v1.1