From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124015 invoked by alias); 4 Jun 2017 22:18:09 -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 123703 invoked by uid 89); 4 Jun 2017 22:18:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Share, sergio, ling, Sergio X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 04 Jun 2017 22:18:05 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3124E81226 for ; Sun, 4 Jun 2017 22:18:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3124E81226 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3124E81226 Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF30CEFB92; Sun, 4 Jun 2017 22:18:07 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Pedro Alves , Sergio Durigan Junior Subject: [PATCH v7 2/4] Share parts of gdb/gdbthread.h with gdbserver Date: Sun, 04 Jun 2017 22:18:00 -0000 Message-Id: <20170604221803.17649-3-sergiodj@redhat.com> In-Reply-To: <20170604221803.17649-1-sergiodj@redhat.com> References: <1482464361-4068-1-git-send-email-sergiodj@redhat.com> <20170604221803.17649-1-sergiodj@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00092.txt.bz2 GDB and gdbserver now share 'switch_to_thread' because of fork_inferior. To make things clear, I created a new file name common/common-gdbthread.h, and left the implementation specific to each part. gdb/ChangeLog: yyyy-mm-dd Sergio Durigan Junior * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-gdbthread.h". * common/common-gdbthread.h: New file, with parts from "gdb/gdbthread.h". * gdbthread.h: Include "common-gdbthread.h". (switch_to_thread): Moved to "common/common-gdbthread.h". gdb/gdbserver/ChangeLog: yyyy-mm-dd Sergio Durigan Junior * inferiors.c (switch_to_thread): New function. --- gdb/Makefile.in | 1 + gdb/common/common-gdbthread.h | 25 +++++++++++++++++++++++++ gdb/gdbserver/inferiors.c | 9 +++++++++ gdb/gdbthread.h | 5 +---- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 gdb/common/common-gdbthread.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 25777f2..6bb44d7 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1507,6 +1507,7 @@ HFILES_NO_SRCDIR = \ common/common-debug.h \ common/common-defs.h \ common/common-exceptions.h \ + common/common-gdbthread.h \ common/common-regcache.h \ common/common-types.h \ common/common-utils.h \ diff --git a/gdb/common/common-gdbthread.h b/gdb/common/common-gdbthread.h new file mode 100644 index 0000000..d8635e7 --- /dev/null +++ b/gdb/common/common-gdbthread.h @@ -0,0 +1,25 @@ +/* Common multi-process/thread control defs for GDB and gdbserver. + Copyright (C) 1987-2017 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +#ifndef COMMON_GDBTHREAD_H +#define COMMON_GDBTHREAD_H + +/* Switch from one thread to another. */ +extern void switch_to_thread (ptid_t ptid); + +#endif /* ! COMMON_GDBTHREAD_H */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index b65a726..5a4a0d1 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -468,3 +468,12 @@ make_cleanup_restore_current_thread (void) { return make_cleanup (do_restore_current_thread_cleanup, current_thread); } + +/* See common/common-gdbthread.h. */ + +void +switch_to_thread (ptid_t ptid) +{ + if (!ptid_equal (ptid, minus_one_ptid)) + current_thread = find_thread_ptid (ptid); +} diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 7bf2070..046bf95 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -32,6 +32,7 @@ struct symtab; #include "target/waitstatus.h" #include "cli/cli-utils.h" #include "common/refcounted-object.h" +#include "common-gdbthread.h" /* Frontend view of the thread state. Possible extensions: stepping, finishing, until(ling),... */ @@ -493,10 +494,6 @@ extern struct thread_info *iterate_over_threads (thread_callback_func, void *); extern int thread_count (void); -/* Switch from one thread to another. Also sets the STOP_PC - global. */ -extern void switch_to_thread (ptid_t ptid); - /* Switch from one thread to another. Does not read registers and sets STOP_PC to -1. */ extern void switch_to_thread_no_regs (struct thread_info *thread); -- 2.9.3