From patchwork Mon May 15 19:27:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 69398 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 91A863853823 for ; Mon, 15 May 2023 19:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91A863853823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684178932; bh=DNJRsc2MGRFsbyKfRBnUxD/ubLoWKKujy2nErAu/wug=; 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=jUBRvcBZB7JKnYX2HORyCI+ahZuLwgAEqH9cWL7JFlRNu9imXIJC3oQyujBBcF+X5 mMSZ9y17dY4UNI5jgYXjTapOPSFP0yv1exsYXeGi2AFbFurUuv45z0EhldLyJtCKnQ UpuI47zJ4NhY9WDjzVWi6CK4XS+ezYo6/P6z5Adw= 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 83154385770D for ; Mon, 15 May 2023 19:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83154385770D Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-HM5RRzipMvyhojlkdpIxpQ-1; Mon, 15 May 2023 15:27:56 -0400 X-MC-Unique: HM5RRzipMvyhojlkdpIxpQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f426ffdbc6so53331445e9.3 for ; Mon, 15 May 2023 12:27:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684178874; x=1686770874; 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=DNJRsc2MGRFsbyKfRBnUxD/ubLoWKKujy2nErAu/wug=; b=fQifMazNVux/8Dx/nenVwzBS2+QRFf+ARnapUzBUAVrCoHoYb3jsFCF0zsQjtDaQXK YLrOsIPTmiryCcfTSvqBAQ2IOqvWM5rSzhORyJeA4+Z0W78/djBhknb8utwka/s8VCIj N5PKywabu+9LL8G4mqwryygwTSzbPsEqvZH/SzR8kF041ybwd1ur02TiqBW35JyShj+Q JpjXzyrB+E4wzbKayptqZZdduvreambiulR2smiO4gSfwBzoRhx6XbzYd+e96x93IqCh pKvHd7jtnvvpFFf9TUdb0MYRSvmIVXzS4i/+oq4VdXeU1TnnicT1aZoZfMMxCrYfn073 /Dbw== X-Gm-Message-State: AC+VfDydUlUMDSUWhJf66/qA8OYEVQOSEN1DLNUChUsDjlIhIWPMPjU8 MipSfTk3M3UKAOpY0yDOWtCzTgi2hggdaJPcT3HnYuBWG+J2HKDgs45fJis2rdwbHIEOWTYqQWd kRxtu9diWYxZPBj9mbjEm21kFO76RnDw5Jba5mvZN5FbIxBPrxXoUmMOHxWJEMGpPE2XCuQs8ok w2WkYtRw== X-Received: by 2002:a7b:ca51:0:b0:3f4:2174:b29d with SMTP id m17-20020a7bca51000000b003f42174b29dmr22086785wml.1.1684178874644; Mon, 15 May 2023 12:27:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LFjVQ97uwdV6dP2JYe4qV1CP0EkI/ObLzYW4DKnp6IcDvwJrE2m4L5w8uAtDmsrYCETsQUw== X-Received: by 2002:a7b:ca51:0:b0:3f4:2174:b29d with SMTP id m17-20020a7bca51000000b003f42174b29dmr22086770wml.1.1684178874241; Mon, 15 May 2023 12:27:54 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b003f50e29bce3sm257114wmi.48.2023.05.15.12.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 12:27:53 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 3/9] gdb: change 'if' to gdb_assert in update_dprintf_command_list Date: Mon, 15 May 2023 20:27:39 +0100 Message-Id: <9ab5e8275f42891b7800f5bff9122b313b1658f0.1684178710.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 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, 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 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: , 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 4d182ac0143..0827b587d5f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8383,8 +8383,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);