This project aims to use proper types internally to represent bitpos and type.length for inferior types.
Currently, GDB uses 32-bit types (i.e., unsigned int) to store the length of an inferior data type. This puts a size limit to the inferior data type of 256MB (not 4GB as there is /2 for the sign bit and /8 as it is sometimes size in bits and not in bytes), which, despite seeming like a lot, can be problematic for certain users. We therefore should use at least a 64-bit type (initially ULONGEST, but more on that later) to represent these lengths.
One of the bugs that originated this whole project is PR 17520.
Throughout the years, several attempts have been made to improve this area. The first one is from Siddhesh Poyarekar, back in 2012. You can find it at:
https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html (Fortran bits)
Parts of Siddesh's patches have been merged upstream, but several areas in GDB still suffer from this problem.
David submitted and pushed a big patch to address PR 17520. You can find it at:
Even though Siddesh's Fortran patch had been approved, it got lost during the review process and was never pushed. So Keith fixed it and resubmitted:
As of this writing, the series has been approved but hasn't been pushed yet.
Idea for improvement
Sergio has been working on a new approach to solve this problem, based on Jan Kratochvil's suggestions. The idea is to encapsulate the new length type (likely ULONGEST for unsigned types and LONGEST for signed ones) inside a C++ class, which would have the benefit to catch implicit 64-to-32-bit conversions (narrowing) and error out at compile time, forcing the developer to either explicitly convert the types, either extending all the GDB types to 64-bit as needed or at least erroring out at run time.
A very early prototype of the work is available at the users/sergiodj/bitpos branch, at our official repository. It involves a massive rework of almost the whole GDB codebase, and does not currently compile, but it can serve as a starting point for others to tackle this problem.