Skip to content

Commit

Permalink
Merge pull request #50 from Dirack/feature/issue/49
Browse files Browse the repository at this point in the history
Feature/issue/49
  • Loading branch information
Dirack authored Feb 25, 2024
2 parents 89be591 + 82a5dce commit 75b4af6
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
22 changes: 14 additions & 8 deletions debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
26 changes: 24 additions & 2 deletions debug/README.md
Original file line number Diff line number Diff line change
@@ -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
```
16 changes: 16 additions & 0 deletions debug/gdb_scripts/gdb_script_nhcrssurf
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/gpl-3.0.txt>.

cd test_data_cube/
set args <dataCube.rsf param=crsParameters.rsf m0=5 v0=1.5 t0=1.1 verb=y > teste.rsf
show args
16 changes: 16 additions & 0 deletions debug/test_data_cube/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,21 @@ 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
''')

End()

0 comments on commit 75b4af6

Please sign in to comment.