Documentation/admin-guide/dynamic-debug-howto.rst

Source file repositories/reference/linux-study-clean/Documentation/admin-guide/dynamic-debug-howto.rst

File Facts

System
Linux kernel
Corpus path
Documentation/admin-guide/dynamic-debug-howto.rst
Extension
.rst
Size
13597 bytes
Lines
393
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

Dynamic debug
+++++++++++++


Introduction
============

Dynamic debug allows you to dynamically enable/disable kernel
debug-print code to obtain additional kernel information.

If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic
debug.  You'll need root access (sudo su) to use this.

Dynamic debug provides:

 * a Catalog of all *prdbgs* in your kernel.
   ``cat /proc/dynamic_debug/control`` to see them.

 * a Simple query/command language to alter *prdbgs* by selecting on
   any combination of 0 or 1 of:

   - source filename
   - function name
   - line number (including ranges of line numbers)
   - module name
   - format string
   - class name (as known/declared by each module)

NOTE: To actually get the debug-print output on the console, you may
need to adjust the kernel ``loglevel=``, or use ``ignore_loglevel``.
Read about these kernel parameters in
Documentation/admin-guide/kernel-parameters.rst.

Viewing Dynamic Debug Behaviour
===============================

You can view the currently configured behaviour in the *prdbg* catalog::

  :#> head -n7 /proc/dynamic_debug/control
  # filename:lineno [module]function flags format
  init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\n"
  init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\n"
  init/main.c:1424 [main]run_init_process =_ "  with arguments:\n"
  init/main.c:1426 [main]run_init_process =_ "    %s\n"
  init/main.c:1427 [main]run_init_process =_ "  with environment:\n"
  init/main.c:1429 [main]run_init_process =_ "    %s\n"

The 3rd space-delimited column shows the current flags, preceded by
a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites.

Controlling dynamic debug Behaviour
===================================

The behaviour of *prdbg* sites are controlled by writing
query/commands to the control file.  Example::

  # grease the interface
  :#> alias ddcmd='echo $* > /proc/dynamic_debug/control'

  :#> ddcmd '-p; module main func run* +p'
  :#> grep =p /proc/dynamic_debug/control
  init/main.c:1424 [main]run_init_process =p "  with arguments:\n"
  init/main.c:1426 [main]run_init_process =p "    %s\n"
  init/main.c:1427 [main]run_init_process =p "  with environment:\n"
  init/main.c:1429 [main]run_init_process =p "    %s\n"

Error messages go to console/syslog::

  :#> ddcmd mode foo +p
  dyndbg: unknown keyword "mode"

Annotation

Implementation Notes