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


> Date: Wed, 19 Oct 2005 16:07:51 -0400
> From: Daniel Jacobowitz <drow@false.org>
> 
> On Wed, Oct 19, 2005 at 10:03:14PM +0200, Eli Zaretskii wrote:
> > > Date: Wed, 19 Oct 2005 10:48:53 +0100
> > > From: Andrew STUBBS <andrew.stubbs@st.com>
> > > Cc: gdb-patches@sources.redhat.com
> > > 
> > > Is there any reason for using a union here?
> > 
> > The reason is that the code should be clean and self-explanatory.
> > Using the same variable for storing two utterly different objects is
> > IMHO The Mother Of Unclean Code.
> 
> Is an untagged union any clearer?
> 
> We've already established (via the bug report) that some of the time,
> the code has no idea which one is in use when comparing them.  They're
> used for relative line ordering within a particular window; if it's a
> source window, the lines are sorted by line number, and if it's a
> disassembly window, they're sorted by code address.  So in both cases
> it's a "line number"; that's why I favor using a single variable for
> them, although I'm open to alternative suggestions.

But encoding line numbers in CORE_ADDR is probably a bad idea.  In
many parts of GDB the signedness of the integer type matters.  I've
found this out the hard way, when trying to fix some of the warnings
generated by GCC 4.  I think there is no other option than going over
the code, analyzing what it does and analyzing it accordingly.

Mark


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