From patchwork Tue Oct 3 21:29:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 77059 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4ECE3385CCBA for ; Tue, 3 Oct 2023 21:30:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4ECE3385CCBA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696368639; 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=xmF+yPOH1ZtPVwcfCIpRzOm36v5fdVLA2XvoG9GbgYo0fTKHYIMFjQ1HlxubBiSj1 i6gR3LSOvJYDZa80Lr907nVmCDhQAeC9s89wT9qzRM0yP0VbJ1xFkt7ygKwH4P5vDJ Ve48npCdyjC9XUrFR19K5W4JJ8zPCVlT4tU7hYWk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 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: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@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);