From 3d25b440fe3ce53eec79bd0ea292ce0c4b35aff9 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 10 Jul 2007 00:18:46 +0000 Subject: [PATCH] All platforms: make it clearer that missing syscalls constitute reportable bugs. AIX only: print name of missing syscall as well as number -- important because there is no fixed name/number binding. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6765 --- coregrind/m_syswrap/syswrap-main.c | 9 ++++++ coregrind/m_vkiscnums.c | 50 ++++++++++++++++++++++++------ coregrind/pub_core_vkiscnums.h | 3 ++ 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 21f3a35c53..9e8a92ee7f 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -682,6 +682,11 @@ void bad_before ( ThreadId tid, { VG_(message) (Vg_DebugMsg,"WARNING: unhandled syscall: %llu", (ULong)args->sysno); +# if defined(VGO_aix5) + VG_(message) + (Vg_DebugMsg," name of syscall: \"%s\"", + VG_(aix5_sysno_to_sysname)(args->sysno)); +# endif if (VG_(clo_verbosity) > 1) { VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size)); } @@ -689,6 +694,10 @@ void bad_before ( ThreadId tid, (Vg_DebugMsg,"You may be able to write your own handler."); VG_(message) (Vg_DebugMsg,"Read the file README_MISSING_SYSCALL_OR_IOCTL."); + VG_(message) + (Vg_DebugMsg,"Nevertheless we consider this a bug. Please report"); + VG_(message) + (Vg_DebugMsg,"it at http://valgrind.org/support/bug_reports.html."); SET_STATUS_Failure(VKI_ENOSYS); } diff --git a/coregrind/m_vkiscnums.c b/coregrind/m_vkiscnums.c index 40ae70cd4e..ca83319ea7 100644 --- a/coregrind/m_vkiscnums.c +++ b/coregrind/m_vkiscnums.c @@ -563,17 +563,28 @@ Int VG_(aix5_NR_kunload64) = __NR_AIX5_UNKNOWN; Int VG_(aix5_NR_FAKE_SIGRETURN) = __NR_AIX5_UNKNOWN; -static Bool local_streq ( UChar* s1, UChar* s2 ) -{ - while (True) { - if (*s1 == 0 && *s2 == 0) return True; - if (*s1 == 0) return False; - if (*s2 == 0) return False; - if (*s1 != *s2) return False; - s1++; s2++; - } + +/* Also make a record of the registered syscalls, so we can print the + name in bad_before() (syswrap-main.c) if needed. The obvious + approach would be to dump them in an XArray, but that requires + dynamic memory allocation, and syscall registration is done before + dynamic memory allocation is available. So just use a fixed size + array and hope it doesn't fill up. */ +#define N_BINDINGS 2000 +static Int bindings_used = 0; +static Int bindings_sysno[N_BINDINGS]; +static UChar* bindings_sysname[N_BINDINGS]; + +UChar* VG_(aix5_sysno_to_sysname)( Int sysno ) { + Int i; + for (i = 0; i < bindings_used; i++) + if (bindings_sysno[i] == sysno) + return bindings_sysname[i]; + return "(unknown name)"; } +static Bool local_streq ( UChar* s1, UChar* s2 ); /* fwds */ + Bool VG_(aix5_register_syscall)( Int sysno, UChar* sysname ) { /* Establish the FAKE_SIGRETURN number. */ @@ -581,7 +592,14 @@ Bool VG_(aix5_register_syscall)( Int sysno, UChar* sysname ) VG_(aix5_NR_FAKE_SIGRETURN) = sysno + 10000; else if (sysno + 10000 > VG_(aix5_NR_FAKE_SIGRETURN)) - VG_(aix5_NR_FAKE_SIGRETURN) = sysno + 10000; + VG_(aix5_NR_FAKE_SIGRETURN) = sysno + 10000; + + /* Note the name, just in case bad_before() needs to complain. */ + if (bindings_used < N_BINDINGS) { + bindings_sysno[bindings_used] = sysno; + bindings_sysname[bindings_used] = sysname; + bindings_used++; + } /* Now do the normal name-to-number binding checks. */ # define XXX(name) \ @@ -1092,6 +1110,18 @@ Bool VG_(aix5_register_syscall)( Int sysno, UChar* sysname ) return False; } + +static Bool local_streq ( UChar* s1, UChar* s2 ) +{ + while (True) { + if (*s1 == 0 && *s2 == 0) return True; + if (*s1 == 0) return False; + if (*s2 == 0) return False; + if (*s1 != *s2) return False; + s1++; s2++; + } +} + #endif /* defined(VGO_aix5) */ /*--------------------------------------------------------------------*/ diff --git a/coregrind/pub_core_vkiscnums.h b/coregrind/pub_core_vkiscnums.h index 29ace099c1..1b3a61581d 100644 --- a/coregrind/pub_core_vkiscnums.h +++ b/coregrind/pub_core_vkiscnums.h @@ -51,6 +51,9 @@ /* Bind the given syscall name to the given number. Returns True if successful, False if the name is unknown. */ extern Bool VG_(aix5_register_syscall)( Int, UChar* ); +/* Look up in said binding later, for the purposes of making error + messages. */ +extern UChar* VG_(aix5_sysno_to_sysname)( Int sysno ); #endif #endif /* !defined(VG_IN_ASSEMBLY_SOURCE) */ -- 2.47.2