This is the mail archive of the gdb-patches@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]

Re: PATCH: Problem union comparision in TUI


Eli Zaretskii wrote:
IMHO, a better way of fixing this would be to change
tui_line_or_address to be a struct as follows:

  /* Structure describing source line or line address */
  struct tui_line_or_address
  {
     unsigned char what
     union {
             int line_no;
	     CORE_ADDR addr;
	   } u;
  };

and then fill the `what' member as appropriate and use the right part
of the union in the comparison.


Yes, that might be true, but that would be a much larger change and I would be much less confident of having done it right, plus it will add some complexity.


A quick grep says there are 51 references to 'line_or_addr', but there are about 15 places other names are declared for this thing so all the uses might take a little more tracking down. I suppose changing the name of the members and seeing what breaks will be the best way.

Is there any reason for using a union here? It's not like one value is float and the other int - both are ints and the fact that you can't tell which you are using shows nobody actually uses the distinction (unless I have missed something). The union doesn't save any space, nor does it make the code any more efficient.

We could just use:

CORE_ADDR line_or_address;

and leave it at that.

Anyway, I am happy to modify the patch to whatever is suggested.

Thanks

Andrew Stubbs


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