public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/11915] New: API for casting pointer to array[length]
@ 2010-08-13 23:02 joachim dot protze at zih dot tu-dresden dot de
  2010-08-19 20:59 ` [Bug python/11915] " tromey at redhat dot com
  2010-08-23 20:32 ` tromey at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: joachim dot protze at zih dot tu-dresden dot de @ 2010-08-13 23:02 UTC (permalink / raw)
  To: gdb-prs

It would be nice, to have a python api mechanism to print a pointer as array of
specific length.

(gdb) python print gdb.parse_and_eval("(int[3]*)buf").type                     
                                                                               
      
int (*)[3]

(gdb) python print gdb.parse_and_eval("(int[3]*)buf").dereference()            
                                                                               
               
{0, 1, 2}

It is possible to cast the pointer to array with the python cast function:
(gdb) python print gdb.parse_and_eval("buf").cast(gdb.parse_and_eval("(int[3]*)
buf").type).type
int (*)[3]

The pointer is successfully printed as array[length]:
(gdb) python print gdb.parse_and_eval("buf").cast(gdb.parse_and_eval("(int[3]*)
buf").type).dereference()
{0, 1, 2}

But there is no way to create the array type with python like:
gdb.lookup_type("int").array(3).pointer()
or:
gdb.lookup_type("int[3]").pointer()

-- 
           Summary: API for casting pointer to array[length]
           Product: gdb
           Version: 7.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: joachim dot protze at zih dot tu-dresden dot de
                CC: gdb-prs at sourceware dot org


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/11915] API for casting pointer to array[length]
  2010-08-13 23:02 [Bug python/11915] New: API for casting pointer to array[length] joachim dot protze at zih dot tu-dresden dot de
@ 2010-08-19 20:59 ` tromey at redhat dot com
  2010-08-23 20:32 ` tromey at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at redhat dot com @ 2010-08-19 20:59 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-08-19 20:59 -------
Testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|tromey at redhat dot com
                   |org                         |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-19 20:59:24
               date|                            |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug python/11915] API for casting pointer to array[length]
  2010-08-13 23:02 [Bug python/11915] New: API for casting pointer to array[length] joachim dot protze at zih dot tu-dresden dot de
  2010-08-19 20:59 ` [Bug python/11915] " tromey at redhat dot com
@ 2010-08-23 20:32 ` tromey at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at redhat dot com @ 2010-08-23 20:32 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2010-08-23 20:22 -------
Subject: Bug 11915

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-08-23 20:21:30

Modified files:
	gdb            : ChangeLog 
	gdb/doc        : ChangeLog gdb.texinfo 
	gdb/python     : py-type.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.python: py-type.exp 

Log message:
	gdb
	PR python/11915:
	* python/py-type.c (typy_array): New function.
	(type_object_methods): Add "array".
	gdb/doc
	PR python/11915:
	* gdb.texinfo (Types In Python): Document array method.
	gdb/testsuite
	PR python/11915:
	* gdb.python/py-type.exp (test_fields): Add tests for array.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12105&r2=1.12106
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1102&r2=1.1103
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.756&r2=1.757
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2425&r2=1.2426
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-type.exp.diff?cvsroot=src&r1=1.7&r2=1.8


------- Additional Comments From tromey at redhat dot com  2010-08-23 20:32 -------
I checked in the fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|7.1                         |7.3


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2010-08-23 20:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-13 23:02 [Bug python/11915] New: API for casting pointer to array[length] joachim dot protze at zih dot tu-dresden dot de
2010-08-19 20:59 ` [Bug python/11915] " tromey at redhat dot com
2010-08-23 20:32 ` tromey 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).