public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/13339] New: type.array(X) creates array of X+1 items
@ 2011-10-24 21:58 jan.kratochvil at redhat dot com
  2011-10-27 10:58 ` [Bug python/13339] " pmuldoon at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-10-24 21:58 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

             Bug #: 13339
           Summary: type.array(X) creates array of X+1 items
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jan.kratochvil@redhat.com
                CC: pmuldoon@redhat.com
    Classification: Unclassified
            Target: x86_64-unknown-linux-gnu


GNU gdb (GDB) 7.3.50.20111023-cvs
./gdb -nx ./gdb
(gdb) python print gdb.lookup_type("struct symtab").array(2)
struct symtab [3]

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
@ 2011-10-27 10:58 ` pmuldoon at redhat dot com
  2011-10-27 12:04 ` pmuldoon at redhat dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pmuldoon at redhat dot com @ 2011-10-27 10:58 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #1 from Phil Muldoon <pmuldoon at redhat dot com> 2011-10-27 10:58:02 UTC ---
This is a confusion in the API between size, and the range passed to GDB:


(gdb) n
381          n2 = n1;
(gdb) n
382          n1 = 0;
(gdb) p n2
$3 = 2
(gdb) n
385      if (n2 < n1)
(gdb) n
392      TRY_CATCH (except, RETURN_MASK_ALL)
(gdb) 
394          array = lookup_array_range_type (type, n1, n2);

So the user wants an array of size "2"

But lookup_array_range_type wants a "low bound" and a "high bound", so in this
case 0..2, which results in an array size of 3.

My solution is to reduce the size argument provided by Python minus one.  What
do you think?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
  2011-10-27 10:58 ` [Bug python/13339] " pmuldoon at redhat dot com
@ 2011-10-27 12:04 ` pmuldoon at redhat dot com
  2011-10-27 12:38 ` jan.kratochvil at redhat dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pmuldoon at redhat dot com @ 2011-10-27 12:04 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

Phil Muldoon <pmuldoon at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware    |pmuldoon at redhat dot com
                   |dot org                     |

--- Comment #2 from Phil Muldoon <pmuldoon at redhat dot com> 2011-10-27 12:03:57 UTC ---
On further investigation, it seems to be working as described:

>From the GDB manual:

Return a new gdb.Type object which represents an array of this
type.  If one argument is given, it is the inclusive upper bound of
the array; in this case the lower bound is zero.  If two arguments are
given, the first argument is the lower bound of the array, and the
second argument is the upper bound of the array.  An array's length
must not be negative, but the bounds can be.

So array(2) == array(0,2) which will have a length of 3.

If you agree with this, can you close the bug?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
  2011-10-27 10:58 ` [Bug python/13339] " pmuldoon at redhat dot com
  2011-10-27 12:04 ` pmuldoon at redhat dot com
@ 2011-10-27 12:38 ` jan.kratochvil at redhat dot com
  2011-10-27 12:52 ` pmuldoon at redhat dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-10-27 12:38 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #3 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-10-27 12:37:39 UTC ---
independent response that time on IRC:

(2011-10-24 23:58:21 CEST) heinz: hm, 7.3.50.20111006-cvs yields (gdb) python
print gdb.lookup_type("struct S").array(4)  -> S [5]

I really think a single number should mean length.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2011-10-27 12:38 ` jan.kratochvil at redhat dot com
@ 2011-10-27 12:52 ` pmuldoon at redhat dot com
  2011-10-27 13:46 ` jan.kratochvil at redhat dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pmuldoon at redhat dot com @ 2011-10-27 12:52 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #4 from Phil Muldoon <pmuldoon at redhat dot com> 2011-10-27 12:51:40 UTC ---
I've really no problem with a single argument being "length", in fact it makes
sense.  But this would break an established and documented API.  If a
maintainer waives that, that is fine, I will change it.  There is an argument
to be made that this was a bug, and we fixed it (and this would be ok under our
API promise), but we already documented the fact that the lower-bound would be
assumed to be zero in the case of single-argument specifications.  We could add
a "length=" keyword which the user could pass in-place of arguments - that
would account for the specification being a length, not a range.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (3 preceding siblings ...)
  2011-10-27 12:52 ` pmuldoon at redhat dot com
