emacs filenamewhere filename is the file you want to edit.
Once you are in emacs, the top menu bars offer the four sub-menus:
Buffer File Edit HelpThe sub-menu Buffer allows you to switch between different files that you are editing. The sub-menu File contains commands on how to open another file, save files, exit emacs, etc. For example, to open a new file, just click the File button and the Open File... option, the cursor will then jump to the minibuffer at the bottom of the screen; you can type in the file name, the one which you want to open, and type the "return" key.
Alternatively (preferred by most people), you can use the key bindings to do most of these and more.
Use the arrow keys to move the cursor C-x C-f open a new file C-x C-s save the current file C-x C-c exit the emacs (but save files first)
C-a go to the beginning-of-line C-e go to the end-of-line C-n go to next-line C-p go to previous-line C-k kill the current line C-o open-line The following two bindings are CS210 specific: C-x C-g go to a specific line numbered x C-x C-w show (in the minibuffer ) the current line number
ESC f forward-word ESC b backward-word ESC d kill-word ESC DEL backward-kill-word
C-f forward-char C-b backward-char C-d delete-char DEL delete-backward-char C-q quoted-insert C-t transpose-chars
C-space set a region mark C-w kill-region (between cursor and mark) ESC-w memorize the contents of the region (without kill) C-y yank (i.e., insert text last killed or memorize)
C-l recenter C-v scroll-up (forward) ESC-v scroll-down (backward) ESC < beginning-of-buffer ESC > end-of-buffer
C-s isearch-forward C-r isearch-backward
C-x C-f find-file C-x C-r find-file-read-only C-x C-s save-current-file
C-x 1 delete-other-windows C-x 2 split-window-vertically C-x 4 f find-file-other-window C-x o other-window
ESC ! shell-command ESC x compile compile ("make -k" is default) C-x ` next-error (used after "compile" to find/edit errors)
C-x C-c save-buffers-kill-emacs C-u universal-argument C-x C-z suspend-emacs (resume by typing "fg" to unix)
C-g keyboard-quit C-h help-command C-h t help-with-tutorial C-h b describe-bindings (complete list of emacs commands)
The cursor initially is placed after the gdb prompt (gdb). Whenever you want to issue a command to gdb, position the cursor at the end of the buffer, i.e., after the (gdb), and type the command as usual. The command ESC-> gets you to the end of the buffer. To examine previous input or output to gdb, use the usual emacs commands to move around the buffer.
Whenever your program, which was running under gdb, stops because of a breakpoint an interrupt, etc., the source code associated with the current locus of execution is displayed automatically in the other window. A marker, =>, points to the specific line. If you use the frame command to change frames, the source for the new frame is displayed and the marker is placed accordingly.
When you find an error, you may change the source code and save the file. However, before recompiling, give gdb the command kill to cancel your running program. Otherwise, when the compiler runs the linker to link your program you'll get the error `text file busy' and a new executable file will not be written.
After recompiling a program, you should reload the symbol table and the executable, otherwise you'll be running the previous program. To do so, execute
(gdb) exec-file program-name (gdb) symbol-file program-nameThe symbol-file command will request confirmation before reloading the symbol table; just answer yes.