aboutsummaryrefslogtreecommitdiff
path: root/gdb/valarith.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-12-14 07:35:45 -0700
committerTom Tromey <tromey@adacore.com>2020-12-14 07:35:45 -0700
commita3bdae4ef826f2b59cc475e530b2a4130185cfac (patch)
tree18d4c1cd273e34ce9e7766d9a824d58ab14daec3 /gdb/valarith.c
parentbf6d80378274fa33001f2ca1cef084eabc904178 (diff)
downloadgdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.zip
gdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.tar.gz
gdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.tar.bz2
Handle fixed-point division by zero
fixed_point_binop did not account for division by zero. This would lead to gdb getting SIGFPE and subsequently cause some test cases to hang. gdb/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * valarith.c (fixed_point_binop): Call error on division by zero. gdb/testsuite/ChangeLog 2020-12-14 Tom Tromey <tromey@adacore.com> * gdb.dwarf2/dw2-fixed-point.exp: Add test for division by zero.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r--gdb/valarith.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 37988f1..6854d9b 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -965,6 +965,8 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
break;
case BINOP_DIV:
+ if (mpq_sgn (v2.val) == 0)
+ error (_("Division by zero"));
mpq_div (res.val, v1.val, v2.val);
val = fixed_point_to_value (res);
break;