ChangeLogTag:Wed Nov 24 12:45:36 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>

This commit is contained in:
Gonzalo A. Diethelm
1999-11-24 16:00:49 +00:00
parent 4f9c4ed7c8
commit 2b158cb673
9 changed files with 199 additions and 43 deletions

View File

@@ -1,3 +1,24 @@
Wed Nov 24 12:45:36 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
* include/hbtrace.h:
* source/common/hbtrace.c:
* source/rtl/trace.c:
* source/rtl/Makefile:
* doc/tracing.txt:
Implememted run-time tracing control; thanks to Jose Lalin
<dezac@corevia.com> for suggesting this. The interface is
described in doc/tracing.txt.
* source/rdd/dbf1.c:
Fixed a compilation error that only appeared with HB_TR_DEBUG.
* source/rtl/inkey.c:
Added a guard to avoid a compilation warning.
* tests/Makefile:
Changed the order of inclusion to make sure you can still do a
make 'PRG_SOURCES=foo.prg'.
19991123-13:35 EDT David G. Holm <dholm@jsd-llc.com>
* rt_misc.prg

View File

@@ -133,3 +133,35 @@ recompile the preprocessor/compiler:
HB_TRACE_UTILS
The value is of no importance.
TRACING AND RUNTIME
===================
It is also possible to enable and disable tracing at run-time, and to
query and set the trace level. From C code:
* To turn tracing completely off:
hb_traceoff();
* To turn tracing back on:
hb_traceon();
* To query the current tracing level, and optionally change the
current level to a given value (which should be in the range [0,5],
otherwise the current level remains unchanged):
hb_tracelevel(level);
Therefore, to just query the current level, you can safely call
hb_tracelevel(-1);
There are wrapper functions callable from Clipper code:
TRACEOFF()
TRACEON()
TRACELEVEL(level)

View File

@@ -122,7 +122,10 @@ extern char * hb_tr_file_;
extern int hb_tr_line_;
extern int hb_tr_level_;
extern void hb_traceon( void );
extern void hb_traceoff( void );
extern int hb_tracelevel( int new_level );
extern int hb_tr_level( void );
extern void hb_tr_trace( char* fmt, ... );
extern int hb_tr_level(void);
#endif /* HB_TRACE_H_ */

View File

@@ -43,6 +43,7 @@ char * hb_tr_file_ = "";
int hb_tr_line_ = 0;
int hb_tr_level_ = 0;
static int hb_tr_state_ = 1;
static FILE* hb_tr_fp_ = 0;
static char* slevel[HB_TR_LAST] =
{
@@ -54,11 +55,75 @@ static char* slevel[HB_TR_LAST] =
"HB_TR_DEBUG"
};
void hb_traceon( void )
{
hb_tr_state_ = 1;
}
void hb_traceoff( void )
{
hb_tr_state_ = 0;
}
int hb_tracelevel( int new_level )
{
int old_level = hb_tr_level_;
if (new_level >= HB_TR_ALWAYS &&
new_level < HB_TR_LAST) {
hb_tr_level_ = new_level;
}
return old_level;
}
int hb_tr_level(void)
{
static int level = -1;
int i;
char* env;
char* out;
if (level != -1) {
return level;
}
hb_tr_fp_ = stderr;
out = getenv("HB_TR_OUTPUT");
if (out != 0 && out[0] != '\0') {
hb_tr_fp_ = fopen(out, "w");
if (hb_tr_fp_ == NULL) {
hb_tr_fp_ = stderr;
}
}
level = HB_TR_DEFAULT;
env = getenv("HB_TR_LEVEL");
if (env != 0 && env[0] != '\0') {
for (i = 0; i < HB_TR_LAST; ++i) {
if (strcmp(env, slevel[i]) == 0) {
level = i;
break;
}
}
}
return level;
}
void hb_tr_trace( char * fmt, ... )
{
int i;
va_list ap;
/*
* If tracing is disabled, do nothing.
*/
if( ! hb_tr_state_ ) {
return;
}
/*
* Clean up the file, so that instead of showing
*
@@ -100,39 +165,3 @@ void hb_tr_trace( char * fmt, ... )
hb_tr_line_ = -1;
hb_tr_level_ = -1;
}
int hb_tr_level(void)
{
static int level = -1;
int i;
char* env;
char* out;
if (level != -1) {
return level;
}
hb_tr_fp_ = stderr;
out = getenv("HB_TR_OUTPUT");
if (out != 0 && out[0] != '\0') {
hb_tr_fp_ = fopen(out, "w");
if (hb_tr_fp_ == NULL) {
hb_tr_fp_ = stderr;
}
}
env = getenv("HB_TR_LEVEL");
if (env == 0 || env[0] == '\0') {
level = HB_TR_DEFAULT;
}
else {
for (i = 0; i < HB_TR_LAST; ++i) {
if (strcmp(env, slevel[i]) == 0) {
level = i;
break;
}
}
}
return level;
}

View File

@@ -298,7 +298,7 @@ static BOOL hb_dbfUpdateRecord( AREAP pArea, ULONG ulRecNo )
LPFIELD pField;
BYTE pBuffer[ 1 ];
HB_TRACE(HB_TR_DEBUG, ("hb_dbfUpdateRecord(%p, %lu)", pArea, lRecNo));
HB_TRACE(HB_TR_DEBUG, ("hb_dbfUpdateRecord(%p, %lu)", pArea, ulRecNo));
if( ulRecNo > pArea->lpExtendInfo->ulRecCount )
{

View File

@@ -44,6 +44,7 @@ C_SOURCES=\
soundex.c \
strings.c \
tone.c \
trace.c \
transfrm.c \
\
gtxxx.c \

View File

@@ -90,6 +90,7 @@
#include "hbwinapi.h"
#if defined(_Windows) || defined(WINNT)
#if ! defined(HARBOUR_USE_CRS_GTAPI) && ! defined(HARBOUR_USE_SLN_GTAPI)
#define INPUT_BUFFER_LEN 128
extern BOOL hb_gtBreak; /* This variable is located in source/rtl/gt/gtwin.c */
extern HANDLE hb_gtHInput; /* This variable is located in source/rtl/gt/gtwin.c */
@@ -97,6 +98,7 @@
static DWORD s_cNumIndex = 0; /* ...to the Windows API, which defines DWORD, etc. */
static INPUT_RECORD s_irInBuf[ INPUT_BUFFER_LEN ];
#endif
#endif
#define HB_BREAK_FLAG 256 /* 256, because that's what DJGPP returns Ctrl+Break as.
Clipper has no key code 256, so it may as well be

View File

@@ -0,0 +1,67 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* The Clipper tracing API.
*
* Copyright 1999 Gonzalo A. Diethelm <gonzalo.diethelm@iname.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) with other files to produce
* an executable, this does not by itself cause the resulting executable
* to be covered by the GNU General Public License. Your use of that
* executable is in no way restricted on account of linking the HRL
* and/or HVM code into it.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
/*
* This code is based on a suggestion made by Jose Lalin
* <dezac@corevia.com>.
*
* See doc/license.txt for licensing terms.
*/
#include "extend.h"
HARBOUR HB_TRACEON( void )
{
hb_traceon();
}
HARBOUR HB_TRACEOFF( void )
{
hb_traceoff();
}
HARBOUR HB_TRACELEVEL( void )
{
int old_level = 0;
int new_level = -1;
if( hb_pcount() == 1 ) {
new_level = hb_parni( 1 );
}
old_level = hb_tracelevel(new_level);
hb_retni( old_level );
}

View File

@@ -26,11 +26,6 @@ endif
ifeq ($(PM),) # PM not defined = build all files
DIRS=\
regress \
include $(TOP)$(ROOT)config/dir.cf
PRG_SOURCES=\
ac_test.prg \
adirtest.prg \
@@ -197,3 +192,9 @@ endif
include $(TOP)$(ROOT)config/bin.cf
endif
DIRS=\
regress \
include $(TOP)$(ROOT)config/dir.cf