File: crash_compatibility.rst

package info (click to toggle)
drgn 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,852 kB
  • sloc: python: 74,992; ansic: 54,589; awk: 423; makefile: 351; sh: 99
file content (66 lines) | stat: -rw-r--r-- 1,740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Crash Compatibility
===================

.. highlight:: pycon

drgn provides a compatibility mode emulating the `crash utility
<https://crash-utility.github.io/>`_. Many commands have been ported from
crash. Output is not byte-identical, but it generally closely resembles crash
output.

These commands can be run directly from the drgn CLI as subcommands of the
:drgncommand:`crash` command::

    >>> %crash sys
    KERNEL: ...

Crash commands take an additional ``--drgn`` option instructing them to print
example drgn code that does the equivalent of the command. This is useful for
learning about drgn helpers and APIs. It can also be used to generate a
template for doing something more advanced than the command supports. You can
copy and paste the output or even write it to a file and edit it before running
it:

.. code-block:: pycon
    :force:

    >>> %crash mount --drgn > mount.py
    >>> %sh $EDITOR mount.py
    >>> %source mount.py

Interactive Crash Prompt
------------------------

Calling the :drgncommand:`crash` command with no arguments enters an
interactive prompt where crash commands can be called directly::

    >>> %crash
    %crash> sys
    KERNEL: ...
    %crash>

drgn code can be executed from the interactive crash prompt with the
:drgncommand:`drgn <crash.drgn>` command::

    %crash> drgn stack_trace(1)[0]["next"].pid
    (pid_t)0

Calling the :drgncommand:`drgn <crash.drgn>` command with no arguments returns
to the drgn CLI::

    %crash> drgn
    >>>

The interactive prompt can also be entered directly from a shell with the
:doc:`drgn-crash <man/drgn-crash>` script:

.. code-block:: console

    $ drgn-crash
    KERNEL: ...
    %crash>

Commands
--------

.. drgndoc-command-namespace:: crash