[PATCH 5/5] gdb: convert arc to new-style debug macros
Shahab Vahedi
shahab.vahedi@gmail.com
Wed Jan 13 15:35:23 GMT 2021
Hi Simon,
Thank you for the patch. I have 2 remarks:
On Fri, Jan 08, 2021 at 11:37:03PM -0500, Simon Marchi wrote:
> Hi Shahab.
>
> Would you mind giving a look at this patch?
>
> Thanks!
>
> Simon
>
> On 2021-01-08 11:28 p.m., Simon Marchi via Gdb-patches wrote:
> > Add the standard arc_debug_printf, but also arc_debug_printf_v
> > (verbose), for when arc_debug is >= 2. This is similar to the existing
> > dwarf_read_debug_print_v.
> >
> > gdb/ChangeLog:
> >
> > * arc-tdep.h (arc_debug_printf, arc_debug_printf_v): New.
> > * arc-tdep.c: Use arc_debug_printf instead of arc_debug +
> > debug_printf.
> > * arc-linux-nat.c: Likewise.
> > * arc-linux-tdep.c: Likewise.
> > * arc-newlib-tdep.c: Likewise.
> >
> > Change-Id: I5d937566ed7a1925f7982e8809802c8f0560d8c6
> > ---
> > gdb/arc-linux-nat.c | 11 +---
> > gdb/arc-linux-tdep.c | 30 +++-------
> > gdb/arc-newlib-tdep.c | 6 +-
> > gdb/arc-tdep.c | 135 ++++++++++++++++--------------------------
> > gdb/arc-tdep.h | 10 ++++
> > 5 files changed, 76 insertions(+), 116 deletions(-)
> >
> > diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
> > index 70fc3d95c483..43a801471772 100644
> > --- a/gdb/arc-tdep.h
> > +++ b/gdb/arc-tdep.h
> > @@ -114,6 +114,16 @@ enum arc_regnum
> >
> > extern int arc_debug;
> >
> > +/* Print an "arc" debug statement if arc_debug is >= 1. */
> > +
> > +#define arc_debug_printf(fmt, ...) \
> > + debug_prefixed_printf_cond (arc_debug >= 1, "arc", fmt, ##__VA_ARGS__)
> > +
> > +/* Print an "arc" debug statement if arc_debug is >= 2. */
> > +
> > +#define arc_debug_printf_v(fmt, ...) \
> > + debug_prefixed_printf_cond (arc_debug >= 2, "arc", fmt, ##__VA_ARGS__)
> > +
Please have the macro defined per module (file). That way we can use
a more meaningful module name than "arc", such as "arc-linux-nat" in
arc-linux-nat.c file or "arc-linux-tdep" in arc-linux-tdep.c file, etc.
> > diff --git a/gdb/arc-linux-nat.c b/gdb/arc-linux-nat.c
> > index db5d44312a68..d55623e0e9cf 100644
> > --- a/gdb/arc-linux-nat.c
> > +++ b/gdb/arc-linux-nat.c
> > @@ -295,8 +291,7 @@ ps_err_e
> > ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx,
> > void **base)
> > {
> > - if (arc_debug >= 2)
> > - debug_printf ("arc-linux-nat: ps_get_thread_area called");
> > + arc_debug_printf_v ("called");
A mere arc_debug_printf() would suffice. In other words, forget about
the verbosity level for this logging. This will also reduce the amount
of debug macros defined in this file.
Cheers,
Shahab
More information about the Gdb-patches
mailing list