From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685479625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4slbOZ6mfwYI7cdKwWKvNzlRHVIfCRzDnMa2zPFuQrI=; b=TY2K49dTBhyaHGS7TnlEAERIOn1dUpeuX83CJ5AV9BwM07YFu4mCUe2k5WnlErhbjfZKqd FrWlCnLNBIOQ/92bkOeuXnp6837aJ2ezR9WwN0dwL582v6K7voXUEqSTfzMXon5WyWabh4 3gnl/jtRqlVMks3T8z5vXZ7ZLmvnRXA= 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) From: Andrew Burgess 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-Spam-Status: No, score=-11.8 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,SPF_HELO_NONE,SPF_NONE,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: 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