Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: "'Joel Brobecker'" <brobecker@adacore.com>,
		"'Doug Evans'" <dje@google.com>
Cc: "'GDB Patches'" <gdb-patches@sourceware.org>
Subject: RE: [BUG] BINOP_DIV and ptyp command
Date: Tue, 29 Jan 2008 07:51:00 -0000	[thread overview]
Message-ID: <000e01c86249$89870100$9c950300$@u-strasbg.fr> (raw)
In-Reply-To: <20080129064148.GB16288@adacore.com>

  The code might be useful, but it returns wrong results...
Because if you go the the value_binop
code, you will see that there are some typecast
that do change the result type of BINOP_DIV.
  The problem with Doug's code is that
the error('Division by zero') will be thrown
even for a ptyp command, which is indeed wrong,
but how do we fix the bug then?

  By the way, Doug patch is also not correct because
even though the signed integer division is caught
in value_binop, the corresponding unsigned code
is still missing the same check.
  The patch below fixes
'p 1/0U' output, without the patch
my cygwin gdb just freezes!

OK to commit?

ChangeLog entry:

2008-01-29  Pierre Muller  <muller@ics.u-strasbg.fr>

	* valarith.c (value_binop): Handle unsigned integer
	division by zero.

Index: gdb/valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.54
diff -u -p -r1.54 valarith.c
--- gdb/valarith.c      18 Jan 2008 17:07:40 -0000      1.54
+++ gdb/valarith.c      29 Jan 2008 07:23:43 -0000
@@ -1035,7 +1035,10 @@ value_binop (struct value *arg1, struct

            case BINOP_DIV:
            case BINOP_INTDIV:
-             v = v1 / v2;
+             if (v2 != 0)
+               v = v1 / v2;
+             else
+               error (_("Division by zero"));
              break;

            case BINOP_EXP: 






  reply	other threads:[~2008-01-29  7:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <002301c85c12$a73a4640$f5aed2c0$@u-strasbg.fr>
2008-01-29  5:26 ` Doug Evans
2008-01-29  6:32   ` Doug Evans
2008-01-29 14:42     ` Daniel Jacobowitz
2008-01-29 16:16       ` Doug Evans
2008-01-29 16:24         ` Doug Evans
2008-01-29 16:37           ` Daniel Jacobowitz
2008-01-29  7:35   ` Joel Brobecker
2008-01-29  7:51     ` Pierre Muller [this message]
2008-01-29 13:46       ` Daniel Jacobowitz
2008-01-29 15:17         ` Pierre Muller
2008-01-29 16:25           ` 'Daniel Jacobowitz'
2008-01-29 16:04       ` Doug Evans
2008-01-29 16:34         ` Pierre Muller
2008-01-29 15:51     ` Doug Evans
2008-01-29 16:49       ` Daniel Jacobowitz

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='000e01c86249$89870100$9c950300$@u-strasbg.fr' \
    --to=muller@ics.u-strasbg.fr \
    --cc=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=gdb-patches@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