From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by sourceware.org (Postfix) with ESMTPS id 538C23858C60 for ; Tue, 21 Dec 2021 22:55:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 538C23858C60 Received: by mail-yb1-xb2c.google.com with SMTP id v64so836834ybi.5 for ; Tue, 21 Dec 2021 14:55:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bL5AUTkJITskiQAO+iI+tKIRLJdDaSxvcF9U6h8BnzA=; b=rUGLr8OL7PAZokENS8Ic2WUhExQ+naX+R1D70qpvvjDV65gsrENVdQslDwWq0+4GTO jH7n+mKyHWHBVOM7V838s0hL/7+RDMrYE5RClF74WePLlFajTE6reFirNp0z4dNL6vKU O3KsyDWZEMNhA+r9hQ9fJ2Ck2kaOrhEz6xRxRHOIdk44TOBwWv6HFHQGwZMPqT0uiyIc 9iBKEMwrQEwh+eK1mrwxqkMzAc/Z/HQ3K1mW74GDWPwp6KvA9NeGwJEFucpG1YdNtgjF awt8c8HiYmgmnnEWZ3P6ndHv+2+EhjstT6w1r3Io8aVKDIIdc1/7K1/ZbTGgnE58VvKb mCsQ== X-Gm-Message-State: AOAM532NkPbKElzjzEDPOYnj8ieqtIBxHY4l24XRa89zNFT8QWi69N+k X5ozIf6znRiRvgLfUqRwRIgp0fUBFli9AM/v8tpVeH15 X-Google-Smtp-Source: ABdhPJwuH4ko+J1J86/KTEjlzFJHASNA3tEei8owhryctqmQcfqo72NECJzrGtyQY8ZeC+gDEKAXnWcxeX7FfLRiDgY= X-Received: by 2002:a25:2c92:: with SMTP id s140mr740492ybs.308.1640127300750; Tue, 21 Dec 2021 14:55:00 -0800 (PST) MIME-Version: 1.0 References: <87bl19hagp.fsf@autistici.org> In-Reply-To: <87bl19hagp.fsf@autistici.org> From: David Blaikie Date: Tue, 21 Dec 2021 17:54:49 -0500 Message-ID: Subject: Re: gdb displaying only one line of instructions when stepping To: Andrea Monaco Cc: gdb X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:55:03 -0000 On Tue, Dec 21, 2021 at 5:14 PM Andrea Monaco wrote: > > > 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; ^ Yeah, for sure. Would be quite a bit of work. > but maybe some kind of heuristics might > do the job. > Possibly - that gets into the realm of design judgments that I'm not qualified to make much of an assessment of, as I don't work on gdb generally (I mostly work on clang's debug info emission) 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. > Hmm, maybe? Not sure how that'll compare between Clang and GCC's (or other compiler's) choice of source location for expressions, or how it might break when macros or other things are involved (where the line may not move forward in a regular way).. At least with Clang's debug info, if you did this - it might not ever trigger, because the next instruction will often be at a previous line (as in the `a = b + c` example - the next line location after the '+' would be earlier, at the '=' - I guess a direction agnostic definition could be used and so in: 1: a 2: = 3: b 4: + 5: c gdb could show lines 3 and 4 when stopped at '+' and, could show lines 2, 3, 4, and 5 when stopped at '='? That might be a bit uncomfortable/haphazard to the user. Not sure what GCC's line table looks like/how it'd appear - I /guess/ if it always use the start of the subexpression, then it'd show line 2 and 3 for the '+' (which might be pretty confusing, since that'd include the '=' line, but not include the '+' line) and then include lines 1-5 for the '='. > 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? > Might be something that could be done - but I worry it'd be more confusing than helpful. Maybe changing the default number of lines of source the debugger shows from 1 to 3 or something, to provide a bit of context rather than just a single line, would be sufficient?