|
From: DUPUIS E. <e.d...@at...> - 2014-08-08 14:40:13
|
Greetings, Please find included a tiny patch to add a new client request to the Valgrind API. This new client requests returns the Valgrind version running the client software. Why this patch ? Our software performs cpu capability detection using CPUID to be able to use AVX or AVX2 instructions. However, as expected, older versions of Valgrind does not handle these instructions and in that case Valgrind halts. In order to facilitate the use of Valgrind for all developpers, I had code like if (RUNNING_ON_VALGRIND) isAvxSupported = false; Since newer versions of Valgrind do implement AVX instructions, I would like to modify my code to something like if (RUNNING_ON_VALGRIND && !VALGRIND_IMPLEMENTS_AVX) isAvxSupported = false; The easiest way I found to check if Valgrind implements AVX or not is to check Valgrind's version number (AVX supports stats with Valgrind 3.8, AVX2 with Valgrind 3.9). Although valgrind.h defines macros holding the version number, I would like to have the runtime value of the version number, as the software is not necessarily run in the same environment as the one it was compiled on. Spanning a system call to run 'valgrind --version' seems a clumsy solution. Hence I added client request VALGRIND_RUNNING_VERSION which returns the version of the currently running Valgrind. It returns for example 0x00000308 for Valgrind 3.8. It returns 0 if Valgrind is not running or on Valgrind versions not implementing the client request. I thought it was the easiest solution. With this patch, my code would be if (RUNNING_ON_VALGRIND && (VALGRIND_RUNNING_VERSION < 0x0000308)) isAvsSupported = false; Please feel free to reject or amend this patch. I have tested it. I have also included a modification of an XML file which I assume is used to built the documentation; however I am not sure it is the only documentation file that needs modification. Regards, Etienne Dupuis P.S. Note also that I downloaded sources for valgrind 3.9.0 and in that source tree, in valgrind.h, __VALGRIND_MAJOR__ was set to 3 and __VALGRIND_MINOR__ was incorrectly set to 8 instead of 9. My patch assumes that these macros are set to the correct version number ! This message and any attachments are confidential and intended solely for the addressees. Any unauthorized modification, edition, use or dissemination is prohibited. If you have received this message by mistake, please notify us immediately. ATEME decline all responsibility for this message if it has been altered, deformed, falsified or even edited or disseminated without authorization. |