2007-04-16 00:20 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/common.mak
  * harbour/bin/pack_src.sh
  * harbour/source/vm/Makefile
  - harbour/source/vm/dbgentry.c
  * harbour/source/debug/Makefile
  + harbour/source/debug/dbgentry.c
    * moved dbgentry.c from HVM to DEBUG library

  * harbour/source/rtl/hbgtcore.c
    + added basic version of GTI_{NEW,GET,SET}WIN

  * harbour/include/hbapidbg.h
  * harbour/source/vm/hvm.c
  * harbour/source/debug/debugger.prg
  * harbour/source/debug/dbgentry.c
    + added set of .prg level functions (HB_DBG_*()) to control
      debugger internals
    * eliminated HB_INLINE() calls
    * use  to switch between user and debugger screen
    * cleaned debugger interface in HVM, removed unused variables
      added one common debug function
This commit is contained in:
Przemyslaw Czerpak
2007-04-15 22:20:37 +00:00
parent dfa8e92612
commit 942d57e0f1
10 changed files with 455 additions and 407 deletions

View File

@@ -8,6 +8,29 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-04-16 00:20 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/common.mak
* harbour/bin/pack_src.sh
* harbour/source/vm/Makefile
- harbour/source/vm/dbgentry.c
* harbour/source/debug/Makefile
+ harbour/source/debug/dbgentry.c
* moved dbgentry.c from HVM to DEBUG library
* harbour/source/rtl/hbgtcore.c
+ added basic version of GTI_{NEW,GET,SET}WIN
* harbour/include/hbapidbg.h
* harbour/source/vm/hvm.c
* harbour/source/debug/debugger.prg
* harbour/source/debug/dbgentry.c
+ added set of .prg level functions (HB_DBG_*()) to control
debugger internals
* eliminated HB_INLINE() calls
* use to switch between user and debugger screen
* cleaned debugger interface in HVM, removed unused variables
added one common debug function
2007-04-15 14:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/common/hbver.c
! fixed typo in buffer size passed to snprintf()

View File

@@ -92,6 +92,7 @@ $hb_collect source/pp/*.[ch]
# SOURCE\DEBUG
$hb_collect source/debug/Makefile
$hb_collect source/debug/*.[ch]
$hb_collect source/debug/*.prg
# SOURCE\LANG

View File

@@ -291,7 +291,6 @@ VM_COMMON_LIB_OBJS = \
$(OBJ_DIR)\classes.obj \
$(OBJ_DIR)\cmdarg.obj \
$(OBJ_DIR)\codebloc.obj \
$(OBJ_DIR)\dbgentry.obj \
$(OBJ_DIR)\debug.obj \
$(OBJ_DIR)\dynlibhb.obj \
$(OBJ_DIR)\dynsym.obj \
@@ -537,6 +536,7 @@ MACRO_LIB_OBJS = \
#**********************************************************
DEBUG_LIB_OBJS = \
$(OBJ_DIR)\dbgentry.obj \
$(OBJ_DIR)\dbgbrwsr.obj \
$(OBJ_DIR)\dbghelp.obj \
$(OBJ_DIR)\dbgmenu.obj \

View File

@@ -57,15 +57,19 @@
HB_EXTERN_BEGIN
/* Debugger API */
/*Debugger API */
/* HVM debugger function */
typedef void (*HB_DBGENTRY_FUNC) ( int , int , char *, int , int );
HB_EXPORT extern HB_DBGENTRY_FUNC hb_vm_pFunDbgEntry;
HB_EXPORT extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry );
HB_EXPORT extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke );
HB_EXPORT extern ULONG hb_dbg_ProcLevel( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarSGet( int nStatic, int nOffset );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal );
HB_EXPORT extern ULONG hb_dbg_vmVarGCount( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset );
/* internal debugger function */
HB_EXPORT extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame );
HB_EXPORT extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction );
HB_EXPORT extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace );
@@ -86,4 +90,4 @@ HB_EXPORT extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BO
HB_EXTERN_END
#endif /* HB_APICLS_H_ */
#endif /* HB_APIDBG_H_ */

View File

@@ -4,6 +4,9 @@
ROOT = ../../
C_SOURCES=\
dbgentry.c \
PRG_SOURCES=\
dbgmenu.prg \
dbghelp.prg \
@@ -17,7 +20,7 @@ PRG_SOURCES=\
dbgtobj.prg \
tbrwtext.prg \
dbgwa.prg \
dbgbrwsr.prg
dbgbrwsr.prg \
LIBNAME=debug

View File

