Due to the recent in-depth Android ndk development, I had to deal with the command line GDB-Eclipse is too slow to connect to GDB!
I think it is always inappropriate to use Gud to manipulate ndk-GDB in Emacs. Therefore, the command line method is used instead.
The call stack created by the Bt (backtrace) command is always copied from terminal to Emacs again.
I spent more time thinking this day and wanted to use the define command to display the call stack to the buffer of Emacs at one time.
Define is not the best GDB extension method, because there are now Python GDB extension interfaces. It is a pity that the gdb experts in the team do not have time to compile for me.
With-Python GDB.
After reading several info documents, I found that the logging command can be used to output the content of GDB to Emacs. This simple and strange useful script is as follows:
Define gobt set logging file ~ /. GDB. BTT set logging overwrite on set logging Redirect on set logging on Bt set logging off shell echo \ # local variables: \ # >> ~ /. GDB. BTT shell echo \ # mode: Compilation \ # >> ~ /. GDB. BTT shell echo \ # End :#>> ~ /. GDB. BTT shell emacsclient-n ~ /. GDB. bttend
If the Emacs server is started, an interactive call stack is generated. When you press enter, you can jump to the corresponding call location to viewCode.
Another command is simpler:
Define EB source ~ /. GDB. lineend
Its strength lies in its cooperation with the following Emacs LISP:
(Defun Jr-debug-line () (interactive) (LET (FN buffer-file-name) (Ln (line-number-at-Pos ))) (With-temp-buffer (insert (Format "B % s: % d" FN ln) (write-region (point-min) (point-max )"~ /. GDB. line ") (kill-New (Format" B % s: % d "FN ln) (Global-set-Key (KBD" C-c B ") 'jr-debug-line)
In this way, you can see that the file is broken in Emacs!
The last setting is the editor environment variable. To use Emacs to view the current row of GDB, the correct setting is:
Export editor = "emacsclient-n"
At this time, the ED (IT) Command will send you to the current row of the current frame of GDB.
A half-duplex debugging environment is complete. When tui's C-x C-A is not enough, Ed is an artifact.
P.s: The back trace generated by gobt can be saved to any location and can be viewed at any time. This is more powerful than eclipse and intelij.