diff mbox series

[07/10] thread: print core state with threadstatus

Message ID 20220531091457.2208488-8-npiggin@gmail.com
State New
Headers show
Series [01/10] sbefifo: correct typo in thread target name | expand

Commit Message

Nicholas Piggin May 31, 2022, 9:14 a.m. UTC
For each line of threads printed, print interesting core state as well.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/thread.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/thread.c b/src/thread.c
index 76909d67..4093f1a3 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -220,6 +220,48 @@  static int thr_stop(void)
 }
 OPTCMD_DEFINE_CMD(stop, thr_stop);
 
+static int print_one_core(struct pdbg_target *core)
+{
+	struct core_state cstate;
+	char s;
+
+	if (!path_target_selected(core)) {
+		printf("--- ");
+		return 0;
+	}
+
+	cstate = core_status(core);
+
+	switch (cstate.smt_state) {
+	case PDBG_SMT_1:
+		s = '1';
+		break;
+
+	case PDBG_SMT_2:
+		s = '2';
+		break;
+
+	case PDBG_SMT_4:
+		s = '4';
+		break;
+
+	case PDBG_SMT_8:
+		s = '8';
+		break;
+
+	default:
+		s = '.';
+		break;
+	}
+
+	printf("%c%c%c ",
+	       s,
+	       (cstate.fused_core_mode ? 'F': 'N'),
+	       (cstate.lpar_per_thread ? 'T': 'C'));
+
+	return 1;
+}
+
 
 static int print_one_thread(struct pdbg_target *thread)
 {
@@ -233,7 +275,6 @@  static int print_one_thread(struct pdbg_target *thread)
 
 	tstate = thread_status(thread);
 
-
 	switch (tstate.sleep_state) {
 	case PDBG_THREAD_STATE_DOZE:
 		c = 'D';
@@ -292,7 +333,7 @@  static int thread_status_print(void)
 		if (pdbg_target_status(pib) != PDBG_TARGET_ENABLED)
 			continue;
 
-		printf("\np%01dt:", pdbg_target_index(pib));
+		printf("\np%01dt:     ", pdbg_target_index(pib));
 		for (i = 0; i < threads_per_core; i++)
 			printf("   %d", i);
 		printf("\n");
@@ -304,6 +345,7 @@  static int thread_status_print(void)
 				continue;
 
 			printf("c%02d:  ", pdbg_target_index(core));
+			print_one_core(core);
 
 			pdbg_for_each_target("thread", core, thread)
 				count += print_one_thread(thread);