@@ -108,7 +108,7 @@ typedef struct
typedef struct
{
char *szExpr;
HB_ITEM *pBlock;
PHB_ITEM pBlock;
int nVars;
char **aVars;
HB_VARINFO *aScopes;
@@ -173,11 +173,11 @@ static HB_DEBUGINFO s_Info = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
static HB_DEBUGINFO *info = &s_Info;
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateBreakArray( HB_DEBUGINFO *info );
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateModuleArray( HB_DEBUGINFO *info );
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateVarArray( int nVars, HB_VARINFO *aVars );
static void
hb_dbgAddLocal( HB_DEBUGINFO *info, char *szName, int nIndex, int nFrame );
@@ -193,7 +193,7 @@ static void
hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, char *szName, char cType, int nIndex, int nFrame );
static void
hb_dbgEndProc( HB_DEBUGINFO *info );
static HB_ITEM *
static PHB_ITEM
hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch );
static PHB_ITEM
hb_dbgEvalMacro( char *szExpr, PHB_ITEM pItem );
@@ -206,13 +206,13 @@ hb_dbgIsAltD( void );
static BOOL
hb_dbgIsBreakPoint( HB_DEBUGINFO *info, char *szModule, int nLine );
static BOOL
hb_dbgEqual( HB_ITEM *pItem1, HB_ITEM *pItem2 );
hb_dbgEqual( PHB_ITEM pItem1, PHB_ITEM pItem2 );
static void
hb_dbgQuit( HB_DEBUGINFO *info );
static PHB_ITEM
hb_dbgVarGet( HB_VARINFO *scope );
static void
hb_dbgVarSet( HB_VARINFO *scope, HB_ITEM *xNewValue );
hb_dbgVarSet( HB_VARINFO *scope, PHB_ITEM xNewValue );
static void *
@@ -250,31 +250,31 @@ hb_dbgActivate( HB_DEBUGINFO *info )
{
HB_CALLSTACKINFO *pEntry = &info->aCallStack[ i ];
PHB_ITEM aEntry = hb_itemArrayNew( 6 );
HB_ITEM *item;
PHB_ITEM pItem;
item = hb_itemPutC( NULL, pEntry->szModule );
hb_arraySet( aEntry, 1, item );
hb_itemRelease( item );
pItem = hb_itemPutC( NULL, pEntry->szModule );
hb_arraySet( aEntry, 1, pItem );
hb_itemRelease( pItem );
item = hb_itemPutC( NULL, pEntry->szFunction );
hb_arraySet( aEntry, 2, item );
hb_itemRelease( item );
pItem = hb_itemPutC( NULL, pEntry->szFunction );
hb_arraySet( aEntry, 2, pItem );
hb_itemRelease( pItem );
item = hb_itemPutNL( NULL, pEntry->nLine );
hb_arraySet( aEntry, 3, item );
hb_itemRelease( item );
pItem = hb_itemPutNL( NULL, pEntry->nLine );
hb_arraySet( aEntry, 3, pItem );
hb_itemRelease( pItem );
item = hb_itemPutNL( NULL, pEntry->nProcLevel );
hb_arraySet( aEntry, 4, item );
hb_itemRelease( item );
pItem = hb_itemPutNL( NULL, pEntry->nProcLevel );
hb_arraySet( aEntry, 4, pItem );
hb_itemRelease( pItem );
item = hb_dbgActivateVarArray( pEntry->nLocals, pEntry->aLocals );
hb_arraySet( aEntry, 5, item );
hb_itemRelease( item );
pItem = hb_dbgActivateVarArray( pEntry->nLocals, pEntry->aLocals );
hb_arraySet( aEntry, 5, pItem );
hb_itemRelease( pItem );
item = hb_dbgActivateVarArray( pEntry->nStatics, pEntry->aStatics );
hb_arraySet( aEntry, 6, item );
hb_itemRelease( item );
pItem = hb_dbgActivateVarArray( pEntry->nStatics, pEntry->aStatics );
hb_arraySet( aEntry, 6, pItem );
hb_itemRelease( pItem );
hb_arraySet( aCallStack, info->nCallStackLen - i, aEntry );
hb_itemRelease( aEntry );
@@ -283,7 +283,7 @@ hb_dbgActivate( HB_DEBUGINFO *info )
aModules = hb_dbgActivateModuleArray( info );
aBreak = hb_dbgActivateBreakArray( info );
hb_vmPushSymbol( pDynSym->pSymbol );
hb_vmPushDynSym( pDynSym );
hb_vmPushNil();
hb_vmPushLong( HB_DBG_ACTIVATE );
hb_vmPushPointer( info );
@@ -301,7 +301,7 @@ hb_dbgActivate( HB_DEBUGINFO *info )
}
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateBreakArray( HB_DEBUGINFO *info )
{
int i;
@@ -336,7 +336,7 @@ hb_dbgActivateBreakArray( HB_DEBUGINFO *info )
}
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateModuleArray( HB_DEBUGINFO *info )
{
int i;
@@ -373,7 +373,7 @@ hb_dbgActivateModuleArray( HB_DEBUGINFO *info )
}
static HB_ITEM *
static PHB_ITEM
hb_dbgActivateVarArray( int nVars, HB_VARINFO *aVars )
{
int i;
@@ -478,7 +478,7 @@ hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
for ( i = 0; i < info->nTracePoints; i++ )
{
HB_TRACEPOINT *tp = &info->aTrace[ i ];
HB_ITEM *xValue;
PHB_ITEM xValue;
xValue = hb_dbgEval( info, &info->aWatch[ tp->nIndex ] );
if ( !xValue )
@@ -948,7 +948,7 @@ hb_dbgEndProc( HB_DEBUGINFO *info )
static BOOL
hb_dbgEqual( HB_ITEM *pItem1, HB_ITEM *pItem2 )
hb_dbgEqual( PHB_ITEM pItem1, PHB_ITEM pItem2 )
{
if ( pItem1->type != pItem2->type )
return FALSE;
@@ -972,10 +972,10 @@ hb_dbgEqual( HB_ITEM *pItem1, HB_ITEM *pItem2 )
}
static HB_ITEM *
static PHB_ITEM
hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch )
{
HB_ITEM *xResult = NULL;
PHB_ITEM xResult = NULL;
HB_TRACE( HB_TR_DEBUG, ( "expr %s", watch->szExpr ) );
@@ -988,7 +988,7 @@ hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch )
if ( watch->pBlock )
{
PHB_ITEM aVars = hb_dbgEvalResolve( info, watch );
HB_ITEM *aNewVars = hb_itemArrayNew( watch->nVars );
PHB_ITEM aNewVars = hb_itemArrayNew( watch->nVars );
int i;
hb_arrayCopy( aVars, aNewVars, NULL, NULL, NULL );
@@ -999,8 +999,8 @@ hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch )
for ( i = 0; i < watch->nVars; i++ )
{
HB_ITEM *xOldValue = hb_itemArrayGet( aVars, i + 1 );
HB_ITEM *xNewValue = hb_itemArrayGet( aNewVars, i + 1 );
PHB_ITEM xOldValue = hb_itemArrayGet( aVars, i + 1 );
PHB_ITEM xNewValue = hb_itemArrayGet( aNewVars, i + 1 );
if ( !hb_dbgEqual( xOldValue, xNewValue ) )
{
@@ -1058,6 +1058,7 @@ hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch )
int i = 0;
PHB_ITEM pBlock;
BOOL bAfterId = FALSE;
char *s;
watch->nVars = 0;
while ( watch->szExpr[ i ] )
@@ -1215,22 +1216,20 @@ hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch )
}
i++;
}
{
HB_ITEM block;
char *s = (char *) ALLOC( 8 + strlen( watch->szExpr ) + 1 + 1 );
strcpy( s, "{|__dbg|" );
strcat( s, watch->szExpr );
strcat( s, "}" );
block.type = 0;
pBlock = hb_dbgEvalMacro( s, &block );
if ( pBlock )
{
pBlock = hb_itemNew( pBlock );
hb_itemClear( &block );
}
FREE( s );
s = ( char * ) ALLOC( 8 + strlen( watch->szExpr ) + 1 + 1 );
strcpy( s, "{|__dbg|" );
strcat( s, watch->szExpr );
strcat( s, "}" );
pBlock = hb_itemNew( NULL );
if( ! hb_dbgEvalMacro( s, pBlock ) )
{
hb_itemRelease( pBlock );
pBlock = NULL;
}
FREE( s );
return pBlock;
}
@@ -1240,7 +1239,7 @@ hb_dbgEvalResolve( HB_DEBUGINFO *info, HB_WATCHPOINT *watch )
{
int i;
HB_CALLSTACKINFO *top = &info->aCallStack[ info->nCallStackLen - 1 ];
HB_ITEM *aVars = hb_itemArrayNew( watch->nVars );
PHB_ITEM aVars = hb_itemArrayNew( watch->nVars );
HB_VARINFO *scopes;
HB_MODULEINFO *module = NULL;
int nProcLevel;
@@ -1637,7 +1636,7 @@ hb_dbgVarGet( HB_VARINFO *scope )
static void
hb_dbgVarSet( HB_VARINFO *scope, HB_ITEM *xNewValue )
hb_dbgVarSet( HB_VARINFO *scope, PHB_ITEM xNewValue )
{
switch ( scope->cType )
{
@@ -1652,7 +1651,7 @@ hb_dbgVarSet( HB_VARINFO *scope, HB_ITEM *xNewValue )
if ( pDynSym && pDynSym->pSymbol->value.pFunPtr )
{
hb_vmPushSymbol( pDynSym->pSymbol );
hb_vmPushDynSym( pDynSym );
hb_vmPushNil();
hb_vmPushString( scope->szName, strlen( scope->szName ) );
hb_vmPush( xNewValue );
@@ -1662,3 +1661,124 @@ hb_dbgVarSet( HB_VARINFO *scope, HB_ITEM *xNewValue )
}
}
}
/*
* .prg functions
*/
HB_FUNC( HB_DBG_SETENTRY )
{
hb_dbg_SetEntry( hb_dbgEntry );
}
HB_FUNC( HB_DBG_SETGO )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetGo( ptr );
}
HB_FUNC( HB_DBG_SETTRACE )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetTrace( ptr );
}
HB_FUNC( HB_DBG_SETCBTRACE )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetCBTrace( ptr, hb_parl( 2 ) );
}
HB_FUNC( HB_DBG_SETNEXTROUTINE )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetNextRoutine( ptr );
}
HB_FUNC( HB_DBG_SETQUIT )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetQuit( ptr );
}
HB_FUNC( HB_DBG_SETTOCURSOR )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetToCursor( ptr, hb_parc( 2 ), hb_parni( 3 ) );
}
HB_FUNC( HB_DBG_GETEXPRVALUE )
{
void * ptr = hb_parptr( 1 );
if( ptr )
{
PHB_ITEM pItem;
if( ISCHAR( 2 ) )
pItem = hb_dbgGetExpressionValue( hb_parptr( 1 ), hb_parc( 2 ) );
else
pItem = hb_dbgGetWatchValue( hb_parptr( 1 ), hb_parni( 2 ) - 1 );
if( pItem )
{
hb_storl( TRUE, 3 );
hb_itemRelease( hb_itemReturn( pItem ) );
}
else
hb_storl( FALSE, 3 );
}
}
HB_FUNC( HB_DBG_GETSOURCEFILES )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_itemRelease( hb_itemReturn( hb_dbgGetSourceFiles( ptr ) ) );
}
HB_FUNC( HB_DBG_ISVALIDSTOPLINE )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_retl( hb_dbgIsValidStopLine( ptr, hb_parc( 2 ), hb_parni( 3 ) ) );
}
HB_FUNC( HB_DBG_ADDBREAK )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgAddBreak( ptr, hb_parc( 2 ), hb_parni( 3 ), NULL );
}
HB_FUNC( HB_DBG_DELBREAK )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgDelBreak( ptr, hb_parni( 2 ) );
}
HB_FUNC( HB_DBG_ADDWATCH )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgAddWatch( ptr, hb_parc( 2 ), hb_parl( 3 ) );
}
HB_FUNC( HB_DBG_DELWATCH )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgDelWatch( ptr, hb_parni( 2 ) );
}
HB_FUNC( HB_DBG_SETWATCH )
{
void * ptr = hb_parptr( 1 );
if( ptr )
hb_dbgSetWatch( ptr, hb_parni( 2 ), hb_parc( 3 ), hb_parl( 4 ) );
}

