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.129.124]) by sourceware.org (Postfix) with ESMTPS id 716CB385840C for ; Tue, 30 May 2023 20:47:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 716CB385840C 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=1685479627; 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=+bs40666ydHhaT0Mz1M2KwV8r3QzFN4GYbUN4/QbHOw=; b=YzMWaXdL9eWe67585gft86n2tUlOY4n5M3omLs9kuCw3TxGm1isbYH6gCnmUMDEw4NPiXS 03/FjBrAVCGnBflI2ELpKKcqX3bCUvRTbNmecS7tYJUg/2VlCgZqlX8O+ui3G7rERNQVZT 4G0uaxxuxYGpFMy7XqFkQhdSLU2ZHCk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-5Fv3OVNkPAWStVMNPiynPQ-1; Tue, 30 May 2023 16:47:05 -0400 X-MC-Unique: 5Fv3OVNkPAWStVMNPiynPQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f5ec8aac77so31070625e9.3 for ; Tue, 30 May 2023 13:47:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685479624; x=1688071624; 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=+bs40666ydHhaT0Mz1M2KwV8r3QzFN4GYbUN4/QbHOw=; b=DkMCQiu7ww5rUd73rQA1yqKdi7yCzKNX3g0oyaKfdy0XNwagmucv7sXxHS6fPvnuOe NLOvz7gelMiDhP/zv5v0pOnwNHhKJGtTu7rUYdzQvnFEecs1IiPvKnYra9DYMUi9ZIzI uCilPx3obN4Q5W2xRSiW+etlJan0eDGxzRP20XDLa907MV5nkHa8kAV35jh5f9U+X7Hm WZczj++vuTTf+EuYZ5BlyZTjXhHRpZxzNssQMd67V+YRLoKsSHudEQc0yn+PqTucg78B o1E/iBb+h4Qp1mz2BSXU76JzzS6NSHbbaAOvzut8NP6tCceAIm0+fhAolsRNf8y0SWXl rB7w== X-Gm-Message-State: AC+VfDx+dtrdWPY4/TOq/ks3vmUd1pSreZBTYEDhoiV1yT7TDbl8Mje9 lA+S+LRPvps3iQhzNTd1HiNHCIkAw31oVhYNMNNUeIa5JK1y3GxXyZJu7m3BDguckoNKioOGVDS gDAVgggiIQtx0hCB3QeJPjeXUtWVMa8pgfyiOmz8ReLCrMu8YJ62ddZWTsqY9DjBWREqL47VZJ4 KocVfOuA== X-Received: by 2002:a7b:cd15:0:b0:3f4:e7c2:607d with SMTP id f21-20020a7bcd15000000b003f4e7c2607dmr2515829wmj.13.1685479624270; Tue, 30 May 2023 13:47:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5e2JYWnvqw81O34Rcxpt2vVZBQTp9HU0ulMllwoQ0OYEpFtv0PqbuUizvhXDRvu8mtJCMqWQ== X-Received: by 2002:a7b:cd15:0:b0:3f4:e7c2:607d with SMTP id f21-20020a7bcd15000000b003f4e7c2607dmr2515822wmj.13.1685479623991; Tue, 30 May 2023 13:47:03 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id a10-20020a05600c224a00b003f4247fbb5fsm21860297wmm.10.2023.05.30.13.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 13:47:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 4/9] gdb: build dprintf commands just once in code_breakpoint constructor Date: Tue, 30 May 2023 21:46:48 +0100 Message-Id: <093c41c52d00f086f5adc9b87826d1d89bdca2a1.1685479504.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.8 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 List-Id: 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 2cadc8c0295..4eb40c01274 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8517,19 +8517,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. */ -- 2.25.4