From patchwork Sat Dec 2 10:42:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 81187 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 37D0B38618EA for ; Sat, 2 Dec 2023 10:43:31 +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 B9E15386185B for ; Sat, 2 Dec 2023 10:42:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9E15386185B 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 B9E15386185B 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=1701513757; cv=none; b=IfMO37wLOck29Cbd1Jgk92GnGViRwFoZmFRJTiXevvA3ucTwTcVOs+yD9AjnmF+gIy1A3CfKD+ShhNy6MMTCMPHT6OG8jWdG4EPk2EJxORodLHvMkf/J8c0ZCyA3XEBTcT+ih05JB7prHwmR4tuHVb9VxqDWymRuG1DTX/54yL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701513757; c=relaxed/simple; bh=QHQkFkNFOx7/lqcoPsvBJiaUgGjOzihGMSQVIgMUgn0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=trW5vh8cb01qgR9rqFg6LKYkawoDnhZKhNMOzObBq8+dp+Sk1av9INe5FAOiLI3Ysm0ZzlXgUCAv/77wYdsanHGW9eqYrLqk06lQfyWqp75qQCbs23KIK0Lttdx7cCl0M/f1Yb3Ne6cZCexIdi8Lh+4Y53g+glipKnpCIU0mbOE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701513756; 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=mal5dyNF1k6kqZh0GsZhDlAQVpxmwWVC4cpw+eMBJLw=; b=DW5NDAPg+mFY0I3siavy3H/zMks+obDu16LLkXp6TZ8snWOH2r5dfdjqgRN5MzffhQzgbc j58PSqPWM7BMXdJTJlVPT6P9ktWRAAssTJaOb1gHeESMYNqgQzTMPj6cgrAEU+0kxt1wFF OastvkcduocymmtCQQCG19fnM+N14XU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-xRqvFst7NlO0wrePbk5ONQ-1; Sat, 02 Dec 2023 05:42:34 -0500 X-MC-Unique: xRqvFst7NlO0wrePbk5ONQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a1a582df193so98587066b.1 for ; Sat, 02 Dec 2023 02:42:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701513753; x=1702118553; 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=mal5dyNF1k6kqZh0GsZhDlAQVpxmwWVC4cpw+eMBJLw=; b=AyVwX1lamXUlfQ4+68gZXBKC3KoqRyBTgNP1o9OaxQ4DvH7IialoRWBnLvlA/n+Dx5 PCBM46UbRyDF1FfFB43ezSvydLee/QqrdiaSAWloGUVtTkEA0GS0PC5EehkLd0IMnTGN LhqDc1zwStzvyw0+w/KiWZdQ2wXdYKdmPhTmUpgZ+7M9IdWCXTqyfFBQZmkoMYKpFcDy xSStMvPxmlikRsvJSOyye0Hlq90uOKvq5PRvLLgZU5/zlNc20rvLVoqPTd2KnLc85tEN wFXHDzMBvTwJUXhRhlCQ/kD58AjfaxfCTXjNHoS/JCl/ACzfxdbz3Vp+I6oRqDX2/glW JifA== X-Gm-Message-State: AOJu0Yyg4RF3JhliAbolwJKnHQUm1DyavyBQxOemTVC/0c+dpMU7WUB8 BdK0GyQ8BIRoegiU1QcZVQvb8Q/uWYBSo3ZOoI+CPVjBv1o3R1ZCl7QkbbhkU9nBLhmSr6OXesf 0+63nkc+LsCmUVRmmecmP1bbfuLgWEvWPem+PN4Gfy7fVSFjsZLa8gRnEFQFiucfzgjiA52Ssrf 0OEzZMDA== X-Received: by 2002:a17:906:714e:b0:a0e:3ba4:4eac with SMTP id z14-20020a170906714e00b00a0e3ba44eacmr3081565ejj.27.1701513753145; Sat, 02 Dec 2023 02:42:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8OCI5UJ1UM6NVAHTFz5VvFVf1RMsPgo8QTLk1FJCPBimQUVdQEXBOFKkO7S0oxTefpNuQXw== X-Received: by 2002:a17:906:714e:b0:a0e:3ba4:4eac with SMTP id z14-20020a170906714e00b00a0e3ba44eacmr3081557ejj.27.1701513752934; Sat, 02 Dec 2023 02:42:32 -0800 (PST) Received: from localhost (92.40.184.5.threembb.co.uk. [92.40.184.5]) by smtp.gmail.com with ESMTPSA id l15-20020a170906a40f00b0098ec690e6d7sm2892636ejz.73.2023.12.02.02.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 02:42:32 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv6 04/10] gdb: build dprintf commands just once in code_breakpoint constructor Date: Sat, 2 Dec 2023 10:42:12 +0000 Message-Id: <3c240e1430759e5bdf78207106d79207a92c5f44.1701513409.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=-8.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_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, 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 I noticed in code_breakpoint::code_breakpoint that we are calling update_dprintf_command_list once for each breakpoint location, when we really only need to call this once per breakpoint -- the data updated by this function, the breakpoint command list -- is per breakpoint, not per breakpoint location. Calling update_dprintf_command_list multiple times is just wasted effort, there's no per location error checking, we don't even pass the current location to the function. This commit moves the update_dprintf_command_list call outside of the per-location loop. I have also changes the 'if' that handles the case where the extra_string (which holds the format/args) is empty. I don't believe that this situation can ever arise -- and if it does we should be catching it earlier and throwing an error at that point. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c629d27c4c0..c1440a6921f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8704,19 +8704,17 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, /* Do not set breakpoint locations conditions yet. As locations are inserted, they get sorted based on their addresses. Let the list stabilize to have reliable location numbers. */ + } - /* 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")); - } - else if (extra_string != nullptr) - error (_("Garbage '%s' at end of command"), extra_string.get ()); + /* Dynamic printf requires and uses additional arguments on the + command line, otherwise it's an error. */ + if (type == bp_dprintf) + { + gdb_assert (extra_string != nullptr); + update_dprintf_command_list (this); } + else if (extra_string != nullptr) + error (_("Garbage '%s' at end of command"), extra_string.get ()); /* The order of the locations is now stable. Set the location condition using the location's number. */