From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16309 invoked by alias); 18 Aug 2008 17:52:31 -0000 Received: (qmail 16187 invoked by uid 22791); 18 Aug 2008 17:52:29 -0000 X-Spam-Check-By: sourceware.org Received: from s200aog13.obsmtp.com (HELO s200aog13.obsmtp.com) (207.126.144.127) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Aug 2008 17:50:35 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob013.postini.com ([207.126.147.11]) with SMTP; Mon, 18 Aug 2008 17:50:20 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 40EEBDA5F; Mon, 18 Aug 2008 17:50:20 +0000 (GMT) Received: from mail1.bri.st.com (unknown [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F251D4C7CB; Mon, 18 Aug 2008 17:50:19 +0000 (GMT) Received: from [164.129.14.85] (bri1017.bri.st.com [164.129.14.85]) by mail1.bri.st.com (MOS 3.8.7a) with ESMTP id CKM70229 (AUTH antony); Mon, 18 Aug 2008 18:50:19 +0100 (BST) Message-ID: <48A9B65A.1020307@st.com> Date: Mon, 18 Aug 2008 18:47:00 -0000 From: Antony KING User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Ulrich Weigand , gdb@sourceware.org Subject: Re: Spurious SIGTRAP reported by GDB 6.8 when debugging embedded RTOS application References: <200808152315.m7FNFeMU025871@d12av02.megacenter.de.ibm.com> <48A94CE7.8010400@st.com> <20080818124205.GA6958@caradoc.them.org> In-Reply-To: <20080818124205.GA6958@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------000504060507070804070907" X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00219.txt.bz2 This is a multi-part message in MIME format. --------------000504060507070804070907 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1650 I have checked the implementation and GDB is calling my target_resume with a ptid of -1 (resume all threads), which I believe is the expected argument (since scheduler locking is not supported). However I think I will add an error check in my target_resume just in case GDB requests a single thread to be resumed. As you state, I think the best course of action for me is to modify GDB. In order to preserve existing behaviour, I think the best solution is to modify GDB so that it switches back to the original thread it stopped at when performing a step operation (i.e. calling proceed() with step = 1). I have attached my initial solution, which is to modify infcmd.c. This is not entirely satisfactory as there needs to be some dynamic control over this logic (so that it can be overridden) plus some input from the target ops object. Cheers, Antony. Daniel Jacobowitz wrote: > On Mon, Aug 18, 2008 at 11:20:23AM +0100, Antony KING wrote: >> Thanks for the explanation. Unfortunately GDB has no influence over the >> RTOS, it is merely an observer. This means that it cannot change the >> status of threads or decide which thread is to execute; this is solely >> under the control of the RTOS. > > If GDB has requested a step for a particular thread, and you're > enabling hardware single step in your stub while another thread is > current, I think this must be a bug in the stub. It should, at the > least, report an error instead of continuing. > > That said, GDB hasn't been used in this way in a while, though it used > to support it. I think you'll need to communicate to GDB somehow that > it can not change the executing thread. --------------000504060507070804070907 Content-Type: text/plain; name="patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.txt" Content-length: 1341 --- gdb/infcmd.c@@/INSIGHT-6.8-ST-1.0 2008-08-12 12:00:00.000000000 +0100 +++ gdb/infcmd.c 2008-08-18 18:18:04.000000000 +0100 @@ -29,6 +29,7 @@ #include "environ.h" #include "value.h" #include "gdbcmd.h" +#include "gdbthread.h" #include "symfile.h" #include "gdbcore.h" #include "target.h" @@ -653,6 +654,27 @@ proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); } +/* Reset to waiting PID. */ +static void +prepare_to_step (void) +{ + ptid_t wait_ptid; + struct target_waitstatus wait_status; + + /* Get the last target status returned by target_wait(). */ + get_last_target_status (&wait_ptid, &wait_status); + + /* Switched over from WAIT_PID. */ + if (!ptid_equal (wait_ptid, minus_one_ptid) + && !ptid_equal (wait_ptid, inferior_ptid)) + { + /* Switch back to WAIT_PID thread. */ + switch_to_thread (wait_ptid); + printf_filtered (_("[Switching to %s]\n"), + target_pid_to_str (inferior_ptid)); + } +} + /* Step until outside of current statement. */ static void @@ -699,6 +721,8 @@ ERROR_NO_INFERIOR; + prepare_to_step (); + if (count_string) async_exec = strip_bg_char (&count_string); @@ -1057,6 +1081,8 @@ struct symbol *func; struct symtab_and_line sal; + prepare_to_step (); + clear_proceed_status (); frame = get_current_frame (); --------------000504060507070804070907--