aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@sourceware.org>2012-06-27 00:21:21 +0000
committerSiva Chandra Reddy <sivachandra@sourceware.org>2012-06-27 00:21:21 +0000
commitee0bf529c3da511fd32d4a997bf958a6af28b582 (patch)
tree9587312091dd0f122683506414693a5f8f0fafc8 /gdb
parentf7ccda615a4867b2f0f7cc0e68ba773562984da6 (diff)
downloadgdb-ee0bf529c3da511fd32d4a997bf958a6af28b582.zip
gdb-ee0bf529c3da511fd32d4a997bf958a6af28b582.tar.gz
gdb-ee0bf529c3da511fd32d4a997bf958a6af28b582.tar.bz2
2012-06-26 Siva Chandra Reddy <sivachandra@google.com>
New attribute 'last' for gdb.Symtab_and_line. * NEWS (Python Scripting): Add entry about the new attribute. * python/py-symtab.c (salpy_get_last): New function which implements the get method for the 'last' attribute of gdb.Symtab_and_line. (sal_object_getset): Add entry for the 'last' attribute. doc/ * gdb.texinfo (Symbol Tables In Python): Add description about the new 'last' attribute of gdb.Symtab_and line. testsuite/ * gdb.python/py-symtab.exp: Add tests to test the new attribute 'last' of gdb.Symtab_and_line. * gdb.python/py-symbol.c: Move break point comment to enable testing of gdb.Symtab_and_line.last.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/NEWS3
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo5
-rw-r--r--gdb/python/py-symtab.c18
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.c4
-rw-r--r--gdb/testsuite/gdb.python/py-symtab.exp3
8 files changed, 52 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b8594e4..d69449a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2012-06-26 Siva Chandra Reddy <sivachandra@google.com>
+
+ New attribute 'last' for gdb.Symtab_and_line.
+ * NEWS (Python Scripting): Add entry about the new attribute.
+ * python/py-symtab.c (salpy_get_last): New function which
+ implements the get method for the 'last' attribute of
+ gdb.Symtab_and_line.
+ (sal_object_getset): Add entry for the 'last' attribute.
+
2012-06-26 Doug Evans <dje@google.com>
* dwarf2read.c (dwo_section_names): Add macinfo_dwo, macro_dwo.
diff --git a/gdb/NEWS b/gdb/NEWS
index eeecc57..b1f6775 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -60,6 +60,9 @@
** New function gdb.find_pc_line which returns the gdb.Symtab_and_line
object associated with a PC value.
+ ** gdb.Symtab_and_line has new attribute 'last' which holds the end
+ of the address range occupied by code for the current source line.
+
* Go language support.
GDB now supports debugging programs written in the Go programming
language.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index f0bbe3e..b1ebf98 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,5 +1,10 @@
2012-06-26 Siva Chandra Reddy <sivachandra@google.com>
+ * gdb.texinfo (Symbol Tables In Python): Add description about
+ the new 'last' attribute of gdb.Symtab_and line.
+
+2012-06-26 Siva Chandra Reddy <sivachandra@google.com>
+
* gdb.texinfo (Symbol Tables In Python): Correct the description
of the 'pc' attribute of gdb.Symtab_and_line.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 80e1b9b..a2c9167 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -25276,6 +25276,11 @@ Indicates the start of the address range occupied by code for the
current source line. This attribute is not writable.
@end defvar
+@defvar Symtab_and_line.last
+Indicates the end of the address range occupied by code for the current
+source line. This attribute is not writable.
+@end defvar
+
@defvar Symtab_and_line.line
Indicates the current line number for this object. This
attribute is not writable.
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index e9e38b2..b6f45e6 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -237,6 +237,22 @@ salpy_get_pc (PyObject *self, void *closure)
return gdb_py_long_from_ulongest (sal->pc);
}
+/* Implementation of the get method for the 'last' attribute of
+ gdb.Symtab_and_line. */
+
+static PyObject *
+salpy_get_last (PyObject *self, void *closure)
+{
+ struct symtab_and_line *sal = NULL;
+
+ SALPY_REQUIRE_VALID (self, sal);
+
+ if (sal->end > 0)
+ return gdb_py_long_from_ulongest (sal->end - 1);
+ else
+ Py_RETURN_NONE;
+}
+
static PyObject *
salpy_get_line (PyObject *self, void *closure)
{
@@ -556,6 +572,8 @@ static PyTypeObject symtab_object_type = {
static PyGetSetDef sal_object_getset[] = {
{ "symtab", salpy_get_symtab, NULL, "Symtab object.", NULL },
{ "pc", salpy_get_pc, NULL, "Return the symtab_and_line's pc.", NULL },
+ { "last", salpy_get_last, NULL,
+ "Return the symtab_and_line's last address.", NULL },
{ "line", salpy_get_line, NULL,
"Return the symtab_and_line's line.", NULL },
{NULL} /* Sentinel */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 23e1965..42ae689 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-26 Siva Chandra Reddy <sivachandra@google.com>
+
+ * gdb.python/py-symtab.exp: Add tests to test the new attribute
+ 'last' of gdb.Symtab_and_line.
+ * gdb.python/py-symbol.c: Move break point comment to enable
+ testing of gdb.Symtab_and_line.last.
+
2012-06-26 Tom Tromey <tromey@redhat.com>
* gdb.threads/step.c: Remove.
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index 8c6cdb1..82395f1 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -40,8 +40,8 @@ int qq = 72; /* line of qq */
int func (int arg)
{
int i = 2;
- i = i * arg;
- return arg; /* Block break here. */
+ i = i * arg; /* Block break here. */
+ return arg;
}
struct simple_struct
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index 9aef863..da0c3e4 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -46,10 +46,13 @@ gdb_py_test_silent_cmd "python static_block = symtab.static_block()" "Get static
gdb_py_test_silent_cmd "python global_symbols = \[\]; static_symbols = \[\]" "Set up symbol name lists" 0
gdb_py_test_silent_cmd "python for sym in global_block: global_symbols.append(sym.name)" "Get global symbol names" 0
gdb_py_test_silent_cmd "python for sym in static_block: static_symbols.append(sym.name)" "Get static symbol names" 0
+gdb_py_test_silent_cmd "step" "Step to the next line" 0
+gdb_py_test_silent_cmd "python new_pc = gdb.selected_frame().find_sal().pc" "Get new PC" 0
# Test sal.
gdb_test "python print sal.symtab" ".*gdb.python/py-symbol.c.*" "Test symtab"
gdb_test "python print sal.pc" "${decimal}" "Test sal.pc"
+gdb_test "python print sal.last == (new_pc - 1)" "True" "Test sal.last"
gdb_test "python print sal.line" "$line_no" "Test sal.line"
gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid"