From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AD59IfBLlGTq0QoAWB0awg (envelope-from ) for ; Thu, 22 Jun 2023 09:26:08 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=JrMxyK69; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8545B1E0BB; Thu, 22 Jun 2023 09:26:08 -0400 (EDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7501F1E0AC for ; Thu, 22 Jun 2023 09:26:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 070643858408 for ; Thu, 22 Jun 2023 13:26:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 070643858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687440366; bh=rMKc3qycclIMhPAmB4AWxk3mPw4BhpsdpRcRJe/c9/A=; h=To:Cc:Subject:In-Reply-To:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=JrMxyK69yrkJPsoFaOkUwfMCQrY5aSBAOQc8a8MtPcMCNbh/PHxIkkQWatL4ZaIG2 bIVaOJ0ktX/LJae+JbAu7A8Shwp6GaiJOpoKZnbr3Hj84A/BnNI+vNiMxrqxoWrAXm EErDzLuGC070pxaQyLOu1kKAv6q3i/LcSWd0QlHY= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 290563858C53 for ; Thu, 22 Jun 2023 13:25:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 290563858C53 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-354-KDscrVYwP1Ol_OLZija55g-1; Thu, 22 Jun 2023 09:25:44 -0400 X-MC-Unique: KDscrVYwP1Ol_OLZija55g-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f9d7ff4b6aso5952915e9.1 for ; Thu, 22 Jun 2023 06:25:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687440342; x=1690032342; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rMKc3qycclIMhPAmB4AWxk3mPw4BhpsdpRcRJe/c9/A=; b=XLedof45CZw2p6CK/6h9z3hgHh508Ez6GBhLqISo6Qlg2IwBsaIZ4BHmDdtdhhb8pM 9DDu0b6bGKHKybnUDKX/Ap1M78NF0IzRKeLOvqH2VzDpSKhpn0pjsoC11GwkR1THX7Q9 AKy2S/RrAPvEKHD3Y3Z9uX3QmHgmgq0h06mbZoL/vHhqNwAA/aVpQ44xWdUp+7AO98E5 c3XniPelIGwAW5pj1negcOrAEoETs0lXrWabtOWyZgq5Nm0SVCvYmaCB6X0lz1zp9BBU DFC70RlvfoCjkzzjN1C0gtAA7L94IbLQo9wZlVbpusuW/Co2npMVG1nWSsMctP9na4Nd 1JqQ== X-Gm-Message-State: AC+VfDyh1Qq7jYhcntGRRfWs+U2Te0GKtWK47pWnbMQM5y4ewouzBmbb f44+ONyrKc8r8NUKkP0PePRyivu09f5hYaAPCmOwPaJgKiWv6hg4p5+l1NikzgUVCYW9gJVZIW7 7Un2+xI9K0NRmZlmdikTv3rsbdu6BXXjyKHMdMDqxOQyH/WFGWv3+CY+zvjdr5TM43nqCChhX9P kRlZ9VVQ== X-Received: by 2002:a05:600c:2113:b0:3f9:b4b5:e000 with SMTP id u19-20020a05600c211300b003f9b4b5e000mr7348230wml.23.1687440342093; Thu, 22 Jun 2023 06:25:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46Qs6pzkyTJbTNDpjgHCr/ku2ho5OWQguBSG7qkpzDScLg0r8kM7zoLvvSnDOIQwK66jGMbA== X-Received: by 2002:a05:600c:2113:b0:3f9:b4b5:e000 with SMTP id u19-20020a05600c211300b003f9b4b5e000mr7348069wml.23.1687440337995; Thu, 22 Jun 2023 06:25:37 -0700 (PDT) Received: from localhost (2.72.115.87.dyn.plus.net. [87.115.72.2]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c220b00b003f819dfa0ddsm7693615wml.28.2023.06.22.06.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 06:25:37 -0700 (PDT) To: Bruno Larsen via Gdb-patches , gdb-patches@sourceware.org Cc: Bruno Larsen Subject: Re: [PATCH v3 1/4] gdb/cli: Factor out code to list lines for the first time In-Reply-To: <20230621104545.2530552-2-blarsen@redhat.com> References: <20230621104545.2530552-1-blarsen@redhat.com> <20230621104545.2530552-2-blarsen@redhat.com> Date: Thu, 22 Jun 2023 14:25:36 +0100 Message-ID: <87bkh7tyr3.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.9 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_H5, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Bruno Larsen via Gdb-patches writes: > A future patch will add more situations that calculates "lines around a > certain point" to be printed using print_source_lines, and the logic > could be re-used. As a preparation for those commits, this one factors > out that part of the logic of the list command into its own function. > No functional changes are expected > --- > gdb/cli/cli-cmds.c | 34 +++++++++++++++++++++------------- > 1 file changed, 21 insertions(+), 13 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index 638c138e7cb..b0b9c08c2ec 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -1200,6 +1200,26 @@ pipe_command_completer (struct cmd_list_element *ignore, > we don't know how to complete. */ > } > > +/* Helper for the list_command function. Resets the location to be printed > + to the line where the inferior is stopped, then prints the lines. */ Is this comment correct? It says "... to the line where the inferior is stopped", but actually appears to list lines around CURSAL. Given this isn't a command entry point then you should probably document what ARG is expected to contain. Thanks, Andrew > +static void > +list_around_line (const char *arg, symtab_and_line cursal) > +{ > + int first; > + > + first = std::max (cursal.line - get_lines_to_list () / 2, 1); > + > + /* A small special case --- if listing backwards, and we > + should list only one line, list the preceding line, > + instead of the exact line we've just shown after e.g., > + stopping for a breakpoint. */ > + if (arg != NULL && arg[0] == '-' > + && get_lines_to_list () == 1 && first > 1) > + first -= 1; > + > + print_source_lines (cursal.symtab, source_lines_range (first), 0); > +} > + > static void > list_command (const char *arg, int from_tty) > { > @@ -1221,19 +1241,7 @@ list_command (const char *arg, int from_tty) > source line, center the listing around that line. */ > if (get_first_line_listed () == 0) > { > - int first; > - > - first = std::max (cursal.line - get_lines_to_list () / 2, 1); > - > - /* A small special case --- if listing backwards, and we > - should list only one line, list the preceding line, > - instead of the exact line we've just shown after e.g., > - stopping for a breakpoint. */ > - if (arg != NULL && arg[0] == '-' > - && get_lines_to_list () == 1 && first > 1) > - first -= 1; > - > - print_source_lines (cursal.symtab, source_lines_range (first), 0); > + list_around_line (arg, cursal); > } > > /* "l" or "l +" lists next ten lines. */ > -- > 2.40.1