Re: [PATCH perf/core v4 01/19] perf probe: Use strbuf for making strings

From: Masami Hiramatsu
Date: Wed Apr 27 2016 - 14:44:50 EST


On Tue, 26 Apr 2016 11:59:34 -0300
Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:

> Em Tue, Apr 26, 2016 at 11:40:47PM +0900, Masami Hiramatsu escreveu:
> > On Tue, 26 Apr 2016 10:36:57 -0300
> > Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> >
> > > Em Tue, Apr 26, 2016 at 06:02:11PM +0900, Masami Hiramatsu escreveu:
> > > > From: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
> > > >
> > > > Replace many fixed-length char array with strbuf to
> > > > stringify perf_probe_event and probe_trace_event etc.
> > >
> > > Sure you want to do that? From time to time I try to reduce the strbuf
> > > usage, not grow it :-\
> >
> > Aah, I got what you want.
> >
> > >
> > > That is one of the last users of xrealloc(), via that ALLOC_GROW()
> > > thing.
> >
> > Hmm I'm not sure what you considering, memory usage? or code reducing?
> > I also would like to remove e_snprintf() use in perf probe by replacing
> > with strbuf functions. I'd like to find better way.
>
> What I don't like is that xrealloc ends up calling die() :-\ It should
> instead propagate back the error.
>
> In lots of cases I managed to use what is in glibc, asprintf(), that
> will allocate space and format in one go.
>
> But strbuf has this addf() one that indeed is handy. So I think I'll
> take this patch as it is not for the simpler cases where asprintf() can
> be used.

OK, I'll try to remove die() and xrealloc() from the strbuf, since
it seems most of users of strbuf() is perf-probe.

Thanks,

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>