====== Vibemosphere Debugger ====== Source editor with tree view, breakpoints and a Java debugger (JDI) for the code that runs in Vibecat: edit, build, hot swap, stop at breakpoints, step, inspect variables. ^ Id | ''debugger'' | ^ Role | ''debugger'' - needed for the page and the REST API (administrators always may) | ^ Page | **Plugins > Open** (overlay with an X at the top right) or ''/plugins/debugger/'' | ^ REST | ''/api/plugins/debugger/...'' and, for callers with the role, ''/plugins/debugger/...'' | ===== Open the configuration ===== In the administration open **Plugins**, select the row of this plug-in and press **Open**. The page opens in an overlay dialog: close it with the **X** at the top right, with Esc or by clicking outside; //Open in a new tab// next to the title shows it full size. {{vibecat:plugin-debugger.png?900|Vibemosphere Debugger: the plug-in page in its overlay dialog}} ===== The page in detail ===== {{vibecat:plugin-debugger-full.png?900|Vibemosphere Debugger: the whole page (playground instance)}} The page has these sections: **Source + File + Folder Delete**, **Build output Debugger log**, **Debug detached**, **Variables**, **Breakpoints Remove all**, **Workspace**. ==== Dialog: New… ==== {{vibecat:plugin-debugger-dialog.png?900|Vibemosphere Debugger: the dialog of "New…"}} ===== Fields and columns ===== ^ Label ^ Meaning ^ | Name | | | Folder on the server | | | Source folders (relative, comma separated; empty: from the Eclipse .classpath, else src) | | | Output folder with the class files (hot swap; empty: bin) | | | Build command (run in the folder, e.g. ant CreateJAR or mvn -q compile ) | | | … or upload a source package (ZIP) | | ===== Actions ===== * **New…** * **Workspace…** * **Save** * **Build** * **Apply classes** * **+ File** * **+ Folder** * **Delete** * **Debug Vibecat** * **Disconnect** * **Attach** * **Resume** * **Step over** * **Step into** * **Step out** * **Remove all** * **Remove workspace** * **Cancel** ===== Notes from the page ===== * Click in the gutter (left of the line numbers) to set or remove a breakpoint. * Other JVM / port Attach * A JVM started with -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 , e.g. another ELO service. Auto resume after s. ===== Reference ===== Edit the source code of the code that runs in Vibecat - a web application, an ELO Indexserver plug-in - and debug it where it runs: set breakpoints in the editor, let the server hit them, step through the code and look at the variables. The editor is the cloccojs code editor, the file browser the cloccojs tree view. ==== Workspaces ==== A workspace is a folder with source code. Two ways to get one (button **New...**): * **A folder of the server** (for example ''C:\Entwicklung\Sysworx\JavaFramework\eloixplugins\sysworx-ixhelper-plugins''): the files are edited in place. The source folders and the output folder are read from the Eclipse ''.classpath'' (else ''src'' and ''bin''). * **An uploaded source package** (ZIP): extracted into the data folder of the plug-in and edited there. The tree shows the folder, a click opens a file (several files = tabs), **Save** or Ctrl+S writes it. **+ File**, **+ Folder** and **Delete** work on the selected node. Only text files up to 3 MB are opened. ==== Breakpoints ==== Click in the gutter left of a line number of a Java file: a red dot = the breakpoint is set in the running JVM, an amber dot = waiting (the class is not loaded yet, it is set as soon as it is), a grey ring = disabled. The panel **Breakpoints** lists them (enable, disable, jump). Breakpoints are kept across restarts. They need line numbers in the class files (the default of the Java compiler and of Eclipse; ''-g'' adds the local variable names). ==== Debugging ==== - **Start Vibecat with the debug agent** (a JVM can only load it at its start): from the command line ''set VIBECAT_DEBUG_PORT=5005'' before ''vibecat.cmd''; as Windows service ''install-windows.ps1 -DebugPort 5005'' (or add ''-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005'' to the Java options of the service, for example with Vibecat Server Status, Settings, Options, and restart the service); Linux: the same option in ''vibecat.sh''. The agent listens on ''127.0.0.1'' only: anybody who can reach the port controls the JVM, never open it to the network without a firewall. - **Debug Vibecat** attaches to it (127.0.0.1, the port of the settings, default 5005). The web applications and the Indexserver plug-ins run in this JVM, so their classes are debugged directly. Another JVM (for example another ELO service) with the same option: **Other JVM / port**, Attach. - When a thread reaches a breakpoint it stops **alone**; all other threads keep running. The page opens the file, marks the line and shows the stack (click a frame to jump) and the variables (expand objects and arrays). **Resume** F8, **Step over** F10, **Step into** F11, **Step out** Shift+F11. - A thread that stays stopped is resumed after the //auto resume// seconds (default 600, 0 = never): a forgotten breakpoint must not hold a server request thread forever. **Careful:** a breakpoint in a code path the administration itself uses (the Tomcat of the administration port, this plug-in) stops that request: the page may not answer until you resume (use the auto resume setting, or debug from another browser window). ==== Build and apply ==== **Build** runs the build command of the workspace (**Workspace...**) in its folder, for example ''ant CreateJAR''; the output is shown below the editor. **Apply classes** (hot swap) replaces the loaded classes that have a newer class file in the output folder, //without a restart//: only the bodies of methods may change (the JVM refuses added or removed methods and fields). For the Indexserver plug-in: let Eclipse (or the build command) compile to ''bin'', then Apply classes, then repeat the call that stops at the breakpoint. ==== REST (role ''debugger'') ==== Base ''/api/plugins/debugger'' (administration port, HTTP Basic, role **debugger** or administrator): ''GET /workspaces'', ''GET /ws/{id}/tree?node='', ''GET|PUT /ws/{id}/file?path='', ''POST /ws/{id}/build'', ''GET|POST /breakpoints'', ''GET /debug'', ''POST /debug/connect|disconnect|resume|stepover|stepinto|stepout|hotswap'', ''GET /debug/variables?thread=&frame=''. A user with this role can run code control over the whole server: give the role only to administrators of the server. [[vibecat:plugins:start|All plug-ins]]