* [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
@ 2012-05-21 8:40 Siva Chandra
2012-05-21 16:27 ` Eli Zaretskii
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Siva Chandra @ 2012-05-21 8:40 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]
Hello,
Attached is a patch which adds the 'end' attribute to
gdb.Symtab_and_line. Essentially, it exposes the 'end' field of
'struct symtab_and_line'.
Though I have named the new attribute 'end' in the attached patch, I
would like to discuss this. There is already an attribute 'pc' which
is described as "Indicates the current program counter address" in the
documentation. I do not think this description is accurate: 'pc' is
actually the begin address of the program counter address range for
the current source line. To indicate the right meaning of 'pc' and
the new 'end' attribute, should they be named 'start_pc' and 'end_pc'
respectively, at least in the python API?
2012-05-21 Siva Chandra Reddy <sivachandra@google.com>
New attribute 'end' for gdb.Symtab_and_line.
* NEWS (Python Scripting): Add entry about the new attribute.
* python/py-symtab.c (salpy_get_end): New function which
implements the get method for the 'end' attribute of
gdb.Symtab_and_line.
(sal_object_getset): Add entry for the 'end' attribute.
doc/
* gdb.texinfo (Symbol Tables In Python): Add description about
the new 'end' attribute of gdb.Symtab_and line.
testsuite/
* gdb.python/py-symtab.exp: Add tests to test the new
attribute
'end' of gdb.Symtab_and_line.
* gdb.python/py-symbol.c: Move break point comment to enable
testing of gdb.Symtab_and_line.end.
Thanks,
Siva Chandra
[-- Attachment #2: sal_end_patch_v1.txt --]
[-- Type: text/plain, Size: 4385 bytes --]
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.524
diff -u -p -r1.524 NEWS
--- NEWS 20 May 2012 20:35:18 -0000 1.524
+++ NEWS 21 May 2012 07:23:07 -0000
@@ -58,6 +58,10 @@
** 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 'end' which holds the open
+ upper bound of the program counter address range for the current
+ source line.
+
* Go language support.
GDB now supports debugging programs written in the Go programming
language.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.970
diff -u -p -r1.970 gdb.texinfo
--- doc/gdb.texinfo 20 May 2012 20:35:19 -0000 1.970
+++ doc/gdb.texinfo 21 May 2012 07:23:15 -0000
@@ -25258,6 +25258,11 @@ Indicates the current program counter ad
writable.
@end defvar
+@defvar Symtab_and_line.end
+Indicates the open upper bound of the program counter address range 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.
Index: python/py-symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-symtab.c,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.c
--- python/py-symtab.c 3 May 2012 07:07:25 -0000 1.9
+++ python/py-symtab.c 21 May 2012 07:23:15 -0000
@@ -237,6 +237,19 @@ salpy_get_pc (PyObject *self, void *clos
return gdb_py_long_from_ulongest (sal->pc);
}
+/* Implementation of the get method for the 'end' attribute of
+ gdb.Symtab_and_line. */
+
+static PyObject *
+salpy_get_end (PyObject *self, void *closure)
+{
+ struct symtab_and_line *sal = NULL;
+
+ SALPY_REQUIRE_VALID (self, sal);
+
+ return gdb_py_long_from_ulongest (sal->end);
+}
+
static PyObject *
salpy_get_line (PyObject *self, void *closure)
{
@@ -556,6 +569,7 @@ 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 },
+ { "end", salpy_get_end, NULL, "Return the symtab_and_line's end pc.", NULL },
{ "line", salpy_get_line, NULL,
"Return the symtab_and_line's line.", NULL },
{NULL} /* Sentinel */
Index: testsuite/gdb.python/py-symbol.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.c,v
retrieving revision 1.6
diff -u -p -r1.6 py-symbol.c
--- testsuite/gdb.python/py-symbol.c 3 May 2012 07:07:26 -0000 1.6
+++ testsuite/gdb.python/py-symbol.c 21 May 2012 07:23:16 -0000
@@ -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
Index: testsuite/gdb.python/py-symtab.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.exp
--- testsuite/gdb.python/py-symtab.exp 3 May 2012 07:07:26 -0000 1.9
+++ testsuite/gdb.python/py-symtab.exp 21 May 2012 07:23:16 -0000
@@ -54,10 +54,13 @@ gdb_py_test_silent_cmd "python static_bl
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.end == new_pc" "True" "Test sal.end"
gdb_test "python print sal.line" "$line_no" "Test sal.line"
gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
@ 2012-05-21 16:27 ` Eli Zaretskii
2012-06-01 19:57 ` Siva Chandra
` (3 subsequent siblings)
4 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-05-21 16:27 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches
> Date: Mon, 21 May 2012 14:10:30 +0530
> From: Siva Chandra <sivachandra@google.com>
>
> 2012-05-21 Siva Chandra Reddy <sivachandra@google.com>
>
> New attribute 'end' for gdb.Symtab_and_line.
> * NEWS (Python Scripting): Add entry about the new attribute.
> * python/py-symtab.c (salpy_get_end): New function which
> implements the get method for the 'end' attribute of
> gdb.Symtab_and_line.
> (sal_object_getset): Add entry for the 'end' attribute.
>
> doc/
> * gdb.texinfo (Symbol Tables In Python): Add description about
> the new 'end' attribute of gdb.Symtab_and line.
>
> testsuite/
> * gdb.python/py-symtab.exp: Add tests to test the new attribute
> 'end' of gdb.Symtab_and_line.
> * gdb.python/py-symbol.c: Move break point comment to enable
> testing of gdb.Symtab_and_line.end.
Thanks. The documentation parts of your patch are fine with me.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
2012-05-21 16:27 ` Eli Zaretskii
@ 2012-06-01 19:57 ` Siva Chandra
2012-06-11 9:17 ` Siva Chandra
` (2 subsequent siblings)
4 siblings, 0 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-01 19:57 UTC (permalink / raw)
To: gdb-patches
ping!
On Mon, May 21, 2012 at 2:10 PM, Siva Chandra <sivachandra@google.com> wrote:
> Attached is a patch which adds the 'end' attribute to
> gdb.Symtab_and_line. Essentially, it exposes the 'end' field of
> 'struct symtab_and_line'.
>
> Though I have named the new attribute 'end' in the attached patch, I
> would like to discuss this. There is already an attribute 'pc' which
> is described as "Indicates the current program counter address" in the
> documentation. I do not think this description is accurate: 'pc' is
> actually the begin address of the program counter address range for
> the current source line. To indicate the right meaning of 'pc' and
> the new 'end' attribute, should they be named 'start_pc' and 'end_pc'
> respectively, at least in the python API?
>
> 2012-05-21 Siva Chandra Reddy <sivachandra@google.com>
>
> New attribute 'end' for gdb.Symtab_and_line.
> * NEWS (Python Scripting): Add entry about the new attribute.
> * python/py-symtab.c (salpy_get_end): New function which
> implements the get method for the 'end' attribute of
> gdb.Symtab_and_line.
> (sal_object_getset): Add entry for the 'end' attribute.
>
> doc/
> * gdb.texinfo (Symbol Tables In Python): Add description about
> the new 'end' attribute of gdb.Symtab_and line.
>
> testsuite/
> * gdb.python/py-symtab.exp: Add tests to test the new
> attribute
> 'end' of gdb.Symtab_and_line.
> * gdb.python/py-symbol.c: Move break point comment to enable
> testing of gdb.Symtab_and_line.end.
>
> Thanks,
> Siva Chandra
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
2012-05-21 16:27 ` Eli Zaretskii
2012-06-01 19:57 ` Siva Chandra
@ 2012-06-11 9:17 ` Siva Chandra
2012-06-11 21:22 ` Doug Evans
2012-06-22 17:10 ` Tom Tromey
4 siblings, 0 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-11 9:17 UTC (permalink / raw)
To: gdb-patches
I ping again.
Is it a good idea to expose the 'end' attribute in the Python API at all?
> 2012-05-21 Siva Chandra Reddy <sivachandra@google.com>
>
> New attribute 'end' for gdb.Symtab_and_line.
> * NEWS (Python Scripting): Add entry about the new attribute.
> * python/py-symtab.c (salpy_get_end): New function which
> implements the get method for the 'end' attribute of
> gdb.Symtab_and_line.
> (sal_object_getset): Add entry for the 'end' attribute.
>
> doc/
> * gdb.texinfo (Symbol Tables In Python): Add description about
> the new 'end' attribute of gdb.Symtab_and line.
>
> testsuite/
> * gdb.python/py-symtab.exp: Add tests to test the new attribute
> 'end' of gdb.Symtab_and_line.
> * gdb.python/py-symbol.c: Move break point comment to enable
> testing of gdb.Symtab_and_line.end.
>
> Thanks,
> Siva Chandra
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
` (2 preceding siblings ...)
2012-06-11 9:17 ` Siva Chandra
@ 2012-06-11 21:22 ` Doug Evans
2012-06-12 18:41 ` Siva Chandra
2012-06-22 17:10 ` Tom Tromey
4 siblings, 1 reply; 20+ messages in thread
From: Doug Evans @ 2012-06-11 21:22 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches
On Mon, May 21, 2012 at 1:40 AM, Siva Chandra <sivachandra@google.com> wrote:
> 2012-05-21 Siva Chandra Reddy <sivachandra@google.com>
>
> New attribute 'end' for gdb.Symtab_and_line.
> * NEWS (Python Scripting): Add entry about the new attribute.
> * python/py-symtab.c (salpy_get_end): New function which
> implements the get method for the 'end' attribute of
> gdb.Symtab_and_line.
> (sal_object_getset): Add entry for the 'end' attribute.
>
> doc/
> * gdb.texinfo (Symbol Tables In Python): Add description about
> the new 'end' attribute of gdb.Symtab_and line.
>
> testsuite/
> * gdb.python/py-symtab.exp: Add tests to test the new
> attribute
> 'end' of gdb.Symtab_and_line.
> * gdb.python/py-symbol.c: Move break point comment to enable
> testing of gdb.Symtab_and_line.end.
>
> Thanks,
> Siva Chandra
Hi.
Yeah, "end" would kinda be consistent and is yet a bit too vague.
Let's go with "end_pc" and at least leave "pc" alone for now.
One question we need to answer is what behaviour to expose in the API.
Is the range [pc,end_pc] or [pc,end_pc)?
[I know what the internal code does, but we don't have to follow it if
it makes for a sufficiently better API.]
And we need to clearly document this behaviour.
I don't have a strong preference on which one to use.
[One recognizes that [pc,end_pc] doesn't have a problem at 0xff...ff,
but I'm not sure it matters in practice.]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-11 21:22 ` Doug Evans
@ 2012-06-12 18:41 ` Siva Chandra
2012-06-12 19:43 ` Eli Zaretskii
2012-06-13 13:29 ` Siva Chandra
0 siblings, 2 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-12 18:41 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]
On Tue, Jun 12, 2012 at 2:52 AM, Doug Evans <dje@google.com> wrote:
> Let's go with "end_pc" and at least leave "pc" alone for now.
Done.
> One question we need to answer is what behaviour to expose in the API.
> Is the range [pc,end_pc] or [pc,end_pc)?
> [I know what the internal code does, but we don't have to follow it if
> it makes for a sufficiently better API.]
I have changed the behavior to [pc, end_pc] as this (at least the
name) feels more meaningful to me. But, why was right open behavior
chosen for internal code? Even the two-argument flavor of the
'disassemble' command has right open behavior.
> And we need to clearly document this behaviour.
I have described it in the documentation as "the end address of the
program counter address range for the current source line".
2012-06-12 Siva Chandra Reddy <sivachandra@google.com>
New attribute 'end_pc' for gdb.Symtab_and_line.
* NEWS (Python Scripting): Add entry about the new attribute.
* python/py-symtab.c (salpy_get_end_pc): New function which
implements the get method for the 'end_pc' attribute of
gdb.Symtab_and_line.
(sal_object_getset): Add entry for the 'end_pc' attribute.
doc/
* gdb.texinfo (Symbol Tables In Python): Add description about
the new 'end_pc' attribute of gdb.Symtab_and line.
testsuite/
* gdb.python/py-symtab.exp: Add tests to test the new attribute
'end_pc' of gdb.Symtab_and_line.
* gdb.python/py-symbol.c: Move break point comment to enable
testing of gdb.Symtab_and_line.end_pc.
Thanks,
Siva Chandra
[-- Attachment #2: sal_end_patch_v2.txt --]
[-- Type: text/plain, Size: 4412 bytes --]
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.527
diff -u -p -r1.527 NEWS
--- NEWS 6 Jun 2012 18:03:53 -0000 1.527
+++ NEWS 12 Jun 2012 18:28:02 -0000
@@ -60,6 +60,10 @@
** 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 'end_pc' which holds the end
+ address of the program counter address range for the current source
+ line.
+
* Go language support.
GDB now supports debugging programs written in the Go programming
language.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.974
diff -u -p -r1.974 gdb.texinfo
--- doc/gdb.texinfo 8 Jun 2012 13:05:55 -0000 1.974
+++ doc/gdb.texinfo 12 Jun 2012 18:28:21 -0000
@@ -25262,6 +25262,11 @@ Indicates the current program counter ad
writable.
@end defvar
+@defvar Symtab_and_line.end_pc
+Indicates the end address of the program counter address range 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.
Index: python/py-symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-symtab.c,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.c
--- python/py-symtab.c 3 May 2012 07:07:25 -0000 1.9
+++ python/py-symtab.c 12 Jun 2012 18:28:22 -0000
@@ -237,6 +237,19 @@ salpy_get_pc (PyObject *self, void *clos
return gdb_py_long_from_ulongest (sal->pc);
}
+/* Implementation of the get method for the 'end_pc' attribute of
+ gdb.Symtab_and_line. */
+
+static PyObject *
+salpy_get_end_pc (PyObject *self, void *closure)
+{
+ struct symtab_and_line *sal = NULL;
+
+ SALPY_REQUIRE_VALID (self, sal);
+
+ return gdb_py_long_from_ulongest (sal->end - 1);
+}
+
static PyObject *
salpy_get_line (PyObject *self, void *closure)
{
@@ -556,6 +569,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 },
+ { "end_pc", salpy_get_end_pc, NULL,
+ "Return the symtab_and_line's end pc.", NULL },
{ "line", salpy_get_line, NULL,
"Return the symtab_and_line's line.", NULL },
{NULL} /* Sentinel */
Index: testsuite/gdb.python/py-symbol.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.c,v
retrieving revision 1.6
diff -u -p -r1.6 py-symbol.c
--- testsuite/gdb.python/py-symbol.c 3 May 2012 07:07:26 -0000 1.6
+++ testsuite/gdb.python/py-symbol.c 12 Jun 2012 18:28:23 -0000
@@ -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
Index: testsuite/gdb.python/py-symtab.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.exp
--- testsuite/gdb.python/py-symtab.exp 3 May 2012 07:07:26 -0000 1.9
+++ testsuite/gdb.python/py-symtab.exp 12 Jun 2012 18:28:23 -0000
@@ -54,10 +54,13 @@ gdb_py_test_silent_cmd "python static_bl
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.end_pc == (new_pc - 1)" "True" "Test sal.end_pc"
gdb_test "python print sal.line" "$line_no" "Test sal.line"
gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-12 18:41 ` Siva Chandra
@ 2012-06-12 19:43 ` Eli Zaretskii
2012-06-13 7:24 ` Siva Chandra
2012-06-13 13:29 ` Siva Chandra
1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2012-06-12 19:43 UTC (permalink / raw)
To: Siva Chandra; +Cc: dje, gdb-patches
> Date: Wed, 13 Jun 2012 00:10:39 +0530
> From: Siva Chandra <sivachandra@google.com>
> Cc: gdb-patches@sourceware.org
>
> + ** gdb.Symtab_and_line has new attribute 'end_pc' which holds the end
> + address of the program counter address range for the current source
> + line.
Perhaps this minor rewording is better:
gdb.Symtab_and_line has a new attribute 'end_pc' which holds the end
of the address range occupied by code for the current source line.
> +@defvar Symtab_and_line.end_pc
> +Indicates the end address of the program counter address range for
> +the current source line. This attribute is not writable.
> +@end defvar
Can you reword this so as not to use "address" twice in the same
sentence, like I did for NEWS?
Thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-12 19:43 ` Eli Zaretskii
@ 2012-06-13 7:24 ` Siva Chandra
2012-06-13 15:15 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: Siva Chandra @ 2012-06-13 7:24 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: dje, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 886 bytes --]
Thanks Eli. I have modified according to your suggestion.
2012-06-13 Siva Chandra Reddy <sivachandra@google.com>
New attribute 'end_pc' for gdb.Symtab_and_line.
* NEWS (Python Scripting): Add entry about the new attribute.
* python/py-symtab.c (salpy_get_end_pc): New function which
implements the get method for the 'end_pc' attribute of
gdb.Symtab_and_line.
(sal_object_getset): Add entry for the 'end_pc' attribute.
doc/
* gdb.texinfo (Symbol Tables In Python): Add description about
the new 'end_pc' attribute of gdb.Symtab_and line.
testsuite/
* gdb.python/py-symtab.exp: Add tests to test the new attribute
'end_pc' of gdb.Symtab_and_line.
* gdb.python/py-symbol.c: Move break point comment to enable
testing of gdb.Symtab_and_line.end_pc.
Thanks,
Siva Chandra
[-- Attachment #2: sal_end_patch_v3.txt --]
[-- Type: text/plain, Size: 4391 bytes --]
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.527
diff -u -p -r1.527 NEWS
--- NEWS 6 Jun 2012 18:03:53 -0000 1.527
+++ NEWS 13 Jun 2012 07:21:13 -0000
@@ -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 'end_pc' 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.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.974
diff -u -p -r1.974 gdb.texinfo
--- doc/gdb.texinfo 8 Jun 2012 13:05:55 -0000 1.974
+++ doc/gdb.texinfo 13 Jun 2012 07:21:21 -0000
@@ -25262,6 +25262,11 @@ Indicates the current program counter ad
writable.
@end defvar
+@defvar Symtab_and_line.end_pc
+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.
Index: python/py-symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-symtab.c,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.c
--- python/py-symtab.c 3 May 2012 07:07:25 -0000 1.9
+++ python/py-symtab.c 13 Jun 2012 07:21:21 -0000
@@ -237,6 +237,19 @@ salpy_get_pc (PyObject *self, void *clos
return gdb_py_long_from_ulongest (sal->pc);
}
+/* Implementation of the get method for the 'end_pc' attribute of
+ gdb.Symtab_and_line. */
+
+static PyObject *
+salpy_get_end_pc (PyObject *self, void *closure)
+{
+ struct symtab_and_line *sal = NULL;
+
+ SALPY_REQUIRE_VALID (self, sal);
+
+ return gdb_py_long_from_ulongest (sal->end - 1);
+}
+
static PyObject *
salpy_get_line (PyObject *self, void *closure)
{
@@ -556,6 +569,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 },
+ { "end_pc", salpy_get_end_pc, NULL,
+ "Return the symtab_and_line's end pc.", NULL },
{ "line", salpy_get_line, NULL,
"Return the symtab_and_line's line.", NULL },
{NULL} /* Sentinel */
Index: testsuite/gdb.python/py-symbol.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.c,v
retrieving revision 1.6
diff -u -p -r1.6 py-symbol.c
--- testsuite/gdb.python/py-symbol.c 3 May 2012 07:07:26 -0000 1.6
+++ testsuite/gdb.python/py-symbol.c 13 Jun 2012 07:21:22 -0000
@@ -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
Index: testsuite/gdb.python/py-symtab.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.exp
--- testsuite/gdb.python/py-symtab.exp 3 May 2012 07:07:26 -0000 1.9
+++ testsuite/gdb.python/py-symtab.exp 13 Jun 2012 07:21:22 -0000
@@ -54,10 +54,13 @@ gdb_py_test_silent_cmd "python static_bl
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.end_pc == (new_pc - 1)" "True" "Test sal.end_pc"
gdb_test "python print sal.line" "$line_no" "Test sal.line"
gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-12 18:41 ` Siva Chandra
2012-06-12 19:43 ` Eli Zaretskii
@ 2012-06-13 13:29 ` Siva Chandra
2012-06-13 17:08 ` Doug Evans
1 sibling, 1 reply; 20+ messages in thread
From: Siva Chandra @ 2012-06-13 13:29 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Wed, Jun 13, 2012 at 12:10 AM, Siva Chandra <sivachandra@google.com> wrote:
> I have changed the behavior to [pc, end_pc] as this (at least the
> name) feels more meaningful to me. But, why was right open behavior
> chosen for internal code? Even the two-argument flavor of the
> 'disassemble' command has right open behavior.
Actually, I would like to take this back. I think, wrt 'disassemble'
command, it is essentially disassembling all instructions which fully
fall in the range provided as argument. Wrt symtab_and_line.end, if we
were to expose it as end_pc in the Python API, then I think it should
correspond to the PC value for the last instruction of that line of
source and not the last address in the range. And, if that were to be
the case, I do not think it is very practical as it does not indicate
where the next instruction starts. With the other choice, where in
end_pc indicates the last address in the range, the name end_pc
becomes a misnomer.
From my personal point of view, I see two options:
1. Call this new attribute 'last' and let it indicate the last address
in the range.
or
2. Call this new attribute 'next_start' and let it indicate the start
PC of the next instruction after the last instruction of the current
source line.
Either of the above is good enough for the use case I have in mind.
Thanks,
Siva Chandra
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-13 7:24 ` Siva Chandra
@ 2012-06-13 15:15 ` Eli Zaretskii
0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2012-06-13 15:15 UTC (permalink / raw)
To: Siva Chandra; +Cc: dje, gdb-patches
> Date: Wed, 13 Jun 2012 12:54:35 +0530
> From: Siva Chandra <sivachandra@google.com>
> Cc: dje@google.com, gdb-patches@sourceware.org
>
> Thanks Eli. I have modified according to your suggestion.
This version is fine, thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-13 13:29 ` Siva Chandra
@ 2012-06-13 17:08 ` Doug Evans
2012-06-13 18:15 ` Siva Chandra
0 siblings, 1 reply; 20+ messages in thread
From: Doug Evans @ 2012-06-13 17:08 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches
On Wed, Jun 13, 2012 at 6:29 AM, Siva Chandra <sivachandra@google.com> wrote:
> On Wed, Jun 13, 2012 at 12:10 AM, Siva Chandra <sivachandra@google.com> wrote:
>> I have changed the behavior to [pc, end_pc] as this (at least the
>> name) feels more meaningful to me. But, why was right open behavior
>> chosen for internal code? Even the two-argument flavor of the
>> 'disassemble' command has right open behavior.
>
> Actually, I would like to take this back. I think, wrt 'disassemble'
> command, it is essentially disassembling all instructions which fully
> fall in the range provided as argument. Wrt symtab_and_line.end, if we
> were to expose it as end_pc in the Python API, then I think it should
> correspond to the PC value for the last instruction of that line of
> source and not the last address in the range. And, if that were to be
> the case, I do not think it is very practical as it does not indicate
> where the next instruction starts. With the other choice, where in
> end_pc indicates the last address in the range, the name end_pc
> becomes a misnomer.
>
> From my personal point of view, I see two options:
>
> 1. Call this new attribute 'last' and let it indicate the last address
> in the range.
> or
> 2. Call this new attribute 'next_start' and let it indicate the start
> PC of the next instruction after the last instruction of the current
> source line.
>
> Either of the above is good enough for the use case I have in mind.
>
> Thanks,
> Siva Chandra
I like "last".
So the range would be [pc,last] ?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-13 17:08 ` Doug Evans
@ 2012-06-13 18:15 ` Siva Chandra
2012-06-22 9:21 ` Siva Chandra
2012-06-22 17:12 ` Tom Tromey
0 siblings, 2 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-13 18:15 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]
On Wed, Jun 13, 2012 at 10:38 PM, Doug Evans <dje@google.com> wrote:
> I like "last".
> So the range would be [pc,last] ?
Yes. The only reason I do not want to call it 'end' is to avoid
confusion with the internal 'end' which has a different behavior.
2012-06-13 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.
Thanks,
Siva Chandra
[-- Attachment #2: sal_end_patch_v4.txt --]
[-- Type: text/plain, Size: 4381 bytes --]
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.527
diff -u -p -r1.527 NEWS
--- NEWS 6 Jun 2012 18:03:53 -0000 1.527
+++ NEWS 13 Jun 2012 18:08:37 -0000
@@ -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.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.974
diff -u -p -r1.974 gdb.texinfo
--- doc/gdb.texinfo 8 Jun 2012 13:05:55 -0000 1.974
+++ doc/gdb.texinfo 13 Jun 2012 18:08:53 -0000
@@ -25262,6 +25262,11 @@ Indicates the current program counter ad
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.
Index: python/py-symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-symtab.c,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.c
--- python/py-symtab.c 3 May 2012 07:07:25 -0000 1.9
+++ python/py-symtab.c 13 Jun 2012 18:08:54 -0000
@@ -237,6 +237,19 @@ salpy_get_pc (PyObject *self, void *clos
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);
+
+ return gdb_py_long_from_ulongest (sal->end - 1);
+}
+
static PyObject *
salpy_get_line (PyObject *self, void *closure)
{
@@ -556,6 +569,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 */
Index: testsuite/gdb.python/py-symbol.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.c,v
retrieving revision 1.6
diff -u -p -r1.6 py-symbol.c
--- testsuite/gdb.python/py-symbol.c 3 May 2012 07:07:26 -0000 1.6
+++ testsuite/gdb.python/py-symbol.c 13 Jun 2012 18:08:55 -0000
@@ -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
Index: testsuite/gdb.python/py-symtab.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.exp
--- testsuite/gdb.python/py-symtab.exp 3 May 2012 07:07:26 -0000 1.9
+++ testsuite/gdb.python/py-symtab.exp 13 Jun 2012 18:08:55 -0000
@@ -54,10 +54,13 @@ gdb_py_test_silent_cmd "python static_bl
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"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-13 18:15 ` Siva Chandra
@ 2012-06-22 9:21 ` Siva Chandra
2012-06-22 17:12 ` Tom Tromey
1 sibling, 0 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-22 9:21 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Wed, Jun 13, 2012 at 11:45 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Wed, Jun 13, 2012 at 10:38 PM, Doug Evans <dje@google.com> wrote:
>> I like "last".
>> So the range would be [pc,last] ?
>
> Yes. The only reason I do not want to call it 'end' is to avoid
> confusion with the internal 'end' which has a different behavior.
>
> 2012-06-13 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.
Ping. Is this good to go in?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
` (3 preceding siblings ...)
2012-06-11 21:22 ` Doug Evans
@ 2012-06-22 17:10 ` Tom Tromey
2012-06-22 18:43 ` Siva Chandra
4 siblings, 1 reply; 20+ messages in thread
From: Tom Tromey @ 2012-06-22 17:10 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
Siva> There is already an attribute 'pc' which
Siva> is described as "Indicates the current program counter address" in the
Siva> documentation. I do not think this description is accurate: 'pc' is
Siva> actually the begin address of the program counter address range for
Siva> the current source line.
Would you mind fixing the documentation here?
(As a separate patch, not required for this one.)
Tom
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-13 18:15 ` Siva Chandra
2012-06-22 9:21 ` Siva Chandra
@ 2012-06-22 17:12 ` Tom Tromey
2012-06-22 21:12 ` Doug Evans
2012-06-24 17:03 ` Siva Chandra
1 sibling, 2 replies; 20+ messages in thread
From: Tom Tromey @ 2012-06-22 17:12 UTC (permalink / raw)
To: Siva Chandra; +Cc: Doug Evans, gdb-patches
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
Siva> +static PyObject *
Siva> +salpy_get_last (PyObject *self, void *closure)
Siva> +{
Siva> + struct symtab_and_line *sal = NULL;
Siva> +
Siva> + SALPY_REQUIRE_VALID (self, sal);
Siva> +
Siva> + return gdb_py_long_from_ulongest (sal->end - 1);
It seems that sal->end can be == 0.
For example I think gdb.decode_line can create sals like this.
In this case I think "- 1" will yield weird results.
Perhaps a None return would be better?
Tom
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-22 17:10 ` Tom Tromey
@ 2012-06-22 18:43 ` Siva Chandra
0 siblings, 0 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-22 18:43 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Siva> There is already an attribute 'pc' which
Siva> is described as "Indicates the current program counter address" in the
Siva> documentation. I do not think this description is accurate: 'pc' is
Siva> actually the begin address of the program counter address range for
Siva> the current source line.
Tom> Would you mind fixing the documentation here?
Tom> (As a separate patch, not required for this one.)
Sure. Will send a separate patch.
Thanks,
Siva Chandra
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-22 17:12 ` Tom Tromey
@ 2012-06-22 21:12 ` Doug Evans
2012-06-24 17:03 ` Siva Chandra
1 sibling, 0 replies; 20+ messages in thread
From: Doug Evans @ 2012-06-22 21:12 UTC (permalink / raw)
To: Tom Tromey; +Cc: Siva Chandra, gdb-patches
On Fri, Jun 22, 2012 at 10:12 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
>
> Siva> +static PyObject *
> Siva> +salpy_get_last (PyObject *self, void *closure)
> Siva> +{
> Siva> + struct symtab_and_line *sal = NULL;
> Siva> +
> Siva> + SALPY_REQUIRE_VALID (self, sal);
> Siva> +
> Siva> + return gdb_py_long_from_ulongest (sal->end - 1);
>
> It seems that sal->end can be == 0.
> For example I think gdb.decode_line can create sals like this.
> In this case I think "- 1" will yield weird results.
> Perhaps a None return would be better?
Good point. None "works for me".
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-22 17:12 ` Tom Tromey
2012-06-22 21:12 ` Doug Evans
@ 2012-06-24 17:03 ` Siva Chandra
2012-06-26 22:12 ` Doug Evans
1 sibling, 1 reply; 20+ messages in thread
From: Siva Chandra @ 2012-06-24 17:03 UTC (permalink / raw)
To: gdb-patches, Doug Evans
[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]
On Fri, Jun 22, 2012 at 10:42 PM, Tom Tromey <tromey@redhat.com> wrote:
> It seems that sal->end can be == 0.
> For example I think gdb.decode_line can create sals like this.
> In this case I think "- 1" will yield weird results.
> Perhaps a None return would be better?
Done. The patch is attached.
2012-06-24 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.
Thanks,
Siva Chandra
[-- Attachment #2: sal_end_patch_v5.txt --]
[-- Type: text/plain, Size: 4439 bytes --]
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.528
diff -u -p -r1.528 NEWS
--- NEWS 23 Jun 2012 22:23:46 -0000 1.528
+++ NEWS 24 Jun 2012 16:55:40 -0000
@@ -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.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.979
diff -u -p -r1.979 gdb.texinfo
--- doc/gdb.texinfo 23 Jun 2012 22:23:47 -0000 1.979
+++ doc/gdb.texinfo 24 Jun 2012 16:55:46 -0000
@@ -25264,6 +25264,11 @@ Indicates the current program counter ad
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.
Index: python/py-symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-symtab.c,v
retrieving revision 1.9
diff -u -p -r1.9 py-symtab.c
--- python/py-symtab.c 3 May 2012 07:07:25 -0000 1.9
+++ python/py-symtab.c 24 Jun 2012 16:55:47 -0000
@@ -237,6 +237,22 @@ salpy_get_pc (PyObject *self, void *clos
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 */
Index: testsuite/gdb.python/py-symbol.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.c,v
retrieving revision 1.6
diff -u -p -r1.6 py-symbol.c
--- testsuite/gdb.python/py-symbol.c 3 May 2012 07:07:26 -0000 1.6
+++ testsuite/gdb.python/py-symbol.c 24 Jun 2012 16:55:47 -0000
@@ -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
Index: testsuite/gdb.python/py-symtab.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symtab.exp,v
retrieving revision 1.10
diff -u -p -r1.10 py-symtab.exp
--- testsuite/gdb.python/py-symtab.exp 22 Jun 2012 17:59:33 -0000 1.10
+++ testsuite/gdb.python/py-symtab.exp 24 Jun 2012 16:55:47 -0000
@@ -46,10 +46,13 @@ gdb_py_test_silent_cmd "python static_bl
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"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-24 17:03 ` Siva Chandra
@ 2012-06-26 22:12 ` Doug Evans
2012-06-27 0:23 ` Siva Chandra
0 siblings, 1 reply; 20+ messages in thread
From: Doug Evans @ 2012-06-26 22:12 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches
On Sun, Jun 24, 2012 at 10:02 AM, Siva Chandra <sivachandra@google.com> wrote:
> On Fri, Jun 22, 2012 at 10:42 PM, Tom Tromey <tromey@redhat.com> wrote:
>> It seems that sal->end can be == 0.
>> For example I think gdb.decode_line can create sals like this.
>> In this case I think "- 1" will yield weird results.
>> Perhaps a None return would be better?
>
> Done. The patch is attached.
>
> 2012-06-24 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.
>
> Thanks,
> Siva Chandra
LGTM.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
2012-06-26 22:12 ` Doug Evans
@ 2012-06-27 0:23 ` Siva Chandra
0 siblings, 0 replies; 20+ messages in thread
From: Siva Chandra @ 2012-06-27 0:23 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Wed, Jun 27, 2012 at 3:42 AM, Doug Evans <dje@google.com> wrote:
>
> On Sun, Jun 24, 2012 at 10:02 AM, Siva Chandra <sivachandra@google.com> wrote:
> > On Fri, Jun 22, 2012 at 10:42 PM, Tom Tromey <tromey@redhat.com> wrote:
> >> It seems that sal->end can be == 0.
> >> For example I think gdb.decode_line can create sals like this.
> >> In this case I think "- 1" will yield weird results.
> >> Perhaps a None return would be better?
> >
> > Done. The patch is attached.
> >
> > 2012-06-24 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.
> >
> > Thanks,
> > Siva Chandra
>
> LGTM.
Committed.
Thank you.
Siva Chandra
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2012-06-27 0:23 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-21 8:40 [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line Siva Chandra
2012-05-21 16:27 ` Eli Zaretskii
2012-06-01 19:57 ` Siva Chandra
2012-06-11 9:17 ` Siva Chandra
2012-06-11 21:22 ` Doug Evans
2012-06-12 18:41 ` Siva Chandra
2012-06-12 19:43 ` Eli Zaretskii
2012-06-13 7:24 ` Siva Chandra
2012-06-13 15:15 ` Eli Zaretskii
2012-06-13 13:29 ` Siva Chandra
2012-06-13 17:08 ` Doug Evans
2012-06-13 18:15 ` Siva Chandra
2012-06-22 9:21 ` Siva Chandra
2012-06-22 17:12 ` Tom Tromey
2012-06-22 21:12 ` Doug Evans
2012-06-24 17:03 ` Siva Chandra
2012-06-26 22:12 ` Doug Evans
2012-06-27 0:23 ` Siva Chandra
2012-06-22 17:10 ` Tom Tromey
2012-06-22 18:43 ` Siva Chandra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox