From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21032 invoked by alias); 26 Jun 2004 09:23:26 -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 21010 invoked from network); 26 Jun 2004 09:23:23 -0000 Received: from unknown (HELO cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com) (81.105.116.12) by sourceware.org with SMTP; 26 Jun 2004 09:23:23 -0000 Received: from localhost (localhost [127.0.0.1]) by cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com (8.12.8/8.12.8) with ESMTP id i5Q9ZTki000959 for ; Sat, 26 Jun 2004 10:35:29 +0100 Subject: [Patch] x % 0 hangs From: David Lecomber To: gdb-patches@sources.redhat.com Content-Type: text/plain Message-Id: <1088242528.30850.78.camel@cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com> Mime-Version: 1.0 Date: Sat, 26 Jun 2004 09:23:00 -0000 Content-Transfer-Encoding: 7bit X-SW-Source: 2004-06/txt/msg00554.txt.bz2 Hi On my x86, gdb does not enjoy evaluating x % 0 or x / 0 for any x: it hangs. Although there may be some systems that can healthily respond to this, I propose a trivial patch - unless someone is going to tell me there's an option to stop the hanging, or respond differently to the signal. 2004-06-26 * valarith.c: check for zero in division and remainder evaluation. Index: valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.22 diff -u -p -r1.22 valarith.c --- valarith.c 1 Apr 2004 12:08:30 -0000 1.22 +++ valarith.c 26 Jun 2004 09:21:31 -0000 @@ -1040,7 +1040,10 @@ value_binop (struct value *arg1, struct break; case BINOP_DIV: - v = v1 / v2; + if (v2 != 0) + v = v1 / v2; + else + error ("Cannot perform division: division by zero"); break; case BINOP_EXP: @@ -1050,7 +1053,10 @@ value_binop (struct value *arg1, struct break; case BINOP_REM: - v = v1 % v2; + if (v2 != 0) + v = v1 % v2; + else + error ("Cannot perform remainer: division by zero"); break; case BINOP_MOD: