]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
coregrind/m_debuglog.c: fix incorrect inline assembly for amd64-linux.
authorJulian Seward <jseward@acm.org>
Fri, 9 Mar 2018 18:03:26 +0000 (19:03 +0100)
committerJulian Seward <jseward@acm.org>
Fri, 9 Mar 2018 18:03:26 +0000 (19:03 +0100)
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.

coregrind/m_debuglog.c

index 7e8b59f623a6374a643ccfbe5bb888611b5f28ce..5c25e33b571f42e51bc5f4a05536ead536fabed1 100644 (file)
@@ -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);