blob: fcaf0b4efba21cfe51ed1aa4a6d9303aa614dea5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001S390 Debug Feature
2==================
3
4files: arch/s390/kernel/debug.c
Randy Dunlap58cc8552009-01-06 14:42:42 -08005 arch/s390/include/asm/debug.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
7Description:
8------------
9The goal of this feature is to provide a kernel debug logging API
10where log records can be stored efficiently in memory, where each component
11(e.g. device drivers) can have one separate debug log.
12One purpose of this is to inspect the debug logs after a production system crash
13in order to analyze the reason for the crash.
Matt LaPlantea2ffd272006-10-03 22:49:15 +020014If the system still runs but only a subcomponent which uses dbf fails,
Michael Holzheu66a464d2005-06-25 14:55:33 -070015it is possible to look at the debug logs on a live system via the Linux
16debugfs filesystem.
Linus Torvalds1da177e2005-04-16 15:20:36 -070017The debug feature may also very useful for kernel and driver development.
18
19Design:
20-------
21Kernel components (e.g. device drivers) can register themselves at the debug
22feature with the function call debug_register(). This function initializes a
23debug log for the caller. For each debug log exists a number of debug areas
24where exactly one is active at one time. Each debug area consists of contiguous
25pages in memory. In the debug areas there are stored debug entries (log records)
26which are written by event- and exception-calls.
27
28An event-call writes the specified debug entry to the active debug
29area and updates the log pointer for the active area. If the end
30of the active debug area is reached, a wrap around is done (ring buffer)
31and the next debug entry will be written at the beginning of the active
32debug area.
33
34An exception-call writes the specified debug entry to the log and
35switches to the next debug area. This is done in order to be sure
36that the records which describe the origin of the exception are not
37overwritten when a wrap around for the current area occurs.
38
Nicolas Kaiser2254f5a2006-12-04 15:40:23 +010039The debug areas themselves are also ordered in form of a ring buffer.
Linus Torvalds1da177e2005-04-16 15:20:36 -070040When an exception is thrown in the last debug area, the following debug
41entries are then written again in the very first area.
42
43There are three versions for the event- and exception-calls: One for
44logging raw data, one for text and one for numbers.
45
46Each debug entry contains the following data:
47
48- Timestamp
49- Cpu-Number of calling task
50- Level of debug entry (0...6)
51- Return Address to caller
52- Flag, if entry is an exception or not
53
54The debug logs can be inspected in a live system through entries in
Michael Holzheu66a464d2005-06-25 14:55:33 -070055the debugfs-filesystem. Under the toplevel directory "s390dbf" there is
Linus Torvalds1da177e2005-04-16 15:20:36 -070056a directory for each registered component, which is named like the
Michael Holzheu66a464d2005-06-25 14:55:33 -070057corresponding component. The debugfs normally should be mounted to
Nicolas Kaiser2254f5a2006-12-04 15:40:23 +010058/sys/kernel/debug therefore the debug feature can be accessed under
Michael Holzheu66a464d2005-06-25 14:55:33 -070059/sys/kernel/debug/s390dbf.
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61The content of the directories are files which represent different views
62to the debug log. Each component can decide which views should be
63used through registering them with the function debug_register_view().
64Predefined views for hex/ascii, sprintf and raw binary data are provided.
65It is also possible to define other views. The content of
Michael Holzheu66a464d2005-06-25 14:55:33 -070066a view can be inspected simply by reading the corresponding debugfs file.
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Paolo Ornati670e9f32006-10-03 22:57:56 +020068All debug logs have an actual debug level (range from 0 to 6).
Linus Torvalds1da177e2005-04-16 15:20:36 -070069The default level is 3. Event and Exception functions have a 'level'
70parameter. Only debug entries with a level that is lower or equal
71than the actual level are written to the log. This means, when
72writing events, high priority log entries should have a low level
73value whereas low priority entries should have a high one.
Michael Holzheu66a464d2005-06-25 14:55:33 -070074The actual debug level can be changed with the help of the debugfs-filesystem
75through writing a number string "x" to the 'level' debugfs file which is
Linus Torvalds1da177e2005-04-16 15:20:36 -070076provided for every debug log. Debugging can be switched off completely
Michael Holzheu66a464d2005-06-25 14:55:33 -070077by using "-" on the 'level' debugfs file.
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79Example:
80
Michael Holzheu66a464d2005-06-25 14:55:33 -070081> echo "-" > /sys/kernel/debug/s390dbf/dasd/level
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83It is also possible to deactivate the debug feature globally for every
84debug log. You can change the behavior using 2 sysctl parameters in
85/proc/sys/s390dbf:
Matt LaPlante992caac2006-10-03 22:52:05 +020086There are currently 2 possible triggers, which stop the debug feature
87globally. The first possibility is to use the "debug_active" sysctl. If
Linus Torvalds1da177e2005-04-16 15:20:36 -070088set to 1 the debug feature is running. If "debug_active" is set to 0 the
89debug feature is turned off.
Nicolas Kaiser2254f5a2006-12-04 15:40:23 +010090The second trigger which stops the debug feature is a kernel oops.
Linus Torvalds1da177e2005-04-16 15:20:36 -070091That prevents the debug feature from overwriting debug information that
92happened before the oops. After an oops you can reactivate the debug feature
93by piping 1 to /proc/sys/s390dbf/debug_active. Nevertheless, its not
Nicolas Kaiser2254f5a2006-12-04 15:40:23 +010094suggested to use an oopsed kernel in a production environment.
Linus Torvalds1da177e2005-04-16 15:20:36 -070095If you want to disallow the deactivation of the debug feature, you can use
96the "debug_stoppable" sysctl. If you set "debug_stoppable" to 0 the debug
97feature cannot be stopped. If the debug feature is already stopped, it
98will stay deactivated.
99
100Kernel Interfaces:
101------------------
102
103----------------------------------------------------------------------------
Michael Holzheu66a464d2005-06-25 14:55:33 -0700104debug_info_t *debug_register(char *name, int pages, int nr_areas,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 int buf_size);
106
Michael Holzheu66a464d2005-06-25 14:55:33 -0700107Parameter: name: Name of debug log (e.g. used for debugfs entry)
108 pages: number of pages, which will be allocated per area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 nr_areas: number of debug areas
110 buf_size: size of data area in each debug entry
111
112Return Value: Handle for generated debug area
113 NULL if register failed
114
115Description: Allocates memory for a debug log
116 Must not be called within an interrupt handler
117
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200118----------------------------------------------------------------------------
119debug_info_t *debug_register_mode(char *name, int pages, int nr_areas,
120 int buf_size, mode_t mode, uid_t uid,
121 gid_t gid);
122
123Parameter: name: Name of debug log (e.g. used for debugfs entry)
124 pages: Number of pages, which will be allocated per area
125 nr_areas: Number of debug areas
126 buf_size: Size of data area in each debug entry
127 mode: File mode for debugfs files. E.g. S_IRWXUGO
128 uid: User ID for debugfs files. Currently only 0 is
129 supported.
130 gid: Group ID for debugfs files. Currently only 0 is
131 supported.
132
133Return Value: Handle for generated debug area
134 NULL if register failed
135
136Description: Allocates memory for a debug log
137 Must not be called within an interrupt handler
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139---------------------------------------------------------------------------
140void debug_unregister (debug_info_t * id);
141
142Parameter: id: handle for debug log
143
144Return Value: none
145
Michael Holzheu98ae9b02013-03-06 11:06:57 +0100146Description: frees memory for a debug log and removes all registered debug
147 views.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 Must not be called within an interrupt handler
149
150---------------------------------------------------------------------------
151void debug_set_level (debug_info_t * id, int new_level);
152
153Parameter: id: handle for debug log
154 new_level: new debug level
155
156Return Value: none
157
158Description: Sets new actual debug level if new_level is valid.
159
160---------------------------------------------------------------------------
Michael Holzheu66a464d2005-06-25 14:55:33 -0700161void debug_stop_all(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163Parameter: none
164
165Return Value: none
166
167Description: stops the debug feature if stopping is allowed. Currently
168 used in case of a kernel oops.
169
170---------------------------------------------------------------------------
171debug_entry_t* debug_event (debug_info_t* id, int level, void* data,
172 int length);
173
174Parameter: id: handle for debug log
175 level: debug level
176 data: pointer to data for debug entry
177 length: length of data in bytes
178
179Return Value: Address of written debug entry
180
181Description: writes debug entry to active debug area (if level <= actual
182 debug level)
183
184---------------------------------------------------------------------------
185debug_entry_t* debug_int_event (debug_info_t * id, int level,
186 unsigned int data);
187debug_entry_t* debug_long_event(debug_info_t * id, int level,
188 unsigned long data);
189
190Parameter: id: handle for debug log
191 level: debug level
192 data: integer value for debug entry
193
194Return Value: Address of written debug entry
195
196Description: writes debug entry to active debug area (if level <= actual
197 debug level)
198
199---------------------------------------------------------------------------
200debug_entry_t* debug_text_event (debug_info_t * id, int level,
201 const char* data);
202
203Parameter: id: handle for debug log
204 level: debug level
205 data: string for debug entry
206
207Return Value: Address of written debug entry
208
209Description: writes debug entry in ascii format to active debug area
210 (if level <= actual debug level)
211
212---------------------------------------------------------------------------
213debug_entry_t* debug_sprintf_event (debug_info_t * id, int level,
214 char* string,...);
215
216Parameter: id: handle for debug log
217 level: debug level
218 string: format string for debug entry
219 ...: varargs used as in sprintf()
220
221Return Value: Address of written debug entry
222
223Description: writes debug entry with format string and varargs (longs) to
224 active debug area (if level $<=$ actual debug level).
225 floats and long long datatypes cannot be used as varargs.
226
227---------------------------------------------------------------------------
228
229debug_entry_t* debug_exception (debug_info_t* id, int level, void* data,
230 int length);
231
232Parameter: id: handle for debug log
233 level: debug level
234 data: pointer to data for debug entry
235 length: length of data in bytes
236
237Return Value: Address of written debug entry
238
239Description: writes debug entry to active debug area (if level <= actual
240 debug level) and switches to next debug area
241
242---------------------------------------------------------------------------
243debug_entry_t* debug_int_exception (debug_info_t * id, int level,
244 unsigned int data);
245debug_entry_t* debug_long_exception(debug_info_t * id, int level,
246 unsigned long data);
247
248Parameter: id: handle for debug log
249 level: debug level
250 data: integer value for debug entry
251
252Return Value: Address of written debug entry
253
254Description: writes debug entry to active debug area (if level <= actual
255 debug level) and switches to next debug area
256
257---------------------------------------------------------------------------
258debug_entry_t* debug_text_exception (debug_info_t * id, int level,
259 const char* data);
260
261Parameter: id: handle for debug log
262 level: debug level
263 data: string for debug entry
264
265Return Value: Address of written debug entry
266
267Description: writes debug entry in ascii format to active debug area
268 (if level <= actual debug level) and switches to next debug
269 area
270
271---------------------------------------------------------------------------
272debug_entry_t* debug_sprintf_exception (debug_info_t * id, int level,
273 char* string,...);
274
275Parameter: id: handle for debug log
276 level: debug level
277 string: format string for debug entry
278 ...: varargs used as in sprintf()
279
280Return Value: Address of written debug entry
281
282Description: writes debug entry with format string and varargs (longs) to
283 active debug area (if level $<=$ actual debug level) and
284 switches to next debug area.
285 floats and long long datatypes cannot be used as varargs.
286
287---------------------------------------------------------------------------
288
289int debug_register_view (debug_info_t * id, struct debug_view *view);
290
291Parameter: id: handle for debug log
292 view: pointer to debug view struct
293
294Return Value: 0 : ok
295 < 0: Error
296
Michael Holzheu66a464d2005-06-25 14:55:33 -0700297Description: registers new debug view and creates debugfs dir entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
299---------------------------------------------------------------------------
300int debug_unregister_view (debug_info_t * id, struct debug_view *view);
301
302Parameter: id: handle for debug log
303 view: pointer to debug view struct
304
305Return Value: 0 : ok
306 < 0: Error
307
Michael Holzheu66a464d2005-06-25 14:55:33 -0700308Description: unregisters debug view and removes debugfs dir entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310
311
312Predefined views:
313-----------------
314
315extern struct debug_view debug_hex_ascii_view;
316extern struct debug_view debug_raw_view;
317extern struct debug_view debug_sprintf_view;
318
319Examples
320--------
321
322/*
323 * hex_ascii- + raw-view Example
324 */
325
326#include <linux/init.h>
327#include <asm/debug.h>
328
329static debug_info_t* debug_info;
330
331static int init(void)
332{
333 /* register 4 debug areas with one page each and 4 byte data field */
334
Michael Holzheu66a464d2005-06-25 14:55:33 -0700335 debug_info = debug_register ("test", 1, 4, 4 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 debug_register_view(debug_info,&debug_hex_ascii_view);
337 debug_register_view(debug_info,&debug_raw_view);
338
339 debug_text_event(debug_info, 4 , "one ");
340 debug_int_exception(debug_info, 4, 4711);
341 debug_event(debug_info, 3, &debug_info, 4);
342
343 return 0;
344}
345
346static void cleanup(void)
347{
348 debug_unregister (debug_info);
349}
350
351module_init(init);
352module_exit(cleanup);
353
354---------------------------------------------------------------------------
355
356/*
357 * sprintf-view Example
358 */
359
360#include <linux/init.h>
361#include <asm/debug.h>
362
363static debug_info_t* debug_info;
364
365static int init(void)
366{
367 /* register 4 debug areas with one page each and data field for */
368 /* format string pointer + 2 varargs (= 3 * sizeof(long)) */
369
Michael Holzheu66a464d2005-06-25 14:55:33 -0700370 debug_info = debug_register ("test", 1, 4, sizeof(long) * 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 debug_register_view(debug_info,&debug_sprintf_view);
372
373 debug_sprintf_event(debug_info, 2 , "first event in %s:%i\n",__FILE__,__LINE__);
374 debug_sprintf_exception(debug_info, 1, "pointer to debug info: %p\n",&debug_info);
375
376 return 0;
377}
378
379static void cleanup(void)
380{
381 debug_unregister (debug_info);
382}
383
384module_init(init);
385module_exit(cleanup);
386
387
388
Michael Holzheu66a464d2005-06-25 14:55:33 -0700389Debugfs Interface
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390----------------
391Views to the debug logs can be investigated through reading the corresponding
Michael Holzheu66a464d2005-06-25 14:55:33 -0700392debugfs-files:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394Example:
395
Michael Holzheu66a464d2005-06-25 14:55:33 -0700396> ls /sys/kernel/debug/s390dbf/dasd
397flush hex_ascii level pages raw
398> cat /sys/kernel/debug/s390dbf/dasd/hex_ascii | sort +1
Linus Torvalds1da177e2005-04-16 15:20:36 -070039900 00974733272:680099 2 - 02 0006ad7e 07 ea 4a 90 | ....
40000 00974733272:682210 2 - 02 0006ade6 46 52 45 45 | FREE
40100 00974733272:682213 2 - 02 0006adf6 07 ea 4a 90 | ....
40200 00974733272:682281 1 * 02 0006ab08 41 4c 4c 43 | EXCP
40301 00974733272:682284 2 - 02 0006ab16 45 43 4b 44 | ECKD
40401 00974733272:682287 2 - 02 0006ab28 00 00 00 04 | ....
40501 00974733272:682289 2 - 02 0006ab3e 00 00 00 20 | ...
40601 00974733272:682297 2 - 02 0006ad7e 07 ea 4a 90 | ....
40701 00974733272:684384 2 - 00 0006ade6 46 52 45 45 | FREE
40801 00974733272:684388 2 - 00 0006adf6 07 ea 4a 90 | ....
409
410See section about predefined views for explanation of the above output!
411
412Changing the debug level
413------------------------
414
415Example:
416
417
Michael Holzheu66a464d2005-06-25 14:55:33 -0700418> cat /sys/kernel/debug/s390dbf/dasd/level
Linus Torvalds1da177e2005-04-16 15:20:36 -07004193
Michael Holzheu66a464d2005-06-25 14:55:33 -0700420> echo "5" > /sys/kernel/debug/s390dbf/dasd/level
421> cat /sys/kernel/debug/s390dbf/dasd/level
Linus Torvalds1da177e2005-04-16 15:20:36 -07004225
423
424Flushing debug areas
425--------------------
426Debug areas can be flushed with piping the number of the desired
Michael Holzheu66a464d2005-06-25 14:55:33 -0700427area (0...n) to the debugfs file "flush". When using "-" all debug areas
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428are flushed.
429
430Examples:
431
4321. Flush debug area 0:
Michael Holzheu66a464d2005-06-25 14:55:33 -0700433> echo "0" > /sys/kernel/debug/s390dbf/dasd/flush
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
4352. Flush all debug areas:
Michael Holzheu66a464d2005-06-25 14:55:33 -0700436> echo "-" > /sys/kernel/debug/s390dbf/dasd/flush
437
438Changing the size of debug areas
439------------------------------------
440It is possible the change the size of debug areas through piping
441the number of pages to the debugfs file "pages". The resize request will
442also flush the debug areas.
443
444Example:
445
446Define 4 pages for the debug areas of debug feature "dasd":
447> echo "4" > /sys/kernel/debug/s390dbf/dasd/pages
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449Stooping the debug feature
450--------------------------
451Example:
452
4531. Check if stopping is allowed
454> cat /proc/sys/s390dbf/debug_stoppable
4552. Stop debug feature
456> echo 0 > /proc/sys/s390dbf/debug_active
457
458lcrash Interface
459----------------
460It is planned that the dump analysis tool lcrash gets an additional command
461's390dbf' to display all the debug logs. With this tool it will be possible
462to investigate the debug logs on a live system and with a memory dump after
463a system crash.
464
465Investigating raw memory
466------------------------
467One last possibility to investigate the debug logs at a live
468system and after a system crash is to look at the raw memory
469under VM or at the Service Element.
470It is possible to find the anker of the debug-logs through
471the 'debug_area_first' symbol in the System map. Then one has
472to follow the correct pointers of the data-structures defined
473in debug.h and find the debug-areas in memory.
474Normally modules which use the debug feature will also have
475a global variable with the pointer to the debug-logs. Following
476this pointer it will also be possible to find the debug logs in
477memory.
478
479For this method it is recommended to use '16 * x + 4' byte (x = 0..n)
480for the length of the data field in debug_register() in
481order to see the debug entries well formatted.
482
483
484Predefined Views
485----------------
486
487There are three predefined views: hex_ascii, raw and sprintf.
488The hex_ascii view shows the data field in hex and ascii representation
489(e.g. '45 43 4b 44 | ECKD').
490The raw view returns a bytestream as the debug areas are stored in memory.
491
492The sprintf view formats the debug entries in the same way as the sprintf
Matt LaPlantefff92892006-10-03 22:47:42 +0200493function would do. The sprintf event/exception functions write to the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494debug entry a pointer to the format string (size = sizeof(long))
495and for each vararg a long value. So e.g. for a debug entry with a format
496string plus two varargs one would need to allocate a (3 * sizeof(long))
497byte data area in the debug_register() function.
498
Michael Holzheuf64d04c2009-09-11 10:28:59 +0200499IMPORTANT: Using "%s" in sprintf event functions is dangerous. You can only
500use "%s" in the sprintf event functions, if the memory for the passed string is
501available as long as the debug feature exists. The reason behind this is that
502due to performance considerations only a pointer to the string is stored in
503the debug feature. If you log a string that is freed afterwards, you will get
504an OOPS when inspecting the debug feature, because then the debug feature will
505access the already freed memory.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
507NOTE: If using the sprintf view do NOT use other event/exception functions
508than the sprintf-event and -exception functions.
509
510The format of the hex_ascii and sprintf view is as follows:
511- Number of area
512- Timestamp (formatted as seconds and microseconds since 00:00:00 Coordinated
513 Universal Time (UTC), January 1, 1970)
514- level of debug entry
515- Exception flag (* = Exception)
516- Cpu-Number of calling task
517- Return Address to caller
518- data field
519
520The format of the raw view is:
521- Header as described in debug.h
522- datafield
523
524A typical line of the hex_ascii view will look like the following (first line
525is only for explanation and will not be displayed when 'cating' the view):
526
527area time level exception cpu caller data (hex + ascii)
528--------------------------------------------------------------------------
52900 00964419409:440690 1 - 00 88023fe
530
531
532Defining views
533--------------
534
535Views are specified with the 'debug_view' structure. There are defined
Michael Holzheu66a464d2005-06-25 14:55:33 -0700536callback functions which are used for reading and writing the debugfs files:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537
538struct debug_view {
539 char name[DEBUG_MAX_PROCF_LEN];
540 debug_prolog_proc_t* prolog_proc;
541 debug_header_proc_t* header_proc;
542 debug_format_proc_t* format_proc;
543 debug_input_proc_t* input_proc;
544 void* private_data;
545};
546
547where
548
549typedef int (debug_header_proc_t) (debug_info_t* id,
550 struct debug_view* view,
551 int area,
552 debug_entry_t* entry,
553 char* out_buf);
554
555typedef int (debug_format_proc_t) (debug_info_t* id,
556 struct debug_view* view, char* out_buf,
557 const char* in_buf);
558typedef int (debug_prolog_proc_t) (debug_info_t* id,
559 struct debug_view* view,
560 char* out_buf);
561typedef int (debug_input_proc_t) (debug_info_t* id,
562 struct debug_view* view,
563 struct file* file, const char* user_buf,
564 size_t in_buf_size, loff_t* offset);
565
566
567The "private_data" member can be used as pointer to view specific data.
568It is not used by the debug feature itself.
569
Michael Holzheu66a464d2005-06-25 14:55:33 -0700570The output when reading a debugfs file is structured like this:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571
572"prolog_proc output"
573
574"header_proc output 1" "format_proc output 1"
575"header_proc output 2" "format_proc output 2"
576"header_proc output 3" "format_proc output 3"
577...
578
Michael Holzheu66a464d2005-06-25 14:55:33 -0700579When a view is read from the debugfs, the Debug Feature calls the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580'prolog_proc' once for writing the prolog.
581Then 'header_proc' and 'format_proc' are called for each
582existing debug entry.
583
584The input_proc can be used to implement functionality when it is written to
Michael Holzheu66a464d2005-06-25 14:55:33 -0700585the view (e.g. like with 'echo "0" > /sys/kernel/debug/s390dbf/dasd/level).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
587For header_proc there can be used the default function
Paolo Ornati670e9f32006-10-03 22:57:56 +0200588debug_dflt_header_fn() which is defined in debug.h.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589and which produces the same header output as the predefined views.
590E.g:
59100 00964419409:440761 2 - 00 88023ec
592
593In order to see how to use the callback functions check the implementation
594of the default views!
595
596Example
597
598#include <asm/debug.h>
599
600#define UNKNOWNSTR "data: %08x"
601
602const char* messages[] =
603{"This error...........\n",
604 "That error...........\n",
605 "Problem..............\n",
606 "Something went wrong.\n",
607 "Everything ok........\n",
608 NULL
609};
610
611static int debug_test_format_fn(
612 debug_info_t * id, struct debug_view *view,
613 char *out_buf, const char *in_buf
614)
615{
616 int i, rc = 0;
617
618 if(id->buf_size >= 4) {
619 int msg_nr = *((int*)in_buf);
620 if(msg_nr < sizeof(messages)/sizeof(char*) - 1)
621 rc += sprintf(out_buf, "%s", messages[msg_nr]);
622 else
623 rc += sprintf(out_buf, UNKNOWNSTR, msg_nr);
624 }
625 out:
626 return rc;
627}
628
629struct debug_view debug_test_view = {
630 "myview", /* name of view */
631 NULL, /* no prolog */
632 &debug_dflt_header_fn, /* default header for each entry */
633 &debug_test_format_fn, /* our own format function */
634 NULL, /* no input function */
635 NULL /* no private data */
636};
637
638=====
639test:
640=====
641debug_info_t *debug_info;
642...
643debug_info = debug_register ("test", 0, 4, 4 ));
644debug_register_view(debug_info, &debug_test_view);
645for(i = 0; i < 10; i ++) debug_int_event(debug_info, 1, i);
646
Michael Holzheu66a464d2005-06-25 14:55:33 -0700647> cat /sys/kernel/debug/s390dbf/test/myview
Linus Torvalds1da177e2005-04-16 15:20:36 -070064800 00964419734:611402 1 - 00 88042ca This error...........
64900 00964419734:611405 1 - 00 88042ca That error...........
65000 00964419734:611408 1 - 00 88042ca Problem..............
65100 00964419734:611411 1 - 00 88042ca Something went wrong.
65200 00964419734:611414 1 - 00 88042ca Everything ok........
65300 00964419734:611417 1 - 00 88042ca data: 00000005
65400 00964419734:611419 1 - 00 88042ca data: 00000006
65500 00964419734:611422 1 - 00 88042ca data: 00000007
65600 00964419734:611425 1 - 00 88042ca data: 00000008
65700 00964419734:611428 1 - 00 88042ca data: 00000009