arch: Fix past end write bug in to_number for vec

The to_number for vector registers had an off-by-one bug that wrote one
byte past the destination data structure.  Overhauled the code
significantly to make the logic more clear.  This could have caused
random data corruption in the simulator itself, but also for the
simulated application when resuming from a checkpoint.

The serialisation part is frustratingly asymmetric: it uses csprintf per
byte, while deserialisation munges std::strings.

Note: both serialisation and deserialisation use the same, non-intuitive
order: despite prefixing the number with 0x, they both store the
lowest-address byte left-most; effectively turning this into a
big-endian number.  Not changing that so that checkpoints will remain
compatible, but.. brrrr!  Added notes in both places, and also dead code
that I used to test this.

Change-Id: Id775fe7335af07d8a76d4c81153591d3a009e95c
Signed-off-by: Stephan Diestelhorst <stephan.diestelhorst@arm.com>
1 file changed