-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*****************************************************************************\ | ||
* Copyright (c) 2017 Lawrence Livermore National Security, LLC. Produced at | ||
* the Lawrence Livermore National Laboratory (cf, AUTHORS, DISCLAIMER.LLNS). | ||
* LLNL-CODE-658032 All rights reserved. | ||
* | ||
* This file is part of the Flux resource manager framework. | ||
* For details, see https://github.com/flux-framework. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the license, or (at your option) | ||
* any later version. | ||
* | ||
* Flux is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
* See also: http://www.gnu.org/licenses/ | ||
\*****************************************************************************/ | ||
#include "builtin.h" | ||
|
||
static struct optparse_option debug_opts[] = { | ||
{ .name = "clear", .key = 'C', .has_arg = 0, | ||
.usage = "Set debug flags to 0", }, | ||
{ .name = "set", .key = 'S', .has_arg = 1, | ||
.usage = "Set debug flags to MASK", }, | ||
{ .name = "setbit", .key = 's', .has_arg = 1, | ||
.usage = "Set one debug flag to 1", }, | ||
{ .name = "clearbit", .key = 'c', .has_arg = 1, | ||
.usage = "Set one debug flag to 0", }, | ||
OPTPARSE_TABLE_END, | ||
}; | ||
|
||
|
||
static int cmd_debug (optparse_t *p, int ac, char *av[]) | ||
{ | ||
int n; | ||
flux_t *h; | ||
char *topic = NULL; | ||
const char *op = "setbit"; | ||
int flags = 0; | ||
flux_rpc_t *rpc = NULL; | ||
|
||
if ((n = optparse_option_index (p)) != ac - 1) | ||
log_msg_exit ("flux-debug requires service argument"); | ||
topic = xasprintf ("%s.debug", av[n]); | ||
|
||
if (!(h = builtin_get_flux_handle (p))) | ||
log_err_exit ("flux_open"); | ||
if (optparse_hasopt (p, "clear")) { | ||
op = "clr"; | ||
flags = strtoul (optparse_get_str (p, "clear", NULL), NULL, 0); | ||
} | ||
else if (optparse_hasopt (p, "set")) { | ||
op = "set"; | ||
flags = strtoul (optparse_get_str (p, "set", NULL), NULL, 0); | ||
} | ||
else if (optparse_hasopt (p, "clearbit")) { | ||
op = "clrbit"; | ||
flags = strtoul (optparse_get_str (p, "clearbit", NULL), NULL, 0); | ||
} | ||
else if (optparse_hasopt (p, "setbit")) { | ||
op = "setbit"; | ||
flags = strtoul (optparse_get_str (p, "setbit", NULL), NULL, 0); | ||
} | ||
if (!(rpc = flux_rpcf (h, topic, FLUX_NODEID_ANY, 0, "{s:s s:i}", | ||
"op", op, "flags", flags))) | ||
log_err_exit ("%s", topic); | ||
if (flux_rpc_getf (rpc, "{s:i}", "flags", &flags) < 0) | ||
log_err_exit ("%s", topic); | ||
printf ("0x%x\n", flags); | ||
flux_close (h); | ||
free (topic); | ||
return (0); | ||
} | ||
|
||
int subcommand_debug_register (optparse_t *p) | ||
{ | ||
optparse_err_t e; | ||
e = optparse_reg_subcommand (p, | ||
"debug", | ||
cmd_debug, | ||
"service [OPTIONS...]", | ||
"Get/set service debug flags", | ||
0, | ||
debug_opts); | ||
return (e == OPTPARSE_SUCCESS ? 0 : -1); | ||
} | ||
|
||
/* | ||
* vi: ts=4 sw=4 expandtab | ||
*/ |