Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source mapping from IR #242

Open
4 tasks
jeaye opened this issue Feb 6, 2025 · 0 comments
Open
4 tasks

Add source mapping from IR #242

jeaye opened this issue Feb 6, 2025 · 0 comments
Assignees

Comments

@jeaye
Copy link
Member

jeaye commented Feb 6, 2025

Overview

When using a debugger, or viewing a stack trace, we want jank source information tied to our native code. This requires specifically emitting that information in the LLVM IR which we generate.

Steps

  • Add a flag to enable source mapping (-g)
  • When that flag is enabled, generate source information for all expressions
    • Start with just function definitions, then add fn calls, then work on let bindings, etc
  • Verify this is working in GDB, LLDB, etc
  • Verify this is working for stacktrace generation

References

The LLVM documentation for this is here: https://llvm.org/docs/SourceLevelDebugging.html

The LLVM build-your-own-language tutorial has a chapter on this: https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.html

I would also use Clang, with LLVM IR output enabled, to see what it adds. For example:

❯ cat source-info.c
#include <stdio.h>

int main()
{
    printf("meow");
    return 0;
}

❯ clang -O0 -ggdb -S -emit-llvm -o - source-info.c
<inspect output>
@jianlingzhong jianlingzhong self-assigned this Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants