Hi D community!
I’m here again, to describe what I’ve done during the fifth week of Symmetry Autumn of Code.
LLVM Patches follow up
During the discussion on some patches, two other patches have been raised, refactoring the usage of string utilities shared among other demanglers.
Second milestone kickoff
This week I started working on the second milestone, mostly covering DWARF issues that I discovered. The initial idea is to research a bit about what debug information is provided by each compiler and understand what can be done, not only on the LLDB side but also improve information generated by the compilers.
During this week I also took a look at the DWARF5 standard to understand what to improve. I discovered very interesting tags that can help generalize the arrays and strings interaction with the debug info.
To give a bit of context, and more deeply into the DWARF standard,
DW_TAG_array_type exists to represent array types. Similarly, there is also a
tag to specifically represent string types. These tags can be used with
DW_TAG_subrange_type to represent a so-called “slice” and attributes like
DW_AT_upper_bound can be used to represent the slice length.
Interestingly those attributes can refer to runtime variables and therefore
create debug information for a “dynamic array”. I checked other compilers and
only C VLAs are using it.
I wrote a document describing some of the issues and comparing the DWARF capabilities of the 3 most known D compilers. You can read it here.
Some of those issues I managed to fix in the compiler backend, others I filed a bug. Here is a list of patches and bug reports I created:
I have an upcoming patch to the DMD backend that I’m currently working on to refactor some of the DMD DWARF generator, specifically to the abbreviation code. My motivation for the refactor is the fact that I spent a lot of time looking into the backend codebase, implementing PR #13202. Later I realized, when looking into the DWARF standard, that DWARF abbreviations are all LEB128 encoded and the code is not respecting that. I believe some of the errors produced by the compiler is due to that.
To have pretty-printing capabilities I will need to either implement some of those missing DWARF tags or/and write an LLDB language plugin. The last bug report on the list above triggers a discussion in that regard. Very soon I’m going to write a thread on the LLVM mailing list describing the goals of the plugin and discuss the possibility of upstreaming it, however, I’m not too confident that will happen, because Rust among other language plugins being removed from the upstream for “lacking maintainability”.
I already started working on some D integration specifically on the LLDB side, although I haven’t pushed any of this code, since some stuff is still janky experiments and not properly split up.
What is next?
Next week, now that I have some scope about DWARF, I’m going to tackle majorly on the LLDB integration, since that is what the milestone is focused on. I’m going to clean up the idea I have of the language plugin and hopefully show some interesting practical results.
You can also read this on the D programming language forum, here, and discuss there.