* [PATCH 0/3] Fixed abortion using Python API for label symbol object.
@ 2014-03-04 10:36 Maxim Bublis
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-03-04 10:36 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
Hi,
There is a problem with calling .value() method for label symbol object,
i.e. symbol object with it's .addr_class == gdb.SYMBOL_LOC_LABEL.
If you debugging code similar to that:
int main() {
abort();
some_label:
return 0;
}
and if you are running something like that (frame with `main' function should be selected in this case):
gdb> python "print list(gdb.selected_frame().block())[0].value(gdb.selected_frame())"
gdb will fail with SIGABRT.
Following patchset adds testcase, fixes problem and documents this behavior.
Maxim Bublis (3):
gdb/testsuite/gdb.python: Added testcase for .value() method
gdb/python: raise TypeError instead of abort() on calling .value()
method for label symbol object
gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on
possible exception thrown from symbol object .value() method
gdb/ChangeLog | 6 ++++++
gdb/doc/ChangeLog | 6 ++++++
gdb/doc/python.texi | 9 ++++++++-
gdb/python/py-symbol.c | 6 ++++++
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.python/py-symbol.c | 3 +++
gdb/testsuite/gdb.python/py-symbol.exp | 6 ++++++
7 files changed, 41 insertions(+), 1 deletion(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method
2014-03-04 10:36 [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
@ 2014-03-04 10:37 ` Maxim Bublis
2014-03-04 16:53 ` Eli Zaretskii
2014-03-05 13:41 ` [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method Maxim Bublis
2014-03-04 10:37 ` [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
` (2 subsequent siblings)
3 siblings, 2 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-03-04 10:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/doc/ChangeLog | 6 ++++++
gdb/doc/python.texi | 9 ++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 47f5f38..2eec47f 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-04 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb/doc/python.texi (Symbols In Python): Document gdb.SYMBOL_LOC_LABEL
+ address class. Added notion on possible exception thrown from .value()
+ method with some address classes.
+
2014-02-26 Ludovic Courtès <ludo@gnu.org>
* gdb/doc/guile.texi (Basic Guile): Document 'history-append!'.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 90b7074..c3d49dc 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3544,7 +3544,10 @@ functions, this computes the address of the function, cast to the
appropriate type. If the symbol requires a frame in order to compute
its value, then @var{frame} must be given. If @var{frame} is not
given, or if @var{frame} is invalid, then this method will throw an
-exception.
+exception. For symbols with some address classes it is not possible
+to compute value (eg. @code{gdb.SYMBOL_LOC_TYPEDEF} or
+@code{gdb.SYMBOL_LOC_LABEL}), in this case exception will
+be thrown.
@end defun
The available domain categories in @code{gdb.Symbol} are represented
@@ -3632,6 +3635,10 @@ Value is a local variable.
@item gdb.SYMBOL_LOC_TYPEDEF
Value not used. Symbols in the domain @code{SYMBOL_STRUCT_DOMAIN} all
have this class.
+@findex SYMBOL_LOC_LABEL
+@findex gdb.SYMBOL_LOC_LABEL
+@item gdb.SYMBOL_LOC_LABEL
+Value is address @code{SYMBOL_VALUE_ADDRESS} in the code.
@findex SYMBOL_LOC_BLOCK
@findex gdb.SYMBOL_LOC_BLOCK
@item gdb.SYMBOL_LOC_BLOCK
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method
2014-03-04 10:36 [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
2014-03-04 10:37 ` [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
@ 2014-03-04 10:37 ` Maxim Bublis
2014-03-05 13:41 ` [PATCH v2 1/3] gdb/testsuite/gdb.python: Added testcase for value method Maxim Bublis
2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
3 siblings, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-03-04 10:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.python/py-symbol.c | 3 +++
gdb/testsuite/gdb.python/py-symbol.exp | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 835338f..e0066fa 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-04 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb.python/py-symbol.c: Add label.
+ * gdb.python/py-symbol.exp: Test label object .value()
+ method call.
+
2014-02-26 Ludovic Courtès <ludo@gnu.org>
* gdb.guile/scm-value.exp (test_value_in_inferior): Add
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index 3201365..746a370 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -40,6 +40,9 @@ int func (int arg)
{
int i = 2;
i = i * arg; /* Block break here. */
+
+some_label:
+
return arg;
}
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index 9b6ba2e..cace689 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -81,6 +81,12 @@ gdb_test "python print (func.print_name)" "func" "Test func.print_name"
gdb_test "python print (func.linkage_name)" "func" "Test func.linkage_name"
gdb_test "python print (func.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "Test func.addr_class"
+# Test attributes and methods of label.
+gdb_py_test_silent_cmd "python some_label = list(block)\[2\]" "Get some_label symbol" 0
+gdb_test "python print (some_label.name)" "some_label" "Test some_label.name"
+gdb_test "python print (some_label.addr_class == gdb.SYMBOL_LOC_LABEL)" "True" "Test some_label.addr_class"
+gdb_test "python print (some_label.value(frame))" ".*TypeError: cannot get the value of a label.*" "Test some_label.value()"
+
gdb_breakpoint [gdb_get_line_number "Break at end."]
gdb_continue_to_breakpoint "Break at end for variable a" ".*Break at end.*"
gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
2014-03-04 10:36 [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
@ 2014-03-04 10:37 ` Maxim Bublis
2014-03-04 17:57 ` Phil Muldoon
2014-03-05 13:41 ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value " Maxim Bublis
2014-03-04 10:37 ` [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method Maxim Bublis
2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
3 siblings, 2 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-03-04 10:37 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/ChangeLog | 6 ++++++
gdb/python/py-symbol.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2129d6f..67749e9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-04 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb/python/py-symbol.c (sympy_value): Throw TypeError exception
+ instead of abort() on calling .value() method for
+ Symbol object with SYMBOL_LOC_LABEL address class.
+
2014-03-03 Tom Tromey <tromey@redhat.com>
* elfread.c (probe_key): Change to bfd_data.
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 6900d58..5e22309 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -262,6 +262,12 @@ sympy_value (PyObject *self, PyObject *args)
return NULL;
}
+ if (SYMBOL_CLASS (symbol) == LOC_LABEL)
+ {
+ PyErr_SetString (PyExc_TypeError, "cannot get the value of a label");
+ return NULL;
+ }
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (frame_obj != NULL)
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
@ 2014-03-04 16:53 ` Eli Zaretskii
2014-03-05 13:34 ` Maxim Bublis
2014-03-05 13:41 ` [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method Maxim Bublis
1 sibling, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2014-03-04 16:53 UTC (permalink / raw)
To: Maxim Bublis; +Cc: gdb-patches
> From: Maxim Bublis <satori@yandex-team.ru>
> Cc: Maxim Bublis <satori@yandex-team.ru>
> Date: Tue, 4 Mar 2014 14:36:00 +0400
>
> +2014-03-04 Maxim Bublis <satori@yandex-team.ru>
> +
> + * gdb/doc/python.texi (Symbols In Python): Document gdb.SYMBOL_LOC_LABEL
> + address class. Added notion on possible exception thrown from .value()
^^
Two spaces between sentences, please. Also, please don't attach "()"
to function and method name to signal they are function, that's
against GNU Coding Standards (it looks like a call to a function with
no arguments, which is not what you want to say).
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -3544,7 +3544,10 @@ functions, this computes the address of the function, cast to the
> appropriate type. If the symbol requires a frame in order to compute
> its value, then @var{frame} must be given. If @var{frame} is not
> given, or if @var{frame} is invalid, then this method will throw an
> -exception.
> +exception. For symbols with some address classes it is not possible
> +to compute value (eg. @code{gdb.SYMBOL_LOC_TYPEDEF} or
> +@code{gdb.SYMBOL_LOC_LABEL}), in this case exception will
> +be thrown.
Please try to minimize the use of passive tense, it makes the text
longer and slightly less clear. In this case, I suggest to rephrase:
This method will also throw an exception for symbols for which it is
not possible to compute the value, such as
@code{gdb.SYMBOL_LOC_TYPEDEF} or @code{gdb.SYMBOL_LOC_LABEL}.
The documentation patch is OK with those changes.
I have a question regarding the last part: is it wise to throw an
exception when a symbol has no value? how about returning None
instead?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
2014-03-04 10:37 ` [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
@ 2014-03-04 17:57 ` Phil Muldoon
2014-03-05 13:39 ` Maxim Bublis
2014-03-05 13:41 ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value " Maxim Bublis
1 sibling, 1 reply; 18+ messages in thread
From: Phil Muldoon @ 2014-03-04 17:57 UTC (permalink / raw)
To: Maxim Bublis, gdb-patches
On 04/03/14 10:35, Maxim Bublis wrote:
>
> + if (SYMBOL_CLASS (symbol) == LOC_LABEL)
> + {
> + PyErr_SetString (PyExc_TypeError, "cannot get the value of a label");
Error text should be complete sentences with punctuation and proper
capitalization (I know there are a few in the code base that aren't,
but we'll get them all eventually).
> + return NULL;
> + }
> +
> TRY_CATCH (except, RETURN_MASK_ALL)
> {
> if (frame_obj != NULL)
This patch looks fine to me apart from one further small aside (please
wait for a maintainer to approve your patch, regardless). In the
documentation you note there are other types of symbol that can
produce this error: e.g., SYMBOL_LOC_TYPEDEF. Can you please audit and
include checks for all, while you are there? I noticed only the
explicit LOC_LABEL check in the patch above.
Cheers,
Phil
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method
2014-03-04 16:53 ` Eli Zaretskii
@ 2014-03-05 13:34 ` Maxim Bublis
0 siblings, 0 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Hi
> I have a question regarding the last part: is it wise to throw an
> exception when a symbol has no value? how about returning None
> instead?
There is already implemented similar behavior for LOC_TYPEDEF, it raises TypeError exception, I think there is no good reason to break current API.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
2014-03-04 17:57 ` Phil Muldoon
@ 2014-03-05 13:39 ` Maxim Bublis
2014-03-06 8:37 ` Phil Muldoon
0 siblings, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:39 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
> This patch looks fine to me apart from one further small aside (please
> wait for a maintainer to approve your patch, regardless). In the
> documentation you note there are other types of symbol that can
> produce this error: e.g., SYMBOL_LOC_TYPEDEF. Can you please audit and
> include checks for all, while you are there? I noticed only the
> explicit LOC_LABEL check in the patch above.
There is already implemented similar behavior for LOC_TYPEDEF, so no additional work here should be done.
On the other hand there is no testcase for typedef symbol object .value() method call.
Maybe you could provide me a help with writing such testcase as I do not quietly understand how typedef symbol object could be retrieved.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
2014-03-04 10:37 ` [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
2014-03-04 17:57 ` Phil Muldoon
@ 2014-03-05 13:41 ` Maxim Bublis
2014-04-14 7:41 ` Phil Muldoon
1 sibling, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/ChangeLog | 6 ++++++
gdb/python/py-symbol.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8108e50..19ec13c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-05 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb/python/py-symbol.c (sympy_value): Throw TypeError exception
+ instead of abort on calling value method for
+ symbol object with SYMBOL_LOC_LABEL address class.
+
2014-03-05 Mike Frysinger <vapier@gentoo.org>
* remote-sim.c (gdbsim_load): Add const to prog.
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 6900d58..6303cea 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -262,6 +262,12 @@ sympy_value (PyObject *self, PyObject *args)
return NULL;
}
+ if (SYMBOL_CLASS (symbol) == LOC_LABEL)
+ {
+ PyErr_SetString (PyExc_TypeError, "It is not possible to compute the value of a label.");
+ return NULL;
+ }
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (frame_obj != NULL)
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
2014-03-04 16:53 ` Eli Zaretskii
@ 2014-03-05 13:41 ` Maxim Bublis
2014-03-05 17:12 ` Eli Zaretskii
1 sibling, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/doc/ChangeLog | 6 ++++++
gdb/doc/python.texi | 8 +++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 47f5f38..c019c8d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-05 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb/doc/python.texi (Symbols In Python): Document gdb.SYMBOL_LOC_LABEL
+ address class. Added notion on possible exception thrown from value
+ method with some address classes.
+
2014-02-26 Ludovic Courtès <ludo@gnu.org>
* gdb/doc/guile.texi (Basic Guile): Document 'history-append!'.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 90b7074..bea372f 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3544,7 +3544,9 @@ functions, this computes the address of the function, cast to the
appropriate type. If the symbol requires a frame in order to compute
its value, then @var{frame} must be given. If @var{frame} is not
given, or if @var{frame} is invalid, then this method will throw an
-exception.
+exception. This method will also throw an exception for symbols
+for which it is not possible to compute the value, such as
+@code{gdb.SYMBOL_LOC_TYPEDEF} or @code{gdb.SYMBOL_LOC_LABEL}).
@end defun
The available domain categories in @code{gdb.Symbol} are represented
@@ -3632,6 +3634,10 @@ Value is a local variable.
@item gdb.SYMBOL_LOC_TYPEDEF
Value not used. Symbols in the domain @code{SYMBOL_STRUCT_DOMAIN} all
have this class.
+@findex SYMBOL_LOC_LABEL
+@findex gdb.SYMBOL_LOC_LABEL
+@item gdb.SYMBOL_LOC_LABEL
+Value is address @code{SYMBOL_VALUE_ADDRESS} in the code.
@findex SYMBOL_LOC_BLOCK
@findex gdb.SYMBOL_LOC_BLOCK
@item gdb.SYMBOL_LOC_BLOCK
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/3] gdb/testsuite/gdb.python: Added testcase for value method
2014-03-04 10:37 ` [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method Maxim Bublis
@ 2014-03-05 13:41 ` Maxim Bublis
0 siblings, 0 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Maxim Bublis
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.python/py-symbol.c | 3 +++
gdb/testsuite/gdb.python/py-symbol.exp | 6 ++++++
3 files changed, 14 insertions(+)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 835338f..b735369 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-05 Maxim Bublis <satori@yandex-team.ru>
+
+ * gdb.python/py-symbol.c: Add label.
+ * gdb.python/py-symbol.exp: Test value method for label object.
+
2014-02-26 Ludovic Courtès <ludo@gnu.org>
* gdb.guile/scm-value.exp (test_value_in_inferior): Add
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index 3201365..746a370 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -40,6 +40,9 @@ int func (int arg)
{
int i = 2;
i = i * arg; /* Block break here. */
+
+some_label:
+
return arg;
}
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index 9b6ba2e..cace689 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -81,6 +81,12 @@ gdb_test "python print (func.print_name)" "func" "Test func.print_name"
gdb_test "python print (func.linkage_name)" "func" "Test func.linkage_name"
gdb_test "python print (func.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "Test func.addr_class"
+# Test attributes and methods of label.
+gdb_py_test_silent_cmd "python some_label = list(block)\[2\]" "Get some_label symbol" 0
+gdb_test "python print (some_label.name)" "some_label" "Test some_label.name"
+gdb_test "python print (some_label.addr_class == gdb.SYMBOL_LOC_LABEL)" "True" "Test some_label.addr_class"
+gdb_test "python print (some_label.value(frame))" ".*TypeError: cannot get the value of a label.*" "Test some_label.value()"
+
gdb_breakpoint [gdb_get_line_number "Break at end."]
gdb_continue_to_breakpoint "Break at end for variable a" ".*Break at end.*"
gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
--
1.7.9.5
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method
2014-03-05 13:41 ` [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method Maxim Bublis
@ 2014-03-05 17:12 ` Eli Zaretskii
0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2014-03-05 17:12 UTC (permalink / raw)
To: Maxim Bublis; +Cc: gdb-patches, satori
> From: Maxim Bublis <satori@yandex-team.ru>
> Cc: Maxim Bublis <satori@yandex-team.ru>
> Date: Wed, 5 Mar 2014 17:41:04 +0400
>
> ---
> gdb/doc/ChangeLog | 6 ++++++
> gdb/doc/python.texi | 8 +++++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
> index 47f5f38..c019c8d 100644
> --- a/gdb/doc/ChangeLog
> +++ b/gdb/doc/ChangeLog
> @@ -1,3 +1,9 @@
> +2014-03-05 Maxim Bublis <satori@yandex-team.ru>
> +
> + * gdb/doc/python.texi (Symbols In Python): Document gdb.SYMBOL_LOC_LABEL
> + address class. Added notion on possible exception thrown from value
> + method with some address classes.
OK, thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
2014-03-05 13:39 ` Maxim Bublis
@ 2014-03-06 8:37 ` Phil Muldoon
0 siblings, 0 replies; 18+ messages in thread
From: Phil Muldoon @ 2014-03-06 8:37 UTC (permalink / raw)
To: Maxim Bublis; +Cc: gdb-patches
On 05/03/14 13:39, Maxim Bublis wrote:
>
>> This patch looks fine to me apart from one further small aside (please
>> wait for a maintainer to approve your patch, regardless). In the
>> documentation you note there are other types of symbol that can
>> produce this error: e.g., SYMBOL_LOC_TYPEDEF. Can you please audit and
>> include checks for all, while you are there? I noticed only the
>> explicit LOC_LABEL check in the patch above.
>
> There is already implemented similar behavior for LOC_TYPEDEF, so no additional work here should be done.
> On the other hand there is no testcase for typedef symbol object .value() method call.
> Maybe you could provide me a help with writing such testcase as I do not quietly understand how typedef symbol object could be retrieved.
That's fine, if it is already implemented. I think the above should
be tested, but it represents a segue to your patch functionality, so
should not block it. I am fine with the patch in the second
revision. Please wait for a maintainer to give the go ahead.
Cheers,
Phil
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/3] Fixed abortion using Python API for label symbol object.
2014-03-04 10:36 [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
` (2 preceding siblings ...)
2014-03-04 10:37 ` [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method Maxim Bublis
@ 2014-03-25 16:51 ` Maxim Bublis
2014-03-25 19:51 ` Phil Muldoon
3 siblings, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-03-25 16:51 UTC (permalink / raw)
To: gdb-patches
Hi,
Is there any way to notify gdb.python maintainer to review this patch set?
—
Maxim Bublis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/3] Fixed abortion using Python API for label symbol object.
2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
@ 2014-03-25 19:51 ` Phil Muldoon
0 siblings, 0 replies; 18+ messages in thread
From: Phil Muldoon @ 2014-03-25 19:51 UTC (permalink / raw)
To: Maxim Bublis, gdb-patches
On 25/03/14 16:51, Maxim Bublis wrote:
> Hi,
>
> Is there any way to notify gdb.python maintainer to review this patch set?
>
>
There is no GDB Python maintainer, so it is a review for anyone to do,
and approval by a global maintainer. I usually review most Python
patches, but I have been exceptionally busy lately. I will look at
it really soon.
Cheers
Phil
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
2014-03-05 13:41 ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value " Maxim Bublis
@ 2014-04-14 7:41 ` Phil Muldoon
2014-04-16 17:20 ` Maxim Bublis
0 siblings, 1 reply; 18+ messages in thread
From: Phil Muldoon @ 2014-04-14 7:41 UTC (permalink / raw)
To: Maxim Bublis, gdb-patches
On 05/03/14 13:41, Maxim Bublis wrote:
> ---
> gdb/ChangeLog | 6 ++++++
> gdb/python/py-symbol.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 8108e50..19ec13c 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,9 @@
> +2014-03-05 Maxim Bublis <satori@yandex-team.ru>
> +
> + * gdb/python/py-symbol.c (sympy_value): Throw TypeError exception
> + instead of abort on calling value method for
> + symbol object with SYMBOL_LOC_LABEL address class.
> +
> 2014-03-05 Mike Frysinger <vapier@gentoo.org>
>
> * remote-sim.c (gdbsim_load): Add const to prog.
> diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
> index 6900d58..6303cea 100644
> --- a/gdb/python/py-symbol.c
> +++ b/gdb/python/py-symbol.c
> @@ -262,6 +262,12 @@ sympy_value (PyObject *self, PyObject *args)
> return NULL;
> }
>
> + if (SYMBOL_CLASS (symbol) == LOC_LABEL)
> + {
> + PyErr_SetString (PyExc_TypeError, "It is not possible to compute the value of a label.");
> + return NULL;
> + }
I am really curious about the sigabort you were seeing. Without it I
cannot tell if there is a deeper problem in GDB, which this patch
would be papering over. Can you provide the backtrace?
Cheers
Phil
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
2014-04-14 7:41 ` Phil Muldoon
@ 2014-04-16 17:20 ` Maxim Bublis
2014-04-17 12:44 ` Maxim Bublis
0 siblings, 1 reply; 18+ messages in thread
From: Maxim Bublis @ 2014-04-16 17:20 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
Hi, Phil.
> I am really curious about the sigabort you were seeing. Without it I
> cannot tell if there is a deeper problem in GDB, which this patch
> would be papering over. Can you provide the backtrace?
For example, we have the following code:
#include <stdlib.h>
int main() {
abort();
some_label:
return 0;
}
I’m inspecting coredump, generated by executable compiled from code above, using Python API in *batch* mode:
$ gdb/bin/gdb a.out a.out.19605.6 --batch --eval-command="python print list(gdb.selected_frame().older().older().block())[0].value(gdb.selected_frame().older().older())"
[New LWP 19605]
Core was generated by `./a.out'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f4a28ee7425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
findvar.c:248: internal-error: store_typed_address: type is not a pointer or reference
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
findvar.c:248: internal-error: store_typed_address: type is not a pointer or reference
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
Aborted (core dumped)
So, it doesn’t look like some deeper problem in GDB for me, just incompleteness of Python API.
There is very similar “if” condition for LOC_TYPEDEF in patched code.
Sure, here is backtrace from GDB coredump:
(gdb) bt
#0 0x00007fba00d56425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007fba00d59b8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x000000000066f476 in dump_core () at utils.c:612
#3 0x00000000006717e9 in internal_vproblem (problem=0xbb2890 <internal_error_problem>, file=<optimized out>, line=248, fmt=<optimized out>, ap=0x7fff15a33d18) at utils.c:781
#4 0x00000000006719e9 in internal_verror (file=<optimized out>, line=<optimized out>, fmt=<optimized out>, ap=<optimized out>) at utils.c:797
#5 0x0000000000671a92 in internal_error (file=<optimized out>, line=<optimized out>, string=<optimized out>) at utils.c:807
#6 0x000000000054521b in store_typed_address (buf=<optimized out>, type=<optimized out>, addr=<optimized out>) at findvar.c:248
#7 store_typed_address (buf=0x1b15ad0 "", type=0x1abf680, addr=0) at findvar.c:244
#8 0x0000000000546090 in default_read_var_value (var=<optimized out>, frame=<optimized out>) at findvar.c:466
#9 0x00000000004ff939 in sympy_value (self=0x1b52fb0, args=<optimized out>) at ./python/py-symbol.c:277
#10 0x00007fba013a65d5 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#11 0x00007fba013666b5 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#12 0x00007fba013669e2 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#13 0x00007fba01366a7c in PyRun_StringFlags () from /usr/lib/libpython2.7.so.1.0
#14 0x00007fba013676cb in PyRun_SimpleStringFlags () from /usr/lib/libpython2.7.so.1.0
#15 0x00000000004efefa in python_command (arg=<optimized out>, from_tty=<optimized out>) at ./python/python.c:477
#16 0x000000000066d58c in execute_command (p=<optimized out>, from_tty=0) at top.c:460
#17 0x00000000005a640f in catch_command_errors (command=0x66d330 <execute_command>,
arg=0x7fff15a3480a "python print list(gdb.selected_frame().older().older().block())[0].value(gdb.selected_frame().older().older())", from_tty=0, mask=<optimized out>) at exceptions.c:551
#18 0x00000000005a9292 in captured_main (data=<optimized out>) at main.c:1030
#19 0x00000000005a634b in catch_errors (func=0x5a8c80 <captured_main>, func_args=0x7fff15a34390, errstring=0x77f7f6 "", mask=RETURN_MASK_ALL) at exceptions.c:524
#20 0x00000000005a9bbb in gdb_main (args=<optimized out>) at main.c:1062
#21 0x000000000045cc25 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:33
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
2014-04-16 17:20 ` Maxim Bublis
@ 2014-04-17 12:44 ` Maxim Bublis
0 siblings, 0 replies; 18+ messages in thread
From: Maxim Bublis @ 2014-04-17 12:44 UTC (permalink / raw)
To: Phil Muldoon; +Cc: gdb-patches
Hi, Phil.
> So, it doesn’t look like some deeper problem in GDB for me, just incompleteness of Python API.
> There is very similar “if” condition for LOC_TYPEDEF in patched code.
I’ve inspected code some more. It seems to me there is a bug in gdb/findvar.c:466.
According to gdb/mdebugread.c:694, it is pretty clear that label symbol always has type of builtin integer:
SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_int;
but store_typed_address expects TYPE_CODE_PTR or TYPE_CODE_REF, so instead of
store_typed_address there should be something like store_unsigned_integer.
Am I correct with my guess?
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2014-04-17 12:44 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-04 10:36 [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
2014-03-04 10:37 ` [PATCH 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL. Added notion on possible exception thrown from symbol object .value() method Maxim Bublis
2014-03-04 16:53 ` Eli Zaretskii
2014-03-05 13:34 ` Maxim Bublis
2014-03-05 13:41 ` [PATCH v2 3/3] gdb/doc/python.texi: documented gdb.SYMBOL_LOC_LABEL, added notion on possible exceptions thrown from symbol object value method Maxim Bublis
2014-03-05 17:12 ` Eli Zaretskii
2014-03-04 10:37 ` [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
2014-03-04 17:57 ` Phil Muldoon
2014-03-05 13:39 ` Maxim Bublis
2014-03-06 8:37 ` Phil Muldoon
2014-03-05 13:41 ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value " Maxim Bublis
2014-04-14 7:41 ` Phil Muldoon
2014-04-16 17:20 ` Maxim Bublis
2014-04-17 12:44 ` Maxim Bublis
2014-03-04 10:37 ` [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method Maxim Bublis
2014-03-05 13:41 ` [PATCH v2 1/3] gdb/testsuite/gdb.python: Added testcase for value method Maxim Bublis
2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API for label symbol object Maxim Bublis
2014-03-25 19:51 ` Phil Muldoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).