Re: [PATCH v2 3/8] Use std::vector for agent_expr::reg_mask

Simon Marchi via Gdb-patches
2023-06-21T16:16:43Z

On 6/20/23 13:36, Tom Tromey wrote:
> agent_expr::reg_mask implements its own packed boolean vector. This
> patch replaces it with a std::vector<bool>, simplifying the code.
> ---
> gdb/ax-general.c | 33 +++++++++------------------------
> gdb/ax.h | 15 +++++----------
> gdb/tracepoint.c | 16 +++++-----------
> 3 files changed, 19 insertions(+), 45 deletions(-)

Starting with this patch, running gdb.ada/ax-ada.exp, I get (building
with -D_GLIBCXX_DEBUG):

(gdb) run

Starting program: /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ada/ax-ada/prog

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".

Breakpoint 1, prog () at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.ada/ax-ada/prog.adb:22

22 null; -- START

(gdb) maint agent-eval variable = 23

/usr/include/c++/13.1.1/debug/vector:442:

In function:

std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp,

_Allocator>::operator[](size_type) [with _Tp = bool; _Allocator =

std::allocator<bool>; reference = std::vector<bool, std::allocator<bool>

>::reference; size_type = long unsigned int]

Error: attempt to subscript container with out-of-bounds index 6, but

container only holds 6 elements.

Objects involved in the operation:

sequence "this" @ 0x60f00000ac30 {

type = std::debug::vector<bool, std::allocator<bool> >;

}

Simon