[xslt] Request for comments on :Request for break point API suggestions




Below is the discussion I've had with Daniel. He asked my to post this and 
reference to xsldbg-0.4.2 (What was intended only for him since I was 
uncertain that the code was "properly" GPL'd) Since then I've created a set 
of diff and tars for libxml and libxslt for a propotype that enable 
breakpoints in libxslt. Also I've updated my debugger which I believe to be 
correct as far as licensing goes (Hopefully I've got the beast under control 
:-)  at least it far better than xsldbg-0.4.2 ) . I'll let the code speak for 
itself. The reference below to transform_shell.c now refer for transform.c in 
libxslt. 

I've put this build together in a rush so it may not even compile, but it 
might :-)

Compiling :
	Either apply each diff in keiths_diffs.tar  to a clean copy of libxml and 
libxslt (using a  patch -p1  )
	or
	Extract and compile each of the tar.gz in keiths_libs.tar 

	do a make install on libxml and then libxslt libraries

	Then compile xsldbg 

The files:
	http://www4.tpgi.com.au/users/k_isdale/xsldebugger/xsldbg-0.4.3.tar.gz 
	http://www4.tpgi.com.au/users/k_isdale/xsldebugger/keiths_diffs.tar 
	http://www4.tpgi.com.au/users/k_isdale/xsldebugger/keiths_libs.tar 


bye,

Keith Isdale


----------  Forwarded Message  ----------

Subject: Re:Request for break point API suggestions
Date: Tue, 18 Sep 2001 20:35:12 +1000
From: Keith Isdale <k_isdale@tpg.com.au>
To: Daniel Veillard <veillard@redhat.com>

Hi Daniel,

Attatched are my thoughts on the breakpoint problem, my suggestion for the
 breakpoint API and public access requests. In this email I also mention some
 of the code I you downloaded from my website ie debugXSL.c and
 transform_shell.c

ln summary on the breakpoint problem, at present the way that I've detected
 breakpoints previously is via finding a template match. Then user can step
 to next instruction, stepout of the current instruction  or run to next
 template. This is different to what xemacs xsl-process.el expects (normal
 debugger behavior). It is able to set/delete/enable/disable a breakpoint at
 a specific file and line number. I would also suggest that the application
 would need to confirm that libxslt it arrived at the right place. But that
 can be solved using a "pwd".  I think there is a problem with macro
 XML_GET_LINE (see tree.h line 432)  because the new "element" node h as a
 type of XML_ELEMENT. This may be a problem when trying to create the break
 point "item" See also Sax.c line 1001 for setting of line number in new
 "element".

I suggest that call stack methods be called from transform.c see
 transform_shell.c  line 455 and 776. and "call stack" in API_Report.txt

Since there is very litte code in my xsldbg.c that not in xsltproc is suggest
 that xsltProc be modified to support debugger "add ons" see API_Report.txt
 "add ons"

Since a large portion of debugXSL.c is from debugXML.c I request public 
 access for these functions as descibed in attatched Public_access.txt

I've listed many changes here. As must as I want to cause a "once off" change
 to libxslt I am starting to wonder if this many changes is an unacceptable
 risk for  libxslt.  Maybe these changes should be "staggered" ie adding the
 breakpoint changes and then thinking about the changes to xsltproc.c,
 debugXML.c and debugXML.h


------------cut -------------------------------------------


	Problem domain analysis
        -----------------------

The follow entities are present in the problem domain for libxslt with
interest and values as follows


libxslt library
	o values to get more users
	o values standards compliance
	o values stability  (relatively stable not changing every day)
	o values reliability (lots of error checking)
	o values localisation of changes to a module
	o values stable project scope:
		a commercial and free library to process stylesheets


Novice user
	o wants to learn language
	o wants to experiment


Experienced user
	o values usability
	o values functionality
	o values getting desired results quickly

Application
	o wants stable third part tools
	o values control over tools
	o values consistant formatting
		- errors
		- normal outputs


Stylesheets
	o contains
		- varialbles
			o local
			o global
		- template
	o values selection of content by
		- template
		- absolute path
		- relative path
	o wants to print content
		- format consistant accross many documents
		- format same as original document

data
	o contains
		- node
		- attibutes
		- content
	o values selection of content by
		- template
		- absolute path
		- relative path
	o wants to print content
		- format consistant accross many documents
		- format same as original document


Recommended API
---------------

In the follow API it is recommened that a copy of fileName is made to make
the breakpoint system independant on other libxslt functions. It is
recommeded that the name be hashed and stored as well. This would
make checking breakpoints faster! 

