Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Jie Zhang <jie.zhang@analog.com>, gdb-patches@sourceware.org
Subject: Re: PING: [PATCH] Fix a bug of addrmap
Date: Wed, 26 Nov 2008 06:34:00 -0000	[thread overview]
Message-ID: <20081125174613.GF3946@adacore.com> (raw)
In-Reply-To: <m3skpfu466.fsf@fleche.redhat.com>

> Jie> Could someone give a review on this patch:
> Jie> http://sourceware.org/ml/gdb-patches/2008-10/msg00503.html
> 
> I was curious about this patch so I took a look.

I took a quick look too, but not being familiar with this part
of the code, I had to postpone the review until I find enough
time to familiarize myself with the code.

Did you familiarize yourself with the code that you'd say that
the patch sounds good to you? If this is the case, I'm quite
happy to trust your judgement.

> Since addrmap is a relatively self-contained data structure, I figured
> it was a good candidate for a unit test.  So, I wrote a test case
> based on your original report.

Yay! :)

> 2008-11-25  Tom Tromey  <tromey@redhat.com>
> 
> 	* Makefile.in (test-addrmap.o): New target.
> 	(test-addrmap): Likewise.
> 	(clean mostlyclean): Remove test-addrmap.
> 	* addrmap.c (xfree): New function.
> 	(internal_error): Likewise.
> 	(test_inclusion): Likewise.
> 	(main): Likewise.

The one comment that I have about this is that it's not automatically
run when we run the testsuite. It would be really nice if they were.

It's not the first time that we have unit-testing like this.
For instance, check we have unit tests for observers, or xfullpath.
Traditionally, they have been implemented inside testsuite/gdb.gdb.
The current solution is not very elegant, in my opinion, as what we
did was debugging GDB and call some functions inside GDB.

How about, we add a testcase that "debugs" test-addrmap by simply
running it to completion and checking its output (including the
fact that it exited normally (meaning error code returned is zero)?

> +void
> +xfree (void *ptr)
> +{
> +  free (ptr);
> +}
> +
> +/* Likewise for internal_error.  */
> +NORETURN void
> +internal_error (const char *file, int line, const char *string, ...)
> +{
> +  /* The user will have to debug this anyway.  */
> +  exit (1);
> +}

I really like the idea of compiling this file as a standalone program,
and I hope that we'll be able to extend the use of this approach in
the future.  If we do, it might be worth putting these in a unit-testing
archive... (just thinking aloud, let's not act on it until it becomes
useful).

-- 
Joel


  reply	other threads:[~2008-11-25 17:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21  4:44 Jie Zhang
2008-11-03  6:09 ` PING: " Jie Zhang
2008-11-25 23:09   ` Tom Tromey
2008-11-26  6:34     ` Joel Brobecker [this message]
2008-11-26 13:53       ` Tom Tromey
2008-11-26 14:24       ` Daniel Jacobowitz
2008-11-26 15:05         ` Daniel Jacobowitz
2008-11-27 14:45       ` Tom Tromey
2008-12-08 23:12         ` Joel Brobecker

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=20081125174613.GF3946@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jie.zhang@analog.com \
    --cc=tromey@redhat.com \
    /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