This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/3] Introduce gdb::array_view, symtabs_and_lines -> std::vector


On 08/21/2017 08:27 PM, Pedro Alves wrote:
> Looking at the "list and multiple locations" patch [1], I thought that
> it's a bit annoying/frustrating to have do remember to free the sals
> array that a symtabs_and_lines object wraps, with 'xfree (sals.sals)'
> or the equivalent make_cleanup(xfree, ...), not to mention how
> error-prone manual memory management is.  We can do better in C++.
> 
> So I wrote a patch to replace 'struct symtabs_and_lines' with 'typedef
> std::vector<symtab_and_line> symtabs_and_lines'.  That works nicelly,
> except that I wasn't entirely happy that that would introduce heap
> allocations in a few cases where there is none nowadays.
> 
> I then addressed that by adding an array_view abstraction, which is
> something that I've wanted at other times before.
> 
> After that, we'd end up with some places using a std::vector disguised
> behind the symtabs_and_lines typedef, while in other places we'd be
> spelling out gdb::array_view.  With that, I no longer see any value in
> keeping the symtabs_and_lines typedef, kind of giving preference to
> std::vector, so I removed the typedef, choosing to spell out
> std::vector explicitly.
> 
> (I'm aware that there are several proposals for adding something like
> array_view to the standard C++ library.  In this implementation, which
> was written from scratch and developed in parallel with the unit
> tests, I chose to keep it as simple and safe as possible.  For
> example, there is no support for ranks != 1, simply because the main
> use case this aims at addressing is abstracting out std::vector vs
> stack arrays in APIs.)
> 
> [1] https://sourceware.org/ml/gdb-patches/2017-07/msg00280.html
> 
> Note that the net increase shown below is mostly caused by the new
> unit tests.  If we only count patches 2 and 3, then we get instead:
> 
>   33 files changed, 537 insertions(+), 820 deletions(-)

FYI, I'm pushing this in now.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]