Commit 02b82326 authored by Sergei Golubchik's avatar Sergei Golubchik

small dbug cleanup

parent a00b3849
...@@ -137,27 +137,17 @@ ...@@ -137,27 +137,17 @@
#define BOOLEAN my_bool #define BOOLEAN my_bool
/*
* Make it easy to change storage classes if necessary.
*/
#define IMPORT extern /* Names defined externally */
#define EXPORT /* Allocated here, available globally */
#define AUTO auto /* Names to be allocated on stack */
#define REGISTER register /* Names to be placed in registers */
#ifdef M_I386 /* predefined by xenix 386 compiler */
#define AUTOS_REVERSE 1
#else
#define AUTOS_REVERSE 0
#endif
/* /*
* Externally supplied functions. * Externally supplied functions.
*/ */
#ifndef HAVE_PERROR #ifndef HAVE_PERROR
static void perror(); /* Fake system/library error print routine */ static void perror(char *s)
{
if (s && *s != '\0')
(void) fprintf(stderr, "%s: ", s);
(void) fprintf(stderr, "<unknown system error>\n");
}
#endif #endif
/* /*
...@@ -1718,7 +1708,7 @@ BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword, int strict) ...@@ -1718,7 +1708,7 @@ BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword, int strict)
static void Indent(CODE_STATE *cs, int indent) static void Indent(CODE_STATE *cs, int indent)
{ {
REGISTER int count; int count;
indent= max(indent-1-cs->stack->sub_level,0)*INDENT; indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
for (count= 0; count < indent ; count++) for (count= 0; count < indent ; count++)
...@@ -1750,7 +1740,7 @@ static void Indent(CODE_STATE *cs, int indent) ...@@ -1750,7 +1740,7 @@ static void Indent(CODE_STATE *cs, int indent)
static void FreeList(struct link *linkp) static void FreeList(struct link *linkp)
{ {
REGISTER struct link *old; struct link *old;
while (linkp != NULL) while (linkp != NULL)
{ {
...@@ -1849,8 +1839,8 @@ static void DoPrefix(CODE_STATE *cs, uint _line_) ...@@ -1849,8 +1839,8 @@ static void DoPrefix(CODE_STATE *cs, uint _line_)
static void DBUGOpenFile(CODE_STATE *cs, static void DBUGOpenFile(CODE_STATE *cs,
const char *name,const char *end,int append) const char *name,const char *end,int append)
{ {
REGISTER FILE *fp; FILE *fp;
REGISTER BOOLEAN newfile; BOOLEAN newfile;
if (name != NULL) if (name != NULL)
{ {
...@@ -1976,7 +1966,7 @@ static void DbugExit(const char *why) ...@@ -1976,7 +1966,7 @@ static void DbugExit(const char *why)
static char *DbugMalloc(size_t size) static char *DbugMalloc(size_t size)
{ {
register char *new_malloc; char *new_malloc;
if (!(new_malloc= (char*) malloc(size))) if (!(new_malloc= (char*) malloc(size)))
DbugExit("out of memory"); DbugExit("out of memory");
...@@ -2017,7 +2007,7 @@ static const char *DbugStrTok(const char *s) ...@@ -2017,7 +2007,7 @@ static const char *DbugStrTok(const char *s)
static const char *BaseName(const char *pathname) static const char *BaseName(const char *pathname)
{ {
register const char *base; const char *base;
base= strrchr(pathname, FN_LIBCHAR); base= strrchr(pathname, FN_LIBCHAR);
if (base++ == NullS) if (base++ == NullS)
...@@ -2054,8 +2044,8 @@ static const char *BaseName(const char *pathname) ...@@ -2054,8 +2044,8 @@ static const char *BaseName(const char *pathname)
static BOOLEAN Writable(const char *pathname) static BOOLEAN Writable(const char *pathname)
{ {
REGISTER BOOLEAN granted; BOOLEAN granted;
REGISTER char *lastslash; char *lastslash;
granted= FALSE; granted= FALSE;
if (EXISTS(pathname)) if (EXISTS(pathname))
...@@ -2079,105 +2069,11 @@ static BOOLEAN Writable(const char *pathname) ...@@ -2079,105 +2069,11 @@ static BOOLEAN Writable(const char *pathname)
} }
#endif #endif
/* /*
* FUNCTION flush dbug-stream, free mutex lock & wait delay
* This is because some systems (MSDOS!!) dosn't flush fileheader
* _db_setjmp_ save debugger environment and dbug-file isn't readable after a system crash !!
* */
* SYNOPSIS
*
* VOID _db_setjmp_()
*
* DESCRIPTION
*
* Invoked as part of the user's DBUG_SETJMP macro to save
* the debugger environment in parallel with saving the user's
* environment.
*
*/
#ifdef HAVE_LONGJMP
EXPORT void _db_setjmp_()
{
CODE_STATE *cs;
get_code_state_or_return;
cs->jmplevel= cs->level;
cs->jmpfunc= cs->func;
cs->jmpfile= cs->file;
}
/*
* FUNCTION
*
* _db_longjmp_ restore previously saved debugger environment
*
* SYNOPSIS
*
* VOID _db_longjmp_()
*
* DESCRIPTION
*
* Invoked as part of the user's DBUG_LONGJMP macro to restore
* the debugger environment in parallel with restoring the user's
* previously saved environment.
*
*/
EXPORT void _db_longjmp_()
{
CODE_STATE *cs;
get_code_state_or_return;
cs->level= cs->jmplevel;
if (cs->jmpfunc)
cs->func= cs->jmpfunc;
if (cs->jmpfile)
cs->file= cs->jmpfile;
}
#endif
/*
* FUNCTION
*
* perror perror simulation for systems that don't have it
*
* SYNOPSIS
*
* static VOID perror(s)
* char *s;
*
* DESCRIPTION
*
* Perror produces a message on the standard error stream which
* provides more information about the library or system error
* just encountered. The argument string s is printed, followed
* by a ':', a blank, and then a message and a newline.
*
* An undocumented feature of the unix perror is that if the string
* 's' is a null string (NOT a NULL pointer!), then the ':' and
* blank are not printed.
*
* This version just complains about an "unknown system error".
*
*/
#ifndef HAVE_PERROR
static void perror(s)
char *s;
{
if (s && *s != '\0')
(void) fprintf(stderr, "%s: ", s);
(void) fprintf(stderr, "<unknown system error>\n");
}
#endif /* HAVE_PERROR */
/* flush dbug-stream, free mutex lock & wait delay */
/* This is because some systems (MSDOS!!) dosn't flush fileheader */
/* and dbug-file isn't readable after a system crash !! */
static void DbugFlush(CODE_STATE *cs) static void DbugFlush(CODE_STATE *cs)
{ {
......
...@@ -116,16 +116,10 @@ ...@@ -116,16 +116,10 @@
# define DBUG_VOID_RETURN return # define DBUG_VOID_RETURN return
# define DBUG_EXECUTE(keyword,a1) # define DBUG_EXECUTE(keyword,a1)
# define DBUG_PRINT(keyword,arglist) # define DBUG_PRINT(keyword,arglist)
# define DBUG_2(keyword,format) /* Obsolete */
# define DBUG_3(keyword,format,a1) /* Obsolete */
# define DBUG_4(keyword,format,a1,a2) /* Obsolete */
# define DBUG_5(keyword,format,a1,a2,a3) /* Obsolete */
# define DBUG_PUSH(a1) # define DBUG_PUSH(a1)
# define DBUG_POP() # define DBUG_POP()
# define DBUG_PROCESS(a1) # define DBUG_PROCESS(a1)
# define DBUG_FILE (stderr) # define DBUG_FILE (stderr)
# define DBUG_SETJMP setjmp
# define DBUG_LONGJMP longjmp
# define DBUG_DUMP(keyword,a1) # define DBUG_DUMP(keyword,a1)
# else # else
# define DBUG_ENTER(a) \ # define DBUG_ENTER(a) \
...@@ -142,19 +136,9 @@ ...@@ -142,19 +136,9 @@
{if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}} {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
# define DBUG_PRINT(keyword,arglist) \ # define DBUG_PRINT(keyword,arglist) \
{if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}} {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
# define DBUG_2(keyword,format) \
DBUG_PRINT(keyword,(format)) /* Obsolete */
# define DBUG_3(keyword,format,a1) \
DBUG_PRINT(keyword,(format,a1)) /* Obsolete */
# define DBUG_4(keyword,format,a1,a2) \
DBUG_PRINT(keyword,(format,a1,a2)) /* Obsolete */
# define DBUG_5(keyword,format,a1,a2,a3) \
DBUG_PRINT(keyword,(format,a1,a2,a3)) /* Obsolete */
# define DBUG_PUSH(a1) _db_push_ (a1) # define DBUG_PUSH(a1) _db_push_ (a1)
# define DBUG_POP() _db_pop_ () # define DBUG_POP() _db_pop_ ()
# define DBUG_PROCESS(a1) (_db_process_ = a1) # define DBUG_PROCESS(a1) (_db_process_ = a1)
# define DBUG_FILE (_db_fp_) # define DBUG_FILE (_db_fp_)
# define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
# define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
# define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2) # define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
# endif # endif
...@@ -823,28 +823,6 @@ number of bytes to dump. ...@@ -823,28 +823,6 @@ number of bytes to dump.
.SP 1 .SP 1
EX: \fCDBUG_DBUG\ ("net",\ packet,\ len);\fR EX: \fCDBUG_DBUG\ ("net",\ packet,\ len);\fR
.SP 1 .SP 1
.LI DBUG_SETJMP\
Used in place of the setjmp() function to first save the current
debugger state and then execute the standard setjmp call.
This allows to the debugger to restore its state when the
DBUG_LONGJMP macro is used to invoke the standard longjmp() call.
Currently all instances of DBUG_SETJMP must occur within the
same function and at the same function nesting level.
.SP 1
EX: \fCDBUG_SETJMP\ (env);\fR
.SP 1
.LI DBUG_LONGJMP\
Used in place of the longjmp() function to first restore the
previous debugger state at the time of the last DBUG_SETJMP
and then execute the standard longjmp() call.
Note that currently all DBUG_LONGJMP macros restore the state
at the time of the last DBUG_SETJMP.
It would be possible to maintain separate DBUG_SETJMP and DBUG_LONGJMP
pairs by having the debugger runtime support module use the first
argument to differentiate the pairs.
.SP 1
EX: \fCDBUG_LONGJMP\ (env,val);\fR
.SP 1
.LI DBUG_LOCK_FILE\ .LI DBUG_LOCK_FILE\
Used in multi-threaded environment to lock DBUG_FILE stream. Used in multi-threaded environment to lock DBUG_FILE stream.
It can be used, for example, in functions that need to write something to a It can be used, for example, in functions that need to write something to a
......
...@@ -89,8 +89,6 @@ extern const char* _db_get_func_(void); ...@@ -89,8 +89,6 @@ extern const char* _db_get_func_(void);
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1) #define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
#define DBUG_PROCESS(a1) _db_process_(a1) #define DBUG_PROCESS(a1) _db_process_(a1)
#define DBUG_FILE _db_fp_() #define DBUG_FILE _db_fp_()
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2) #define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
#define DBUG_END() _db_end_ () #define DBUG_END() _db_end_ ()
#define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_LOCK_FILE _db_lock_file_()
...@@ -155,8 +153,6 @@ extern void _db_suicide_(); ...@@ -155,8 +153,6 @@ extern void _db_suicide_();
#define DBUG_SET_INITIAL(a1) do { } while(0) #define DBUG_SET_INITIAL(a1) do { } while(0)
#define DBUG_POP() do { } while(0) #define DBUG_POP() do { } while(0)
#define DBUG_PROCESS(a1) do { } while(0) #define DBUG_PROCESS(a1) do { } while(0)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2) do { } while(0) #define DBUG_DUMP(keyword,a1,a2) do { } while(0)
#define DBUG_END() do { } while(0) #define DBUG_END() do { } while(0)
#define DBUG_ASSERT(A) do { } while(0) #define DBUG_ASSERT(A) do { } while(0)
......
...@@ -278,7 +278,7 @@ my_bool my_thread_init(void) ...@@ -278,7 +278,7 @@ my_bool my_thread_init(void)
my_bool error=0; my_bool error=0;
#ifdef EXTRA_DEBUG_THREADS #ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n", fprintf(stderr,"my_thread_init(): pthread_self: 0x%lx\n",
(ulong) pthread_self()); (ulong) pthread_self());
#endif #endif
......
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