From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from latitanza.investici.org (latitanza.investici.org [82.94.249.234]) by sourceware.org (Postfix) with ESMTPS id 916863858C60 for ; Tue, 21 Dec 2021 22:14:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 916863858C60 Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id 4JJW2v4KY9zGp4K; Tue, 21 Dec 2021 22:14:31 +0000 (UTC) Received: from [82.94.249.234] (mx3.investici.org [82.94.249.234]) (Authenticated sender: andrea.monaco@autistici.org) by localhost (Postfix) with ESMTPSA id 4JJW2v3F8SzGp4C; Tue, 21 Dec 2021 22:14:31 +0000 (UTC) From: Andrea Monaco To: dblaikie@gmail.com Cc: gdb@sourceware.org Subject: Re: gdb displaying only one line of instructions when stepping In-Reply-To: CAENS6EudpGD+52w4GF=DdUQ9MbDy7-u=BRnqkhx1ox1i6Y0=iQ@mail.gmail.com Date: Tue, 21 Dec 2021 23:14:30 +0100 Message-ID: <87bl19hagp.fsf@autistici.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Dec 2021 22:14:35 -0000 > Though ultimately the DWARF format itself would probably need to be > improved to describe source ranges (maybe even non-contiguous ones) > and a preferred location - then then + operation could be described > as the whole range of "x + y" with a specific location of '+', and > the assignment could be the whole range of "a = x + y" with a > specific location of '='. I looked up DWARF format a bit using the dwarfdump utility. I see that DWARF records the line number of each new instruction. Changing the format would be a lot of work; but maybe some kind of heuristics might do the job. When single stepping, gdb could display all lines until the following instruction, excluding it, and also excluding blank lines and (perhaps) comments immediately before it. As another rule, it might stop immediately (like it does now) when the current line is, or includes, the closing bracket of a function. (I saw that gcc records the closing bracket as a separate instruction, even when it is on the same line as the last instruction of the function.) This heuristics may give reasonable results in many cases, or be a starting point. What do you think? Andrea Monaco