Kaydet (Commit) c6431e76 authored tarafından Andreas Bregas's avatar Andreas Bregas

mib17: #163025# Basic Trace functionality for debugging (inactive by default)

üst d8524eb9
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "sb.hxx" #include "sb.hxx"
#include "iosys.hxx" #include "iosys.hxx"
#include "disas.hxx" #include "disas.hxx"
#include "sbtrace.hxx"
static const char* pOp1[] = { static const char* pOp1[] = {
...@@ -361,6 +362,11 @@ BOOL SbiDisas::DisasLine( String& rText ) ...@@ -361,6 +362,11 @@ BOOL SbiDisas::DisasLine( String& rText )
rText.Erase(); rText.Erase();
if( !Fetch() ) if( !Fetch() )
return FALSE; return FALSE;
#ifdef DBG_TRACE_BASIC
String aTraceStr_STMNT;
#endif
// New line? // New line?
if( eOp == _STMNT && nOp1 != nLine ) if( eOp == _STMNT && nOp1 != nLine )
{ {
...@@ -393,8 +399,13 @@ BOOL SbiDisas::DisasLine( String& rText ) ...@@ -393,8 +399,13 @@ BOOL SbiDisas::DisasLine( String& rText )
rText.AppendAscii( "; " ); rText.AppendAscii( "; " );
rText += s; rText += s;
rText.AppendAscii( _crlf() ); rText.AppendAscii( _crlf() );
#ifdef DBG_TRACE_BASIC
aTraceStr_STMNT = s;
#endif
} }
} }
// Label? // Label?
const char* p = ""; const char* p = "";
if( cLabels[ nPC >> 3 ] & ( 1 << ( nPC & 7 ) ) ) if( cLabels[ nPC >> 3 ] & ( 1 << ( nPC & 7 ) ) )
...@@ -432,20 +443,29 @@ BOOL SbiDisas::DisasLine( String& rText ) ...@@ -432,20 +443,29 @@ BOOL SbiDisas::DisasLine( String& rText )
rText.AppendAscii( _crlf() ); rText.AppendAscii( _crlf() );
} }
snprintf( cBuf, sizeof(cBuf), pMask[ nParts ], nPC, (USHORT) eOp, nOp1, nOp2 ); snprintf( cBuf, sizeof(cBuf), pMask[ nParts ], nPC, (USHORT) eOp, nOp1, nOp2 );
rText.AppendAscii( cBuf );
String aPCodeStr;
aPCodeStr.AppendAscii( cBuf );
int n = eOp; int n = eOp;
if( eOp >= SbOP2_START ) if( eOp >= SbOP2_START )
n -= SbOP2_START; n -= SbOP2_START;
else if( eOp >= SbOP1_START ) else if( eOp >= SbOP1_START )
n -= SbOP1_START; n -= SbOP1_START;
rText += '\t'; aPCodeStr += '\t';
rText.AppendAscii( pOps[ nParts-1 ][ n ] ); aPCodeStr.AppendAscii( pOps[ nParts-1 ][ n ] );
rText += '\t'; aPCodeStr += '\t';
switch( nParts ) switch( nParts )
{ {
case 2: (this->*( pOperand2[ n ] ) )( rText ); break; case 2: (this->*( pOperand2[ n ] ) )( aPCodeStr ); break;
case 3: (this->*( pOperand3[ n ] ) )( rText ); break; case 3: (this->*( pOperand3[ n ] ) )( aPCodeStr ); break;
} }
rText += aPCodeStr;
#ifdef DBG_TRACE_BASIC
dbg_RegisterTraceTextForPC( pMod, nPC, aTraceStr_STMNT, aPCodeStr );
#endif
return TRUE; return TRUE;
} }
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "runtime.hxx" #include "runtime.hxx"
#include "token.hxx" #include "token.hxx"
#include "sbunoobj.hxx" #include "sbunoobj.hxx"
#include "sbtrace.hxx"
//#include <basic/hilight.hxx> //#include <basic/hilight.hxx>
...@@ -1044,6 +1045,9 @@ USHORT SbModule::Run( SbMethod* pMeth ) ...@@ -1044,6 +1045,9 @@ USHORT SbModule::Run( SbMethod* pMeth )
StarBASICRef xBasic; StarBASICRef xBasic;
if( bDelInst ) if( bDelInst )
{ {
#ifdef DBG_TRACE_BASIC
dbg_InitTrace();
#endif
// #32779: Basic waehrend der Ausfuehrung festhalten // #32779: Basic waehrend der Ausfuehrung festhalten
xBasic = (StarBASIC*) GetParent(); xBasic = (StarBASIC*) GetParent();
...@@ -1122,18 +1126,28 @@ USHORT SbModule::Run( SbMethod* pMeth ) ...@@ -1122,18 +1126,28 @@ USHORT SbModule::Run( SbMethod* pMeth )
SbModule* pOldMod = pMOD; SbModule* pOldMod = pMOD;
pMOD = this; pMOD = this;
SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart ); SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart );
#ifdef DBG_TRACE_BASIC
dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl );
#endif
pRt->pNext = pINST->pRun; pRt->pNext = pINST->pRun;
if( pRt->pNext ) if( pRt->pNext )
pRt->pNext->block(); pRt->pNext->block();
pINST->pRun = pRt; pINST->pRun = pRt;
if ( mbVBACompat ) if ( mbVBACompat )
{ {
pINST->EnableCompatibility( TRUE ); pINST->EnableCompatibility( TRUE );
} }
while( pRt->Step() ) {} while( pRt->Step() ) {}
if( pRt->pNext ) if( pRt->pNext )
pRt->pNext->unblock(); pRt->pNext->unblock();
#ifdef DBG_TRACE_BASIC
bool bLeave = true;
dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl, bLeave );
#endif
// #63710 Durch ein anderes Thread-Handling bei Events kann es passieren, // #63710 Durch ein anderes Thread-Handling bei Events kann es passieren,
// dass show-Aufruf an einem Dialog zurueckkehrt (durch schliessen des // dass show-Aufruf an einem Dialog zurueckkehrt (durch schliessen des
// Dialogs per UI), BEVOR ein per Event ausgeloester weitergehender Call, // Dialogs per UI), BEVOR ein per Event ausgeloester weitergehender Call,
...@@ -1227,9 +1241,20 @@ void SbModule::RunInit() ...@@ -1227,9 +1241,20 @@ void SbModule::RunInit()
pMOD = this; pMOD = this;
// Der Init-Code beginnt immer hier // Der Init-Code beginnt immer hier
SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 ); SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 );
#ifdef DBG_TRACE_BASIC
dbg_traceNotifyCall( this, NULL, 0 );
#endif
pRt->pNext = pINST->pRun; pRt->pNext = pINST->pRun;
pINST->pRun = pRt; pINST->pRun = pRt;
while( pRt->Step() ) {} while( pRt->Step() ) {}
#ifdef DBG_TRACE_BASIC
bool bLeave = true;
dbg_traceNotifyCall( this, NULL, 0, bLeave );
#endif
pINST->pRun = pRt->pNext; pINST->pRun = pRt->pNext;
delete pRt; delete pRt;
pMOD = pOldMod; pMOD = pOldMod;
......
This diff is collapsed.
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _SBTRACE_HXX
#define _SBTRACE_HXX
// #define DBG_TRACE_BASIC
#ifdef DBG_TRACE_BASIC
void dbg_InitTrace( void );
void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl );
void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave = false );
void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl );
void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC,
const String& aTraceStr_STMNT, const String& aTraceStr_PCode );
#endif
#endif
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp>
#include "sbunoobj.hxx" #include "sbunoobj.hxx"
#include "errobject.hxx" #include "errobject.hxx"
#include "sbtrace.hxx"
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -720,6 +721,12 @@ BOOL SbiRuntime::Step() ...@@ -720,6 +721,12 @@ BOOL SbiRuntime::Step()
if( pInst->IsReschedule() && bStaticGlobalEnableReschedule ) if( pInst->IsReschedule() && bStaticGlobalEnableReschedule )
Application::Reschedule(); Application::Reschedule();
} }
#ifdef DBG_TRACE_BASIC
UINT32 nPC = ( pCode - (const BYTE* )pImg->GetCode() );
dbg_traceStep( pMod, nPC, pINST->nCallLvl );
#endif
SbiOpcode eOp = (SbiOpcode ) ( *pCode++ ); SbiOpcode eOp = (SbiOpcode ) ( *pCode++ );
UINT32 nOp1, nOp2; UINT32 nOp1, nOp2;
if( eOp <= SbOP0_END ) if( eOp <= SbOP0_END )
...@@ -756,6 +763,11 @@ BOOL SbiRuntime::Step() ...@@ -756,6 +763,11 @@ BOOL SbiRuntime::Step()
// (insbesondere nicht nach Compiler-Fehlern zur Laufzeit) // (insbesondere nicht nach Compiler-Fehlern zur Laufzeit)
if( nError && bRun ) if( nError && bRun )
{ {
#ifdef DBG_TRACE_BASIC
SbError nTraceErr = nError;
String aTraceErrMsg = GetSbData()->aErrMsg;
bool bTraceErrHandled = true;
#endif
SbError err = nError; SbError err = nError;
ClearExprStack(); ClearExprStack();
nError = 0; nError = 0;
...@@ -836,12 +848,19 @@ BOOL SbiRuntime::Step() ...@@ -836,12 +848,19 @@ BOOL SbiRuntime::Step()
// Kein Error-Hdl gefunden -> altes Vorgehen // Kein Error-Hdl gefunden -> altes Vorgehen
else else
{ {
#ifdef DBG_TRACE_BASIC
bTraceErrHandled = false;
#endif
pInst->Abort(); pInst->Abort();
} }
// ALT: Nur // ALT: Nur
// pInst->Abort(); // pInst->Abort();
} }
#ifdef DBG_TRACE_BASIC
dbg_traceNotifyError( nTraceErr, aTraceErrMsg, bTraceErrHandled, pINST->nCallLvl );
#endif
} }
} }
return bRun; return bRun;
......
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