Author: Luís Ferreira <email@example.com>
Date: Thu, 18 Nov 2021 20:56:49 +0000
posts: Add 'SAOC LLDB D integration: 9th Weekly Update'
Signed-off-by: Luís Ferreira <firstname.lastname@example.org>
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/content/posts/d-saoc-2021-08.md b/content/posts/d-saoc-2021-08.md
@@ -134,4 +134,5 @@ parallel and probably going to start implementing the D TypeSystem and
DWARFFASTParser, required for the LLDB plugin. These are things not trivial to
me, but I'm going to try to have some output.
-Read about the [previous week](../d-saoc-2021-07/).
+Read about the [previous week](../d-saoc-2021-07/) and the [next
diff --git a/content/posts/d-saoc-2021-09.md b/content/posts/d-saoc-2021-09.md
@@ -0,0 +1,73 @@
+title: 'SAOC LLDB D integration: 9th Weekly Update'
+tags: ['saoc', 'saoc2021', 'dlang', 'llvm', 'lldb', 'debug', 'debugging', 'dwarf']
+description: "This post describes what I've done on the 9th week of the
+Symmetry Autumn of Code 2021, including follow up updates on the LLVM patches
+and some fixed issues."
+Hi D community!
+I'm here again, to describe what I've done during the ninth week of Symmetry
+Autumn of Code.
+## LLVM upstream follow up update
+I started this week updating the rest of the patches to reflect the suggestions
+made in the first patch, such as use a different OutputBuffer and other nit
+codestyle changes. It turns out to be very unproductive week, unfortunately,
+since I got some runtime errors such as heap buffer overflows and heap usage
+after free() calls leading to very weird bugs because of my dumb idea of
+refactoring the existing code.
+TL;DR of the situation, I made a vim macro to substitute the existing
+OutputString to an OutputBuffer and, since comma expressions are a thing,
+situations like `buffer.append(ptr, size);` got silently translated to `buffer
+<< ptr, size;`. Since I preallocated the buffer, the segfaults were
+intermittent. Furthermore, the semantics of my previous Free() method included
+resetting the buffer after a free(), leading to some heap usage after free().
+Anyway, you can check the changes I've made
+## Fixed issues
+### Generate artificial tag on generated main files
+DWARF now generates an artificial tag when `-main` argument is passed
+indicating that the symbol is generated by the compiler. The change can be
+found [here](https://github.com/dlang/dmd/pull/13301). In the meanwhile, I
+accidentally found and [fixed](https://github.com/dlang/dmd/pull/13302) a
+pre-release regression caused by the OutBuffer move when testing this.
+### Associative arrays are now named with its qualified type name
+Instead of printing `_AArray_<key>_<value>` where `<key>` and `<value>` is the
+string representation of the TY, we now have the type name we are used to
+`<value>[<key>]`. This also eliminates the problem where fake TY types are
+internally used -- e.g. `string` types are faked to `ucent` types. You can see
+the change [here](https://github.com/dlang/dmd/pull/13296) and the [associated
+### Attempt to fix the calling convention
+I dug into the backend codegen to understand a bit more about how the calling
+convention is currently being processed. I ended up with a working test
+although very weird errors are happening and I cannot have a reduced
+reproducible test case to locally understand the problem and go forward with
+this, although Martin Kinkelin suggested something that I can start with. You
+can find the WIP PR [here](https://github.com/dlang/dmd/pull/13287).
+### Other reported issues
+On LDC I found out that the compiler always generates the DWARF visibility
+attributes, even if not necessary, leading to bigger binary sizes. I created an
+[issue](https://github.com/ldc-developers/ldc/issues/3870) about that.
+## What is next?
+I ended up not starting the TypeSystem nor DWARFFASTParser implementation. I
+will try to hopefully go forward with it next week.
+Read about the [previous week](../d-saoc-2021-08/).