From a4e9a6a942d11cc3afd5df3f3c407cae06cb3fed Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Wed, 21 Jan 2004 14:28:10 +0000 Subject: [PATCH] 2004-01-21 15:30 UTC+0100 Ryszard Glab * source/compiler/harbour.y *fixed generation of line number's pcode related to the debugger * source/debug/dbgmenu.prg * source/debug/debugger.prg *fixed TRACE command *added support for 'Codeblock trace' option * other minor fixes to make the debugger usable Additionally in my previous commit (2004-01-20 19:15) * source/vm/hvm.c *added call for hb_inkeyPoll to the main pcode execution loop to correctly support Alt-D, Alt-C and Ctrl-C requests (only if HB_GUI is not defined) - it is called every 256 opcodes --- harbour/ChangeLog | 18 +++++++++++++ harbour/source/compiler/harbour.y | 8 +++--- harbour/source/debug/dbgmenu.prg | 4 ++- harbour/source/debug/debugger.prg | 43 +++++++++++++++++++------------ harbour/source/vm/hvm.c | 16 +----------- 5 files changed, 53 insertions(+), 36 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0932141863..8f4c53cfab 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,24 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-01-21 15:30 UTC+0100 Ryszard Glab + * source/compiler/harbour.y + *fixed generation of line number's pcode related to + the debugger + + * source/debug/dbgmenu.prg + * source/debug/debugger.prg + *fixed TRACE command + *added support for 'Codeblock trace' option + * other minor fixes to make the debugger usable + + Additionally in my previous commit (2004-01-20 19:15) + * source/vm/hvm.c + *added call for hb_inkeyPoll to the main pcode execution + loop to correctly support Alt-D, Alt-C and Ctrl-C + requests (only if HB_GUI is not defined) - it is + called every 256 opcodes + 2004-01-20 19:15 UTC+0100 Ryszard Glab * include/hbcomp.h * include/hbexprb.c diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index d4ae2d2964..ac76434821 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -405,13 +405,13 @@ Statement : ExecFlow { hb_comp_bDontGenLineNum = TRUE; } CrlfStmnt { } } | PUBLIC { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PUBLIC; } ExtVarList - { hb_compRTVariableGen( "__MVPUBLIC" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } CrlfStmnt + { hb_compRTVariableGen( "__MVPUBLIC" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } Crlf | PRIVATE { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PRIVATE; } ExtVarList - { hb_compRTVariableGen( "__MVPRIVATE" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } CrlfStmnt + { hb_compRTVariableGen( "__MVPRIVATE" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } Crlf - | EXIT { hb_comp_bDontGenLineNum = TRUE; hb_compLoopExit(); } CrlfStmnt { hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } - | LOOP { hb_comp_bDontGenLineNum = TRUE; hb_compLoopLoop(); } CrlfStmnt { hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } + | EXIT { hb_comp_bDontGenLineNum = !hb_comp_bDebugInfo; } CrlfStmnt { hb_compLoopExit(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } + | LOOP { hb_comp_bDontGenLineNum = !hb_comp_bDebugInfo; } CrlfStmnt { hb_compLoopLoop(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | EXTERN ExtList Crlf | ANNOUNCE IdentName { if( hb_comp_szAnnounce == NULL ) diff --git a/harbour/source/debug/dbgmenu.prg b/harbour/source/debug/dbgmenu.prg index 77ccfc9d71..59159966dc 100644 --- a/harbour/source/debug/dbgmenu.prg +++ b/harbour/source/debug/dbgmenu.prg @@ -68,6 +68,7 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu local oMonoDisplay local oPublic, oPrivate, oStatic, oLocal, oAll, oSort local oCallStack + local oCBTrace MENU oMenu MENUITEM " ~File " @@ -151,7 +152,8 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu ACTION ( oDebugger:LineNumbers(), oLineNumbers:Toggle() ) CHECKED MENUITEM " ~Exchange Screens" ACTION Alert( "Not implemented yet!" ) MENUITEM " swap on ~Input" ACTION Alert( "Not implemented yet!" ) - MENUITEM " code~Block Trace" ACTION Alert( "Not implemented yet!" ) + MENUITEM oCBTrace PROMPT " code~Block Trace" ; + ACTION ( oDebugger:CodeblockTrace(), oCBTrace:Toggle() ) CHECKED MENUITEM " ~Menu Bar" ACTION Alert( "Not implemented yet!" ) MENUITEM oMonoDisplay PROMPT " mono ~Display" ; ACTION ( oDebugger:MonoDisplay(), oMonoDisplay:Toggle() ) diff --git a/harbour/source/debug/debugger.prg b/harbour/source/debug/debugger.prg index 3bdc8ba66a..abd961a4b5 100644 --- a/harbour/source/debug/debugger.prg +++ b/harbour/source/debug/debugger.prg @@ -128,7 +128,7 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin IF( s_oDebugger == NIL ) s_oDebugger := TDebugger():New() - public __DbgStatics // hb_vmStaticName() and hb_vmLocalName() + public __DbgStatics __DbgStatics := {} ENDIF @@ -138,7 +138,9 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin if s_oDebugger:lTrace //In TRACE mode (step over procedure) IF( s_oDebugger:nTraceLevel < Len( s_oDebugger:aCallStack ) ) - IF( !(s_oDebugger:lTrace := ! s_oDebugger:IsBreakPoint( uParam1, s_oDebugger:aCallStack[1][ CSTACK_MODULE ] )) ) + s_oDebugger:lTrace := (! s_oDebugger:IsBreakPoint( uParam1, s_oDebugger:aCallStack[1][ CSTACK_MODULE ] )) .AND.; + (! InvokeDebug()) + if s_oDebugger:lTrace RETURN ENDIF ELSE @@ -151,6 +153,13 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin s_oDebugger:lGo := ! s_oDebugger:IsBreakPoint( uParam1, s_oDebugger:aCallStack[1][ CSTACK_MODULE ] ) endif + IF( s_oDebugger:lCodeblock ) + IF( !s_oDebugger:lCBTrace ) + s_oDebugger:lCodeblock := .F. + RETURN + ENDIF + ENDIF + s_oDebugger:aCallStack[ 1 ][CSTACK_LINE] := uParam1 if !s_oDebugger:lGo .or. InvokeDebug() s_oDebugger:lGo := .F. @@ -170,7 +179,10 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin cProcName := ProcName( 1 ) nVarIndex := uParam1 cVarName := IIF(valtype(uParam2)=='C',uParam2,'NIL') -/* + + IF Len( s_oDebugger:aCallStack )>0 .AND. valtype( s_oDebugger:aCallStack[ 1, CSTACK_LOCALS ])=='A' + AAdd( s_oDebugger:aCallStack[ 1 ][ CSTACK_LOCALS ], { cVarName, nVarIndex, "Local", cProcName } ) + endif if s_oDebugger:lShowLocals if ( nAt := AScan( s_oDebugger:aVars,; // Is there another var with this name ? { | aVar | aVar[ 1 ] == cVarName } ) ) != 0 @@ -178,14 +190,10 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin else AAdd( s_oDebugger:aVars, { cVarName, nVarIndex, "Local", cProcName } ) endif + if s_oDebugger:oBrwVars != nil + s_oDebugger:oBrwVars:RefreshAll() + endif endif -*/ - IF Len( s_oDebugger:aCallStack )>0 .AND. valtype( s_oDebugger:aCallStack[ 1, CSTACK_LOCALS ])=='A' - AAdd( s_oDebugger:aCallStack[ 1 ][ CSTACK_LOCALS ], { cVarName, nVarIndex, "Local", cProcName } ) - endif -// if s_oDebugger:oBrwVars != nil -// s_oDebugger:oBrwVars:RefreshAll() -// endif case nMode == HB_DBG_STATICNAME nVarIndex := uParam1 @@ -203,7 +211,7 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin IF Len( s_oDebugger:aCallStack )>0 .AND. valtype( s_oDebugger:aCallStack[ 1, CSTACK_STATICS ])=='A' AAdd( s_oDebugger:aCallStack[ 1 ][ CSTACK_STATICS ], { cVarName, nVarIndex, "Static" } ) endif -/* + if s_oDebugger:lShowStatics if ( nAt := AScan( s_oDebugger:aVars,; // Is there another var with this name ? { | aVar | aVar[ 1 ] == cVarName } ) ) != 0 @@ -215,7 +223,7 @@ procedure __dbgEntry( nMode, uParam1, uParam2, uParam3 ) // debugger entry poin s_oDebugger:oBrwVars:RefreshAll() endif endif -*/ + case nMode == HB_DBG_ENDPROC // called from hvm.c hb_vmDebuggerEndProc() if Empty( ProcName( 1 ) ) // ending (_INITSTATICS) return @@ -251,6 +259,7 @@ CLASS TDebugger DATA nTraceLevel //procedure level where TRACE was requested DATA lCodeblock INIT .F. DATA lActive INIT .F. + DATA lCBTrace INIT .T. //stores if codeblock tracing is allowed METHOD New() METHOD Activate() @@ -275,7 +284,7 @@ CLASS TDebugger METHOD EditVar( nVar ) METHOD EndProc() METHOD Exit() INLINE ::lEnd := .t. - METHOD Go() INLINE ::RestoreAppStatus(), ::lGo := .t., DispEnd(), ::Exit() + METHOD Go() INLINE ::RestoreAppStatus(), ::lGo := .t., ::Exit() METHOD GoToLine( nLine ) METHOD HandleEvent() METHOD Hide() @@ -333,6 +342,7 @@ CLASS TDebugger METHOD Trace() INLINE ::lTrace := .t., ::nTraceLevel := Len( ::aCallStack ),; __Keyboard( Chr( 255 ) ) //forces a Step() + METHOD CodeblockTrace() INLINE ::lCBTrace := ! ::lCBTrace METHOD ViewSets() METHOD WndVarsLButtonDown( nMRow, nMCol ) METHOD LineNumbers() // Toggles numbering of source code lines @@ -416,13 +426,13 @@ return Self METHOD Activate() CLASS TDebugger ::SaveAppStatus() - ::loadVars() IF( ! ::lActive ) ::lActive := .T. ::Show() if ::lShowCallStack ::ShowCallStack() endif + ::loadVars() ::ShowVars() // ::RestoreAppStatus() ENDIF @@ -1025,14 +1035,14 @@ METHOD HandleEvent() CLASS TDebugger endif case nKey == K_RBUTTONDOWN - +/* case nKey == K_ESC ::RestoreAppStatus() s_oDebugger := nil s_lExit := .T. DispEnd() ::Exit() - +*/ case nKey == K_UP .or. nKey == K_DOWN .or. nKey == K_HOME .or. ; nKey == K_END .or. nKey == K_ENTER .or. nKey == K_PGDN .or. nKey == K_PGUP oWnd := ::aWindows[ ::nCurrentWindow ] @@ -1862,6 +1872,7 @@ return nil METHOD SaveAppStatus() CLASS TDebugger + DispBegin() ::cAppImage := SaveScreen() ::nAppRow := Row() ::nAppCol := Col() diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 0d45d4c6b6..b3b84bd4d9 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -497,7 +497,7 @@ void HB_EXPORT hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) ULONG ulLastOpcode = 0; /* opcodes profiler support */ ULONG ulPastClock = 0; /* opcodes profiler support */ #ifndef HB_GUI - unsigned int uiPolls = 0; + static unsigned char uiPolls = 0; #endif HB_TRACE(HB_TR_DEBUG, ("hb_vmExecute(%p, %p)", pCode, pSymbols)); @@ -528,20 +528,6 @@ void HB_EXPORT hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) #ifndef HB_GUI if( ++uiPolls == 1 ) hb_inkeyPoll(); - /* - if( hb_set.HB_SET_CANCEL ) - { - static unsigned short s_iCancel = 0; - - if( ++s_iCancel == 65535 ) - { - int ch = hb_gt_ReadKey( hb_set.HB_SET_EVENTMASK ); - - if( (ch == s_VMCancelKey) || (ch == s_VMCancelKeyEx) ) - hb_vmRequestCancel();/ * Request cancellation * / - } - } - */ #endif switch( pCode[ w ] )