2004-01-26 11:45 UTC+0100 Ryszard Glab <rglab@imid.med.pl>

* source/compiler/harbour.c
      *fixed generation of codeblock's pcode with debugging info

   * source/debug/dbgmenu.prg
   * source/debug/dbgtmenu.prg
   * source/debug/dbgtmitm.prg
   * source/debug/dbgtwin.prg
   * source/debug/debugger.prg
   * source/debug/tbrwtext.prg
      *added Tracepoint support
      *added support for PPO files
      *added monitoring of local variables used in a codeblock
      *local variables are displayed correctly when the
      callstack window is browsed
      *other minor fixes

   * source/vm/debug.c
      *renamed '__vm*' functions to 'hb_dbg_*'
      *fixed support for local variables inside of codeblock

   * source/vm/hvm.c
      *added 'hb_dbg_ProcLevel' function which return the
      size of procedure stack calls (the debugger support)
This commit is contained in:
Ryszard Glab
2004-01-26 10:40:18 +00:00
parent 2e7305d69b
commit 152325f856
10 changed files with 589 additions and 262 deletions

View File

@@ -8,6 +8,31 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2004-01-26 11:45 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* source/compiler/harbour.c
*fixed generation of codeblock's pcode with debugging info
* source/debug/dbgmenu.prg
* source/debug/dbgtmenu.prg
* source/debug/dbgtmitm.prg
* source/debug/dbgtwin.prg
* source/debug/debugger.prg
* source/debug/tbrwtext.prg
*added Tracepoint support
*added support for PPO files
*added monitoring of local variables used in a codeblock
*local variables are displayed correctly when the
callstack window is browsed
*other minor fixes
* source/vm/debug.c
*renamed '__vm*' functions to 'hb_dbg_*'
*fixed support for local variables inside of codeblock
* source/vm/hvm.c
*added 'hb_dbg_ProcLevel' function which return the
size of procedure stack calls (the debugger support)
2004-01-25 10:11 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
* makefile.nt
* makefile.vc

View File

@@ -720,24 +720,6 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType )
pLastVar->pNext = pVar;
}
/*
if( hb_comp_bDebugInfo )
{
BYTE * pBuffer = ( BYTE * ) hb_xgrab( strlen( szVarName ) + 5 );
int iVar = hb_compStaticGetPos( szVarName, pFunc );
pBuffer[0] = HB_P_STATICNAME;
pBuffer[1] = (hb_compVariableScope( szVarName )==HB_VS_GLOBAL_STATIC)?1:0;
pBuffer[2] = HB_LOBYTE( iVar );
pBuffer[3] = HB_HIBYTE( iVar );
memcpy( ( BYTE * ) ( & ( pBuffer[4] ) ), szVarName, strlen( szVarName ) + 1 );
hb_compGenPCodeN( pBuffer, strlen( szVarName ) + 5 , 0 );
hb_xfree( pBuffer );
}
*/
}
break;
@@ -3788,21 +3770,11 @@ void hb_compCodeBlockStart()
{
PFUNCTION pBlock;
#if 0
if( hb_comp_iWarnings >= 3 )
{
/* Not generating yet - will be generated in hb_compCodeBlockEnd() */
hb_compGenPCode1( HB_P_PUSHBLOCK );
pBlock->lPCodePos--;
}
#endif
pBlock = hb_compFunctionNew( NULL, HB_FS_STATIC );
pBlock->pOwner = hb_comp_functions.pLast;
pBlock->iStaticsBase = hb_comp_functions.pLast->iStaticsBase;
hb_comp_functions.pLast = pBlock;
/* hb_compLinePushIfDebugger(); */
}
void hb_compCodeBlockEnd( void )
@@ -3811,7 +3783,9 @@ void hb_compCodeBlockEnd( void )
PFUNCTION pFunc;/* pointer to a function that owns a codeblock */
USHORT wSize;
USHORT wLocals = 0; /* number of referenced local variables */
USHORT wLocalsCnt, wLocalsLen;
USHORT wPos;
int iLocalPos;
PVAR pVar, pFree;
if( hb_comp_functions.pLast &&
@@ -3840,13 +3814,17 @@ void hb_compCodeBlockEnd( void )
*/
/* Count the number of referenced local variables */
wLocalsLen = 0;
pVar = pCodeblock->pStatics;
while( pVar )
{
if( hb_comp_bDebugInfo )
wLocalsLen += (4 + strlen(pVar->szName));
pVar = pVar->pNext;
++wLocals;
}
wLocalsCnt = wLocals;
if( ( pCodeblock->lPCodePos + 3 ) <= 255 && pCodeblock->wParamCount == 0 && wLocals == 0 )
{
/* NOTE: 3 = HB_P_PUSHBLOCKSHORT + BYTE( size ) + _ENDBLOCK */
@@ -3860,7 +3838,8 @@ void hb_compCodeBlockEnd( void )
wSize = ( USHORT ) pCodeblock->lPCodePos + 8 + wLocals * 2;
if( hb_comp_bDebugInfo )
{
wSize += (3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( hb_comp_functions.pLast->szName ));
wSize += (3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( pFunc->szName ));
wSize += wLocalsLen;
}
hb_compGenPCode3( HB_P_PUSHBLOCK, HB_LOBYTE( wSize ), HB_HIBYTE( wSize ), ( BOOL ) 0 );
@@ -3874,24 +3853,47 @@ void hb_compCodeBlockEnd( void )
{
wPos = hb_compVariableGetPos( pFunc->pLocals, pVar->szName );
hb_compGenPCode2( HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), ( BOOL ) 0 );
pFree = pVar;
pVar = pVar->pNext;
hb_xfree( ( void * ) pFree );
}
if( hb_comp_bDebugInfo )
{
BYTE * pBuffer;
pBuffer = ( BYTE * ) hb_xgrab( 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( hb_comp_functions.pLast->szName ) );
pBuffer = ( BYTE * ) hb_xgrab( 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( pFunc->szName ) );
pBuffer[0] = HB_P_MODULENAME;
memcpy( ( BYTE * ) ( &( pBuffer[1] ) ), ( BYTE * ) hb_comp_files.pLast->szFileName, strlen( hb_comp_files.pLast->szFileName ) );
pBuffer[ strlen( hb_comp_files.pLast->szFileName ) + 1 ] = ':';
memcpy( ( BYTE * ) ( &( pBuffer[ strlen( hb_comp_files.pLast->szFileName ) + 2 ] ) ), ( BYTE * ) hb_comp_functions.pLast->szName, strlen( hb_comp_functions.pLast->szName ) + 1 );
hb_compGenPCodeN( pBuffer, 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( hb_comp_functions.pLast->szName ), 0 );
memcpy( ( BYTE * ) ( &( pBuffer[ strlen( hb_comp_files.pLast->szFileName ) + 2 ] ) ), ( BYTE * ) pFunc->szName, strlen( pFunc->szName ) + 1 );
hb_compGenPCodeN( pBuffer, 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( pFunc->szName ), 0 );
hb_xfree( pBuffer );
/* generate the name of reference local variables */
pVar = pCodeblock->pStatics;
iLocalPos = -1;
while( wLocalsCnt-- )
{
pBuffer = ( BYTE * ) hb_xgrab( strlen( pVar->szName ) + 4 );
pBuffer = ( BYTE * ) hb_xgrab( strlen( pVar->szName ) + 4 );
pBuffer[0] = HB_P_LOCALNAME;
pBuffer[1] = HB_LOBYTE( iLocalPos );
pBuffer[2] = HB_HIBYTE( iLocalPos );
iLocalPos--;
memcpy( ( BYTE * ) ( & ( pBuffer[3] ) ), pVar->szName, strlen( pVar->szName ) + 1 );
hb_compGenPCodeN( pBuffer, strlen( pVar->szName ) + 4 , 0 );
hb_xfree( pBuffer );
pFree = pVar;
pVar = pVar->pNext;
hb_xfree( ( void * ) pFree );
}
}
hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, ( BOOL ) 0 );

View File

@@ -53,10 +53,11 @@
#include "hbclass.ch"
#xcommand MENU [<oMenu>] => [ <oMenu> := ] TDbMenu():New()
#xcommand MENUITEM [ <oMenuItem> PROMPT ] <cPrompt> [ ACTION <uAction,...> ] ;
#xcommand MENUITEM [ <oMenuItem> PROMPT ] <cPrompt> ;
[ IDENT <nIdent> ] [ ACTION <uAction,...> ] ;
[ <checked: CHECK, CHECKED> ] => ;
[ <oMenuItem> := ] TDbMenu():AddItem( TDbMenuItem():New( <cPrompt>,;
[{|Self|<uAction>}] ,[<.checked.>] ) )
[{|Self|<uAction>}] ,[<.checked.>], [<nIdent>] ) )
#xcommand SEPARATOR => TDbMenu():AddItem( TDbMenuItem():New( "-" ) )
#xcommand ENDMENU => ATail( TDbMenu():aMenus ):Build()
@@ -69,12 +70,13 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu
local oPublic, oPrivate, oStatic, oLocal, oAll, oSort
local oCallStack
local oCBTrace
local oPPo
MENU oMenu
MENUITEM " ~File "
MENU
MENUITEM " ~Open..." ACTION oDebugger:Open()
MENUITEM " ~Resume" ACTION oDebugger:NotSupported()
MENUITEM " ~Resume" ACTION oDebugger:Resume()
MENUITEM " O~S Shell" ACTION oDebugger:OSShell()
SEPARATOR
MENUITEM " e~Xit Alt-X " ACTION oDebugger:Exit(), oDebugger:Hide(), __Quit()
@@ -116,10 +118,10 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu
MENUITEM " ~Point "
MENU
MENUITEM " ~Watchpoint..." ACTION oDebugger:AddWatchpoint()
MENUITEM " ~Tracepoint..." ACTION oDebugger:NotSupported()
MENUITEM " ~Watchpoint..." ACTION oDebugger:WatchpointAdd()
MENUITEM " ~Tracepoint..." ACTION oDebugger:TracepointAdd()
MENUITEM " ~Breakpoint F9 " ACTION oDebugger:ToggleBreakPoint()
MENUITEM " ~Delete..." ACTION oDebugger:DelWatchpoint()
MENUITEM " ~Delete..." ACTION oDebugger:WatchpointDel()
ENDMENU
MENUITEM " ~Monitor "
@@ -147,7 +149,8 @@ function __dbgBuildMenu( oDebugger ) // Builds the debugger pulldown menu
MENUITEM " ~Options "
MENU
MENUITEM " ~Preprocessed Code" ACTION oDebugger:NotSupported()
MENUITEM oPPo PROMPT " ~Preprocessed Code" IDENT "PPO";
ACTION (IIF( oDebugger:OpenPPO(), oPPo:Toggle(), NIL))
MENUITEM oLineNumbers PROMPT " ~Line Numbers" ;
ACTION ( oDebugger:LineNumbers(), oLineNumbers:Toggle() ) CHECKED
MENUITEM " ~Exchange Screens" ACTION oDebugger:NotSupported()

View File

@@ -82,6 +82,7 @@ CLASS TDbMenu /* debugger menu */
METHOD EvalAction()
METHOD GetHotKeyPos( nKey )
METHOD GetItemOrdByCoors( nRow, nCol )
METHOD GetItemByIdent( uIdent )
METHOD GoBottom()
METHOD GoDown() INLINE ::aItems[ ::nOpenPopup ]:bAction:GoRight()
METHOD GoLeft()
@@ -264,6 +265,19 @@ METHOD GetItemOrdByCoors( nRow, nCol ) CLASS TDbMenu
return 0
METHOD GetItemByIdent( uIdent ) CLASS TDbMenu
local n
for n := 1 to Len( ::aItems )
if VALTYPE(::aItems[ n ]:Ident) == VALTYPE(uIdent) .AND.;
::aItems[n]:Ident == uIdent
return ::aItems[ n ]
endif
next
return NIL
METHOD GoBottom() CLASS TDbMenu
local oPopup

