# Emacs # GDB # linkage, which is the best emacs-GDB

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.