Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [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 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method Maxim Bublis
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ 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] 16+ 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 ` [PATCH 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method 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
  2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API " Maxim Bublis
  3 siblings, 2 replies; 16+ 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] 16+ 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 ` Maxim Bublis
  2014-03-05 13:41   ` [PATCH v2 1/3] gdb/testsuite/gdb.python: Added testcase for value method 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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ 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] 16+ 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 1/3] gdb/testsuite/gdb.python: Added testcase for .value() method 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-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API " Maxim Bublis
  3 siblings, 1 reply; 16+ 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] 16+ 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; 16+ 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] 16+ 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
       [not found]     ` <07E7B14B-748D-4CF7-A8AD-623AF5D6E701@yandex-team.ru>
  0 siblings, 1 reply; 16+ 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] 16+ 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; 16+ messages in thread
From: Maxim Bublis @ 2014-03-05 13:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 7090 bytes --]

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.
From gdb-patches-return-110916-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed Mar 05 13:39:16 2014
Return-Path: <gdb-patches-return-110916-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 13944 invoked by alias); 5 Mar 2014 13:39:16 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 13928 invoked by uid 89); 5 Mar 2014 13:39:16 -0000
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.1 required=5.0 testsºYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2
X-HELO: forward-corp1f.mail.yandex.net
Received: from forward-corp1f.mail.yandex.net (HELO forward-corp1f.mail.yandex.net) (95.108.130.40) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 05 Mar 2014 13:39:15 +0000
Received: from smtpcorp4.mail.yandex.net (smtpcorp4.mail.yandex.net [95.108.252.2])	by forward-corp1f.mail.yandex.net (Yandex) with ESMTP id A9F3424200D6;	Wed,  5 Mar 2014 17:39:10 +0400 (MSK)
Received: from smtpcorp4.mail.yandex.net (localhost [127.0.0.1])	by smtpcorp4.mail.yandex.net (Yandex) with ESMTP id 85DE42C07C0;	Wed,  5 Mar 2014 17:39:10 +0400 (MSK)
Received: from unknown (unknown [2a02:6b8:0:408:f552:3e3:fe7a:878a])	by smtpcorp4.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fsFoPs5pkT-dAM4mJZT;	Wed,  5 Mar 2014 17:39:10 +0400	(using TLSv1 with cipher AES128-SHA (128/128 bits))	(Client certificate not present)
X-Yandex-Uniq: 3eb675e6-d571-4c96-ad3e-8b88b0d8f9bc
Authentication-Results: smtpcorp4.mail.yandex.net; dkim=pass header.i=@yandex-team.ru
Content-Type: text/plain; charset=iso-8859-1
Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\))
Subject: Re: [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
From: Maxim Bublis <satori@yandex-team.ru>
In-Reply-To: <53161401.5080408@redhat.com>
Date: Wed, 05 Mar 2014 13:39:00 -0000
Cc: gdb-patches@sourceware.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <07E7B14B-748D-4CF7-A8AD-623AF5D6E701@yandex-team.ru>
References: <1393929360-31299-1-git-send-email-satori@yandex-team.ru> <1393929360-31299-3-git-send-email-satori@yandex-team.ru> <53161401.5080408@redhat.com>
To: Phil Muldoon <pmuldoon@redhat.com>
X-SW-Source: 2014-03/txt/msg00114.txt.bz2
Content-length: 732


> 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.
From gdb-patches-return-110918-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed Mar 05 13:41:39 2014
Return-Path: <gdb-patches-return-110918-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 15907 invoked by alias); 5 Mar 2014 13:41:38 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 15755 invoked by uid 89); 5 Mar 2014 13:41:37 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RP_MATCHES_RCVD autolearn=no version=3.3.2
X-HELO: satori.sandbox-dev.search.yandex.net
Received: from satori.sandbox-dev.search.yandex.net (HELO satori.sandbox-dev.search.yandex.net) (5.255.204.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Mar 2014 13:41:36 +0000
Received: by satori.sandbox-dev.search.yandex.net (Postfix, from userid 30101)	id F17C8F40C3D; Wed,  5 Mar 2014 17:41:32 +0400 (MSK)
From: Maxim Bublis <satori@yandex-team.ru>
To: gdb-patches@sourceware.org
Cc: Maxim Bublis <satori@yandex-team.ru>
Subject: [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
Date: Wed, 05 Mar 2014 13:41:00 -0000
Message-Id: <1394026864-4691-2-git-send-email-satori@yandex-team.ru>
In-Reply-To: <1394026864-4691-1-git-send-email-satori@yandex-team.ru>
References: <1394026864-4691-1-git-send-email-satori@yandex-team.ru>
In-Reply-To: <1393929360-31299-3-git-send-email-satori@yandex-team.ru>
X-SW-Source: 2014-03/txt/msg00116.txt.bz2
Content-length: 1079

---
 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] 16+ 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
       [not found]     ` <1394026864-4691-2-git-send-email-satori@yandex-team.ru>
  0 siblings, 1 reply; 16+ 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] 16+ 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; 16+ 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] 16+ 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; 16+ 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] 16+ messages in thread

* Re: [PATCH 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object
       [not found]     ` <07E7B14B-748D-4CF7-A8AD-623AF5D6E701@yandex-team.ru>
@ 2014-03-06  8:37       ` Phil Muldoon
  0 siblings, 0 replies; 16+ 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] 16+ 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 2/3] gdb/python: raise TypeError instead of abort() on calling .value() method for label symbol object Maxim Bublis
@ 2014-03-25 16:51 ` Maxim Bublis
  2014-03-25 19:51   ` Phil Muldoon
  3 siblings, 1 reply; 16+ 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
From gdb-patches-return-111400-listarch-gdb-patches=sources.redhat.com@sourceware.org Tue Mar 25 17:51:00 2014
Return-Path: <gdb-patches-return-111400-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 28994 invoked by alias); 25 Mar 2014 17:50:59 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 28984 invoked by uid 89); 25 Mar 2014 17:50:58 -0000
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2
X-HELO: rock.gnat.com
Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 25 Mar 2014 17:50:57 +0000
Received: from localhost (localhost.localdomain [127.0.0.1])	by filtered-rock.gnat.com (Postfix) with ESMTP id E1F331167C2;	Tue, 25 Mar 2014 13:50:55 -0400 (EDT)
Received: from rock.gnat.com ([127.0.0.1])	by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024)	with LMTP id 3099Cvgm6ZRa; Tue, 25 Mar 2014 13:50:55 -0400 (EDT)
Received: from joel.gnat.com (localhost.localdomain [127.0.0.1])	by rock.gnat.com (Postfix) with ESMTP id B8E2C11669A;	Tue, 25 Mar 2014 13:50:55 -0400 (EDT)
Received: by joel.gnat.com (Postfix, from userid 1000)	id 98D98E07DC; Tue, 25 Mar 2014 10:50:56 -0700 (PDT)
Date: Tue, 25 Mar 2014 17:50:00 -0000
From: Joel Brobecker <brobecker@adacore.com>
To: Keith Seitz <keiths@redhat.com>
Cc: "gp >> \"gdb-patches@sourceware.org ml\"" <gdb-patches@sourceware.org>
Subject: Re: [RFA] Fix c++/16253 (tag/variable name collision)
Message-ID: <20140325175056.GO4282@adacore.com>
References: <532C810F.7010809@redhat.com> <20140324141527.GM4282@adacore.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20140324141527.GM4282@adacore.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-SW-Source: 2014-03/txt/msg00598.txt.bz2
Content-length: 2029

Hey Keith,

> > I must also give a shout out to Joel -- I've largely avoided hacking
> > with/at Ada. In fact, Ada *largely* remains unchanged. However, it
> > now must explicitly search STRUCT_DOMAIN in a few places itself (an
> > analogous change to the other symbol table API changes I've made).
> > Joel, if you could run this through your internal AdaCore test
> > harness, that would be most helpful.
>
> I had a chance to test your patch today, and unfortunately our testsuite
> detected some regressions. I think they might all be the same, so I
> picked the simplest testcase. I might be running short of time today
> to look deeper into this, but I can try scheduling some time for it
> tomorrow or Wed.
>
>     % gnatmake -g foo
>     % gdb foo
>     (gdb) ptype base

Insert missing "No definition of "base" in current context." as the
output of the "ptype base" command above...

I had a chance to investigate the source of the problem, and I think
I understand it, now. Basically, I think you fixed up the Ada symbol
lookups for local symbols, but did not adjust the non-local lookups.

In our case, our type "base" is defined in unit foo.adb as a static
(non-global) STRUCT_DOMAIN symbol. The symbol lookup is performed
via ada-lang.c::add_nonlocal_symbols which calls
objfile->sf->qf->map_matching_symbols (=map_matching_symbols_psymtab).
And the match now fails since it performs strict domain matching.

I think you actually ended up noticing the problem, since you had to
change ada-tasks to do a STRUCT_DOMAIN search instead of a VAR_DOMAIN
search. I think the ada-tasks change is correct regardless, since
these are all structure types anyways (need to double-check, but
pretty sure), but that was also a clue.

Now, the question becomes: Does Ada need to add some logic to call
objfile->sf->qf->map_matching_symbols a second time with STRUCT_DOMAIN,
or should objfile->sf->qf->map_matching_symbols do it? From the looks
of your patch, it looks like this should be done on the Ada side?

Thanks!
--
Joel


^ permalink raw reply	[flat|nested] 16+ 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 " Maxim Bublis
@ 2014-03-25 19:51   ` Phil Muldoon
  0 siblings, 0 replies; 16+ 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] 16+ messages in thread

* Re: [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object
       [not found]     ` <1394026864-4691-2-git-send-email-satori@yandex-team.ru>
@ 2014-04-14  7:41       ` Phil Muldoon
  2014-04-16 17:20         ` Maxim Bublis
  0 siblings, 1 reply; 16+ 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] 16+ 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       ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object Phil Muldoon
@ 2014-04-16 17:20         ` Maxim Bublis
  2014-04-17 12:44           ` Maxim Bublis
  0 siblings, 1 reply; 16+ 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
From gdb-patches-return-111832-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed Apr 16 17:21:53 2014
Return-Path: <gdb-patches-return-111832-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 30538 invoked by alias); 16 Apr 2014 17:21:53 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 30526 invoked by uid 89); 16 Apr 2014 17:21:53 -0000
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mga01.intel.com
Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Apr 2014 17:21:52 +0000
Received: from fmsmga002.fm.intel.com ([10.253.24.26])  by fmsmga101.fm.intel.com with ESMTP; 16 Apr 2014 10:21:06 -0700
X-ExtLoop1: 1
Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157])  by fmsmga002.fm.intel.com with ESMTP; 16 Apr 2014 10:21:02 -0700
Received: from irsmsx106.ger.corp.intel.com ([169.254.8.58]) by IRSMSX103.ger.corp.intel.com ([163.33.3.157]) with mapi id 14.03.0123.003; Wed, 16 Apr 2014 18:18:31 +0100
From: "Blanc, Nicolas" <nicolas.blanc@intel.com>
To: Pedro Alves <palves@redhat.com>
CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH] Stale breakpoint instructions, spurious SIGTRAPS.
Date: Wed, 16 Apr 2014 17:21:00 -0000
Message-ID: <388084C8C1E6A64FA36AD1D656E4856635AE8EB5@IRSMSX106.ger.corp.intel.com>
References: <1397585886-29261-1-git-send-email-palves@redhat.com>
In-Reply-To: <1397585886-29261-1-git-send-email-palves@redhat.com>
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
X-SW-Source: 2014-04/txt/msg00322.txt.bz2
Content-length: 2256

Hi Pedro,

> Then, the reason that disable_breakpoints_in_freed_objfile was clearing the inserted flag isn't clear, but likely to avoid breakpoint removal errors, assuming remove-symbol-file was called after the dynamic object was already unmapped from the inferior. 

Indeed that was the intend. The clearing of the flag copied from disable_breakpoints_in_unloaded_shlib.

> Comments?

The suggestion makes sense to me.
Thanks for looking into this.

>       if (val)
> @@ -7666,7 +7693,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
> ?   /* If the file is a shared library not loaded by the user then
>      solib_unloaded was notified and disable_breakpoints_in_unloaded_shlib
>       was called.  In that case there is no need to take action again.  */
> -  if ((objfile->flags & OBJF_SHARED) && !(objfile->flags & OBJF_USERLOADED))
> +  if ((objfile->flags & OBJF_USERLOADED) == 0)
>      return;

The comment above should be updated. The condition is  now weaker. 


   ALL_BREAKPOINTS (b)
@@ -7698,7 +7725,11 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
> 	  if (is_addr_in_objfile (loc_addr, objfile))
> 	    {
> 	      loc->shlib_disabled = 1;
> -	      loc->inserted = 0;
> +	      /* At this point, we don't know whether the object was
> +		 unmapped from the inferior or not, so leave the
> +		 inserted flag alone.  We'll handle failure to
> +		 uninsert quietly, in case the object was indeed
> +		 unmapped.  */

Would it work to simplify disable_breakpoints_in_unloaded_shlib in the same way?
Note that I understand it might be unnecessary risky to fix a function that is not broken.

> +  /* Make sure we see the memory breakpoints.  */  cleanup = 
> + make_show_memory_breakpoints_cleanup (1);  val = target_read_memory 
> + (addr, old_contents, bplen);

It was not immediately clear to me that old_contents means current content.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


^ permalink raw reply	[flat|nested] 16+ 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; 16+ 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?
From gdb-patches-return-111876-listarch-gdb-patches=sources.redhat.com@sourceware.org Thu Apr 17 13:35:32 2014
Return-Path: <gdb-patches-return-111876-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 4119 invoked by alias); 17 Apr 2014 13:35:32 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 4106 invoked by uid 89); 17 Apr 2014 13:35:31 -0000
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2
X-HELO: rock.gnat.com
Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 17 Apr 2014 13:35:29 +0000
Received: from localhost (localhost.localdomain [127.0.0.1])	by filtered-rock.gnat.com (Postfix) with ESMTP id 2937A1160B7;	Thu, 17 Apr 2014 09:35:27 -0400 (EDT)
Received: from rock.gnat.com ([127.0.0.1])	by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024)	with LMTP id guNeo-WFyJZ2; Thu, 17 Apr 2014 09:35:27 -0400 (EDT)
Received: from joel.gnat.com (localhost.localdomain [127.0.0.1])	by rock.gnat.com (Postfix) with ESMTP id 0056A1160AD;	Thu, 17 Apr 2014 09:35:26 -0400 (EDT)
Received: by joel.gnat.com (Postfix, from userid 1000)	id 3BDD1E041B; Thu, 17 Apr 2014 06:35:34 -0700 (PDT)
Date: Thu, 17 Apr 2014 13:35:00 -0000
From: Joel Brobecker <brobecker@adacore.com>
To: Marcus Shawcroft <marcus.shawcroft@arm.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Drop srcdir from untested source path.
Message-ID: <20140417133534.GX4250@adacore.com>
References: <534FA596.6040502@arm.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <534FA596.6040502@arm.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-SW-Source: 2014-04/txt/msg00366.txt.bz2
Content-length: 1320

> 2014-04-17  Marcus Shawcroft  <marcus.shawcroft@arm.com>
>
> 	* gdb.java/jnpe.exp: Drop srcdir from untested path.

LGTM!

> commit 0e3c473a07b06ebd742478b7a602fcb9ebfc7388
> Author: Marcus Shawcroft <marcus.shawcroft@arm.com>
> Date:   Mon Mar 31 14:25:36 2014 +0100
>
>     [PATCH] Drop srcdir from untested source path.
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index c230f8c..e9e8249 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,5 +1,9 @@
>  2014-03-31  Marcus Shawcroft  <marcus.shawcroft@arm.com>
>
> +	* gdb.java/jnpe.exp: Drop srcdir from untested path.
> +
> +2014-03-31  Marcus Shawcroft  <marcus.shawcroft@arm.com>
> +
>  	* lib/gdb.exp (gdb_compile_pthreads, gdb_compile_objc): Drop prefix
>  	from unsupported source file path.
>
> diff --git a/gdb/testsuite/gdb.java/jnpe.exp b/gdb/testsuite/gdb.java/jnpe.exp
> index 054ade8..bd47f109c 100644
> --- a/gdb/testsuite/gdb.java/jnpe.exp
> +++ b/gdb/testsuite/gdb.java/jnpe.exp
> @@ -17,7 +17,7 @@ load_lib "java.exp"
>
>  standard_testfile .java
>  if  { [compile_java_from_source $srcdir/$subdir/$srcfile $binfile "-g"] != "" } {
> -    untested "Couldn't compile ${srcdir}/$subdir/${srcfile}"
> +    untested "Couldn't compile $subdir/${srcfile}"
>      return -1
>  }
>


--
Joel


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-04-17 12:44 UTC | newest]

Thread overview: 16+ 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 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
     [not found]     ` <1394026864-4691-2-git-send-email-satori@yandex-team.ru>
2014-04-14  7:41       ` [PATCH v2 2/3] gdb/python: raise TypeError instead of abort on calling value method for label symbol object Phil Muldoon
2014-04-16 17:20         ` Maxim Bublis
2014-04-17 12:44           ` 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
     [not found]     ` <07E7B14B-748D-4CF7-A8AD-623AF5D6E701@yandex-team.ru>
2014-03-06  8:37       ` Phil Muldoon
2014-03-25 16:51 ` [PATCH 0/3] Fixed abortion using Python API " 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