View File

@@ -63,6 +63,7 @@ CLASS TDbMenuItem
DATA cPrompt
DATA bAction
DATA lChecked
DATA Ident
METHOD New( cPrompt, bAction, lChecked )
METHOD Display( cClrText, cClrHotKey )
@@ -70,7 +71,7 @@ CLASS TDbMenuItem
ENDCLASS
METHOD New( cPrompt, bAction, lChecked ) CLASS TDbMenuItem
METHOD New( cPrompt, bAction, lChecked, nIdent ) CLASS TDbMenuItem
DEFAULT lChecked TO .f.

View File

@@ -84,7 +84,8 @@ CLASS TDbWindow // Debugger windows and dialogs
METHOD ShowModal()
METHOD LButtonDown( nMRow, nMCol )
METHOD LDblClick( nMRow, nMCol )
METHOD LoadColors() INLINE ::cColor := __DbgColors()[ 1 ]
METHOD LoadColors()
METHOD Move()
METHOD KeyPressed( nKey )
METHOD Refresh()
@@ -335,3 +336,14 @@ METHOD KeyPressed( nKey ) CLASS TDbWindow
endif
return nil
METHOD LoadColors() CLASS TDbWindow
LOCAL aClr:=__DbgColors()
::cColor := aClr[ 1 ]
IF( ::Browser!=NIL )
::Browser:ColorSpec := aClr[ 2 ] + "," + aClr[ 5 ] + "," + aClr[ 3 ]
ENDIF
RETURN nil

File diff suppressed because it is too large Load Diff

View File

@@ -72,6 +72,9 @@ CLASS TBrwText FROM HBEditor
DATA lLineNumbers // If .T. source code lines are preceded by their number
ACCESS colorSpec INLINE ::cColorSpec
ASSIGN colorSpec(cClr) INLINE ::cColorSpec:=cClr
METHOD New(nTop, nLeft, nBottom, nRight, cFileName, cColor)
METHOD GoTop() // Methods available on a standard TBrowse, needed to handle a HBEditor like a TBrowse

View File

