Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) S390 Debug Feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)       - arch/s390/kernel/debug.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)       - arch/s390/include/asm/debug.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) The goal of this feature is to provide a kernel debug logging API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) where log records can be stored efficiently in memory, where each component
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) (e.g. device drivers) can have one separate debug log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) One purpose of this is to inspect the debug logs after a production system crash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) in order to analyze the reason for the crash.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) If the system still runs but only a subcomponent which uses dbf fails,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) it is possible to look at the debug logs on a live system via the Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) debugfs filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) The debug feature may also very useful for kernel and driver development.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) Design:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) -------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) Kernel components (e.g. device drivers) can register themselves at the debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) feature with the function call :c:func:`debug_register()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) This function initializes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) debug log for the caller. For each debug log exists a number of debug areas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) where exactly one is active at one time.  Each debug area consists of contiguous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) pages in memory. In the debug areas there are stored debug entries (log records)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) which are written by event- and exception-calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) An event-call writes the specified debug entry to the active debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) area and updates the log pointer for the active area. If the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) of the active debug area is reached, a wrap around is done (ring buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) and the next debug entry will be written at the beginning of the active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) debug area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) An exception-call writes the specified debug entry to the log and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) switches to the next debug area. This is done in order to be sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) that the records which describe the origin of the exception are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) overwritten when a wrap around for the current area occurs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) The debug areas themselves are also ordered in form of a ring buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) When an exception is thrown in the last debug area, the following debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) entries are then written again in the very first area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) There are four versions for the event- and exception-calls: One for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) logging raw data, one for text, one for numbers (unsigned int and long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) and one for sprintf-like formatted strings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) Each debug entry contains the following data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) - Timestamp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) - Cpu-Number of calling task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) - Level of debug entry (0...6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) - Return Address to caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) - Flag, if entry is an exception or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) The debug logs can be inspected in a live system through entries in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) the debugfs-filesystem. Under the toplevel directory "``s390dbf``" there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) a directory for each registered component, which is named like the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) corresponding component. The debugfs normally should be mounted to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) ``/sys/kernel/debug`` therefore the debug feature can be accessed under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) ``/sys/kernel/debug/s390dbf``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) The content of the directories are files which represent different views
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) to the debug log. Each component can decide which views should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) used through registering them with the function :c:func:`debug_register_view()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) Predefined views for hex/ascii and sprintf data are provided.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) It is also possible to define other views. The content of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) a view can be inspected simply by reading the corresponding debugfs file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) All debug logs have an actual debug level (range from 0 to 6).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) The default level is 3. Event and Exception functions have a :c:data:`level`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) parameter. Only debug entries with a level that is lower or equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) than the actual level are written to the log. This means, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) writing events, high priority log entries should have a low level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) value whereas low priority entries should have a high one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) The actual debug level can be changed with the help of the debugfs-filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) through writing a number string "x" to the ``level`` debugfs file which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) provided for every debug log. Debugging can be switched off completely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) by using "-" on the ``level`` debugfs file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	> echo "-" > /sys/kernel/debug/s390dbf/dasd/level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) It is also possible to deactivate the debug feature globally for every
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) debug log. You can change the behavior using  2 sysctl parameters in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) ``/proc/sys/s390dbf``:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) There are currently 2 possible triggers, which stop the debug feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) globally. The first possibility is to use the ``debug_active`` sysctl. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) set to 1 the debug feature is running. If ``debug_active`` is set to 0 the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) debug feature is turned off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) The second trigger which stops the debug feature is a kernel oops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) That prevents the debug feature from overwriting debug information that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) happened before the oops. After an oops you can reactivate the debug feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) by piping 1 to ``/proc/sys/s390dbf/debug_active``. Nevertheless, it's not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) suggested to use an oopsed kernel in a production environment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) If you want to disallow the deactivation of the debug feature, you can use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) the ``debug_stoppable`` sysctl. If you set ``debug_stoppable`` to 0 the debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) feature cannot be stopped. If the debug feature is already stopped, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) will stay deactivated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) Kernel Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .. kernel-doc:: arch/s390/kernel/debug.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .. kernel-doc:: arch/s390/include/asm/debug.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Predefined views:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)   extern struct debug_view debug_hex_ascii_view;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)   extern struct debug_view debug_sprintf_view;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) Examples
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) --------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)   /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)    * hex_ascii-view Example
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)   #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)   #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)   static debug_info_t *debug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)   static int init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)       /* register 4 debug areas with one page each and 4 byte data field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)       debug_info = debug_register("test", 1, 4, 4 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)       debug_register_view(debug_info, &debug_hex_ascii_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)       debug_text_event(debug_info, 4 , "one ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)       debug_int_exception(debug_info, 4, 4711);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)       debug_event(debug_info, 3, &debug_info, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)       return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)   static void cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)       debug_unregister(debug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)   module_init(init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)   module_exit(cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)   /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)    * sprintf-view Example
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)   #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)   #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)   static debug_info_t *debug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)   static int init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)       /* register 4 debug areas with one page each and data field for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)       /* format string pointer + 2 varargs (= 3 * sizeof(long))       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)       debug_info = debug_register("test", 1, 4, sizeof(long) * 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)       debug_register_view(debug_info, &debug_sprintf_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)       debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)       debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)       return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)   static void cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)       debug_unregister(debug_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)   module_init(init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)   module_exit(cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) Debugfs Interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) Views to the debug logs can be investigated through reading the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) debugfs-files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)   > ls /sys/kernel/debug/s390dbf/dasd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)   flush  hex_ascii  level pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)   > cat /sys/kernel/debug/s390dbf/dasd/hex_ascii | sort -k2,2 -s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)   00 00974733272:680099 2 - 02 0006ad7e  07 ea 4a 90 | ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)   00 00974733272:682210 2 - 02 0006ade6  46 52 45 45 | FREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)   00 00974733272:682213 2 - 02 0006adf6  07 ea 4a 90 | ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)   00 00974733272:682281 1 * 02 0006ab08  41 4c 4c 43 | EXCP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)   01 00974733272:682284 2 - 02 0006ab16  45 43 4b 44 | ECKD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)   01 00974733272:682287 2 - 02 0006ab28  00 00 00 04 | ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)   01 00974733272:682289 2 - 02 0006ab3e  00 00 00 20 | ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)   01 00974733272:682297 2 - 02 0006ad7e  07 ea 4a 90 | ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)   01 00974733272:684384 2 - 00 0006ade6  46 52 45 45 | FREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)   01 00974733272:684388 2 - 00 0006adf6  07 ea 4a 90 | ....
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) See section about predefined views for explanation of the above output!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) Changing the debug level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)   > cat /sys/kernel/debug/s390dbf/dasd/level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)   3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)   > echo "5" > /sys/kernel/debug/s390dbf/dasd/level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)   > cat /sys/kernel/debug/s390dbf/dasd/level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)   5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) Flushing debug areas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) Debug areas can be flushed with piping the number of the desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) area (0...n) to the debugfs file "flush". When using "-" all debug areas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) are flushed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) Examples:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 1. Flush debug area 0::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)      > echo "0" > /sys/kernel/debug/s390dbf/dasd/flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 2. Flush all debug areas::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)      > echo "-" > /sys/kernel/debug/s390dbf/dasd/flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) Changing the size of debug areas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) It is possible the change the size of debug areas through piping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) the number of pages to the debugfs file "pages". The resize request will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) also flush the debug areas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) Define 4 pages for the debug areas of debug feature "dasd"::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)   > echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) Stopping the debug feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 1. Check if stopping is allowed::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)      > cat /proc/sys/s390dbf/debug_stoppable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 2. Stop debug feature::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)      > echo 0 > /proc/sys/s390dbf/debug_active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) crash Interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) The ``crash`` tool since v5.1.0 has a built-in command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ``s390dbf`` to display all the debug logs or export them to the file system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) With this tool it is possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) to investigate the debug logs on a live system and with a memory dump after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) a system crash.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) Investigating raw memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) One last possibility to investigate the debug logs at a live
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) system and after a system crash is to look at the raw memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) under VM or at the Service Element.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) It is possible to find the anchor of the debug-logs through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) the ``debug_area_first`` symbol in the System map. Then one has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) to follow the correct pointers of the data-structures defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) in debug.h and find the debug-areas in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) Normally modules which use the debug feature will also have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) a global variable with the pointer to the debug-logs. Following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) this pointer it will also be possible to find the debug logs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) for the length of the data field in :c:func:`debug_register()` in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) order to see the debug entries well formatted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) Predefined Views
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) There are two predefined views: hex_ascii and sprintf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) The hex_ascii view shows the data field in hex and ascii representation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) (e.g. ``45 43 4b 44 | ECKD``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) The sprintf view formats the debug entries in the same way as the sprintf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) function would do. The sprintf event/exception functions write to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) debug entry a pointer to the format string (size = sizeof(long))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) and for each vararg a long value. So e.g. for a debug entry with a format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) string plus two varargs one would need to allocate a (3 * sizeof(long))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) byte data area in the debug_register() function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) IMPORTANT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)   Using "%s" in sprintf event functions is dangerous. You can only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)   use "%s" in the sprintf event functions, if the memory for the passed string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)   is available as long as the debug feature exists. The reason behind this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)   that due to performance considerations only a pointer to the string is stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)   in  the debug feature. If you log a string that is freed afterwards, you will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)   get an OOPS when inspecting the debug feature, because then the debug feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)   will access the already freed memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) NOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)   If using the sprintf view do NOT use other event/exception functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)   than the sprintf-event and -exception functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) The format of the hex_ascii and sprintf view is as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) - Number of area
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) - Timestamp (formatted as seconds and microseconds since 00:00:00 Coordinated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)   Universal Time (UTC), January 1, 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) - level of debug entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) - Exception flag (* = Exception)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) - Cpu-Number of calling task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) - Return Address to caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) - data field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) A typical line of the hex_ascii view will look like the following (first line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) is only for explanation and will not be displayed when 'cating' the view)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)   area  time           level exception cpu caller    data (hex + ascii)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)   --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)   00    00964419409:440690 1 -         00  88023fe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) Defining views
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) Views are specified with the 'debug_view' structure. There are defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) callback functions which are used for reading and writing the debugfs files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)   struct debug_view {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	char name[DEBUG_MAX_PROCF_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	debug_prolog_proc_t* prolog_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	debug_header_proc_t* header_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	debug_format_proc_t* format_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	debug_input_proc_t*  input_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	void*                private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)   };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) where:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)   typedef int (debug_header_proc_t) (debug_info_t* id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 				     struct debug_view* view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 				     int area,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				     debug_entry_t* entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 				     char* out_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)   typedef int (debug_format_proc_t) (debug_info_t* id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 				     struct debug_view* view, char* out_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 				     const char* in_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)   typedef int (debug_prolog_proc_t) (debug_info_t* id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				     struct debug_view* view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 				     char* out_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)   typedef int (debug_input_proc_t) (debug_info_t* id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 				    struct debug_view* view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 				    struct file* file, const char* user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				    size_t in_buf_size, loff_t* offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) The "private_data" member can be used as pointer to view specific data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) It is not used by the debug feature itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) The output when reading a debugfs file is structured like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)   "prolog_proc output"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)   "header_proc output 1"  "format_proc output 1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)   "header_proc output 2"  "format_proc output 2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)   "header_proc output 3"  "format_proc output 3"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)   ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) When a view is read from the debugfs, the Debug Feature calls the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 'prolog_proc' once for writing the prolog.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) Then 'header_proc' and 'format_proc' are called for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) existing debug entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) The input_proc can be used to implement functionality when it is written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) the view (e.g. like with ``echo "0" > /sys/kernel/debug/s390dbf/dasd/level``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) For header_proc there can be used the default function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) :c:func:`debug_dflt_header_fn()` which is defined in debug.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) and which produces the same header output as the predefined views.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) E.g::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)   00 00964419409:440761 2 - 00 88023ec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) In order to see how to use the callback functions check the implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) of the default views!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)   #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)   #define UNKNOWNSTR "data: %08x"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)   const char* messages[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)   {"This error...........\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)    "That error...........\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)    "Problem..............\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)    "Something went wrong.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)    "Everything ok........\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)    NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)   };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)   static int debug_test_format_fn(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)      debug_info_t *id, struct debug_view *view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)      char *out_buf, const char *in_buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)   )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)   {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)     int i, rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)     if (id->buf_size >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)        int msg_nr = *((int*)in_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)        if (msg_nr < sizeof(messages) / sizeof(char*) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	  rc += sprintf(out_buf, "%s", messages[msg_nr]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)        else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	  rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)     return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)   struct debug_view debug_test_view = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)     "myview",                 /* name of view */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)     NULL,                     /* no prolog */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)     &debug_dflt_header_fn,    /* default header for each entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)     &debug_test_format_fn,    /* our own format function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)     NULL,                     /* no input function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)     NULL                      /* no private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)   };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) test:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) =====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)   debug_info_t *debug_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)   int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)   ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)   debug_info = debug_register("test", 0, 4, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)   debug_register_view(debug_info, &debug_test_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)   for (i = 0; i < 10; i ++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)     debug_int_event(debug_info, 1, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)   > cat /sys/kernel/debug/s390dbf/test/myview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)   00 00964419734:611402 1 - 00 88042ca   This error...........
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)   00 00964419734:611405 1 - 00 88042ca   That error...........
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)   00 00964419734:611408 1 - 00 88042ca   Problem..............
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)   00 00964419734:611411 1 - 00 88042ca   Something went wrong.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)   00 00964419734:611414 1 - 00 88042ca   Everything ok........
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)   00 00964419734:611417 1 - 00 88042ca   data: 00000005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)   00 00964419734:611419 1 - 00 88042ca   data: 00000006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)   00 00964419734:611422 1 - 00 88042ca   data: 00000007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)   00 00964419734:611425 1 - 00 88042ca   data: 00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)   00 00964419734:611428 1 - 00 88042ca   data: 00000009