I sometimes run multiple instances of Emacs, each running a GDB session. These GDB sessions are often running different versions of the same program, or the same program with different arguments, so I'd like the frame title to indicate what program is running, with what arguments, and in what directory.
Right now I'm doing it with
(set-frame-name (format "gdb: %s (%s)" command-string default-directory))
command-string is the command line that GDB runs. But this doesn't change when I use commands such as
set args in GDB.
How can I keep the frame title automatically updated when I change the debugged file, run it with different arguments, or change to another directory?
For example, suppose I start Emacs telling it to run
myprogram foo. The frame title would initially be something like
gdb: myprogram foo (/some/path). I run
set args bar, I want this to automatically update the frame title to
gdb: myprogram bar (/some/path). If I run
file myotherprogram then the frame title should change to
gdb: myotherprogram (/some/path), and so on.
It's ok to assume that there is exactly one Gdb session in this Emacs instance and that there is a single frame. It's ok to use something other than
set-frame-name to set the frame title initially — anything that works.