pyclewn.txt 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  1. *pyclewn.txt* Last change: 2013 September 10
  2. PYCLEWN USER MANUAL
  3. The Pyclewn user guide *pyclewn*
  4. 1. Introduction |pyclewn-intro|
  5. 2. Starting pyclewn |:Pyclewn|
  6. 3. Options |pyclewn-options|
  7. 4. Using pyclewn |pyclewn-using|
  8. 5. Gdb |pyclewn-gdb|
  9. 6. Pdb |pyclewn-pdb|
  10. 7. Windows |pyclewn-windows|
  11. 8. Key mappings |pyclewn-mappings|
  12. 9. Watched variables |pyclewn-variable|
  13. 10. Extending pyclewn |pyclewn-extending|
  14. ==============================================================================
  15. 1. Introduction *pyclewn-intro*
  16. Pyclewn is a python program that allows the use of vim as a front end to a
  17. debugger. Pyclewn supports the gdb and the pdb debuggers. Pyclewn uses the
  18. netbeans protocol to control vim.
  19. The debugger output is redirected to a vim window, the|pyclewn-console|. The
  20. debugger commands are mapped to vim user-defined commands with a common letter
  21. prefix (the default is the|C|letter), and with vim command completion
  22. available on the commands and their first argument.
  23. On unix when running gvim, the controlling terminal of the program to debug is
  24. the terminal used to launch pyclewn. Any other terminal can be used when the
  25. debugger allows it, for example after using the ``attach`` or ``tty`` gdb
  26. commands or using the ``--tty`` option with pdb.
  27. On Windows, gdb pops up a console attached to the program to debug.
  28. Pyclewn currently supports the following debuggers:
  29. * gdb: version 6.2.1 and above, pyclewn uses the gdb MI interface
  30. * pdb: the Python debugger
  31. * simple: a fake debugger implemented in python to test pyclewn
  32. internals
  33. Pyclewn provides the following features:
  34. ---------------------------------------
  35. * A debugger command can be mapped in vim to a key sequence using vim key
  36. mappings. This allows, for example, to set/clear a breakpoint or print a
  37. variable value at the current cursor or mouse position by just hitting a
  38. key.
  39. * A sequence of gdb commands can be run from a vim script when the
  40. |async-option|is set. This may be useful in a key mapping.
  41. * Breakpoints and the line in the current frame are highlighted in the source
  42. code. Disabled breakpoints are noted with a different highlighting color.
  43. Pyclewn automatically finds the source file for the breakpoint if it exists,
  44. and tells vim to load and display the file and highlight the line.
  45. * The value of an expression or variable is displayed in a balloon in gvim
  46. when the mouse pointer is hovering over the selected expression or the
  47. variable.
  48. * Similarly to gdb, one may attach to a running python process with the pdb
  49. debugger, interrupt the process, manage a debugging session and terminate
  50. the debugging session by detaching from the process. A new debugging session
  51. may be conducted later on this same process, possibly from another Vim
  52. instance.
  53. * An expression can be watched in a vim window. The expression value is
  54. updated and highlighted whenever it has changed. When the expression is a
  55. structure or class instance, it can be expanded (resp. folded) to show
  56. (resp. hide) its members and their values. This feature is only available
  57. with gdb.
  58. * The|project-command|saves the current gdb settings to a project file that
  59. may be sourced later by the gdb "source" command. These settings are the
  60. working directory, the debuggee program file name, the program arguments and
  61. the breakpoints. The sourcing and saving of the project file can be
  62. automated to occur on each gdb startup and termination, whith the
  63. |project-file|command line option. The ``project`` command is currently only
  64. available with gdb.
  65. * Vim command completion on the commands and their first argument.
  66. The remaining sections of this manual are:
  67. -----------------------------------------
  68. 2.|:Pyclewn|explains how to start pyclewn.
  69. 3.|pyclewn-options|lists pyclewn options and their usage.
  70. 4.|pyclewn-using|explains how to use the pyclewn features common to all
  71. supported debuggers
  72. 5.|pyclewn-gdb|details the topics relevant to pyclewn and the gdb
  73. debugger.
  74. 6.|pyclewn-pdb|details the topics relevant to pyclewn and the pdb
  75. debugger.
  76. 7.|pyclewn-windows|describes what is specific to pyclewn on Windows.
  77. 8.|pyclewn-mappings|lists the pyclewn key mappings and how to use them.
  78. 9.|pyclewn-variable|explains how to use the variable debugger window with
  79. gdb.
  80. 10.|pyclewn-extending|explains how to implement a new debugger in pyclewn
  81. ==============================================================================
  82. 2. Starting pyclewn *:Pyclewn*
  83. Start pyclewn from vim:
  84. -----------------------
  85. The|:Pyclewn|vim command requires at least vim 7.3. To start pyclewn with the
  86. gdb debugger: >
  87. :Pyclewn
  88. To start pyclewn with the pdb debugger: >
  89. :Pyclewn pdb [script.py]
  90. Next, the gdb debugger is started by running a debugger command from vim
  91. command line. For example, load foobar with the gdb command "file" and start
  92. gbd by typing on the vim command line: >
  93. :Cfile foobar
  94. To just start gdb with a command that does not have any effect: >
  95. :Cecho
  96. To terminate pyclewn and the vim netbeans interface, run the following
  97. command: >
  98. :nbclose
  99. To know if the netbeans interface is connected, run the following command: >
  100. :echo has("netbeans_enabled")
  101. The|:Pyclewn|command is provided by the vim plugin installed as the
  102. "pyclewn.vim" file in vim plugin directory. Pyclewn command line arguments and
  103. connection details may be set with the "pyclewn_args" and the
  104. "pyclewn_connection" vim global variables. For further customization you can
  105. edit the "pyclewn.vim" file in vim autoload directory.
  106. The|:Pyclewn|command does the following:
  107. * spawn pyclewn
  108. * start the vim netbeans interface and connect it to pyclewn
  109. * source a script automatically generated by pyclewn containing utility
  110. functions and the debugger commands as vim commands
  111. Start the pyclewn process:
  112. --------------------------
  113. Pyclewn with the gdb debugger is simply started as: >
  114. pyclewn
  115. On Windows, pyclewn is started with a Desktop shortcut that runs pyclewn.bat.
  116. The pyclewn.bat file is located in the Scripts directory of the python
  117. distribution.
  118. ==============================================================================
  119. 3. Options *pyclewn-options*
  120. The pyclewn options can be set:
  121. * on pyclewn command line
  122. * in the "pyclewn_args" and the "pyclewn_connection" vim global
  123. variables when starting pyclewn with the|:Pyclewn|command
  124. * as the keyword parameters of the pdb function
  125. options:
  126. --version show program's version number and exit
  127. -h, --help show this help message and exit
  128. -s, --simple select the simple debugger
  129. --pdb select 'pdb', the python debugger
  130. --run allow the debuggee to run after the pdb() call
  131. (default 'False')
  132. --tty=TTY use TTY for input/output by the python script
  133. being debugged (default '/dev/null')
  134. -g PARAM_LIST, --gdb=PARAM_LIST
  135. select the gdb application (the default), with a
  136. mandatory, possibly empty, PARAM_LIST
  137. --terminal=TERMINAL set the terminal to use with the inferiortty
  138. command for running gdb or pdb inferior (default
  139. 'xterm,-e')
  140. -d, --daemon run as a daemon (default 'False')
  141. -p PGM, --pgm=PGM set the debugger program to PGM
  142. -a ARGS, --args=ARGS set the debugger program arguments to ARGS
  143. -e EDITOR, --editor=EDITOR set the Vim program to EDITOR;
  144. Vim is not spawned by pyclewn when this
  145. parameter is set to an empty string
  146. -c ARGS, --cargs=ARGS set the Vim program arguments to ARGS
  147. -w LOCATION, --window=LOCATION
  148. open the debugger console window at LOCATION
  149. which may be one of (top, bottom, left,
  150. right), the default is top
  151. -m LNUM, --maxlines=LNUM set the maximum number of lines of the debugger
  152. console window to LNUM (default 10000 lines)
  153. -x PREFIX, --prefix=PREFIX set the commands prefix to PREFIX (default|C|)
  154. -b COLORS, --background=COLORS
  155. COLORS is a comma separated list of the three
  156. colors of the breakpoint enabled, breakpoint
  157. disabled and frame sign background colors, in
  158. this order (default 'Cyan,Green,Magenta')
  159. -n CONN, --netbeans=CONN set netBeans connection parameters to CONN with
  160. CONN as 'host[:port[:passwd]]', (the default is
  161. ':3219:changeme' where the empty host represents
  162. INADDR_ANY)
  163. -l LEVEL, --level=LEVEL set the log level to LEVEL: critical, error,
  164. warning, info, debug or nbdebug (default error)
  165. -f FILE, --file=FILE set the log file name to FILE
  166. The full description of pyclewn options follows:
  167. ------------------------------------------------
  168. --version Show program's version number and exit.
  169. -h
  170. --help Show this help message and exit.
  171. -s
  172. --simple Select the simple debugger. In that case, the --pgm and
  173. --args options are meaningless. The simple debugger is
  174. documented in debugger/simple.py, in the source
  175. distribution.
  176. --pdb Select 'pdb', the python debugger.
  177. --run By default the python debuggee is stopped at the first
  178. statement after the call to pdb(). Enabling this option
  179. allows the debuggee to run after the call to pdb().
  180. --tty={TTY} Use TTY for input/output by the python script being
  181. debugged. The default is "/dev/null".
  182. -g {PARAM_LIST}
  183. --gdb={PARAM_LIST} Select the gdb debugger (the default). The default value
  184. of the "pgm" option is "gdb". The PARAM_LIST option
  185. parameter is a comma separated list of parameters and is
  186. mandatory when the option is present. So, to run gdb with
  187. no specific parameter, the following commands are
  188. equivalent: >
  189. pyclewn
  190. pyclewn -g ""
  191. pyclewn --gdb=
  192. .
  193. There are three optional parameters:
  194. * the "async" keyword sets the|async-option|
  195. * the "nodereference" keyword, see|gdb-balloon|.
  196. * the project file name sets the|project-file|
  197. The project file name can be an absolute pathname, a
  198. relative pathname starting with '.' or a home relative
  199. pathname starting with '~'. The directory of the project
  200. file name must be an existing directory.
  201. For example on unix: >
  202. pyclewn --gdb=async,./project_name
  203. --terminal=TERMINAL Set the terminal to use with the inferiortty command for
  204. running gdb or pdb inferior (default 'xterm,-e'). The
  205. option is a comma separated list of the arguments needed
  206. to start the terminal and a program running in this
  207. terminal.
  208. -d
  209. --daemon Run as a daemon (default 'False'): on unix, pyclewn is
  210. detached from the terminal from where it has been
  211. launched, which means that this terminal cannot be used as
  212. a controlling terminal for the program to debug, and
  213. cannot be used for printing the pyclewn logs as well.
  214. On Windows, this option hides the pyclewn Windows console
  215. and it is set on the shortcut that is installed on the
  216. Desktop.
  217. -p {PGM}
  218. --pgm={PGM} Set the debugger program to PGM. PGM must be in one of the
  219. directories listed in the PATH environment variable.
  220. -a {ARGS}
  221. --args={ARGS} Set the debugger program arguments to ARGS. These
  222. arguments may be double quoted. For example, start gdb
  223. with the program foobar and "this is foobar argument" as
  224. foobar's argument: >
  225. pyclewn -a '--args foobar "this is foobar argument"'
  226. -e {EDITOR}
  227. --editor={EDITOR} Set the editor program to EDITOR. EDITOR must be in one
  228. of the directories listed in the PATH environment
  229. variable, or the full pathname to vim or gvim executable.
  230. When this command line option is not set, pyclewn uses the
  231. value of the EDITOR environment variable, and if this
  232. environment variable is not set either, then pyclewn
  233. defaults to using "gvim" as the name of the program to
  234. spawn.
  235. -c {ARGS}
  236. --cargs={ARGS} Set the editor program arguments to ARGS, possibly double
  237. quoted (same as option --args).
  238. -w {LOCATION}
  239. --window={LOCATION} The debugger console window pops up at LOCATION, which may
  240. be one of top, bottom, left, right or none. The default is
  241. top. In the left or right case, the window pops up on the
  242. left (resp. right) if there is only one window currently
  243. displayed, otherwise the debugger window is opened at the
  244. default top. When LOCATION is none, the automatic display
  245. of the console is disabled.
  246. -m {LNUM}
  247. --maxlines={LNUM} Set the maximum number of lines of the debugger console
  248. window to LNUM (default 10000 lines). When the number of
  249. lines in the buffer reaches LNUM, 10% of LNUM first lines
  250. are deleted from the buffer.
  251. -x {PREFIX}
  252. --prefix={PREFIX} Set the user defined vim commands prefix to PREFIX
  253. (default|C|). The prefix may be more than one letter
  254. long. The first letter must be upper case.
  255. -b {COLORS}
  256. --background={COLORS}
  257. COLORS is a comma separated list of the three colors of
  258. the breakpoint enabled, breakpoint disabled and frame sign
  259. background colors, in this order (default
  260. 'Cyan,Green,Magenta'). The color names are case sensitive.
  261. See|highlight-ctermbg|for the list of the valid color
  262. names.
  263. This option has no effect when vim version is vim72 or
  264. older.
  265. -n {CONN}
  266. --netbeans={CONN} Set netBeans connection parameters to CONN with CONN as
  267. 'host[:port[:passwd]]', (the default is ':3219:changeme'
  268. where the empty host represents INADDR_ANY). Pyclewn
  269. listens on host:port, with host being a name or the IP
  270. address of one of the local network interfaces in standard
  271. dot notation. These parameters must match those used by
  272. vim for the connection to succeed.
  273. -l {LEVEL}
  274. --level={LEVEL} Set the log level to LEVEL: critical, error, warning, info,
  275. debug or nbdebug (default critical). Level nbdebug is very
  276. verbose and logs all the netbeans pdu as well as all the
  277. debug traces. Critical error messages are printed on
  278. stderr. No logging is done on stderr (including critical
  279. error messages) when the "--level" option is set to
  280. something else than "critical" and the "--file" option is
  281. set.
  282. -f {FILE}
  283. --file={FILE} Set the log file name to FILE.
  284. On unix, when the 'CLEWN_PIPES' environment variable is set, pyclewn uses
  285. pipes instead of a pseudo tty to communicate with gdb and emulates the select
  286. event loop with threads. When the 'CLEWN_POPEN' environment variable is set,
  287. pyclewn uses pipes instead of a pseudo tty but continues using the select
  288. event loop. These variables are mainly used for regression testing.
  289. ==============================================================================
  290. 4. Using pyclewn *pyclewn-using* *pyclewn-console*
  291. Console:
  292. --------
  293. The debugger output is redirected to a vim window: the console.
  294. The console window pops up whenever a|Ccommand|is entered on vim command line
  295. or a key mapped by pyclewn is hit. This behavior may be disabled by setting to
  296. `none` the `window`|pyclewn-options|and may be useful when using Vim tabs and
  297. wanting to keep the console in a tab of its own. In this case, the cursor
  298. position in the console is not updated by pyclewn, so you need to set manually
  299. the cursor at the bottom of the console, the first time you open
  300. (clewn)_console.
  301. The initial console window height is set with the vim option 'previewheight'
  302. that defaults to 12 lines.
  303. Commands: *Ccommand* *C*
  304. ---------
  305. The prefix letter|C|is the default vim command prefix used to map debugger
  306. commands to vim user-defined commands. These commands are called|Ccommand|in
  307. this manual. The prefix can be changed with a command line option.
  308. A debugger command can be entered on vim command line with the|C|prefix. It is
  309. also possible to enter the command as the first argument of the|C|command. In
  310. the following example with gdb, both methods are equivalent: >
  311. :Cfile /path/to/foobar
  312. :C file /path/to/foobar
  313. The first method provides completion on the file name while the second one
  314. does not.
  315. The second method is useful when the command is a user defined command in the
  316. debugger (user defined commands built by <define> in gdb), and therefore not a
  317. vim command. It is also needed for gdb command names that cannot be mapped to
  318. a vim command because vim does not accept non alphanumeric characters within
  319. command names (for example <core-file> in gdb).
  320. To get help on the pyclewn commands, use Chelp.
  321. Pyclewn commands can be mapped to keys, or called within a Vim script or a
  322. menu.
  323. Note:
  324. The gdb debugger cannot handle requests asynchronously, so the
  325. |async-option|must be set, when mapping a key to a sequence of commands.
  326. With this option set, one can build for example the following mapping: >
  327. :map <F8> :Cfile /path/to/foobar <Bar> Cbreak main <Bar> Crun <CR>
  328. Note:
  329. Quotes and backslashes must be escaped on vim command line. For example, to
  330. print foo with a string literal as first argument to the foo function: >
  331. :Cprint foo(\"foobar\", 1)
  332. And to do the same thing with the string including a new line: >
  333. :Cprint foo(\"foobar\\n\", 1)
  334. Completion:
  335. -----------
  336. Command line completion in vim is usually done using the <Tab> key (set by the
  337. 'wildchar' option). To get the list of all valid completion matches, type
  338. CTRL-D. For example, to list all the debugger commands (assuming the
  339. default|C|prefix is being used): >
  340. :C<C-D>
  341. See also the 'wildmenu' option. With this option, the possible matches are
  342. shown just above the command line and can be selected with the arrow keys.
  343. The first argument completion of a|Ccommand|may be done on a file name or on a
  344. list. For example with gdb, the following command lists all the gdb help
  345. items: >
  346. :Chelp <C-D>
  347. The first argument completion of the|C|command is the list of all the debugger
  348. commands. For example, to list all the debugger commands (note the space after
  349. the|C|): >
  350. :C <C-D>
  351. Command line search:
  352. --------------------
  353. Use the powerful command line search capabilities of the Vim command line.
  354. For example, you want to type again, possibly after a little editing, one of
  355. the commands previously entered: >
  356. :Cprint (*(foo*)0x0123ABCD)->next->next->part1->something_else.aaa
  357. You can get rapidly to this command by using the Vim command line window
  358. |cmdline-window|: >
  359. :<CTRL-F>
  360. /something_else
  361. <CR>
  362. or from normal mode >
  363. q:
  364. /something_else
  365. <CR>
  366. Vim in a terminal
  367. -----------------
  368. The debuggee output is redirected to '/dev/null' when the name of the program
  369. is "vim" or "vi". One must use the "set inferior-tty" gdb command to redirect
  370. the debuggee output to a terminal.
  371. Do not use the "--daemon" command line option when running vim in a console.
  372. Balloon:
  373. --------
  374. A variable is evaluated by the debugger and displayed in a balloon in gvim,
  375. when the mouse pointer is hovering over the the variable. To get the
  376. evaluation of an expression, first select the expression in visual mode in the
  377. source code and point the mouse over the selected expression. To disable this
  378. feature, set the vim option 'noballooneval'.
  379. ==============================================================================
  380. 5. Gdb *pyclewn-gdb*
  381. When gdb is started, it automatically executes commands from its init file,
  382. normally called '.gdbinit'. See the gdb documentation.
  383. Debuggee standard input and output:
  384. -----------------------------------
  385. On Windows, gdb pops up a console attached to the program to debug.
  386. *inferior_tty*
  387. On unix, when starting pyclewn from a terminal and using gvim, pyclewn creates
  388. a pseudo terminal that is the the controlling terminal of the program to
  389. debug. Programs debugged by gdb, including those based on curses and termios
  390. such as vim, run in this terminal. A <Ctl-C> typed in the terminal interrupts
  391. the debuggee.
  392. When pyclewn is started from vim with the|:Pyclewn|command, there is no
  393. terminal associated with pyclewn. The|inferiortty|command provides the same
  394. functionality as above and spawns the controlling terminal (using the
  395. --terminal option, default xterm) of the debuggee and sets accordingly gdb
  396. 'inferior-tty' variable and the TERM environment variable. The gdb
  397. 'inferior-tty' variable MUST be set BEFORE the inferior is started.
  398. One can also do step by step what the above command does automatically: start
  399. the "inferior_tty.py" script installed with pyclewn. This script creates a
  400. pseudo terminal to be used as the controlling terminal of the process debugged
  401. by gdb. For example, to debug vim (not gvim) and start the debugging session
  402. at vim's main function. From pyclewn, spawn an xterm terminal and launch
  403. "inferior_tty.py" in this terminal: >
  404. :Cfile /path/to/vim
  405. :Cshell setsid xterm -e inferior_tty.py &
  406. "inferior_tty.py" prints the name of the pseudo terminal to be used by gdb and
  407. the two gdb commands needed to configure properly gdb with this terminal. Copy
  408. and paste these two commands in vim command line: >
  409. :Cset inferior-tty /dev/pts/nn
  410. :Cset environment TERM = xterm
  411. Then start the debugging session of vim and stop at vim main(): >
  412. :Cstart
  413. Note:
  414. * <setsid> is necessary to prevent gdb from killing the xterm process when a
  415. <Ctl-C> is typed from gdb to interrupt the debuggee. This is not needed when
  416. the terminal emulator is not started from gdb.
  417. *async-option*
  418. Async option:
  419. -------------
  420. The gdb event loop is not asynchronous in most configurations, which means
  421. that gdb cannot handle a command while the previous one is being processed and
  422. discards it.
  423. When gdb is run with the|async-option|set, pyclewn queues the commands in a
  424. fifo and send a command to gdb, only when gdb is ready to process the command.
  425. This allows the key mappings of a sequence of gdb commands. To set the
  426. |async-option|, see|pyclewn-options|.
  427. *gdb-keys*
  428. List of the gdb default key mappings:
  429. -------------------------------------
  430. These keys are mapped after the|Cmapkeys|vim command is run.
  431. CTRL-Z send an interrupt to gdb and the program it is running (unix
  432. only)
  433. B info breakpoints
  434. L info locals
  435. A info args
  436. S step
  437. CTRL-N next: next source line, skipping all function calls
  438. F finish
  439. R run
  440. Q quit
  441. C continue
  442. W where
  443. X foldvar
  444. CTRL-U up: go up one frame
  445. CTRL-D down: go down one frame
  446. cursor position: ~
  447. CTRL-B set a breakpoint on the line where the cursor is located
  448. CTRL-E clear all breakpoints on the line where the cursor is located
  449. mouse pointer position: ~
  450. CTRL-P print the value of the variable defined by the mouse pointer
  451. position
  452. CTRL-X print the value that is referenced by the address whose
  453. value is that of the variable defined by the mouse pointer
  454. position
  455. *$cdir*
  456. Source path:
  457. -----------
  458. Pyclewn automatically locates the source file with the help of gdb, by using
  459. the debugging information stored in the file that is being debugged. This is
  460. useful when the program to debug is the result of multiple compilation units
  461. located in different directories.
  462. *Csymcompletion*
  463. Symbols completion:
  464. -------------------
  465. The gdb <break> and <clear> commands are set initially with file name
  466. completion. This can be changed to completion matching the symbols of the
  467. program being debugged, after running the|Csymcompletion|command. This is a
  468. pyclewn command.
  469. To minimize the number of loaded symbols and to avoid fetching the shared
  470. libraries symbols, run the Csymcompletion command after the file is loaded
  471. with the gdb <file> command, and before the program is run.
  472. Note: The <break> and <clear> filename completion is not the same as gdb file
  473. name completion for these two commands. Gdb uses the symbols found in the
  474. program file to debug, while pyclewn uses only the file system.
  475. *gdb-balloon*
  476. Balloon evaluation:
  477. -------------------
  478. The gdb <whatis> command is used by pyclewn to get the type of the variable or
  479. the type of the selected expression that is being hovered over by the mouse.
  480. When it is a pointer to data, the pointer is dereferenced and its value
  481. displayed in the vim balloon. The paramater of the "--gdb" option named
  482. "nodereference" disables this feature: the balloon prints the pointer address
  483. value.
  484. *project-command* *project-file*
  485. Project file:
  486. -------------
  487. The pyclewn|project-command|name is "project". This command saves the current
  488. gdb settings to a project file that may be sourced later by the gdb "source"
  489. command.
  490. These settings are:
  491. * current working directory
  492. * debuggee program file name
  493. * program arguments
  494. * all the breakpoints (at most one breakpoint per source line is saved)
  495. The argument of the|project-command|is the pathname of the project file.
  496. For example: >
  497. :Cproject /path/to/project
  498. When the "--gdb" option is set with a project filename (see|pyclewn-options|),
  499. the project file is automatically sourced when a a gdb session is started, and
  500. the project file is automatically saved when the gdb session or vim session,
  501. is terminated.
  502. Note: When gdb sources the project file and cannot set a breakpoint because,
  503. for example, it was set in a shared library that was loaded at the time the
  504. project file was saved, gdb ignores silently the breakpoint (see gdb help on
  505. "set breakpoint pending").
  506. Limitations:
  507. ------------
  508. When pyclewn cannot setup a pseudo tty to communicate with gdb, pyclewn falls
  509. back to pipes. In this case, the Csigint command does not work as gdb does not
  510. handle interrupts over a pipe. Instead, one must send a SIGINT signal to the
  511. debuggee in order to interrupt the debuggee while it is running. This can be
  512. done from Vim with the command: >
  513. :!kill -SIGINT $(pgrep debuggee_process_name)
  514. On Windows, it is not possible to interrupt gdb with the Csigint command, but
  515. you can type <Ctl-C> in the console to interrupt the debuggee.
  516. When setting breakpoints on an overloaded method, pyclewn bypasses the gdb
  517. prompt for the multiple choice and sets automatically all breakpoints.
  518. In order to set a pending breakpoint (for example in a shared library that has
  519. not yet been loaded by gdb), you must explicitly set the breakpoint pending
  520. mode to "on", with the command: >
  521. :Cset breakpoint pending on
  522. After a "detach" gdb command, the frame sign remains highlighted because
  523. gdb/mi considers the frame as still valid.
  524. When answering "Abort" to a dialog after pyclewn attempts to edit a buffer and
  525. set a breakpoint in a file already opened within another Vim session, the
  526. breakpoint is set in gdb, but not highlighted in the corresponding buffer.
  527. However, it is possible to|bwipeout|a buffer at any time, and load it again in
  528. order to restore the correct highlighting of all the breakpoints in the
  529. buffer.
  530. Pyclewn commands:
  531. -----------------
  532. The|Ccommand|list includes all the gdb commands and some pyclewn specific
  533. commands that are listed here:
  534. *|Ccwindow| opens a vim quickfix window holding the list of the
  535. breakpoints with their current state; the quickfix
  536. window allows moving directly to any breakpoint
  537. (requires the vim|+quickfix|feature)
  538. *|Cdbgvar| add a watched variable or expression to the
  539. (clewn)_dbgvar buffer
  540. *|Cdelvar| delete a watched variable from the (clewn)_dbgvar buffer
  541. * Cdumprepr print on the console pyclewn internal structures that
  542. may be used for debugging pyclewn
  543. *|Cfoldvar| collapse/expand the members of a watched structure or
  544. class instance
  545. * Chelp print on the console, help on the pyclewn specific
  546. commands (those on this list) in addition to the help on
  547. the debugger commands
  548. *inferiortty*
  549. * Cinferiortty spawn the controlling terminal (default xterm) of the
  550. debuggee and sets accordingly gdb 'inferior-tty' variable
  551. and the TERM environment variable; this command MUST be
  552. issued BEFORE starting the inferior.
  553. * Cloglevel print or set the log level dynamically from inside Vim
  554. *|Cmapkeys| map pyclewn keys
  555. *|Cproject| save the current gdb settings to a project file
  556. *|Csetfmtvar| set the output format of the value of a watched variable
  557. * Csigint send a <C-C> character to the debugger to interrupt the
  558. running program that is being debugged; only with gdb,
  559. and when pyclewn and gdb communicate over a pseudo
  560. terminal, which means on unix but not on Windows;
  561. on Windows, to interrupt the debuggee, one must type
  562. <C-C> in the console that is popped by gdb on debuggee
  563. start up
  564. *|Csymcompletion|populate the break and clear commands with symbols
  565. completion (only with gdb)
  566. * Cunmapkeys unmap the pyclewn keys, this vim command does not invoke
  567. pyclewn
  568. List of illegal gdb commands:
  569. -----------------------------
  570. The following gdb commands cannot be run from pyclewn:
  571. complete
  572. edit
  573. end
  574. set annotate
  575. set confirm
  576. set height
  577. set width
  578. shell
  579. ==============================================================================
  580. 6. Pdb *pyclewn-pdb*
  581. Start a python script from Vim and debug it, or attach to a running python
  582. process and start the debugging session.
  583. Start a python script from Vim and debug it:
  584. -------------------------------------------
  585. To debug a python script named "script.py", run the vim command (arg1, arg2,
  586. ... being the script.py command line arguments): >
  587. :Pyclewn pdb script.py arg1 arg2 ...
  588. Or, more conveniently, debug the python script being edited in vim as the
  589. current buffer with: >
  590. :Pyclewn pdb %:p
  591. On unix, the script is started without a controlling terminal unless the "tty"
  592. option has been set (see below). The|Cinferiortty|command spawns a controlling
  593. terminal (using the --terminal option that defaults to xterm) connected to a
  594. pseudo tty, and redirects all three standard streams of the script to this
  595. pseudo tty.
  596. One may also redirect the script output to another tty, using the "tty" option
  597. and setting the "pyclewn_args" vim global variable before starting the script.
  598. For example: >
  599. :let g:pyclewn_args="--tty=/dev/pts/4"
  600. The ":Cquit" command and the Vim ":quitall" command terminate the debugging
  601. session and the script being debugged. Both commands MUST be issued at the pdb
  602. prompt.
  603. Attach to a python process and debug it: >
  604. ----------------------------------------
  605. To debug a python process after having attached to it, first insert the
  606. following statement in the debuggee source code before starting it: >
  607. import clewn.vim as vim; vim.pdb()
  608. By default, the debuggee is stopped at the first statement following the call
  609. to vim.pdb(). To let the debuggee run instead, then use the "run" option: >
  610. import clewn.vim as vim; vim.pdb(run=True)
  611. Next, attach to the process and start the debugging session by running the vim
  612. command: >
  613. :Pyclewn pdb
  614. Notes:
  615. When the pyclewn installation has been made following the "home scheme" (see
  616. INSTALL) and in order to have python find the clewn package, one must set the
  617. PYTHONPATH environment variable to include the python home library pathname.
  618. For example with bash, run the script as: >
  619. PYTHONPATH=$HOME/lib/python python script_pathname
  620. The current debugging session may be terminated with the ":Cdetach" or the Vim
  621. ":quitall" command. Another debugging session with the same process can be
  622. started later with the ":Pyclewn pdb" command.
  623. The ":Cdetach", ":Cquit" or the Vim ":quitall" commands do not terminate the
  624. debuggee. To kill the debuggee, issue the following command at the pdb prompt:
  625. >
  626. :C import sys; sys.exit(1)
  627. On posix platforms, when the python process is not attached, typing two
  628. <Ctl-C> instead of one, is needed to kill the process. This is actually a
  629. feature that allows the process to run without any tracing overhead (before
  630. the first <Ctl-C>) when it is not attached and no breakpoints are being set
  631. (there is still the small overhead of the context switches between the idle
  632. clewn thread and the process threads).
  633. Pdb commands:
  634. -------------
  635. The commands "interrupt", "detach" and "threadstack" are new pdb commands and
  636. are the only commands that are available at the "[running...]" prompt when the
  637. debuggee is running. Use the "help" command (and completion on the first
  638. argument of the help command) to get help on each command.
  639. The following list describes the pdb commands that are new or behave
  640. differently from the pdb commands of the Python standard library:
  641. *Cinterrupt*
  642. interrupt
  643. This command interrupts the debuggee and is available from the
  644. "[running...]" prompt.
  645. *Cinferiortty*
  646. inferiortty
  647. Without argument, the pdb command "inferiortty" spawns a terminal
  648. connected to a pseudo tty and redirects all three standard streams to this
  649. pseudo tty.
  650. With the name of an existing pseudo tty as an argument, "inferiortty'
  651. redirects all three standard streams to this pseudo tty (convenient for
  652. re-using the same pseudo tty across multiple debugging sessions).
  653. This command can be issued after the script has been started.
  654. Available on unix.
  655. *Cdetach*
  656. detach
  657. This command terminates the debugging session by closing the netbeans
  658. socket. The debuggee is free to run and does not stop at the breakpoints.
  659. To start another debugging session, run the command: >
  660. :Pyclewn pdb
  661. . The breakpoints becomes effective again when the new session starts up.
  662. Available from the "[running...]" prompt and from the pdb prompt.
  663. *Cquit*
  664. quit
  665. This command terminates the debugging session by closing the netbeans
  666. socket, and removes the python trace function. The pyclewn thread in
  667. charge of handling netbeans connection terminates and it is not possible
  668. anymore to attach to the process. Since there is no trace function, the
  669. breakpoints are ineffective and the process performance is not impaired
  670. anymore by the debugging overhead.
  671. When the script has been started from Vim, this command terminates the
  672. script.
  673. *Cthreadstack*
  674. threadstack
  675. The command uses the sys._current_frames() function from the standard
  676. library to print a stack of the frames for all the threads.
  677. The function sys._current_frames() is available since python 2.5.
  678. Available from the "[running...]" prompt and from the pdb prompt.
  679. *Cclear*
  680. clear
  681. This command is the same as the Python standard library "clear" command,
  682. except it requires at least one parameter and therefore, it is not
  683. possible to clear all the breakpoints in one shot with the "clear" command
  684. without parameters.
  685. the prefix alone:
  686. There is no "!" pdb command as in the Python standard library since Vim
  687. does not allow this character in a command name. However, the equivalent
  688. way to execute a python statement in the context of the current frame is
  689. with the command prefix alone, for example: >
  690. :C global list_options; list_options = ['-l']
  691. :C import sys; sys.exit(1)
  692. . The first word of the statement must not be a pdb command and will be
  693. expanded if it is an alias.
  694. not implemented:
  695. The following pdb commands are not implemented: list, ll, whatis, source,
  696. display, undisplay, interact, run, restart.
  697. *pdb-pdbrc*
  698. The initialisation file .pdbrc:
  699. -------------------------------
  700. This file is read at initialisation and its commands are executed on startup.
  701. See the pdb python documentation for the location of this file. Breakpoints
  702. can be set through this file, or aliases may be defined. One useful alias
  703. entered in the file would be for example: >
  704. alias kill import sys; sys.exit(1)
  705. So that the debuggee may be killed with the command: >
  706. :C kill
  707. *pdb-keys*
  708. List of the pdb default key mappings:
  709. -------------------------------------
  710. These keys are mapped after the|Cmapkeys|vim command is run.
  711. CTRL-Z interrupt the pdb process
  712. B list all breaks, including for each breakpoint, the number of
  713. times that breakpoint has been hit, the current ignore count,
  714. and the associated condition if any
  715. A print the argument list of the current function
  716. S step
  717. CTRL-N next: next source line, skipping all function calls
  718. R continue execution until the current function returns
  719. C continue
  720. W where
  721. CTRL-U up: go up one frame
  722. CTRL-D down: go down one frame
  723. cursor position: ~
  724. CTRL-B set a breakpoint on the line where the cursor is located
  725. CTRL-E clear all breakpoints on the line where the cursor is located
  726. mouse pointer position: ~
  727. CTRL-P print the value of the selected expression defined by the
  728. mouse pointer position
  729. Pyclewn commands:
  730. -----------------
  731. The|Ccommand|list includes pdb commands and some pyclewn specific commands
  732. that are listed here:
  733. * Cdumprepr print on the console pyclewn internal structures that
  734. may be used for debugging pyclewn
  735. * Cloglevel print or set the log level dynamically from inside Vim
  736. *|Cmapkeys| map pyclewn keys
  737. * Cunmapkeys unmap the pyclewn keys, this vim command does not invoke
  738. pyclewn
  739. Troubleshooting:
  740. ----------------
  741. * Pyclewn error messages can be logged in a file with the "--file" option.
  742. When starting the debuggee from vim, use the "pyclewn_args" vim global
  743. variable before starting the script: >
  744. :let g:pyclewn_args="--file=/path/to/logfile"
  745. When attaching to a python process, use the corresponding keyword argument: >
  746. import clewn.vim as vim; vim.pdb(file='/path/to/logfile')
  747. * To conduct two debugging sessions simultaneously (for example when debugging
  748. pyclewn with pyclewn), change the netbeans socket port with the
  749. "pyclewn_connection" vim global variable before starting the script: >
  750. :let g:pyclewn_connection="localhost:3220:foo"
  751. And change the corresponding keyword argument: >
  752. import clewn.vim as vim; vim.pdb(netbeans='localhost:3220:foo')
  753. Limitations:
  754. ------------
  755. On Windows, the netbeans session is not closed in Vim after the Python script
  756. terminates normaly. The Vim ":nbclose" command must be issued in order to
  757. start a new debugging session. See Vim issue 107 at
  758. http://code.google.com/p/vim/.
  759. The|Cinterrupt|command does not properly interrupt the input() Python
  760. function. Workaround: after the Cinterrupt command has been issued while at
  761. the prompt displayed by input(), enter some data to allow the input() function
  762. to complete execution of its C code implementation, this allows pdb to gain
  763. control when back in python code and to stop.
  764. ==============================================================================
  765. 7. Windows *pyclewn-windows*
  766. Installation:
  767. -------------
  768. See http://pyclewn.wiki.sourceforge.net/install for installing pyclewn on
  769. Windows.
  770. If pyclewn does not start once installed, edit the desktop shortcut and add
  771. "-l debug -f \path\to\logfile.txt" to the command line. Check the content of
  772. logfile.txt.
  773. When pyclewn stops with the following error in the logfile:
  774. gdb CRITICAL cannot start gdb as "C:\msys\mingw\bin\gdb.exe"
  775. This means you have to update the shortcut command line with the correct path
  776. to gdb.
  777. Interrupt the debuggee:
  778. -----------------------
  779. Gdb is started with the "console-new" gdb variable set to on. When you start
  780. the debuggee, gdb pops up the console attached to the debuggee. You can type
  781. <Ctl-C> in the console to interrupt the debuggee.
  782. If this console bothers you, run the following gdb command: >
  783. :Cset new-console off
  784. Escape quotes:
  785. --------------
  786. The following is true as well for pyclewn on unix, but since pathnames
  787. containing space characters are common on Windows, it may be useful to recall
  788. that quotes must be escaped on Vim command line.
  789. For example one could write: >
  790. :Cfile \"\path with space\to\foobar.exe\"
  791. ==============================================================================
  792. 8. Key mappings *pyclewn-mappings*
  793. All|Ccommand|can be mapped to vim keys using the vim|:map-commands|.
  794. For example, to set a breakpoint at the current cursor position: >
  795. :map <F8> :exe "Cbreak " . expand("%:p") . ":" . line(".")<CR>
  796. Or to print the value of the variable under the cursor: >
  797. :map <F8> :exe "Cprint " . expand("<cword>") <CR>
  798. *Cmapkeys*
  799. Pyclewn key mappings:
  800. ---------------------
  801. This section describes another mapping mechanism where pyclewn maps vim keys
  802. by reading a configuration file. This is done when the|Cmapkeys|vim command is
  803. run. The pyclewn keys mapping is mostly useful for the pyclewn casual user.
  804. When the configuration file cannot be found, pyclewn sets the default key
  805. mappings. See|gdb-keys|for the list of default key mappings for gdb
  806. and|pdb-keys|for the list of default key mappings for pdb.
  807. Please note that pyclewn relies on the vim|balloon-eval|feature to get the
  808. text under the mouse position when expanding the ${text} macro. This feature
  809. is not available with vim console. So in this case you must build your own
  810. key mapping as in the above example.
  811. The configuration file is named .pyclewn_keys.{debugger}, where debugger is
  812. the name of the debugger. The default placement for this file is
  813. $CLEWNDIR/.pyclewn_keys.{debugger}, or $HOME/.pyclewn_keys.{debugger}.
  814. To customize pyclewn key mappings copy the configurations files found in the
  815. distribution to the proper directory: >
  816. cp runtime/.pyclewn_keys.gdb $CLEWNDIR
  817. or >
  818. cp runtime/.pyclewn_keys.gdb $HOME
  819. The comments in the configuration file explain how to customize the key
  820. mappings.
  821. On Windows, the .pyclewn_keys.{debugger} configuration files are found in the
  822. directory $VIM\vimfiles\macros. The value of $VIM can be obtained by running
  823. the following command in Vim: >
  824. :echo $VIM
  825. Copy these files to the $CLEWNDIR or $HOME directory, and customize the key
  826. mappings.
  827. ==============================================================================
  828. 9. Watched variables *pyclewn-variable*
  829. The Watched Variables feature is available with the gdb debugger. The vim
  830. watched variables buffer is named "(clewn)_dbgvar".
  831. *Cdbgvar*
  832. The|Cdbgvar|command is used to create a gdb watched variable in the variables
  833. buffer from any valid expression. A valid expression is an expression that is
  834. valid in the current frame.
  835. The argument of the|Cdbgvar|pyclewn command is the expression to be watched.
  836. For example, to create a watched variable for the expression "len - max":
  837. >
  838. :Cdbgvar len - max
  839. Upon creation, the watched variable is given a name by gdb, for example:
  840. <var1>.
  841. The watched variables buffer, "(clewn)_dbgvar", is created upon creation of
  842. the first watched variable. It is created but not displayed in a window.
  843. To display "(clewn)_dbgvar" just after the creation of the first variable: >
  844. :e #
  845. or >
  846. CTL-^
  847. Use the following command to find the number N of the "(clewn)_dbgvar"
  848. buffer: >
  849. :ls
  850. Knowing N, the following commands display the "(clewn)_dbgvar" buffer: >
  851. :Nb
  852. or >
  853. N CTL-^
  854. To split the current window and display "(clewn)_dbgvar": >
  855. :Nsb
  856. .
  857. *Cfoldvar*
  858. When the watched variable is a structure or class instance, it can be expanded
  859. with the|Cfoldvar|pyclewn command to display all its members and their values
  860. as children watched variables.
  861. The argument of the|Cfoldvar|command is the line number of the watched
  862. variable to expand, in the watched variable window.
  863. For example: >
  864. :Cfoldvar 1
  865. The|Cfoldvar|command is meant to be used in a key mapping. This is the 'X' key
  866. when using pyclewn key mappings, or one can use the following mapping:
  867. >
  868. :map <F8> :exe "Cfoldvar " . line(".")<CR>
  869. The watched variable can also be collapsed with the|Cfoldvar|command.
  870. *Cdelvar*
  871. A gdb watched variable can be deleted with the|Cdelvar|pyclewn command.
  872. The argument of the|Cdelvar|command is the name of the variable as given by
  873. gdb upon creation.
  874. For example: >
  875. :Cdelvar var1
  876. When the watched variable is a structure or class instance and it has been
  877. expanded, all its children are also deleted.
  878. *Csetfmtvar*
  879. Set the output format of the value of the watched variable <name>
  880. to be <format>: >
  881. :Csetfmtvar <name> <format>
  882. Parameter <name> is the gdb/mi name of the watched variable or one of its
  883. children.
  884. Parameter <format> is one of the strings in the following list:
  885. {binary | decimal | hexadecimal | octal | natural}
  886. The "natural" format is the default format chosen automatically based on the
  887. variable type (like "decimal" for an int, "hexadecimal" for pointers, etc.).
  888. For a variable with children, the format is set only on the variable itself,
  889. and the children are not affected.
  890. Note: The setting of the format of a child watched variable is lost after
  891. folding one of its parents (because the child is actually not watched anymore
  892. by gdb after the folding).
  893. Highlighting:
  894. -------------
  895. When the value of a watched variable has changed, it is highlighted with the
  896. "Special" highlight group.
  897. When a watched variable becomes out of scope, it is highlighted with the
  898. "Comment" highlight group.
  899. The foreground and background colors used by these highlight groups are setup
  900. by the|:colorscheme|currently in use.
  901. ==============================================================================
  902. 10. Extending pyclewn *pyclewn-extending*
  903. NAME
  904. debugger
  905. FILE
  906. clewn/debugger.py
  907. DESCRIPTION
  908. This module provides the basic infrastructure for using Vim as a
  909. front-end to a debugger.
  910. The basic idea behind this infrastructure is to subclass the 'Debugger'
  911. abstract class, list all the debugger commands and implement the
  912. processing of these commands in 'cmd_<command_name>' methods in the
  913. subclass. When the method is not implemented, the processing of the
  914. command is dispatched to the 'default_cmd_processing' method. These
  915. methods may call the 'Debugger' API methods to control Vim. For example,
  916. 'add_bp' may be called to set a breakpoint in a buffer in Vim, or
  917. 'console_print' may be called to write the output of a command in the
  918. Vim debugger console.
  919. The 'Debugger' subclass is made available to the user after adding an
  920. option to the 'parse_options' method in the 'Vim' class, see vim.py.
  921. The 'Simple' class in simple.py provides a simple example of a fake
  922. debugger front-end.
  923. CLASSES
  924. __builtin__.object
  925. Debugger
  926. class Debugger(__builtin__.object)
  927. | Abstract base class for pyclewn debuggers.
  928. |
  929. | The debugger commands received through netbeans 'keyAtPos' events
  930. | are dispatched to methods whose name starts with the 'cmd_' prefix.
  931. |
  932. | The signature of the cmd_<command_name> methods are:
  933. |
  934. | cmd_<command_name>(self, str cmd, str args)
  935. | cmd: the command name
  936. | args: the arguments of the command
  937. |
  938. | The '__init__' method of the subclass must call the '__init__'
  939. | method of 'Debugger' as its first statement and forward the method
  940. | parameters as an opaque list. The __init__ method must update the
  941. | 'cmds' and 'mapkeys' dict attributes with its own commands and key
  942. | mappings.
  943. |
  944. | Instance attributes:
  945. | cmds: dict
  946. | The debugger command names are the keys. The values are the
  947. | sequence of available completions on the command first
  948. | argument. The sequence is possibly empty, meaning no
  949. | completion. When the value is not a sequence (for example
  950. | None), this indicates file name completion.
  951. | mapkeys: dict
  952. | Key names are the dictionary keys. See the 'keyCommand'
  953. | event in Vim netbeans documentation for the definition of a
  954. | key name. The values are a tuple made of two strings
  955. | (command, comment):
  956. | 'command' is the debugger command mapped to this key
  957. | 'comment' is an optional comment
  958. | One can use template substitution on 'command', see the file
  959. | runtime/.pyclewn_keys.template for a description of this
  960. | feature.
  961. | options: optparse.Values
  962. | The pyclewn command line parameters.
  963. | vim_socket_map: dict
  964. | The asyncore socket dictionary
  965. | testrun: boolean
  966. | True when run from a test suite
  967. | started: boolean
  968. | True when the debugger is started.
  969. | closed: boolean
  970. | True when the debugger is closed.
  971. | pyclewn_cmds: dict
  972. | The subset of 'cmds' that are pyclewn specific commands.
  973. | __nbsock: netbeans.Netbeans
  974. | The netbeans asynchat socket.
  975. | _jobs: list
  976. | list of pending jobs to run on a timer event in the
  977. | dispatch loop
  978. | _jobs_enabled: bool
  979. | process enqueued jobs when True
  980. | _last_balloon: str
  981. | The last balloonText event received.
  982. | prompt: str
  983. | The prompt printed on the console.
  984. | _consbuffered: boolean
  985. | True when output to the vim debugger console is buffered
  986. |
  987. | Methods defined here:
  988. |
  989. | __init__(self, options, vim_socket_map, testrun)
  990. | Initialize instance variables and the prompt.
  991. |
  992. | __str__(self)
  993. | Return the string representation.
  994. |
  995. | add_bp(self, bp_id, pathname, lnum)
  996. | Add a breakpoint to a Vim buffer at lnum.
  997. |
  998. | Load the buffer in Vim and set an highlighted sign at 'lnum'.
  999. |
  1000. | Method parameters:
  1001. | bp_id: object
  1002. | The debugger breakpoint id.
  1003. | pathname: str
  1004. | The absolute pathname to the Vim buffer.
  1005. | lnum: int
  1006. | The line number in the Vim buffer.
  1007. |
  1008. | balloon_text(self, text)
  1009. | Process a netbeans balloonText event.
  1010. |
  1011. | Used when 'ballooneval' is set and the mouse pointer rests on
  1012. | some text for a moment.
  1013. |
  1014. | Method parameter:
  1015. | text: str
  1016. | The text under the mouse pointer.
  1017. |
  1018. | close(self)
  1019. | Close the debugger and remove all signs in Vim.
  1020. |
  1021. | cmd_dumprepr(self, cmd, args)
  1022. | Print debugging information on netbeans and the debugger.
  1023. |
  1024. | cmd_help(self, *args)
  1025. | Print help on all pyclewn commands in the Vim debugger
  1026. | console.
  1027. |
  1028. | cmd_loglevel(self, cmd, level)
  1029. | Get or set the pyclewn log level.
  1030. |
  1031. | cmd_mapkeys(self, *args)
  1032. | Map the pyclewn keys.
  1033. |
  1034. | cmd_unmapkeys(self, cmd, *args)
  1035. | Unmap the pyclewn keys.
  1036. |
  1037. | This is actually a Vim command and it does not involve pyclewn.
  1038. |
  1039. | console_flush(self)
  1040. | Flush the console.
  1041. |
  1042. | console_print(self, format, *args)
  1043. | Print a format string and its arguments to the console.
  1044. |
  1045. | Method parameters:
  1046. | format: str
  1047. | The message format string.
  1048. | args: str
  1049. | The arguments which are merged into 'format' using the
  1050. | python string formatting operator.
  1051. |
  1052. | debugger_background_jobs = _newf(self, *args, **kwargs)
  1053. | The decorated method.
  1054. |
  1055. | default_cmd_processing(self, cmd, args)
  1056. | Fall back method for commands not handled by a 'cmd_<name>'
  1057. | method.
  1058. |
  1059. | This method must be implemented in a subclass.
  1060. |
  1061. | Method parameters:
  1062. | cmd: str
  1063. | The command name.
  1064. | args: str
  1065. | The arguments of the command.
  1066. |
  1067. | delete_bp(self, bp_id)
  1068. | Delete a breakpoint.
  1069. |
  1070. | The breakpoint must have been already set in a Vim buffer with
  1071. | 'add_bp'.
  1072. |
  1073. | Method parameter:
  1074. | bp_id: object
  1075. | The debugger breakpoint id.
  1076. |
  1077. | get_console(self)
  1078. | Return the console.
  1079. |
  1080. | get_lnum_list(self, pathname)
  1081. | Return a list of line numbers of all enabled breakpoints in a
  1082. | Vim buffer.
  1083. |
  1084. | A line number may be duplicated in the list.
  1085. | This is used by Simple and may not be useful to other debuggers.
  1086. |
  1087. | Method parameter:
  1088. | pathname: str
  1089. | The absolute pathname to the Vim buffer.
  1090. |
  1091. | inferiortty(self)
  1092. | Spawn the inferior terminal.
  1093. |
  1094. | netbeans_detach(self)
  1095. | Request vim to close the netbeans session.
  1096. |
  1097. | not_a_pyclewn_method(self, cmd)
  1098. | "Warn that 'cmd' cannot be used as 'C' parameter.
  1099. |
  1100. | post_cmd(self, cmd, args)
  1101. | The method called after each invocation of a 'cmd_<name>'
  1102. | method.
  1103. |
  1104. | This method must be implemented in a subclass.
  1105. |
  1106. | Method parameters:
  1107. | cmd: str
  1108. | The command name.
  1109. | args: str
  1110. | The arguments of the command.
  1111. |
  1112. | pre_cmd(self, cmd, args)
  1113. | The method called before each invocation of a 'cmd_<name>'
  1114. | method.
  1115. |
  1116. | This method must be implemented in a subclass.
  1117. |
  1118. | Method parameters:
  1119. | cmd: str
  1120. | The command name.
  1121. | args: str
  1122. | The arguments of the command.
  1123. |
  1124. | print_prompt(self)
  1125. | Print the prompt in the Vim debugger console.
  1126. |
  1127. | remove_all(self)
  1128. | Remove all annotations.
  1129. |
  1130. | Vim signs are unplaced.
  1131. | Annotations are not deleted.
  1132. |
  1133. | set_nbsock(self, nbsock)
  1134. | Set the netbeans socket.
  1135. |
  1136. | set_nbsock_owner(self, thread_ident, socket_map=None)
  1137. | Add nbsock to 'socket_map' and make 'thread_ident' nbsock owner.
  1138. |
  1139. | show_balloon(self, text)
  1140. | Show 'text' in the Vim balloon.
  1141. |
  1142. | Method parameter:
  1143. | text: str
  1144. | The text to show in the balloon.
  1145. |
  1146. | show_frame(self, pathname=None, lnum=1)
  1147. | Show the frame highlighted sign in a Vim buffer.
  1148. |
  1149. | The frame sign is unique.
  1150. | Remove the frame sign when 'pathname' is None.
  1151. |
  1152. | Method parameters:
  1153. | pathname: str
  1154. | The absolute pathname to the Vim buffer.
  1155. | lnum: int
  1156. | The line number in the Vim buffer.
  1157. |
  1158. | start(self)
  1159. | This method must be implemented in a subclass.
  1160. |
  1161. | timer(self, callme, delta)
  1162. | Schedule the 'callme' job at 'delta' time from now.
  1163. |
  1164. | The timer granularity is LOOP_TIMEOUT, so it does not make sense
  1165. | to request a 'delta' time less than LOOP_TIMEOUT.
  1166. |
  1167. | Method parameters:
  1168. | callme: callable
  1169. | the job being scheduled
  1170. | delta: float
  1171. | time interval
  1172. |
  1173. | update_bp(self, bp_id, disabled=False)
  1174. | Update the enable/disable state of a breakpoint.
  1175. |
  1176. | The breakpoint must have been already set in a Vim buffer with
  1177. | 'add_bp'.
  1178. | Return True when successful.
  1179. |
  1180. | Method parameters:
  1181. | bp_id: object
  1182. | The debugger breakpoint id.
  1183. | disabled: bool
  1184. | When True, set the breakpoint as disabled.
  1185. |
  1186. | update_dbgvarbuf(self, getdata, dirty, lnum=None)
  1187. | Update the variables buffer in Vim.
  1188. |
  1189. | Update the variables buffer in Vim when one the following
  1190. | conditions is
  1191. | True:
  1192. | * 'dirty' is True
  1193. | * the content of the Vim variables buffer and the content of
  1194. | pyclewn 'dbgvarbuf' are not consistent after an error in the
  1195. | netbeans protocol occured
  1196. | Set the Vim cursor at 'lnum' after the buffer has been updated.
  1197. |
  1198. | Method parameters:
  1199. | getdata: callable
  1200. | A callable that returns the content of the variables
  1201. | buffer as a string.
  1202. | dirty: bool
  1203. | When True, force updating the buffer.
  1204. | lnum: int
  1205. | The line number in the Vim buffer.
  1206. |
  1207. | vim_script_custom(self, prefix)
  1208. | Return debugger specific Vim statements as a string.
  1209. |
  1210. | A Vim script is run on Vim start-up, for example to define all
  1211. | the debugger commands in Vim. This method may be overriden to
  1212. | add some debugger specific Vim statements or functions to this
  1213. | script.
  1214. |
  1215. | Method parameter:
  1216. | prefix: str
  1217. | The prefix used for the debugger commands in Vim.
  1218. |
  1219. FUNCTIONS
  1220. restart_timer(timeout)
  1221. Decorator to re-schedule the method at 'timeout', after it has run.
  1222. ==============================================================================
  1223. vim:tw=78:ts=8:ft=help:norl:et: