Dear Axel and Steve,
As a follow-up to my earlier question, I am trying to learn how lammps works by following the code execution with gdb but I am finding:
- backtrace cannot give me all the functions before pair.cpp - instead of file:line-number I get a memory address and “??”:
(This example is using RESPA)
Breakpoint 1, LAMMPS_NS::ComputePEMolTally::pair_tally_callback (this=0x100a0b5a0, i=0, j=1, nlocal=1105, newton=1, evdwl=0,
ecoul=-2.9017068011391349) at …/compute_pe_mol_tally.cpp:96
96 if ( ((mask[i] & groupbit) && (mask[j] & groupbit2))
(gdb) bt
#0 LAMMPS_NS::ComputePEMolTally::pair_tally_callback (this=0x100a0b5a0, i=0, j=1, nlocal=1105, newton=1, evdwl=0,
ecoul=-2.9017068011391349) at …/compute_pe_mol_tally.cpp:96
#1 0x00000001003b6709 in LAMMPS_NS::Pair::ev_tally (this=0x100a098b0, i=0, j=1, nlocal=1105, newton_pair=1, evdwl=0,
ecoul=-2.9017068011391349, fpair=-0.14064396945146065, delx=-1.3739999999999988, dely=-0.66300000000000026,
delz=-0.16599999999999948) at …/pair.cpp:908
#2 0x3ff217eb8ee294fc in ?? ()
#3 0x00000001000e6460 in ?? () at …/compute_pe_mol_tally.cpp:86
#4 0x00000001055b99d6 in ?? ()
#5 0x0000000100a098b0 in ?? ()
#6 0x0000000100a0b5a0 in ?? ()
#7 0x00000000ade2fd05 in ?? ()
#8 0x3ff10f6f9c6b86ea in ?? ()
#9 0xbfd2bf929b1e6594 in ?? ()
#10 0x3fe6f789b8a10c27 in ?? ()
#11 0xbfc53f7ced916860 in ?? ()
#12 0xbfe5374bc6a7efa0 in ?? ()
#13 0xbff5fbe76c8b4390 in ?? ()
#14 0xbfc2009f20963a0d in ?? ()
#15 0xc00736b20e2bc971 in ?? ()
#16 0x0000000000000000 in ?? ()
-
the first line that gdb hits is not a main function, but a line in library.cpp:
(gdb) start -in in.lammps -e both
Temporary breakpoint 1 at 0x100324110: main. (2 locations)
Starting program: /Users/jeff/lammps/src/lmp_serial -in in.lammps -e both
Temporary breakpoint 1, 0x0000000100324130 in lammps_create_atoms (ptr=0x1, n=0, id=0x7fff5fbff580, type=0xa900adb097f62c82,
x=0x0, v=0x0, image=0x0, shrinkexceed=0) at …/library.cpp:1041
1041 if (image) atom->image[nlocal] = image[i];
-
certain lines and files (like read_data.cpp) can not have breakpoints placed:
(gdb) break read_data.cpp:126
Cannot access memory at address 0x100000160
I understand I need to compile with gdb flags and no optimization, so I modified Makefile.serial to be:
CC = g++
CCFLAGS = -ggdb -O0
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = g++
LINKFLAGS = -ggdb -O0
LIB =
SIZE = size
ARCHIVE = ar
ARFLAGS = -rc
SHLIBFLAGS = #-shared (I tried with and without shared)
(I do have FFTW on this mac, but I added “FFT_INC = -DFFT_NONE” to use KISS)
I also made sure to compile STUBS/Makefile with gdb flags
CC = g++
CCFLAGS = -ggdb -O0 -fPIC -I.
ARCHIVE = ar
ARCHFLAG = rs
Do I need to make further changes to the makefiles?
Any guidance would be appreciated.
(I ask here because I figure this is a problem with my understanding of how to compile lammps, rather than a problem with how to use gdb, but please accept my apologies if this guess is wrong.)
Thank you.
Best,
Jeff