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

Joel Stanley joel at jms.id.au
Fri Oct 9 23:47:15 AEDT 2020


On Fri, 9 Oct 2020 at 04:00, Amitay Isaacs <amitay at ozlabs.org> wrote:
>
> Signed-off-by: Amitay Isaacs <amitay at 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 at 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 at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg


More information about the Pdbg mailing list