Re: [PATCH 11/12] gdb: make displaced stepping implementation capable of managing multiple buffers

Simon Marchi
2020-11-30T18:58:46Z

On 2020-11-24 8:41 p.m., Pedro Alves wrote:
> Call:
>
> m_buffers.reserve (buffer_addrs.size ());
>
> before.
>
>
> But even better, the caller is allocating a temporary std::vector
> and passing that:
>
> + std::vector<CORE_ADDR> buffers;
> + for (int i = 0; i < gdbarch_data->num_disp_step_buffers; i++)
> + buffers.push_back (disp_step_buf_addr + i * buf_len);
>
> So how about making the ctor above be instead:
>
> displaced_step_buffers (std::vector<CORE_ADDR> &&buffer_addrs);
>
> and make the caller move the vector into displaced_step_buffers?
>
> + per_inferior->disp_step_bufs.emplace (std::move (buffers));

displaced_step_buffers' ctor takes a vector of CORE_ADDR, but it
contains a vector of displaced_step_buffer. So it can't just move and
use directly the vector passed by its caller.

I'll call reserve though.

Simon