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 83154385770D for ; Mon, 15 May 2023 19:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83154385770D 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=1684178877; 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=DNJRsc2MGRFsbyKfRBnUxD/ubLoWKKujy2nErAu/wug=; b=a37Sh7PSIl6DXhbdi7OkEKhWBgpBApC1IbWT+IsfsOeW7aNJKyEkBIEqL/bGbIvX5swq+P iXhZZ40bDtFmMU5rqvLb3o2ljr6j2cf3jtBFAxpF0W6R20FnaVlm4KKMp9uOOiBTgBc3kW dpTHm+EWbCjcai5ZyO3WoRofZSTrHPY= 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) From: Andrew Burgess 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 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,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 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); -- 2.25.4