From 0e095b7eee9adf0be7109de8662647df7d0ee0ac Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 28 Feb 2010 17:56:37 +0000 Subject: [PATCH] gdb/ * infcall.c (call_function_by_hand): Remove gdb_assert on sp and old_sp. New comment. gdb/testsuite/ * gdb.base/callfuncs.exp: New tests for $spval 0 and -1. Remove return. --- gdb/ChangeLog | 5 +++++ gdb/infcall.c | 7 +++---- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/callfuncs.exp | 14 +++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 38792a65f05..56f16d50a41 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-02-28 Jan Kratochvil + + * infcall.c (call_function_by_hand): Remove gdb_assert on sp and old_sp. + New comment. + 2010-02-28 Corinna Vinschen * Makefile.in (SUBDIR_MI_OBS): Move mi-common.o from here... diff --git a/gdb/infcall.c b/gdb/infcall.c index e6428941483..2d8bd2cecad 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -518,10 +518,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) /* Stack grows up. */ sp = gdbarch_frame_align (gdbarch, old_sp + 1); } - gdb_assert ((gdbarch_inner_than (gdbarch, 1, 2) - && sp <= old_sp) - || (gdbarch_inner_than (gdbarch, 2, 1) - && sp >= old_sp)); + /* SP may have underflown address zero here from OLD_SP. Memory access + functions will probably fail in such case but that is a target's + problem. */ } else /* FIXME: cagney/2002-09-18: Hey, you loose! diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ebc5edb9372..8684ebc67d4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-28 Jan Kratochvil + Daniel Jacobowitz + + * gdb.base/callfuncs.exp: New tests for $spval 0 and -1. Remove return. + 2010-02-25 David S. Miller * gdb.base/catch-syscall.exp: Allow to run on sparc*-*-linux and diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 46ba5095246..9aeb09be3ed 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -469,5 +469,17 @@ if {$old_reg_content == $new_reg_content} then { fail "nested call dummies preserve register contents" } -return 0 +# GDB should not crash by internal error on $sp underflow during the inferior +# call. It is OK it will stop on some: Cannot access memory at address 0x$hex. +if {![target_info exists gdb,nosignals] && ![istarget "*-*-uclinux*"]} { + gdb_test {set $old_sp = $sp} + + gdb_test {set $sp = 0} + gdb_test "call doubleit (1)" "" "sp == 0: call doubleit (1)" + + gdb_test {set $sp = -1} + gdb_test "call doubleit (1)" "" "sp == -1: call doubleit (1)" + + gdb_test {set $sp = $old_sp} +} -- 2.30.2