From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xa/zBP1yUGjWExEAWB0awg (envelope-from ) for ; Mon, 16 Jun 2025 15:39:41 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JBnt8JSF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 07E5B1E11C; Mon, 16 Jun 2025 15:39:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0A1571E089 for ; Mon, 16 Jun 2025 15:39:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC4623844158 for ; Mon, 16 Jun 2025 19:39:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC4623844158 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JBnt8JSF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C9BC5380D5AF for ; Mon, 16 Jun 2025 19:38:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9BC5380D5AF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9BC5380D5AF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750102711; cv=none; b=YU2zoNrSt/OlmWgRTCfUkSi7Co/iHa0Z0DfIkkOnF9SSznPY7UVYR6W/+LxkOXnBxzZTnyYpMXwxlElT4jw4eX/ReScecMA5s84pivUZLVqcwaescpFO9HdOtngDuWUeUX4BlWJe+vM1BabbJnyGhPxkzsB6sqkrxSpf3JUAetE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750102711; c=relaxed/simple; bh=qqe3OoZA/GaEgGznKVTTLRMmKHA/bHRyxfkdYVCnTtc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=NTYnm21c2LgFFLLiM93o9WGoswcVh2lR57n9eyt6x/65Qg4SgGyxpbd5xxAtco8TJ3DvmzyVja1wCoWeKjZ1XV48rgLya4H4u44VapqpMGXTWHVrIW4udB9BXcDMua83x8hFlU7CnSw0iTQtcKB8ag7Bqcqi4wk0Yc4g8CUHWL4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9BC5380D5AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750102711; 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=J3E0jvJsKYVffBEu9zWzyuSQ8ahfd/tTN0pBLoVBbSw=; b=JBnt8JSF2wUu5VSLIF9qWzTUX2y7vuatslo+NeLiCDTA/D1+s4ARh1fhELs0GTqY/4G0LE sB7uG9DRsLjo6rh9LVVQZ3fiyU12BwRL5tIb0f+2JocubhXlQNNIARaG9hhLYSa0yGMwtO Lgn6Hcws2q/+TYmodsae6qg+RvGv45g= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-Lm33RkR5OeKTOrm2yDSwug-1; Mon, 16 Jun 2025 15:38:30 -0400 X-MC-Unique: Lm33RkR5OeKTOrm2yDSwug-1 X-Mimecast-MFC-AGG-ID: Lm33RkR5OeKTOrm2yDSwug_1750102710 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7c5e2a31f75so1625479485a.1 for ; Mon, 16 Jun 2025 12:38:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750102710; x=1750707510; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J3E0jvJsKYVffBEu9zWzyuSQ8ahfd/tTN0pBLoVBbSw=; b=OBUeFxvem8B55FakEA8DIVgA7ALjultydGxWibsTPUQPc7pm6z+CTEn5dYgcCDYUZ/ 6N/lw/lDfzhnag5WxCUDA/9xbnCkisYf4UaE5xQGyUao7j9Wpownvn1yI6eK8s5mQajD Nz+OAHaVx2N7pkMrmOITqI0b8IA0N6S5tlCX0vsF4Q+QPKzhOZijPnYApqO9XxNIUf7t wCsUoj4ITtWWThOTt/ElNpAuwkY/8UmbQqLWY+ML8oWVioSMadMVAU63Ve2fTZ9ls1W8 LaXFRBuk4kxSWv8nRYv8/9Zydrdy0QRX4FAonNbz1ep9tMisz9adUMt7gpNdjrZwnM+u qbYQ== X-Forwarded-Encrypted: i=1; AJvYcCW7HVq0b1cRQRx9G9cHzxIOdo8EMke/FoiU5Eg+4cMfbOg2APKDZBCDsRrhqowwbpECEcgOnFpZH8ENCQ==@sourceware.org X-Gm-Message-State: AOJu0YzWIiVkXT4tq9wnmlg7WqLxKrYhWNX7H7O27OvBCEhyd7pi3IcA mo1P01v7xCO1I+LdtZSzepOwqzFq1zq9vLN95cM4T4DtIgjMReYLY6POjovcdUzT8BsZAnZNiVR MD8celSF2AA/+sV3tJCyGp7ZDeD5sUKLsKctlFb0ryla0eFyr/eBjR6JqOKRcOQ4= X-Gm-Gg: ASbGnctIgFQm+sAhdnkHwmkzunxIl5XkQ6FiCjxm+jQRGvpwDG1sLgiSdS1H3IU7ym5 dgMA0lzqFZIPrqzkldM2zFagZtlbWv6CiqmQOhnWpIGtZXrWz6v8dbrpzWawIqco0lfpoztmqTF 2sSzUZhTsWKWGFzOgwnWvciO+X8RmQu70VCOjZalZ5w0gwmIVKemobJ2JKSblpWQ7Fy0AMYAGkk jMborU131/qxgy0x9fbI8QBNBNV2CbMzX3tpRqZUEa3Sc8se3als+V70xNfaK79WdlBxuEtlClW E/n1JQjuDVHiYVZPXX2IAWn31p1hjX80KA== X-Received: by 2002:a05:620a:17a8:b0:7ca:cd16:b433 with SMTP id af79cd13be357-7d3c6cc98bamr1826316485a.31.1750102709803; Mon, 16 Jun 2025 12:38:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESePA3e1Vv6vCuh4GW6P6NT0d+LtdYPwL2h7bQMHAYciG4xfUq0BQIQEcjynHN8vb2N5/tlQ== X-Received: by 2002:a05:620a:17a8:b0:7ca:cd16:b433 with SMTP id af79cd13be357-7d3c6cc98bamr1826312985a.31.1750102709411; Mon, 16 Jun 2025 12:38:29 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1000? ([2804:14d:8084:9a69::1000]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d3b8eacccfsm562970285a.66.2025.06.16.12.38.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Jun 2025 12:38:28 -0700 (PDT) Message-ID: <8795ae3d-7ffd-41b5-b4d9-4d9c2da1cee0@redhat.com> Date: Mon, 16 Jun 2025 16:38:26 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] gdb/progspace: add solib_ops pointer in program_space To: Simon Marchi , gdb-patches@sourceware.org References: <20250609194146.137730-1-simon.marchi@efficios.com> <20250609194146.137730-3-simon.marchi@efficios.com> <222942a6-2d9c-43d1-b68d-0826863989f2@efficios.com> From: Guinevere Larsen In-Reply-To: <222942a6-2d9c-43d1-b68d-0826863989f2@efficios.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6QPHOGm1-f1diM7QB2XW91Wns8YzPvRPEMoBqVI7FPY_1750102710 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 6/16/25 3:41 PM, Simon Marchi wrote: > On 6/11/25 2:43 PM, Simon Marchi wrote: >> On 6/11/25 2:14 PM, Guinevere Larsen wrote: >>>> @@ -1273,9 +1277,9 @@ solib_name_from_address (struct program_space *pspace, CORE_ADDR address) >>>> bool >>>> solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) >>>> { >>>> - const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); >>>> + const solib_ops *ops = current_program_space->solib_ops (); >>>> - if (ops->keep_data_in_core) >>>> + if (ops != nullptr && ops->keep_data_in_core != nullptr) >>> Can this function be called before the program space is fully setup? >>> >>> Otherwise I think we should either assume that it was set correctly, >>> or assert it. Better to be loud and easy to find the bug than >>> accidentally adding a regression in a hard-to-spot place. >>> >>> This goes to all other similar places where you check for ops != >>> nullptr. >> I don't really know for sure for all the methods. >> program_space::m_solib_ops is nullptr before you run the program, and I >> don't know off-hand which methods are reachable with an inferior that's >> not running yet. I'll try to see if I can figure it out. > I think it would be safer to leave it like this. There are some > functions in solib.c that are called with m_solib_ops == nullptr (when > the inferior isn't running), and returning early just makes sense there. > > Speaking of that, I found out that I am missing an early return in the > newly added print_. So with this patch, if you do "info shared" without > running the inferior first, GDB crashes. I'll add it. Ok, this makes sense. I guess i had the wrong mental model for when m_solib_ops would be set, I didn't think that using commands before starting an inferior would have a null pointer. We should be fine to leave things like this, but this would be a nice improvement in the future to try and figure out where we can be sure of things, or even where we can make checks earlier to enforce things only happening after solib_ops has been set. > > It's probable that some of the functions in solib.c are always called in > paths where the inferior is running, so there we could assert that ops > != nullptr. But figuring those out seems difficult, and I wouldn't be > that confident to get it right. > > If for some reason the program space's solib_ops wasn't properly set up, > I think it would quickly show up in the test results. > > Simon > -- Cheers, Guinevere Larsen She/Her/Hers