COMPUTER READABLE STORAGE MEDIUM FOR MULTI-LANGUAGE DEBUGGING

Information

  • Patent Application
  • 20080066059
  • Publication Number
    20080066059
  • Date Filed
    November 09, 2007
    16 years ago
  • Date Published
    March 13, 2008
    16 years ago
Abstract
Software developers working on multi-language systems can utilize a multi-language debugging environment. The debugging environment can be uniform across languages, and can seamlessly perform debugging between one or more languages in a multi-language environment. Such a system can have a number of attributes intended to help developers facing debugging problems in multi-language environments. This description is not intended to be a complete description of, or limit the scope of, the invention. Other features, aspects, and objects of the invention can be obtained from a review of the specification, the figures, and the claims.
Description
COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document of the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.


FIELD OF THE INVENTION

The present invention relates to the debugging of software and software components.


BACKGROUND

Most real-world software systems of any significant complexity are written in more than one programming language. For example, an environment may be implemented in JAVA™ while an interpreted language may be running on top of JAVA™ and need to be debugged. This situation creates significant difficulties for software developers attempting to debug these systems. This problem is complicated by the fact that there is no standardization in terms of internal structures, such as stack frames, between different programming languages. For example, it is not uncommon for a developer to see stack information not directly related to the software being debugged when encountering a stack frame for one language, when using a debugger intended for another language. As another example, when using a debugger intended for the JAVA™ language, a JAVA™ stack will not include the stack for XScript (a JavaScript variant with native support for extensible markup language (XML)), and can sometimes show the set of Java classes that implement the XScript engine (these are part of the environment, but not the software the developer is working on). One multi-language debugger, described in JAVA™ Specification Request (JSR) 45, can only be used to debug languages that are easily transformed into Java and then compiled. This and most other multi-language debuggers won't work with languages such as XScript where the language will be run by an interpreter or the language can not be mapped directly to JAVA™ because the language has a different data structure. Thus, creating debugging tools that can be applied to software applied to more than one programming language, and running in the same environment, has proved to be extremely difficult.


SUMMARY OF THE INVENTION

Methods for a debugging environment that can be used by software developers working on multi-language systems. The techniques used create a debugging environment that can be uniform across languages, and can seamlessly perform debugging between one or more languages in a multi-language environment. Such a system can have a number of attributes intended to help developers facing debugging problems in multi-language environments.




BRIEF DESCRIPTION OF THE DRAWINGS


FIG. 1 describes an initialization process for one embodiment of the invention.




DETAILED DESCRIPTION

Systems and methods in accordance with embodiments of the present invention provide a debugging environment that can be used by software developers working on multi-language systems. The techniques used create a debugging environment that can be uniform across languages, and can seamlessly perform debugging between one or more languages in a multi-language environment. Such a system can have a number of attributes intended to help developers facing debugging problems in multi-language environments including:

    • Integrate debugging between two or more languages at the same time. If more than one language appears on a stack, a developer can see the frames for each language, as well as be able to inspect variables for each language.
    • Nested language debugging. A developer can debug source code that has several nested languages within a single source file. Mixing several languages in a single source file is becoming an increasingly valuable and popular capability. For example, the emerging ECMAScript for XML languages embeds the XML languages directly in ECMAScript.
    • An extensible architecture. Support for additional languages can be added to the multi-language debugging environment. For example, using multiple language definitions, a developer can perform debugging in the JAVA™ language, Xscript language, the Xquery language, and various Business Process Modeling languages, such as the Business Process Execution Language.


