diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-15 10:47:50 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-07-15 10:47:50 -0300 |
commit | 649390ac814ce5ea1e77b833ab5fe92dfcfe86d5 (patch) | |
tree | ac8b15ac65b08a492c256369b73e372f6568c7a4 /dbug | |
parent | 06b8897e8e9a27b6ffc562af90153ab63f30e63e (diff) | |
parent | 8df20918d6751dc1eeb47ab722269dbd9d2da297 (diff) | |
download | mariadb-git-649390ac814ce5ea1e77b833ab5fe92dfcfe86d5.tar.gz |
Merge of mysql-trunk-bugfixing into mysql-trunk-merge.
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/CMakeLists.txt | 2 | ||||
-rw-r--r-- | dbug/Makefile.am | 2 | ||||
-rw-r--r-- | dbug/dbug.c | 110 | ||||
-rw-r--r-- | dbug/dbug_analyze.c | 118 | ||||
-rw-r--r-- | dbug/sanity.c | 13 | ||||
-rw-r--r-- | dbug/user.r | 8 |
6 files changed, 9 insertions, 244 deletions
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt index 16e130fa28a..4cf6dd88cb7 100644 --- a/dbug/CMakeLists.txt +++ b/dbug/CMakeLists.txt @@ -17,6 +17,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/dbug ${CMAKE_SOURCE_DIR}/include ) -SET(DBUG_SOURCES dbug.c sanity.c) +SET(DBUG_SOURCES dbug.c) ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES}) TARGET_LINK_LIBRARIES(dbug mysys) diff --git a/dbug/Makefile.am b/dbug/Makefile.am index 4091858a1af..3581b3597ee 100644 --- a/dbug/Makefile.am +++ b/dbug/Makefile.am @@ -19,7 +19,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a pkglib_LIBRARIES = libdbug.a noinst_HEADERS = dbug_long.h -libdbug_a_SOURCES = dbug.c sanity.c +libdbug_a_SOURCES = dbug.c EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \ user.r monty.doc dbug_add_tags.pl \ my_main.c main.c factorial.c dbug_analyze.c \ diff --git a/dbug/dbug.c b/dbug/dbug.c index 0355d553cff..fd87669b8ca 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -95,7 +95,7 @@ #define fnmatch(A,B,C) strcmp(A,B) #endif -#if defined(MSDOS) || defined(__WIN__) +#if defined(__WIN__) #include <process.h> #endif @@ -128,9 +128,8 @@ #define PROFILE_ON (1 << 7) /* Print out profiling code */ #define PID_ON (1 << 8) /* Identify each line with process id */ #define TIMESTAMP_ON (1 << 9) /* timestamp every line of output */ -#define SANITY_CHECK_ON (1 << 10) /* Check safemalloc on DBUG_ENTER */ -#define FLUSH_ON_WRITE (1 << 11) /* Flush on every write */ -#define OPEN_APPEND (1 << 12) /* Open for append */ +#define FLUSH_ON_WRITE (1 << 10) /* Flush on every write */ +#define OPEN_APPEND (1 << 11) /* Open for append */ #define TRACE_ON ((uint)1 << 31) /* Trace enabled. MUST be the highest bit!*/ #define TRACING (cs->stack->flags & TRACE_ON) @@ -184,12 +183,6 @@ static void perror(); /* Fake system/library error print routine */ #endif -#ifdef SAFEMALLOC -IMPORT int _sanity(const char *file,uint line); /* safemalloc sanity checker */ -#else -#define _sanity(X,Y) (1) -#endif - /* * The user may specify a list of functions to trace or * debug. These lists are kept in a linear linked list, @@ -309,7 +302,7 @@ static int DoTrace(CODE_STATE *cs); #define DISABLE_TRACE 4 /* Test to see if file is writable */ -#if defined(HAVE_ACCESS) && !defined(MSDOS) +#if defined(HAVE_ACCESS) static BOOLEAN Writable(const char *pathname); /* Change file owner and group */ static void ChangeOwner(CODE_STATE *cs, char *pathname); @@ -343,23 +336,19 @@ static unsigned long Clock(void); #define ERR_OPEN "%s: can't open debug output stream \"%s\": " #define ERR_CLOSE "%s: can't close debug file: " #define ERR_ABORT "%s: debugger aborting because %s\n" -#define ERR_CHOWN "%s: can't change owner/group of \"%s\": " /* * Macros and defines for testing file accessibility under UNIX and MSDOS. */ #undef EXISTS -#if !defined(HAVE_ACCESS) || defined(MSDOS) +#if !defined(HAVE_ACCESS) #define EXISTS(pathname) (FALSE) /* Assume no existance */ #define Writable(name) (TRUE) #else #define EXISTS(pathname) (access(pathname, F_OK) == 0) #define WRITABLE(pathname) (access(pathname, W_OK) == 0) #endif -#ifndef MSDOS -#define ChangeOwner(cs,name) -#endif /* @@ -705,12 +694,6 @@ int DbugParse(CODE_STATE *cs, const char *control) else stack->flags |= TIMESTAMP_ON; break; - case 'S': - if (sign < 0) - stack->flags &= ~SANITY_CHECK_ON; - else - stack->flags |= SANITY_CHECK_ON; - break; } if (!*end) break; @@ -1069,7 +1052,6 @@ int _db_explain_ (CODE_STATE *cs, char *buf, size_t len) op_bool_to_buf('r', cs->stack->sub_level != 0); op_intf_to_buf('t', cs->stack->maxdepth, MAXDEPTH, TRACING); op_bool_to_buf('T', cs->stack->flags & TIMESTAMP_ON); - op_bool_to_buf('S', cs->stack->flags & SANITY_CHECK_ON); *buf= '\0'; return 0; @@ -1187,8 +1169,6 @@ void _db_enter_(const char *_func_, const char *_file_, if (!TRACING) break; /* fall through */ case DO_TRACE: - if ((cs->stack->flags & SANITY_CHECK_ON) && _sanity(_file_,_line_)) - cs->stack->flags &= ~SANITY_CHECK_ON; if (TRACING) { if (!cs->locked) @@ -1247,9 +1227,6 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_) #endif if (DoTrace(cs) & DO_TRACE) { - if ((cs->stack->flags & SANITY_CHECK_ON) && - _sanity(_stack_frame_->file,_line_)) - cs->stack->flags &= ~SANITY_CHECK_ON; if (TRACING) { if (!cs->locked) @@ -2027,10 +2004,6 @@ static void DBUGOpenFile(CODE_STATE *cs, else { cs->stack->out_file= fp; - if (newfile) - { - ChangeOwner(cs, name); - } } } } @@ -2088,10 +2061,6 @@ static FILE *OpenProfile(CODE_STATE *cs, const char *name) else { cs->stack->prof_file= fp; - if (newfile) - { - ChangeOwner(cs, name); - } } } return fp; @@ -2285,42 +2254,6 @@ static BOOLEAN Writable(const char *pathname) /* * FUNCTION * - * ChangeOwner change owner to real user for suid programs - * - * SYNOPSIS - * - * static VOID ChangeOwner(pathname) - * - * DESCRIPTION - * - * For unix systems, change the owner of the newly created debug - * file to the real owner. This is strictly for the benefit of - * programs that are running with the set-user-id bit set. - * - * Note that at this point, the fact that pathname represents - * a newly created file has already been established. If the - * program that the debugger is linked to is not running with - * the suid bit set, then this operation is redundant (but - * harmless). - * - */ - -#ifndef ChangeOwner -static void ChangeOwner(CODE_STATE *cs, char *pathname) -{ - if (chown(pathname, getuid(), getgid()) == -1) - { - (void) fprintf(stderr, ERR_CHOWN, cs->process, pathname); - perror(""); - (void) fflush(stderr); - } -} -#endif - - -/* - * FUNCTION - * * _db_setjmp_ save debugger environment * * SYNOPSIS @@ -2489,7 +2422,7 @@ static unsigned long Clock() return ru.ru_utime.tv_sec*1000 + ru.ru_utime.tv_usec/1000; } -#elif defined(MSDOS) || defined(__WIN__) +#elif defined(__WIN__) static ulong Clock() { @@ -2538,37 +2471,6 @@ static unsigned long Clock() #endif /* RUSAGE */ #endif /* THREADS */ -#ifdef NO_VARARGS - -/* - * Fake vfprintf for systems that don't support it. If this - * doesn't work, you are probably SOL... - */ - -static int vfprintf(stream, format, ap) -FILE *stream; -char *format; -va_list ap; -{ - int rtnval; - ARGS_DCL; - - ARG0= va_arg(ap, ARGS_TYPE); - ARG1= va_arg(ap, ARGS_TYPE); - ARG2= va_arg(ap, ARGS_TYPE); - ARG3= va_arg(ap, ARGS_TYPE); - ARG4= va_arg(ap, ARGS_TYPE); - ARG5= va_arg(ap, ARGS_TYPE); - ARG6= va_arg(ap, ARGS_TYPE); - ARG7= va_arg(ap, ARGS_TYPE); - ARG8= va_arg(ap, ARGS_TYPE); - ARG9= va_arg(ap, ARGS_TYPE); - rtnval= fprintf(stream, format, ARGS_LIST); - return rtnval; -} - -#endif /* NO_VARARGS */ - #else /* diff --git a/dbug/dbug_analyze.c b/dbug/dbug_analyze.c index 3263b2ccc59..1ebe8bfd77e 100644 --- a/dbug/dbug_analyze.c +++ b/dbug/dbug_analyze.c @@ -561,9 +561,6 @@ FILE *outf; #define usage() fprintf (DBUG_FILE,"Usage: %s [-v] [prof-file]\n",my_name) -#ifdef MSDOS -extern int getopt(int argc, char **argv, char *opts); -#endif extern int optind; extern char *optarg; @@ -609,118 +606,5 @@ int main (int argc, char **argv) process (infile); output (outfile); DBUG_RETURN (EX_OK); + } } -} - -#ifdef MSDOS - -/* - * From std-unix@ut-sally.UUCP (Moderator, John Quarterman) Sun Nov 3 14:34:15 1985 - * Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site gatech.CSNET - * Posting-Version: version B 2.10.2 9/18/84; site ut-sally.UUCP - * Path: gatech!akgua!mhuxv!mhuxt!mhuxr!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!ut-sally!std-unix - * From: std-unix@ut-sally.UUCP (Moderator, John Quarterman) - * Newsgroups: mod.std.unix - * Subject: public domain AT&T getopt source - * Message-ID: <3352@ut-sally.UUCP> - * Date: 3 Nov 85 19:34:15 GMT - * Date-Received: 4 Nov 85 12:25:09 GMT - * Organization: IEEE/P1003 Portable Operating System Environment Committee - * Lines: 91 - * Approved: jsq@ut-sally.UUCP - * - * Here's something you've all been waiting for: the AT&T public domain - * source for getopt(3). It is the code which was given out at the 1985 - * UNIFORUM conference in Dallas. I obtained it by electronic mail - * directly from AT&T. The people there assure me that it is indeed - * in the public domain. - * - * There is no manual page. That is because the one they gave out at - * UNIFORUM was slightly different from the current System V Release 2 - * manual page. The difference apparently involved a note about the - * famous rules 5 and 6, recommending using white space between an option - * and its first argument, and not grouping options that have arguments. - * Getopt itself is currently lenient about both of these things White - * space is allowed, but not mandatory, and the last option in a group can - * have an argument. That particular version of the man page evidently - * has no official existence, and my source at AT&T did not send a copy. - * The current SVR2 man page reflects the actual behavor of this getopt. - * However, I am not about to post a copy of anything licensed by AT&T. - * - * I will submit this source to Berkeley as a bug fix. - * - * I, personally, make no claims or guarantees of any kind about the - * following source. I did compile it to get some confidence that - * it arrived whole, but beyond that you're on your own. - * - */ - -/*LINTLIBRARY*/ - -int opterr = 1; -int optind = 1; -int optopt; -char *optarg; - -static void _ERR(s,c,argv) -char *s; -int c; -char *argv[]; -{ - char errbuf[3]; - - if (opterr) { - errbuf[0] = c; - errbuf[1] = '\n'; - (void) fprintf(stderr, "%s", argv[0]); - (void) fprintf(stderr, "%s", s); - (void) fprintf(stderr, "%s", errbuf); - } -} - -int getopt(argc, argv, opts) -int argc; -char **argv, *opts; -{ - static int sp = 1; - register int c; - register char *cp; - - if(sp == 1) - if(optind >= argc || - argv[optind][0] != '-' || argv[optind][1] == '\0') - return(EOF); - else if(strcmp(argv[optind], "--") == 0) { - optind++; - return(EOF); - } - optopt = c = argv[optind][sp]; - if(c == ':' || (cp=strchr(opts, c)) == NULL) { - _ERR(": illegal option -- ", c, argv); - if(argv[optind][++sp] == '\0') { - optind++; - sp = 1; - } - return('?'); - } - if(*++cp == ':') { - if(argv[optind][sp+1] != '\0') - optarg = &argv[optind++][sp+1]; - else if(++optind >= argc) { - _ERR(": option requires an argument -- ", c, argv); - sp = 1; - return('?'); - } else - optarg = argv[optind++]; - sp = 1; - } else { - if(argv[optind][++sp] == '\0') { - sp = 1; - optind++; - } - optarg = NULL; - } - return(c); -} - -#endif /* !unix && !xenix */ diff --git a/dbug/sanity.c b/dbug/sanity.c deleted file mode 100644 index df43fc14ba9..00000000000 --- a/dbug/sanity.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Declarate _sanity() if not declared in main program */ - -#include <my_global.h> - -extern int _sanity(const char *file,uint line); - -#if defined(SAFEMALLOC) && !defined(MASTER) /* Avoid errors in MySQL */ -int _sanity(const char * file __attribute__((unused)), - uint line __attribute__((unused))) -{ - return 0; -} -#endif diff --git a/dbug/user.r b/dbug/user.r index 847ad80b30f..5628f5a4fa1 100644 --- a/dbug/user.r +++ b/dbug/user.r @@ -1019,14 +1019,6 @@ Most useful with .B DBUG_PUSH macros used to temporarily alter the debugger state. -.LI S -When compiled with -.I safemalloc -this flag forces "sanity" memory checks (for overwrites/underwrites) -on each -.B DBUG_ENTER -and -.B DBUG_RETURN. .LI t[,N] Enable function control flow tracing. The maximum nesting depth is specified by N, and defaults to |