From: Julian Seward Date: Fri, 9 Mar 2018 18:03:26 +0000 (+0100) Subject: coregrind/m_debuglog.c: fix incorrect inline assembly for amd64-linux. X-Git-Tag: VALGRIND_3_14_0~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b92194acabdcdc44ce86c748dc6523a7071e369;p=thirdparty%2Fvalgrind.git coregrind/m_debuglog.c: fix incorrect inline assembly for amd64-linux. This adds rcx and r11 to the trash lists for inline assembly in local_sys_write_stderr and local_sys_getpid, since those registers are not preserved across the embedded syscall that takes us into the kernel. I believe this to be the root cause of the apparent code generation bug addressed in 53faacfda4ad6a27bc0e8ab859c1cc5388a61a5e (16 Nov 2017). This commit also undoes that commit, because I think it is no longer necessary. --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 7e8b59f623..5c25e33b57 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -130,7 +130,7 @@ static UInt local_sys_write_stderr ( const HChar* buf, Int n ) "addq $256, %%rsp\n" /* restore stack ptr */ : /*wr*/ : /*rd*/ "r" (block) - : /*trash*/ "rax", "rdi", "rsi", "rdx", "memory", "cc" + : /*trash*/ "rax", "rdi", "rsi", "rdx", "memory", "cc", "rcx", "r11" ); if (block[0] < 0) block[0] = -1; @@ -146,7 +146,8 @@ static UInt local_sys_getpid ( void ) "movl %%eax, %0\n" /* set __res = %eax */ : "=mr" (__res) : - : "rax" ); + : "rax", "rcx", "r11" + ); return __res; } @@ -1203,6 +1204,9 @@ void VG_(debugLog) ( Int level, const HChar* modulename, if (level > loglevel) return; + indent = 2*level - 1; + if (indent < 1) indent = 1; + buf.n = 0; buf.buf[0] = 0; pid = local_sys_getpid(); @@ -1220,8 +1224,6 @@ void VG_(debugLog) ( Int level, const HChar* modulename, (void)myvprintf_int64 ( add_to_buf, &buf, 0, 10, 1, False, (ULong)level ); (void)myvprintf_str ( add_to_buf, &buf, 0, 1, ":", False ); (void)myvprintf_str ( add_to_buf, &buf, 0, 8, modulename, False ); - indent = 2*level - 1; - if (indent < 1) indent = 1; (void)myvprintf_str ( add_to_buf, &buf, 0, indent, "", False ); va_start(vargs,format);