Each language integrated into a multi-language debugger can include specific support for the stack frame structures and variable representations used in that language. Each new language added to the multi-language debugger can extend the system in at least one of 3 areas:

    • The Integrated Development Environment (IDE). If the debugger is associated with an IDE, this environment can contain support for the languages supported by the debugger. These extensions may include appropriate APIs to get at dialog boxes (watch, locals, stack frame, etc), as well as the debugging commands. As an example, many Business Processes Modeling languages will simply be extensions in the IDE that will map to normal JAVA™ code, or code in some other complied or interpreted programming language. In these cases, the extensions may be able to simply create extensions to the IDE environment for the underling programming language.
    • The Proxy. In one embodiment of the present invention, the proxy is not required. When implemented, the proxy may be used to implement user interface (UI) commands into the underlying debugging framework requests. The proxy can be used in-process or out-of-process. In the case where a proxy is out-of-process and used as an intermediate between the environment the software is executing in and the debugger, a proxy with the correct mapping between the new language and the underling language may be used. For example, to add debugging for a new language that maps directly to JAVA™ byte codes, the proxy is extended to map between the new language and JAVA™.
    • Runtime messaging infrastructure. For some languages the debugger should be capable of interacting with the messaging infrastructure. For example, to debug an interpreted language, like Xscript, the debugging may be done on the server side of the messaging infrastructure. In one embodiment, the Runtime messaging infrastructure may interpret language interactions and perform debugging in JAVA™ Platform Debugging Architecture (JPDA).


Throughout the following discussion, an example is developed using the JAVA™ language. It will be understood that the invention is equally applicable to any programming language. This example is presented for illustrative purposes only and is not meant to limit the scope, functionality or spirit of any particular embodiment of the invention.


Architectural Overview


Some embodiments will be comprised of one or more functional components or modules. It will be understood that any particular embodiment of the invention may not require all of the components listed, may use additional components, or may use an entirely different organization without changing the functionality, scope or spirit. Components used in some embodiments can include:

    • A proxy—In some embodiments a proxy is used between the executing code being debugged and the debugger. In some cases, the proxy serves to improve the efficiency or reduce the overhead associated with debugging protocols. For example, many JAVA™ language debuggers use the JAVA™ Debugging Interface (JDI), which has a fine-grain API and therefore will create a lot of message traffic between the code under test and the debugger. In this case a proxy can consolidate the contents of some of the messages, potentially reducing messages and overhead.
    • A script engine interface—A script engine can communicate with the multi- language debugger through a standardized interface. This interface can be used by the multi-language debugger to communicate metadata to the proxy (or possibly directly to the debugger), so the proxy can determine when to call into which debuggable language. As an example, for multi-language support of JavaScript, a JAVA™ language debugger may define an interface, possibly called IdebuggableLanguage, which is used anytime the script engine is invoked. Typically there is an object in the JAVA™ stack that implements this interface, and can translate the JAVA™ stack into a JavaScript stack.
    • A debuggable frame—For each language supported, the scripting engine may use a debuggable frame object, capable of retrieving the script context. As an example, a JAVA™ language debugger may define such a standardized frame, possibly known as IdebuggableFrame.
    • An interface to the messaging environment—This is an interface that can be implemented by a runtime-messaging environment that controls the running state of the scripting engines. As an example, a JAVA™ language debugger may define a standardized interface, possibly known as IdebugScriptController.
    • Script context object—For each language supported, the scripting engine can use an object to hold a script context. As an example, a JAVA™ language debugger may define a standardized object, possibly known as IcontextHolder.
    • A debug commands interface—For each language supported, the script engine can use a standardized interface, which the multi-language debugger uses to call into the different debuggable languages. As an example, a JAVA™ language debugger may define a standardized object, possibly known as IDebugCommands.
    • A script debug controller—A script engine may have a static constructor that loads a script debug controller, which may registers itself upon start-up. When the script engine registers itself, the script debug controller may get the following information from the engine: a) the language extensions for each language, b) the classes that implement the script engine, c) information on optional capabilities for the language, and d) the language name. In some cases the controller may store this information internally in a map that goes from extension to script engine. As an example, for a JAVA™ language debugger the script debug controller, possibly known as ScriptDebugController, is defined in debugger.jar.


      Process Overview


