From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by sourceware.org (Postfix) with ESMTPS id 387CE3857C70 for ; Wed, 22 Jul 2020 11:36:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 387CE3857C70 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f67.google.com with SMTP id a15so1550594wrh.10 for ; Wed, 22 Jul 2020 04:36:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LU4QMipOu1adGgGfPySJMG2OdCiBTlOhh1LzRN/q3yw=; b=ghhgKOxceFNr4dZEgvHzM3XXCrVPBLNjMD5fZKzfusbHW9ak0yGN/srCwgCWw55mdo GIJzCdATvBNo2BjbmP2QmkIEHxOj+VN8LCVMaTLD2xZgMoDA05dcSnFIjkdhnW9Dt0x9 81tRfFT0aFSUuKgwum1YYvw+SY5Q9A0WA4jQLoabTI5xNbgWpFJiysB8oOvH7xS7IbZT fT6FULhliDnD26bpMItPAdEfEf1aDfdriX3IBHFvJRI9sQf+seBsMS31GJLPensexSE3 EakHxo/w0OFF1QanIhepVOKui4gdJwP2iM0KYsuFZ06u0GKSzug5VCll9odBrfms9tik 9g0g== X-Gm-Message-State: AOAM532SACZP+J7NrlopdTQhfgXsiFPJfiBaxA0R1vz2dm1rdYgrcVhZ klEwomyNm/D2pJx0lF9CneHRtXS0V4w= X-Google-Smtp-Source: ABdhPJzOHEkkMd0fMR8fLOj/nVHZnlvypHOYYPmTQrPnw7mopU1jKRasVCXUskVSW0DiePPJbVehyQ== X-Received: by 2002:adf:94e5:: with SMTP id 92mr8322007wrr.316.1595417766798; Wed, 22 Jul 2020 04:36:06 -0700 (PDT) Received: from ?IPv6:2001:8a0:f91a:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f91a:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id v29sm17795946wrv.51.2020.07.22.04.36.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 04:36:05 -0700 (PDT) Subject: Re: [PATCH] gdbserver: handle running threads in qXfer:threads:read To: "Aktemur, Tankut Baris" , "gdb-patches@sourceware.org" References: <20200722014324.23166-1-pedro@palves.net> From: Pedro Alves Message-ID: Date: Wed, 22 Jul 2020 12:36:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2020 11:36:09 -0000 On 7/22/20 8:32 AM, Aktemur, Tankut Baris wrote: > On Wednesday, July 22, 2020 3:43 AM, Pedro Alves wrote: >> diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc >> index 88adb16eac2..0bdf4b761e8 100644 >> --- a/gdbserver/inferiors.cc >> +++ b/gdbserver/inferiors.cc >> @@ -223,6 +223,16 @@ switch_to_thread (process_stratum_target *ops, ptid_t ptid) >> current_thread = find_thread_ptid (ptid); >> } >> >> +/* See inferiors.h. */ >> + >> +void >> +switch_to_process (struct process_info *proc) > > Can we get rid of 'struct' here? Done. > >> +{ >> + int pid = pid_of (proc); >> + >> + current_thread = find_any_thread_of_pid (pid); >> +} >> + >> /* See gdbsupport/common-inferior.h. */ >> >> const char * >> diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h >> index 4e24b2c7bb2..2af0169a4e1 100644 >> --- a/gdbserver/inferiors.h >> +++ b/gdbserver/inferiors.h >> @@ -138,6 +138,9 @@ struct process_info *find_process_pid (int pid); >> int have_started_inferiors_p (void); >> int have_attached_inferiors_p (void); >> >> +/* Switch to a thread of PROC. */ >> +void switch_to_process (struct process_info *proc); > > And here. Done. > >> + >> void clear_inferiors (void); >> >> void *thread_target_data (struct thread_info *); >> diff --git a/gdbserver/server.cc b/gdbserver/server.cc >> index ab5363eb032..b1015229ad0 100644 >> --- a/gdbserver/server.cc >> +++ b/gdbserver/server.cc >> @@ -48,6 +48,7 @@ >> #include "gdbsupport/selftest.h" >> #include "gdbsupport/scope-exit.h" >> #include "gdbsupport/gdb_select.h" >> +#include "gdbsupport/scoped_restore.h" >> >> #define require_running_or_return(BUF) \ >> if (!target_running ()) \ >> @@ -1678,19 +1679,54 @@ handle_qxfer_threads_worker (thread_info *thread, struct buffer >> *buffer) >> buffer_xml_printf (buffer, "/>\n"); >> } >> >> -/* Helper for handle_qxfer_threads. */ >> +/* Helper for handle_qxfer_threads. Return true on success, false >> + otherwise. */ >> >> -static void >> +static bool >> handle_qxfer_threads_proper (struct buffer *buffer) >> { >> + client_state &cs = get_client_state (); >> + >> + scoped_restore save_current_thread >> + = make_scoped_restore (¤t_thread); >> + scoped_restore save_current_generalte_thread > > "generalte" seems like a typo. Indeed it is. Thanks for taking a look. I've merged the patch with those fixes now. Pedro Alves