Report a clear error when program is a native executable or other non-bytecode file - #95
Open
tmcgilchrist wants to merge 4 commits into
Open
Report a clear error when program is a native executable or other non-bytecode file#95tmcgilchrist wants to merge 4 commits into
program is a native executable or other non-bytecode file#95tmcgilchrist wants to merge 4 commits into
Conversation
Add four scenarios on top of the existing scopes/frames tests: - test_stepping drives next/stepIn/stepOut and records where the debuggee lands, using stack depth as the stable signal so the test does not depend on exactly which line each step snaps to. - test_values renders one local per shape of value (ints, floats, chars, strings, bools, unit, boxed ints, lists, arrays, tuples, options, records, variants, closures, lazies) and expands the structured ones a level. The fixture references every local so none is dropped as unused. - test_heap stops inside a closure and reads the Heap scope, i.e. the variables captured from the enclosing scope. This exercises Value_scope.iter_compenv_heap, which is version-conditional in the same way the Globals scope was in hackwaly#74. - test_events exercises Code_module.find_event/find_events directly, without a debuggee, and records how each source line maps to a debug event. It documents the current mapping, including the lines that are not breakpointable and the backward snap noted in KNOWN_ISSUES.md. The dap_client helper gains stepping commands and value expansion that fetches named and indexed children separately, with a filter, the way an editor does. debugger.ml re-exports the symbol-table modules so the event-mapping test can reach them.
The variables request handler asserted that a value had no indexed children when the request omitted the filter field, and raised Assert_failure for an array. The DAP spec says an omitted filter returns both named and indexed children, so this is a valid request.
Loading a non-bytecode file now fails with a message that names the file, says earlybird debugs bytecode not native executables, and tells the user to build with ocamlc -g or a dune (modes byte) target and point program at the .bc. A dedicated Not_ocaml_bytecode exception with a registered printer keeps the message unwrapped when the adapter surfaces it.
sim642
reviewed
Jul 25, 2026
Comment on lines
60
to
+77
| if%lwt Lwt.return (magic <> Config.exec_magic_number) then | ||
| Lwt.fail_invalid_arg "Bad magic";%lwt | ||
| Lwt.fail | ||
| (Not_ocaml_bytecode | ||
| (Printf.sprintf | ||
| "%s is not an OCaml bytecode executable. earlybird debugs \ | ||
| bytecode programs, not native executables. Compile with \ | ||
| `ocamlc -g` or a dune `(modes byte)` target and set \"program\" \ | ||
| to the resulting .bc file." | ||
| file));%lwt |
Collaborator
There was a problem hiding this comment.
Doesn't this also trigger when it is an OCaml bytecode executable but built with a different version of the compiler?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives issues like #33 a more user friendly error message.
On top of #93