softwareCobbler / luceedebug

line debugger for lucee
GNU Lesser General Public License v2.1
44 stars 15 forks source link
cfml coldfusion debugging lucee

luceedebug

luceedebug is a step debugger for Lucee.

misc. features of a debug session indicating that luceedebug is a step debugger for Lucee.

There are two components:

The java agent needs a particular invocation and needs to be run as part of the JVM/Lucee server startup.

The VS Code client extension is available as luceedebug when searching in the VS Code extensions pane (or it can be built locally, see subsequent instructions).

Java Agent

Min supported JDK is JDK11. Building requires JDK17 or higher.

Built jars are available via github 'releases'. The most recent build is https://github.com/softwareCobbler/luceedebug/releases/latest

Build Agent Jar

The following steps will build to: ./luceedebug/build/libs/luceedebug.jar

Build Agent Jar on Mac / Linux

cd luceedebug
./gradlew shadowjar

Build Agent Jar on Windows

cd luceedebug
gradlew.bat shadowjar

Install and Configure Agent

Note that you must be running a JDK version of your java release (a common error on startup when running "just" a JRE is java.lang.NoClassDefFoundError: com/sun/jdi/Bootstrap).

Add the following to your java invocation. (Tomcat users can use the setenv.sh file for this purpose.)

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:9999

-javaagent:/abspath/to/luceedebug.jar=jdwpHost=localhost,jdwpPort=9999,debugHost=0.0.0.0,debugPort=10000,jarPath=/abspath/to/luceedebug.jar

VS Code luceedebug Debugger Extension

Install and Run from VS Code Marketplace

The VS Code luceedebug extension is available on the VS Code Marketplace. If you are an end-user who just wants to start debugging your CFML, install the luceedebug extension from the Marketplace.

Run the Extension

Hacking the luceedebug Extension

If you want to hack the extension, itself, build/run instructions follow.

Build Extension

Prerequisites:

# vs code client
cd vscode-client
npm install

npm run build-dev-windows # windows
npm run build-dev-linux # mac/linux
Run the Self-Built Extension

Steps to run the extension in VS Code's "extension development host":

VS Code Extension Configuration

A CFML debug configuration looks like:

{
    "type": "cfml",
    "request": "attach",
    "name": "Project A",
    "hostName": "localhost",
    "port": 10000,
    // optional; only necessary when ide and lucee paths don't match
    "pathTransforms": [
      {
        "idePrefix": "${workspaceFolder}",
        "serverPrefix": "/app"
      }
    ]
}

hostName/port should match the debugHost/debugPort of the Java agent's configuration. (There are exceptions; e.g., on remote hosts where DNS and/or port forwarding are in play.)

Mapping Paths with pathTransforms

pathTransforms maps between "IDE paths" and "Lucee server paths". For example, in your editor, you may be working on a file called /foo/bar/baz/TheThing.cfc, but it runs in a container and Lucee sees it as /serverAppRoot/bar/baz/TheThing.cfc.

In the case of local debugging (when there are no virtual machines or containers involved), you may not need a pathTransforms configuration, because both your IDE and Lucee probably know any given CFML file by the same path name.

However, in environments where the IDE path of a CFML file isn't identical to the Lucee path, luceedebug needs to know how to transform these paths.

Currently, it is a simple prefix replacement, e.g.:

"pathTransforms": [
  {
    "idePrefix": "/foo",
    "serverPrefix": "/serverAppRoot"
  }
]

In the above example, the IDE would announce, "set a breakpoint in /foo/bar/baz/TheThing.cfc, which the server will understand as "set a breakpoint in /serverAppRoot/bar/baz/TheThing.cfc".

Omitting pathTransforms means no path transformation will take place. (It can be omitted when IDE paths match server paths.)

Multiple pathTransforms may be specified if more than one mapping is needed. The first match wins.

Example:

"pathTransforms": [
  {
    "idePrefix": "/Users/sc/projects/subapp_b_helper",
    "serverPrefix": "/var/www/subapp/b/helper"
  },
  {
    "idePrefix": "/Users/sc/projects/subapp_b",
    "serverPrefix": "/var/www/subapp/b"
  },
  {
    "idePrefix": "/Users/sc/projects/app",
    "serverPrefix": "/var/www"
  }
]

In this example:


Misc.

writedump / serializeJSON

writeDump(x) and serializeJSON(x) data visualizations are made available as context menu items from within the debug variables pane. Right-clicking on a variable brings up the menu:

misc. features of a debug session indicating that luceedebug is a step debugger for Lucee.

and results are placed into an editor tab.


Watch expressions

Support for conditional breakpoints, watch expressions, and REPL evaluation.

misc. watch features being used


Debug breakpoint bindings

If breakpoints aren't binding, you can inspect what's going using the "luceedebug: show class and breakpoint info" command. Surface this by typing "show class and breakpoint info" into the command palette.

Scan luceedebug Agent for Security Vulnerabilities

./gradlew dependencyCheckAnalyze