Visual Studio breakpoint don't get hit C++ - c++

I built llvm with clang using cmake to create the Visual studio sln file to debug it in windows. I'm using VS2017 with the v140 (Visual studio 2015) compiler compiled in Debug mode and x64. It compiled with 0 warnings.
I want to set a breakpoint at here and I do so using Visual Studio but it never gets hit and the execution code definitely goes through that line because I put a MessageBox and I can see the pop up.
I've tried using DebugBreak too but it crashes clang.
I've checked the two solutions clang and LLVMAsmPrinter (where the function i'm setting the breakpoint is) and they are compiled with as Debug with symbols.
LLVMAsmPrinter compiles to a .lib file.
I already tried to rebuild the project but not luck either :(
Why is the breakpoint not being hit. Is it because LLVMAsmPrinter is a different project within the same llvm Visual Studio solution
Thanks you all!

Related

How can I debug a .exe from the command line with a .exe generated from cl.exe (Visual Studio C/C++ Compiler)?

How can I debug a .exe from the command line with a .exe generated from cl.exe (Visual Studio C/C++ Compiler)?
If you aren't going to use a proper debugger (such as found with the full version of visual studio or windbg.exe) then your best bet will be old fashioned printed log traces. Add code (when usingh cl.exe usually bracketed by #ifdef _DEBUG/#endif directives) that print messages to the console about your current program state. Using a real debugger is, however, generally much easier.

Exe file from a console project in Visual Studio?

I want to execute a C++ program in a second machine without any IDE.
I tried to launch the .exe file which is located in the debug folder of the project and to generate a .exe file following this guide.
Both .exe gave me the same errors (launched manually and from a prompt):
The program can’t start because
- VCRUNTIME140D.dll
- MSVCP140D.dll
- VCRUNTIME140_1D.dll
- ucrtbased.dll
is missing from your computer. [...]
So i try to uninstall and reinstall Microsoft Visual C++ Redistributable per Visual Studio 2015, 2017 e 2019 from there, but still the same errors.
What am I missing? How can I run it without install the whole Visual Studio IDE? Thanks for your time.
You need to compile your program to a Release exe file. Compiling your program using Debug will never work on any device unless it has Visual Studio installed on it.
Why this happens?
If you select debugging, before the program runs it loads some DLL files for debugging in visual studio. Now, on other machines visual studio may not be installed, so it couldn't find the DLL files so it will just not start. But Release, it is like its name, when you want to send your program to a friend or use it on another computer or share it on the internet, use Release. But if you are testing bugs and still working on the program, use Debug.

Debugging x64 application (C++) using visual studio 2012

I have a visual studio 2012 C++ application which compiles and run, but doesn't stop on breakpoints.
I already installed remote debugger (x64) and also run it and configure it for remote debugging.
In visual studio I tried boith remote debug and local debug, but both of them generate same result. It doesn't stop at breakpoints.
What do I do to debug a x64 c++ application?
Edit 1
Just found that the debugger says:
Symbol loading for myapp.exe was skipped because it is not specified in the includes modules
What that means?
After checking project and build configuration, I found that the Generate debug info in debug part of linker
(Linker ->Debug: generate debug info)
is blank.
After setting it to yes, the debugger starts to work!

SQLAPI++ in VS 2012

I am trying to use SQLapi library from inside Visual Studio 2012 x64 but SQLapi does not have lib & dll.
Of Visual Studio 2012 so I used older version from Visual Studio 2010 dll and lib.
First I got an error msvcr100d.dll not found (I think it is for Visual Studio 2010) even for Visual Studio 2010 x64.
Redistributal is installed, and I added to debug a folder manually, then I ran the program, I got another error.
The application was unable to start correctly (0xc000007b). Click OK to close the application.
This may have been due to debug mode so I changed it to release mode but I got 22 linker errors what is wrong? I am not getting the exact problem.
Thanks in advance.
This problem is solved by SQLAPI team in newer version.

How can I debug a MinGW EXE with the Microsoft Visual C++ debugger?

How can I debug a MinGW EXE with the Microsoft Visual C++ debugger?
You can attach the Visual C++ debugger to any process running on the system (from the Visual C++ menu). But for being able to step through your source code Visual C++ would have to load the symbol file (.pdb if I remember correctly) and I don't think GCC generates those files.
Exists many Visual studio extensions such us: WinGDB, VisualGDB you can find it on the web. It allows you to debug as regular Visual Studio project. These projects are not free but it has full functional 30 days trial. It has some restrictions but it's good enough.
The Problem:
GCC compiler (ie MinGW's gcc) generates debug info with "-g" flag. The debug info is embedded into the generated executable. Windows' compiler, on the other hand, uses a peculiar ".pdb" format to store the debug info. For example, Microsoft Visual Studio's debugger needs not only the executable (.exe), but also its debug info (.pdb) to be available.
The Solution:
There is a small program that can extract .pdb files from executables compiled with gcc.
It is called cv2pdb, available at https://github.com/rainers/cv2pdb.
Download cv2pdb https://github.com/rainers/cv2pdb
Put the cv2pdb.exe somewhere in your path, maybe a custom bin folder, so that it will be accessible through the command line.
Compile your file as usual using MinGW's gcc compiler, with the "-g" flag, so that the debug info is included.
Simply run cv2pdb.exe on your executable.
cv2pdb out.exe
This will generate a out.pdb file in the same directory.
(If you have Microsoft Visual Studio installed) Open the executable directly in Microsoft Visual Studio
devenv out.exe
Note: This command simply opens the executable in Microsoft Visual Studio, without creating a project for it. In effect, you can use whatever text editor + build system you want to build your executable, and then use Visual studio only as a standalone debugger.