Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Koning <paulkoning@comcast.net>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Phil Muldoon <pmuldoon@redhat.com>, gdb-patches@sourceware.org
Subject: Re: Python: fetch value when building gdb.Value object [rediff]
Date: Sat, 01 Oct 2011 18:58:00 -0000	[thread overview]
Message-ID: <786484A8-7FDA-449E-9D03-FACB65A02C7E@comcast.net> (raw)
In-Reply-To: <20111001121642.GA29550@host1.jankratochvil.net>


On Oct 1, 2011, at 8:16 AM, Jan Kratochvil wrote:

> Updated for current HEAD:
> 
> On Sat, 01 Oct 2011 11:28:52 +0200, Jan Kratochvil wrote:
> On Wed, 28 Sep 2011 21:24:45 +0200, Phil Muldoon wrote:
>> What scenario will this test catch that the previous test won't?  I'm
>> not saying you are incorrect, I just don't understand. What
>> error-trigger does the assignment to "inval" trigger?
> 
> I would prefer here a testcase more clearly showing the bug, attached below.

Thanks, yes I agree that's a clearer and more complete testcase.

	paul

> 
> I believe the patch is right, as Phil hasn't yet agreed posting it only.
> 
> 
> Thanks,
> Jan
> 
> 
> gdb/
> 2011-09-21  Paul Koning  <paul_koning@dell.com>
> 
> 	* python/py-value.c (valpy_get_address): Use Py_XINCREF.
> 	(value_to_value_object): Fetch value if it was lazy.
> 
> testsuite/
> 2011-09-21  Paul Koning  <paul_koning@dell.com>
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.python/py-value.exp
> 	(python inval = gdb.parse_and_eval('*(int*)0'))
> 	(python argc_lazy = gdb.parse_and_eval('argc'), sanity check argc)
> 	(set argc=2, python print argc_lazy): New tests.
> 
> --- a/gdb/python/py-value.c
> +++ b/gdb/python/py-value.c
> @@ -209,7 +209,7 @@ valpy_get_address (PyObject *self, void *closure)
> 	val_obj->address = value_to_value_object (res_val);
>     }
> 
> -  Py_INCREF (val_obj->address);
> +  Py_XINCREF (val_obj->address);
> 
>   return val_obj->address;
> }
> @@ -1045,7 +1045,15 @@ PyObject *
> value_to_value_object (struct value *val)
> {
>   value_object *val_obj;
> +  volatile struct gdb_exception except;
> 
> +  TRY_CATCH (except, RETURN_MASK_ALL)
> +    {
> +      if (value_lazy (val))
> +	value_fetch_lazy (val);
> +    }
> +  GDB_PY_HANDLE_EXCEPTION (except);
> +  
>   val_obj = PyObject_New (value_object, &value_object_type);
>   if (val_obj != NULL)
>     {
> --- a/gdb/testsuite/gdb.python/py-value.exp
> +++ b/gdb/testsuite/gdb.python/py-value.exp
> @@ -236,6 +236,18 @@ proc test_value_in_inferior {} {
>     gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test
>   }
> 
> +  # Test Python values are not lazy.
> +  set test "memory error occurs even for possibly lazy values"
> +  if {$can_read_0} {
> +    untested $test
> +  } else {
> +    gdb_test "python inval = gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test
> +  }
> +  gdb_test "python argc_lazy = gdb.parse_and_eval('argc')"
> +  gdb_test "print argc" " = 1" "sanity check argc"
> +  gdb_test_no_output "set argc=2"
> +  gdb_test "python print argc_lazy" "\r\n1"
> +
>   # Test string fetches,  both partial and whole.
>   gdb_test "print st" "\"divide et impera\""
>   gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value from history" 1


  reply	other threads:[~2011-10-01 18:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21 16:17 Python: fetch value when building gdb.Value object Paul Koning
2011-09-28 19:29 ` Phil Muldoon
2011-09-28 20:06   ` Paul Koning
2011-10-04 15:43     ` Tom Tromey
2011-09-28 20:42   ` Paul Koning
2011-10-01  9:05     ` Jan Kratochvil
2011-10-03 10:22       ` Phil Muldoon
2011-10-04 15:40       ` Tom Tromey
2011-10-01  9:29   ` Jan Kratochvil
2011-10-01 10:23     ` Pedro Alves
2011-10-01 11:03       ` Jan Kratochvil
2011-10-01 12:17     ` Python: fetch value when building gdb.Value object [rediff] Jan Kratochvil
2011-10-01 18:58       ` Paul Koning [this message]
2011-10-03 10:19       ` Phil Muldoon
2011-10-03 16:16         ` Paul Koning
2011-10-01  1:00 ` [PING] [RFA] Re: Python: fetch value when building gdb.Value object Paul Koning
2011-10-04 15:45 ` Tom Tromey
2011-10-04 15:51   ` Paul Koning
2011-10-14 20:03     ` Tom Tromey
2011-10-14 20:30       ` Paul Koning
2011-10-19 20:56         ` Tom Tromey
2011-10-19 20:58           ` Paul Koning
2011-10-20 15:09             ` Tom Tromey
2011-10-21  7:46               ` Paul Koning
2011-10-21 17:13                 ` Tom Tromey
2011-10-14 23:36   ` Jim Blandy

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=786484A8-7FDA-449E-9D03-FACB65A02C7E@comcast.net \
    --to=paulkoning@comcast.net \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=pmuldoon@redhat.com \
    /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