From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 974 invoked by alias); 16 Sep 2013 08:11:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 962 invoked by uid 89); 16 Sep 2013 08:11:08 -0000 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Sep 2013 08:11:08 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RDNS_NONE,SPF_HELO_FAIL autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VLTtf-0003YZ-2C from Muhammad_Waqas@mentor.com for gdb-patches@sourceware.org; Mon, 16 Sep 2013 01:11:03 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 16 Sep 2013 01:11:02 -0700 Received: from [137.202.156.204] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.2.247.3; Mon, 16 Sep 2013 09:11:00 +0100 Message-ID: <5236BD0B.9090802@codesourcery.com> Date: Mon, 16 Sep 2013 08:11:00 -0000 From: Muhammad Waqas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [PATCH] PR 15520 - GDB step command crashed on non-stop mode Content-Type: multipart/mixed; boundary="------------070600010108000508020700" X-SW-Source: 2013-09/txt/msg00428.txt.bz2 --------------070600010108000508020700 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Content-length: 4556 Hi! In adjust_pc_after_break if (singlestep_breakpoints_inserted_p || !ptid_equal (ecs->ptid, inferior_ptid) || !currently_stepping (ecs->event_thread) || ecs->event_thread->prev_pc == breakpoint_pc) regcache_write_pc (regcache, breakpoint_pc); We should check for breakpoint_pc is software_breakpoint ( as here we only consider it is software breakpoint that is not enough in my thoughts) which is missing right now and it keep executing again and again the same instruction until the breakpoint is ripped off the moribund list and our program crashed if breakpoint is not software. I place this check and this fix the bug. What's your thought is it ok? Tested on x86_64-Ubuntu-linux-gnu, no regressions. Find the patch in attachment as well. gdb/ChangeLog 2013-09-13 Muhammad Waqas PR 15520 * infrun.c (adjust_pc_after_break): In non-stop mode verify software_breakpoint at breakpoint_pc before backup to breakpoint address. gdb.base/ChangeLog 2013-09-13 Muhammad Waqas PR 15520 *gdb.base/pr15520.cc: New file. *gdb.base/pr15520.exp: New file. Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.590 diff -u -p -r1.590 infrun.c --- infrun.c 3 Sep 2013 17:22:45 -0000 1.590 +++ infrun.c 16 Sep 2013 08:06:02 -0000 @@ -3038,7 +3038,8 @@ adjust_pc_after_break (struct execution_ if (singlestep_breakpoints_inserted_p || !ptid_equal (ecs->ptid, inferior_ptid) || !currently_stepping (ecs->event_thread) - || ecs->event_thread->prev_pc == breakpoint_pc) + || (ecs->event_thread->prev_pc == breakpoint_pc + && software_breakpoint_inserted_here_p (aspace, breakpoint_pc))) regcache_write_pc (regcache, breakpoint_pc); do_cleanups (old_cleanups); Index: testsuite/gdb.base/pr15520.cc =================================================================== RCS file: testsuite/gdb.base/pr15520.cc diff -N testsuite/gdb.base/pr15520.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr15520.cc 16 Sep 2013 08:06:03 -0000 @@ -0,0 +1,33 @@ +# Copyright 2013 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 . + +#include +using namespace std; + +void +fun (string &str1, string &str2) +{ + str1 += str2; +} + +int +main (void) +{ + string str1 = "abc"; + string str2 = "def"; + fun(str1,str2); + + return 0; +} Index: testsuite/gdb.base/pr15520.exp =================================================================== RCS file: testsuite/gdb.base/pr15520.exp diff -N testsuite/gdb.base/pr15520.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr15520.exp 16 Sep 2013 08:06:03 -0000 @@ -0,0 +1,36 @@ +# Copyright 2013 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 running programs +# +standard_testfile .cc + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if ![runto_main] { + untested non-stop-step + return -1 +} + +gdb_test "set target-async on" ".*" "Set async mode" +gdb_test "set non-stop on" ".*" "Set non stop mode" + +gdb_breakpoint "fun" +gdb_continue_to_breakpoint "fun" +gdb_test "step" ".*}.*" "step 1" +gdb_test "step" ".*main .*$srcfile.*\[\n\r\].*return 0;.*" "step 2" --------------070600010108000508020700 Content-Type: text/plain; charset="UTF-8"; name="diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="diff" Content-length: 3428 Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.590 diff -u -p -r1.590 infrun.c --- infrun.c 3 Sep 2013 17:22:45 -0000 1.590 +++ infrun.c 16 Sep 2013 08:06:02 -0000 @@ -3038,7 +3038,8 @@ adjust_pc_after_break (struct execution_ if (singlestep_breakpoints_inserted_p || !ptid_equal (ecs->ptid, inferior_ptid) || !currently_stepping (ecs->event_thread) - || ecs->event_thread->prev_pc == breakpoint_pc) + || (ecs->event_thread->prev_pc == breakpoint_pc + && software_breakpoint_inserted_here_p (aspace, breakpoint_pc))) regcache_write_pc (regcache, breakpoint_pc); do_cleanups (old_cleanups); Index: testsuite/gdb.base/pr15520.cc =================================================================== RCS file: testsuite/gdb.base/pr15520.cc diff -N testsuite/gdb.base/pr15520.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr15520.cc 16 Sep 2013 08:06:03 -0000 @@ -0,0 +1,33 @@ +# Copyright 2013 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 . + +#include +using namespace std; + +void +fun (string &str1, string &str2) +{ + str1 += str2; +} + +int +main (void) +{ + string str1 = "abc"; + string str2 = "def"; + fun(str1,str2); + + return 0; +} Index: testsuite/gdb.base/pr15520.exp =================================================================== RCS file: testsuite/gdb.base/pr15520.exp diff -N testsuite/gdb.base/pr15520.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr15520.exp 16 Sep 2013 08:06:03 -0000 @@ -0,0 +1,36 @@ +# Copyright 2013 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 running programs +# +standard_testfile .cc + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if ![runto_main] { + untested non-stop-step + return -1 +} + +gdb_test "set target-async on" ".*" "Set async mode" +gdb_test "set non-stop on" ".*" "Set non stop mode" + +gdb_breakpoint "fun" +gdb_continue_to_breakpoint "fun" +gdb_test "step" ".*}.*" "step 1" +gdb_test "step" ".*main .*$srcfile.*\[\n\r\].*return 0;.*" "step 2" --------------070600010108000508020700--