@@ -97,7 +97,7 @@ static USHORT hb_stackLenGlobal( void )
return uiCount;
}
HB_FUNC( __VMSTKGCOUNT )
HB_FUNC( HB_DBG_VMSTKGCOUNT )
{
hb_retni( hb_stackLenGlobal() );
}
@@ -106,7 +106,7 @@ HB_FUNC( __VMSTKGCOUNT )
* $FuncName$ <aStack> __vmStkGList()
* $Description$ Returns the global stack
* $End$ */
HB_FUNC( __VMSTKGLIST )
HB_FUNC( HB_DBG_VMSTKGLIST )
{
PHB_ITEM pReturn;
PHB_ITEM * pItem;
@@ -142,7 +142,7 @@ static USHORT hb_stackLen( int iLevel )
return uiCount;
}
HB_FUNC( __VMSTKLCOUNT )
HB_FUNC( HB_DBG_VMSTKLCOUNT )
{
int iLevel = hb_parni( 1 ) + 1;
@@ -160,7 +160,7 @@ HB_FUNC( __VMSTKLCOUNT )
* [x+1 .. y] Locals
* [y+1 ..] Pushed data
* $End$ */
HB_FUNC( __VMSTKLLIST )
HB_FUNC( HB_DBG_VMSTKLLIST )
{
PHB_ITEM pReturn;
PHB_ITEM * pItem;
@@ -184,7 +184,7 @@ HB_FUNC( __VMSTKLLIST )
/* TODO : put bLocals / bParams */
/* somewhere for declared parameters */
/* and locals */
HB_FUNC( __VMPARLLIST )
HB_FUNC( HB_DBG_VMPARLLIST )
{
int iLevel = hb_parni( 1 ) + 1;
PHB_ITEM * pBase = hb_stack.pBase;
@@ -204,24 +204,50 @@ HB_FUNC( __VMPARLLIST )
hb_itemRelease( hb_itemReturn( pReturn ) );
}
HB_FUNC( __VMVARLGET )
static void hb_dbgStop()
{
}
HB_FUNC( HB_DBG_VMVARLGET )
{
int iLevel = hb_parni( 1 ) + 1;
int iLocal = hb_parni( 2 );
PHB_ITEM * pBase = hb_stack.pBase;
while( ( iLevel-- > 0 ) && pBase != hb_stack.pItems )
pBase = hb_stack.pItems + ( *pBase )->item.asSymbol.stackbase;
hb_itemReturn( hb_itemUnRef( *(pBase + 1 + hb_parni( 2 )) ) );
if( iLocal > SHRT_MAX )
{
hb_dbgStop();
iLocal -= USHRT_MAX;
iLocal--;
}
if( iLocal >= 0 )
hb_itemReturn( hb_itemUnRef( *(pBase + 1 + iLocal) ) );
else
hb_itemReturn( hb_codeblockGetVar( *(pBase+1), ( LONG ) iLocal ) );
}
HB_FUNC( __VMVARLSET )
HB_FUNC( HB_DBG_VMVARLSET )
{
int iLevel = hb_parni( 1 ) + 1;
int iLocal = hb_parni( 2 );
PHB_ITEM * pBase = hb_stack.pBase;
PHB_ITEM pLocal;
while( ( iLevel-- > 0 ) && pBase != hb_stack.pItems )
pBase = hb_stack.pItems + ( *pBase )->item.asSymbol.stackbase;
hb_itemCopy( hb_itemUnRef(*(pBase + 1 + hb_parni( 2 ))), *(hb_stack.pBase + 4) );
if( iLocal > SHRT_MAX )
{
iLocal -= USHRT_MAX;
iLocal--;
}
if( iLocal >= 0 )
pLocal = *(pBase + 1 + iLocal);
else
pLocal = hb_codeblockGetVar( *(pBase+1), ( LONG ) iLocal );
hb_itemCopy( hb_itemUnRef(pLocal), *(hb_stack.pBase + 4) );
}

View File

@@ -245,6 +245,10 @@ static LONG s_lRecoverBase;
#define HB_RECOVER_ADDRESS -3
#define HB_RECOVER_VALUE -4
/* Stores level of procedures call stack
*/
static ULONG s_ulProcLevel = 0;
int hb_vm_aiExtraParams[HB_MAX_MACRO_ARGS], hb_vm_iExtraParamsIndex = 0;
PHB_SYMB hb_vm_apExtraParamsSymbol[HB_MAX_MACRO_ARGS];
@@ -3258,7 +3262,8 @@ void hb_vmDo( USHORT uiParams )
/*
printf( "\VmDo nItems: %i Params: %i Extra %i\n", hb_stack.pPos - hb_stack.pBase, uiParams, hb_vm_aiExtraParams[hb_vm_iExtraParamsIndex - 1] );
*/
s_ulProcLevel++;
if( hb_vm_iExtraParamsIndex && HB_IS_SYMBOL( pItem = hb_stackItemFromTop( -( uiParams + hb_vm_aiExtraParams[hb_vm_iExtraParamsIndex - 1] + 2 ) ) ) && pItem->item.asSymbol.value == hb_vm_apExtraParamsSymbol[hb_vm_iExtraParamsIndex - 1] )
{
uiParams += hb_vm_aiExtraParams[--hb_vm_iExtraParamsIndex];
@@ -3420,6 +3425,7 @@ void hb_vmDo( USHORT uiParams )
hb_vmDebuggerEndProc();
s_bDebugging = bDebugPrevState;
s_ulProcLevel--;
}
void hb_vmSend( USHORT uiParams )
@@ -3440,6 +3446,7 @@ void hb_vmSend( USHORT uiParams )
printf( "\n VmSend nItems: %i Params: %i Extra %i\n", hb_stack.pPos - hb_stack.pBase, uiParams, hb_vm_aiExtraParams[hb_vm_iExtraParamsIndex - 1] );
*/
s_ulProcLevel++;
if( hb_vm_iExtraParamsIndex && HB_IS_SYMBOL( pItem = hb_stackItemFromTop( -( uiParams + hb_vm_aiExtraParams[hb_vm_iExtraParamsIndex - 1] + 2 ) ) ) && pItem->item.asSymbol.value == hb_vm_apExtraParamsSymbol[hb_vm_iExtraParamsIndex - 1] )
{
uiParams += hb_vm_aiExtraParams[--hb_vm_iExtraParamsIndex];
@@ -3648,6 +3655,7 @@ void hb_vmSend( USHORT uiParams )
}
s_bDebugging = bDebugPrevState;
s_ulProcLevel--;
}
static HARBOUR hb_vmDoBlock( void )
@@ -5014,13 +5022,17 @@ ULONG hb_vmFlagEnabled( ULONG flags )
return s_VMFlags & (flags);
}
/* ------------------------------------------------------------------------ */
/* The debugger support functions */
/* ------------------------------------------------------------------------ */
void hb_vmRequestDebug( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestDebug()"));
s_bDebugRequest = TRUE;
}
HB_FUNC( INVOKEDEBUG )
HB_FUNC( HB_DBG_INVOKEDEBUG )
{
BOOL bRequest = s_bDebugRequest;
s_bDebugRequest = FALSE;
@@ -5031,7 +5043,7 @@ HB_FUNC( INVOKEDEBUG )
* $FuncName$ <aStat> __vmVarSList()
* $Description$ Return the statics array. Please aClone before assignments
* $End$ */
HB_FUNC( __VMVARSLIST )
HB_FUNC( HB_DBG_VMVARSLIST )
{
PHB_ITEM pStatics = hb_arrayClone( &s_aStatics, NULL );
@@ -5043,7 +5055,7 @@ HB_FUNC( __VMVARSLIST )
* $FuncName$ <nStatics> __vmVarSLen()
* $Description$ Return the statics array length.
* $End$ */
HB_FUNC( __VMVARSLEN )
HB_FUNC( HB_DBG_VMVARSLEN )
{
hb_retnl( s_aStatics.item.asArray.value->ulLen );
}
@@ -5052,7 +5064,7 @@ HB_FUNC( __VMVARSLEN )
* $FuncName$ <xStat> __vmVarSGet(<nStatic>)
* $Description$ Return a specified statics
* $End$ */
HB_FUNC( __VMVARSGET )
HB_FUNC( HB_DBG_VMVARSGET )
{
/* hb_itemReturn( s_aStatics.item.asArray.value->pItems +
hb_stack.iStatics + hb_parni( 1 ) - 1 ); */
@@ -5064,12 +5076,17 @@ HB_FUNC( __VMVARSGET )
* $FuncName$ __vmVarSSet(<nStatic>,<uValue>)
* $Description$ Sets the value of a specified statics
* $End$ */
HB_FUNC( __VMVARSSET )
HB_FUNC( HB_DBG_VMVARSSET )
{
hb_itemCopy( s_aStatics.item.asArray.value->pItems + hb_parni( 1 ) - 1,
* ( hb_stack.pBase + 3 ) );
}
HB_FUNC( HB_DBG_PROCLEVEL )
{
hb_retnl( s_ulProcLevel - 1 ); /* Don't count self */
}
/* ------------------------------------------------------------------------ */
/* The garbage collector interface */
/* ------------------------------------------------------------------------ */