Bug 11797 - create a gdb.Type from a string "char[10]"
Summary: create a gdb.Type from a string "char[10]"
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 7.1
: P2 normal
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-08 16:51 UTC by Andre'
Modified: 2021-03-04 13:21 UTC (History)
4 users (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre' 2010-07-08 16:51:30 UTC
There seems no way to create a gdb.Type from a string "char[10]".

For non-arrays, gdb.lookup_type works:

   str(gdb.lookup_type('char')) == 'char'

but for arrays I get

   gdb.lookup_type('char[10]') 

   -> RuntimeError: No type named char[10].
Comment 1 Meador Inge 2012-01-05 19:07:20 UTC
Use the 'array' method on the constructed gdb.Type instance:

(gdb) py print(gdb.lookup_type('char').array(9))
char [10]
Comment 2 Tom Tromey 2012-01-05 20:41:04 UTC
(In reply to comment #1)
> Use the 'array' method on the constructed gdb.Type instance:
> 
> (gdb) py print(gdb.lookup_type('char').array(9))
> char [10]

Yeah -- but I think what this bug is really about is having
a method like "gdb.parse_type" that will parse a type according
to the language rules.
Comment 3 Andre' 2020-05-25 06:35:58 UTC
Tom is right. 

It would be nice to have a roundtrip gdb.Type -> str(...) -> gdb.Type giving the original type as close as possible.