From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24399 invoked by alias); 23 Jan 2006 15:20:47 -0000 Received: (qmail 24391 invoked by uid 22791); 23 Jan 2006 15:20:46 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 23 Jan 2006 15:20:45 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1F13Ui-0003gC-Ai for gdb@sources.redhat.com; Mon, 23 Jan 2006 18:20:42 +0300 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1F13Uh-0003fb-QZ for gdb@sources.redhat.com; Mon, 23 Jan 2006 18:20:36 +0300 From: Vladimir Prus To: gdb@sources.redhat.com Subject: Multithreaded debugging: strange thread switches Date: Mon, 23 Jan 2006 15:46:00 -0000 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601231820.33372.ghost@cs.msu.su> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00216.txt.bz2 Hello, I'm observing strange behaviour when debugging with gdb using a custom stub. I have two threads. After connecting, I say "next" several times and that steps in thread 1. Then I say "thread 2" and "next". Gdb then stops again in thread 1, not in thread 2 as I'd expected. In the remote protocol I see "Hc1" packet after last "next" though I'd expect "Hc2", and in infrun.c, function prepare_to_proceed, I see this: if (!ptid_equal (wait_ptid, minus_one_ptid) && !ptid_equal (inferior_ptid, wait_ptid)) { /* Switched over from WAIT_PID. */ CORE_ADDR wait_pc = read_pc_pid (wait_ptid); if (wait_pc != read_pc ()) { /* Switch back to WAIT_PID thread. */ inferior_ptid = wait_ptid; /* FIXME: This stuff came from switch_to_thread() in thread.c (which should probably be a public function). */ flush_cached_frames (); registers_changed (); stop_pc = wait_pc; select_frame (get_current_frame ()); } Can somebody explain the reason for this explicit switch back to "wait_ptid"? Thanks, Volodya