View File

@@ -80,6 +80,7 @@
#include "setcurs.ch"
#include "getexit.ch"
#include "hbdebug.ch" // for "nMode" of __dbgEntry
#include "hbgtinfo.ch"
#define NTRIM(x) (ALLTRIM(STR(x)))
@@ -153,9 +154,7 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3, uParam4, uParam5 ) // d
DO CASE
CASE nMode == HB_DBG_GETENTRY
HB_INLINE(){
hb_vm_pFunDbgEntry = hb_dbgEntry;
}
HB_DBG_SetEntry()
CASE nMode == HB_DBG_ACTIVATE
IF s_oDebugger == NIL
@@ -169,9 +168,7 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3, uParam4, uParam5 ) // d
s_oDebugger:aBreakPoints := uParam5
IF bStartup
IF s_oDebugger:lRunAtStartup
HB_INLINE( uParam1 ){
hb_dbgSetGo( hb_parptr( 1 ) );
}
HB_DBG_SetGo( uParam1 )
RETURN
ENDIF
ENDIF
@@ -188,16 +185,13 @@ CLASS TDebugger
DATA oPullDown
DATA oWndCode, oWndCommand, oWndStack, oWndVars
DATA oBar, oBrwText, cPrgName, oBrwStack, oBrwVars, aVars
DATA cImage
DATA cAppImage, nAppRow, nAppCol, cAppColors, nAppCursor, nAppDispCount
DATA nAppDispCount
DATA nAppLastKey, bAppInkeyAfter, bAppInkeyBefore, bAppClassScope
DATA nAppCTWindow, nAppDirCase, nAppFileCase, oAppGetList, nAppTypeAhead
DATA nAppDirCase, nAppFileCase, oAppGetList, nAppTypeAhead
DATA nMaxRow, nMaxCol
DATA nAppMaxRow, nAppMaxCol //x new: app's maxrow/col
DATA nAppWindow
DATA nDebuggerWindow
DATA hUserWindow, hDebuggerWindow
DATA lDebuggerWindowIsOpen INIT .F.
DATA aBreakPoints
DATA aCallStack //stack of procedures with debug info
@@ -222,7 +216,6 @@ CLASS TDebugger
DATA lLineNumbers INIT .T.
//x for gtwvw:
DATA lDebuggerWindowIsOpen INIT .F.
DATA cGTVersion INIT ' '
METHOD New()
@@ -293,7 +286,7 @@ CLASS TDebugger
METHOD RestoreAppState()
METHOD RestoreSettings()
METHOD RunAtStartup() INLINE ::lRunAtStartup := ::oPullDown:GetItemByIdent( "ALTD" ):checked := !::lRunAtStartup
METHOD SaveAppScreen( lRestore )
METHOD SaveAppScreen()
METHOD SaveAppState()
METHOD SaveSettings()
METHOD Show()
@@ -354,7 +347,6 @@ CLASS TDebugger
METHOD ResizeWindows( oWindow )
METHOD NotSupported() INLINE Alert( "Not implemented yet!" )
//x for gtwvw:
METHOD OpenDebuggerWindow()
METHOD CloseDebuggerWindow()
@@ -420,10 +412,6 @@ METHOD New() CLASS TDebugger
::nMaxCol := MaxCol()
#endif
/* Store the initial screen dimensions for now */
::nAppMaxRow := MaxRow()
::nAppMaxCol := MaxCol()
::oPullDown := __dbgBuildMenu( Self )
::oWndCode := TDbWindow():New( 1, 0, ::nMaxRow - 6, ::nMaxCol )
@@ -445,38 +433,30 @@ METHOD New() CLASS TDebugger
::lGo := ::lRunAtStartup
return Self
//x new
METHOD OpenDebuggerWindow() CLASS TDebugger
if ::cGTVersion == 'WVW'
IF !::lDebuggerWindowIsOpen
::nAppMaxRow := maxrow()
::nAppMaxCol := maxcol()
::nAppWindow := hb_ExecFromArray( 'WVW_NSETCURWINDOW' )
::nDebuggerWindow := hb_ExecFromArray( 'WVW_NOPENWINDOW', ;
{ "Debugger", DEBUGGER_MINROW, DEBUGGER_MINCOL, ;
DEBUGGER_MAXROW, DEBUGGER_MAXCOL } )
::lDebuggerWindowIsOpen := .t.
ENDIF
hb_ExecFromArray( 'WVW_NSETCURWINDOW', { ::nDebuggerWindow } )
return nil
if !::lDebuggerWindowIsOpen
::hUserWindow = hb_gtInfo( GTI_GETWIN )
if ::hDebuggerWindow == NIL
::hDebuggerWindow := hb_gtInfo( GTI_GETWIN, ;
{ "Debugger", DEBUGGER_MINROW, DEBUGGER_MINCOL, ;
DEBUGGER_MAXROW, DEBUGGER_MAXCOL } )
else
hb_gtInfo( GTI_SETWIN, ::hDebuggerWindow )
endif
::lDebuggerWindowIsOpen := .t.
endif
return nil
//x new
METHOD CloseDebuggerWindow() CLASS Tdebugger
if ::cGTVersion == 'WVW'
//if !::lDebuggerWindowIsOpen
hb_ExecFromArray( 'WVW_NSETCURWINDOW', { ::nAppWindow } )
return nil
//endif
/*hb_ExecFromArray( 'WVW_LCLOSEWINDOW' )
if ::lDebuggerWindowIsOpen
::hDebuggerWindow = hb_gtInfo( GTI_GETWIN )
hb_gtInfo( GTI_SETWIN, ::hUserWindow )
::lDebuggerWindowIsOpen := .f.
if !( type( 'WVW_SHOWWINDOW()' ) == 'U' )
hb_ExecFromArray('WVW_SHOWWINDOW')
endif*/
endif
return nil
@@ -676,9 +656,7 @@ return nil
METHOD CodeblockTrace()
::oPullDown:GetItemByIdent( "CODEBLOCK" ):checked := ::lCBTrace := ! ::lCBTrace
HB_INLINE( ::pInfo, ::lCBTrace ){
hb_dbgSetCBTrace( hb_parptr( 1 ), hb_parl( 2 ) );
}
HB_DBG_SetCBTrace( ::pInfo, ::lCBTrace )
RETURN NIL
@@ -1234,29 +1212,7 @@ METHOD GetExprValue( xExpr, lValid ) CLASS TDebugger
lValid := .F.
bOldErrorBlock := ErrorBlock( {|oErr| Break( oErr ) } )
BEGIN SEQUENCE
xResult := HB_INLINE( ::pInfo, xExpr, @lValid ){
PHB_ITEM item;
if ( ISCHAR( 2 ) )
{
item = hb_dbgGetExpressionValue( hb_parptr( 1 ), hb_parc( 2 ) );
}
else
{
item = hb_dbgGetWatchValue( hb_parptr( 1 ), hb_parni( 2 ) - 1 );
}
if ( item )
{
hb_itemRelease( hb_itemReturn( item ) );
hb_storl( TRUE, 3 );
}
else
{
hb_storl( FALSE, 3 );
hb_ret();
}
}
xResult := HB_DBG_GetExprValue( ::pInfo, xExpr, @lValid )
IF !lValid
xResult := "Syntax error"
ENDIF
@@ -1273,17 +1229,13 @@ RETURN xResult
METHOD GetSourceFiles() CLASS TDebugger
RETURN HB_INLINE( ::pInfo ){
hb_itemRelease( hb_itemReturn( hb_dbgGetSourceFiles( hb_parptr( 1 ) ) ) );
}
RETURN HB_DBG_GetSourceFiles( ::pInfo )
METHOD Global() CLASS TDebugger
::lShowGlobals := ! ::lShowGlobals
::RefreshVars()
return nil
RETURN NIL
METHOD Go() CLASS TDebugger
@@ -1294,9 +1246,7 @@ METHOD Go() CLASS TDebugger
ENDIF
::RestoreAppScreen()
::RestoreAppState()
HB_INLINE( ::pInfo ){
hb_dbgSetGo( hb_parptr( 1 ) );
}
HB_DBG_SetGo( ::pInfo )
::Exit()
RETURN NIL
@@ -1488,17 +1438,7 @@ METHOD HandleEvent() CLASS TDebugger
return nil
METHOD Hide() CLASS TDebugger
::CloseDebuggerWindow() //x gtwvw
if !(::cGTVersion=='WVW') //#IFNDEF __GTWVW__
//x was: RestScreen( ,,,, ::cAppImage )
RestScreen( 0,0,::nAppMaxRow,::nAppMaxCol, ::cAppImage )
endif //#ENDIF
::cAppImage := nil
SetColor( ::cAppColors )
SetCursor( ::nAppCursor )
::CloseDebuggerWindow()
return nil
@@ -1685,9 +1625,7 @@ return nil
METHOD IsValidStopLine( cName, nLine ) CLASS TDebugger
RETURN HB_INLINE( ::pInfo, cName, nLine ){
hb_retl( hb_dbgIsValidStopLine( hb_parptr( 1 ), hb_parc( 2 ), hb_parni( 3 ) ) );
}
RETURN HB_DBG_IsValidStopLine( ::pInfo, cName, nLine )
METHOD LineNumbers( lLineNumbers ) CLASS TDebugger
@@ -1931,9 +1869,7 @@ return nil
METHOD NextRoutine() CLASS TDebugger
::RestoreAppScreen()
::RestoreAppState()
HB_INLINE( ::pInfo ){
hb_dbgSetNextRoutine( hb_parptr( 1 ) );
}
HB_DBG_SetNextRoutine( ::pInfo )
::Exit()
RETURN self
@@ -2089,9 +2025,7 @@ return nil
METHOD Quit() CLASS TDebugger
::Exit()
::Hide()
HB_INLINE( ::pInfo ){
hb_dbgSetQuit( hb_parptr( 1 ) );
}
HB_DBG_SetQuit( ::pInfo )
s_oDebugger := NIL
__QUIT()
RETURN NIL
@@ -2243,30 +2177,9 @@ RETURN self
METHOD RestoreAppScreen() CLASS TDebugger
LOCAL i
local lWindowed := ::lDebuggerWindowIsOpen
::cImage := SaveScreen()
::CloseDebuggerWindow()
if !lWindowed //x
DispBegin()
RestScreen( 0, 0, ::nMaxRow, ::nMaxCol, ::cAppImage )
IF !Empty( ::nAppCTWindow )
/* Don't link libct automatically... */
HB_INLINE( ::nAppCTWindow ){
/* hb_ctWSelect( hb_parni( 1 ) ); */
}
ENDIF
else //x
::CloseDebuggerWindow() //x
endif
SetPos( ::nAppRow, ::nAppCol )
SetColor( ::cAppColors )
SetCursor( ::nAppCursor )
if !lWindowed //x
DispEnd()
endif
FOR i := 1 TO ::nAppDispCount
DispBegin()
NEXT
@@ -2299,52 +2212,18 @@ METHOD RestoreSettings() CLASS TDebugger
return nil
METHOD SaveAppScreen( lRestore ) CLASS TDebugger
METHOD SaveAppScreen() CLASS TDebugger
LOCAL nRight, nTop, i
IF lRestore == NIL
lRestore := .T.
ENDIF
::nAppDispCount := DispCount()
FOR i := 1 TO ::nAppDispCount
DispEnd()
NEXT
//x these two lines are moved to after SetCursor()
//x DispBegin()
//x ::cAppImage := SaveScreen()
::OpenDebuggerWindow()
/* Get cursor coordinates INSIDE ct window */
::nAppRow := Row()
::nAppCol := Col()
::cAppColors := SetColor()
/* We don't want to auto-link libct... */
::nAppCTWindow := HB_INLINE(){
/* hb_retni( hb_ctWSelect( -1 ) ); */
/* hb_ctWSelect( 0 ); */
}
::nAppCursor := SetCursor( SC_NONE )
//x more...
::nAppMaxRow := maxrow()
::nAppMaxCol := maxcol()
if !( ::cGTVersion == 'WVW' )
::cAppImage := SaveScreen()
endif
::OpenDebuggerWindow() //x this will also assign ::nMaxRow/col
DispBegin()
IF lRestore
//x was: RestScreen( 0, 0, ::nMaxRow, ::nMaxCol, ::cImage )
RestScreen( , , , , ::cImage )
ENDIF
IF ::nMaxRow != MaxRow() .OR. ::nMaxCol != MaxCol()
DispBegin()
::nMaxRow := MaxRow()
::nMaxCol := MaxCol()
nTop := 1
@@ -2371,8 +2250,8 @@ METHOD SaveAppScreen( lRestore ) CLASS TDebugger
::oWndCode:Resize( nTop, 0, ::nMaxRow - 6, nRight )
::oPullDown:Refresh()
::BarDisplay()
DispEnd()
ENDIF
DispEnd()
return nil
@@ -2497,8 +2376,7 @@ return nil
METHOD Show() CLASS TDebugger
::SaveAppScreen( .F. )
::SaveAppScreen()
::oPullDown:Display()
::oWndCode:Show( .t. )
::oWndCommand:Show()
@@ -2519,29 +2397,15 @@ RETURN NIL
METHOD ShowAppScreen() CLASS TDebugger
::cImage := SaveScreen()
::CloseDebuggerWindow() //x gtwvw
if !( ::cGTVersion == 'WVW' )
RestScreen( 0, 0, ::nAppMaxRow, ::nAppMaxCol, ::cAppImage )
endif
::CloseDebuggerWindow()
if LastKey() == K_LBUTTONDOWN
InKey( 0, INKEY_ALL )
InKey( 0, INKEY_ALL )
else
InKey( 0, INKEY_ALL )
endif
while LastKey() == K_MOUSEMOVE
InKey( 0, INKEY_ALL )
while InKey( 0, INKEY_ALL ) == K_MOUSEMOVE
end
::OpenDebuggerWindow() //x
//x was: RestScreen( 0, 0, ::nMaxRow, ::nMaxCol, ::cImage )
RestScreen( , , , , ::cImage )
::OpenDebuggerWindow()
return nil
@@ -2859,9 +2723,7 @@ METHOD ToCursor() CLASS TDebugger
LOCAL cName := strip_path( ::cPrgName ), nLine := ::oBrwText:nRow
IF ::IsValidStopLine( cName, nLine )
HB_INLINE( ::pInfo, strip_path( ::cPrgName ), ::oBrwText:nRow ){
hb_dbgSetToCursor( hb_parptr( 1 ), hb_parc( 2 ), hb_parni( 3 ) );
}
HB_DBG_SetToCursor( ::pInfo, strip_path( ::cPrgName ), ::oBrwText:nRow )
::RestoreAppScreen()
::RestoreAppState()
::Exit()
@@ -2893,18 +2755,14 @@ METHOD ToggleBreakPoint( nLine, cFileName ) CLASS TDebugger
if nAt == 0
AAdd( ::aBreakPoints, { nLine, cFileName } ) // it was nLine
HB_INLINE( ::pInfo, cFileName, nLine ){
hb_dbgAddBreak( hb_parptr( 1 ), hb_parc( 2 ), hb_parni( 3 ), NULL );
}
HB_DBG_AddBreak( ::pInfo, cFileName, nLine )
IF FILENAME_EQUAL( cFileName, strip_path( ::cPrgName ) )
::oBrwText:ToggleBreakPoint( nLine, .T. )
ENDIF
else
ADel( ::aBreakPoints, nAt )
ASize( ::aBreakPoints, Len( ::aBreakPoints ) - 1 )
HB_INLINE( ::pInfo, nAt - 1 ){
hb_dbgDelBreak( hb_parptr( 1 ), hb_parni( 2 ) );
}
HB_DBG_DelBreak( ::pInfo, nAt - 1 )
IF FILENAME_EQUAL( cFileName, strip_path( ::cPrgName ) )
::oBrwText:ToggleBreakPoint( nLine, .F. )
ENDIF
@@ -2916,9 +2774,7 @@ return nil
METHOD Trace() CLASS TDebugger
HB_INLINE( ::pInfo ){
hb_dbgSetTrace( hb_parptr( 1 ) );
}
HB_DBG_SetTrace( ::pInfo )
::Step() //forces a Step()
RETURN Self
@@ -2939,9 +2795,7 @@ METHOD TracepointAdd( cExpr ) CLASS TDebugger
ENDIF
aWatch := {"tp", cExpr, NIL}
::RestoreAppState()
HB_INLINE( ::pInfo, cExpr ){
hb_dbgAddWatch( hb_parptr( 1 ), hb_parc( 2 ), TRUE );
}
HB_DBG_AddWatch( ::pInfo, cExpr, .T. )
::SaveAppState()
AADD( ::aWatch, aWatch )
::WatchpointsShow()
@@ -3104,9 +2958,7 @@ METHOD WatchpointAdd( cExpr ) CLASS TDebugger
RETURN self
ENDIF
aWatch := { "wp", cExpr }
HB_INLINE( ::pInfo, cExpr ){
hb_dbgAddWatch( hb_parptr( 1 ), hb_parc( 2 ), FALSE );
}
HB_DBG_AddWatch( ::pInfo, cExpr, .F. )
AADD( ::aWatch, aWatch )
::WatchpointsShow()
@@ -3125,9 +2977,7 @@ METHOD WatchpointDel( nPos ) CLASS TDebugger
IF( LastKey() != K_ESC )
IF( nPos >=0 .AND. nPos < LEN(::aWatch) )
::oBrwPnt:gotop()
HB_INLINE( ::pInfo, nPos ){
hb_dbgDelWatch( hb_parptr( 1 ), hb_parni( 2 ) );
}
HB_DBG_DelWatch( ::pInfo, nPos )
ADEL( ::aWatch, nPos+1 )
ASIZE( ::aWatch, LEN(::aWatch)-1 )
IF( LEN(::aWatch) == 0 )
@@ -3156,9 +3006,7 @@ METHOD WatchpointEdit( nPos ) CLASS TDebugger
RETURN self
ENDIF
aWatch := { "wp", cExpr }
HB_INLINE( ::pInfo, nPos - 1, cExpr ){
hb_dbgSetWatch( hb_parptr( 1 ), hb_parni( 2 ), hb_parc( 3 ), FALSE );
}
HB_DBG_SetWatch( ::pInfo, nPos - 1, cExpr, .F. )
::aWatch[ nPos ] := aWatch
::WatchpointsShow()
@@ -3282,8 +3130,8 @@ METHOD WatchpointsShow() CLASS TDebugger
if ! ::oWndPnt:lVisible .OR. lRepaint
::ResizeWindows( ::oWndPnt )
endif
DispEnd()
endif
DispEnd()
return nil

