[patch v4 20/24] btrace, gdbserver: read branch trace incrementally

Jan Kratochvil jan.kratochvil@redhat.com
Wed Sep 25 19:05:00 GMT 2013


On Mon, 23 Sep 2013 09:09:18 +0200, Metzger, Markus T wrote:
> > > I need to distinguish different types of errors, e.g. overflow and not
> > supported.
> > 
> > Then use enum.  There is for example:
> > enum return_reason
> >   {
> >     /* User interrupt.  */
> >     RETURN_QUIT = -2,
> >     /* Any other error.  */
> >     RETURN_ERROR
> >   };
> > 
> > One could even throw and catch specific exceptions (enum errors) but I find
> > that needlessly overcomplicated when we just return to the immediate
> > caller.
> 
> In addition to errors I defined myself, I might get errors from the system call,
> e.g. ENOMEM, EOPNOTSUPP, ENOSYS.

I do not see such system call.  linux_read_btrace can ever return only 0,
-EOVERFLOW or -ENOSYS and nothing else.  It never returns for example
variable value like "-errno".


> For the not-available function, for
> example, I'm just mimicking the error that would be returned by the system
> call on systems where that call is not available.

This is not GDB style, it probably comes from Linux kernel.  GDB code should
not needlessly depend on any system E* macros as it reduces portability
(these are linux-* files but still).


> Do you want me to translate those into an enum?

As it can return only 0, -EOVERFLOW and -ENOSYS yes, I find enum as the best
one.


Thanks,
Jan



More information about the Gdb-patches mailing list