From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6ElHDtZZTGRLDjkAWB0awg (envelope-from ) for ; Fri, 28 Apr 2023 19:42:14 -0400 Received: by simark.ca (Postfix, from userid 112) id 376941E221; Fri, 28 Apr 2023 19:42:14 -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=PFNHEZBZ; 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=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 D952C1E0D5 for ; Fri, 28 Apr 2023 19:42:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35C803858C20 for ; Fri, 28 Apr 2023 23:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35C803858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682725333; bh=7GnuDq4rXJVkxVOA5UewHQhxSAIm/UqY73V7l2PM4Vk=; 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=PFNHEZBZ9HIklVlYDxxT4/1NkQpGdW476SSkXzg+5gyHKZt0FbxCJj4ltWjeUPzsT kkL+Y3rloOI+LPbAmmWs9XyR1OEzjhJl2xg5sCMNI6uGrW7x7rVRSZA42mELFh9p3M Ipobo+yjmkS4LNed6RYYrTxx/CmZICxI+Siecv7U= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A6635385783F for ; Fri, 28 Apr 2023 23:35:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6635385783F Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-glzGUgGQNHSHVPvZPImdCQ-1; Fri, 28 Apr 2023 19:35:53 -0400 X-MC-Unique: glzGUgGQNHSHVPvZPImdCQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-302cdf5d034so183121f8f.0 for ; Fri, 28 Apr 2023 16:35:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682724952; x=1685316952; 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=7GnuDq4rXJVkxVOA5UewHQhxSAIm/UqY73V7l2PM4Vk=; b=RAvdHcaabXXwjH7cIpIDEs1tRh3+sp1EHpuI4TdKOUAZojcK9dXgkaqgD0gVfCBvul mdZysdtzC7MiDSgbPdRWEzT1/FbVL+xeW9WeZDfclMz/+qggKW5X51sv3Z3OW9ec/hvE XbonzAVQum6X/wE7BYAt7J/IKLHaq4wqlIFwNHD3YIbvcnpI43bzJubnBmDFUuyqax4l bF3uFP190bnFgc+4xEZ48jpia6+k/eYBbYM0U2bmBcyygsQAJ33rPMJRIsGl2iTdU8QB iR/0A0hrjkT73iN9b/bdfMyG4t0lfsFQwxH2FwDJCW5T4OwjOyk1hoY5NBpgbcRRcvBZ jAaQ== X-Gm-Message-State: AC+VfDzwnxGvciuVoHUkYgIYme0rJp0SbrmS5FQ2gIUT4vdG0jv+z0SV jMrRUmicKePG+infonShlevq/AabGBpc1fJEJNR2xocM6cKHmfqTRsYmlJwOcsbiQzyfancbKjg HlHgnlzXbTvFUhQhEGOSegCYmbGkKe9qd/vG4UA7BsO3aGAU0X6mmyftTWq4zw5AUHc7mnBXqbi zIE1CrYQ== X-Received: by 2002:adf:f805:0:b0:2f0:833:6acc with SMTP id s5-20020adff805000000b002f008336accmr5311282wrp.61.1682724952449; Fri, 28 Apr 2023 16:35:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jUGkdPuTS6rzfVLzleSD0Zjk9lYSCxjOancXfBXwQm9Ri0sEJVM1+OWwxxI7bI2kI76C3/w== X-Received: by 2002:adf:f805:0:b0:2f0:833:6acc with SMTP id s5-20020adff805000000b002f008336accmr5311276wrp.61.1682724952268; Fri, 28 Apr 2023 16:35:52 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id t15-20020adfe44f000000b002f00793bd7asm22069302wrm.27.2023.04.28.16.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 16:35:51 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/9] gdb: change 'if' to gdb_assert in update_dprintf_command_list Date: Sat, 29 Apr 2023 00:35:39 +0100 Message-Id: <2793a93ca9aa228f432650743674cb481881e9db.1682724005.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 350fa495319..b75990963ca 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8382,8 +8382,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