In some embodiments, when the runtime-messaging infrastructure is started in non-production (debug) mode, a script controller for the debug process is started. This object inspects the system for script engines, and loads them and their configuration information.


In some embodiments when the runtime-messaging infrastructure starts a debugging session, it will send a message to the proxy. Typically, this message includes a list of languages and language configuration information for the languages supported by the multi-language debugger. In some embodiments, when debugging begins, the debug proxy will talk to the script controller for control flow (e.g. step, continue, pause), and will operate directly on the script engines for debugging information (e.g. stack frames, variable inspection, expressions).


In some embodiments, after the script engines have all registered themselves, the script debug controller waits until debugging is started. This process is depicted in FIG. 1. Once debugging commences:


1. The server can send 102 an initialization message to the proxy.


2. The proxy can respond 104 with a packet indicating the languages discovered.


3. The server can send 106 a language response packet during the boot sequence. This packet may include the information used by the script debug controller, such as: a) the language extensions for each language, b) the classes that implement the script engine, c) information on optional capabilities for the language, and d) the language name.


4. The proxy will now send 108 a message indicating the successful completion of the initialization to the runtime massaging server, and will then wait for events.


Breakpoint Hits


In some embodiments, when a breakpoint is hit, or a step is finished in communications with the script engine will be to the script debug controller. As an example, with JAVA™ code, all communications with the script engines will be through JDI calls to the script debug controller.


For some embodiments, the first breakpoint hit in the underling language can behave like a normal break. The following process may then occur:


1. The debugger gets the current class, line, and stack and processes the stack through a language filter. If during processing, the debugger encounters a class that implements a script language the following steps may be take: a) if the object derives from a context holder, the debug script controller makes a method call to get the context, and b) the debug script controller will call a method to get the contents of the stack. Continuing the examples for the JAVA™ language, the debug script controller will call getcontext (or some other suitable named method) on the IcontextHolder object to get the context and then calls a method ScriptDebugController.getStack (LanguageExt, Context) (or some other suitable named method) via JDI, to get a list of scriptFrames.


2. All script languages are processed as described above, creating a stack frame list to send back to the debugger.


3. The debugger proceeds to discover and inspect variables in the same way as before.


Current Frame Set to Script Frame


In some embodiments, the following process may occur if the current stack frame is set to a frame controlled by a script engine:

  • 1. Get the “this” object and the frame variables and send them to the client as the list of variables.


2. For each object queried, call a method to get the values of the script variables. Continuing the example for the JAVA™ language, a call is made to IDebuggableLanguage.getVariable( ) (or some other suitable named method), to get the IScriptVariable (or some other suitable named interface)value. Some possible Java language examples of the results of this operation can be seen in the following table.

ValueValueTypeTypeDisplayDisplayIf ExpandedIn ExpressionSimplegetValue( )getType( )Call getPrimativeType( ) todetermine which get* function tocall to get the correct value.ComplexgetValue( )GetCallUse getMember to get members,TypegetMembers( ) toand callMethod to call methods on( )get the list ofthe value.members todisplay, then callgetMember( ) oneeach to get thevalues.ArraygetValue( )getType( )Create a listUse getElement to lookup thegetLength( ) long,valuesand populate itwith calls togetElement( )OtherCall into theCall into theCall into theCall into theLanguageScriptDebugScriptDebugScriptDebugControllerScriptDebugController to get aController toController toto get aresolved ScriptValue and use that.get aget aresolvedresolvedresolvedScriptValue andScriptValueScriptValueuse that.and useand usethat.that.JavaCallCallCallCall getValueObject and treat asgetValueObjectgetValueObjectgetValueObjectordinary Java Objectand treat asand treat asand treat asordinaryordinaryordinary JavaJava ObjectJava ObjectObject


Stepping Through Code


