From patchwork Tue Mar 5 15:21:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 86803 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 A7D1C38582A0 for ; Tue, 5 Mar 2024 15:23: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 91FB938582A2 for ; Tue, 5 Mar 2024 15:22:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91FB938582A2 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 91FB938582A2 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=1709652123; cv=none; b=sHO1ocKSCJUhMSlVRU5kyFTPJhIHDJAbB47NwHi7h9drHTB3XK1Ibbfk5lZ58LwAJ+WUSE5mthsOFDRDxAz/8iKbVGK4Mz2xa93Cki/ySkqceO5vDIsBETT3eI/FFMBMUbqYDRNFQLyP00mijceDzotDt+sro20Tf9bAE0iwIoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709652123; c=relaxed/simple; bh=iD7WX/bVcuO0vw7UkUw9eJD1yomvFEPczG9mkyrV17s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QJU2LY7Tqcqtz65HsYh/Xyh0e/88eFT0wyk00DsTBrJZgiPcqZ1m8bGsApkuMd+Je/2ucag0odSmV93Hi7b1BgwAim43CwHU31smYpfU6cy4olXXVf/RzlE/E7bg2PcBRK82PKbiagb0W2/H6kuJLv7gNInjC/gVNUZe2uznZOE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709652121; 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=ZLt+vWxMS2y0vWUboa7D6JrnkSlkbthnM/O629+lvCA=; b=crXbD3ZHJwk9ymmcB1xgb/3ML5CdPJuSxfG2YUfFUrkFC18oxmTYOYhOX9OiRwkxQFtzIX COwb5YIAm1MPvACTEK29X83kRykKV599IUppfO3PTaHTivKJEx7IC8KTIcE4nS/XPlHWsj CYcj7zLELh+fyjH5HZzsEIr39XV5l9Q= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-_R0mN8XTNtuA9cWzyP738g-1; Tue, 05 Mar 2024 10:21:59 -0500 X-MC-Unique: _R0mN8XTNtuA9cWzyP738g-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a4585db429bso91208866b.0 for ; Tue, 05 Mar 2024 07:21:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709652117; x=1710256917; 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=ZLt+vWxMS2y0vWUboa7D6JrnkSlkbthnM/O629+lvCA=; b=PRsz9cBaC2nPHXPGkmAZfwkzxdtg1JyPwsbTnd8l11fKWMeSSNBws24CNobKlBK59T ZgKnuYjnuldoqOQuahHVQWnhclr6Z86laEJqyWOo6XKeEAvKYRP2TF5l2nm8sSxoLCUN /TAZvnH8hljnVi4LP6CJ/75r3nhobWp3f6FTcTtY2FF7rd7bwUqRCaI0z6gKNAUnnB/F q1atUOQeDZlCscb3J67xMHfToBnCF9+/2doQFoMxbYpQFQ7+w3F+fPpT671644lvshMr zpYMFL4YX2AGUbOAP4HNEY62dhZxY+C8Tlk7/Qx+gkPeWAuawPZOq4eKi/96O8MntN24 upvw== X-Gm-Message-State: AOJu0YxZ4cfm8DK7+HrhMQ0hS56hOI/5l0X45U6L4KfChPeKAAn8M5JC Qsi7GcB1k0Nqalt0+/ZtGuXJDwoApx5PR88VB0s7pDpc9qGpN4sH7+rKLMqaEKYXOck8QGAjcTd 1txUezwzAb9SQH/RafYIdYaC3Zm4s6InjMYWzor1o+yAzwAMpNd1kVeISy1vio5DquTop3WlkVF 9apIhvxXOPafOk8TSKwby0uGoEzRmY2hDgLzRGAiIZJj8= X-Received: by 2002:a17:906:7f99:b0:a45:a450:ae4 with SMTP id f25-20020a1709067f9900b00a45a4500ae4mr1884101ejr.13.1709652117684; Tue, 05 Mar 2024 07:21:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrprczBzpNAk0hHiSgz0WRfTK+nrTpAqs1L4JRVpgJ6T2NfB+p9757MVsdMpLJugESIknwcw== X-Received: by 2002:a17:906:7f99:b0:a45:a450:ae4 with SMTP id f25-20020a1709067f9900b00a45a4500ae4mr1884090ejr.13.1709652117420; Tue, 05 Mar 2024 07:21:57 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id br25-20020a170906d15900b00a44fcdf20d1sm3538790ejb.189.2024.03.05.07.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 07:21:56 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv9 05/14] gdb: build dprintf commands just once in code_breakpoint constructor Date: Tue, 5 Mar 2024 15:21:36 +0000 Message-Id: <3119a0dcb07fbcb9b0232e92af308653005de7fa.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 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. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 437dd082fde..c9023a13d6c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8697,15 +8697,15 @@ 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) - update_dprintf_command_list (this); - 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) + 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. */ int loc_num = 1;