diff mbox series

[8/8] libpdbg: Update thread state when starting/stopping all threads

Message ID 20201009040001.310868-9-amitay@ozlabs.org
State Accepted
Headers show
Series Fix thread status for sbefifo thread driver | expand

Commit Message

Amitay Isaacs Oct. 9, 2020, 4 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/sbefifo.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

Comments

Joel Stanley Oct. 9, 2020, 12:47 p.m. UTC | #1
On Fri, 9 Oct 2020 at 04:00, Amitay Isaacs <amitay@ozlabs.org> wrote:
>
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  libpdbg/sbefifo.c | 36 +++++++++++++++++++++++++++++++++---
>  1 file changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
> index fae2ab7..a8e4522 100644
> --- a/libpdbg/sbefifo.c
> +++ b/libpdbg/sbefifo.c
> @@ -263,12 +263,32 @@ static int sbefifo_pib_thread_op(struct pib *pib, uint32_t oper)
>
>  static int sbefifo_pib_thread_start(struct pib *pib)
>  {
> -       return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
> +       struct pdbg_target *target;
> +       int rc;
> +
> +       rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
> +
> +       pdbg_for_each_target("thread", &pib->target, target) {
> +               struct thread *thread = target_to_thread(target);
> +               thread->status = thread->state(thread);
> +       }

You could have a update_thread_state(struct pib *pib) to save
duplicating this three times.

Either way,

Reviewed-by: Joel Stanley <joel@jms.id.au>


> +
> +       return rc;
>  }
>
>  static int sbefifo_pib_thread_stop(struct pib *pib)
>  {
> -       return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_STOP);
> +       struct pdbg_target *target;
> +       int rc;
> +
> +       rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_STOP);
> +
> +       pdbg_for_each_target("thread", &pib->target, target) {
> +               struct thread *thread = target_to_thread(target);
> +               thread->status = thread->state(thread);
> +       }
> +
> +       return rc;
>  }
>
>  static int sbefifo_pib_thread_step(struct pib *pib, int count)
> @@ -283,7 +303,17 @@ static int sbefifo_pib_thread_step(struct pib *pib, int count)
>
>  static int sbefifo_pib_thread_sreset(struct pib *pib)
>  {
> -       return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_SRESET);
> +       struct pdbg_target *target;
> +       int rc;
> +
> +       rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_SRESET);
> +
> +       pdbg_for_each_target("thread", &pib->target, target) {
> +               struct thread *thread = target_to_thread(target);
> +               thread->status = thread->state(thread);
> +       }
> +
> +       return rc;
>  }
>
>  static int sbefifo_thread_probe(struct pdbg_target *target)
> --
> 2.26.2
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
Amitay Isaacs Oct. 13, 2020, 6:37 a.m. UTC | #2
On Fri, 2020-10-09 at 12:47 +0000, Joel Stanley wrote:
> On Fri, 9 Oct 2020 at 04:00, Amitay Isaacs <amitay@ozlabs.org> wrote:
> > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > ---
> >  libpdbg/sbefifo.c | 36 +++++++++++++++++++++++++++++++++---
> >  1 file changed, 33 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
> > index fae2ab7..a8e4522 100644
> > --- a/libpdbg/sbefifo.c
> > +++ b/libpdbg/sbefifo.c
> > @@ -263,12 +263,32 @@ static int sbefifo_pib_thread_op(struct pib
> > *pib, uint32_t oper)
> > 
> >  static int sbefifo_pib_thread_start(struct pib *pib)
> >  {
> > -       return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
> > +       struct pdbg_target *target;
> > +       int rc;
> > +
> > +       rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
> > +
> > +       pdbg_for_each_target("thread", &pib->target, target) {
> > +               struct thread *thread = target_to_thread(target);
> > +               thread->status = thread->state(thread);
> > +       }
> 
> You could have a update_thread_state(struct pib *pib) to save
> duplicating this three times.

Good point. :-)

> 
> Either way,
> 
> Reviewed-by: Joel Stanley <joel@jms.id.au>
> 

Amitay.
diff mbox series

Patch

diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
index fae2ab7..a8e4522 100644
--- a/libpdbg/sbefifo.c
+++ b/libpdbg/sbefifo.c
@@ -263,12 +263,32 @@  static int sbefifo_pib_thread_op(struct pib *pib, uint32_t oper)
 
 static int sbefifo_pib_thread_start(struct pib *pib)
 {
-	return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
+	struct pdbg_target *target;
+	int rc;
+
+	rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_START);
+
+	pdbg_for_each_target("thread", &pib->target, target) {
+		struct thread *thread = target_to_thread(target);
+		thread->status = thread->state(thread);
+	}
+
+	return rc;
 }
 
 static int sbefifo_pib_thread_stop(struct pib *pib)
 {
-	return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_STOP);
+	struct pdbg_target *target;
+	int rc;
+
+	rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_STOP);
+
+	pdbg_for_each_target("thread", &pib->target, target) {
+		struct thread *thread = target_to_thread(target);
+		thread->status = thread->state(thread);
+	}
+
+	return rc;
 }
 
 static int sbefifo_pib_thread_step(struct pib *pib, int count)
@@ -283,7 +303,17 @@  static int sbefifo_pib_thread_step(struct pib *pib, int count)
 
 static int sbefifo_pib_thread_sreset(struct pib *pib)
 {
-	return sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_SRESET);
+	struct pdbg_target *target;
+	int rc;
+
+	rc = sbefifo_pib_thread_op(pib, SBEFIFO_INSN_OP_SRESET);
+
+	pdbg_for_each_target("thread", &pib->target, target) {
+		struct thread *thread = target_to_thread(target);
+		thread->status = thread->state(thread);
+	}
+
+	return rc;
 }
 
 static int sbefifo_thread_probe(struct pdbg_target *target)