Whamcloud - gitweb
b=15977 analyse only consistent part of the log
[fs/lustre-release.git] / lnet / utils / debugctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
5  *
6  *   This file is part of Portals, http://www.sf.net/projects/lustre/
7  *
8  *   Portals is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Portals is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Portals; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Some day I'll split all of this functionality into a cfs_debug module
22  * of its own.  That day is not today.
23  */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <lnet/lnetctl.h>
28 #include <libcfs/libcfsutil.h>
29
30
31 command_t list[] = {
32         {"debug_kernel", jt_dbg_debug_kernel, 0, "usage: debug_kernel [file] [raw], get debug buffer and print it [to a file]"},
33         {"debug_daemon", jt_dbg_debug_daemon, 0, "usage: debug_daemon [start file|stop], control debug daemon to dump debug buffer to a file"}, 
34         {"debug_file", jt_dbg_debug_file, 0, "usage: debug_file <input> [output] [raw], read debug buffer from input and print it [to output]"},
35         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer"},
36         {"mark", jt_dbg_mark_debug_buf, 0, "insert a marker into the kernel debug buffer (args: [marker text])"},
37         {"filter", jt_dbg_filter, 0, "filter certain messages (args: subsystem/debug ID)\n"},
38         {"show", jt_dbg_show, 0, "enable certain messages (args: subsystem/debug ID)\n"},
39         {"list", jt_dbg_list, 0, "list subsystem and debug types (args: subs or types)\n"},
40         {"modules", jt_dbg_modules, 0, "provide gdb-friendly module info (arg: <path>)"},
41         {"panic", jt_dbg_panic, 0, "cause the kernel to panic"},
42         {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"},
43         {"help", Parser_help, 0, "help"},
44         {"exit", Parser_quit, 0, "quit"},
45         {"quit", Parser_quit, 0, "quit"},
46         { 0, 0, 0, NULL }
47 };
48
49 int main(int argc, char **argv)
50 {
51         int rc = 0;
52
53         rc = libcfs_arch_init();
54         if (rc < 0)
55                 return rc;
56
57         rc =  dbg_initialize(argc, argv);
58         if (rc < 0)
59                 goto errorout;
60
61         register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH, 
62                          LNET_DEV_MAJOR, LNET_DEV_MINOR);
63
64         Parser_init("debugctl > ", list);
65         if (argc > 1) {
66                 rc = Parser_execarg(argc - 1, &argv[1], list);
67                 unregister_ioc_dev(LNET_DEV_ID);
68                 goto errorout;
69         }
70
71         Parser_commands();
72
73         unregister_ioc_dev(LNET_DEV_ID);
74
75 errorout:
76         libcfs_arch_cleanup();
77         return rc;
78 }