├── .gitignore ├── extension.js ├── images └── colour-icon.png ├── debug-adapter.js ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | gitignore 3 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | activate() {}, 3 | deactivate() {} 4 | }; -------------------------------------------------------------------------------- /images/colour-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hackwaly/vscode-ocaml-debugger/HEAD/images/colour-icon.png -------------------------------------------------------------------------------- /debug-adapter.js: -------------------------------------------------------------------------------- 1 | const child_process = require('child_process'); 2 | 3 | const cp = child_process.spawn('ocamlearlybird'); 4 | process.stdin.pipe(cp.stdin); 5 | cp.stdout.pipe(process.stdout); 6 | cp.stderr.pipe(process.stderr); 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OCaml Debugger 2 | 3 | ***[Please report issuses here](https://github.com/hackwaly/ocamlearlybird/issues)*** 4 | 5 | ## Prerequisite 6 | 7 | ``` 8 | opam install earlybird 9 | ``` 10 | 11 | ### Sample launch.json 12 | 13 | ```json 14 | { 15 | "version": "0.2.0", 16 | "configurations": [ 17 | { 18 | "name": "OCaml Debug", 19 | "type": "ocaml-debugger", 20 | "request": "launch", 21 | "program": "${workspaceFolder}/a.out" 22 | } 23 | ] 24 | } 25 | ``` 26 | 27 | Assuming a file at `src/main.ml` 28 | 29 | ```ocaml 30 | let fizzbuzz i = match ((i mod 3), (i mod 5)) with 31 | | (0, 0) -> "fizbuzz" 32 | | (_, 0) -> "buzz" 33 | | (0, _) -> "fizz" 34 | | (_, _) -> string_of_int i;; 35 | 36 | let do_fizzbuzz n = for i = 1 to n do 37 | print_endline (fizzbuzz i) 38 | done;; 39 | 40 | do_fizzbuzz 100;; 41 | 42 | ``` 43 | 44 | Compile `main.ml` 45 | 46 | ```bash 47 | ocamlc -g src/main.ml 48 | # creates a.out in root of the project 49 | ``` 50 | 51 | Then set breakpoint in `main.ml` and run **"OCaml Debug"** from the VS Code Debug panel. 52 | 53 | ## FAQ 54 | 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "ocaml-debugger", 4 | "displayName": "OCaml Debugger", 5 | "description": "OCaml debugger.", 6 | "version": "0.1.3", 7 | "publisher": "hackwaly", 8 | "icon": "images/colour-icon.png", 9 | "engines": { 10 | "vscode": "^1.17.0" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/hackwaly/vscode-ocaml-debugger" 15 | }, 16 | "categories": [ 17 | "Debuggers" 18 | ], 19 | "main": "extension.js", 20 | "activationEvents": [ 21 | "onDebugResolve:ocaml" 22 | ], 23 | "contributes": { 24 | "breakpoints": [ 25 | { 26 | "language": "ocaml" 27 | }, 28 | { 29 | "language": "ocamllex" 30 | }, 31 | { 32 | "language": "menhir" 33 | } 34 | ], 35 | "debuggers": [ 36 | { 37 | "type": "ocaml-debugger", 38 | "label": "OCaml", 39 | "runtime": "node", 40 | "program": "debug-adapter.js", 41 | "configurationSnippets": [ 42 | { 43 | "label": "OCaml: Launch program", 44 | "description": "Debug the program", 45 | "body": { 46 | "name": "${2:Launch file}", 47 | "type": "ocaml-debugger", 48 | "request": "launch", 49 | "program": "^\"${1:\\${file}}\"" 50 | } 51 | } 52 | ], 53 | "configurationAttributes": { 54 | "launch": { 55 | "required": [ 56 | "program" 57 | ], 58 | "properties": { 59 | "noDebug": { 60 | "type": "boolean", 61 | "default": false 62 | }, 63 | "cwd": { 64 | "type": "string", 65 | "description": "The working directory for debuggee program." 66 | }, 67 | "env": { 68 | "type": "object", 69 | "additionalProperties": { 70 | "type": "string" 71 | }, 72 | "description": "Environment variables passed to the debuggee program.", 73 | "default": {} 74 | }, 75 | "program": { 76 | "type": "string", 77 | "description": "The path of debuggee program." 78 | }, 79 | "symbols": { 80 | "type": "string", 81 | "description": "The path to optional OCaml debug symbols .cds file." 82 | }, 83 | "arguments": { 84 | "type": "array", 85 | "items": { 86 | "type": "string" 87 | }, 88 | "description": "The command-line arguments for the debuggee program." 89 | }, 90 | "console": { 91 | "enum": [ 92 | "internalConsole", 93 | "integratedTerminal", 94 | "externalTerminal" 95 | ], 96 | "description": "Where to launch the debug target: internal console, integrated terminal, or external terminal.", 97 | "default": "internalConsole" 98 | }, 99 | "stopOnEntry": { 100 | "type": "boolean", 101 | "description": "Automatically stop after launch.", 102 | "default": false 103 | }, 104 | "dotMerlins": { 105 | "type": "array", 106 | "items": { 107 | "type": "string" 108 | }, 109 | "description": "List of *.merlin files." 110 | } 111 | } 112 | } 113 | } 114 | } 115 | ] 116 | } 117 | } 118 | --------------------------------------------------------------------------------