This is the mail archive of the gdb@sources.redhat.com 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]

Re: INTEGER_TO_ADDRESS(), thoughts?



[I phoned Andrew about this; here's how I feel about things after the
conversation.]

I think INTEGER_TO_ADDRESS is a good idea as proposed --- but we must
admonish GDB hackers to make sure its behavior matches the compiler's,
whenever possible.

In general, I think GDB should evaluate expressions the same way the
compiler does.  When the user copies an expression out of their source
code and hands it to a `print' command, they should get the same value
the compiler would have computed.  Any deviation from this rule can
cause major confusion and annoyance, and needs to be justified
carefully.  In other words, GDB doesn't really have the freedom to do
these conversions in clever and useful ways.

You pointed out that users aren't complaining about how GDB casts
integers to pointers; they are complaining that they can't take an
address from a disassembly listing and give it to `x/i'.  This is
certainly important.

Adding an architecture method like INTEGER_TO_ADDRESS certainly makes
it possible for GDB to "get it right" in all circumstances --- the
target has complete control over how things get done, so people can Do
The Right Thing for their target without breaking anyone else.  The
standard doesn't specify how integers get converted to pointers;
usually, the ABI doesn't either, but ABI-specific code is a more
reasonable place to handle it.


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