Source browsing using emacs and etags
To work on the code the first time
- Use
C-x 2 or C-x 3 to split the windows into sub-windows vertically or horizontally
- Use
C-x C-f to open a file
- Use "etags -R *" in command line to get the TAGS file for browsing the code
- Use
M-. to find the definition for a symbol (variable or function and so on) and use M-* to jump back
-
C-u M-. to find remaining ones
-
M-x tags-apropos to list all tages that match REGEXP
- Use
grep symbol_string * -n to find all occurrences of symbol_string in the current directory
You don't need to re-generate the tags each time starting emacs. Below is how to generate the tags through the command line and then load them when needed.
- generate the tags
- the basic syntax is
etags input_files, the tag table is in TAGS
- if you have many files in sub-directories you can use
- if you use absolute file names, then you can move the TAGS file to another directory
- loading the tag table
-
M-x visit-tags-table
- to load a table automatically when starting emacs
-
(setq tags-table-list '("file_path"))
See the following for more information
- man/info etags
-
info emacs, search for tags
-
etags --help gives the list of options including default suffixes for languages
Debugging using emacs and gdb
-
M-x gdb file_name
- use
break [file:]func_name to set a break point
-
break [filename:]linenum to stop at a line
-
break ... if cond to stop only when cond evaluates to true
-
info break to print all breakpoints
- for other commands see Debugging with GDB by Stallman, Pesch, Shebs, et al.
- you can set watchpoints and disable, enble or delete these points.
- you can examine the stack and data and change the value of variables