blob: 98192261491de90d5951dc95530ba0a666bc02fe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/s390/kernel/debug.c
3 * S/390 debug facility
4 *
5 * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
7 * Author(s): Michael Holzheu (holzheu@de.ibm.com),
8 * Holger Smolinski (Holger.Smolinski@de.ibm.com)
9 *
10 * Bugreports to: <Linux390@de.ibm.com>
11 */
12
Michael Holzheuc5612c12008-12-25 13:39:43 +010013#define KMSG_COMPONENT "s390dbf"
14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/stddef.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/slab.h>
20#include <linux/ctype.h>
André Goddard Rosae7d28602009-12-14 18:01:06 -080021#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/sysctl.h>
23#include <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/module.h>
25#include <linux/init.h>
Michael Holzheu66a464d2005-06-25 14:55:33 -070026#include <linux/fs.h>
27#include <linux/debugfs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <asm/debug.h>
30
31#define DEBUG_PROLOG_ENTRY -1
32
Michael Holzheu66a464d2005-06-25 14:55:33 -070033#define ALL_AREAS 0 /* copy all debug areas */
34#define NO_AREAS 1 /* copy no debug areas */
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* typedefs */
37
38typedef struct file_private_info {
39 loff_t offset; /* offset of last read in file */
40 int act_area; /* number of last formated area */
Michael Holzheu66a464d2005-06-25 14:55:33 -070041 int act_page; /* act page in given area */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 int act_entry; /* last formated entry (offset */
43 /* relative to beginning of last */
Michael Holzheu66a464d2005-06-25 14:55:33 -070044 /* formated page) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 size_t act_entry_offset; /* up to this offset we copied */
46 /* in last read the last formated */
47 /* entry to userland */
48 char temp_buf[2048]; /* buffer for output */
49 debug_info_t *debug_info_org; /* original debug information */
50 debug_info_t *debug_info_snap; /* snapshot of debug information */
51 struct debug_view *view; /* used view of debug info */
52} file_private_info_t;
53
54typedef struct
55{
56 char *string;
57 /*
58 * This assumes that all args are converted into longs
59 * on L/390 this is the case for all types of parameter
60 * except of floats, and long long (32 bit)
Michael Holzheu66a464d2005-06-25 14:55:33 -070061 *
62 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 long args[0];
64} debug_sprintf_entry_t;
65
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* internal function prototyes */
68
69static int debug_init(void);
70static ssize_t debug_output(struct file *file, char __user *user_buf,
Michael Holzheu66a464d2005-06-25 14:55:33 -070071 size_t user_len, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072static ssize_t debug_input(struct file *file, const char __user *user_buf,
Michael Holzheu66a464d2005-06-25 14:55:33 -070073 size_t user_len, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static int debug_open(struct inode *inode, struct file *file);
75static int debug_close(struct inode *inode, struct file *file);
Cornelia Huck5cbbf162008-05-15 16:52:35 +020076static debug_info_t *debug_info_create(const char *name, int pages_per_area,
Michael Holzheu9637c3f2008-04-17 07:46:18 +020077 int nr_areas, int buf_size, mode_t mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078static void debug_info_get(debug_info_t *);
79static void debug_info_put(debug_info_t *);
80static int debug_prolog_level_fn(debug_info_t * id,
Michael Holzheu66a464d2005-06-25 14:55:33 -070081 struct debug_view *view, char *out_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082static int debug_input_level_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070083 struct file *file, const char __user *user_buf,
84 size_t user_buf_size, loff_t * offset);
85static int debug_prolog_pages_fn(debug_info_t * id,
86 struct debug_view *view, char *out_buf);
87static int debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
88 struct file *file, const char __user *user_buf,
89 size_t user_buf_size, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090static int debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070091 struct file *file, const char __user *user_buf,
92 size_t user_buf_size, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093static int debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070094 char *out_buf, const char *in_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095static int debug_raw_format_fn(debug_info_t * id,
Michael Holzheu66a464d2005-06-25 14:55:33 -070096 struct debug_view *view, char *out_buf,
97 const char *in_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098static int debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070099 int area, debug_entry_t * entry, char *out_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101static int debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -0700102 char *out_buf, debug_sprintf_entry_t *curr_event);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104/* globals */
105
106struct debug_view debug_raw_view = {
107 "raw",
108 NULL,
109 &debug_raw_header_fn,
110 &debug_raw_format_fn,
111 NULL,
112 NULL
113};
114
115struct debug_view debug_hex_ascii_view = {
116 "hex_ascii",
117 NULL,
118 &debug_dflt_header_fn,
119 &debug_hex_ascii_format_fn,
120 NULL,
121 NULL
122};
123
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100124static struct debug_view debug_level_view = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 "level",
126 &debug_prolog_level_fn,
127 NULL,
128 NULL,
129 &debug_input_level_fn,
130 NULL
131};
132
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100133static struct debug_view debug_pages_view = {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700134 "pages",
135 &debug_prolog_pages_fn,
136 NULL,
137 NULL,
138 &debug_input_pages_fn,
139 NULL
140};
141
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100142static struct debug_view debug_flush_view = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 "flush",
144 NULL,
145 NULL,
146 NULL,
147 &debug_input_flush_fn,
148 NULL
149};
150
151struct debug_view debug_sprintf_view = {
152 "sprintf",
153 NULL,
154 &debug_dflt_header_fn,
155 (debug_format_proc_t*)&debug_sprintf_format_fn,
156 NULL,
157 NULL
158};
159
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100160/* used by dump analysis tools to determine version of debug feature */
Heiko Carstensa8061702008-04-17 07:46:26 +0200161static unsigned int __used debug_feature_version = __DEBUG_FEATURE_VERSION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163/* static globals */
164
165static debug_info_t *debug_area_first = NULL;
166static debug_info_t *debug_area_last = NULL;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200167static DEFINE_MUTEX(debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169static int initialized;
170
Arjan van de Ven5dfe4c92007-02-12 00:55:31 -0800171static const struct file_operations debug_file_ops = {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700172 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 .read = debug_output,
Michael Holzheu66a464d2005-06-25 14:55:33 -0700174 .write = debug_input,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 .open = debug_open,
176 .release = debug_close,
177};
178
Michael Holzheu66a464d2005-06-25 14:55:33 -0700179static struct dentry *debug_debugfs_root_entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181/* functions */
182
183/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700184 * debug_areas_alloc
185 * - Debug areas are implemented as a threedimensonal array:
186 * areas[areanumber][pagenumber][pageoffset]
187 */
188
189static debug_entry_t***
190debug_areas_alloc(int pages_per_area, int nr_areas)
191{
192 debug_entry_t*** areas;
193 int i,j;
194
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800195 areas = kmalloc(nr_areas *
Michael Holzheu66a464d2005-06-25 14:55:33 -0700196 sizeof(debug_entry_t**),
197 GFP_KERNEL);
198 if (!areas)
199 goto fail_malloc_areas;
200 for (i = 0; i < nr_areas; i++) {
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800201 areas[i] = kmalloc(pages_per_area *
Michael Holzheu66a464d2005-06-25 14:55:33 -0700202 sizeof(debug_entry_t*),GFP_KERNEL);
203 if (!areas[i]) {
204 goto fail_malloc_areas2;
205 }
206 for(j = 0; j < pages_per_area; j++) {
Eric Sesterhennfb630512006-03-24 03:15:31 -0800207 areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700208 if(!areas[i][j]) {
209 for(j--; j >=0 ; j--) {
210 kfree(areas[i][j]);
211 }
212 kfree(areas[i]);
213 goto fail_malloc_areas2;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700214 }
215 }
216 }
217 return areas;
218
219fail_malloc_areas2:
220 for(i--; i >= 0; i--){
221 for(j=0; j < pages_per_area;j++){
222 kfree(areas[i][j]);
223 }
224 kfree(areas[i]);
225 }
226 kfree(areas);
227fail_malloc_areas:
228 return NULL;
229
230}
231
232
233/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 * debug_info_alloc
235 * - alloc new debug-info
236 */
237
Michael Holzheu66a464d2005-06-25 14:55:33 -0700238static debug_info_t*
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200239debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
240 int buf_size, int level, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241{
242 debug_info_t* rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 /* alloc everything */
245
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800246 rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 if(!rc)
248 goto fail_malloc_rc;
Eric Sesterhennfb630512006-03-24 03:15:31 -0800249 rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700250 if(!rc->active_entries)
251 goto fail_malloc_active_entries;
Eric Sesterhennfb630512006-03-24 03:15:31 -0800252 rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700253 if(!rc->active_pages)
254 goto fail_malloc_active_pages;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700255 if((mode == ALL_AREAS) && (pages_per_area != 0)){
256 rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
257 if(!rc->areas)
258 goto fail_malloc_areas;
259 } else {
260 rc->areas = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 }
262
263 /* initialize members */
264
265 spin_lock_init(&rc->lock);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700266 rc->pages_per_area = pages_per_area;
267 rc->nr_areas = nr_areas;
268 rc->active_area = 0;
269 rc->level = level;
270 rc->buf_size = buf_size;
271 rc->entry_size = sizeof(debug_entry_t) + buf_size;
Jean Delvare20cb9e72007-03-19 13:18:53 +0100272 strlcpy(rc->name, name, sizeof(rc->name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
Michael Holzheu66a464d2005-06-25 14:55:33 -0700274 memset(rc->debugfs_entries, 0 ,DEBUG_MAX_VIEWS *
275 sizeof(struct dentry*));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 atomic_set(&(rc->ref_count), 0);
277
278 return rc;
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280fail_malloc_areas:
Michael Holzheu66a464d2005-06-25 14:55:33 -0700281 kfree(rc->active_pages);
282fail_malloc_active_pages:
283 kfree(rc->active_entries);
284fail_malloc_active_entries:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 kfree(rc);
286fail_malloc_rc:
287 return NULL;
288}
289
290/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700291 * debug_areas_free
292 * - free all debug areas
293 */
294
295static void
296debug_areas_free(debug_info_t* db_info)
297{
298 int i,j;
299
300 if(!db_info->areas)
301 return;
302 for (i = 0; i < db_info->nr_areas; i++) {
303 for(j = 0; j < db_info->pages_per_area; j++) {
304 kfree(db_info->areas[i][j]);
305 }
306 kfree(db_info->areas[i]);
307 }
308 kfree(db_info->areas);
309 db_info->areas = NULL;
310}
311
312/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 * debug_info_free
314 * - free memory debug-info
315 */
316
Michael Holzheu66a464d2005-06-25 14:55:33 -0700317static void
318debug_info_free(debug_info_t* db_info){
319 debug_areas_free(db_info);
320 kfree(db_info->active_entries);
321 kfree(db_info->active_pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 kfree(db_info);
323}
324
325/*
326 * debug_info_create
327 * - create new debug-info
328 */
329
Michael Holzheu66a464d2005-06-25 14:55:33 -0700330static debug_info_t*
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200331debug_info_create(const char *name, int pages_per_area, int nr_areas,
332 int buf_size, mode_t mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 debug_info_t* rc;
335
Michael Holzheu66a464d2005-06-25 14:55:33 -0700336 rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size,
337 DEBUG_DEFAULT_LEVEL, ALL_AREAS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 if(!rc)
339 goto out;
340
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200341 rc->mode = mode & ~S_IFMT;
342
Michael Holzheu66a464d2005-06-25 14:55:33 -0700343 /* create root directory */
344 rc->debugfs_root_entry = debugfs_create_dir(rc->name,
345 debug_debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 /* append new element to linked list */
Michael Holzheu66a464d2005-06-25 14:55:33 -0700348 if (!debug_area_first) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 /* first element in list */
350 debug_area_first = rc;
351 rc->prev = NULL;
352 } else {
353 /* append element to end of list */
354 debug_area_last->next = rc;
355 rc->prev = debug_area_last;
356 }
357 debug_area_last = rc;
358 rc->next = NULL;
359
360 debug_info_get(rc);
361out:
362 return rc;
363}
364
365/*
366 * debug_info_copy
367 * - copy debug-info
368 */
369
Michael Holzheu66a464d2005-06-25 14:55:33 -0700370static debug_info_t*
371debug_info_copy(debug_info_t* in, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700373 int i,j;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 debug_info_t* rc;
Michael Holzheu942eaab2005-09-03 15:57:58 -0700375 unsigned long flags;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700376
Michael Holzheu942eaab2005-09-03 15:57:58 -0700377 /* get a consistent copy of the debug areas */
378 do {
379 rc = debug_info_alloc(in->name, in->pages_per_area,
380 in->nr_areas, in->buf_size, in->level, mode);
381 spin_lock_irqsave(&in->lock, flags);
382 if(!rc)
383 goto out;
384 /* has something changed in the meantime ? */
385 if((rc->pages_per_area == in->pages_per_area) &&
386 (rc->nr_areas == in->nr_areas)) {
387 break;
388 }
389 spin_unlock_irqrestore(&in->lock, flags);
390 debug_info_free(rc);
391 } while (1);
392
Julia Lawallacfa9222008-12-25 13:39:30 +0100393 if (mode == NO_AREAS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 goto out;
395
396 for(i = 0; i < in->nr_areas; i++){
Michael Holzheu66a464d2005-06-25 14:55:33 -0700397 for(j = 0; j < in->pages_per_area; j++) {
398 memcpy(rc->areas[i][j], in->areas[i][j],PAGE_SIZE);
399 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 }
401out:
Michael Holzheu942eaab2005-09-03 15:57:58 -0700402 spin_unlock_irqrestore(&in->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 return rc;
404}
405
406/*
407 * debug_info_get
408 * - increments reference count for debug-info
409 */
410
Michael Holzheu66a464d2005-06-25 14:55:33 -0700411static void
412debug_info_get(debug_info_t * db_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413{
414 if (db_info)
415 atomic_inc(&db_info->ref_count);
416}
417
418/*
419 * debug_info_put:
420 * - decreases reference count for debug-info and frees it if necessary
421 */
422
Michael Holzheu66a464d2005-06-25 14:55:33 -0700423static void
424debug_info_put(debug_info_t *db_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425{
426 int i;
427
428 if (!db_info)
429 return;
430 if (atomic_dec_and_test(&db_info->ref_count)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700432 if (!db_info->views[i])
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 continue;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700434 debugfs_remove(db_info->debugfs_entries[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700436 debugfs_remove(db_info->debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 if(db_info == debug_area_first)
438 debug_area_first = db_info->next;
439 if(db_info == debug_area_last)
440 debug_area_last = db_info->prev;
441 if(db_info->prev) db_info->prev->next = db_info->next;
442 if(db_info->next) db_info->next->prev = db_info->prev;
443 debug_info_free(db_info);
444 }
445}
446
447/*
448 * debug_format_entry:
449 * - format one debug entry and return size of formated data
450 */
451
Michael Holzheu66a464d2005-06-25 14:55:33 -0700452static int
453debug_format_entry(file_private_info_t *p_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 debug_info_t *id_snap = p_info->debug_info_snap;
456 struct debug_view *view = p_info->view;
457 debug_entry_t *act_entry;
458 size_t len = 0;
459 if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
460 /* print prolog */
461 if (view->prolog_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700462 len += view->prolog_proc(id_snap,view,p_info->temp_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 goto out;
464 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700465 if (!id_snap->areas) /* this is true, if we have a prolog only view */
466 goto out; /* or if 'pages_per_area' is 0 */
467 act_entry = (debug_entry_t *) ((char*)id_snap->areas[p_info->act_area]
468 [p_info->act_page] + p_info->act_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 if (act_entry->id.stck == 0LL)
471 goto out; /* empty entry */
472 if (view->header_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700473 len += view->header_proc(id_snap, view, p_info->act_area,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 act_entry, p_info->temp_buf + len);
475 if (view->format_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700476 len += view->format_proc(id_snap, view, p_info->temp_buf + len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 DEBUG_DATA(act_entry));
Michael Holzheu66a464d2005-06-25 14:55:33 -0700478out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 return len;
480}
481
482/*
483 * debug_next_entry:
484 * - goto next entry in p_info
485 */
486
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800487static inline int
Michael Holzheu66a464d2005-06-25 14:55:33 -0700488debug_next_entry(file_private_info_t *p_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700490 debug_info_t *id;
491
492 id = p_info->debug_info_snap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
494 p_info->act_entry = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700495 p_info->act_page = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 goto out;
497 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700498 if(!id->areas)
499 return 1;
500 p_info->act_entry += id->entry_size;
501 /* switch to next page, if we reached the end of the page */
502 if (p_info->act_entry > (PAGE_SIZE - id->entry_size)){
503 /* next page */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 p_info->act_entry = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700505 p_info->act_page += 1;
506 if((p_info->act_page % id->pages_per_area) == 0) {
507 /* next area */
508 p_info->act_area++;
509 p_info->act_page=0;
510 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 if(p_info->act_area >= id->nr_areas)
512 return 1;
513 }
514out:
515 return 0;
516}
517
518/*
519 * debug_output:
520 * - called for user read()
521 * - copies formated debug entries to the user buffer
522 */
523
Michael Holzheu66a464d2005-06-25 14:55:33 -0700524static ssize_t
525debug_output(struct file *file, /* file descriptor */
526 char __user *user_buf, /* user buffer */
527 size_t len, /* length of buffer */
528 loff_t *offset) /* offset in the file */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529{
530 size_t count = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700531 size_t entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 file_private_info_t *p_info;
533
534 p_info = ((file_private_info_t *) file->private_data);
535 if (*offset != p_info->offset)
536 return -EPIPE;
537 if(p_info->act_area >= p_info->debug_info_snap->nr_areas)
538 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 entry_offset = p_info->act_entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 while(count < len){
Michael Holzheu66a464d2005-06-25 14:55:33 -0700541 int formatted_line_size;
542 int formatted_line_residue;
543 int user_buf_residue;
544 size_t copy_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
Michael Holzheu66a464d2005-06-25 14:55:33 -0700546 formatted_line_size = debug_format_entry(p_info);
547 formatted_line_residue = formatted_line_size - entry_offset;
548 user_buf_residue = len-count;
549 copy_size = min(user_buf_residue, formatted_line_residue);
550 if(copy_size){
551 if (copy_to_user(user_buf + count, p_info->temp_buf
552 + entry_offset, copy_size))
553 return -EFAULT;
554 count += copy_size;
555 entry_offset += copy_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700557 if(copy_size == formatted_line_residue){
558 entry_offset = 0;
559 if(debug_next_entry(p_info))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 goto out;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700561 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 }
563out:
564 p_info->offset = *offset + count;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700565 p_info->act_entry_offset = entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 *offset = p_info->offset;
567 return count;
568}
569
570/*
571 * debug_input:
572 * - called for user write()
573 * - calls input function of view
574 */
575
Michael Holzheu66a464d2005-06-25 14:55:33 -0700576static ssize_t
577debug_input(struct file *file, const char __user *user_buf, size_t length,
578 loff_t *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579{
580 int rc = 0;
581 file_private_info_t *p_info;
582
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200583 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 p_info = ((file_private_info_t *) file->private_data);
585 if (p_info->view->input_proc)
586 rc = p_info->view->input_proc(p_info->debug_info_org,
587 p_info->view, file, user_buf,
588 length, offset);
589 else
590 rc = -EPERM;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200591 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 return rc; /* number of input characters */
593}
594
595/*
596 * debug_open:
597 * - called for user open()
598 * - copies formated output to private_data area of the file
599 * handle
600 */
601
Michael Holzheu66a464d2005-06-25 14:55:33 -0700602static int
603debug_open(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604{
Michael Holzheua0fa8e32009-03-26 15:24:49 +0100605 int i, rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 file_private_info_t *p_info;
607 debug_info_t *debug_info, *debug_info_snapshot;
608
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200609 mutex_lock(&debug_mutex);
Josef Sipekd20343e2006-12-08 02:37:35 -0800610 debug_info = file->f_path.dentry->d_inode->i_private;
Michael Holzheu942eaab2005-09-03 15:57:58 -0700611 /* find debug view */
612 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
613 if (!debug_info->views[i])
614 continue;
615 else if (debug_info->debugfs_entries[i] ==
Josef Sipekd20343e2006-12-08 02:37:35 -0800616 file->f_path.dentry) {
Michael Holzheu942eaab2005-09-03 15:57:58 -0700617 goto found; /* found view ! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 }
620 /* no entry found */
621 rc = -EINVAL;
622 goto out;
623
Michael Holzheu66a464d2005-06-25 14:55:33 -0700624found:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Michael Holzheu66a464d2005-06-25 14:55:33 -0700626 /* Make snapshot of current debug areas to get it consistent. */
627 /* To copy all the areas is only needed, if we have a view which */
628 /* formats the debug areas. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Michael Holzheu66a464d2005-06-25 14:55:33 -0700630 if(!debug_info->views[i]->format_proc &&
631 !debug_info->views[i]->header_proc){
632 debug_info_snapshot = debug_info_copy(debug_info, NO_AREAS);
633 } else {
634 debug_info_snapshot = debug_info_copy(debug_info, ALL_AREAS);
635 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
637 if(!debug_info_snapshot){
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 rc = -ENOMEM;
639 goto out;
640 }
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800641 p_info = kmalloc(sizeof(file_private_info_t),
Michael Holzheu66a464d2005-06-25 14:55:33 -0700642 GFP_KERNEL);
643 if(!p_info){
Michael Holzheu58ace9f2009-03-26 15:24:50 +0100644 debug_info_free(debug_info_snapshot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 rc = -ENOMEM;
646 goto out;
647 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 p_info->offset = 0;
649 p_info->debug_info_snap = debug_info_snapshot;
650 p_info->debug_info_org = debug_info;
651 p_info->view = debug_info->views[i];
652 p_info->act_area = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700653 p_info->act_page = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 p_info->act_entry = DEBUG_PROLOG_ENTRY;
655 p_info->act_entry_offset = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700656 file->private_data = p_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 debug_info_get(debug_info);
Martin Schwidefsky58ea91c2010-05-17 10:00:07 +0200658 nonseekable_open(inode, file);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700659out:
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200660 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 return rc;
662}
663
664/*
665 * debug_close:
666 * - called for user close()
667 * - deletes private_data area of the file handle
668 */
669
Michael Holzheu66a464d2005-06-25 14:55:33 -0700670static int
671debug_close(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672{
673 file_private_info_t *p_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 p_info = (file_private_info_t *) file->private_data;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700675 if(p_info->debug_info_snap)
676 debug_info_free(p_info->debug_info_snap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 debug_info_put(p_info->debug_info_org);
678 kfree(file->private_data);
679 return 0; /* success */
680}
681
682/*
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200683 * debug_register_mode:
684 * - Creates and initializes debug area for the caller
685 * The mode parameter allows to specify access rights for the s390dbf files
686 * - Returns handle for debug area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 */
688
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200689debug_info_t *debug_register_mode(const char *name, int pages_per_area,
690 int nr_areas, int buf_size, mode_t mode,
691 uid_t uid, gid_t gid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692{
693 debug_info_t *rc = NULL;
694
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200695 /* Since debugfs currently does not support uid/gid other than root, */
696 /* we do not allow gid/uid != 0 until we get support for that. */
697 if ((uid != 0) || (gid != 0))
Michael Holzheuc5612c12008-12-25 13:39:43 +0100698 pr_warning("Root becomes the owner of all s390dbf files "
699 "in sysfs\n");
Stoyan Gaydarov6aa0d3a2009-03-26 15:24:47 +0100700 BUG_ON(!initialized);
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200701 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702
703 /* create new debug_info */
704
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200705 rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 if(!rc)
707 goto out;
708 debug_register_view(rc, &debug_level_view);
709 debug_register_view(rc, &debug_flush_view);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700710 debug_register_view(rc, &debug_pages_view);
711out:
712 if (!rc){
Michael Holzheuc5612c12008-12-25 13:39:43 +0100713 pr_err("Registering debug feature %s failed\n", name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 }
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200715 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 return rc;
717}
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200718EXPORT_SYMBOL(debug_register_mode);
719
720/*
721 * debug_register:
722 * - creates and initializes debug area for the caller
723 * - returns handle for debug area
724 */
725
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200726debug_info_t *debug_register(const char *name, int pages_per_area,
727 int nr_areas, int buf_size)
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200728{
729 return debug_register_mode(name, pages_per_area, nr_areas, buf_size,
730 S_IRUSR | S_IWUSR, 0, 0);
731}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
733/*
734 * debug_unregister:
735 * - give back debug area
736 */
737
Michael Holzheu66a464d2005-06-25 14:55:33 -0700738void
739debug_unregister(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740{
741 if (!id)
742 goto out;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200743 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 debug_info_put(id);
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200745 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
Michael Holzheu66a464d2005-06-25 14:55:33 -0700747out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 return;
749}
750
751/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700752 * debug_set_size:
753 * - set area size (number of pages) and number of areas
754 */
755static int
756debug_set_size(debug_info_t* id, int nr_areas, int pages_per_area)
757{
758 unsigned long flags;
759 debug_entry_t *** new_areas;
760 int rc=0;
761
762 if(!id || (nr_areas <= 0) || (pages_per_area < 0))
763 return -EINVAL;
764 if(pages_per_area > 0){
765 new_areas = debug_areas_alloc(pages_per_area, nr_areas);
766 if(!new_areas) {
Michael Holzheuc5612c12008-12-25 13:39:43 +0100767 pr_info("Allocating memory for %i pages failed\n",
768 pages_per_area);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700769 rc = -ENOMEM;
770 goto out;
771 }
772 } else {
773 new_areas = NULL;
774 }
775 spin_lock_irqsave(&id->lock,flags);
776 debug_areas_free(id);
777 id->areas = new_areas;
778 id->nr_areas = nr_areas;
779 id->pages_per_area = pages_per_area;
780 id->active_area = 0;
781 memset(id->active_entries,0,sizeof(int)*id->nr_areas);
782 memset(id->active_pages, 0, sizeof(int)*id->nr_areas);
783 spin_unlock_irqrestore(&id->lock,flags);
Michael Holzheuc5612c12008-12-25 13:39:43 +0100784 pr_info("%s: set new size (%i pages)\n" ,id->name, pages_per_area);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700785out:
786 return rc;
787}
788
789/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 * debug_set_level:
791 * - set actual debug level
792 */
793
Michael Holzheu66a464d2005-06-25 14:55:33 -0700794void
795debug_set_level(debug_info_t* id, int new_level)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796{
797 unsigned long flags;
798 if(!id)
799 return;
800 spin_lock_irqsave(&id->lock,flags);
801 if(new_level == DEBUG_OFF_LEVEL){
802 id->level = DEBUG_OFF_LEVEL;
Michael Holzheuc5612c12008-12-25 13:39:43 +0100803 pr_info("%s: switched off\n",id->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
Michael Holzheuc5612c12008-12-25 13:39:43 +0100805 pr_info("%s: level %i is out of range (%i - %i)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 id->name, new_level, 0, DEBUG_MAX_LEVEL);
807 } else {
808 id->level = new_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 }
810 spin_unlock_irqrestore(&id->lock,flags);
811}
812
813
814/*
815 * proceed_active_entry:
816 * - set active entry to next in the ring buffer
817 */
818
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800819static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700820proceed_active_entry(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700822 if ((id->active_entries[id->active_area] += id->entry_size)
823 > (PAGE_SIZE - id->entry_size)){
824 id->active_entries[id->active_area] = 0;
825 id->active_pages[id->active_area] =
826 (id->active_pages[id->active_area] + 1) %
827 id->pages_per_area;
828 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829}
830
831/*
832 * proceed_active_area:
833 * - set active area to next in the ring buffer
834 */
835
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800836static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700837proceed_active_area(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838{
839 id->active_area++;
840 id->active_area = id->active_area % id->nr_areas;
841}
842
843/*
844 * get_active_entry:
845 */
846
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800847static inline debug_entry_t*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700848get_active_entry(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700850 return (debug_entry_t *) (((char *) id->areas[id->active_area]
851 [id->active_pages[id->active_area]]) +
852 id->active_entries[id->active_area]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853}
854
855/*
856 * debug_finish_entry:
857 * - set timestamp, caller address, cpu number etc.
858 */
859
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800860static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700861debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
862 int exception)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863{
Michael Holzheu942eaab2005-09-03 15:57:58 -0700864 active->id.stck = get_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 active->id.fields.cpuid = smp_processor_id();
866 active->caller = __builtin_return_address(0);
867 active->id.fields.exception = exception;
868 active->id.fields.level = level;
869 proceed_active_entry(id);
870 if(exception)
871 proceed_active_area(id);
872}
873
874static int debug_stoppable=1;
875static int debug_active=1;
876
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877#define CTL_S390DBF_STOPPABLE 5678
878#define CTL_S390DBF_ACTIVE 5679
879
880/*
881 * proc handler for the running debug_active sysctl
882 * always allow read, allow write only if debug_stoppable is set or
883 * if debug_active is already off
884 */
Michael Holzheu66a464d2005-06-25 14:55:33 -0700885static int
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700886s390dbf_procactive(ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 void __user *buffer, size_t *lenp, loff_t *ppos)
888{
889 if (!write || debug_stoppable || !debug_active)
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700890 return proc_dointvec(table, write, buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 else
892 return 0;
893}
894
895
896static struct ctl_table s390dbf_table[] = {
897 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 .procname = "debug_stoppable",
899 .data = &debug_stoppable,
900 .maxlen = sizeof(int),
901 .mode = S_IRUGO | S_IWUSR,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800902 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 },
904 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 .procname = "debug_active",
906 .data = &debug_active,
907 .maxlen = sizeof(int),
908 .mode = S_IRUGO | S_IWUSR,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800909 .proc_handler = s390dbf_procactive,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 },
Eric W. Biedermanb05fd352009-04-03 04:36:34 -0700911 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912};
913
914static struct ctl_table s390dbf_dir_table[] = {
915 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 .procname = "s390dbf",
917 .maxlen = 0,
918 .mode = S_IRUGO | S_IXUGO,
919 .child = s390dbf_table,
920 },
Eric W. Biedermanb05fd352009-04-03 04:36:34 -0700921 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922};
923
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100924static struct ctl_table_header *s390dbf_sysctl_header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925
Michael Holzheu66a464d2005-06-25 14:55:33 -0700926void
927debug_stop_all(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928{
929 if (debug_stoppable)
930 debug_active = 0;
931}
932
933
934/*
935 * debug_event_common:
936 * - write debug entry with given size
937 */
938
Michael Holzheu66a464d2005-06-25 14:55:33 -0700939debug_entry_t*
940debug_event_common(debug_info_t * id, int level, const void *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941{
942 unsigned long flags;
943 debug_entry_t *active;
944
Michael Holzheu66a464d2005-06-25 14:55:33 -0700945 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 return NULL;
947 spin_lock_irqsave(&id->lock, flags);
948 active = get_active_entry(id);
949 memset(DEBUG_DATA(active), 0, id->buf_size);
950 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
951 debug_finish_entry(id, active, level, 0);
952 spin_unlock_irqrestore(&id->lock, flags);
953
954 return active;
955}
956
957/*
958 * debug_exception_common:
959 * - write debug entry with given size and switch to next debug area
960 */
961
Michael Holzheu66a464d2005-06-25 14:55:33 -0700962debug_entry_t
963*debug_exception_common(debug_info_t * id, int level, const void *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964{
965 unsigned long flags;
966 debug_entry_t *active;
967
Michael Holzheu66a464d2005-06-25 14:55:33 -0700968 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 return NULL;
970 spin_lock_irqsave(&id->lock, flags);
971 active = get_active_entry(id);
972 memset(DEBUG_DATA(active), 0, id->buf_size);
973 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
974 debug_finish_entry(id, active, level, 1);
975 spin_unlock_irqrestore(&id->lock, flags);
976
977 return active;
978}
979
980/*
981 * counts arguments in format string for sprintf view
982 */
983
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800984static inline int
Michael Holzheu66a464d2005-06-25 14:55:33 -0700985debug_count_numargs(char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986{
987 int numargs=0;
988
989 while(*string) {
990 if(*string++=='%')
991 numargs++;
992 }
993 return(numargs);
994}
995
996/*
997 * debug_sprintf_event:
998 */
999
Michael Holzheu66a464d2005-06-25 14:55:33 -07001000debug_entry_t*
1001debug_sprintf_event(debug_info_t* id, int level,char *string,...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002{
1003 va_list ap;
1004 int numargs,idx;
1005 unsigned long flags;
1006 debug_sprintf_entry_t *curr_event;
1007 debug_entry_t *active;
1008
1009 if((!id) || (level > id->level))
1010 return NULL;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001011 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 return NULL;
1013 numargs=debug_count_numargs(string);
1014
1015 spin_lock_irqsave(&id->lock, flags);
1016 active = get_active_entry(id);
1017 curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active);
1018 va_start(ap,string);
1019 curr_event->string=string;
1020 for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
1021 curr_event->args[idx]=va_arg(ap,long);
1022 va_end(ap);
1023 debug_finish_entry(id, active, level, 0);
1024 spin_unlock_irqrestore(&id->lock, flags);
1025
1026 return active;
1027}
1028
1029/*
1030 * debug_sprintf_exception:
1031 */
1032
Michael Holzheu66a464d2005-06-25 14:55:33 -07001033debug_entry_t*
1034debug_sprintf_exception(debug_info_t* id, int level,char *string,...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035{
1036 va_list ap;
1037 int numargs,idx;
1038 unsigned long flags;
1039 debug_sprintf_entry_t *curr_event;
1040 debug_entry_t *active;
1041
1042 if((!id) || (level > id->level))
1043 return NULL;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001044 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 return NULL;
1046
1047 numargs=debug_count_numargs(string);
1048
1049 spin_lock_irqsave(&id->lock, flags);
1050 active = get_active_entry(id);
1051 curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active);
1052 va_start(ap,string);
1053 curr_event->string=string;
1054 for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
1055 curr_event->args[idx]=va_arg(ap,long);
1056 va_end(ap);
1057 debug_finish_entry(id, active, level, 1);
1058 spin_unlock_irqrestore(&id->lock, flags);
1059
1060 return active;
1061}
1062
1063/*
1064 * debug_init:
1065 * - is called exactly once to initialize the debug feature
1066 */
1067
Michael Holzheu66a464d2005-06-25 14:55:33 -07001068static int
1069__init debug_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070{
1071 int rc = 0;
1072
Eric W. Biederman0b4d4142007-02-14 00:34:09 -08001073 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
Christoph Hellwige11f0d02007-05-31 17:38:03 +02001074 mutex_lock(&debug_mutex);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001075 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 initialized = 1;
Christoph Hellwige11f0d02007-05-31 17:38:03 +02001077 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078
1079 return rc;
1080}
1081
1082/*
1083 * debug_register_view:
1084 */
1085
Michael Holzheu66a464d2005-06-25 14:55:33 -07001086int
1087debug_register_view(debug_info_t * id, struct debug_view *view)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088{
1089 int rc = 0;
1090 int i;
1091 unsigned long flags;
Michael Holzheu9637c3f2008-04-17 07:46:18 +02001092 mode_t mode;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001093 struct dentry *pde;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094
1095 if (!id)
1096 goto out;
Michael Holzheu9637c3f2008-04-17 07:46:18 +02001097 mode = (id->mode | S_IFREG) & ~S_IXUGO;
1098 if (!(view->prolog_proc || view->format_proc || view->header_proc))
1099 mode &= ~(S_IRUSR | S_IRGRP | S_IROTH);
1100 if (!view->input_proc)
1101 mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001102 pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry,
Michael Holzheu942eaab2005-09-03 15:57:58 -07001103 id , &debug_file_ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 if (!pde){
Michael Holzheuc5612c12008-12-25 13:39:43 +01001105 pr_err("Registering view %s/%s failed due to out of "
1106 "memory\n", id->name,view->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 rc = -1;
1108 goto out;
1109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 spin_lock_irqsave(&id->lock, flags);
1111 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001112 if (!id->views[i])
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 break;
1114 }
1115 if (i == DEBUG_MAX_VIEWS) {
Michael Holzheuc5612c12008-12-25 13:39:43 +01001116 pr_err("Registering view %s/%s would exceed the maximum "
1117 "number of views %i\n", id->name, view->name, i);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001118 debugfs_remove(pde);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 rc = -1;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001120 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 id->views[i] = view;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001122 id->debugfs_entries[i] = pde;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 }
1124 spin_unlock_irqrestore(&id->lock, flags);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001125out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 return rc;
1127}
1128
1129/*
1130 * debug_unregister_view:
1131 */
1132
Michael Holzheu66a464d2005-06-25 14:55:33 -07001133int
1134debug_unregister_view(debug_info_t * id, struct debug_view *view)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135{
1136 int rc = 0;
1137 int i;
1138 unsigned long flags;
1139
1140 if (!id)
1141 goto out;
1142 spin_lock_irqsave(&id->lock, flags);
1143 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
1144 if (id->views[i] == view)
1145 break;
1146 }
1147 if (i == DEBUG_MAX_VIEWS)
1148 rc = -1;
1149 else {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001150 debugfs_remove(id->debugfs_entries[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 id->views[i] = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 }
1153 spin_unlock_irqrestore(&id->lock, flags);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001154out:
1155 return rc;
1156}
1157
1158static inline char *
1159debug_get_user_string(const char __user *user_buf, size_t user_len)
1160{
1161 char* buffer;
1162
1163 buffer = kmalloc(user_len + 1, GFP_KERNEL);
1164 if (!buffer)
1165 return ERR_PTR(-ENOMEM);
1166 if (copy_from_user(buffer, user_buf, user_len) != 0) {
1167 kfree(buffer);
1168 return ERR_PTR(-EFAULT);
1169 }
1170 /* got the string, now strip linefeed. */
1171 if (buffer[user_len - 1] == '\n')
1172 buffer[user_len - 1] = 0;
1173 else
1174 buffer[user_len] = 0;
1175 return buffer;
1176}
1177
1178static inline int
1179debug_get_uint(char *buf)
1180{
1181 int rc;
1182
André Goddard Rosae7d28602009-12-14 18:01:06 -08001183 buf = skip_spaces(buf);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001184 rc = simple_strtoul(buf, &buf, 10);
1185 if(*buf){
Michael Holzheu66a464d2005-06-25 14:55:33 -07001186 rc = -EINVAL;
1187 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 return rc;
1189}
1190
1191/*
1192 * functions for debug-views
1193 ***********************************
1194*/
1195
1196/*
1197 * prints out actual debug level
1198 */
1199
Michael Holzheu66a464d2005-06-25 14:55:33 -07001200static int
1201debug_prolog_pages_fn(debug_info_t * id,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 struct debug_view *view, char *out_buf)
1203{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001204 return sprintf(out_buf, "%i\n", id->pages_per_area);
1205}
1206
1207/*
1208 * reads new size (number of pages per debug area)
1209 */
1210
1211static int
1212debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
1213 struct file *file, const char __user *user_buf,
1214 size_t user_len, loff_t * offset)
1215{
1216 char *str;
1217 int rc,new_pages;
1218
1219 if (user_len > 0x10000)
1220 user_len = 0x10000;
1221 if (*offset != 0){
1222 rc = -EPIPE;
1223 goto out;
1224 }
1225 str = debug_get_user_string(user_buf,user_len);
1226 if(IS_ERR(str)){
1227 rc = PTR_ERR(str);
1228 goto out;
1229 }
1230 new_pages = debug_get_uint(str);
1231 if(new_pages < 0){
1232 rc = -EINVAL;
1233 goto free_str;
1234 }
1235 rc = debug_set_size(id,id->nr_areas, new_pages);
1236 if(rc != 0){
1237 rc = -EINVAL;
1238 goto free_str;
1239 }
1240 rc = user_len;
1241free_str:
1242 kfree(str);
1243out:
1244 *offset += user_len;
1245 return rc; /* number of input characters */
1246}
1247
1248/*
1249 * prints out actual debug level
1250 */
1251
1252static int
1253debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf)
1254{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 int rc = 0;
1256
Michael Holzheu66a464d2005-06-25 14:55:33 -07001257 if(id->level == DEBUG_OFF_LEVEL) {
1258 rc = sprintf(out_buf,"-\n");
1259 }
1260 else {
1261 rc = sprintf(out_buf, "%i\n", id->level);
1262 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 return rc;
1264}
1265
1266/*
1267 * reads new debug level
1268 */
1269
Michael Holzheu66a464d2005-06-25 14:55:33 -07001270static int
1271debug_input_level_fn(debug_info_t * id, struct debug_view *view,
1272 struct file *file, const char __user *user_buf,
1273 size_t user_len, loff_t * offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001275 char *str;
1276 int rc,new_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277
Michael Holzheu66a464d2005-06-25 14:55:33 -07001278 if (user_len > 0x10000)
1279 user_len = 0x10000;
1280 if (*offset != 0){
1281 rc = -EPIPE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 goto out;
1283 }
Michael Holzheu66a464d2005-06-25 14:55:33 -07001284 str = debug_get_user_string(user_buf,user_len);
1285 if(IS_ERR(str)){
1286 rc = PTR_ERR(str);
1287 goto out;
1288 }
1289 if(str[0] == '-'){
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 debug_set_level(id, DEBUG_OFF_LEVEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001291 rc = user_len;
1292 goto free_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 } else {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001294 new_level = debug_get_uint(str);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 }
Michael Holzheu66a464d2005-06-25 14:55:33 -07001296 if(new_level < 0) {
Michael Holzheuc5612c12008-12-25 13:39:43 +01001297 pr_warning("%s is not a valid level for a debug "
1298 "feature\n", str);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001299 rc = -EINVAL;
1300 } else {
1301 debug_set_level(id, new_level);
1302 rc = user_len;
1303 }
1304free_str:
1305 kfree(str);
1306out:
1307 *offset += user_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 return rc; /* number of input characters */
1309}
1310
1311
1312/*
1313 * flushes debug areas
1314 */
1315
Heiko Carstens2b67fc42007-02-05 21:16:47 +01001316static void debug_flush(debug_info_t* id, int area)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317{
1318 unsigned long flags;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001319 int i,j;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320
Michael Holzheu66a464d2005-06-25 14:55:33 -07001321 if(!id || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 return;
1323 spin_lock_irqsave(&id->lock,flags);
1324 if(area == DEBUG_FLUSH_ALL){
1325 id->active_area = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001326 memset(id->active_entries, 0, id->nr_areas * sizeof(int));
1327 for (i = 0; i < id->nr_areas; i++) {
1328 id->active_pages[i] = 0;
1329 for(j = 0; j < id->pages_per_area; j++) {
1330 memset(id->areas[i][j], 0, PAGE_SIZE);
1331 }
1332 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 } else if(area >= 0 && area < id->nr_areas) {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001334 id->active_entries[area] = 0;
1335 id->active_pages[area] = 0;
1336 for(i = 0; i < id->pages_per_area; i++) {
1337 memset(id->areas[area][i],0,PAGE_SIZE);
1338 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 }
1340 spin_unlock_irqrestore(&id->lock,flags);
1341}
1342
1343/*
1344 * view function: flushes debug areas
1345 */
1346
Michael Holzheu66a464d2005-06-25 14:55:33 -07001347static int
1348debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
1349 struct file *file, const char __user *user_buf,
1350 size_t user_len, loff_t * offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351{
1352 char input_buf[1];
Michael Holzheu66a464d2005-06-25 14:55:33 -07001353 int rc = user_len;
1354
1355 if (user_len > 0x10000)
1356 user_len = 0x10000;
1357 if (*offset != 0){
1358 rc = -EPIPE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 goto out;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001360 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 if (copy_from_user(input_buf, user_buf, 1)){
1362 rc = -EFAULT;
1363 goto out;
1364 }
1365 if(input_buf[0] == '-') {
1366 debug_flush(id, DEBUG_FLUSH_ALL);
1367 goto out;
1368 }
1369 if (isdigit(input_buf[0])) {
1370 int area = ((int) input_buf[0] - (int) '0');
1371 debug_flush(id, area);
1372 goto out;
1373 }
1374
Michael Holzheuc5612c12008-12-25 13:39:43 +01001375 pr_info("Flushing debug data failed because %c is not a valid "
1376 "area\n", input_buf[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377
Michael Holzheu66a464d2005-06-25 14:55:33 -07001378out:
1379 *offset += user_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 return rc; /* number of input characters */
1381}
1382
1383/*
1384 * prints debug header in raw format
1385 */
1386
Michael Holzheu66a464d2005-06-25 14:55:33 -07001387static int
1388debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
1389 int area, debug_entry_t * entry, char *out_buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390{
1391 int rc;
1392
1393 rc = sizeof(debug_entry_t);
1394 memcpy(out_buf,entry,sizeof(debug_entry_t));
1395 return rc;
1396}
1397
1398/*
1399 * prints debug data in raw format
1400 */
1401
Michael Holzheu66a464d2005-06-25 14:55:33 -07001402static int
1403debug_raw_format_fn(debug_info_t * id, struct debug_view *view,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 char *out_buf, const char *in_buf)
1405{
1406 int rc;
1407
1408 rc = id->buf_size;
1409 memcpy(out_buf, in_buf, id->buf_size);
1410 return rc;
1411}
1412
1413/*
1414 * prints debug data in hex/ascii format
1415 */
1416
Michael Holzheu66a464d2005-06-25 14:55:33 -07001417static int
1418debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
1419 char *out_buf, const char *in_buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420{
1421 int i, rc = 0;
1422
1423 for (i = 0; i < id->buf_size; i++) {
1424 rc += sprintf(out_buf + rc, "%02x ",
1425 ((unsigned char *) in_buf)[i]);
1426 }
1427 rc += sprintf(out_buf + rc, "| ");
1428 for (i = 0; i < id->buf_size; i++) {
1429 unsigned char c = in_buf[i];
1430 if (!isprint(c))
1431 rc += sprintf(out_buf + rc, ".");
1432 else
1433 rc += sprintf(out_buf + rc, "%c", c);
1434 }
1435 rc += sprintf(out_buf + rc, "\n");
1436 return rc;
1437}
1438
1439/*
1440 * prints header for debug entry
1441 */
1442
Michael Holzheu66a464d2005-06-25 14:55:33 -07001443int
1444debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 int area, debug_entry_t * entry, char *out_buf)
1446{
Michael Holzheu942eaab2005-09-03 15:57:58 -07001447 struct timespec time_spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 char *except_str;
1449 unsigned long caller;
1450 int rc = 0;
1451 unsigned int level;
1452
1453 level = entry->id.fields.level;
Christof Schmittb592e892009-08-18 15:43:31 +02001454 stck_to_timespec(entry->id.stck, &time_spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455
1456 if (entry->id.fields.exception)
1457 except_str = "*";
1458 else
1459 except_str = "-";
1460 caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
1461 rc += sprintf(out_buf, "%02i %011lu:%06lu %1u %1s %02i %p ",
Michael Holzheu942eaab2005-09-03 15:57:58 -07001462 area, time_spec.tv_sec, time_spec.tv_nsec / 1000, level,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 except_str, entry->id.fields.cpuid, (void *) caller);
1464 return rc;
1465}
1466
1467/*
1468 * prints debug data sprintf-formated:
1469 * debug_sprinf_event/exception calls must be used together with this view
1470 */
1471
1472#define DEBUG_SPRINTF_MAX_ARGS 10
1473
Michael Holzheu66a464d2005-06-25 14:55:33 -07001474static int
1475debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
1476 char *out_buf, debug_sprintf_entry_t *curr_event)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477{
1478 int num_longs, num_used_args = 0,i, rc = 0;
1479 int index[DEBUG_SPRINTF_MAX_ARGS];
1480
1481 /* count of longs fit into one entry */
1482 num_longs = id->buf_size / sizeof(long);
1483
1484 if(num_longs < 1)
1485 goto out; /* bufsize of entry too small */
1486 if(num_longs == 1) {
1487 /* no args, we use only the string */
1488 strcpy(out_buf, curr_event->string);
1489 rc = strlen(curr_event->string);
1490 goto out;
1491 }
1492
1493 /* number of arguments used for sprintf (without the format string) */
1494 num_used_args = min(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
1495
1496 memset(index,0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
1497
1498 for(i = 0; i < num_used_args; i++)
1499 index[i] = i;
1500
1501 rc = sprintf(out_buf, curr_event->string, curr_event->args[index[0]],
1502 curr_event->args[index[1]], curr_event->args[index[2]],
1503 curr_event->args[index[3]], curr_event->args[index[4]],
1504 curr_event->args[index[5]], curr_event->args[index[6]],
1505 curr_event->args[index[7]], curr_event->args[index[8]],
1506 curr_event->args[index[9]]);
1507
1508out:
1509
1510 return rc;
1511}
1512
1513/*
1514 * clean up module
1515 */
Heiko Carstens2b67fc42007-02-05 21:16:47 +01001516static void __exit debug_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001518 debugfs_remove(debug_debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 unregister_sysctl_table(s390dbf_sysctl_header);
1520 return;
1521}
1522
1523/*
1524 * module definitions
1525 */
Michael Holzheu66a464d2005-06-25 14:55:33 -07001526postcore_initcall(debug_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527module_exit(debug_exit);
1528MODULE_LICENSE("GPL");
1529
1530EXPORT_SYMBOL(debug_register);
1531EXPORT_SYMBOL(debug_unregister);
1532EXPORT_SYMBOL(debug_set_level);
1533EXPORT_SYMBOL(debug_stop_all);
1534EXPORT_SYMBOL(debug_register_view);
1535EXPORT_SYMBOL(debug_unregister_view);
1536EXPORT_SYMBOL(debug_event_common);
1537EXPORT_SYMBOL(debug_exception_common);
1538EXPORT_SYMBOL(debug_hex_ascii_view);
1539EXPORT_SYMBOL(debug_raw_view);
1540EXPORT_SYMBOL(debug_dflt_header_fn);
1541EXPORT_SYMBOL(debug_sprintf_view);
1542EXPORT_SYMBOL(debug_sprintf_exception);
1543EXPORT_SYMBOL(debug_sprintf_event);