From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 7F2E83858C20 for ; Tue, 21 Nov 2023 18:03:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F2E83858C20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F2E83858C20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2610:1c1:1:606c::19:2 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700589785; cv=pass; b=kUkyxjWaVrZLce9dO4U6LlFiCEiBuYKwy65BNpWz6tYHmqiPSES1scOEuikqKqjPt179pX5tN1B/t0bxaHwLVsV7yw7MGLklw7F6ARaeMWG+exU9cNUyM7kJIYiYno6i8DP87243A0eU/3KSwoNzrCLEeJW3Cn6WHyQl3xoatMc= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700589785; c=relaxed/simple; bh=kA3nPXOLZWle5tDe+Hr18pH3bEjq/c46cMpSALLJQJ0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=GJ9Xu/P4dVAAqZVOt9Oa8cUb8heXbdTUbZyfQQyh/mixG2rSxdnMkNPDTUE34h/BPEj+qrQArl1B1cZHg0mlm79WMyxcgeUSqa/4hU/B52Ve0ahWS7PEddIkP2jvBHhck6WcYqRCgYkmh60+aWNT7v5oRSyIL9UTUlFBy1bzxnQ= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4SZXKh2S1Sz3fCG; Tue, 21 Nov 2023 18:03:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SZXKh1dl7z4l7s; Tue, 21 Nov 2023 18:03:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700589784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L867V/XIt0YiYS8Ignb4z2h4vi8MXjl+sMRvoj4CYIk=; b=GRr8B8ytDv8TKSMyOA+hu5rG0vZwgsRhW48CA14ERX0d5MFQudXxEHPsu2knoQqiCbOVBG 8TXspcKocibMWQm71oEahQg8Bu0LNSJdjc/PMiQJVNSj2OOap7ELt44EGgTcvdNNiuCNyR vEOrrLV+D53gB+r4IeaGJtiSgPQHRIw1rXzUGWgq11jkQ+bgAacK21QyyITJkpOsOoGNdR 46njywmofzrzx8nwXsIEVukxK7yxRExUYUJ3relyEXPQDachS3hgvYqfyCLl8YUyFjvviM vLuFL36UhWStvTHLt3X6ijQSxdeIlZqh2qwCFadCzIB0K3Ak7kaUAFY1MqvLsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700589784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L867V/XIt0YiYS8Ignb4z2h4vi8MXjl+sMRvoj4CYIk=; b=Ijanw4jtdzmGSuVxLS3eN7tu0CWNQlYsXs0AwW0XQr9m0z4FcCEdpPUaAiJN/PzyqDHVTs 7rgNd69xiOFIlYZwnYn/suPzj9R9AupwsLgSNpvbtLFtFm98rQBoSS/wBwHUcUHBrXxMmu g1AXijJhWSLx9G71J6A0mm6m/q3x3ktpxTsVZkN1Vb68pLXO9ss/L2s4J5q1Wbiu2FlxKt w2DfZo4mJIEe4SFW9SWc06F7yaIy+8ej9dflD2q0Pn1t19ynbH7PduyFhnLm/XqCGSRKbo BuQL5JTSbSD16rk7+wlS6zSupwdpeXmI2gs+TaVZKT0Zli589DNz3+M4Yy8S5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700589784; a=rsa-sha256; cv=none; b=F2oSGx4laY1/ziAhTv/i+De0QALNCzFKNUOZOIotwo2oCoDrsVxBTwtqJDZxyV3JeyNJcR GXiV4USmZ1G3LNGL0+4JSVJbMFf97I1cWiGc4mSH5dTCUGt73UclHfpNKnnwreDC2KGlY/ RdQ/LXrAQNPLJjn4Z/Snsif6oChakxJjIATgUhQ1fCRA8/alx0/o5FvPqp9ChsKqznZTme x+8QGMOecniWhcApp67lf2b1upUz5Qoyz3RMG5CROa59mmURxq4bpuTpF1wF6LWj5s/DNf cKr2JzlCd3lKjnyxf3c0T+WwbJ71Tr7y6osDf8TtQNrcXp+MPCDZjycffpG3qA== Received: from [IPV6:2601:648:8384:fd00:9c4:9ca2:ebcd:98c6] (unknown [IPv6:2601:648:8384:fd00:9c4:9ca2:ebcd:98c6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4SZXKg5BlBz1PKH; Tue, 21 Nov 2023 18:03:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <270c0418-e216-415a-b40b-d100983cb6e0@FreeBSD.org> Date: Tue, 21 Nov 2023 10:03:02 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 1/3] [gdb] Call gdbarch_get_syscall_number less often Content-Language: en-US To: Tom de Vries , Simon Marchi , gdb-patches@sourceware.org References: <20231120153749.11072-1-tdevries@suse.de> <0297df07-9331-4911-becc-e7aba0e92a7b@suse.de> From: John Baldwin In-Reply-To: <0297df07-9331-4911-becc-e7aba0e92a7b@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/21/23 3:08 AM, Tom de Vries wrote: > On 11/20/23 17:12, Simon Marchi wrote: >> On 11/20/23 10:37, Tom de Vries wrote: >>> I think there's an open issue with this patch: the cache needs to be >>> invalidated when we stop tracking syscalls. I wonder if a generation_counter >>> scheme would be a good approach here. >>> >>> Perhaps we can do a per-thread approach where when continuing a thread we >>> reset the cached value unless PTRACE_SYSCALL is used to continue the thread. >> >> I think that last idea makes sense. I am not sure I undertsand the >> generation_counter idea. >> > > Well, my first idea was to hook into disabling syscall tracing, and then > find all threads in the inferior and reset the cached value. But I was > not sure how to do this (I'm sure it's trivial, I just couldn't find the > right code examples), so I figured it would be easier to implement > incrementing a generation counter that is incremented when disabling > syscall tracing, and store the generation alongside the cached value, > allowing us to check whether the cached value is current. > > Anyway, I'll try the per-thread approach. I think you can use linux_nat_target::set_syscall_catchpoint to do the invalidation. From my reading it is called each time a syscall catchpoint is added or removed, and needed is set to false if there are no more catchpoints (so syscall catches are disabled). I think that means you could do something like: linux_nat_target::set_syscall_catchpoint () { if (!needed) iterate_over_lwps (ptid_t (pid), [] (struct lwp_info *lp) { lp->syscall_number = -1; }); } -- John Baldwin