dlang / project-ideas

Collection of impactful projects in the D ecosystem
36 stars 12 forks source link

Write an LLDB plugin for dlang #81

Open Geod24 opened 3 years ago

Geod24 commented 3 years ago

Description

LLDB is the LLVM debugger. It's the main debugger on Mac OSX and available on other platforms. Currently, support for LLDB is rather poor. While GDB support has been implemented years ago by @ibuclaw (), LLDB still doesn't know much about D.

Support for language is implemented via Plugins. The goal of this project is to write such a plugin, and to upstream it.

What are rough milestones of this project?

  1. Get familiar with the capability of plugins, what is possible / isn't;
  2. Get a basic plugin architecture in place, which is called when dlang is detected;
  3. Implement demangling of D symbols, most likely integrating the same code as GDB;
  4. Recognize D-specific data structures, such as arrays, associative arrays, typeinfo...
  5. Implement support for parsing D expressions, e.g. the ability to do "foo"[0 .. 2] in myAA;

How does this project help the D community?

Currently, one of the biggest obstacle in D adoption is the tool support. Notable, the debugging experience is miles behind other established languages.

Recommended skills

C++ proficiency. Knowledge of Linux and how binaries are generated. Experience with debugging in other native languages, such as C / C++. DWARF or LLVM knowledge is a plus.

What can students expect to get out of doing this project?

Deep knowledge of how debugging works at the core. Participation in not just one, but two open source projects.

Rating

Medium - Hard

Project Type

Infrastructure/Automation

Point of Contact/Possible Mentors

@Geod24

References

The DWARF standard: http://www.dwarfstd.org/ DMD debug info generator: https://github.com/dlang/dmd/blob/master/src/dmd/backend/dwarfdbginf.d LDC debug info generator: https://github.com/ldc-developers/ldc/blob/master/gen/dibuilder.cpp Example of a simple D-related contribution: https://reviews.llvm.org/D79559 Previous attempt limited to demangling: https://reviews.llvm.org/D44321 Associated discussion: https://lists.llvm.org/pipermail/lldb-dev/2016-September/011321.html

Geod24 commented 3 years ago

@jblachly @timotheecour @JohanEngelen would you be interested in being point of contact as well ?

Geod24 commented 3 years ago

Same question for @Luhrel

jblachly commented 3 years ago

I cannot commit to being primary mentor, but I would be happy to co-mentor (gratis) along with another expert if a student is selected for this project.

In addition to plugin, the LLDB team have signaled that they are potential amenable to including dlang types added directly; see my patch which added support for C++20 char8_t, as well as dlang's immutable characters:

https://reviews.llvm.org/D66447

They kept the char8_t work and suggested that the dlang changes (i.e. recognizing character types by name) could be acceptable but should be split out. Unfortunately I did not complete this. This would complement Mathias' work (linked above) in which character types are recognized by size. It has been a couple years since I loooked but LDC2 last I checked emits DWARF DW_ATE_UTF irrespective of whether the char (wchar, dchar) is plain, const, or immutable. Related, I see that @Luhrel has a pending PR for DMD to add DWARF immutable tag.

maxhaton commented 3 years ago

It would be good if this ended up with some boilerplate/guidance along the lines of "How to add D support to your toolchain" on our website, thinking about it.

Luhrel commented 3 years ago

@Geod24 I've never contributed to LLVM, so I'm not sure I'll be a good mentor, unfortunately.

JohanEngelen commented 3 years ago

@Geod24 I like the project, but I lack the time to commit as primary mentor. I think it'd be good if we could find an LLDB developer to provide regular guidance too, because the actual source contribution would be mainly in that project. I don't know what the current status is of language/plugin support, but I think figuring out how to handle languages that are not at the core of LLVM development is the biggest issue to tackle.

JohanEngelen commented 3 years ago

See https://reviews.llvm.org/rG7310403e3cdf for demangling support in LLVM, which is much more than just LLDB.