May 22, 2012 ... Is it possible to use Microsoft Visual Studio to debug the production code ...
Debugging production code with Visual Studio 6.0 is only possible ...
dSPACE FAQ 724
FAQ 724
Debugging Production Code Keywords debug; code analysis; Microsoft Visual Studio Question Is it possible to use Microsoft Visual Studio to debug the production code generated by TargetLink? Solution Debugging production code with Visual Studio 6.0 is possible only with TargetLink 2.0 or later. For debugging production code with Visual Studio .net 2003 or later, TargetLink 2.1 or later is needed. This document provides an excerpt of the TargetLink user documentation:
Contents How to debug Production Code .......................................... 1
1.
How to Debug Production Code with Visual Studio 6.0
2
1.1.
Preconditions ................................................... 2
1.2.
Starting a Debug Session ........................................... 2
2.
How to Debug Production Code with Visual Studio .net 2003 (or Later)
4
2.1.
Preconditions ................................................... 4
2.2.
Starting a Debug Session ........................................... 4
Debugging Production Code FAQ Version: 4 / 2016-09-23 Page 1
dSPACE FAQ 724
This document applies to TargetLink 3.1 and earlier. In TargetLink 3.2 and later, production code debugging with Visual Studio is integrated. Refer to the relevant sections of the dSPACE user documentation: TargetLink Production Code Generation Guide > Simulating a Model and Analyzing Simulation Results > Debugging in SIL Simulation Mode > How to Debug in SIL Simulation Mode. For TargetLink 3.5 and higher: TargetLink Preparation and Simulation Guide > Simulating Models and Analyzing Simulation Results > Debugging in SIL Simulation Mode > How to Debug in SIL Simulation Mode.
1. How to Debug Production Code with Visual Studio 6.0 The following steps describe how to use Microsoft Visual Studio 6.0 to debug generated code. 1.1. Preconditions The following preconditions must be fulfilled: TL 2.0 or later is installed. Visual Studio 6.0 is installed. The Mex compiler is switched to Visual Studio 6.0. To do this, enter 'mex –setup' in the MATLAB Command Window. 1.2.
Starting a Debug Session
To start a debug session, perform the following steps: 1. Open MATLAB and the TargetLink model (e.g., a TargetLink demo model). Open the TargetLink Main Dialog, go to the Options page and set the host compiler option ‘–g’.
2. Build code for SIL simulation (Build Host). 3. Start Visual Studio and attach the MATLAB process to the debug session. Refer to the following illustrations:
Debugging Production Code FAQ Version: 4 / 2016-09-23 Page 2
dSPACE FAQ 724
4. Start the simulation of the TargetLink model. 5. Switch to Visual Studio and open the generated production code (e.g., pidcontroller.c for the TargetLink demo VCFP).
6. Specify a breakpoint in the generated production code. After the model simulation is restarted, the debugger stops at the breakpoint.
Debugging Production Code FAQ Version: 4 / 2016-09-23 Page 3
dSPACE FAQ 724
2. How to Debug Production Code with Visual Studio .net 2003 (or Later) The following steps describe how to use Microsoft Visual Studio .net 2003 (or later) to debug generated code. 2.1. Preconditions The following preconditions must be fulfilled: TargetLink 2.1 or later is installed. Visual Studio .net 2003 (or later) is installed. The Mex compiler is switched to the Visual Studio version whose compiler is to be used for debugging. To do this, enter “mex –setup” in the MATLAB Command Window. The environment variable I86_MSVC_ROOT contains the path of the Visual Studio version whose compiler is to be used for debugging, for example: D:\Program Files\Microsoft Visual Studio 8\VC. 2.2. Starting a Debug Session 1. Open makefile.mk in %dSPACE_ROOT%\Matlab\Tl\SimFiles\HostPC\MSVC in an editor and search for the following variable: for TargetLink 2.2 and earlier: DebugWithMSVC70 for TargetLink 2.3 and later: DebugWithMSVCStudio 2. Set this variable to 1, i.e., 'DebugWithMSVC70=1’ or ‘DebugWithMSVCStudio = 1'. 3. Open MATLAB and the TargetLink model, e.g., a TargetLink demo model. 4. Open the TargetLink Main Dialog and build code for SIL simulation (Build Host). 5. Start Visual Studio and open the generated production code (e.g., pidcontroller.c for the TargetLink demo VCFP). Refer to the following illustration:
For TargetLink 3.1, the source files to be debugged must be taken from %MODEL_DIR%\TLSim\TestDebugging\HostPC_MSVC.
Debugging Production Code Version: 32 / 2016-09-23
pg. 4
dSPACE FAQ 724
6. Attach the MATLAB process to the debug session. Refer to the following illustrations:
7. Start the simulation of the TargetLink model. Simulating the model is not mandatory. However, if you do not simulate the model, the breakpoints are labeled with question marks because the relevant DLL file is not in the memory yet.
Debugging Production Code Version: 32 / 2016-09-23
pg. 5
dSPACE FAQ 724
8. Switch to Visual Studio. Set a breakpoint in the generated code. When you restart the model simulation, the debugger stops at the breakpoint. Before you can (re)build the host for the TargetLink model after simulating the model with MATLAB, you must close Visual Studio. Otherwise, an error occurs.
Related FAQs
Debugging Production Code Version: 32 / 2016-09-23
pg. 6
dSPACE FAQ 724
How to Contact dSPACE Support dSPACE GmbH Rathenaustraße 26 33102 Paderborn Germany ++49 5251 1638-941 mailto:
[email protected] http://www.dspace.com/support
dSPACE recommends that you use the support request form on the Internet to contact dSPACE Support. It is available at:
http://www.dspace.com/go/supportrequest
Software Updates and Patches dSPACE strongly recommends that you download and install the most recent patches for your current dSPACE installation. Visit http://www.dspace.com/go/patches for software updates and patches. FAQ FAQ documents are available at http://www.dspace.com/go/faq.
Important Notice This document contains proprietary information that is protected by copyright. All rights are reserved. Neither the documentation nor software may be copied, photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form, in whole or in part, without the prior written consent of dSPACE GmbH. © Copyright 2016 by: dSPACE GmbH Rathenaustraße 26 33102 Paderborn Germany This publication and the contents hereof are subject to change without notice. A list of registered dSPACE trademarks is available at: http://www.dspace.com/go/Trademarks
Debugging Production Code Version: 32 / 2016-09-23
pg. 7