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

Problems and workarounds for debugging C3 on Windows #1646

Open
heavymetalmixer opened this issue Nov 26, 2024 · 6 comments
Open

Problems and workarounds for debugging C3 on Windows #1646

heavymetalmixer opened this issue Nov 26, 2024 · 6 comments
Assignees
Labels
Bug Something isn't working
Milestone

Comments

@heavymetalmixer
Copy link

heavymetalmixer commented Nov 26, 2024

After watching the same pattern as with Zig (ziglang/zig#22039) I thought it could be an issue from LLVM, but with C3 there are other small issues added on top of it:

  1. LLDB starts debugging the line AFTER the breakpoint. Now, this doesn't mean "line number" but code line, so the if developer wrote down the next code line 4 lines below, LLDB will jump 4 lines down.

  2. Both LLDB and MSVC Debugger ignore module declarations (the thing at the top of the file) and imports. MSVC debugger jumps to the main function if there's a breakpoint on an import or module, LLDB looks for the next breakpoint and ends the debugging session if there's none.

@lerno
Copy link
Collaborator

lerno commented Nov 26, 2024

What happens with the MSVC debugger in the first case.

@heavymetalmixer
Copy link
Author

What happens with the MSVC debugger in the first case.

The MSVC debugger starts at the breakpoint unlike LLDB.

@lerno
Copy link
Collaborator

lerno commented Nov 26, 2024

Does compiling C with Clang give the right output then?

@heavymetalmixer
Copy link
Author

Does compiling C with Clang give the right output then?

Yeah, as it should on both C and C++.

@lerno
Copy link
Collaborator

lerno commented Nov 26, 2024

Could you perhaps create a small sample and dump the LLVM here for C and the corresponding C3 program? Maybe paste in a gist if it's too big.

@lerno lerno self-assigned this Nov 26, 2024
@lerno lerno added the Bug Something isn't working label Nov 26, 2024
@lerno lerno added this to the 0.6.6 milestone Nov 26, 2024
@heavymetalmixer
Copy link
Author

Could you perhaps create a small sample and dump the LLVM here for C and the corresponding C3 program? Maybe paste in a gist if it's too big.

I'm sorry if this si frustrating to you. I'm a novice and I don't know how to make an LLVM dump, so i used llvm-pdbutil dump to get info about the PDB file and I got the following:

llvm-pdbutil dump -summary main.pdb

                          Summary
============================================================
  Block Size: 4096
  Number of blocks: 1398
  Number of streams: 240
  Signature: 849705519
  Age: 1
  GUID: {32A57A2F-08C4-FC45-4C4C-44205044422E}
  Features: 0x1
  Has Debug Info: true
  Has Types: true
  Has IDs: true
  Has Globals: true
  Has Publics: true
  Is incrementally linked: false
  Has conflicting types: false
  Is stripped: false

The code is a simple Hello World:

#include <stdio.h>

int main(void) {
    printf("Hello world!\n");
    return 0;
}

If this isn't what you're looking for, let mw know what I should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants