[PATCH] gdb: change type of `general_symbol_info::m_section` to int

Tom Tromey tom@tromey.com
Fri Sep 13 02:10:20 GMT 2024


>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

>> FWIW, we could use typeof:
>> ...
>> -  void set_section_index (short idx)
>> +  void set_section_index (typeof (m_section) idx)

Simon> Or decltype, which would be more standard C++.

I think using "auto" just for the getter method is not really that
great.  My reason is that suppose we actually do need to change the
type: in this case, this one method will be ok, but essentially every
other user in the program will still need to be updated.

Better would be to introduce a new typedef and then use it consistently.
C++ doesn't really provide a whole lot of type safety this way -- like,
unless we use some kind of enum-based newtype, one could still just
write "short section = mumble" and it would compile.  Still, this would
be a little better; and in important cases we could use a newtype, since
after all we did this for DWARF section offsets, which we were
frequently confusing with other offsets.

Just my $.02 on this, I will forget about this "auto" relatively soon.

Speaking of the type laxity of C++, I found some spots still using
"short" here.  I will send a patch momentarily.

thanks,
Tom


More information about the Gdb-patches mailing list