Re: [DTC][RFC] dtc: Allow better error reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Feb 19, 2021 at 11:07:53AM +0530, Viresh Kumar wrote:
> On 17-02-21, 16:07, David Gibson wrote:
> > > diff --git a/dtc.h b/dtc.h
> > > index d3e82fb8e3db..b8ffec155263 100644
> > > --- a/dtc.h
> > > +++ b/dtc.h
> > > @@ -29,6 +29,12 @@
> > >  #define debug(...)
> > >  #endif
> > >  
> > > +#ifdef VERBOSE
> > > +#define dtc_err(fmt, ...)	fprintf(stderr, "DTC: %s: %d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
> > > +#else
> > > +#define dtc_err(fmt, ...)
> > > +#endif
> > 
> > Actually, the natural way to handle this is to make dtc_err() -
> > hrm... bad name, since this is libfdt - be something that must be
> > provided by libfdt_env.h.  The default version would have it be a
> > no-op, with a define that makes it use stdio.
> > 
> > This has the additional advantage that it would be relatively
> > straightfoward to enable the rich reporting in a non-POSIXish
> > environment (these should provide their own libfdt_env.h and it can
> > implement the error reporting callback in a way that makes sense in
> > that environment.
> 
> Okay, I will move it to libfdt_env.h. And using -DVERBOSE to enable
> rich errors look fine to you, right ?

Well, using -DVERBOSE looks like an option worth considering further
to me.  I'm not yet totally convinced its the best approach.

> > You will also definitely need Makefile changes, because you'll need to
> > make the fdtoverlay binary link to the verbose-compiled version of
> > libfdt not the normal one.
> 
> Actually it worked for me because of how we compile this in kernel, we
> don't link different libraries there.
> 
> libfdt-objs     := fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o
> libfdt          = $(addprefix libfdt/,$(libfdt-objs))
> fdtoverlay-objs := $(libfdt) fdtoverlay.o util.o
> 
> HOST_EXTRACFLAGS := -DVERBOSE

Um.. I think this is only working because the objects are compiled one
way for the target and another for the host.  If you ever wanted to
build any other host side tools that shouldn't have -DVERBOSE, this
would break.

> > Except.... it might make more sense to do this in dtc rather than
> > libfdt, more on that in different mails.
> 
> I am not sure about this comment, are you going to send more emails on
> this ?

Sorry, I got sidetracked and didn't get around to following that up.
I'm still trying to do that.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux