]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Remove function sr_ResHI from Linux specific code.
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 20 Apr 2015 20:42:42 +0000 (20:42 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 20 Apr 2015 20:42:42 +0000 (20:42 +0000)
Add function VG_(sr_as_string).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15116

coregrind/m_libcprint.c
coregrind/m_syswrap/priv_types_n_macros.h
coregrind/m_syswrap/syswrap-main.c
include/pub_tool_basics.h
include/pub_tool_libcprint.h

index fbd3d4c4b8f77e8b5d811ea453b7a9dc106b3f43..b6efaada53d3504e60b6a63604bf9216c26c4697 100644 (file)
@@ -643,6 +643,44 @@ void VG_(err_config_error) ( const HChar* format, ... )
    VG_(exit)(1);
 }
 
+/* ---------------------------------------------------------------------
+   VG_(sr_as_string)()
+   ------------------------------------------------------------------ */
+
+/* Return a textual representation of a SysRes value in a statically
+   allocated buffer. The buffer will be overwritten with the next 
+   invocation. */
+#if defined(VGO_linux)
+// FIXME: Does this function need to be adjusted for MIPS's _valEx ?
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+   static HChar buf[7+1+2+16+1+1];   // large enough
+
+   if (sr_isError(sr))
+      VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+   else
+      VG_(sprintf)(buf, "Success(0x%lx)", sr_Res(sr));
+   return buf;
+}
+
+#elif defined(VGO_darwin)
+
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+   static HChar buf[7+1+2+16+1+2+16+1+1];   // large enough
+
+   if (sr_isError(sr))
+      VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+   else
+      VG_(sprintf)(buf, "Success(0x%lx:0x%lx)", sr_ResHI(sr), sr_Res(sr));
+   return buf;
+}
+
+#else
+
+#error unknown OS
+
+#endif
 
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
index 14f17802edfe3d1500cf3c29c6702e6c1708f246..26a82f7abd2f8a329c7e0779f0b344ba87cbb2a3 100644 (file)
@@ -331,11 +331,13 @@ static inline UWord getRES ( SyscallStatus* st ) {
    return sr_Res(st->sres);
 }
 
+#if defined(VGO_darwin)
 static inline UWord getRESHI ( SyscallStatus* st ) {
    vg_assert(st->what == SsComplete);
    vg_assert(!sr_isError(st->sres));
    return sr_ResHI(st->sres);
 }
+#endif
 
 static inline UWord getERR ( SyscallStatus* st ) {
    vg_assert(st->what == SsComplete);
index a7127ea3a514aed1446f030745d1dbdac9bac53b..c5aac59b4d93c7dda1019b6ec42e05fb9925e084 100644 (file)
@@ -1669,9 +1669,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc )
       if (sci->flags & SfNoWriteResult) {
          PRINT(" --> [pre-success] NoWriteResult");
       } else {
-         PRINT(" --> [pre-success] Success(0x%llx:0x%llx)",
-               (ULong)sr_ResHI(sci->status.sres),
-               (ULong)sr_Res(sci->status.sres));
+         PRINT(" --> [pre-success] %s", VG_(sr_as_string)(sci->status.sres));
       }                                      
       /* In this case the allowable flags are to ask for a signal-poll
          and/or a yield after the call.  Changing the args isn't
@@ -1684,7 +1682,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc )
    else
    if (sci->status.what == SsComplete && sr_isError(sci->status.sres)) {
       /* The pre-handler decided to fail syscall itself. */
-      PRINT(" --> [pre-fail] Failure(0x%llx)", (ULong)sr_Err(sci->status.sres));
+      PRINT(" --> [pre-fail] %s", VG_(sr_as_string)(sci->status.sres));
       /* In this case, the pre-handler is also allowed to ask for the
          post-handler to be run anyway.  Changing the args is not
          allowed. */
@@ -1769,18 +1767,9 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc )
 
          /* Be decorative, if required. */
          if (VG_(clo_trace_syscalls)) {
-            Bool failed = sr_isError(sci->status.sres);
-            if (failed) {
-               PRINT("SYSCALL[%d,%d](%s) ... [async] --> Failure(0x%llx)",
-                     VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
-                     (ULong)sr_Err(sci->status.sres));
-            } else {
-               PRINT("SYSCALL[%d,%d](%s) ... [async] --> "
-                     "Success(0x%llx:0x%llx)",
-                     VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
-                     (ULong)sr_ResHI(sci->status.sres),
-                     (ULong)sr_Res(sci->status.sres) );
-            }
+            PRINT("SYSCALL[%d,%d](%s) ... [async] --> %s",
+                  VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
+                  VG_(sr_as_string)(sci->status.sres));
          }
 
       } else {
@@ -1800,15 +1789,7 @@ void VG_(client_syscall) ( ThreadId tid, UInt trc )
 
          /* Be decorative, if required. */
          if (VG_(clo_trace_syscalls)) {
-            Bool failed = sr_isError(sci->status.sres);
-            if (failed) {
-               PRINT("[sync] --> Failure(0x%llx)",
-                     (ULong)sr_Err(sci->status.sres) );
-            } else {
-               PRINT("[sync] --> Success(0x%llx:0x%llx)",
-                     (ULong)sr_ResHI(sci->status.sres),
-                     (ULong)sr_Res(sci->status.sres) );
-            }
+           PRINT("[sync] --> %s", VG_(sr_as_string)(sci->status.sres));
          }
       }
    }
index 949459e0f28a39046373c0493f4d3aa5f4996aab..80d64999ad3f0a7041d52e98ea19dec8b4e56052 100644 (file)
@@ -192,9 +192,6 @@ static inline UWord sr_Res ( SysRes sr ) {
 static inline UWord sr_ResEx ( SysRes sr ) {
    return sr._isError ? 0 : sr._valEx;
 }
-static inline UWord sr_ResHI ( SysRes sr ) {
-   return 0;
-}
 static inline UWord sr_Err ( SysRes sr ) {
    return sr._isError ? sr._val : 0;
 }
index adfedb60f5fc8a889a3933efe3f0e2e5e97b746e..60e47531cb4519432443d2ac049130fb7787ab6e 100644 (file)
@@ -154,6 +154,9 @@ extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
 /* Flush any output cached by previous calls to VG_(message) et al. */
 extern void VG_(message_flush) ( void );
 
+/* Return a SysRes value as a character string. */
+extern const HChar *VG_(sr_as_string) ( SysRes sr );
+
 #endif   // __PUB_TOOL_LIBCPRINT_H
 
 /*--------------------------------------------------------------------*/