Compatible LLDB and GDB Python extensions#13136
Conversation
2244bb2 to
d7b6d9d
Compare
I don't understand these two examples. Why would the first one print |
gasche
left a comment
There was a problem hiding this comment.
This looks overall fine to me, and I would propose to merge instead of nitpicking on the implementation.
I have one question: on the assumption that some people may be used to the current scripts, have muscle memory of its commands etc., why don't we also keep the old script around? (Maybe with a message to suggest using the new scripts instead?) Is there a cost to offering both?
| def get_short_help(self): | ||
| return "Describe the location of the given OCaml value in the heap." | ||
| def get_long_help(self): | ||
| return "Wibble Wibble Wibble ##TODO" |
There was a problem hiding this comment.
Could this include some examples of how to print out values?
(lldb) help ocaml find
Describe the location of the given OCaml value in the heap. Expects 'raw' input (see 'help raw-input'.)
Syntax: find
Wibble Wibble Wibble ##TODO
This is just a typo on my part as I wrote the matching comment. I think these textual representation choices I made are pretty ugly, and some of them should change, probably before merging. The important part of this PR is the structure: matching LLDB/GDB shims and the debugger-independent |
|
I do find the "full" printing a bit heavyweight, and I thought in particular about suggesting to drop the arity and not show the tag when it is 0. But I don't have much experience using |
|
From a high-level perspective: I think it is up to the users of these scripts to suggest improvements, and I think we should be liberal in merging them as they don't affect the correctness of the compiler distribution. My only worry is that existing users of the previous script may not appreciate having their muscle-memorized workflow break with the new version, hence my suggestion to maybe keep the old script around to make everyone happy. |
|
I like the idea of keeping the old scripts around, and making them print deprecation and migration messages. |
I'm just tweaking the output a bit today. I agree that it is a bit heavyweight, especially with tag zero and low arity (we could just write |
|
I've reworked all the textual representations, and think they are now better (though doubtless still imperfect). The code for making them is improved too! I've also reinstated the old scripts, which will still load into GDB, and run, but produce deprecation messages. |
… deprecation messages.
c6069ae to
4b7c8d4
Compare
|
I'm not fond of the new printing. Pain points:
Possible suggestion:
(Note: I never ever needed to ask for the GC marks of an OCaml value from gdb to track a bug in my code. This is obviously useful to debug GC issues and maybe some FFI bugs, but fairly niche; could this maybe be a separate command?) |
|
I'm happy to rework the representations again. I knew they were wrong but had run out of steam for experimentation. How's this: I think the worst part that remains is highly-summarized blocks: when we want to elide all the contents and just communicate "a block with tag N and size k". At present this is |
|
User settings for structure depth and breadth, and of whether to show the GC color, could be added as an |
|
Another thing I am less fond of when seeing your examples (thanks!) is the visual overloading of We could use |
|
Following your comment and in-person input from @dra27, I feel we are converging rapidly:
If you can live with this, let's stop bike-shedding at this point? |
|
Agreed! |
|
Thanks for all your input on the representations, @gasche: they are much better now than they were an hour ago! |
|
Unicode nitpicking (even if is probably not be applicable): angle brackets are |
|
I decided to go ahead and merge. If someone is motivated to use unicode bells and whistles, just open a new small PR. |
[Edited to show updated textual representations].
This PR improves the OCaml debugger extensions in several ways:
gdb-macrosscript has been re-implemented in Python, and is now much faster;gdb_ocamlrun.pyhas been rewritten as separate debugger-agnosticocaml.pyand GDB-specificgdb.py;lldb.pyhas been added to supportocaml.pyin LLDB (note that GDB is not available in MacOS on Apple Silicon);gdb-macrosandgdb_ocamlrun.pystill exist and work, but give deprecation warnings when loaded.Use
Value printing
In either debugger, any value of type
valuewill now print in a consistent way:The "summary" will appear as part of a tuple or array. Within a summary, summaries are shortened further (so this is a two-level representation).
Tag zero is omitted. The
(m)or(u)(or(g)or(-)) is the GC color.Very long strings are abbreviated (and more abbreviated in a summary):
Long tuples are abbreviated, in full display and in summary:
Closures show the symbol names of all their functions, the arity of the first, and the closure contents. When summarized, they just show the first function name, the number of functions, and the closure length:
Infix pointers (to functions in shared closures) show the function symbol name, and the summary of the containing closure:
Custom blocks show the custom operations block identifier:
(Note that
"_bigarr02"is the custom operations block "identifier" for big arrays, so this last example is how a Bigarray will print).ocamlcommandIn both debuggers, this introduces an
ocamlcommand, which allows for many sub-commands. At present, this provides just one sub-command:ocaml findThe old heap-search code in
gdb-macrosis now invoked with theocaml findsub-command:$Arrayin gdbThis PR retains the old
$Fconvenience function in gdb, but renames it$Array(as it converts thevalueparameter to an array). LLDB does not support convenience functions, so there is no equivalent there.Example of use
This is cut-and-paste from a shell: