|
From: | Yuan Fu |
Subject: | Re: Extend gdb to filter registers |
Date: | Sun, 19 Jan 2020 20:22:38 -0500 |
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.
Yuan |
[Prev in Thread] | Current Thread | [Next in Thread] |