Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb@sourceware.org
Subject: Re: CORE_ADDR representation
Date: Fri, 19 Feb 2010 19:27:00 -0000	[thread overview]
Message-ID: <m3vddt81s4.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20100218134345.GB17163@caradoc.them.org> (Daniel Jacobowitz's 	message of "Thu, 18 Feb 2010 08:43:45 -0500")

>>>>> "Daniel" == Daniel Jacobowitz <dan@codesourcery.com> writes:

Mark> Perhaps we should introduce a function to "normalize" addresses (mask
Mark> off high-bits or sign extend) that we call in places that need it?
Mark> It'd be a no-op for a N-bit debugger debugging an N-bit target, so
Mark> you'd be able to call it unconditionally.  That should clear away
Mark> quite a bit of clutter.

Daniel> That does sound better than the status quo.  I worry that we'll have
Daniel> otherwise the same trouble with figuring out places that 'need' it...

Daniel> Hmm.  I wonder if we could use a static analysis tool for this.  It
Daniel> sounds like a classic example of a static problem.

The appended finds all uses of "+" on a CORE_ADDR.  Well... it finds
"all" uses modulo whatever little issues coccinelle has, I didn't mess
around trying to make it look into macros.

I ran it like:

  cd src/gdb
  spatch -sp_file coreaddr.cocci -dir .

... and got 1071 hits.

On Fedora you can get the tool with "yum install coccinelle", I assume
other distros are similar.  Also it is here:

    http://coccinelle.lip6.fr/

I'm not sure if this was what you're really looking for, but it isn't
too hard to modify this script to look for other things.

The problem with doing static analysis is that you have to redo it
pretty frequently.  While moving to a struct CORE_ADDR would result in
more verbose code (which is definitely bad, don't get me wrong), it does
have the benefit that an attempt to do arithmetic on it results in a
compiler error.  This in turns means it is simpler to review the
resulting patches.

Tom

@ coreaddr
@
CORE_ADDR x;
expression y;
position p_1;
@@
x @p_1 + y
@
script:python @ loc_1 << coreaddr.p_1;
	@@
print "%s:%s:%s: CORE_ADDR + operation" % (loc_1[0].file, loc_1[0].line, loc_1[0].column)


  reply	other threads:[~2010-02-19 19:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18  4:44 Daniel Jacobowitz
2010-02-18  5:42 ` Stan Shebs
2010-02-18 14:11   ` Daniel Jacobowitz
2010-02-18 23:04     ` Tom Tromey
2010-02-18 10:18 ` Mark Kettenis
2010-02-18 13:43   ` Daniel Jacobowitz
2010-02-19 19:27     ` Tom Tromey [this message]
2010-02-18 10:34 ` Jan Kratochvil
2010-02-18 13:41   ` Daniel Jacobowitz
2010-02-18 13:53     ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3vddt81s4.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox