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.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 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=1682724957; 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=7GnuDq4rXJVkxVOA5UewHQhxSAIm/UqY73V7l2PM4Vk=; b=OgMYQxdPFm7NfREErhuzKkVyOyOHgx58hFUexr/P76G9/VM2R7St1YT8SJ1f5Iaf7lWbnT LLjhiISHwtruWHvUe95CYxY2jv7s+EW8AnNiygUmlKSHW0xrRLQRq0K3O8ZFwcBZZMZWnq KMOl3+loGOdSeVuCg3C/dmYaCDLIXc0= 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) From: Andrew Burgess 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-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_H2,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 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