|
From: <sv...@va...> - 2012-01-30 15:12:01
|
Author: bart
Date: 2012-01-30 15:07:20 +0000 (Mon, 30 Jan 2012)
New Revision: 12360
Log:
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.
Modified:
trunk/coregrind/m_debuglog.c
Modified: trunk/coregrind/m_debuglog.c
===================================================================
--- trunk/coregrind/m_debuglog.c 2012-01-29 02:23:07 UTC (rev 12359)
+++ trunk/coregrind/m_debuglog.c 2012-01-30 15:07:20 UTC (rev 12360)
@@ -73,28 +73,18 @@
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 )
|