From: Bart Van Assche Date: Mon, 30 Jan 2012 15:07:20 +0000 (+0000) Subject: Make -d (enable debug logging) work on Fedora 16 / x86. X-Git-Tag: svn/VALGRIND_3_8_0~493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c474ee2210e2a6939cbfe95b079cdbf8550315c;p=thirdparty%2Fvalgrind.git Make -d (enable debug logging) work on Fedora 16 / x86. Apparently the 32-bit Fedora 16 compiler chooses register esp to pass "&block" to the inline assembly code in local_sys_write_stderr(). First pushing data on the stack and next reading the contents of %0 doesn't yield the desired result if %0 == %esp. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12360 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index ab580ed8f6..44f7376f7a 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -73,28 +73,18 @@ void VG_(debugLog_setXml)(Bool xml) static UInt local_sys_write_stderr ( HChar* buf, Int n ) { - volatile Int block[2]; - block[0] = (Int)buf; - block[1] = n; + Int result; + __asm__ volatile ( - "pushl %%ebx\n" /* ebx is callee-save */ - "movl %0, %%ebx\n" /* ebx = &block */ - "pushl %%ebx\n" /* save &block */ - "movl 0(%%ebx), %%ecx\n" /* %ecx = buf */ - "movl 4(%%ebx), %%edx\n" /* %edx = n */ "movl $"VG_STRINGIFY(__NR_write)", %%eax\n" /* %eax = __NR_write */ "movl $2, %%ebx\n" /* %ebx = stderr */ "int $0x80\n" /* write(stderr, buf, n) */ - "popl %%ebx\n" /* reestablish &block */ - "movl %%eax, 0(%%ebx)\n" /* block[0] = result */ - "popl %%ebx\n" /* restore ebx */ - : /*wr*/ - : /*rd*/ "r" (block) - : /*trash*/ "eax", "edi", "ecx", "edx", "memory", "cc" + : /*wr*/ "=a" (result) + : /*rd*/ "c" (buf), "d" (n) + : /*trash*/ "ebx", "edi", "memory", "cc" ); - if (block[0] < 0) - block[0] = -1; - return block[0]; + + return result >= 0 ? result : -1; } static UInt local_sys_getpid ( void )