Debugging Clang with Visual Studio

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging Clang with Visual Studio

David Chisnall via cfe-dev
Hi all,

I Built Clang from source using Visual Studio in debug mode, and I'm trying to debug it.
However, the debugger doesn't break on any breakpoint that I put.
When I put breakpoints directly using __debugbreak(), clang just crashes with the even though the debugger is attached.

(I'm sure that this code flow actually happens, as I added some llvm::errs to prove it)

The original Cmake command was:
cmake.exe -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_IDE=ON -G "Visual Studio 15 2017" -A x64 -Thost=x64 <path_to_llvm>

Am I doing something wrong?
Is there some other step that I'm missing?

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Clang with Visual Studio

David Chisnall via cfe-dev
This would be an issue of the Visual Studio debugger, not of the
program you are debugging.

Like this is because when you launch clang, you are launching just the
driver which invokes itself as `clang -cc1` (although under some
conditions it invokes itself directly). Visual Studio does not debug
processes the

To see what happens, I suggest to start debugging using "step into"
(or set a breakpoint in main of driver.cpp) and continue from there.

Michael


Am Di., 14. Juli 2020 um 02:00 Uhr schrieb Shachaf Co via cfe-dev
<[hidden email]>:

>
> Hi all,
>
> I Built Clang from source using Visual Studio in debug mode, and I'm trying to debug it.
> However, the debugger doesn't break on any breakpoint that I put.
> When I put breakpoints directly using __debugbreak(), clang just crashes with the even though the debugger is attached.
>
> (I'm sure that this code flow actually happens, as I added some llvm::errs to prove it)
>
> The original Cmake command was:
> cmake.exe -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_IDE=ON -G "Visual Studio 15 2017" -A x64 -Thost=x64 <path_to_llvm>
>
> Am I doing something wrong?
> Is there some other step that I'm missing?
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Clang with Visual Studio

David Chisnall via cfe-dev
It seems right - the VS debugger doesn't attach to the new process created by the original one. 

Invoking `clang -cc1` directly works, and is good enough for my purpose.

Thank you very much!
Shachaf

בתאריך יום ג׳, 14 ביולי 2020, 18:43, מאת Michael Kruse ‏<[hidden email]>:
This would be an issue of the Visual Studio debugger, not of the
program you are debugging.

Like this is because when you launch clang, you are launching just the
driver which invokes itself as `clang -cc1` (although under some
conditions it invokes itself directly). Visual Studio does not debug
processes the

To see what happens, I suggest to start debugging using "step into"
(or set a breakpoint in main of driver.cpp) and continue from there.

Michael


Am Di., 14. Juli 2020 um 02:00 Uhr schrieb Shachaf Co via cfe-dev
<[hidden email]>:
>
> Hi all,
>
> I Built Clang from source using Visual Studio in debug mode, and I'm trying to debug it.
> However, the debugger doesn't break on any breakpoint that I put.
> When I put breakpoints directly using __debugbreak(), clang just crashes with the even though the debugger is attached.
>
> (I'm sure that this code flow actually happens, as I added some llvm::errs to prove it)
>
> The original Cmake command was:
> cmake.exe -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_IDE=ON -G "Visual Studio 15 2017" -A x64 -Thost=x64 <path_to_llvm>
>
> Am I doing something wrong?
> Is there some other step that I'm missing?
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Clang with Visual Studio

David Chisnall via cfe-dev
Whenever I debug Clang in VS I like to use this plugin to auto attach to all spawned child processes:

-Matt

On Tue, Jul 14, 2020 at 9:04 AM Shachaf Co via cfe-dev <[hidden email]> wrote:
It seems right - the VS debugger doesn't attach to the new process created by the original one. 

Invoking `clang -cc1` directly works, and is good enough for my purpose.

Thank you very much!
Shachaf

בתאריך יום ג׳, 14 ביולי 2020, 18:43, מאת Michael Kruse ‏<[hidden email]>:
This would be an issue of the Visual Studio debugger, not of the
program you are debugging.

Like this is because when you launch clang, you are launching just the
driver which invokes itself as `clang -cc1` (although under some
conditions it invokes itself directly). Visual Studio does not debug
processes the

To see what happens, I suggest to start debugging using "step into"
(or set a breakpoint in main of driver.cpp) and continue from there.

Michael


Am Di., 14. Juli 2020 um 02:00 Uhr schrieb Shachaf Co via cfe-dev
<[hidden email]>:
>
> Hi all,
>
> I Built Clang from source using Visual Studio in debug mode, and I'm trying to debug it.
> However, the debugger doesn't break on any breakpoint that I put.
> When I put breakpoints directly using __debugbreak(), clang just crashes with the even though the debugger is attached.
>
> (I'm sure that this code flow actually happens, as I added some llvm::errs to prove it)
>
> The original Cmake command was:
> cmake.exe -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_IDE=ON -G "Visual Studio 15 2017" -A x64 -Thost=x64 <path_to_llvm>
>
> Am I doing something wrong?
> Is there some other step that I'm missing?
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev