Upload
badersadij
View
145
Download
0
Embed Size (px)
Citation preview
www.tetcos.com
Debugging in NetSimUsing Graphical User Interface (GUI)
and Command Line Interface (CLI)
www.tetcos.com
1:Debugging through GUI1. Before start any simulation
or debugging, make sure you make a back up of simulation folder present in <NetSim_Install_Dir>\src\Simulation. Eg: “C:\Program Files (x86)\NetSim Standard\src\Simulation”.
2. Work on the folder Simulation
3. The folder simulation-copy is a back-up of the original files
A prerequisite to debugging is that the user has already
completed the “Hello World” Program in NetSim
www.tetcos.com
1:Debugging through GUI4. Create a scenario in GUI of
the respective protocol5. Open the protocol’s init
function. This will be present in the .c file of respective protocol
6. Ex : fn_NetSim_Zigbee_Init() in 802_15_4.c. fn_NetSim_CR_Init( ) in 802.22.c
7. Write getch() at the start of the above function.
www.tetcos.com
1:Debugging through GUI
8. Build the protocol and replace the dll in bin folder in NetSim. Do not
close Visual Studio.
9. In NetSim, create a network scenario and simulate.
10. The simulation won’t start and will pause (because of getch()).
11. Switch to the Visual Studio window and put break point inside the
source code where you want to debug.
12. Go to “Debug->Attach to Process” in Visual studio and attach to
NetSimCore.exe.
www.tetcos.com
1:Debugging through GUI
13. Click on “Attach” and continue the simulation by pressing Enter.
www.tetcos.com
1. The App path is the file location in the system in which NetSim has been installed.
2. Typically this path would be “C:\Program Files\NetSimStandard\bin”
3. To get it, right click on the NetSim icon and select Open File Location.
4. The IO path (Input/output Path) is the path where the input and output files of an application is written.
5. For NetSim, the IO path can be got by Start -> Run-> %temp%/NetSim.
6. Once you reach this folder, the user would notice that the path would be something like “C:\Users\Ram\AppData\Local\Temp\NetSim”
2:Information needed for CLI
www.tetcos.com
2:Information needed for CLI7. The IO path is the path where the Configuration.xml (NetSim
Config file) of the scenario, that will be simulated, should be present.
8. Create the required scenario in GUI as described previously to get the config file( Ignore steps 4 and 7 of GUI)
9. You may also need the IP Address of the License Server. If the user is running a floating license then this is the address of where the dongle is running
10. For node locked licenses the IP Address need not be entered
www.tetcos.com
3:Debugging through CLI1. Create the required scenario in GUI as described previously to get
the config file( Ignore steps 4 and 7 of GUI)2. In the command window (cmd), open your apppath ( Write cd
<apppath> in cmd)3. Then type NetSimCore.exe<space> -apppath<space><app
path><space>-iopath<space><io path><space>-license<space>5053@<Server IP Address> -d
Figure 3.1
www.tetcos.com
3:Debugging through CLI
4. Then press Enter key to get screen like figure given below
Figure 3.2
www.tetcos.com
5. Now follow the steps 8 to 10 as mentioned in Debugging with GUI section
3:Debugging through CLI
www.tetcos.com
3:Debugging through CLI6. Enter the desired event id where you want to break ( see prev.
fig.) Execution will stop at the desired Event Id ( see fig. below)
www.tetcos.com
3:Debugging through CLI7. Press enter then control goes to visual studio and stops at the
break point in the source code as shown in figure below.
8. All debugging options like step over (F10), step into (F11), step out (Shift + F11), continue(F5) are available.
www.tetcos.com
4:Co-relating with Event Trace (CLI)
1. Enable the Event trace manually in the config file.2. The config file Configuration.xml is located inside the IO Path.
Open this file in notepad / visual studio and change file name & path in line marked in figure below; and set STATUS=ENABLE.
3. Sometimes in visual studio the entire file is opened in 1 line and to see it in the correct format, click the reformat selection icon
www.tetcos.com
4:Co-relating with Event Trace (CLI)
4. Run the simulation as described in debugging through CLI section without the the debug (–d) option.( This generates the event trace)
5. Rename the Event trace file generated in previous step. This is done to avoid over writing of the file when the simulation is run. So while debugging the code flow is compared against a recorded event trace.
6. Run the simulation as described in Debugging Through CLI section again and enter -1 as event id to break in .This is required to watch the variable.
www.tetcos.com
7. Open the C file inside the protocol folder inside Simulation folder that has the init function as explained in the earlier slides. The run function will be present in the same file.
8. There will be a switch case statement , where the switch is on the variable nEventType.
4:Co-relating with Event Trace (CLI)
www.tetcos.com
4:Co-relating with Event Trace (CLI)
9. Set a break point there and check the values of members of this struct as the code executes using F5, F10 and F11 keys
10. Add a watch as described in the coming slides on pstruEventDetails variable .
11. Compare it with the event trace file generated in steps 1-4. The values will match exactly.
www.tetcos.com
5:Viewing & Accessing variables1. To follow a variable through execution, use “Add Watch” option
available.2. Some variables cannot be viewed directly when added in the watch
tab, as this would throw the error: “CX0017: Error:symbol“Variable_Name”not found”.
3. In the call stack window one can find the file in which that variable is situated.
4. If this file is grey color in the call stack window, then load it knowing the location of its .pdb file (Refer to user manual)
www.tetcos.com
5. Otherwise, if variable is already loaded add prefix {,,<filename>.dll} to the variable name and press enter (Refer to user manual)
6. For eg. For viewing pstruEventDetails prefix {,,NetworkStack.dll}.
5:Viewing & Accessing variables
• Prefixing {,,Networkstack.dll} before
variable name and press Enter to see
the watch window.