Differences between revisions 12 and 13
Revision 12 as of 2013-09-14 16:39:48
Size: 2179
Editor: mpm
Comment:
Revision 13 as of 2017-10-18 17:54:48
Size: 2485
Comment: how to debug using PuDB
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
||||||<style="text-align:center">'''Global Options''' ||
||{{{-v, --verbose}}} ||show more verbose output ||
||{{{--debug}}} ||show extended debugging output ||
||{{{--traceback}}} ||show Python tracebacks that are otherwise hidden ||
||{{{--profile}}} ||generate performance profiling information ||
||{{{--debugger}}} ||drop into the built-in source-level debugger (more below) ||
Line 5: Line 11:
|||||| '''Global Options''' ||
|| {{{-v, --verbose}}} || show more verbose output ||
|| {{{--debug}}} || show extended debugging output ||
|| {{{--traceback}}} || show Python tracebacks that are otherwise hidden ||
|| {{{--profile}}} || generate performance profiling information ||
|| {{{--debugger}}} || drop into the built-in source-level debugger (more below) ||

Line 14: Line 16:
|||||| '''Debug Commands''' ||
|| {{{ debugcheckstate }}} ||  validate the correctness of the current dirstate ||
|| {{{ debugconfig }}} || show combined config settings from all hgrc files ||
|| {{{ debugdata }}} || dump the contents of an data file revision ||
|| {{{ debugindex }}}    || dump the contents of an index file ||
|| {{{ debugindexdot }}} ||  dump an index DAG as a .dot file ||
|| {{{ debugrename }}} || dump rename information ||
|| {{{ debugstate }}} || show the contents of the current dirstate ||
|| {{{ debugwalk }}}     || show how files match on given patterns ||
||||||<style="text-align:center">'''Debug Commands''' ||
||{{{ debugcheckstate }}} ||validate the correctness of the current dirstate ||
||{{{ debugconfig }}} ||show combined config settings from all hgrc files ||
||{{{ debugdata }}} ||dump the contents of an data file revision ||
||{{{ debugindex }}} ||dump the contents of an index file ||
||{{{ debugindexdot }}} ||dump an index DAG as a .dot file ||
||{{{ debugrename }}} ||dump rename information ||
||{{{ debugstate }}} ||show the contents of the current dirstate ||
||{{{ debugwalk }}} ||show how files match on given patterns ||
Line 25: Line 28:
Line 44: Line 48:
Documentation for some debug commands is available through {{{hg help}}}:
Line 45: Line 50:
Documentation for some debug commands is available through {{{hg help}}}:
Line 55: Line 59:
=== using the debugger === === using the basic debugger ===
Line 57: Line 61:
{{{hg --debugger <command>}}} will drop you at the debug prompt shortly before command execution. This
will allow you to set breakpoints, singlestep code, inspect data structures, and run arbitrary bits of Python
code. Help is available with '?'.
{{{hg --debugger <command>}}} will drop you at the debug prompt shortly before command execution. This will allow you to set breakpoints, singlestep code, inspect data structures, and run arbitrary bits of Python code. Help is available with '?'.
Line 62: Line 64:

=== using a better debugger ===

[[https://documen.tician.de/pudb/|PuDB]] is a far more useful debugger than Python's native {{{pdb}}}. To use PuDB:
 1. pip install pudb
 1. Add to {{{~/.hgrc}}}:
 {{{
 [ui]
 debugger = pudb
 }}}
 1. Invoke {{{hg --debugger <command>}}} as described above.

Mercurial has a bunch of features for debugging problems that are useful for developers to know about.

See also: DebuggingTests

Global Options

-v, --verbose

show more verbose output

--debug

show extended debugging output

--traceback

show Python tracebacks that are otherwise hidden

--profile

generate performance profiling information

--debugger

drop into the built-in source-level debugger (more below)

Debug Commands

 debugcheckstate 

validate the correctness of the current dirstate

 debugconfig 

show combined config settings from all hgrc files

 debugdata 

dump the contents of an data file revision

 debugindex 

dump the contents of an index file

 debugindexdot 

dump an index DAG as a .dot file

 debugrename 

dump rename information

 debugstate 

show the contents of the current dirstate

 debugwalk 

show how files match on given patterns

To get a complete up-to-date list of all available debug commands use hg debugcomplete debug:

> hg debugcomplete debug
debugancestor
debugcheckstate
debugcomplete
debugconfig
debugdata
debugdate
debugfsinfo
debugindex
debugindexdot
debuginstall
debugrawcommit
debugrebuildstate
debugrename
debugsetparents
debugstate
debugwalk

Documentation for some debug commands is available through hg help:

> hg help debugstate
hg debugstate

show the contents of the current dirstate

use "hg -v help debugstate" to show global options

using the basic debugger

hg --debugger <command> will drop you at the debug prompt shortly before command execution. This will allow you to set breakpoints, singlestep code, inspect data structures, and run arbitrary bits of Python code. Help is available with '?'.

If you let Mercurial run (with 'cont'), the debugger will be reinvoked if an exception occurs. This is useful for diagnosing tracebacks in situ.

using a better debugger

PuDB is a far more useful debugger than Python's native pdb. To use PuDB:

  1. pip install pudb
  2. Add to ~/.hgrc:

     [ui]
     debugger = pudb
  3. Invoke hg --debugger <command> as described above.


CategoryInternals

DebuggingFeatures (last edited 2018-03-14 19:43:27 by HollisBlanchard)