View File

@@ -1480,15 +1480,65 @@ static BOOL hb_gt_def_Info( int iType, PHB_GT_INFO pInfo )
case GTI_VIEWMAXHEIGHT:
pInfo->pResult = hb_itemPutNInt( pInfo->pResult, hb_gt_MaxRow() );
break;
/*
TODO:
case GTI_GETWIN:
// save screen buffer, cursor shape and possition
case GTI_SETWIN:
// restore screen buffer, cursor shape and possition
case GTI_NEWWIN:
// clear screen area, set default cursor shape and position
*/
case GTI_NEWWIN: /* clear screen area, set default cursor shape and position */
{
/* Clear screen */
hb_gt_DispBegin();
hb_gt_Scroll( 0, 0, hb_gt_MaxRow(), hb_gt_MaxCol(), ( BYTE ) hb_gt_GetColor(), hb_gt_GetClearChar(), 0, 0 );
hb_gt_SetPos( 0, 0 );
hb_gt_SetCursorStyle( SC_NORMAL );
hb_gt_DispEnd();
hb_gt_Flush();
/* no break; */
}
case GTI_GETWIN: /* save screen buffer, cursor shape and possition */
{
int iRow, iCol;
ULONG ulSize;
if( !pInfo->pResult )
pInfo->pResult = hb_itemNew( NULL );
hb_arrayNew( pInfo->pResult, 7 );
hb_gt_GetPos( &iRow, &iCol );
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 1 ), iRow );
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 2 ), iCol );
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 3 ), hb_gt_GetCursorStyle() );
hb_itemPutC( hb_arrayGetItemPtr( pInfo->pResult, 4 ), hb_conSetColor( NULL ) );
iRow = hb_gt_MaxRow();
iCol = hb_gt_MaxCol();
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 5 ), iRow );
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 6 ), iCol );
ulSize = hb_gt_RectSize( 0, 0, iRow, iCol );
if( ulSize )
{
BYTE * pBuffer = ( BYTE * ) hb_xgrab( ulSize + 1 );
hb_gt_Save( 0, 0, iRow, iCol, pBuffer );
hb_itemPutCPtr( hb_arrayGetItemPtr( pInfo->pResult, 7 ),
( char * ) pBuffer, ulSize );
}
break;
}
case GTI_SETWIN: /* restore screen buffer, cursor shape and possition */
if( hb_arrayLen( pInfo->pNewVal ) == 7 )
{
hb_gt_DispBegin();
if( hb_arrayGetCLen( pInfo->pNewVal, 7 ) > 0 )
{
hb_gt_Rest( 0, 0, hb_arrayGetNI( pInfo->pNewVal, 5 ),
hb_arrayGetNI( pInfo->pNewVal, 6 ),
( BYTE * ) hb_arrayGetCPtr( pInfo->pNewVal, 7 ) );
}
hb_gt_SetPos( hb_arrayGetNI( pInfo->pNewVal, 1 ),
hb_arrayGetNI( pInfo->pNewVal, 2 ) );
hb_gt_SetCursorStyle( hb_arrayGetNI( pInfo->pNewVal, 3 ) );
hb_conSetColor( hb_arrayGetCPtr( pInfo->pNewVal, 4 ) );
hb_gt_DispEnd();
hb_gt_Flush();
}
break;
default:
return FALSE;

