From patchwork Fri Dec 29 09:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 82983 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 E744C3858282 for ; Fri, 29 Dec 2023 09:31:23 +0000 (GMT) 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 02A023858409 for ; Fri, 29 Dec 2023 09:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02A023858409 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 02A023858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703842051; cv=none; b=bxgPXKQC3zkTsvxAdmwWRx4rJAsLPhGMyDtYHmG99O2LDx4m/1KE5vMKFoQObSBHb9mbF/QE5gCBeNfnAbk92bitT7P6TqXu+vZcMOmFYX5x1NgehBWF3sL6IccnYKmF6Oot2hBLNslnDzkMRKmqA6xQAAlplNuZhjs6Hz1dnT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703842051; c=relaxed/simple; bh=lxnMEz4spVtiXWWgLhCeA1wwXlwH8kal/UoH/+Zr1+Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Qv7E0SvPyvkEUj2gZbmEUXsnL66ozFsF5V0gdcPPee85Oib44avYwbEAk9/UjYyYv/tnJDxaMvpOnSzk1gS/zE7ZDceyfbRQe32iVL2n9mXmcZBoo/ctiIGzKdx7Fd0fctx05VtvXnEOPDonUrhWIeBUdhqUojqzdBwer3MiDQc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703842043; 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=rqkfwk2wjoVREDRsC92c9aA62i8JNtmS2Ym854nvuPE=; b=LDWn/h9Daf7QEL337GG9bJaecAiKaKjgDEjLwxPXOC+u7Fl1aM9mQlQmVqAtaIsQUHmtmq AXLMF19wTPWcg6oc3JVJsS8mxYtsraKYZTxwm9YM/OqNRxO71AoffD3euKYpfrhhnxVt0r 7Km+iu2LhQBM6byCzldonpTcg7CSnNA= 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-573-Gx7LcHqANEW0zHHSapNAPg-1; Fri, 29 Dec 2023 04:27:22 -0500 X-MC-Unique: Gx7LcHqANEW0zHHSapNAPg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-336a56ff1e5so2447494f8f.1 for ; Fri, 29 Dec 2023 01:27:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703842040; x=1704446840; 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=rqkfwk2wjoVREDRsC92c9aA62i8JNtmS2Ym854nvuPE=; b=UqplAhODOrMiuXNCr+VJhMTDOmTdNul/a5iq42NlfsLwU63tkelFavjM18L+0ug6I2 CukDVlF/52zuPnNfi66VgNMhVcdKQTOV3n9f4VuPRwSyzcJ7ZKkuWyVoUOyLDxkL1xII PY5ApMrvXwS2MdOmAB3Qq81hR/BKQScQQLJpk3bbYVrhrmBF/fsFWMg1132GzwFCs/Hz ykKkVKIikhbL1v73mKgxvHuTUIbU6Pvy9aD574WqLzwZNAG1MtUAOPr3mrTtX2vSNPMP DYDbcZW6WoTXtiGoq1XdWsW/7/yar4342fbIRi94waqR9aYH3wX8xxnvxPXJkR253fLT wN8A== X-Gm-Message-State: AOJu0YwYknUxTWtZ4tcPaoXD8isTpLL9xrBYV3eqTQLhkNTunxUz4M2G 14sgGMzmIczZN0gvaIjvTqsDTZc8LyOfxNGw7RF84MjmOPXXjHlwBNhCoRiCNVKzN7UgzzenGSq j3JUygOzSQBwUvZVNezOtFAN0SlVVrU3Ft9PdC5IzojPano0OaaPOCuM5nLNa6dTmUG9pzpzpGA qigY1FusG7bFEoEg== X-Received: by 2002:a05:600c:2483:b0:40c:2ca4:1642 with SMTP id 3-20020a05600c248300b0040c2ca41642mr5863047wms.137.1703842039829; Fri, 29 Dec 2023 01:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEv21WxDaTw23XAhi0cxFBWnOwvUsofcxf8fsdcbvKhtcT+OvsaVsPvBcHLxOJqsZRMLMbHqQ== X-Received: by 2002:a05:600c:2483:b0:40c:2ca4:1642 with SMTP id 3-20020a05600c248300b0040c2ca41642mr5863039wms.137.1703842039550; Fri, 29 Dec 2023 01:27:19 -0800 (PST) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id v8-20020a05600c444800b0040c2c5f5844sm30134943wmn.21.2023.12.29.01.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:18 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv8 04/14] gdb: the extra_string in a dprintf breakpoint is never nullptr Date: Fri, 29 Dec 2023 09:26:59 +0000 Message-Id: <32a856106a7b8ed248e053a4c771f7dddcb9adb8.1703841366.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=-13.2 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, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Given the changes in the previous couple of commits, this commit cleans up some of the asserts and 'if' checks related to the extra_string within a dprintf breakpoint. This commit: 1. Adds some asserts to update_dprintf_command_list about the breakpoint type, and that the extra_string is not nullptr, 2. Given that we know extra_string is not nullptr (this is enforced when the breakpoint is created), we can simplify code_breakpoint::code_breakpoint -- it no longer needs to check for the extra_string is nullptr case, 3. In dprintf_breakpoint::re_set we can remove the assert (this will be checked within update_dprintf_command_list, we can also remove the redundant 'if' check. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 48c44ea27cc..69a6f926b4e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8535,6 +8535,9 @@ bp_loc_is_permanent (struct bp_location *loc) static void update_dprintf_command_list (struct breakpoint *b) { + gdb_assert (b->type == bp_dprintf); + gdb_assert (b->extra_string != nullptr); + const char *dprintf_args = b->extra_string.get (); gdb::unique_xmalloc_ptr printf_line = nullptr; @@ -8708,12 +8711,7 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, /* Dynamic printf requires and uses additional arguments on the command line, otherwise it's an error. */ if (type == bp_dprintf) - { - if (extra_string != nullptr) - update_dprintf_command_list (this); - else - error (_("Format string required")); - } + update_dprintf_command_list (this); else if (extra_string != nullptr) error (_("Garbage '%s' at end of command"), extra_string.get ()); } @@ -12429,9 +12427,6 @@ dprintf_breakpoint::re_set () { re_set_default (); - /* extra_string should never be non-NULL for dprintf. */ - gdb_assert (extra_string != NULL); - /* 1 - connect to target 1, that can run breakpoint commands. 2 - create a dprintf, which resolves fine. 3 - disconnect from target 1 @@ -12442,8 +12437,7 @@ dprintf_breakpoint::re_set () answers for target_can_run_breakpoint_commands(). Given absence of finer grained resetting, we get to do it all the time. */ - if (extra_string != NULL) - update_dprintf_command_list (this); + update_dprintf_command_list (this); } /* Implement the "print_recreate" method for dprintf. */