Beef up VG_(strerror) to provide correct messages for the

errno codes in asm-generic/errno-base.h (on linux). 
The error strings were obtained by calling strerror natively in
Linux. 
Extend vki-linux.h accordingly. vki-darwin.h already had
those errno codes.
Add testcase. This fixes #287858.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12316
This commit is contained in:
Florian Krohm 2011-12-24 21:50:53 +00:00
parent c953f410c8
commit b8466723cd
6 changed files with 68 additions and 21 deletions

2
NEWS
View File

@ -28,7 +28,7 @@ where XXXXXX is the bug number as listed below.
283413 Fix wrong sanity check
286270 vgpreload is not friendly to 64->32 bit execs, gives ld.so warnings
286374 Running cachegrind with --branch-sim=yes on 64-bit PowerPC program fails
287858 VG_(strerror): unknown error
Release 3.7.0 (5 November 2011)

View File

@ -695,28 +695,51 @@ SysRes VG_(do_syscall) ( UWord sysno, UWord a1, UWord a2, UWord a3,
const HChar* VG_(strerror) ( UWord errnum )
{
switch (errnum) {
case VKI_EPERM: return "Operation not permitted";
case VKI_ENOENT: return "No such file or directory";
case VKI_ESRCH: return "No such process";
case VKI_EINTR: return "Interrupted system call";
case VKI_EBADF: return "Bad file number";
case VKI_EAGAIN: return "Try again";
case VKI_ENOMEM: return "Out of memory";
case VKI_EACCES: return "Permission denied";
case VKI_EFAULT: return "Bad address";
case VKI_EEXIST: return "File exists";
case VKI_EINVAL: return "Invalid argument";
case VKI_EMFILE: return "Too many open files";
case VKI_ENOSYS: return "Function not implemented";
case VKI_EOVERFLOW: return "Value too large for defined data type";
case VKI_EPERM: return "Operation not permitted";
case VKI_ENOENT: return "No such file or directory";
case VKI_ESRCH: return "No such process";
case VKI_EINTR: return "Interrupted system call";
case VKI_EIO: return "Input/output error";
case VKI_ENXIO: return "No such device or address";
case VKI_E2BIG: return "Argument list too long";
case VKI_ENOEXEC: return "Exec format error";
case VKI_EBADF: return "Bad file descriptor";
case VKI_ECHILD: return "No child processes";
case VKI_EAGAIN: return "Resource temporarily unavailable";
case VKI_ENOMEM: return "Cannot allocate memory";
case VKI_EACCES: return "Permission denied";
case VKI_EFAULT: return "Bad address";
case VKI_ENOTBLK: return "Block device required";
case VKI_EBUSY: return "Device or resource busy";
case VKI_EEXIST: return "File exists";
case VKI_EXDEV: return "Invalid cross-device link";
case VKI_ENODEV: return "No such device";
case VKI_ENOTDIR: return "Not a directory";
case VKI_EISDIR: return "Is a directory";
case VKI_EINVAL: return "Invalid argument";
case VKI_ENFILE: return "Too many open files in system";
case VKI_EMFILE: return "Too many open files";
case VKI_ENOTTY: return "Inappropriate ioctl for device";
case VKI_ETXTBSY: return "Text file busy";
case VKI_EFBIG: return "File too large";
case VKI_ENOSPC: return "No space left on device";
case VKI_ESPIPE: return "Illegal seek";
case VKI_EROFS: return "Read-only file system";
case VKI_EMLINK: return "Too many links";
case VKI_EPIPE: return "Broken pipe";
case VKI_EDOM: return "Numerical argument out of domain";
case VKI_ERANGE: return "Numerical result out of range";
case VKI_ENOSYS: return "Function not implemented";
case VKI_EOVERFLOW: return "Value too large for defined data type";
# if defined(VKI_ERESTARTSYS)
case VKI_ERESTARTSYS: return "ERESTARTSYS";
# endif
default: return "VG_(strerror): unknown error";
default: return "VG_(strerror): unknown error";
}
}
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -1158,22 +1158,43 @@ struct vki_seminfo {
#define VKI_ENOENT 2 /* No such file or directory */
#define VKI_ESRCH 3 /* No such process */
#define VKI_EINTR 4 /* Interrupted system call */
#define VKI_ENOEXEC 8 /* Exec format error */
#define VKI_EIO 5 /* I/O error */
#define VKI_ENXIO 6 /* No such device or address */
#define VKI_E2BIG 7 /* Argument list too long */
#define VKI_ENOEXEC 8 /* Exec format error */
#define VKI_EBADF 9 /* Bad file number */
#define VKI_ECHILD 10 /* No child processes */
#define VKI_EAGAIN 11 /* Try again */
#define VKI_EWOULDBLOCK VKI_EAGAIN
#define VKI_ECHILD 10 /* No child processes */
#define VKI_EAGAIN 11 /* Try again */
#define VKI_ENOMEM 12 /* Out of memory */
#define VKI_EACCES 13 /* Permission denied */
#define VKI_EFAULT 14 /* Bad address */
#define VKI_ENOTBLK 15 /* Block device required */
#define VKI_EBUSY 16 /* Device or resource busy */
#define VKI_EEXIST 17 /* File exists */
#define VKI_EXDEV 18 /* Cross-device link */
#define VKI_ENODEV 19 /* No such device */
#define VKI_ENOTDIR 20 /* Not a directory */
#define VKI_EISDIR 21 /* Is a directory */
#define VKI_EINVAL 22 /* Invalid argument */
#define VKI_ENFILE 23 /* File table overflow */
#define VKI_EMFILE 24 /* Too many open files */
#define VKI_ENOTTY 25 /* Not a typewriter */
#define VKI_ETXTBSY 26 /* Text file busy */
#define VKI_EFBIG 27 /* File too large */
#define VKI_ENOSPC 28 /* No space left on device */
#define VKI_ESPIPE 29 /* Illegal seek */
#define VKI_EROFS 30 /* Read-only file system */
#define VKI_EMLINK 31 /* Too many links */
#define VKI_EPIPE 32 /* Broken pipe */
#define VKI_EDOM 33 /* Math argument out of domain of func */
#define VKI_ERANGE 34 /* Math result not representable */
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/asm-generic/errno.h
//----------------------------------------------------------------------
#define VKI_EWOULDBLOCK VKI_EAGAIN
#define VKI_ENOSYS 38 /* Function not implemented */
#define VKI_EOVERFLOW 75 /* Value too large for defined data type */

View File

@ -99,6 +99,7 @@ EXTRA_DIST = \
mq.stderr.exp mq.vgtest \
munmap_exe.stderr.exp munmap_exe.vgtest \
nestedfns.stderr.exp nestedfns.stdout.exp nestedfns.vgtest \
nodir.stderr.exp nodir.vgtest \
pending.stdout.exp pending.stderr.exp pending.vgtest \
procfs-linux.stderr.exp-with-readlinkat \
procfs-linux.stderr.exp-without-readlinkat \

View File

@ -0,0 +1 @@
valgrind: ./nodir.vgtest/foobar: Not a directory

1
none/tests/nodir.vgtest Normal file
View File

@ -0,0 +1 @@
prog: nodir.vgtest/foobar