[Pdbg] [PATCH 08/14] libpdbg: thread_regs don't print regs

Joel Stanley joel at jms.id.au
Wed Mar 16 10:13:23 AEDT 2022


On Mon, 14 Mar 2022 at 04:18, Nicholas Piggin <npiggin at gmail.com> wrote:
>
> The gdbserver uses thread_getregs to send data to the client, printing
> to console is noisy. Push the printing into callers that want it.
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>

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

> ---
>  libpdbg/chip.c   | 2 --
>  libpdbg/thread.c | 7 +------
>  src/thread.c     | 2 ++
>  3 files changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/libpdbg/chip.c b/libpdbg/chip.c
> index 79aeb35..6cbf48b 100644
> --- a/libpdbg/chip.c
> +++ b/libpdbg/chip.c
> @@ -380,8 +380,6 @@ int ram_getregs(struct thread *thread, struct thread_regs *regs)
>
>         CHECK_ERR(thread->ram_destroy(thread));
>
> -       thread_print_regs(regs);
> -
>         return 0;
>  }
>
> diff --git a/libpdbg/thread.c b/libpdbg/thread.c
> index 4a7523c..78a59b8 100644
> --- a/libpdbg/thread.c
> +++ b/libpdbg/thread.c
> @@ -371,7 +371,6 @@ void thread_print_regs(struct thread_regs *regs)
>  int thread_getregs(struct pdbg_target *target, struct thread_regs *regs)
>  {
>         struct thread *thread;
> -       int err;
>
>         assert(pdbg_target_is_class(target, "thread"));
>
> @@ -385,11 +384,7 @@ int thread_getregs(struct pdbg_target *target, struct thread_regs *regs)
>                 return -1;
>         }
>
> -       err = thread->getregs(thread, regs);
> -       if (!err)
> -               thread_print_regs(regs);
> -
> -       return err;
> +       return thread->getregs(thread, regs);
>  }
>
>  int thread_getgpr(struct pdbg_target *target, int gpr, uint64_t *value)
> diff --git a/src/thread.c b/src/thread.c
> index 8ddf4ae..76909d6 100644
> --- a/src/thread.c
> +++ b/src/thread.c
> @@ -362,6 +362,8 @@ static int thread_regs_print(struct reg_flags flags)
>                 if (thread_getregs(thread, &regs))
>                         continue;

Unrelated to this patch, we should print something when thread_getregs
fails here. Currently we just print out the proc/core/thread numbers
and move on, which is a bit mysterious for new users.

>
> +               thread_print_regs(&regs);
> +
>                 if (flags.do_backtrace) {
>                         struct pdbg_target *adu;
>
> --
> 2.23.0
>
> --
> Pdbg mailing list
> Pdbg at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg


More information about the Pdbg mailing list