Re: [PATCH 2/3] Fix copy_bitwise()

Pedro Alves
2016-11-15T19:42:39Z

On 11/14/2016 03:02 PM, Andreas Arnez wrote:
> Written in binary, the wrong result above looks like this:
>
> 01111111011111111111111
>
> Which means that two zero bits have sneaked into the copy of the
> original all-one bit pattern. The test uses this simple all-one value
> in order to avoid another GDB bug that causes the DWARF piece of a
> DW_OP_stack_value to be taken from the wrong end on big-endian
> architectures.

Looks like the sort of function that should be possible to
cover all sorts of inputs/outputs with unit tests. Aligned, misaligned,
big/little endian, etc., that sort of thing. That'd help
a lot with ensuring rewrites behave as intended. Would you feel like
including some?

The unit testing framework is trivial to use, since it's baked inside
gdb. All you need to do is write a function that throws some corner case
inputs at copy_bitwise, checking expected outputs and calling SELF_CHECK.
You register that function in the selftests frameworks with "register_self_test".
Then to trigger the tests, just do: gdb -ex "maintenance selftest".
testsuite/gdb.gdb/unittest.exp does that too.

Thanks,
Pedro Alves