From 7e09a22367934a6d53f79d8b01135832b80ab246 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Mon, 28 Jul 2014 13:44:57 +0800 Subject: [PATCH] Fix PR 17206 As reported in PR 17206, an internal error is triggered when command until is executed. In infcmd.c:until_next_command, step_range_end is set to 'pc', if (!func) { struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol.minsym == NULL) error (_("Execution is not within a known function.")); tp->control.step_range_start = BMSYMBOL_VALUE_ADDRESS (msymbol); tp->control.step_range_end = pc; } and later in infrun.c:resume, the assert below is triggered in PR 17206. if (tp->control.may_range_step) { /* If we're resuming a thread with the PC out of the step range, then we're doing some nested/finer run control operation, like stepping the thread out of the dynamic linker or the displaced stepping scratch pad. We shouldn't have allowed a range step then. */ gdb_assert (pc_in_thread_step_range (pc, tp)); } In until_next_command, we set step range to [XXX, pc), so pc isn't within the range. pc_in_thread_step_range returns false and the assert is triggered. AFAICS, the range we want in until_next_command is [XXX, pc] instead of [XXX, pc), because we want to program step until greater than pc. This patch is to set step_range_end to 'pc + 1'. Running until-nodebug.exp with unpatched GDB will get the following fail, FAIL: gdb.base/until-nodebug.exp: until 2 (GDB internal error) and the fail goes away when the fix is applied. gdb: 2014-07-29 Yao Qi PR gdb/17206 * infcmd.c (until_next_command): Set step_range_end to PC + 1. gdb/testsuite: 2014-07-29 Yao Qi PR gdb/17206 * gdb.base/until-nodebug.exp: New. --- gdb/ChangeLog | 5 ++++ gdb/infcmd.c | 4 ++- gdb/testsuite/ChangeLog | 5 ++++ gdb/testsuite/gdb.base/until-nodebug.exp | 37 ++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.base/until-nodebug.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0e47fbcb39..ae8a101366 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-07-29 Yao Qi + + PR gdb/17206 + * infcmd.c (until_next_command): Set step_range_end to PC + 1. + 2014-07-28 Doug Evans PR guile/17203 diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 5eb092b804..d84c591865 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1359,7 +1359,9 @@ until_next_command (int from_tty) error (_("Execution is not within a known function.")); tp->control.step_range_start = BMSYMBOL_VALUE_ADDRESS (msymbol); - tp->control.step_range_end = pc; + /* The upper-bound of step_range is exclusive. In order to make PC + within the range, set the step_range_end with PC + 1. */ + tp->control.step_range_end = pc + 1; } else { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e65e76a044..a90ee8b4b7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-07-29 Yao Qi + + PR gdb/17206 + * gdb.base/until-nodebug.exp: New. + 2014-07-28 Doug Evans PR guile/17203 diff --git a/gdb/testsuite/gdb.base/until-nodebug.exp b/gdb/testsuite/gdb.base/until-nodebug.exp new file mode 100644 index 0000000000..a7e75e2827 --- /dev/null +++ b/gdb/testsuite/gdb.base/until-nodebug.exp @@ -0,0 +1,37 @@ +# Copyright 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# Test that the address range for stepping is correctly set in command +# until when there is no debug information. + +standard_testfile advance.c + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile nodebug]} { + return -1 +} + +if ![runto_main] { + fail "Can't run to main" + return 0 +} + +# Without debug information, the program stops at the next +# instruction, which is still in main. +gdb_test "until" "in main .*" "until 1" + +# If the stepping range is correctly set, the program stops at the next +# instruction. Otherwise, an internal error will be triggered. See +# PR gdb/17206. +gdb_test "until" "in main .*" "until 2" -- 2.34.1