From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id APD5OPtgdmQTIRkAWB0awg (envelope-from ) for ; Tue, 30 May 2023 16:47:55 -0400 Received: by simark.ca (Postfix, from userid 112) id E714F1E11E; Tue, 30 May 2023 16:47:55 -0400 (EDT) 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=fkJMJyvV; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9ACC31E0D4 for ; Tue, 30 May 2023 16:47:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F5E438532C7 for ; Tue, 30 May 2023 20:47:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F5E438532C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685479675; bh=4slbOZ6mfwYI7cdKwWKvNzlRHVIfCRzDnMa2zPFuQrI=; 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=fkJMJyvVGnC/kgr+QQVLIVyoLtd/YJ69tS0W+qcYhwExxLYvng+4XvMs17XTtj8IG o0NuWAHNK5sl6QeX6E5xJEFDL0M1h2Jqx128suWvp1JN70+RRVFrDc8fY5ShVTYIzq ix8I4VedtImliYOQ8+l+yriPJ83J0cUk27ckrYOo= 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 F319C3858410 for ; Tue, 30 May 2023 20:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F319C3858410 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-lZaQFA5ZOdqUPqyemztjPg-1; Tue, 30 May 2023 16:47:04 -0400 X-MC-Unique: lZaQFA5ZOdqUPqyemztjPg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so19146135e9.2 for ; Tue, 30 May 2023 13:47:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685479622; x=1688071622; 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=4slbOZ6mfwYI7cdKwWKvNzlRHVIfCRzDnMa2zPFuQrI=; b=VEAXHmKSGiIGsHBS9baJnzij4NSnoYZ7J+OKMBqRZ8Xk297FB59RJiMRq/RSiqG0ic gyp7C+86ictxb3+4/E3Qbt3otdc46Ojrf4ep7Ma+rDcYTSx/An4MRDDOmJw4J6s7L5G3 KL3jDZTMVIMTiEq1SwPprMva9+tlFbmkDj/fA+7kcL9mUszCUHvp1NRenb/ygkSInXJu 1HLav0jj4RfJmTfkTyWBhX6AXrQ2zJXOVl9h2Tf1/+Z8unvBVpzWELdyF8OxvcPzy3l+ HGrGS0QZWtdPQAeYuYVt8JotNX08ox1Mu/Ex8eiWQCu8o3A7B1lv3apB55AlSbGrAJYh EK8w== X-Gm-Message-State: AC+VfDwe71/wlfbixJ8gGHULVqLmIa3Br3NVjZUApyw1YKdX0N1m4WK9 6io9iWQClTdJWNq6YDu+nCaltGDlyjA7jMHsnGUgCtMhIvwk3Iyh77OuS2Rdx9s0W5bKudWpY/n PtxQJYr4wkzgfUA77Mz1y1JNQt2aaXFOTAx4eqcq0ihA8POGUx+6JFd0D5/UCXyt0bJL7NfOOjG sted1eqg== X-Received: by 2002:a5d:4a12:0:b0:30a:de1b:93e5 with SMTP id m18-20020a5d4a12000000b0030ade1b93e5mr2612084wrq.52.1685479622777; Tue, 30 May 2023 13:47:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fdUA8ydT6uBtZutLSG3k/NB1tfDeiYvbFB8cdnIQHoNBkSsYiwtf1rCCKPlSIyrhvWLQzPg== X-Received: by 2002:a5d:4a12:0:b0:30a:de1b:93e5 with SMTP id m18-20020a5d4a12000000b0030ade1b93e5mr2612073wrq.52.1685479622428; Tue, 30 May 2023 13:47:02 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id a27-20020a5d457b000000b002f103ca90cdsm4318085wrc.101.2023.05.30.13.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 13:47:02 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 3/9] gdb: change 'if' to gdb_assert in update_dprintf_command_list Date: Tue, 30 May 2023 21:46:47 +0100 Message-Id: <09152d06a4099a28ec03bf4e3167bdf6287da1ef.1685479504.git.aburgess@redhat.com> 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-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: , 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 fcd2f472bf7..2cadc8c0295 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8356,8 +8356,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