Some embodiments can step though code using a mechanism analogous to that used in an ordinary (without multi-language support) debugger, except that the debugger will inform the script debug controller when a step is about to begin. In this way, any script engine that is started, and script engines that return from calling into the underling language (e.g. JAVA™) will be able to stop appropriately. In some cases, script implementation classes are placed into the excludes-filter during a step request.


Continuing


In some embodiments this operation behaves like a continue in an ordinary (not multi-language) debugger.


Script Breakpoint Hit


In some embodiments, when a script breakpoint is hit the following actions can occur:

    • The script controller will call a breakpoint method, sending a message indicating the breakpoint hit to the proxy. Continuing the JAVA™ language example, the controller can call into a method with a name, such as, ScriptDebugController.Break( ) to send the message to the proxy.
    • The Proxy can then freeze the thread, and perform any required communications. In the JAVA™ example these communications can use function calls via JDI.
    • When the user decides to continue, the debugger will unfreeze the thread and send a Continue, StepIn, StepOver, StepOut, etc., packet as appropriate.


      In some embodiments, if the user hits Stop instead of Continue, the thread can be un- frozen, no network packet will be sent, and the thread may be forced to throw an exception used for killing threads. Alternatively, such actions by the user can be temporarily blocked.


      Pause


In some embodiments, when the user hits Pause, the thread will be paused. The debugger can then look to see if the stack is currently in scripting or the underling language (e.g. JAVA™) code. One of the following actions may then be taken:

  • 1. If the stack is in the underling language code, the process is complete. In some cases, this situation is treated in the same way hitting a breakpoint is treated.
  • 2. If the stack is in script code, a pause method is called on the script engine interface and the execution of the scripting language will continue until it hits a stopping point, when a pause method is called on the script debug controller. Continuing the JAVA™ language example, when a pause( ) method on the IdebuggableLanguage interface is called, the scripting language will continue until it hits a stopping point, at which point the engine calls ScriptDebugController.Pause( ).


    In some embodiments, when a pause is called on a script language while it is waiting on some synchronization object, it will be treated as a normal thread in the underling language (e.g. JAVA™), which can prevent deadlock scenarios.


    Breakpoints


In some embodiments, information in breakpoint packets can use a suitable extension or other indicator to identify the language type being executed. In some cases, the absence of the extension can indicate the underling language (e.g. JAVA™) is being used. If a breakpoint is not in the underling language the following actions may be taken:

  • 1. Send a message to the script debug controller telling it to set a breakpoint.
  • 2. The script debug controller will look up the proper extension or indicator and set a breakpoint using the method available for that language.
  • 3. The script debug controller will then send a message indicating the success or failure of setting the breakpoint.


In some embodiments several types of breakpoints are supported, which can include:

Source BreakpointsThis is the ordinary type of breakpoint that goeson a source file/line numberMethod BreakpointThis breakpoint is hit when a certain method iscalledWatch pointThis breakpoint is hit when a variable is eitherread or written.


It should be noted, that depending on the details of the embodiment, any language may be able to support a sub-set of the available breakpoint types for any given language. Returning a true or false to a query for that type can indicate the support for a particular breakpoint type. For example, a true or false can be returned for a method, featureEnabledo (or some other suitable name), when called with a variable indicating the break point type, such as, SOURCE_BREAKPOINT_SUPPORT, METHOD_BREAKPOINT_SUPPORT, or WATCH_POINT_SUPPORT


An Example
Interfaces

The following examples show sets of interface definitions for two embodiments, developed using the JAVA™ language. It will be understood that the invention is equally applicable to any programming language. This example is presented for illustrative purposes only and is not meant to limit the scope, functionality or spirit of any particular embodiment of the invention.


Network Messages