If the library user wants to make special break points then they will need
 to override all breakpoint code :-(. But I think that is unlikely they
 would want to do that.



/* 
 * here just to clarify what I mean :-) 
 
 #ifndef boolean
   typedef int boolean;
    #define TRUE 1
   #define FALSE 0
 #endif

 #define WITH_XSLT_DEBUG_PROCESS TRUE
 #define XSL_USE_HASH TRUE
*/ 
	
/* Define the types of status whilst debugging*/
typedef enum {
  DEBUG_NONE, /* no debugging allowed strange !*/
  DEBUG_INIT,
  DEBUG_STEP,
  DEBUG_STEPOUT,
  DEBUG_NEXT,
  DEBUG_STOP,
  DEBUG_CONT,
  DEBUG_RUN,
  DEBUG_RUN_RESTART,
  DEBUG_QUIT
}DebugStatus;





typedef struct _xslBreakPoint xslBreakpoint;
typedef xslBreakpoint *xslBreakpointPtr;
struct _xslBreakpoint {
#ifdef XSL_USE_HASH
  long fileNameHash;
#endif
  xmlChar *fileName;
  int lineNo;
};

boolean setDebugStatus(int newStatus);
/*
 * getDebugStatus:
 */
int getDebugStatus();

/* xslDebugBreak :
 * A break point has been found in processing stylesheet so pass control to
 *      user
 * @templ : The source node being executed
 * @node : The data node being processed
 * @root : The template being applyied to "node"
 * @ctxt : The stylesheet context
 */
void xslDebugBreak(xmlNodePtr templ, xmlNodePtr node, xsltTemplatePtr root,
		   xsltTransformContextPtr ctxt) ;


/*
 * xslInitBreakpoint:
 *
 * Intialize breakpoint system. An error message will be printed be printed
 *  if WITH_XSLT_DEBUG_PROCESS is  TRUE and attempted to run this function
 * more than once
 */
void xslInitBreakpoint()		;


/*
 * xslInitBreakpoint:
 *
 * Free resources used by breakpoint system. An error message will be
 * be printed if WITH_XSLT_DEBUG_PROCESS is  TRUE and and
 * attempted to run this function more than once after xslInitBreakpoint()
 *  or before xslInitBreakpoint() has been called
*/
void xslInitBreakpoint()		;


/*
 * xslAddBreakpoint:
 *
 * Add breakpoint at file and line number specifiec
 *
 * @fileName : fileName non-null, non-empty file name that has been loaded by
 *                    debugger
 * @lineNumber : number >= 0 and is available in fileName specified
 * Returns TRUE if successfull,
 *	FALSE OTW and error message will be printed if WITH_XSLT_DEBUG_PROCESS is
 *                  TRUE
*/
boolean xslAddBreakpoint(xmlChar *fileName, int lineNumber) ;


/*
 * xslDeleteBreakpoint:
 *
 * Delete breakpoint at file and line number specifiec
 *
 * @fileName : fileName non-null, non-empty file name that has been loaded by
 *                    debugger
 * @lineNumber : number >= 0 and is available in fileName specified
 *
 * Returns TRUE if successfull,
 *	FALSE OTW and error message will be printed if WITH_XSLT_DEBUG_PROCESS is
 *                  TRUE
*/
boolean xslDeleteBreakpoint(xmlChar *fileName, int lineNumber) ;

/*
 * xslEnableBreakpoint:
 *
 * Enable or disable a breakpoint at file and line number specified
 *
 * @fileName : fileName non-null, non-empty file name that has been loaded by
 *                    debugger
 * @lineNumber : number >= 0 and is available in fileName specified
 *
 * Returns TRUE if successfull,
 *	FALSE OTW and error message will be printed if WITH_XSLT_DEBUG_PROCESS is
 *                  TRUE
*/
boolean xslEnableBreakpoint(xmlChar *fileName, int lineNumber,
			    boolean enable) ;

/*
 * xslBreakPointCount:
 *
 * Return the number of breakpoints present
 */
int xslBreakPointCount()		;


/* -- I don't want to allow write acccess to breakpoints. They should
just delete and then add the new version of break point they want -- */
/*
 * xslGetBreakpoint:
 *
 * Retrieve the values of file and line number for specifed break point
 *
 * @breakpointNumber : 0 < breakpointNumber <= xslBreakPointCount()
 *
 * Returns if  breakpointNumber is valid with values set as needed,
 *	FALSE OTW and error message will be printed if WITH_XSLT_DEBUG_PROCESS is
 *                  TRUE
*/
boolean xslGetBreakpoint(int breakpointNumber, const xmlChar **fileName,
			 const int *lineNumber) ;


/*
 * xslPrintBreakpoint:
 *
 * Print the details of breakpoint to file specified
 *
 * @file : file != NULL
 * @breakpointNumber : 0 < breakpointNumber <= xslBreakPointCount()
 *
 * Returns TRUE if successfull,
 *	FALSE OTW and error message will be printed if WITH_XSLT_DEBUG_PROCESS is
 *                  TRUE
 */
boolean xslPrintBreakpoint(FILE *file, int breakpointNumber) ;



/* xslIsBreakpoint:
 * Determine if a node is a break point
 * @node : node != NULL
 * Returns : TRUE on sucess, FALSE OTW
 */
boolean xslIsBreakpoint(xmlNodePtr node) ;



/*
------------------------------------------------------
                Xsl call stack related
-----------------------------------------------------
*/

/*
 * xslAddCall:
 * Add template "call" to call stack
 * @source : source node being executed
 * @name : name of template being called
 *
 * Returns : TRUE on sucess, FALSE OTW and an error message will
 *    be printed if WITH_XSLT_DEBUG_PROCESS is  TRUE
 */
boolean xslAddCall(xmlDocPtr source, xmlChar *name) ;

/* xslDropCall :
* Drop the topmost item off the call stack
*
* Returns : TRUE on sucess, FALSE OTW and an error message will
*    be printed if WITH_XSLT_DEBUG_PROCESS is  TRUE
*/
boolean xslDropCall()			;


/*
 * xslGetCall :
 *
 * Retrieve the values of item on the call stack
 * @depth : call stack depth to look for
 * @source : set to the value of source node of "call" if found
 * @name : set to the value of name of template "call"
 *
 * Returns : TRUE on sucess, FALSE OTW and an error message will
 *    be printed if WITH_XSLT_DEBUG_PROCESS is TRUE
 */
boolean xslGetCall(int depth, xmlDocPtr *source, xmlChar **name) ;


/*
 * xslCallDepth :
 *
 * Determine the call stack depth
 *
 * Returns the depth of call stack
*/
int xslCallDepth()			;



/* 
---------------------------------------------------
         Debugger "add ons"
------------------------------------------------------
 */

/*
 * xsltProcUsage:
 *
 * Print the extra usage information provided by the debugger
 */
void xsltProcUsage(const char *name); 


/* Gets called before any options are processed xsltproc.c line 395*/
/*
 * xsltProcInit:
 * 
 * Allow debugger to do setup
 */
void xsltProcInit();


/* Called before xsltproc quits to allow debugger to free resources 
   xsltproc.c line 623
 */
/*
 * xsltProcQuit:
 * 
 * Allow debugger to free resources
 */
void xsltProcQuit();


/* gets called after "--maxdepth" was not found xsltproc.c line 506 */
/*
 * xsltProcParseOptions:
 *
 * Parse the extra options of the debugger
 * 
 * @argc : the number of arguments provided at the command line to
 *            xsltproc
 * @argc : the arguments provided at the command line to xsltproc
 * @index : the argument being processed by xsltproc
 * 
 * Returns TRUE if a valid option is found, FALSE OTW
 */
int xsltProcParseOptions(int argc, char **argv, int index )


/* gets called after "--param" was not found xsltproc.c line 540 */
/*
 * xsltProcParseOptions:
 *
 * Parse the extra options of the debugger
 * 
 * @argc : the number of arguments provided at the command line to
 *            xsltproc
 * @argc : the arguments provided at the command line to xsltproc
 * @index : the argument being processed by xsltproc
 * 
 * Returns TRUE if a valid option is found, FALSE OTW
 */
int xsltProcHandleOptions(int argc, char **argv, int index);



        Public access for debugXML.h / debugXML.h
        
        xmlShellReadline
	xmlLsCountNode
	xmlLsOneNode
	xmlShellList
	xmlShellBase
	xmlShellDir
	xmlShellCat
	xslCatItem
	xmlShellLoad
	xmlShellWrite
	xmlShellSave
	xmlShellValidate
	xmlShellDu
	xmlShellPwd
	xmlPrintList
	xmlDebugCat

	/* The following are from debugXSL.c  please add to debugXML.c */
	xmlPrintItem  (see xslPrintItem)
	xmlPrintXpathError ( see xslPrintXpathError)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]