Showing posts with label Emacs. Show all posts
Showing posts with label Emacs. Show all posts

Thursday, May 14, 2009

(转)gdb –annotate=

转自:http://blog.163.com/zhang7410@126/blog/static/233564612008338548800/

Emacs中使用gdb命令调试,然后用

gdb –annotate=0 myprog.exe 启动gdb进入gud-mode ,

不同的annotate 的值不代表不同的模式

annotate = 0是最基本的模式和在命令行使用gdb完全一样。

annotate = 1是单步调试模式,出现上下两个窗口,上面是gdb运行的buffer,下面是你代码的buffer,会在代码 buffer中,同步指示当前运行的语句的位置。

annotate = 3是信息最完整的模式,会进入一个多窗口界面同时显示6个窗口分别是gdb-buffer, locals-buffer(局部 变量),source-buffer,inferor I/Obuffer(正在调试程序的IO),stack-buffer,breakpoint-buffer.


无论上面的那种情况,都出现了一个现象:程序的输出不能显示,只有在程序退出的时候才显示出来。这样是非常不方便的。

GUD/GDB mode:

M-x gdb --annotate=3 test ;;进入gdb

如果没有进入graphical mode可以 M-x gdba 然后输入你要debug的file

C-x : set breakpoint ;;可以直接点击旁边的fringe set/clear 断点

C-c C-l : clear breakpoint

C-c C-s : step(step one line code but stop in function)

C-c C-n : next(step one line code but stepping across function)

C-c C-i : stepi(Execute a single machine instruction)

C-c C-r : continue(感觉还是直接按go按钮吧)

C-c C-d : Delete the breakpoint(s) on the current source line

其他:

1. 如果更改了gdb的window 可以用: M-x gdb-restore-windows 恢复

在breakpoint buffer上:

2 Return : gdb-goto-breakpoint (即转到source对应的行)

3.D : gdb-delete-breakpoint

4.Space : Enable/disable the current breakpoint (`gdb-toggle-breakpoint')

5: 可以将鼠标放到一个variable上, 然后点击toolbar上的watch就可以watch a expression了

这是varibale显示在 speedbar中:

return: To expand or contract a complex data type

D : To delete a complex watch expression

space : To edit a variable with a simple data type

6: C-x C-a C-l : refresh a buffer

Monday, March 02, 2009

Emacs tips

一些网上不常见,但又很方便的设置,不断增加中...
1.使emacs中剪贴或复制的文字能粘贴到其他程序:
(setq x-select-enable-clipboard t)

2.;scroll other window
(global-set-key (kbd "C-c C-v") 'scroll-other-window)
(global-set-key (kbd "C-c C-b") 'scroll-other-window-down)

Sunday, February 15, 2009

在emacs中查字典

实验环境:windows下的emacs22.3,dictionary-1.8.7
1.下载dict mode支持包。

2.安装Windows下的make:
http://sourceforge.net/projects/gnuwin32/
这个开源项目就是要移植一些linux下的常用工具到windows下,其中包括make,grep等等。

3.然后安装dict mode。注意两点:
(1)为方便起见,应先把make的路径加到系统的环境变量中;
(2)修改dictionary-1.8.7的makefile中的EMACS变量的值为你的runemacs的路径。
2.在配置文件init.el或(.emacs)中添加如下代码:
;;-----------------dictionary------------------
(autoload 'dictionary-search "dictionary"
"Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
"Ask for a word and search all matching words in the dictionaries" t)
(autoload 'dictionary-lookup-definition "dictionary"
"Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
"Create a new dictionary buffer" t)
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
"Display entries matching the word at the cursor" t)
(autoload 'dictionary-popup-matching-words "dictionary"
"Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
"Display tooltips for the current word" t)
(unless (boundp 'running-xemacs)
(autoload 'global-dictionary-tooltip-mode "dictionary"
"Enable/disable dictionary-tooltip-mode for all buffers" t))
;; key bindings
(global-set-key "\C-cs" 'dictionary-search)
(global-set-key "\C-cm" 'dictionary-match-words)
(global-set-key [mouse-3] 'dictionary-mouse-popup-matching-words)
(global-set-key "\C-cd" 'dictionary-lookup-definition)
;; for dictionary tooltip mode
;; "web1913" for Webster's Revised Unabridged Dictionary(1913)
;; 貌似在emacs 22.3中不支持tooltip,即鼠标取词,故去掉,节省内存
;;(setq dictionary-tooltip-dictionary "web1913")
;(global-dictionary-tooltip-mode t)
(setq dictionary-default-dictionary "web1913")

OK了,上面几个操作函数意思如下:
dictionary-search:请求输入一个单词,输出所有的解释条目。
dictionary-lookup-definition:查当前鼠标处的单词。
dictionary-match-words:输入一个匹配模式,输出匹配的单词。
dictionary-popup-matching-words:弹出一个菜单,显示各个字典中相的匹配单词(匹配策略点击按钮Select Match Strategy中选择)。
在查询结果窗口中,输入h可查看快捷键。

有了这个,看起英文文档来就方便多了,而且用的是原汁原味的英语词典,对英语水平的提升也很有帮助啦。

Insist On

English words
Go to bed at 23:30

About Me

Gtalk:l0he1g at gmail
Location:Beijing,China