Difference between revisions of "GPU621/OpenMP Debugging"

From CDOT Wiki
Jump to: navigation, search
(Process and thread)
(Process and thread)
Line 26: Line 26:
 
*3. Add test files on each projects
 
*3. Add test files on each projects
  
[[File:1klee214.jpg]]
+
[[File:1klee214.png]]
  
 
'''Start debugging with multiple processes'''
 
'''Start debugging with multiple processes'''
Line 40: Line 40:
 
*Select Apply, or OK to apply and close the dialog.
 
*Select Apply, or OK to apply and close the dialog.
  
[[File:2klee214.jpg]]
+
[[File:2klee214.png]]
  
  
Line 53: Line 53:
 
*In the Attach to Process dialog box, select the process from the Available Processes list, and then select Attach.
 
*In the Attach to Process dialog box, select the process from the Available Processes list, and then select Attach.
  
[[File:3klee214.jpg]]
+
[[File:3klee214.png]]
  
 
'''Use the Registry Editor to automatically start a process in the debugger'''
 
'''Use the Registry Editor to automatically start a process in the debugger'''
Line 69: Line 69:
 
*Right-click debugger and select Modify.
 
*Right-click debugger and select Modify.
  
[[File:4klee214.jpg]]
+
[[File:4klee214.png]]
  
 
'''Debug with multiple processes'''
 
'''Debug with multiple processes'''
Line 80: Line 80:
 
*Under Tools (or Debug) > Options > Debugging > General, select or clear the Break all processes when one process breaks check box.
 
*Under Tools (or Debug) > Options > Debugging > General, select or clear the Break all processes when one process breaks check box.
  
[[File:5klee214.jpg]]
+
[[File:5klee214.png]]
  
 
'''Switch between processes'''
 
'''Switch between processes'''
Line 96: Line 96:
 
*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.
 
*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:6klee214.jpg]]
+
[[File:6klee214.png]]
  
 
= User Interface =
 
= User Interface =

Revision as of 23:34, 5 December 2021

Group Members

  1. Kimin Lee
  2. Jashua Luna
  3. Irene Park

Process and thread

Process

A process is the instance of a computer program that is being executed by one or many threads.

Thread

A thread is a sequence of instructions to which the operating system grants processor time. Every process that is running in the operating system consists of at least one thread. Processes that have more than one thread are called multithreaded.

Multiple Processes Debug

Visual Studio can debug a solution that has several processes. You can start and switch between processes, break, continue, and step through source, stop debugging, and end or detach from individual processes.

Create two projects

To test it, the best way with Visual Studio is creating two projects.

  • 1. Create a new project of Visual Studio
  • 2. Add a new project within the Solution
  • 3. Add test files on each projects

File:1klee214.png

Start debugging with multiple processes

If you have more than one project in a project solution, you can choose which projects the debugger starts.

Follow this:

  • Select the solution in Solution Explorer and then select the Properties icon in the toolbar, or right-click the solution and select Properties.
  • On the Properties page, select Common Properties > Startup Project.
  • Select Current selection, Single startup project and a project file, or Multiple startup projects.
  • If you select Multiple startup projects, you can change the startup order and action to take for each project: Start, Start without debugging, or None.
  • Select Apply, or OK to apply and close the dialog.

File:2klee214.png


Attach to a process

The debugger can also attach to apps running in processes outside of Visual Studio, including on remote devices. After we attach to an app, we can use the Visual Studio debugger.

Follow this:

  • With the app running, select Debug > Attach to Process.
  • In the Attach to Process dialog box, select the process from the Available Processes list, and then select Attach.

File:3klee214.png

Use the Registry Editor to automatically start a process in the debugger

We might need to debug the startup code for an app that is launched by another process. You can have the debugger launch and automatically attach to the app.

Follow this:

  • Start the Windows Registry Editor by running regedit.exe.
  • In Registry Editor, navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options.
  • Select the folder of the app that you want to start in the debugger.
  • If the app isn't listed as a child folder, right-click Image File Execution Options, select New > Key, and type the app name. Or, right-click the new *key in the tree, select Rename, and then enter the app name.
  • Right-click the new key in the tree and select New > String Value.
  • Change the name of the new value from New Value #1 to debugger.
  • Right-click debugger and select Modify.

File:4klee214.png

Debug with multiple processes

When debugging an app with several processes, the breaking, stepping, and continuing debugger commands affect all processes by default. You can change this option.

Follow this:

  • Under Tools (or Debug) > Options > Debugging > General, select or clear the Break all processes when one process breaks check box.

File:5klee214.png

Switch between processes

Only one process should be active in the debugger at any given time. We can set the active or current process in the Debug Location toolbar, or in the Processes window. To switch between processes, both processes must be in break mode.

To set the current process from the Debug Location toolbar:

  • To open the Debug Location toolbar, select View > Toolbars > Debug Location.
  • During debugging, on the Debug Location toolbar, select the process you want to set as the current process from the Process dropdown.

To set the current process from the Processes window:

  • To open the Processes window, while debugging, select Debug > Windows > 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:6klee214.png

User Interface

For processes, the primary tools are the Attach to Process dialog box, the Processes window, and the Debug Location toolbar.

For threads, the primary tools for debugging threads are the Threads window, thread markers in source windows, Parallel Stacks window, Parallel Watch window, and the Debug Location toolbar.

Attach to Process dialog box

The Attach to Process dialog box shows outside processes to be attached to the visual Studio debugger.

Example.jpg

You can attach the following processes

  • Process name (.exe)
  • Process ID number
  • Menubar Title
  • Type (Managed v4.0; Managed v2.0, v1.1, v1.0; x86; x64; IA64)
  • User Name (account name)
  • Session number

Action you can perform

  • Select a process to attach to
  • Select a remote computer
  • Change transport type for connecting to remote computers

Processes window

The Process Window shows processes attached to the Visual Studio debugger. You can choose one of the processes during debugging mode.

Example.jpg

Threads window

Setup:


How to Use:


Columns:


Source window

Setup:


How to Use:


Debug Location toolbar

You can set the active or current process in the Debug Location toolbar.

Example.jpg

Debug Location toolbar has the following options:

  • Current process
  • Suspend the application
  • Resume the application
  • Suspend and shut down the application
  • Current thread
  • Toggle current thread flag state
  • Show only flagged threads
  • Show only current process
  • Current stack frame

With this options you can perform the following actions:

  • Switch to another process
  • Suspend, resume, or shut down the application
  • Switch to another thread in current process
  • Switch to another stack frame in current thread
  • Flag or unflag current threads
  • Show only flagged threads
  • Show only the current process

Parallel Stacks window

Setup:


How to Use:


Features:


Parallel Tasks window

Parallel Watch window

Setup:


How To Use:

Features:

Walkthrough

Case A - Using the Thread window

serial region


auto OpenMP parallel region



OpenMP parallel region thread number decided (8)

Case B - Using the Parallel Stacks and the Parallel Watch Window

Setup:



Walkthrough:


Setup:


Walkthrough:


https://en.wikipedia.org/wiki/Help:Cheatsheet