-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Comments
What happens with the MSVC debugger in the first case. |
The MSVC debugger starts at the breakpoint unlike LLDB. |
Does compiling C with Clang give the right output then? |
Yeah, as it should on both C and C++. |
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
The code is a simple Hello World:
If this isn't what you're looking for, let mw know what I should do. |
I was looking for the llvm output (-llvm-emit or something like that), but try the latest update now and see if it looks the same. Oh, and are you compiling with -gcodeview for Clang? |
Ok, so after installing LLVM 19.1.4 (I used to have 19.1.0) and making a few tests I can say:
|
So wait, for C you can kind of add a breakpoint on the include itself or what? Aside from that, what else is problematic for C3? |
It seems that for now the only way to reliably debug C3 programs on Windows is with the MSVC debugger, same for Zig. So yeah, this is totally an LLVM v19.1.x issue. |
After downgrading to LLVM 18.1.8:
|
Ok, so there was no improvement for C3 after the changes? |
Also can you compare C using Clang with -gcodeview with C3 / Zig? Because only those are comparable. |
After today's tests of C (-gcodeview), C3 and Zig: The -gcodeview flag for C makes it impossible for LLDB to work. |
Will you try C3 output with the very latest? I made some changes. |
Today (just a few minutes ago) I used the "latest" version which was release around 18 hours ago. I also tried installing LLVM 19.1.5 (released 4 hours ago) but the result didn't change. |
I made mistake with the latest. Pushing something new now. |
Main is special since it has some implicit macro expansions, can you try stopping in some other regular function and see what happens? If the problem is the same or if it works properly there at least. |
This change I added two simple functions to test the debuggin:
So: b) For the sumB function if I set a breakpoint on top of its function name, the debugger does start right there. The same goes for the first line of the function which is a variable definition. |
Thank you, I'll inspect the LLVM output |
The LLVM output (for Clang) surprised me. Basically it's the normal output but just without column information. You can see if the latest update yields a better result. |
Changes from the same code:
|
Is this with native pdb reader? So what are the remaining issues to fix? Just so I understand correctly? Doesn't stop correctly in when placing the breakpoint on the function? How does main behave now? |
a) If I press Step Out and then Step Over until it ends: |
A question: Internally what level of optimization (-Ox) and debug info (-gx) uses LLVM for C3 when building? |
Do you mean what is passed to LLVM in these cases? |
Sorry for taking so long to reply, my ISP gave me a broken router a few days ago. On topic: Yeah, to LLVM. I wasn't able to find info about the debug info and optimization levels in the documentation for C3. |
-g is equivalent to Clang's -g and -g0 to Clang's -g0. For optimization options: C3 |
Ok, so: The only "real" issue right now is that for some reason LLDB ignores io::print variations if they only have a string literal as argument, if that function call has a breakpoint on top of it. I used -g and O0 to compile this time. |
io::print is macro, so maybe that is the reason. |
MSVC debugger doesn't avoid them, but still gets buggy if I try to get into their code. Maybe C3 macros. right now are difficult to get proper debug info for. |
No, it should be possible to get it to work. A "fake" function is created for macros so that they can be entered. What's the behaviour you see? |
To examine the interior of the
|
So MSVC looks fine, or was there still something unexpected? @heavymetalmixer I'm thinking we could add a -gdwarf flag to make it output DWARF only for LLDB. |
That could be a good option tbh, as long as the making PDB files doesn't get removed. |
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:
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.
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.
The text was updated successfully, but these errors were encountered: