From b9f97b53c24b6253c71251a0aa4633871cffe9a2 Mon Sep 17 00:00:00 2001 From: Dirack Date: Sun, 25 Feb 2024 11:48:58 -0300 Subject: [PATCH 1/2] [chore](debug): Add debug script for sfnhcrssurf #49 Add a GDB debug script and a makefile command to build a debug version of the program sfnhcrssurf for debugging sessions with GDB --- debug/Makefile | 22 ++++++++++++++-------- debug/README.md | 26 ++++++++++++++++++++++++-- debug/gdb_scripts/gdb_script_nhcrssurf | 16 ++++++++++++++++ debug/test_data_cube/SConstruct | 21 +++++++++++++++++++++ 4 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 debug/gdb_scripts/gdb_script_nhcrssurf diff --git a/debug/Makefile b/debug/Makefile index f1cccc2..ee5122d 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -14,26 +14,31 @@ #CENTOS=1 DEP = ../vfsacrsnh_lib.c +DEP_SURF=../nhcrssurf_lib.c GDBDEP = ../Mvfsacrsnh.c $(DEP) +GDBDEP_SURF=../Mnhcrssurf.c $(DEP_SURF) UNITY = Unity/unity.c # Default is to run the test -all: vfsa.x generate_data_cube +all: generate_data_cube vfsa.x nhcrssurf.x -%.x: %.c +# Generate a version of the program for debugging with GDB +vfsa.x: generate_data_cube $(GDBDEP) + @echo "\033[95mGenerate a version of the program for debugging with GDB...\033[m" ifdef CENTOS - @gcc -I$$RSFSRC/include -I/usr/include/openblas -L$$RSFSRC/lib $< $(DEP) $(UNITY) -o $@ -lm -lrsf -lopenblas -g + gcc -I$$RSFSRC/include -I/usr/include/openblas -L$$RSFSRC/lib $(GDBDEP) -o $@ -lm -lrsf -lopenblas -g -fopenmp else - @gcc -I$$RSFSRC/include -L$$RSFSRC/lib $< $(DEP) $(UNITY) -o $@ -lm -lrsf + gcc -g -I$$RSFSRC/include -L$$RSFSRC/lib $(GDBDEP) -o $@ -lrsf -lm -fopenmp endif + @echo "...done" # Generate a version of the program for debugging with GDB -vfsa.x: generate_data_cube $(GDBDEP) +nhcrssurf.x: generate_data_cube $(GDBDEP_SURF) @echo "\033[95mGenerate a version of the program for debugging with GDB...\033[m" ifdef CENTOS - gcc -I$$RSFSRC/include -I/usr/include/openblas -L$$RSFSRC/lib $(GDBDEP) -o $@ -lm -lrsf -lopenblas -g -fopenmp + gcc -I$$RSFSRC/include -I/usr/include/openblas -L$$RSFSRC/lib $(GDBDEP_SURF) -o $@ -lm -lrsf -lopenblas -g -fopenmp else - gcc -g -I$$RSFSRC/include -L$$RSFSRC/lib $(GDBDEP) -o $@ -lrsf -lm -fopenmp + gcc -g -I$$RSFSRC/include -L$$RSFSRC/lib $(GDBDEP_SURF) -o $@ -lrsf -lm -fopenmp endif @echo "...done" @@ -52,6 +57,7 @@ clean: help: @echo "Run 'make' or 'make vfsa.x' to prepare a program version for GDB" - @echo "Run 'make gdbtest' run test in GDB shell" + @echo "Run 'make' or 'make nhcrssurf.x' to prepare a program version for GDB" + @echo "Run 'make gdbtest' run vfsa test in GDB shell" .PHONY: clean help all diff --git a/debug/README.md b/debug/README.md index 9aaf961..d5adb4b 100644 --- a/debug/README.md +++ b/debug/README.md @@ -1,8 +1,30 @@ # Debug directory for vfsa debug sessions with GDB -- GDB debug session: Run 'make' or 'make vfsa.x' to generate the executable vfsa.x +This directory is a framework for debugging sessions with GNU debugger (GDB) and +VFSA programs. The programs versions are compiled for gdb and arguments are loaded +using gdb scripts. In the directory 'test\_data\_cube', dummy data is build to be +offered as input in debugging sessions. + +Above, the debugging options: + +- GDB debug session: Run 'make' or 'make vfsa.x' or 'make nhcrssurf.x' +to generate the executable vfsa.x or 'nhcrssurf.x' to be used in debugging with GNU Debugger (GDB). The 'gdb\_scripts/gdb\_script' file can be used to load all arguments needed to run the program in GDB. Use 'source gdb\_scripts/gdb\_script' in GDB shell. -- GDB test: Run 'make gdbtest' to run tests in GDB shell. +- GDB test: Run 'make gdbtest' to run 'vfsa.x' tests in GDB shell. + +## Usage examples + +To run 'vfsa.x' with a gdb script called 'gdb\_script' use: + +``` +gdb --command=gdb_scripts/gdb_script ./vfsa.x +``` + +To run 'nhcrssurf.x' with a gdb script called 'gdb\_script\_nhcrssurf' use: + +``` +gdb --command=gdb_scripts/gdb_script_nhcrssurf ./nhcrssurf.x +``` diff --git a/debug/gdb_scripts/gdb_script_nhcrssurf b/debug/gdb_scripts/gdb_script_nhcrssurf new file mode 100644 index 0000000..e6b5936 --- /dev/null +++ b/debug/gdb_scripts/gdb_script_nhcrssurf @@ -0,0 +1,16 @@ +# gdb_script (GDB Script) +# +# Purpose: Load test parameters in GDB. Use the command +# 'source gdb_script' inside gdb shell to load args. +# +# Site: https://www.geofisicando.com +# +# Programmer: Rodolfo A C Neves (Dirack) 25/02/2024 +# +# Email: rodolfo_profissional@hotmail.com +# +# License: GPL-3.0 . + +cd test_data_cube/ +set args teste.rsf +show args diff --git a/debug/test_data_cube/SConstruct b/debug/test_data_cube/SConstruct index 3a52777..37120cc 100644 --- a/debug/test_data_cube/SConstruct +++ b/debug/test_data_cube/SConstruct @@ -57,5 +57,26 @@ Flow('rnipmin',None,'spike n1=25 d1=1 o1=0 mag=1 | put n1=5 n2=5') Flow('betamax',None,'spike n1=25 d1=1 o1=0 mag=-1 | put n1=5 n2=5') Flow('betamin',None,'spike n1=25 d1=1 o1=0 mag=1 | put n1=5 n2=5') +# Parameter file to debug sfnhcrssurf +param = 'crsParameters' +rn = 4.725 +rnip = 0.2558 +beta = -0.001232 +semb = 0.5248 +Flow(param+'.asc',None, + ''' + echo %g %g %g %g n1=4 d1=1 o1=0 data_format=ascii_float in=${TARGETS} + '''%(rn,rnip,beta,semb)) + +Flow(param,param+'.asc', + ''' + dd type=float form=native + ''') + +#Flow('crsAppSurface',['dataReflectionSurface','crsParameters'], +# ''' +# nhcrssurf param=${SOURCES[1]} m0=%g v0=%g t0=%g verb=y +# ''' % (m0,v0,t0)) + End() From 82a5dce85e9444a46063d8cd8be2f941469a8b44 Mon Sep 17 00:00:00 2001 From: Dirack Date: Sun, 25 Feb 2024 11:53:33 -0300 Subject: [PATCH 2/2] Remove zombie code --- debug/test_data_cube/SConstruct | 5 ----- 1 file changed, 5 deletions(-) diff --git a/debug/test_data_cube/SConstruct b/debug/test_data_cube/SConstruct index 37120cc..16bcaf7 100644 --- a/debug/test_data_cube/SConstruct +++ b/debug/test_data_cube/SConstruct @@ -73,10 +73,5 @@ Flow(param,param+'.asc', dd type=float form=native ''') -#Flow('crsAppSurface',['dataReflectionSurface','crsParameters'], -# ''' -# nhcrssurf param=${SOURCES[1]} m0=%g v0=%g t0=%g verb=y -# ''' % (m0,v0,t0)) - End()