bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#2556: 23.0.91; gdb-ui sometimes messes up window handling


From: Alexandre BACQUART
Subject: bug#2556: 23.0.91; gdb-ui sometimes messes up window handling
Date: Sun, 09 Nov 2014 07:20:44 +0100

I'm bothered by this issue since years. I finally decided to take a
look. My usage of gdb in emacs is a bit different from the OP, but the
issue is almost the same.

In fact, I have gdb-many-windows set to t. I like debugging that way so
when gdb starts, I get the 6 windows layout and I keep it that way most
of the time. My issue (which in this regard is the same as the OP) is
that when I select a line in the stack frames window, the matching
source file is opened in the gdb buffer's window (the one showing gdb
command prompt at top-left on the initial layout). Any other command
leading gdb UI to show a source file does that too. This made me crazy
for years, but not anymore. Here's what I did, but first, my reasoning:

What I found is that the gdb buffer's window is not dedicated when I
launch the gdb command. If I select it and do :

  M-: (window-dedicated-p (selected-window))

The output was nil. All other GUD windows (stack, register,
breakpoint...) output t.

The fact that the gdb buffer's window is not dedicated is the reason of
this issue. So I searched for hours to make it dedicated ON LAUNCH.
Doing this after launching gdb is easy, but it has to be done each time
gdb is launched and this is very annoying.

I tried many things (gdb-mode-hook, advising functions...) without
success. As a last resort, I did something I never usually do because
it's ugly. But hey... I guess years of annoyance is enough. So yes, I
modified gdb-mi.el. Nothing big really, just a single line in the
gdb-setup-windows function, this one:

  (set-window-dedicated-p (selected-window) nil)

I replaced nil with t. And it works.

Why ? Well, I suppose that is old code assuming the selected window
holds a source buffer. But in fact it is not, at least on launch,
because you see, this function is called only in 2 places:

- in gdb-restore-windows
- in gdb-get-source-file


On launch, since my gdb-many-windows is t, gdb-restore-windows is
called. And before this function calls gdb-setup-windows, it does that
(copy-paste of the line):

  (switch-to-buffer gud-comint-buffer) ;Select the right window and
frame.

gud-comint-buffer being the gdb buffer. So when gdb-setup-windows is
called, it used (set-window-dedicated-p (selected-window) nil) on the
gdb buffer's window, not on a source file.

Now my issue is gone. BUT (and that is the reason I prefer to explain
what I did instead of providing a clean patch) I'm not sure my change
don't have bad side effects. After all, gdb-get-source-file also calls
gdb-setup-windows...

Well, that's it. In the hope that at least I clarified a bit the source
of the issue in the first place and that someone better than me in lisp
(not hard really!) will provide a clean patch, some day... ;)







reply via email to

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