[Pdbg] [PATCH 07/10] libpdbg/p9chip.c: allow sreset in !expert mode

Nicholas Piggin npiggin at gmail.com
Thu May 3 16:26:59 AEST 2018


Have sreset work in !expert mode, by stopping threads automatically.

There is some indication in the workbook that the sreset control
works on running threads, but testing has so far proven otherwise,
so stop them if they were not stopped.

Expert mode still require it only be used on threads already stopped.

Signed-off-by: Nicholas Piggin <npiggin at mgail.com>
---
 libpdbg/p9chip.c | 8 ++++++++
 src/main.c       | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index d9fcf5f..3dafcf2 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -195,6 +195,14 @@ static int p9_thread_step(struct thread *thread, int count)
 
 static int p9_thread_sreset(struct thread *thread)
 {
+	if (!pdbg_expert_mode) {
+		/* Something already quiesced it, fail*/
+		if (thread->status & THREAD_STATUS_QUIESCE)
+			return 1;
+		if (p9_thread_stop(thread))
+			return 1;
+	}
+
 	/* Can only sreset if a thread is quiesced */
 	if (!(thread->status & THREAD_STATUS_QUIESCE))
 		return 1;
diff --git a/src/main.c b/src/main.c
index b651395..a295ef1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -92,7 +92,6 @@ static struct action expert_actions[] = {
 	{ "start",   "", "Start thread", &thread_start },
 	{ "step",    "<count>", "Set a thread <count> instructions", &thread_step },
 	{ "stop",    "", "Stop thread", &thread_stop },
-	{ "sreset",  "", "Reset", &thread_sreset },
 	{ "htm_start", "", "[deprecated use 'htm nest start'] Start Nest HTM", &run_htm_start },
 	{ "htm_stop", "", "[deprecated use 'htm nest stop'] Stop Nest HTM", &run_htm_stop },
 	{ "htm_status", "", "[deprecated use 'htm nest status'] Print the status of HTM", &run_htm_status },
@@ -107,6 +106,7 @@ static struct action expert_actions[] = {
 static struct action actions[] = {
 	{ "probe", "", "", &handle_probe },
 	{ "threadstatus", "", "Print the status of a thread", &thread_status_print },
+	{ "sreset",  "", "Reset", &thread_sreset },
 };
 
 
-- 
2.17.0



More information about the Pdbg mailing list