@ 2011-10-27 13:46 ` jan.kratochvil at redhat dot com
  2011-11-02 16:27 ` tromey at redhat dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-10-27 13:46 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #5 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-10-27 13:45:20 UTC ---
I do not think API is stables unless there is a FSF GDB release with it.
I understand I could catch in the patch, I did not.
I do not mind, it was FYI, leaving it to be decided by Tom, you and others.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (4 preceding siblings ...)
  2011-10-27 13:46 ` jan.kratochvil at redhat dot com
@ 2011-11-02 16:27 ` tromey at redhat dot com
  2011-11-02 16:30 ` jan.kratochvil at redhat dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at redhat dot com @ 2011-11-02 16:27 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #6 from Tom Tromey <tromey at redhat dot com> 2011-11-02 16:26:09 UTC ---
Phil asked me to reply on this.
I don't have a particular feeling about it.
I'd support a length= argument for sure.
One idea would be to add a length= keyword argument,
and then make the other form require both arguments.
That way, array(5) would be an error.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (5 preceding siblings ...)
  2011-11-02 16:27 ` tromey at redhat dot com
@ 2011-11-02 16:30 ` jan.kratochvil at redhat dot com
  2011-12-02  0:33 ` dje at google dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-11-02 16:30 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #7 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-11-02 16:29:52 UTC ---
(In reply to comment #6)
> That way, array(5) would be an error.

I do not see much why it cannot create an array of 5 items but in general fine
with me, if it matters.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (6 preceding siblings ...)
  2011-11-02 16:30 ` jan.kratochvil at redhat dot com
@ 2011-12-02  0:33 ` dje at google dot com
  2011-12-02 18:51 ` tromey at redhat dot com
  2012-01-09  9:37 ` jan.kratochvil at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: dje at google dot com @ 2011-12-02  0:33 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

dje at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at google dot com

--- Comment #8 from dje at google dot com 2011-12-02 00:33:15 UTC ---
I committed this patch to fix the doc string to match the current behaviour.

http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13565&r2=1.13566
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.31&r2=1.32

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (7 preceding siblings ...)
  2011-12-02  0:33 ` dje at google dot com
@ 2011-12-02 18:51 ` tromey at redhat dot com
  2012-01-09  9:37 ` jan.kratochvil at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at redhat dot com @ 2011-12-02 18:51 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

--- Comment #9 from Tom Tromey <tromey at redhat dot com> 2011-12-02 18:50:40 UTC ---
Doug -- thanks for the patch.

Jan -- this API shipped in 7.3, so I think we can't change it incompatibly now.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/13339] type.array(X) creates array of X+1 items
  2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
                   ` (8 preceding siblings ...)
  2011-12-02 18:51 ` tromey at redhat dot com
@ 2012-01-09  9:37 ` jan.kratochvil at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2012-01-09  9:37 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13339

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #10 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2012-01-09 09:36:52 UTC ---
According to the Commment 9.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2012-01-09  9:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-24 21:58 [Bug python/13339] New: type.array(X) creates array of X+1 items jan.kratochvil at redhat dot com
2011-10-27 10:58 ` [Bug python/13339] " pmuldoon at redhat dot com
2011-10-27 12:04 ` pmuldoon at redhat dot com
2011-10-27 12:38 ` jan.kratochvil at redhat dot com
2011-10-27 12:52 ` pmuldoon at redhat dot com
2011-10-27 13:46 ` jan.kratochvil at redhat dot com
2011-11-02 16:27 ` tromey at redhat dot com
2011-11-02 16:30 ` jan.kratochvil at redhat dot com
2011-12-02  0:33 ` dje at google dot com
2011-12-02 18:51 ` tromey at redhat dot com
2012-01-09  9:37 ` jan.kratochvil at redhat dot com

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).