[Pdbg] [PATCH 13/14] pdbg: expert mode

Nicholas Piggin npiggin at gmail.com
Mon Apr 9 17:35:21 AEST 2018


Add an --expert mode of things that are likely to make you cry.
Or things that carry state over multiple invocations of pdbg and
have to be cleaned up manually.

More things can be moved to non-expert mode as they are ironed out.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 src/main.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 3f026f8..368bc4e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,12 +64,15 @@ static int threadsel[MAX_PROCESSORS][MAX_CHIPS][MAX_THREADS];
 
 static int handle_probe(int optind, int argc, char *argv[]);
 
-static struct {
+struct action {
 	const char *name;
 	const char *args;
 	const char *desc;
 	int (*fn)(int, int, char **);
-} actions[] = {
+};
+
+static bool expert = false;
+static struct action expert_actions[] = {
 	{ "getcfam", "<address>", "Read system cfam", &handle_cfams },
 	{ "putcfam", "<address> <value> [<mask>]", "Write system cfam", &handle_cfams },
 	{ "getscom", "<address>", "Read system scom", &handle_scoms },
@@ -100,6 +103,12 @@ static struct {
 	{ "probe", "", "", &handle_probe },
 };
 
+static struct action actions[] = {
+	{ "sreset",  "", "Reset", &thread_sreset },
+	{ "probe", "", "", &handle_probe },
+};
+
+
 static void print_usage(char *pname)
 {
 	int i;
@@ -125,12 +134,18 @@ static void print_usage(char *pname)
 	printf("\t-s, --slave-address=backend device address\n");
 	printf("\t\tDevice slave address to use for the backend. Not used by FSI\n");
 	printf("\t\tand defaults to 0x50 for I2C\n");
+	printf("\t--expert\n");
 	printf("\t-V, --version\n");
 	printf("\t-h, --help\n");
 	printf("\n");
 	printf(" Commands:\n");
 	for (i = 0; i < ARRAY_SIZE(actions); i++)
 		printf("\t%s %s\n", actions[i].name, actions[i].args);
+	if (expert) {
+		printf(" Expert Commands:\n");
+		for (i = 0; i < ARRAY_SIZE(expert_actions); i++)
+			printf("\t%s %s\n", expert_actions[i].name, expert_actions[i].args);
+	}
 }
 
 static bool parse_options(int argc, char *argv[])
@@ -148,6 +163,7 @@ static bool parse_options(int argc, char *argv[])
 		{"slave-address",	required_argument,	NULL,	's'},
 		{"thread",		required_argument,	NULL,	't'},
 		{"version",		no_argument,		NULL,	'V'},
+		{"expert",		no_argument,		NULL,	'E'},
 		{NULL,			0,			NULL,     0}
 	};
 	char *endptr;
@@ -242,6 +258,11 @@ static bool parse_options(int argc, char *argv[])
 			exit(1);
 			break;
 
+		case 'E':
+			errno = 0;
+			expert = true;
+			break;
+
 		case '?':
 		case 'h':
 			opt_error = true;
-- 
2.17.0



More information about the Pdbg mailing list