Emacs gdb, "-i=mi" option seems to disallow additional arguments - emacs

I tried M-x gdb RET gdb -i=mi --args myexec -d 2 -tl 10 -ba 100
Error: you did not specify -i=mi on GDB's command line!
Is there something wrong with my syntax here? I usually run gdb exactly like that but without the -i=mi flag. I can ofc just run it without args and specify them at the gdb prompt, but that seems annoying to do since I want to be able to launch the debugger with a key binding...

Related

Opening emacsclient in terminal works but won't work with Automator

So I'm getting some pretty strange behaviour when I try to use an Automator service to open new emacs (GNU Version 25.2 with spacemacs) buffers.
In my terminal, the command emacsclient -a '' -c works as expected, opening a new buffer through emacsclient. However, when I make a service in Automator which simply runs a (/bin/bash) shell script:
emacsclient -a '' -c
I get an error message:
The action “Run Shell Script” encountered an error: “emacsclient: could not get terminal name”
On suspicions that this was due to Automator not using some default PATH variable, I tried the following instead:
PATH=/usr/local/bin:$PATH
emacsclient -c
which produced the same error as before.
Next I tried
PATH=/usr/bin:/usr/local/bin export PATH;
emacsclient -c
which produced a different error message:
The action “Run Shell Script” encountered an error: “emacsclient: invalid option -- c
Try `emacsclient --help' for more information”
however why I try that script in my terminal it also gives a similar error which doesn't make much sense to me.
If anyone has suggestions for how to fix this I'd really appreciate it.
The problem is the shell script is running an old version of emacsclient in /usr/bin you need to run the one in Emacs.app/Contents/MacOS/bin/emacsclient. Delete the PATH line and you can use a solution listed here for running emacsclient inside automator Running a macOS service for open with emacs failed with "emacsclient: could not get terminal name mac"

How to use the "command" command when using gdb in emacs?

I use gdb in emacs.
The "command" command is used to set commands to be executed when a breakpoint is hit.
It should return when I type "end" as below, but nothing happened.
But when I use gdb in shell, it is ok.
So who can tell me why?

Emacsclient crashes when evaluating window functions

To not bore anyone here with specifics, whenever I evaluate an expression similar to this one:
emacsclient -t -e '(set-buffer *scratch*)'
the client will flash up on the terminal and crash.
This seems to be happening with all window-changing functions. Is the client not supposed to work like that? Running this in a normal emacs session does not cause this problem.
You're also using -t, but I'm not exactly sure why.
Is your emacs running in another tty session?
Or is your emacs running in windowing mode (e.g. on X Windows)?
If I have emacs running in windowing mode and I run the following command from another xterm window, then everything works exactly as I would expect it to:
emacsclient -c -e '(set-buffer "*scratch*")
Note in particular the -c option, and the fact that the buffer name is a string and so must be enclosed in double-quotes.

Define default compile command in Emacs

I have a project that uses a bash script to invoke cmake and make. I have successfully used this script from Emacs by using M-x compile, followed by typing:
cd ../..; ./build.sh
in the minibuffer. (The project organization is top/src/various_source_folders and build.sh is in top/.)
I am trying to define a directory variable to specify the default command to use for compile. I have tried the following (both with single or double quotes around the compile command) in .dir-locals.el:
((c++-mode
(compile-command 'cd ../..\; ./build.sh')))
Which gives no errors, but M-x compile still defaults to make -k.
((c++-mode
(set-variable 'compile-command' "cd ../../\; ./build.sh")))
Which gives a warning about unsafe variables. Even if I choose apply, compile still defaults to make -k
Simply using M-x eval-buffer with the second line ((set variable...) in *scratch* correctly sets the compile command.
Is there a different way I can/should be doing this?
Found an answer here.
Two periods and some parenthesis were missing from the syntax:
((c++-mode
. ((compile-command . "cd ../../\; ./build.sh"))))

remote debugging emacs 24 and gdb

I have code on a compute node of a cluster. I can't ssh directly to the compute node so I first set up an ssh tunnel with
ssh -f cluster.master.node -L 2222:cluster.compute.node:22 -N.
Next I visit the file with
C-x C-f /ssh:user#localhost#2222/path/to/blah.c.
Finally I do
M-x gdb.
In emacs 23 I would do
Run gdb (like this) gdb --annotate=3/ssh:localhost#2222:/path/to/program
but documentation for the gdb function in emacs 24 says "The command-line
options should include -i=mi to use gdb's MI text interface. Note that the old "--annotate" option is no longer supported."
Running
gdb (like this) gdb --i=mi /ssh:loalhost#2222:/path/to/program
seems to work, but when I try to run the program I get "Starting program: /misc/home/joey/git/proteus/proteus /dev/pts/5: No such file or directory." The problems seems to be with the non-existent /misc/ directory prepended to the path of the executable. Even when I do a cd to /home/joey/git/proteus/ the response is "Working directory /home/joey/git/proteus (canonically /misc/home/joey/git/proteus)."
Can I remotely debug my program in Emacs 24 or should I go back to 23?
Try M-x gud-gdb RET: it will give you the old Emacs-22 behavior.