I only list few functions and commands that I use them to
find bugs in R and C. I will come back to explain them when
I have time.
#### Debug in R
- Rdebug.pdf
- I lost the original of this file. Please tell me where this good
slide came from if you knew.
- R-debug-tools.pdf
- Roger D. Peng, UCLA, Department of Statistics.
#### Debug in C
- ddd
- Linux command: nm
, ld
, gprof
.
- valgrind
Quick Example:
```
SHELL> gcc -g -o a.out *.c
SHELL> valgrind --show-reachable=yes --leak-check=full a.out
SHELL> valgrind --track-origins=yes ./a.out
SHELL> gcc -pg -o a.out *.c
SHELL> ./a.out
SHELL> gprof > a.prof
```
#### Debug in R call C
- valgrind
Quick Example:
```
SHELL> gcc -shared -g -o a.so *.c
SHELL> R -d "valgrind --show-reachable=yes --tool=memcheck --leak-check=full" \
--vanilla < a.r
SHELL> R -d "valgrind --track-origins=yes" --vanilla < a.r
```
Here, "a.r" should load "a.so" at the first.
- Debugging with GDB
#### Debug in MPI for R call C
- valgrind
Quick Example:
```
SHELL> gcc -shared -g -o a.so *.c
SHELL> mpiexec -np 2 R -d \
"valgrind --show-reachable=yes --tool=memcheck --leak-check=full --log-file=a.log" \
--vanilla -f a.r
SHELL> mpiexec -np 2 R -d \
"valgrind --track-origins=yes --log-file=a.log" \
--vanilla -f a.r
```
Here, "a.so" is a MPI application, "a.r" should load "a.so" at the first, and
the output file "a.log" has the tracing results.
---