From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WOjwN/2HHGUW6SMAWB0awg (envelope-from ) for ; Tue, 03 Oct 2023 17:30:37 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=WtKXy1Yt; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E17661E0C3; Tue, 3 Oct 2023 17:30:37 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.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 D3F411E092 for ; Tue, 3 Oct 2023 17:30:35 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6257E3861809 for ; Tue, 3 Oct 2023 21:30:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6257E3861809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696368635; bh=Lp7VJRIjBbmvBu6MCzTBAWyl2NdRuUNV4uC8oKPyg1U=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WtKXy1YtfqcQDrpznFldQD4/Uv07pPZlZmow33Q3AK+ZEsAfRz02ed2CPklQNn8fc EkQ6BLWkKAlG/+1uiXoScw0Z7PR2vRgZQ10QJjesiNJMcv+yXy9V7N5efmtn0G2V0x AMba7EYXY++A96hvpLkqhzJ3rF6pvIUPMcx9AZEY= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E1EF23856DDE for ; Tue, 3 Oct 2023 21:30:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1EF23856DDE Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-ZPrH9AgNPmySxIXosFs80w-1; Tue, 03 Oct 2023 17:29:54 -0400 X-MC-Unique: ZPrH9AgNPmySxIXosFs80w-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9a1cf3e6c04so41784166b.3 for ; Tue, 03 Oct 2023 14:29:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696368593; x=1696973393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lp7VJRIjBbmvBu6MCzTBAWyl2NdRuUNV4uC8oKPyg1U=; b=HbCSbTXfopHYzXxkzonicBpi9e0SeARp3QzsHfeezmRds6lKoa+EIZgQ7G7RjVsTNy dopLxmCFKAWdOInus8mfiIpsfrgWhNgc7115LluEXwtflvyaw+awtgKUtFJLqd5mpaga qPVIWqLxrkrFZW5kPiEvFMskx3Bolsl55Y+MNOguuV6pxtKXuExYHq5hsBvNpimA6BQO juOCToX2vgVTKSxgldk+linuEQIyJ2rxF/GwWCodoTRujlvpHHWMRFEjHJcYHPEFlc0s GXQmHbnYpwQcW4DLPUS9krNuzuF2iBWtdgj1xRiqps4/M4pB9o0e0OzBXCamJ5E0CVnz wX8A== X-Gm-Message-State: AOJu0YzVrURpGoffqkQZHAO3NWq283PyRuL34eapko3Tu12DtbCu7EqD ACutvRMR/3BOGFnAbHP7DY8GuwtrSiGgSd+sH0fenbDQ/P9vT+QyuUB20o2ciH0wkxXSqChqHbU GEE7vXu8izsQzCW77XEtCISEhrMXvUE/t31oKt1uDocYCLYqr3F2e+NsOx80I/6aQiRzFphwGaK ur4UcPUw== X-Received: by 2002:a17:906:51d1:b0:9b2:7657:87c0 with SMTP id v17-20020a17090651d100b009b2765787c0mr371016ejk.51.1696368593213; Tue, 03 Oct 2023 14:29:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRMbIMq062LmLdkDbGWSh2rjYbfwKneZADEXL+CpY8pz7L4Hw9i5tZoLDcBhyNeZ1Gejcjzg== X-Received: by 2002:a17:906:51d1:b0:9b2:7657:87c0 with SMTP id v17-20020a17090651d100b009b2765787c0mr371000ejk.51.1696368592814; Tue, 03 Oct 2023 14:29:52 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id jo3-20020a170906f6c300b0099df2ddfc37sm1644861ejb.165.2023.10.03.14.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 14:29:52 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess , Lancelot SIX Subject: [PATCHv5 03/10] gdb: change 'if' to gdb_assert in update_dprintf_command_list Date: Tue, 3 Oct 2023 22:29:36 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 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: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" I noticed in update_dprintf_command_list that we handle the case where the bp_dprintf style breakpoint doesn't have a format and args string. However, I don't believe such a situation is possible. The obvious approach certainly already catches this case: (gdb) dprintf main Format string required If it is possible to create a dprintf breakpoint without a format and args string then I think we should be catching this case and handling it at creation time, rather than having GDB just ignore the situation later on. And so, I propose that we change the 'if' that ignores the case where the format/args string is empty, and instead assert that we do always have a format/args string. The original code, that handled an empty format/args string has existed since commit e7e0cddfb0d4, which is when dprintf support was added to GDB. If I'm correct and this situation can't ever happen then there should be no user visible changes after this commit. --- gdb/breakpoint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 5849e7df1af..c615ed65011 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8542,8 +8542,9 @@ update_dprintf_command_list (struct breakpoint *b) const char *dprintf_args = b->extra_string.get (); gdb::unique_xmalloc_ptr printf_line = nullptr; - if (!dprintf_args) - return; + /* Trying to create a dprintf breakpoint without a format and args + string should be detected at creation time. */ + gdb_assert (dprintf_args != nullptr); dprintf_args = skip_spaces (dprintf_args); -- 2.25.4