As has already been discussed, some embodiments use facilities in the runtime-messaging environment to perform debugging operations on network messages. This capability is demonstrated here by example shown in the table below developed using the JAVA™ language. In another embodiment, method calls may be made via the native debugging infrastructure JDI. Methods are called on the ScriptController via JDI to do continues and other such tasks. Breakpoints are executed by hitting actual Java breakpoint and are then translated in the proxy to script breakpoint. Thus, breakpoints reduce to java breakpoints. JDI sends a message to the proxy in the underlying JDI protocol. For example, a packet may be sent from the server to the proxy that includes meta-data for a scripting language. The meta-data is used to determine whether to treat the language as a scripting language or to treat the language as a native language. It will be understood that the invention is equally applicable to any programming language. This example is presented for illustrative purposes only and is not meant to limit the scope, functionality or spirit of any particular embodiment of the invention.

MessageSenderMeaningParametersSetBreakpointProxyTrying to set aFile - File namescript breakpoint.Line - Line numberLanguage Ext - LanguageExtensionSetMethodBreakpointProxyTrying to set aClass - Class name (or file namebreakpoint on ais language doesn't have classes)methodMethod -- Name of the method toset a breakpoint onParameters - The parameters forthe method to set a breakpoint on.This disambiguates in the case ofmultiple methods with the samename but different parametersLanguage Ext - LanguageExtensionsBreakpointSetRuntime-Breakpoint is setStatus - Did the breakpoint get setmessagingError -- Error message if it failedenvironmentBreakHitRuntime-A Script hit aFile - the file namemessagingbreakpointLine - the line numberenvironmentContinueProxyA script shouldContinueType - whether thisresumeshould continue with a step or acontinuePauseRuntime-Tells the proxy aPauseID - This is the ID we usemessagingscript has gottento map a pause the thread it wasenvironmentto a safe placerequested on.and paused


The foregoing description of preferred embodiments of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to one of ordinary skill in the art. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalents.

Claims
  • 1. A computer-readable storage medium, with instructions stored thereon for debugging in more than one programming language with a multi-language debugger, comprising: debugging a source code file which contains multiple nested languages; interpreting multiple nested languages within a single source file and displaying each of the multiple nested languages in a debugging frame; editing each language in a debugging frame; and wherein the multi-language debugger uses a standardize interface for a script engine and all communications with the script engine will be through calls to a script debug controller.
  • 2. The computer-readable storage medium of claim 1, wherein the multi-language debugger is extensible and a user can add language definitions to support additional languages.
  • 3. The computer-readable storage medium of claim 1, wherein if more than one language appears on a stack, a user can see a debuggable frame for each language and the user can inspect variables for each language.
  • 4. The computer-readable storage medium of claim 1, wherein a proxy is used between executing code being debugged and a debugger.
  • 5. The computer-readable storage medium of claim 1, wherein a script engine interface can be used by a debugger to communicate metadata to a proxy.
  • 6. The computer-readable storage medium of claim 1, wherein a debugger interacts with a runtime messaging environment.
  • 7. The computer-readable storage medium of claim 1, wherein debugging is performed on a server side of a runtime messaging environment.
  • 8. The computer-readable storage medium of claim 1, wherein a runtime messaging environment interprets language interactions and performs debugging.
  • 9. The computer-readable storage medium of claim 1, wherein a script engine has a static constructor load a script debug controller.
  • 10. The computer-readable storage medium of claim 9, wherein the script debug controller receives information from the script engine, comprising: a) language extensions for each language; b) classes that implement the script engine; c) information on optional capabilities for each language; and d) language name.
CLAIM OF PRIORITY

This application is a continuation of U.S. patent application Ser. No. 10/784,600 entitled “Method for Multi-Language Debugging,” filed on Feb. 23, 2004 by William A. Pugh, et al., which claims priority to U.S. Provisional Application No. 60/450,014 entitled “Systems and Methods for Multi-Language Debugging,” filed on Feb. 26, 2003, by William A. Pugh, et al., which applications are incorporated by reference.

Provisional Applications (1)
Number Date Country
60450014 Feb 2003 US
Continuations (1)
Number Date Country
Parent 10784600 Feb 2004 US
Child 11938114 Nov 2007 US