Skip to content

Conversation

@dwblaikie
Copy link
Contributor

@dwblaikie dwblaikie commented Nov 12, 2025

This helps at least lldb handle calling functions (currently the debug
info describes every function as void(), so no parameters or return
values are supported) - seems gdb and lldb both depend on demangling to
varying degrees in C code (marking a function as "prototyped" in C in
DWARF does seem to also address this problem).

Given:

fn PrintThree() {
  Core.Print(3);
}

Before:

  (lldb) p PrintThree()
  error: Couldn't look up symbols:
    PrintThree
  Hint: The expression tried to call a function that is not present in
    the target, perhaps because it was optimized out by the compiler.

After:

  (lldb) p PrintThree()
  3
  (lldb)

@dwblaikie dwblaikie requested a review from a team as a code owner November 12, 2025 21:34
@dwblaikie dwblaikie requested review from geoffromer and removed request for a team November 12, 2025 21:34
llvm::DIFile* compile_unit_file = di_builder.createFile(module_name, "");
// TODO: Introduce a new language code for Carbon. C works well for now since
// it's something debuggers will already know/have support for at least.
// Probably have to bump to C++ at some point for virtual functions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is done now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yep - thanks! updated the comment in 9423c63

@dwblaikie dwblaikie requested a review from geoffromer November 14, 2025 23:52
This helps at least lldb handle calling functions (currently the debug
info describes every function as `void()`, so no parameters or return
values are supported) - seems gdb and lldb both depend on demangling to
varying degrees in C code (marking a function as "prototyped" in C in
DWARF does seem to also address this problem).

Given:
fn PrintThree() {
  Core.Print(3);
}

Before:
  (lldb) p PrintThree()
  error: Couldn't look up symbols:
    PrintThree
  Hint: The expression tried to call a function that is not present in
    the target, perhaps because it was optimized out by the compiler.

After:
  (lldb) p PrintThree()
  3
  (lldb)
@dwblaikie dwblaikie force-pushed the debug_info_lang_c_plus_plus branch from 9423c63 to 3ce398a Compare November 18, 2025 18:11
@dwblaikie dwblaikie enabled auto-merge November 18, 2025 18:12
@dwblaikie dwblaikie added this pull request to the merge queue Nov 18, 2025
Merged via the queue into carbon-language:trunk with commit bb99428 Nov 18, 2025
8 checks passed
@dwblaikie dwblaikie deleted the debug_info_lang_c_plus_plus branch November 18, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants