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