From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1937 invoked by alias); 19 Oct 2005 20:22:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1918 invoked by uid 22791); 19 Oct 2005 20:22:01 -0000 Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 19 Oct 2005 20:22:01 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id j9JKLMM6020329; Wed, 19 Oct 2005 22:21:22 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.4/8.13.3) with ESMTP id j9JKLMiv020105; Wed, 19 Oct 2005 22:21:22 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.4/8.13.4/Submit) id j9JKLM82007105; Wed, 19 Oct 2005 22:21:22 +0200 (CEST) Date: Wed, 19 Oct 2005 20:22:00 -0000 Message-Id: <200510192021.j9JKLM82007105@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: drow@false.org CC: eliz@gnu.org, andrew.stubbs@st.com, gdb-patches@sources.redhat.com In-reply-to: <20051019200751.GA19037@nevyn.them.org> (message from Daniel Jacobowitz on Wed, 19 Oct 2005 16:07:51 -0400) Subject: Re: PATCH: Problem union comparision in TUI References: <4353BA69.1030401@st.com> <43561685.3010300@st.com> <20051019200751.GA19037@nevyn.them.org> X-SW-Source: 2005-10/txt/msg00164.txt.bz2 > Date: Wed, 19 Oct 2005 16:07:51 -0400 > From: Daniel Jacobowitz > > 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 > > > 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