I have an exe file which will execute the cpp files and capture the results. I want to debug the cpp file which is being called by the exe file in the visual studio.
Currently
I am loading the exe file as a project in the Visual studio, i open the c++ code which is called by exe file as well and keep breakpoints at relevant places. when I run the exe file it does not stop at the breakpoint but continues execution and stops.
Is any settings to be made in the visual studio to gain control over the cpp code while debugging.
#santosh I think you are loading VC++ Project file(Not Exe file)
you have t build your project (compilation of the project).
Put a breakpoint in menu bar debugging->start debugging or Press F5.
Even though your debugger not hitting the breakpoint check your "symbols" in VisualStudio in menu bar Tools -> Options -> Debugging-> Symbols tick the Microsoft symbol servers press ok.
Again build your project and debug.
Related
This may have a very simple solution, but being new to Visual Studio and C++ programming, I'm having a hard time with this.
I downloaded an SDK written in C++ which contains an executable file and also the source and header files. The executable file accepts some command line arguments. So far I've been running the executable file from the windows command prompt (like C:\path\filename.exe -argument), but now I want to be able to enter these command line arguments and then place breakpoints in the source code for debugging the source code.
I don't know how I can open the source files in Visual Studio and debug it. If I just open the source file with the main function, the debug button says 'Attach' on it instead of debug.
I see another similar question here, but that question is for a project developed using Visual Studio whereas the source code I have does not have any Visual Studio project/solution files. The only files I have are the executable, the source and header files (.cpp, .h, .hpp), and CMakeLists.txt files.
You can "open" the exe as a project (you can achieve the same if you drag and drop the exe into VS icon). Then you can add command line parameters at Project Properties. You will need to have debug symbol information (usually a .pdb file), if you want source code level debugging (values of variables, etc.). If you don't have that, you can only debug at the disassembly level.
You may want to create a proper project for the source files - it is an easy task, if the project is simple - so you can rebuild the exe.
I have C++ code in visual studio and an exe with pdb file, the exe is a command line utility.
I want to debug the executable. I cannot compile the source code in visual studio since it has a large no. of dependencies.
Is there a way where I can attach the debugger to debug the executable.
If it is compiled with VC++ then yes. Run your code, and attach the debugger from the menu: "Debug/Attach to process".
If you want to start the process with the debugger already attached, the follow this tutorial:
http://msdn.microsoft.com/en-us/library/0bxe8ytt.aspx.
To create an EXE project for an existing executable
On the File menu, click Open and select Project.
In the Open Project dialog box, click the drop-down list next to the File name box, and select All Project Files.
Locate the executable, and click OK.
This creates a temporary solution that contains the executable.
If yo did this, you can simply click on "Debug".
I have compiled an exe file in Visual Studio 2013, and it depends on some external files to function. I want to keep those files in the same folder that the exe is in. When I run the .exe by clicking on it in file explorer, it loads the files fine. However, when I run it from Visual Studio, it is unable to run because the PATH variable does not include the directory with the necessary files. How can I configure my project to run the program with a modified path variable so that it can access the files properly?
As far as I understand you question correctly. I suspect that this is an issue related to the different directories when you execute. In Visual Studio (to my knowledge), you have a folder named Debug and a second folder named Release.
You may choose in Visual Studio to run the program in either debug or release mode. But you might not have the required files neccessary in both directories.
For example:
I've made a program that reads "Hello World!" from hello.txt, and displays this in the dialog window as a string.
If I store the file in the Release directory, the executable will run fine outside the IDE, when just launching the executable file.
However, if you run the application in debug mode through the IDE (Visual Studio), the program will not find the neccessary file. The program is looking for the file in it's current directory (Debug).
A quick fix to this is to copy the required files to the current working directory. Eventually have a duplicate set of files in both directories at all times.
Hope that I did understand you correct, and that my answer helps you. :)
I have a separate Visual Studio solution with the DLL written in C. I use it in another solution; in a console C++ project. While debugging the console project I step into a DLL function.
However, the page is opened reporting that There is no source code available for the current location with call stack location MyConsole.exe!_tailMerge_MyLibrary_dll(). I use delay loading of the DLL file in the console project. As the no source code page is displayed, I inspect the output window and find symbols loaded of the DLL line. Why does Visual Studio 2012 fail to step into this DLL code?
I had the same problem and the following solved mine. I set "Debugger Type" to "Mixed" on the properties page of the main project. My main project is managed code while the .dll is native.
It happens, when dealing with external projects that Visual Studio asks you if you have the code. If you cancel the process, the requested file gets added to a list in the solution and it remembers NOT to ask for the file again.
Check your Solution Property Pages > Debug Source Files. First, make sure your file is NOT in Do not look for these source files: and then make sure you add the location of the sources in the Directories containing source code. This should help fix the problem.
I got a minidump from a server on which my native c++ app was running. I also have the exe and pdb files. I am able to open the minidump using Visual Studio 2005 Pro and it correctly loads the symbols from the pdb file.
I run the debugger (F5) and it shows me that it crashed. When I click on the stack trace to see where, it tells me that it can't find the source code "There is no source code available for the current location.".
How do I tell Visual Studio where the source code is?
My exe is an optimized release build that I build with a pdb file.
From this MSDN page:
In the Solution Property Pages, you can change the directories where the debugger looks for sources files and tell the debugger to ignore selected source files. See Debug Source Files, Common Properties, Solution Property Pages Dialog Box.
Make sure you supply VS with the sources that correspond to the binaries and PDB files.
Normally, VS should ask you where the sources are when first double-clicking a stack frame. I ran into a problem where VS would pop up the There is no source code available for the current location. dialog when clicking on some stack frames only, but display the source for others. This turned out to be because the /Zi flag was not set for some projects, causing the link back to the source files to be missing. This flag can be set in Project Propery Pages > C/C++ > General > Debug Information Format.