From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15328 invoked by alias); 5 Dec 2007 14:13:32 -0000 Received: (qmail 15319 invoked by uid 22791); 5 Dec 2007 14:13:30 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Dec 2007 14:13:25 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1Izv06-0000xt-00; Wed, 05 Dec 2007 14:13:22 +0000 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1Izv02-0004QX-00; Wed, 05 Dec 2007 14:13:18 +0000 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1Izv02-000536-5M; Wed, 05 Dec 2007 14:13:18 +0000 Date: Wed, 05 Dec 2007 14:26:00 -0000 From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: "Maciej W. Rozycki" Subject: Target-specific thread switching backend Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: macro@mips.com 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 X-SW-Source: 2007-12/txt/msg00081.txt.bz2 Hello, In preparation for submitting support for the MDI target I propose the following enhancement to target_switch_to_thread(). The MDI implements a multi-threaded target which remembers the currently selected thread within itself. All the operations that have thread-local scope, such as accessing of the CPU registers, use that thread identifier. Therefore I think it is reasonable to propagate the thread-switch event down to the target, which is what the following change implements. Tested using the mipsisa32-sde-elf target, with the mips-sim-sde32/-EB and mips-sim-sde32/-EL boards with no regressions. 2007-12-05 Maciej W. Rozycki * target.c (update_current_target): Initialize to_switch_to_thread. * target.h (target_switch_to_thread): New macro. * thread.c (switch_to_thread): Call target_switch_to_thread(). OK to apply? Maciej 13327-1.diff Index: binutils-quilt/src/gdb/target.h =================================================================== --- binutils-quilt.orig/src/gdb/target.h 2007-12-03 14:28:21.000000000 +0000 +++ binutils-quilt/src/gdb/target.h 2007-12-03 14:28:24.000000000 +0000 @@ -393,6 +393,7 @@ void (*to_mourn_inferior) (void); int (*to_can_run) (void); void (*to_notice_signals) (ptid_t ptid); + void (*to_switch_to_thread) (void); int (*to_thread_alive) (ptid_t ptid); void (*to_find_new_threads) (void); char *(*to_pid_to_str) (ptid_t); @@ -878,6 +879,14 @@ #define target_notice_signals(ptid) \ (*current_target.to_notice_signals) (ptid) +/* Switch to a selected thread. */ + +#define target_switch_to_thread() \ + do \ + if (current_target.to_switch_to_thread) \ + (*current_target.to_switch_to_thread) (); \ + while (0) + /* Check to see if a thread is still alive. */ #define target_thread_alive(ptid) \ Index: binutils-quilt/src/gdb/thread.c =================================================================== --- binutils-quilt.orig/src/gdb/thread.c 2007-12-03 14:20:57.000000000 +0000 +++ binutils-quilt/src/gdb/thread.c 2007-12-03 14:28:24.000000000 +0000 @@ -462,6 +462,7 @@ inferior_ptid = ptid; reinit_frame_cache (); registers_changed (); + target_switch_to_thread (); stop_pc = read_pc (); } Index: binutils-quilt/src/gdb/target.c =================================================================== --- binutils-quilt.orig/src/gdb/target.c 2007-12-03 14:20:57.000000000 +0000 +++ binutils-quilt/src/gdb/target.c 2007-12-03 14:28:24.000000000 +0000 @@ -438,6 +438,7 @@ INHERIT (to_mourn_inferior, t); INHERIT (to_can_run, t); INHERIT (to_notice_signals, t); + INHERIT (to_switch_to_thread, t); INHERIT (to_thread_alive, t); INHERIT (to_find_new_threads, t); INHERIT (to_pid_to_str, t);