c++ - C function to exercise as many registers as possible -


i'm writing test suite assembler stub on multiple cpu architectures. stub meant pass arguments c callback.

i have written tests cover multiple scenarios (eg passing struct value, mixing arguments of different native size, mixing float args ints etc) , test callback something use lots of registers/stack slots etc.

the idea try , flush out implementations working fluke (eg value not correctly put on stack, happens still in register away etc).

can recommend piece of c/c++ can use test here? realise register use varies wildly across architectures , there's no guarantee @ complete coverage, nice have gave reasonable amount of confidence. thanks

there nothing in c/c++ standards here. reliable way way compiler writers it. study code compiler generates , think ways break it.

having said that, can think of strategies might flush out common problems.

  1. make calls lots of different combinations of argument types , numbers. example, function single argument or return value char/short/int/long/float/double/pointer etc exercise range of compiler code generation (and passed in register if possible). same function lots of arguments use different strategy, , (in cases) not have enough registers.
  2. insert preamble code called function, passed in arguments not used registers filled other values.
  3. use variadic arguments. calling conventions variadic arguments (especially separate compile , link) virtually guarantee arguments on stack , not in registers.
  4. exercise lots of different call types: not simple scalars struct value, pointer function, pointer member, etc.
  5. cheat. call 1 prototype cast function pointer callee has different prototype. example, call double on stack callee function has 2 longs. requires inside knowledge of compiler workings.

the pre-written code find stuff compiler compliance suite chosen compiler.

breaking compilers fun. here it.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -