Difference between revisions of "Programming Howto:Attach the Debugger to a BCI2000 Module"

From BCI2000 Wiki
Jump to: navigation, search
(Switch to debug mode and rebuild)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Back==
 
==Back==
 
To [[Programming Howto:Building and Customizing BCI2000|this howto's overview page]].
 
To [[Programming Howto:Building and Customizing BCI2000|this howto's overview page]].
 +
 +
==Switch to debug mode and rebuild==
 +
Make sure that the build mode is set to "Debug". If you switched from a different build mode, rebuild by choosing "Build" from the project's context menu.
 +
[[File:debug_0.png|center]]
  
 
==Create a batch file to start up your configuration==
 
==Create a batch file to start up your configuration==
 
Duplicate a SignalGenerator batch file from the BCI2000 batch directory. Which one you choose may depend on the task your module is going to be used with.
 
Duplicate a SignalGenerator batch file from the BCI2000 batch directory. Which one you choose may depend on the task your module is going to be used with.
  
[[File:debug_1.png]]
+
[[File:debug_1.png|center]]
  
 
Rename the duplicated file to contain "VeryNiceSignalProcessing" in its name.
 
Rename the duplicated file to contain "VeryNiceSignalProcessing" in its name.
  
[[File:debug_2.png]]
+
[[File:debug_2.png|center]]
  
 
Edit the batch file by adding <tt>--EvaluateTiming=0</tt> to the SignalGenerator line, and by replacing the signal processing module's name with "VeryNiceSignalProcessing".
 
Edit the batch file by adding <tt>--EvaluateTiming=0</tt> to the SignalGenerator line, and by replacing the signal processing module's name with "VeryNiceSignalProcessing".
  
[[File:debug_3.png]]
+
[[File:debug_3.png|center]]
  
 
Double-click the batch file to start up BCI2000.
 
Double-click the batch file to start up BCI2000.
  
[[File:debug_4.png]]
+
[[File:debug_4.png|center]]
  
 
==Attach the debugger==
 
==Attach the debugger==
 
In the VisualStudio IDE, set a breakpoint in <tt>VeryNiceFilter::StartRun()</tt>, and choose "Attach to Process..." from the "Debug" menu.
 
In the VisualStudio IDE, set a breakpoint in <tt>VeryNiceFilter::StartRun()</tt>, and choose "Attach to Process..." from the "Debug" menu.
  
[[File:debug_5.png]]
+
[[File:debug_5.png|center]]
  
 
From the process list, choose "Very Nice Signal Processing", and click "Attach".
 
From the process list, choose "Very Nice Signal Processing", and click "Attach".
 +
 +
[[File:debug_6.png|center]]
  
 
==Verify that execution stops at the breakpoint==
 
==Verify that execution stops at the breakpoint==
[[File:debug_6.png]]
+
In the Operator window, click "Set Config" ...
  
In the Operator window, click "Set Config" ...
+
[[File:debug_7.png|center]]
 +
 
 +
... and "Start", which will execute <tt>VeryNiceFilter::StartRun()</tt> ...
  
[[File:debug_7.png]]
+
[[File:debug_8.png|center]]
  
... and "Run", which will execute <tt>VeryNiceFilter::StartRun()</tt> ...
+
... and cause the debugger to stop execution at the breakpoint you set earlier.
  
[[File:debug_8.png]]
+
[[File:debug_9.png|center]]
  
and cause the debugger to stop execution at the breakpoint you set earlier.
+
You may now step through the code, set more breakpoints, etc. When you are done, don't forget to "Quit" the Operator module from its "File" menu to terminate any BCI2000 modules that are still running.
  
[[File:debug_9.png]]
+
[[File:debug_10.png|center]]
  
 
==Next step==
 
==Next step==

Latest revision as of 13:27, 24 August 2018

Back

To this howto's overview page.

Switch to debug mode and rebuild

Make sure that the build mode is set to "Debug". If you switched from a different build mode, rebuild by choosing "Build" from the project's context menu.

Debug 0.png

Create a batch file to start up your configuration

Duplicate a SignalGenerator batch file from the BCI2000 batch directory. Which one you choose may depend on the task your module is going to be used with.

Debug 1.png

Rename the duplicated file to contain "VeryNiceSignalProcessing" in its name.

Debug 2.png

Edit the batch file by adding --EvaluateTiming=0 to the SignalGenerator line, and by replacing the signal processing module's name with "VeryNiceSignalProcessing".

Debug 3.png

Double-click the batch file to start up BCI2000.

Debug 4.png

Attach the debugger

In the VisualStudio IDE, set a breakpoint in VeryNiceFilter::StartRun(), and choose "Attach to Process..." from the "Debug" menu.

Debug 5.png

From the process list, choose "Very Nice Signal Processing", and click "Attach".

Debug 6.png

Verify that execution stops at the breakpoint

In the Operator window, click "Set Config" ...

Debug 7.png

... and "Start", which will execute VeryNiceFilter::StartRun() ...

Debug 8.png

... and cause the debugger to stop execution at the breakpoint you set earlier.

Debug 9.png

You may now step through the code, set more breakpoints, etc. When you are done, don't forget to "Quit" the Operator module from its "File" menu to terminate any BCI2000 modules that are still running.

Debug 10.png

Next step

As a next step, learn how to programmatically wait for the debugger in a BCI2000 module.

See also

Programming Howto:Building and Customizing BCI2000