30
edits
Changes
→User Interface
*3. Add test files on each projects
[[File:1klee214.PNG|1000px800px]]
'''Start debugging with multiple processes'''
*Select Apply, or OK to apply and close the dialog.
[[File:2klee214.PNG|1000px800px]]
*In the Attach to Process dialog box, select the process from the Available Processes list, and then select Attach.
[[File:3klee214.PNG|1000px800px]]
'''Use the Registry Editor to automatically start a process in the debugger'''
*Right-click debugger and select Modify.
[[File:4klee214.PNG|1000px800px]]
'''Debug with multiple processes'''
*Under Tools (or Debug) > Options > Debugging > General, select or clear the Break all processes when one process breaks check box.
[[File:5klee214.PNG|1000px800px]]
'''Switch between processes'''
*In the Processes window, the current process is marked by a yellow arrow. Double-click the process you want to set as the current process.
[[File:7klee214.PNG|1000px800px]]
= User Interface =
The Attach to Process dialog box shows outside processes to be attached to the visual Studio debugger.
[[File:8klee2149klee214.PNG|1000px]]
'''You can attach the following processes'''
You can choose one of the processes during debugging mode.
[[File:9klee2148klee214.PNG|1000px]]
==Threads window==
'''Setup:'''
This is the default window when working in visual studio. If it is closed for a particular file, it can be re-opened by double clicking any linked items (like functions imported from it), or by double clicking the filename in the project pane.
'''How to Use:'''
Source Window has many options for debugging. From the debug menu, many diagnostic tools can be accessed. Furthermore, the context menu in this window has many features which can help in debugging. See this image for more details.
In the this window's gutter, breakpoints appear as red dots. They can be added or removed by clicking in the gutter.
[[File:SourceWindow.jpeg]]
==Debug Location toolbar==
Run Debug with a breakpoint
Select Debug from the menu
'''How to Use:'''
'''Features:''' <br/>
1. Switch to another frame of the thread [[File:Screenshot_(10).png|1000px]][[Screenshot_(11) 2. Toggle to change to the '''methods view'''.png]] [[File:Screenshot_(12).png|1000px]] [[File:Screenshot_(13).png]][[Screenshot_(15).png|1000px]]
==Parallel Tasks window==
'''Setup:'''
Open '''Call Stack''' from the Debug -> Windows [[File:Parallelstack1.png]] <br/> Open '''Threads''' from Debug -> Windows [[File:Parallelstack2.png]]
'''How to Use:'''
==Parallel Watch window==
The parallel watch window allows the user to watch the thread and variables by organizing the columns by the preferred view of order/filter.
'''Setup:'''
'''How To Use:'''
Users can select variables to put on a parallel watch.
The selected variable is added to the watch and it shows value in steps for all active threads.
'''Features:'''
Freeze/unfreeze the thread if you want to pause one thread to investigate another thread.
= Walkthrough =
[[File:ParallelNumThreadsThreadWindow.jpg]]
==Case B - Using the Parallel Stacks and the Parallel Watch Window== <syntaxhighlight lang="cpp"> #include <iostream> #include <thread> #include <vector> #include<omp.h> #include <chrono> #include <string> using namespace std; void print(int n, const std::string& str) { std::string msg = std::to_string(n) + " : " + str; std::cout << msg << std::endl; } int main() { std::vector<std::string> s = { "Hello World", "Hello", "This", "is", "a testing", "code", "for", "multithread", "debugging" }; std::vector<std::thread> threads;
for (int i = 0; i < s.size(); i++) {
threads.push_back(std::thread(print, i, s[i]));
}
for (auto& th : threads) {
th.join();
}
return 0;
}
</syntaxhighlight>
The main program calls the print function for the size of the string vector.
Threads are open when it is called and join back on line 33.
'''Setup:'''
Set breakpoints at the definition of the function, and when join() is called.
Debug using F5 or by clicking debug from the top menu bar.
Here is the '''output''' of the program:
<syntaxhighlight lang="bash">
0 : Hello World
3 : is
6 : for
2 : This
5 : code
7 : multithread
8 : debugging
1 : Hello
4 : a testing
</syntaxhighlight>
There are 9 different threads that were being created and used every time print() is called.
Using Parallel Stacks Windows, we are able to see the call stack information through a UI.
----
'''Walkthrough:'''
First Call:
<br/>
[[File:parallelstackswalkthrough1.png]]
<br/>
It is being called at the definition of the function "print()"
<br/>
<br/>
The yellow arrow means the currently executing thread.
By advancing more threads,
<br/><br/>
[[File:parallelstackswalkthrough2.png]]
[[File:parallelstackswalkthrough6.png]]
<br/><br/>
https://en.wikipedia.org/wiki/Help:Cheatsheet