commit 2609773618f3c434879b04ae53735bab47c0d95c
parent ed11ad69e137e489433205a1fc6c6adca9281a78
Author: Luís Ferreira <[email protected]>
Date: Thu, 21 Oct 2021 02:36:30 +0100
posts: Add 'SAOC LLDB D integration: 5th Weekly Update'
Signed-off-by: Luís Ferreira <[email protected]>
Diffstat:
2 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/content/posts/d-saoc-2021-04.md b/content/posts/d-saoc-2021-04.md
@@ -87,4 +87,5 @@ mentor. On the meanwhile, I made my TODO list open and automatically deployed,
at least daily, so you can see what I'm doing during the week
[here](tasks.lsferreira.net) .
-Read about the [previous week](../d-saoc-2021-03/).
+Read about the [previous week](../d-saoc-2021-03/) and [next
+week](../d-saoc-2021-05/).
diff --git a/content/posts/d-saoc-2021-05.md b/content/posts/d-saoc-2021-05.md
@@ -0,0 +1,90 @@
+---
+title: 'SAOC LLDB D integration: 5th Weekly Update'
+date: '2021-10-21T01:33:00+01:00'
+tags: ['saoc', 'saoc2021', 'dlang', 'llvm', 'lldb', 'debug', 'debugging', 'dwarf']
+description: "This post describes what I've done on the 5th week of the
+Symmetry Autumn of Code 2021, including follow up on LLVM patches, researching
+on DWARF standard tags and attributes, investigation of what debug info is
+generated among D compilers, written patches to DMD compiler and small updates
+for LLDB plugin."
+---
+
+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.
+
+- https://reviews.llvm.org/D111948
+- https://reviews.llvm.org/D111947
+
+## 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_count` or `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](https://gist.github.com/ljmf00/0194d03f6f30303feec9f58eb9f0c7df).
+
+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:
+
+- https://github.com/dlang/dmd/pull/13196
+- https://issues.dlang.org/show_bug.cgi?id=22423
+- https://github.com/dlang/dmd/pull/13200
+- https://issues.dlang.org/show_bug.cgi?id=22426
+- https://github.com/dlang/dmd/pull/13202
+- https://github.com/dlang/dmd/pull/13204
+- https://bugs.llvm.org/show_bug.cgi?id=52223
+
+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.
+
+## LLVM Plugin
+
+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.
+
+Read about the [previous week](../d-saoc-2021-04/).