From: Siva Chandra <sivachandra@google.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC - Python Scripting] Add 'end' attribute to gdb.Symtab_and_line
Date: Tue, 12 Jun 2012 18:41:00 -0000 [thread overview]
Message-ID: <CAGyQ6gwDhacRNuCxvsWRnt7tKDJ2_0iyryw+hdL5rsq+h3MaAA@mail.gmail.com> (raw)
In-Reply-To: <CADPb22Sacqq3vWoXh0Q9q2fdxZr9WXHPOhvbCUWTDKOwrmNCMA@mail.gmail.com>
[-- 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"
next prev parent reply other threads:[~2012-06-12 18:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-21 8:40 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGyQ6gwDhacRNuCxvsWRnt7tKDJ2_0iyryw+hdL5rsq+h3MaAA@mail.gmail.com \
--to=sivachandra@google.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox