gdb: remove two uses of alloca from printcmd.c
Remove a couple of uses of alloca from printcmd.c, and replace them
with gdb::byte_vector.
An earlier variant of this patch was proposed in this thread:
https://inbox.sourceware.org/gdb-patches/cover.
1677533215.git.aburgess@redhat.com/
however, there was push back on that thread due to it adding extra
dynamic allocation, i.e. moving the memory buffers off the stack on to
the heap.
However, of all the patches originally proposed, I think in these two
cases moving off the stack is the correct thing to do. Unlike all the
other patches in the original series, where the data being read
was (mostly) small in size, a register, or a couple of registers, in
this case we are reading an arbitrary string from the inferior. This
could be any size, and so should not be placed on the stack.
So in this commit I replace the use of alloca with std::byte_vector
and simplify the logic a little (I think) to take advantage of the
ability of std::byte_vector to dynamically grow in size.
Of course, really, we should probably be checking the max-value-size
setting as we load the string to stop GDB crashing if a corrupted
inferior causes GDB to try read a stupidly large amount of
memory... but I'm leaving that for a follow on patch.
There should be no user visible changes after this commit.