This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/22686] gdb.lookup_type fails for array types


https://sourceware.org/bugzilla/show_bug.cgi?id=22686

Simon Marchi <simon.marchi at ericsson dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon.marchi at ericsson dot com

--- Comment #1 from Simon Marchi <simon.marchi at ericsson dot com> ---
Hi Jonathan,

I think this is expected with the current code, as lookup_type looks up type by
name only.  In your case, you could do

  >>> print(gdb.lookup_type('int').array(0, 1))                                 
  int [2]
  >>> print(gdb.lookup_type('int').array(1))
  int [2]

In both cases, the 1 is the inclusive upper bound of the array.

It would be handy to be able to do lookup_type('int[2]') though.  And it might
allow things that can't be done today.  For example, I don't know how you would
make a function pointer type from scratch.  It would be nice if you could just
do lookup_type('int (*)(const char *)').

Well, as a workaround you could always do

  >>> print(gdb.parse_and_eval('(int (*)(const char *)) 0').type)
  int (*)(const char *)

and for the int[2] example:

  >>> print(gdb.parse_and_eval('{int[2]} 0').type)
  int [2]

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]