1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-08-07 10:42:55 +03:00

revamped the mechanism to hook a debuger to use a callback setup function,

* libxslt/attributes.c libxslt/transform.c libxslt/xsltutils.c
  libxslt/xsltutils.h: revamped the mechanism to hook a debuger
  to use a callback setup function, deprecating libxsltbreakpoint
* xsltproc/Makefile.am configure.in breakpoint/Makefile.am: removing
  dependancies on libxsltbreakpoint
Daniel
This commit is contained in:
Daniel Veillard
2001-11-30 12:01:25 +00:00
parent b95c91c67b
commit 3efba7ccbf
8 changed files with 412 additions and 287 deletions

View File

@@ -1,3 +1,11 @@
Fri Nov 30 12:59:05 CET 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/attributes.c libxslt/transform.c libxslt/xsltutils.c
libxslt/xsltutils.h: revamped the mechanism to hook a debuger
to use a callback setup function, deprecating libxsltbreakpoint
* xsltproc/Makefile.am configure.in breakpoint/Makefile.am: removing
dependancies on libxsltbreakpoint
Thu Nov 29 09:52:38 CET 2001 Daniel Veillard <daniel@veillard.com> Thu Nov 29 09:52:38 CET 2001 Daniel Veillard <daniel@veillard.com>
Build patch from Peter Williams <peterw@ximian.com> Build patch from Peter Williams <peterw@ximian.com>

View File

@@ -15,7 +15,7 @@ libxsltbreakpoint_la_SOURCES = \
libxsltbreakpoint_la_LIBADD = @LIBXML_LIBS@ libxsltbreakpoint_la_LIBADD = @LIBXML_LIBS@
libxsltbreakpoint_la_LDFLAGS = -version-info @LIBXSLT_VERSION_INFO@ libxsltbreakpoint_la_LDFLAGS = -version-info @LIBXSLTBREAK_VERSION_INFO@
man_MANS = #breakpoint.4 man_MANS = #breakpoint.4

View File

@@ -42,6 +42,30 @@ AC_SUBST(LIBEXSLT_VERSION)
AC_SUBST(LIBEXSLT_VERSION_INFO) AC_SUBST(LIBEXSLT_VERSION_INFO)
AC_SUBST(LIBEXSLT_VERSION_NUMBER) AC_SUBST(LIBEXSLT_VERSION_NUMBER)
dnl
dnl libxsltbreakpoint is a compatibility obsoleted library
dnl it's blocked at 1.0.8 and should be removed in default build in the
dnl future
dnl
LIBXSLTBREAK_MAJOR_VERSION=1
LIBXSLTBREAK_MINOR_VERSION=0
LIBXSLTBREAK_MICRO_VERSION=8
LIBXSLTBREAK_VERSION=$LIBXSLTBREAK_MAJOR_VERSION.$LIBXSLTBREAK_MINOR_VERSION.$LIBXSLTBREAK_MICRO_VERSION
LIBXSLTBREAK_VERSION_INFO=`expr $LIBXSLTBREAK_MAJOR_VERSION + $LIBXSLTBREAK_MINOR_VERSION`:$LIBXSLTBREAK_MICRO_VERSION:$LIBXSLTBREAK_MINOR_VERSION
LIBXSLTBREAK_VERSION_NUMBER=`expr $LIBXSLTBREAK_MAJOR_VERSION \* 10000 + $LIBXSLTBREAK_MINOR_VERSION \* 100 + $LIBXSLTBREAK_MICRO_VERSION`
AC_SUBST(LIBXSLTBREAK_MAJOR_VERSION)
AC_SUBST(LIBXSLTBREAK_MINOR_VERSION)
AC_SUBST(LIBXSLTBREAK_MICRO_VERSION)
AC_SUBST(LIBXSLTBREAK_VERSION)
AC_SUBST(LIBXSLTBREAK_VERSION_INFO)
AC_SUBST(LIBXSLTBREAK_VERSION_NUMBER)
VERSION=${LIBXSLT_VERSION} VERSION=${LIBXSLT_VERSION}
@@ -136,7 +160,7 @@ AC_SUBST(WITH_MEM_DEBUG)
dnl dnl
dnl Is debugger support requested dnl Is debugger support requested
dnl dnl
AC_ARG_WITH(with_debugger, [ --with-debugger Add the debugging module (off)]) AC_ARG_WITH(with_debugger, [ --with-debugger Add the debugging support (on)])
if test "$with_debugger" = "no" ; then if test "$with_debugger" = "no" ; then
echo Disabling debugger echo Disabling debugger
WITH_DEBUGGER=0 WITH_DEBUGGER=0
@@ -260,13 +284,8 @@ case ${host} in
esac esac
XSLT_INCLUDEDIR='-I${includedir}' XSLT_INCLUDEDIR='-I${includedir}'
if test "${WITH_DEBUGGER}" = "1" ; then XSLT_LIBS="-lxslt $LIBXML_LIBS $M_LIBS"
XSLT_LIBS="-lxslt -lxsltbreakpoint $LIBXML_LIBS $M_LIBS" EXTRA_LIBS="$LIBXML_LIBS $M_LIBS"
EXTRA_LIBS='$(top_builddir)/breakpoint/libxsltbreakpoint.la'" $LIBXML_LIBS $M_LIBS"
else
XSLT_LIBS="-lxslt $LIBXML_LIBS $M_LIBS"
EXTRA_LIBS="$LIBXML_LIBS $M_LIBS"
fi
AC_SUBST(XSLT_LIBDIR) AC_SUBST(XSLT_LIBDIR)
AC_SUBST(XSLT_INCLUDEDIR) AC_SUBST(XSLT_INCLUDEDIR)

