[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extend gdb to filter registers

From: Yuan Fu
Subject: Re: Extend gdb to filter registers
Date: Sun, 19 Jan 2020 20:22:38 -0500

I mean when gdb-display-source-buffer will fail to find the source

I dug into gud.el and gdb-mi.el to see what’s really going on. It’s not very straightforward. Let me present my understanding of the logic below. Please correct me if I’m wrong.

First, “frame” in gud is a cons of file name and line, basically at where gdb stops (file:line).

When gud needs to display the current line at where gdb stops at (“frame”), it tries to display it in a new window if the target buffer is not already shown. `gud-last-frame` is set to the frame we want to display, and we call `gud-display-frame` to display it. `gud-display-frame` calls `gud-display-line` calls `display-buffer` with `(inhibit-same-window . t)`. Then it sets `gud-last-last-frame` to the frame just displayed, and `gdb-last-frame` to nil. So `last-frame` is basically the frame to be displayed, and `last-last-frame` is the last displayed frame.

As for gdb-mi, in `gdb-display-source-buffer`, it first looks for the window displaying `gud-last-last-frame` (last displayed frame, that is). If that doesn’t exist, it looks for `gdb-source-window` and use that. Either way it sets the window found to `gdb-source-window`. And it returns nil if no last-last-frame window nor `gdb-source-window` is found. How can `gdb-source-window` be set? There are two ways, 1) when gdb-mi starts with many-windows or show-main option, it opens a source window and set that to `gdb-source-window`, 2) if `gdb-display-source-window` finds a window displaying `gud-last-last-frame`, that window will be set to `gdb-source-window`. 

Gdb-mi also uses `gud-display-frame`: when I type commands in comint buffer, the result from gdb is handled by `gdb-frame-handler`, which sets `gud-last-frame` and calls `gud-display-frame`.

So, commands like step, next, etc, uses `gud-display-frame`. Except that `gdb-goto-breakpoint` uses gdb-display-source.

So it seems the intension is to display source in new window, not using only one window as I originally thought. I’d like to simplify it, put the decision logic into one place. And then we can add customizability to it.

It shouldn't harm to try that.  I'd still make it optional - maybe
someone wants to see the other buffers.

I tend to agree with the last bit.

At the very least I want to fix the inconsistency in gdb-mi — goto-breakpoint uses `(or
gdb-display-source-buffer display-buffer)` and gud-display-line uses `display-buffer`. We can modify the
display logic to allow user customization once gdb-mi is consistent within itself.

Let's add a defcustom to control this new behavior.

Do you mean options like `only-one-window`, `switch-between-two`, `as-much-as-possible`?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]