From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id 66EF53858426 for ; Mon, 6 Feb 2023 20:29:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66EF53858426 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f45.google.com with SMTP id h3so3772608wrp.10 for ; Mon, 06 Feb 2023 12:29:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ro1+KpmVfPpUZmIMHo+S8ID2c0eWHWLFaK3ThWFklmo=; b=0Gen5OwhJOoqMeli2dtbzwLxVore299XtUVFeWi3k7dwPguc40sGwlfR9XE2D1jq4r 4fo40MFvg6FcaoBh9QKwfsYZrReoFWNzQbW33VMC2OhBs94mfVNyNY19reYAAKRPgkBQ dCkc8AaNJG2EcEbzuleynjfR3qOAoIsIvOkkrw9iPKkuys/nsZa7gfoC4XTdJlWBgBQE N/P1Srfscz8G8jzVzanwm0s7K5NJrKhoI8D2TiptdgiN/bfjpnAylE4BjgmlZm7h2n6D fG6N6uLNQhwoZNRMsJ6v4nBackY86KIBhi8uQWtDMMcv/d4rclEggn4XaeV5JZl/DZT+ GZzQ== X-Gm-Message-State: AO0yUKUFv//C2txrJe/he1CSl1Kj4Nli3TA7eR0OFKp+RQE4Tss+pV2f JFOQel45MDciJlEK5mI47dm2QftnKc6LUg== X-Google-Smtp-Source: AK7set9a8LjMobztNTAvHplOPnDr/s5q0LOjkJPv7hIUxHVCrDNQUfE/EvLZkzCAYCO1Ejdku9pHvA== X-Received: by 2002:adf:e749:0:b0:2c3:e5f5:9faa with SMTP id c9-20020adfe749000000b002c3e5f59faamr194506wrn.58.1675715346971; Mon, 06 Feb 2023 12:29:06 -0800 (PST) Received: from ?IPv6:2001:8a0:f92b:9e00::1fe? ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id y10-20020a05600015ca00b002bfd137ecddsm9861342wry.11.2023.02.06.12.29.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Feb 2023 12:29:06 -0800 (PST) Subject: Re: [PATCH v3 4/8] gdbserver/linux-aarch64: When thread stops, update its target description To: Thiago Jung Bauermann , Luis Machado Cc: Simon Marchi , Andrew Burgess , Thiago Jung Bauermann via Gdb-patches References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-5-thiago.bauermann@linaro.org> <87pmattzjw.fsf@redhat.com> <7970ac03-1123-d5f6-7b17-808832d43be6@simark.ca> <9a85e2fe-078a-e2ee-7e49-53fe0ceef492@arm.com> <87y1pgaib6.fsf@linaro.org> <9d30751a-589b-eb95-09b1-61d083ad9730@arm.com> <87leldmp6r.fsf@linaro.org> From: Pedro Alves Message-ID: <045c1e09-5b6d-22b6-df7a-39cfa339b0e1@palves.net> Date: Mon, 6 Feb 2023 20:29:04 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <87leldmp6r.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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 2023-02-04 3:21 p.m., Thiago Jung Bauermann via Gdb-patches wrote: > > Luis Machado writes: > >> On 2/2/23 03:47, Simon Marchi wrote: >>> On 2/1/23 21:54, Thiago Jung Bauermann wrote: >>>> In any case, it wouldn't be possible to make get_thread_target_desc just >>>> return thread_info->tdesc because at least the way these patches are >>>> currently written, when the inferior starts or a new thread of the >>>> inferior is spawned thread_info->tdesc is nullptr. gdbserver will only >>>> call get_thread_tdesc after the first stop (in get_thread_regcache, in >>>> the process of obtaining the pc register), so we will need to cope with >>>> that situation. >>> Ok. Would it work if a new thread initially inherited the tdesc from >>> its process? >>> >> >> It should be fine because the first time we fetch a process target >> description, it is eventually obtained from the first and only thread. >> So the SVE vector length should be correct. >> >> Any subsequent attempts to use the process' target description (the >> first one we obtained), after further stops, may end up using an >> incorrect description. >> >> I think this is handled correctly by the target architecture target >> hook though. But there are other places where this is potentially >> incorrect. >> >> For example... >> >> - When using gcore to dump a core file, GDB only dumps a single target >> description. While this might be correct for a target with a fixed >> target description or a AArch64 target that doesn't support SVE, it >> likely won't be correctly for one AArch64 target supporting SVE if its >> threads changed vector length mid-execution. Either we emit target >> description notes by thread, or we don't emit a target description >> note for those cases. >> >> - When loading the above/older gcore core files back, GDB will use a >> potentially incorrect target description. If we decide to emit >> per-thread target descriptions, it should be fine. Otherwise we may >> need to have a "thread architecture" hook for core files as well. >> >> - The remote has no concept of a thread architecture (Thiago is >> addressing this with this patch series). >> >> - AArch64 frames may have slightly different vg values, which means >> their gdbarches are different as well. >> >> Given the differences between two gdbarches are small, we mostly get >> away with it. But if there are further differences (different hooks, >> for example), I fear we may run into a situation where we use an >> incorrect gdbarch to call a particular hook. > > Indeed, good points! Thank you for bringing them up. I can address core > file dumping/loading after this series. > > Regarding frames with different vg values, it's important to be aware of > this discrepancy but IMHO it makes sense to work on it when it becomes > a problem... > Yeah, one thought that keeps crossing my mind is if really modeling all this stuff as different target descriptions is really the best approach. The Intel AMX support posted on the list last year also ran into a similar problem, with the matrix registers height/width changing at runtime, and it is impractical (or really, it really smells like the wrong approach) to have different target descriptions for every potential matrix size. Which is not unlike different SVE sizes. It feels like a single tdesc should be able to be a bit more dynamic. It's a bit funny that ptrace manages to work with a single registers interface, while we don't. What if we extended the target description mechanism so that a single description could describe all SVE sizes? For example, what if a tdesc could describe the SVE width/length as a dynamic property, retrieved from elsewhere, e.g., from another register? BTW, for core files, where are we going to retrieve the SVE length from?