View File

@@ -46,9 +46,6 @@
#include "imports.h" #include "imports.h"
#include "transform.h" #include "transform.h"
#ifdef WITH_DEBUGGER
#include "../breakpoint/breakpoint.h"
#endif
#ifdef WITH_XSLT_DEBUG #ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_ATTRIBUTES #define WITH_XSLT_DEBUG_ATTRIBUTES
#endif #endif
@@ -383,7 +380,9 @@ error:
*/ */
static void static void
xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr inst, xsltStylePreCompPtr comp, int fromset) { xmlNodePtr inst, xsltStylePreCompPtr comp,
int fromset)
{
xmlChar *prop = NULL; xmlChar *prop = NULL;
xmlChar *ncname = NULL, *name, *namespace; xmlChar *ncname = NULL, *name, *namespace;
xmlChar *prefix = NULL; xmlChar *prefix = NULL;
@@ -402,7 +401,8 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
return; return;
} }
if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL)) if ((ctxt == NULL) || (node == NULL) || (inst == NULL)
|| (comp == NULL))
return; return;
if (!comp->has_name) { if (!comp->has_name) {
return; return;
@@ -413,16 +413,15 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
"xsl:attribute : node already has children\n"); "xsl:attribute : node already has children\n");
return; return;
} }
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
/* --- break point code --- */ if (xslDebugStatus != XSLT_DEBUG_NONE) {
if (xslDebugStatus != DEBUG_NONE) {
xslHandleDebugger(inst, node, NULL, ctxt); xslHandleDebugger(inst, node, NULL, ctxt);
} }
#endif #endif
if (comp->name == NULL) { if (comp->name == NULL) {
prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"name", prop =
xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *) "name",
XSLT_NAMESPACE); XSLT_NAMESPACE);
if (prop == NULL) { if (prop == NULL) {
xsltPrintErrorContext(ctxt, NULL, inst); xsltPrintErrorContext(ctxt, NULL, inst);
@@ -441,7 +440,7 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else { } else {
name = ncname; name = ncname;
} }
if (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)) { if (!xmlStrncasecmp(prefix, (xmlChar *) "xml", 3)) {
#ifdef WITH_XSLT_DEBUG_PARSING #ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext, xsltGenericDebug(xsltGenericDebugContext,
"xsltAttribute: xml prefix forbidden\n"); "xsltAttribute: xml prefix forbidden\n");
@@ -450,7 +449,8 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
if ((comp->ns == NULL) && (comp->has_ns)) { if ((comp->ns == NULL) && (comp->has_ns)) {
namespace = xsltEvalAttrValueTemplate(ctxt, inst, namespace = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)"namespace", XSLT_NAMESPACE); (const xmlChar *)
"namespace", XSLT_NAMESPACE);
if (namespace != NULL) { if (namespace != NULL) {
ns = xsltGetSpecialNamespace(ctxt, inst, namespace, prefix, ns = xsltGetSpecialNamespace(ctxt, inst, namespace, prefix,
ctxt->insert); ctxt->insert);
@@ -461,7 +461,8 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (ns == NULL) { if (ns == NULL) {
xsltPrintErrorContext(ctxt, NULL, inst); xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext, xsltGenericError(xsltGenericErrorContext,
"xsl:attribute : no namespace bound to prefix %s\n", prefix); "xsl:attribute : no namespace bound to prefix %s\n",
prefix);
} else { } else {
ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert); ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert);
} }
@@ -479,9 +480,10 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (value == NULL) { if (value == NULL) {
if (ns) { if (ns) {
attr = xmlSetNsProp(ctxt->insert, ns, name, attr = xmlSetNsProp(ctxt->insert, ns, name,
(const xmlChar *)""); (const xmlChar *) "");
} else { } else {
attr = xmlSetProp(ctxt->insert, name, (const xmlChar *)""); attr =
xmlSetProp(ctxt->insert, name, (const xmlChar *) "");
} }
} else { } else {
if (ns) { if (ns) {
@@ -492,7 +494,7 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
} }
error: error:
if (prop != NULL) if (prop != NULL)
xmlFree(prop); xmlFree(prop);
if (ncname != NULL) if (ncname != NULL)
@@ -530,7 +532,9 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
void void
xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr inst ATTRIBUTE_UNUSED, xmlChar *attributes) { xmlNodePtr inst ATTRIBUTE_UNUSED,
xmlChar * attributes)
{
xmlChar *ncname = NULL; xmlChar *ncname = NULL;
xmlChar *prefix = NULL; xmlChar *prefix = NULL;
xmlChar *attrib, *endattr; xmlChar *attrib, *endattr;
@@ -543,11 +547,13 @@ xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
attrib = attributes; attrib = attributes;
while (*attrib != 0) { while (*attrib != 0) {
while (IS_BLANK(*attrib)) attrib++; while (IS_BLANK(*attrib))
attrib++;
if (*attrib == 0) if (*attrib == 0)
break; break;
endattr = attrib; endattr = attrib;
while ((*endattr != 0) && (!IS_BLANK(*endattr))) endattr++; while ((*endattr != 0) && (!IS_BLANK(*endattr)))
endattr++;
attrib = xmlStrndup(attrib, endattr - attrib); attrib = xmlStrndup(attrib, endattr - attrib);
if (attrib) { if (attrib) {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES #ifdef WITH_XSLT_DEBUG_ATTRIBUTES
@@ -563,15 +569,17 @@ xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node,
style = ctxt->style; style = ctxt->style;
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
/* --- break point code --- */ if (style && (xslDebugStatus != XSLT_DEBUG_NONE)) {
if (style && (xslDebugStatus != DEBUG_NONE)) { values =
values = xmlHashLookup2(style->attributeSets, ncname, prefix); xmlHashLookup2(style->attributeSets, ncname, prefix);
if (values) if (values)
xslHandleDebugger(values->attr->parent, node, NULL, ctxt); xslHandleDebugger(values->attr->parent, node, NULL,
ctxt);
} }
#endif #endif
while (style != NULL) { while (style != NULL) {
values = xmlHashLookup2(style->attributeSets, ncname, prefix); values =
xmlHashLookup2(style->attributeSets, ncname, prefix);
while (values != NULL) { while (values != NULL) {
if (values->attr != NULL) { if (values->attr != NULL) {
xsltAttributeInternal(ctxt, node, values->attr, xsltAttributeInternal(ctxt, node, values->attr,

View File

@@ -61,11 +61,6 @@ static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID,
const xmlChar **systemID); const xmlChar **systemID);
#endif #endif
#ifdef WITH_DEBUGGER
#include "../breakpoint/breakpoint.h"
int xslDebugStatus;
#endif
int xsltMaxDepth = 5000; int xsltMaxDepth = 5000;
/* /*
@@ -1016,24 +1011,6 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
/**
* xslHandleDebugger:
* @cur : source node being executed
* @node : data node being processed
* @templ : temlate that applies to node
* @ctxt : the xslt transform context
*
* If either cur or node are a breakpoint, or xslDebugStatus in state
* where debugging must occcur at this time then transfer control
* to the xslDebugBreak function
*/
void
xslHandleDebugger(xmlNodePtr cur ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNUSED,
xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED)
{
}
/** /**
* xsltApplyOneTemplate: * xsltApplyOneTemplate:
* @ctxt: a XSLT process context * @ctxt: a XSLT process context
@@ -1064,8 +1041,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
long start = 0; long start = 0;
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
/* --- break point code --- */ if (xslDebugStatus != XSLT_DEBUG_NONE) {
if (xslDebugStatus != DEBUG_NONE) {
if (templ) { if (templ) {
addCallResult = xslAddCall(templ, templ->elem); addCallResult = xslAddCall(templ, templ->elem);
} else { } else {
@@ -1074,8 +1050,8 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
switch (xslDebugStatus) { switch (xslDebugStatus) {
case DEBUG_RUN_RESTART: case XSLT_DEBUG_RUN_RESTART:
case DEBUG_QUIT: case XSLT_DEBUG_QUIT:
if (addCallResult) if (addCallResult)
xslDropCall(); xslDropCall();
return; return;
@@ -1088,7 +1064,6 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
else if (ctxt->inst) else if (ctxt->inst)
xslHandleDebugger(ctxt->inst, node, templ, ctxt); xslHandleDebugger(ctxt->inst, node, templ, ctxt);
} }
/* -- end --- */
#endif #endif
if ((ctxt == NULL) || (list == NULL)) if ((ctxt == NULL) || (list == NULL))
@@ -1125,8 +1100,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
#ifdef WITH_XSLT_DEBUG_PROCESS #ifdef WITH_XSLT_DEBUG_PROCESS
if (templ->name != NULL) if (templ->name != NULL)
xsltGenericDebug(xsltGenericDebugContext, xsltGenericDebug(xsltGenericDebugContext,
"applying template '%s'\n", "applying template '%s'\n", templ->name);
templ->name);
#endif #endif
} }
@@ -1137,14 +1111,12 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
while (cur != NULL) { while (cur != NULL) {
ctxt->inst = cur; ctxt->inst = cur;
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
/* --- break point code --- */
switch (xslDebugStatus) { switch (xslDebugStatus) {
case DEBUG_RUN_RESTART: case XSLT_DEBUG_RUN_RESTART:
case DEBUG_QUIT: case XSLT_DEBUG_QUIT:
break; break;
} }
/* --- end --- */
#endif #endif
/* /*
* test, we must have a valid insertion point * test, we must have a valid insertion point
@@ -1157,7 +1129,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
goto error; goto error;
} }
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(cur, node, templ, ctxt); xslHandleDebugger(cur, node, templ, ctxt);
#endif #endif
@@ -1238,7 +1210,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
function = (xsltTransformFunction) function = (xsltTransformFunction)
xsltExtElementLookup(ctxt, cur->name, cur->ns->href); xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
else else
function = ((xsltElemPreCompPtr)cur->_private)->func; function = ((xsltElemPreCompPtr) cur->_private)->func;
if (function == NULL) { if (function == NULL) {
xmlNodePtr child; xmlNodePtr child;
@@ -1304,10 +1276,11 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
int i; int i;
xmlNsPtr ns, ret; xmlNsPtr ns, ret;
for (i = 0;i < ctxt->templ->inheritedNsNr;i++) { for (i = 0; i < ctxt->templ->inheritedNsNr; i++) {
ns = ctxt->templ->inheritedNs[i]; ns = ctxt->templ->inheritedNs[i];
if (ctxt->style->nsAliases != NULL) { if (ctxt->style->nsAliases != NULL) {
const xmlChar *URI; const xmlChar *URI;
URI = (const xmlChar *) URI = (const xmlChar *)
xmlHashLookup(ctxt->style->nsAliases, xmlHashLookup(ctxt->style->nsAliases,
ns->href); ns->href);
@@ -1364,7 +1337,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
} while (cur != NULL); } while (cur != NULL);
} }
error: error:
ctxt->node = oldCurrent; ctxt->node = oldCurrent;
ctxt->inst = oldInst; ctxt->inst = oldInst;
ctxt->insert = oldInsert; ctxt->insert = oldInsert;
@@ -1372,6 +1345,7 @@ error:
xsltFreeStackElemList(varsPop(ctxt)); xsltFreeStackElemList(varsPop(ctxt));
else { else {
xsltStackElemPtr p, tmp = varsPop(ctxt); xsltStackElemPtr p, tmp = varsPop(ctxt);
if (tmp != params) { if (tmp != params) {
p = tmp; p = tmp;
while ((p != NULL) && (p->next != params)) while ((p != NULL) && (p->next != params))
@@ -1409,13 +1383,12 @@ error:
} }
} }
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE && addCallResult) { if ((xslDebugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
xslDropCall(); xslDropCall();
} }
#endif #endif
} }
/************************************************************************ /************************************************************************
* * * *
* XSLT-1.1 extensions * * XSLT-1.1 extensions *
@@ -2522,7 +2495,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
cur = inst->children; cur = inst->children;
while (cur != NULL) { while (cur != NULL) {
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(cur, node, comp->templ, ctxt); xslHandleDebugger(cur, node, comp->templ, ctxt);
#endif #endif
if (ctxt->state == XSLT_STATE_STOPPED) break; if (ctxt->state == XSLT_STATE_STOPPED) break;
@@ -2722,7 +2695,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
cur = inst->children; cur = inst->children;
while (cur!=NULL) { while (cur!=NULL) {
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(cur, node, comp->templ, ctxt); xslHandleDebugger(cur, node, comp->templ, ctxt);
#endif #endif
if (ctxt->state == XSLT_STATE_STOPPED) break; if (ctxt->state == XSLT_STATE_STOPPED) break;
@@ -2856,7 +2829,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(when, node, comp->templ, ctxt); xslHandleDebugger(when, node, comp->templ, ctxt);
#endif #endif
@@ -2912,7 +2885,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
} }
if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) { if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) {
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(replacement, node, comp->templ, ctxt); xslHandleDebugger(replacement, node, comp->templ, ctxt);
#endif #endif
@@ -3101,7 +3074,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
sorts[nbsorts++] = replacement; sorts[nbsorts++] = replacement;
} }
#ifdef WITH_DEBUGGER #ifdef WITH_DEBUGGER
if (xslDebugStatus != DEBUG_NONE) if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(replacement, node, NULL, ctxt); xslHandleDebugger(replacement, node, NULL, ctxt);
#endif #endif
replacement = replacement->next; replacement = replacement->next;

View File

@@ -32,6 +32,7 @@
#include "templates.h" #include "templates.h"
#include "xsltInternals.h" #include "xsltInternals.h"
#include "imports.h" #include "imports.h"
#include "transform.h"
/* gettimeofday on Windows ??? */ /* gettimeofday on Windows ??? */
#ifdef WIN32 #ifdef WIN32
@@ -1246,3 +1247,103 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
xmlFree(templates); xmlFree(templates);
} }
/************************************************************************
* *
* Hooks for the debugger *
* *
************************************************************************/
/*
* There is currently only 3 debugging callback defined
* Debugger callbacks are disabled by default
*/
#define XSLT_CALLBACK_NUMBER 3
typedef struct _xsltDebuggerCallbacks xsltDebuggerCallbacks;
typedef xsltDebuggerCallbacks *xsltDebuggerCallbacksPtr;
struct _xsltDebuggerCallbacks {
xsltHandleDebuggerCallback handler;
xsltAddCallCallback add;
xsltDropCallCallback drop;
};
static xsltDebuggerCallbacks xsltDebuggerCurrentCallbacks = {
NULL, /* handler */
NULL, /* add */
NULL /* drop */
};
int xslDebugStatus;
/**
* xslSetDebuggerCallbacks:
* @no : number of callbacks
* @block : the block of callbacks
*
* This function allow to plug a debugger into the XSLT library
* @block points to a block of memory containing the address of @no
* callback routines.
*
* Returns 0 in case of success and -1 in case of error
*/
int
xsltSetDebuggerCallbacks(int no, void *block)
{
xsltDebuggerCallbacksPtr callbacks;
if ((block == NULL) || (no != 1))
return(-1);
callbacks = (xsltDebuggerCallbacksPtr) block;
xsltDebuggerCurrentCallbacks.handler = callbacks->handler;
return(0);
}
/**
* xslHandleDebugger:
* @cur : source node being executed
* @node : data node being processed
* @templ : temlate that applies to node
* @ctxt : the xslt transform context
*
* If either cur or node are a breakpoint, or xslDebugStatus in state
* where debugging must occcur at this time then transfer control
* to the xslDebugBreak function
*/
void
xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ,
xsltTransformContextPtr ctxt)
{
if (xsltDebuggerCurrentCallbacks.handler != NULL)
xsltDebuggerCurrentCallbacks.handler(cur, node, templ, ctxt);
}
/**
* xslAddCall:
* @templ : current template being applied
* @source : the source node being processed
*
* Add template "call" to call stack
* Returns : 1 on sucess 0 otherwise an error may be printed if
* WITH_XSLT_DEBUG_BREAKPOINTS is defined
*/
int
xslAddCall(xsltTemplatePtr templ, xmlNodePtr source)
{
if (xsltDebuggerCurrentCallbacks.add != NULL)
return(xsltDebuggerCurrentCallbacks.add(templ, source));
return(0);
}
/**
* xslDropCall :
*
* Drop the topmost item off the call stack
*/
void
xslDropCall(void)
{
if (xsltDebuggerCurrentCallbacks.drop != NULL)
xsltDebuggerCurrentCallbacks.drop();
}

View File

@@ -154,6 +154,35 @@ void xsltCalibrateAdjust (long delta);
#define XSLT_TIMESTAMP_TICS_PER_SEC 100000l #define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
/*
* Hooks for the debugger
*/
typedef enum {
XSLT_DEBUG_NONE = 0, /* no debugging allowed */
XSLT_DEBUG_INIT,
XSLT_DEBUG_STEP,
XSLT_DEBUG_STEPOUT,
XSLT_DEBUG_NEXT,
XSLT_DEBUG_STOP,
XSLT_DEBUG_CONT,
XSLT_DEBUG_RUN,
XSLT_DEBUG_RUN_RESTART,
XSLT_DEBUG_QUIT
} xsltDebugStatusCodes;
LIBXSLT_PUBLIC extern int xslDebugStatus;
typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
typedef void (*xsltDropCallCallback) (void);
int xsltSetDebuggerCallbacks (int no, void *block);
int xslAddCall (xsltTemplatePtr templ,
xmlNodePtr source);
void xslDropCall (void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -11,22 +11,9 @@ xsltproc_LDFLAGS =
xsltproc_DEPENDENCIES = $(DEPS) xsltproc_DEPENDENCIES = $(DEPS)
xsltproc_LDADD = $(LDADDS) xsltproc_LDADD = $(LDADDS)
if WITH_DEBUGGER
DEPS = $(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/breakpoint/libxsltbreakpoint.la \
$(top_builddir)/libexslt/libexslt.la
else
DEPS = $(top_builddir)/libxslt/libxslt.la \ DEPS = $(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la $(top_builddir)/libexslt/libexslt.la
endif
if WITH_DEBUGGER
LDADDS = $(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la \
$(top_builddir)/breakpoint/libxsltbreakpoint.la \
@LIBXML_LIBS@ $(EXTRA_LIBS)
else
LDADDS = $(top_builddir)/libxslt/libxslt.la \ LDADDS = $(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la \ $(top_builddir)/libexslt/libexslt.la \
@LIBXML_LIBS@ $(EXTRA_LIBS) @LIBXML_LIBS@ $(EXTRA_LIBS)
endif