Closed yusufcananar closed 8 months ago
Hello everyone,
I am developing a code that writes simulation values to influxdb and visualizes the data in Grafana. I could not debug the trick source code in VsCode either. If you solve the problem, I would be happy if you write it as an answer.
Hi, I have been trying to debug the NASA Trick source for a while. On my other C++ projects, I use GDB for debugging which can be used for breakpoints but for NASA Trick can't figure out how to debug. I planned to develop a new feature for NASA Trick to use in simulation time but couldn't add the feature to the source.
@Fjolnirr @tastangh If you can figure out how to debug, Could you share it with me?
I saw this issue #1500 I guess cmake is still broken.
I have managed to debug whole trick code. Trick sources(services), trick ICG, and simulation model source codes. I will explain what you need to do to debug trick step by step. @tastangh @GITburakdeniz
Before making any changes we will set few env variables:
nano .bashrc
hit enter and go to the end of the page. export CFLAGS="$CFLAGS $1 -O0 -g"
export CXXFLAGS="$CXXFLAGS $1 -O0 -g"
export LDFLAGS="$LDFLAGS $1 -O0 -g"
export TRICK_CFLAGS="$TRICK_CFLAGS $1 -O0 -g"
export TRICK_CXXFLAGS="$TRICK_CXXFLAGS $1 -O0 -g"
export TRICK_LDFLAGS="$TRICK_LDFLAGS $1 -O0 -g"
export TRICK_SYSTEM_CFLAGS="$TRICK_SYSTEM_CFLAGS $1 -O0 -g"
export TRICK_SYSTEM_CXXFLAGS="$TRICK_SYSTEM_CXXFLAGS $1 -O0 -g"
export TRICK_SYSTEM_LDFLAGS="$TRICK_SYSTEM_LDFLAGS $1 -O0 -g"
save and exit.
First you need to add this lines to the Makefile
of the trick located at trick/Makefile
CXX = g++
CXXFLAGS = -std=c++11 -g
./configure
and then make
the trick at TRICK_HOME dir. (You can use make -j8 for faster compilation time)
You need to have simulation like SIM_cannon_analytic
(I have used the one located in trick/trick_sims/Cannon/SIM_cannon_analytic
Open S_overrides.mk
and paste this lines:
TRICK_CFLAGS += -I../models -I/home/backend/trick/trick_source -g
TRICK_CXXFLAGS += -I../models -I/home/backend/trick/trick_source -g
In terminal, use trick-CP -g
command:
backend@backend-VirtualBox:~/trick/trick_sims/Cannon/SIM_cannon_analytic$ trick-CP -g
Open vscode at TRICK_HOME dir.
Create a launch.json file. This is for attaching to process on launch.
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch SimExe",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/trick_sims/Cannon/SIM_cannon_analytic/S_main_Linux_11.4_x86_64.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"additionalSOLibSearchPath": "${workspaceFolder}/lib",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
make sure you have makefile tools extension installed.
In extension editor, select launch target "${workspaceFolder}/trick_sims/Cannon/SIM_cannon_analytic/S_main_Linux_11.4_x86_64.exe"
Open "Run&Debug" menu.
select your launch in this case mine was "(gdb) Launch SimExe"
place your break points all over your model source, or trick sources.
Finally, click the Start Debugging(F5) button.
This is how I have managed to debug trick source and my own model sources. I hope it works for you guys as well. If trick people approve I can turn this answer into tutorial.
Thanks for all the details. Trick does have a couple of docs listed below as examples that contain info on debugging need although not how to use a specific IDE such as vscode to debug. We'll discuss whether to add an IDE specific tutorial as there are various ways.
Hello,
I would like to develop a feature for Nasa Trick software according to my needs where I need to record datas to MongoDB on sim run time. Just like DataRecord service records data to .csv. I will use this data to real-time plot on a react based frontend. I have developed C++ project for mongodb connections and crud operations but I am not sure how can I implement it to trick. I don't know how to debug trick source code. My working environment is Ubuntu 22.04 and I am using Vscode(with makefiletools extension).
What I have tried so far is:
I am very confused about whether I am wrong about the debugging approach or am I facing IDE's environment settings or debugging issues. But I am able to debug my other C++ projects with the current settings.
I have looked through the documentations but I could not resolve the issue by myself. Would you help me to find out how can I debug Nasa Trick source?