SAOC LLDB D integration: 5th Weekly Update

Luís Ferreira contact at lsferreira.net
Thu Oct 21 01:48:32 UTC 2021


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.

You can also read this on my blog,
[here](https://lsferreira.net/posts/d-saoc-2021-05).

-- 
Sincerely,
Luís Ferreira @ lsferreira.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20211021/fbb8a71d/attachment.sig>


More information about the Digitalmars-d mailing list