From patchwork Tue Mar 5 15:21:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 86804 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 E1D7E38582A0 for ; Tue, 5 Mar 2024 15:23:29 +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 7249B3858C54 for ; Tue, 5 Mar 2024 15:22:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7249B3858C54 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 7249B3858C54 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=1709652122; cv=none; b=a4DRT7+Y64+ixDd+PhvwyQm+Zy1SEpVAnYsmA6GzJEs6SjZObTejQ0Wp2DFjLCbQ2s70uRq+t8PWFt1/hOYViRNZp/WqCNwNZXkT5r/alg9PLjgM/7CiAwV/8mIRIEFhnh7/GRDXWdkz72JOOCh269Xn4VG0EFcm9KMzQBFYCP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709652122; c=relaxed/simple; bh=xX7gfp+q9hvQhOrQAgQWEDuPG9t4nDuVZd4bHZnpsBQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GMbBTOZOHFpClXL7E+kA+4csZXUQgI8sDOXCbQouUvdWLGbpIF14urgXY1m3U1uQWpQvTgXJsktQAPcX6amnGmOLGS89xYAbCEY3iZDmxQz0f2DEh9AMX6odDp7Nox5Ds6STiNnaMDnoU5Iq7xSQoitPTKfakdCSHMl/LlGCHag= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652120; 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=gviLLqmFEPp0wOPb6mrZPYmYc6aU483ORr20Nve4/p4=; b=FzDpUNvgwLyuohfB+RJRBlbHEa74DLKaxx/0dR/MgzaiLPkgSZQFRqfbVOzpjk6No8wLOC kDIV8dBxBGXgZ5q1nME4sXCQk7B3dF6bVEWsvtQy9h6rJrlRMHqbaqoI8afJDVEIofxp2N knbLD94jgY8Fzabgv+P+21aNrzTVynk= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-q2FdICCyMNGhvlGV5OXb0A-1; Tue, 05 Mar 2024 10:21:58 -0500 X-MC-Unique: q2FdICCyMNGhvlGV5OXb0A-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-51345bb1c89so2746575e87.1 for ; Tue, 05 Mar 2024 07:21:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709652116; x=1710256916; 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=gviLLqmFEPp0wOPb6mrZPYmYc6aU483ORr20Nve4/p4=; b=f1cxxN8/I4Zj6h39aBry+qAyGaUJ84nSuNVIfnYNuhk9rRRzuU7LGzB4XGMX3UwPty xPquBNw4LeNgJRjALz58wtwdjMU5uSypF0Nu+1Cb7Z+hYQNdJc8qe+v9Z6E1sUisTtVp vkMIzHMmk2ekdTQ6K2zFy0M6PG0YRmfuf1G9G4UG2tdw+nZpOeYX2GypgZcNIFUy4yW8 vTj/NglWk8YuSrRaikAzAJ6lq5P6nSFQJMkaOzvW6KVsQ7RU4+Ce/dGX9jqNWCechf61 8DmUi1bfMDMy5IyevaOjsH1Edzasm17mAFtzcD8n7xzIctgKpa1w60XkJus+kMqccCnk fr1w== X-Gm-Message-State: AOJu0Ywi8wQDtzOfxzoDuywUYVHK2xFd9wYIOEFCNz++tszg0+pnqqP+ 4LtGC0kQ+Bh+IoCGhYn8DfM/eQEBKl4XRTekSyLeiTimVuRNHm3r57TPFCg9xx4/Gczf6gBuxG9 AKQK7G2CtJeW23eyr32jSyS8a4zG4tRE1zsVkP8+bE8SlI7qB/lI/jF5VEQXXHT4QcX/hGWjEIM /e6CfBV7lokZyAWUvaGzjEb1qMF/IBmsDgQTR0uM9OZbc= X-Received: by 2002:a2e:9dcb:0:b0:2d3:f0e7:6bcd with SMTP id x11-20020a2e9dcb000000b002d3f0e76bcdmr1569059ljj.40.1709652116648; Tue, 05 Mar 2024 07:21:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFatV/LK7DIyMuOfUXNlcZjpnXd6wT5P5v1HOqCKbUZQ6XSiQA4qgAyndvd8ScDx5UH/6Dl6Q== X-Received: by 2002:a2e:9dcb:0:b0:2d3:f0e7:6bcd with SMTP id x11-20020a2e9dcb000000b002d3f0e76bcdmr1569045ljj.40.1709652116274; Tue, 05 Mar 2024 07:21:56 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id z6-20020a05640240c600b005670d2c253csm3751395edb.13.2024.03.05.07.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 07:21:54 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv9 04/14] gdb: the extra_string in a dprintf breakpoint is never nullptr Date: Tue, 5 Mar 2024 15:21:35 +0000 Message-Id: <4f415e1a1abea8d9b4e9e8c8837dd7e17097a005.1709651994.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=-12.3 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.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 a7b516ab26c..437dd082fde 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8525,6 +8525,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; @@ -8698,12 +8701,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 ()); } @@ -12419,9 +12417,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 @@ -12432,8 +12427,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. */