View File

@@ -26,7 +26,6 @@ C_SOURCES=\
break.c \
classes.c \
cmdarg.c \
dbgentry.c \
debug.c \
dynlibhb.c \
dynsym.c \

View File

@@ -157,6 +157,7 @@ static void hb_vmSwapAlias( void ); /* swaps items on the eval stac
/* Execution */
static HARBOUR hb_vmDoBlock( void ); /* executes a codeblock */
static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame );
static void hb_vmDebuggerExit( void ); /* shuts down the debugger */
static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ); /* locals and parameters index and name information for the debugger */
static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ); /* statics vars information for the debugger */
@@ -180,13 +181,14 @@ static void hb_vmPushMacroBlock( BYTE * pCode, ULONG ulSize, USHORT usParams
static void hb_vmPushDoubleConst( double dNumber, int iWidth, int iDec ); /* Pushes a double constant (pcode) */
static void hb_vmPushLocal( int iLocal ); /* pushes the containts of a local onto the stack */
static void hb_vmPushLocalByRef( int iLocal ); /* pushes a local by refrence onto the stack */
static void hb_vmPushLongConst( long lNumber ); /* Pushes a long constant (pcode) */
static void hb_vmPushHBLong( HB_LONG lNumber ); /* pushes a HB_LONG number onto the stack */
#if !defined( HB_LONG_LONG_OFF )
static void hb_vmPushLongLongConst( LONGLONG lNumber ); /* Pushes a long long constant (pcode) */
#endif
#if HB_INT_MAX >= INT32_MAX
static void hb_vmPushIntegerConst( int iNumber ); /* Pushes a int constant (pcode) */
#else
static void hb_vmPushLongConst( long lNumber ); /* Pushes a long constant (pcode) */
#endif
static void hb_vmPushNumInt( HB_LONG lNumber ); /* pushes a number on to the stack and decides if it is integer or HB_LONG */
static void hb_vmPushNumType( double dNumber, int iDec, int iType1, int iType2 ); /* pushes a number on to the stack and decides if it is integer, long or double */
@@ -245,10 +247,8 @@ static BOOL s_fCloneSym = FALSE;/* clone registered symbol tables */
static BOOL s_bDebugging;
static BOOL s_bDebugRequest; /* debugger invoked via the VM */
static BOOL s_bDebugShowLines; /* update source code line on the debugger display */
static BOOL s_bDebuggerIsWorking; /* to know when __DBGENTRY is beeing invoked */
static PHB_DYNS s_pDynsDbgEntry = NULL; /* Cached __DBGENTRY symbol */
HB_EXPORT HB_DBGENTRY_FUNC hb_vm_pFunDbgEntry = NULL; /* C level debugger entry */
static HB_DBGENTRY_FUNC s_pFunDbgEntry; /* C level debugger entry */
/* Various compatibility flags
*/
@@ -372,8 +372,6 @@ HB_EXPORT void hb_vmInit( BOOL bStartMainProc )
s_aStatics.type = HB_IT_NIL;
s_bDebugging = FALSE;
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = FALSE;
hb_vmSymbolInit_RT(); /* initialize symbol table with runtime support functions */
@@ -412,13 +410,13 @@ HB_EXPORT void hb_vmInit( BOOL bStartMainProc )
}
#endif
if( s_pDynsDbgEntry && !hb_vm_pFunDbgEntry )
if( s_pDynsDbgEntry )
{
/* Try to get C dbgEntry() function pointer */
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_GETENTRY );
hb_vmDo( 1 );
if( !s_pFunDbgEntry )
hb_vmDebugEntry( HB_DBG_GETENTRY, 0, NULL, 0, 0 );
if( !s_pFunDbgEntry )
s_pFunDbgEntry = hb_vmDebugEntry;
}
/* Call functions that initializes static variables
@@ -1076,7 +1074,7 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo));
hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
if( s_bDebugging && s_bDebugShowLines )
if( s_bDebugging )
hb_vmDebuggerShowLine( hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo );
w += 3;
break;
@@ -5015,6 +5013,75 @@ void hb_vmFunction( USHORT uiParams )
}
static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebugEntry"));
HB_SYMBOL_UNUSED( nFrame );
switch( nMode )
{
case HB_DBG_MODULENAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_MODULENAME );
hb_vmPushString( szName, strlen( szName ) );
hb_vmDo( 2 );
break;
case HB_DBG_LOCALNAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_LOCALNAME );
hb_vmPushInteger( nIndex );
hb_vmPushString( szName, strlen( szName ) );
hb_vmDo( 3 );
break;
case HB_DBG_STATICNAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_STATICNAME );
hb_vmPushLong( hb_stackGetStaticsBase() ); /* current static frame */
hb_vmPushInteger( nIndex ); /* variable index */
hb_vmPushString( szName, strlen( szName ) );
hb_vmDo( 4 );
break;
case HB_DBG_ENDPROC:
hb_stackPushReturn(); /* saves the previous returned value */
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_ENDPROC );
hb_vmDo( 1 );
hb_stackPopReturn(); /* restores the previous returned value */
break;
case HB_DBG_SHOWLINE:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_SHOWLINE );
hb_vmPushInteger( nLine );
hb_vmDo( 2 );
break;
case HB_DBG_GETENTRY:
/* Try to get C dbgEntry() function pointer */
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_GETENTRY );
hb_vmDo( 1 );
break;
case HB_DBG_VMQUIT:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
hb_vmPushInteger( HB_DBG_VMQUIT );
hb_vmDo( 1 );
break;
}
}
static void hb_vmDummyDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmDummyDebugEntry"));
@@ -5031,21 +5098,14 @@ static void hb_vmDebuggerExit( void )
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerExit"));
/* is debugger linked ? */
if( s_pDynsDbgEntry )
if( s_pFunDbgEntry )
{
s_bDebugging = FALSE;
/* inform debugger that we are quitting now */
if ( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_VMQUIT, 0, NULL, 0, 0 );
else
{
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_VMQUIT );
hb_vmDo( 1 );
}
s_pFunDbgEntry( HB_DBG_VMQUIT, 0, NULL, 0, 0 );
/* set dummy debugger function to avoid debugger activation in .prg
* destructors if any */
hb_vm_pFunDbgEntry = hb_vmDummyDebugEntry;
s_pFunDbgEntry = hb_vmDummyDebugEntry;
}
}
@@ -5053,24 +5113,11 @@ static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ) /* locals and p
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmLocalName(%hu, %s)", uiLocal, szLocalName));
if( s_pDynsDbgEntry && s_bDebugging )
if( s_bDebugging )
{
s_bDebugging = FALSE;
s_pFunDbgEntry( HB_DBG_LOCALNAME, 0, szLocalName, uiLocal, 0 );
s_bDebugging = TRUE;
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = TRUE;
if ( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_LOCALNAME, 0, szLocalName, uiLocal, 0 );
else
{
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_LOCALNAME );
hb_vmPushLongConst( uiLocal );
hb_vmPushString( szLocalName, strlen( szLocalName ) );
hb_vmDo( 3 );
}
s_bDebuggerIsWorking = FALSE;
s_bDebugShowLines = TRUE;
}
}
@@ -5080,25 +5127,11 @@ static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticNam
HB_SYMBOL_UNUSED( bIsGlobal );
if( s_pDynsDbgEntry && s_bDebugging )
if( s_bDebugging )
{
s_bDebugging = FALSE;
s_pFunDbgEntry( HB_DBG_STATICNAME, 0, szStaticName, uiStatic, hb_stackGetStaticsBase() );
s_bDebugging = TRUE;
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = TRUE;
if ( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_STATICNAME, 0, szStaticName, uiStatic, hb_stackGetStaticsBase() );
else
{
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_STATICNAME );
hb_vmPushLongConst( hb_stackGetStaticsBase() ); /* current static frame */
hb_vmPushLongConst( uiStatic ); /* variable index */
hb_vmPushString( szStaticName, strlen( szStaticName ) );
hb_vmDo( 4 );
}
s_bDebuggerIsWorking = FALSE;
s_bDebugShowLines = TRUE;
}
}
@@ -5106,26 +5139,33 @@ static void hb_vmModuleName( char * szModuleName ) /* PRG and function name info
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmModuleName(%s)", szModuleName));
if( s_pDynsDbgEntry )
if( s_pFunDbgEntry )
{
s_bDebugging = FALSE;
s_pFunDbgEntry( HB_DBG_MODULENAME, 0, szModuleName, 0, 0 );
s_bDebugging = TRUE;
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = TRUE;
if ( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_MODULENAME, 0, szModuleName, 0, 0 );
else
{
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_MODULENAME );
hb_vmPushString( szModuleName, strlen( szModuleName ) );
hb_vmDo( 2 );
}
s_bDebuggerIsWorking = FALSE;
s_bDebugShowLines = TRUE;
}
}
static void hb_vmDebuggerEndProc( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerEndProc()"));
s_bDebugging = FALSE;
s_pFunDbgEntry( HB_DBG_ENDPROC, 0, NULL, 0, 0 );
}
static void hb_vmDebuggerShowLine( USHORT uiLine ) /* makes the debugger shows a specific source code line */
{
BOOL bDebugging = s_bDebugging;
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerShowLine(%hu)", uiLine));
s_bDebugging = FALSE;
s_pFunDbgEntry( HB_DBG_SHOWLINE, uiLine, NULL, 0, 0 );
s_bDebugging = bDebugging;
}
static void hb_vmFrame( USHORT usLocals, BYTE bParams )
{
int iTotal, iExtra;
@@ -5211,51 +5251,6 @@ static void hb_vmRetValue( void )
hb_stackPopReturn();
}
static void hb_vmDebuggerEndProc( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerEndProc()"));
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = TRUE;
if( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_ENDPROC, 0, NULL, 0, 0 );
else
{
hb_stackPushReturn(); /* saves the previous returned value */
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_ENDPROC );
hb_vmDo( 1 );
hb_stackPopReturn(); /* restores the previous returned value */
}
s_bDebuggerIsWorking = FALSE;
s_bDebugShowLines = TRUE;
}
static void hb_vmDebuggerShowLine( USHORT uiLine ) /* makes the debugger shows a specific source code line */
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerShowLine(%hu)", uiLine));
s_bDebugShowLines = FALSE;
s_bDebuggerIsWorking = TRUE;
if ( hb_vm_pFunDbgEntry )
hb_vm_pFunDbgEntry( HB_DBG_SHOWLINE, uiLine, NULL, 0, 0 );
else
{
hb_vmPushSymbol( s_pDynsDbgEntry->pSymbol );
hb_vmPushNil();
hb_vmPushLongConst( HB_DBG_SHOWLINE );
hb_vmPushInteger( uiLine );
hb_vmDo( 2 );
}
s_bDebuggerIsWorking = FALSE;
s_bDebugShowLines = TRUE;
}
/* ------------------------------- */
/* Push */
/* ------------------------------- */
@@ -5363,8 +5358,20 @@ static void hb_vmPushIntegerConst( int iNumber )
pItem->item.asInteger.value = iNumber;
pItem->item.asInteger.length = hb_vmCalcIntWidth( iNumber );
}
#else
static void hb_vmPushLongConst( long lNumber )
{
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLongConst(%ld)", lNumber));
pItem->type = HB_IT_LONG;
pItem->item.asLong.value = ( HB_LONG ) lNumber;
pItem->item.asLong.length = hb_vmCalcIntWidth( lNumber );
}
#endif
HB_EXPORT void hb_vmPushLong( long lNumber )
{
PHB_ITEM pItem = hb_stackAllocItem();
@@ -5382,23 +5389,6 @@ HB_EXPORT void hb_vmPushLong( long lNumber )
#endif
}
static void hb_vmPushLongConst( long lNumber )
{
PHB_ITEM pItem = hb_stackAllocItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLongConst(%ld)", lNumber));
#if HB_INT_MAX >= LONG_MAX
pItem->type = HB_IT_INTEGER;
pItem->item.asInteger.value = ( int ) lNumber;
pItem->item.asInteger.length = hb_vmCalcIntWidth( lNumber );
#else
pItem->type = HB_IT_LONG;
pItem->item.asLong.value = ( HB_LONG ) lNumber;
pItem->item.asLong.length = hb_vmCalcIntWidth( lNumber );
#endif
}
static void hb_vmPushHBLong( HB_LONG lNumber )
{
PHB_ITEM pItem = hb_stackAllocItem();
@@ -7044,7 +7034,7 @@ HB_EXPORT void hb_xvmSetLine( USHORT uiLine )
HB_TRACE(HB_TR_DEBUG, ("hb_xvmSetLine(%hu)", uiLine));
hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo = uiLine;
if( s_bDebugging && s_bDebugShowLines )
if( s_bDebugging )
hb_vmDebuggerShowLine( uiLine );
}
@@ -9092,6 +9082,16 @@ HB_EXPORT BOOL hb_dbg_InvokeDebug( BOOL bInvoke )
return bRequest;
}
HB_EXPORT HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry )
{
HB_DBGENTRY_FUNC pPrevFunc = s_pFunDbgEntry;
HB_TRACE(HB_TR_DEBUG, ("hb_dbg_SetEntry(%p)", pFunDbgEntry));
s_pFunDbgEntry = pFunDbgEntry;
return pPrevFunc;
}
HB_EXPORT PHB_ITEM hb_dbg_vmVarSGet( int nStatic, int nOffset )
{
return hb_arrayGetItemPtr( &s_aStatics, nStatic + nOffset );