One last note: I normally use emacs in terminal mode, but couldn't do
that inside gdb (for obvious reasons). Some of the behaviors I observed
before -- including seg faults -- may be terminal-specific, and some of
the new strangeness I'm pointing out now may be X11-specific... or it
might just be the difference between -O0 and -O2.
What do you mean by "terminal mode"? Do you mean you run emacs under
mintty? Or do you run it under xterm with the -nw switch? And could
you elaborate on the "obvious reasons"? I don't see why you can't run
emacs in a terminal under gdb; or attach to it from a different
terminal if that's more convenient.
I usually run under mintty with -nw. When following the instructions in
that /etc/DEBUG file you pointed me at, the .gdbinit included
breakpoints and other pre-main intializations to perform that would not
happen if I merely attached to a running emacs. However, that will
probably be my next attempt, since the X11 route didn't pan out (and I
dislike using the graphical version).