Commit 66a5d3b1 by Frank Ch. Eigler Committed by Frank Ch. Eigler

configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.

2004-09-07  Frank Ch. Eigler  <fche@redhat.com>

	* configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
	* mf-hooks2.c (strerror): Unregister previous string returned by
	previous strerror.
	(getlogin,cuserid,getpwnam,getpwuid,getgrnam,getgrgid): New wrappers.
	(getservent,getservbyname,getservbyport,gai_strerror): Ditto.
	* mf-runtime.h.in: Add redefine_extname pragmas for them all.
	* mf-runtime.c (__mf_describe_object): Clarify object life status.
	* testsuite/libmudflap.c/pass48-frag.c, pass49-frag.c, fail32-frag.c:
	New tests.
	* configure, config.h.in: Regenerated.

From-SVN: r87160
parent ec666d23
2004-09-07 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
* mf-hooks2.c (strerror): Unregister previous string returned by
previous strerror.
(getlogin,cuserid,getpwnam,getpwuid,getgrnam,getgrgid): New wrappers.
(getservent,getservbyname,getservbyport,gai_strerror): Ditto.
* mf-runtime.h.in: Add redefine_extname pragmas for them all.
* mf-runtime.c (__mf_describe_object): Clarify object life status.
* testsuite/libmudflap.c/pass48-frag.c, pass49-frag.c, fail32-frag.c:
New tests.
* configure, config.h.in: Regenerated.
2004-08-03 Dale Johannesen <dalej@apple.com> 2004-08-03 Dale Johannesen <dalej@apple.com>
* mf-runtime.c: Conditionalize POSIX_SOURCE for Darwin. * mf-runtime.c: Conditionalize POSIX_SOURCE for Darwin.
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
/* Define to 1 if you have the <ctype.h> header file. */ /* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H #undef HAVE_CTYPE_H
/* Define to 1 if you have the `cuserid' function. */
#undef HAVE_CUSERID
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #undef HAVE_DLFCN_H
...@@ -27,9 +33,63 @@ ...@@ -27,9 +33,63 @@
/* Define to 1 if you have the `ftello64' function. */ /* Define to 1 if you have the `ftello64' function. */
#undef HAVE_FTELLO64 #undef HAVE_FTELLO64
/* Define to 1 if you have the `gai_strerror' function. */
#undef HAVE_GAI_STRERROR
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the `getgrent' function. */
#undef HAVE_GETGRENT
/* Define to 1 if you have the `getgrgid' function. */
#undef HAVE_GETGRGID
/* Define to 1 if you have the `getgrgid_r' function. */
#undef HAVE_GETGRGID_R
/* Define to 1 if you have the `getgrnam' function. */
#undef HAVE_GETGRNAM
/* Define to 1 if you have the `getgrnam_r' function. */
#undef HAVE_GETGRNAM_R
/* Define to 1 if you have the `getlogin' function. */
#undef HAVE_GETLOGIN
/* Define to 1 if you have the `getlogin_r' function. */
#undef HAVE_GETLOGIN_R
/* Define to 1 if you have the `getpwent' function. */
#undef HAVE_GETPWENT
/* Define to 1 if you have the `getpwnam' function. */
#undef HAVE_GETPWNAM
/* Define to 1 if you have the `getpwnam_r' function. */
#undef HAVE_GETPWNAM_R
/* Define to 1 if you have the `getpwuid' function. */
#undef HAVE_GETPWUID
/* Define to 1 if you have the `getpwuid_r' function. */
#undef HAVE_GETPWUID_R
/* Define to 1 if you have the `getservbyname' function. */
#undef HAVE_GETSERVBYNAME
/* Define to 1 if you have the `getservbyport' function. */
#undef HAVE_GETSERVBYPORT
/* Define to 1 if you have the `getservent' function. */
#undef HAVE_GETSERVENT
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY #undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <grp.h> header file. */
#undef HAVE_GRP_H
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
...@@ -51,6 +111,9 @@ ...@@ -51,6 +111,9 @@
/* define if you have <pthread.h> */ /* define if you have <pthread.h> */
#undef HAVE_PTHREAD_H #undef HAVE_PTHREAD_H
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
/* Define to 1 if you have the `sethostname' function. */ /* Define to 1 if you have the `sethostname' function. */
#undef HAVE_SETHOSTNAME #undef HAVE_SETHOSTNAME
......
...@@ -59,7 +59,7 @@ AC_TRY_COMPILE([ ...@@ -59,7 +59,7 @@ AC_TRY_COMPILE([
[AC_MSG_RESULT(no) [AC_MSG_RESULT(no)
enable_shared=no]) enable_shared=no])
AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h dirent.h \ AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h dirent.h pwd.h grp.h \
netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h ctype.h) netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h ctype.h)
AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal) AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
...@@ -72,6 +72,11 @@ AC_CHECK_FUNCS(strnlen memrchr strncpy memmem sethostname) ...@@ -72,6 +72,11 @@ AC_CHECK_FUNCS(strnlen memrchr strncpy memmem sethostname)
dnl Check for glibc ctype functions dnl Check for glibc ctype functions
AC_CHECK_FUNCS(__ctype_b_loc __ctype_tolower_loc __ctype_toupper_loc) AC_CHECK_FUNCS(__ctype_b_loc __ctype_tolower_loc __ctype_toupper_loc)
dnl Check for pwd.h / grp.h family of functions
AC_CHECK_FUNCS(getlogin cuserid getpwnam getpwuid getpwent getgrnam getgrgid getgrent)
AC_CHECK_FUNCS(getlogin_r getpwnam_r getpwuid_r getgrnam_r getgrgid_r)
AC_CHECK_FUNCS(getservent getservbyname getservbyport getaddrinfo gai_strerror)
AC_TRY_COMPILE([#include <sys/types.h> AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0]) #include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
......
...@@ -84,7 +84,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -84,7 +84,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifdef HAVE_SYS_SHM_H #ifdef HAVE_SYS_SHM_H
#include <sys/shm.h> #include <sys/shm.h>
#endif #endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#include "mf-runtime.h" #include "mf-runtime.h"
#include "mf-impl.h" #include "mf-impl.h"
...@@ -524,7 +529,6 @@ WRAPPER2(struct tm*, gmtime, const time_t *timep) ...@@ -524,7 +529,6 @@ WRAPPER2(struct tm*, gmtime, const time_t *timep)
/* The following indicate if the result of the corresponding function /* The following indicate if the result of the corresponding function
* should be explicitly un/registered by the wrapper * should be explicitly un/registered by the wrapper
*/ */
#define MF_REGISTER_strerror __MF_TYPE_STATIC
#undef MF_REGISTER_fopen #undef MF_REGISTER_fopen
#define MF_RESULT_SIZE_fopen (sizeof (FILE)) #define MF_RESULT_SIZE_fopen (sizeof (FILE))
#undef MF_REGISTER_opendir #undef MF_REGISTER_opendir
...@@ -552,17 +556,15 @@ WRAPPER2(time_t, time, time_t *timep) ...@@ -552,17 +556,15 @@ WRAPPER2(time_t, time, time_t *timep)
WRAPPER2(char *, strerror, int errnum) WRAPPER2(char *, strerror, int errnum)
{ {
char *p; char *p;
size_t n; static char * last_strerror = NULL;
TRACE ("%s\n", __PRETTY_FUNCTION__); TRACE ("%s\n", __PRETTY_FUNCTION__);
p = strerror (errnum); p = strerror (errnum);
if (NULL != p) { if (last_strerror != NULL)
n = strlen (p); __mf_unregister (last_strerror, 0, __MF_TYPE_STATIC);
n = CLAMPADD(n, 1); if (NULL != p)
#ifdef MF_REGISTER_strerror __mf_register (p, strlen (p) + 1, __MF_TYPE_STATIC, "strerror result");
__mf_register (p, n, MF_REGISTER_strerror, "strerror result"); last_strerror = p;
#endif
MF_VALIDATE_EXTENT (p, n, __MF_CHECK_WRITE, "strerror result");
}
return p; return p;
} }
...@@ -1722,3 +1724,150 @@ WRAPPER2(int **, __ctype_tolower_loc, void) ...@@ -1722,3 +1724,150 @@ WRAPPER2(int **, __ctype_tolower_loc, void)
return ptr; return ptr;
} }
#endif #endif
/* passwd/group related functions. These register every (static) pointer value returned,
and rely on libmudflap's quiet toleration of duplicate static registrations. */
#ifdef HAVE_GETLOGIN
WRAPPER2(char *, getlogin, void)
{
char *buf = getlogin ();
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getlogin() return");
return buf;
}
#endif
#ifdef HAVE_CUSERID
WRAPPER2(char *, cuserid, char * buf)
{
if (buf != NULL)
{
MF_VALIDATE_EXTENT(buf, L_cuserid, __MF_CHECK_WRITE,
"cuserid destination");
return cuserid (buf);
}
buf = cuserid (NULL);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getcuserid() return");
return buf;
}
#endif
#ifdef HAVE_GETPWNAM
WRAPPER2(struct passwd *, getpwnam, const char *name)
{
struct passwd *buf;
MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
"getpwnam name");
buf = getpwnam (name);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getpw*() return");
return buf;
}
#endif
#ifdef HAVE_GETPWUID
WRAPPER2(struct passwd *, getpwuid, uid_t uid)
{
struct passwd *buf;
buf = getpwuid (uid);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getpw*() return");
return buf;
}
#endif
#ifdef HAVE_GETGRNAM
WRAPPER2(struct group *, getgrnam, const char *name)
{
struct group *buf;
MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
"getgrnam name");
buf = getgrnam (name);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getgr*() return");
return buf;
}
#endif
#ifdef HAVE_GETGRGID
WRAPPER2(struct group *, getgrgid, uid_t uid)
{
struct group *buf;
buf = getgrgid (uid);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getgr*() return");
return buf;
}
#endif
#ifdef HAVE_GETSERVENT
WRAPPER2(struct servent *, getservent, void)
{
struct servent *buf;
buf = getservent ();
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getserv*() return");
return buf;
}
#endif
#ifdef HAVE_GETSERVBYNAME
WRAPPER2(struct servent *, getservbyname, const char *name, const char *proto)
{
struct servent *buf;
MF_VALIDATE_EXTENT(name, strlen(name)+1, __MF_CHECK_READ,
"getservbyname name");
MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
"getservbyname proto");
buf = getservbyname (name, proto);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getserv*() return");
return buf;
}
#endif
#ifdef HAVE_GETSERVBYPORT
WRAPPER2(struct servent *, getservbyport, int port, const char *proto)
{
struct servent *buf;
MF_VALIDATE_EXTENT(proto, strlen(proto)+1, __MF_CHECK_READ,
"getservbyport proto");
buf = getservbyport (port, proto);
if (buf != NULL)
__mf_register (buf, sizeof(*buf), __MF_TYPE_STATIC,
"getserv*() return");
return buf;
}
#endif
#ifdef HAVE_GAI_STRERROR
WRAPPER2(const char *, gai_strerror, int errcode)
{
const char *buf;
buf = gai_strerror (errcode);
if (buf != NULL)
__mf_register ((void *) buf, strlen(buf)+1, __MF_TYPE_STATIC,
"gai_strerror() return");
return buf;
}
#endif
...@@ -1614,7 +1614,8 @@ __mf_describe_object (__mf_object_t *obj) ...@@ -1614,7 +1614,8 @@ __mf_describe_object (__mf_object_t *obj)
if (__mf_opts.abbreviate && obj->description_epoch == epoch) if (__mf_opts.abbreviate && obj->description_epoch == epoch)
{ {
fprintf (stderr, fprintf (stderr,
"mudflap object %p: name=`%s'\n", "mudflap %sobject %p: name=`%s'\n",
(obj->deallocated_p ? "dead " : ""),
(void *) obj, (obj->name ? obj->name : "")); (void *) obj, (obj->name ? obj->name : ""));
return; return;
} }
...@@ -1622,13 +1623,14 @@ __mf_describe_object (__mf_object_t *obj) ...@@ -1622,13 +1623,14 @@ __mf_describe_object (__mf_object_t *obj)
obj->description_epoch = epoch; obj->description_epoch = epoch;
fprintf (stderr, fprintf (stderr,
"mudflap object %p: name=`%s'\n" "mudflap %sobject %p: name=`%s'\n"
"bounds=[%p,%p] size=%lu area=%s check=%ur/%uw liveness=%u%s\n" "bounds=[%p,%p] size=%lu area=%s check=%ur/%uw liveness=%u%s\n"
"alloc time=%lu.%06lu pc=%p" "alloc time=%lu.%06lu pc=%p"
#ifdef LIBMUDFLAPTH #ifdef LIBMUDFLAPTH
" thread=%u" " thread=%u"
#endif #endif
"\n", "\n",
(obj->deallocated_p ? "dead " : ""),
(void *) obj, (obj->name ? obj->name : ""), (void *) obj, (obj->name ? obj->name : ""),
(void *) obj->low, (void *) obj->high, (void *) obj->low, (void *) obj->high,
(unsigned long) (obj->high - obj->low + 1), (unsigned long) (obj->high - obj->low + 1),
......
...@@ -187,6 +187,16 @@ extern int __mf_set_options (const char *opts); ...@@ -187,6 +187,16 @@ extern int __mf_set_options (const char *opts);
#pragma redefine_extname __ctype_b_loc __mfwrap___ctype_b_loc #pragma redefine_extname __ctype_b_loc __mfwrap___ctype_b_loc
#pragma redefine_extname __ctype_toupper_loc __mfwrap___ctype_toupper_loc #pragma redefine_extname __ctype_toupper_loc __mfwrap___ctype_toupper_loc
#pragma redefine_extname __ctype_tolower_loc __mfwrap___ctype_tolower_loc #pragma redefine_extname __ctype_tolower_loc __mfwrap___ctype_tolower_loc
#pragma redefine_extname getlogin __mfwrap_getlogin
#pragma redefine_extname cuserid __mfwrap_cuserid
#pragma redefine_extname getpwnam __mfwrap_getpwnam
#pragma redefine_extname getpwuid __mfwrap_getpwuid
#pragma redefine_extname getgrnam __mfwrap_getgrnam
#pragma redefine_extname getgrgid __mfwrap_getgrgid
#pragma redefine_extname getservent __mfwrap_getservent
#pragma redefine_extname getservbyname __mfwrap_getservbyname
#pragma redefine_extname getservbyport __mfwrap_getservbyport
#pragma redefine_extname gai_strerror __mfwrap_gai_strerror
/* Disable glibc macros. */ /* Disable glibc macros. */
#define __NO_STRING_INLINES #define __NO_STRING_INLINES
......
void foo (int k)
{
volatile int *b = & k;
b++;
*b = 5;
}
int main ()
{
foo (5);
return 0;
}
/* { dg-output "mudflap violation 1.*" } */
/* { dg-output "Nearby object.*" } */
/* { dg-output "mudflap object.*k" } */
/* { dg-do run { xfail *-*-* } } */
void foo (int k)
{
volatile int *b = & k;
*b = 5;
}
int main ()
{
foo (5);
return 0;
}
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
int foo (int a, ...)
{
va_list args;
char *a1;
int a2;
int k;
va_start (args, a);
for (k = 0; k < a; k++)
{
if ((k % 2) == 0)
{
char *b = va_arg (args, char *);
printf ("%s", b);
}
else
{
int b = va_arg (args, int);
printf ("%d", b);
}
}
va_end (args);
return a;
}
int main ()
{
foo (7, "hello ", 5, " ", 3, " world ", 9, "\n");
return 0;
}
/* { dg-output "hello 5 3 world 9" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment