cray-lgdb / attach

Issue #78 new
jg piccinali repo owner created an issue

Cray's lgdb is a GDB-based parallel debugger used to debug applications (CCE, PGI, GNU, INTEL * Fortran,C,C++).

Launch

brisi01: slurm/16.05.4

  • module load cray-lgdb/3.0.2
  • cd /scratch/santis/piccinal/lgdb.eff/
  • make
cc  -g -o hello_mpi_c hello_mpi.c
ftn  -g -o hello_mpi_f hello_mpi.f90
CC  -g -o hello_mpi_cpp hello_mpi.cpp
  • lgdb
dbg all> launch $a{12} ./hello_mpi_c
...
Launch complete.
a{0..11}: Initial breakpoint, main at hello_mpi.c:18

dbg all> break hello_mpi.c:21
a{0..11}: Breakpoint 1: file hello_mpi.c, line 21.

dbg all> continue

dbg all> print myRank
a{0}: 0
a{1}: 1
a{2}: 2
a{3}: 3
a{4}: 4
a{5}: 5
a{6}: 6
a{7}: 7
a{8}: 8
a{9}: 9
a{10}: 10
a{11}: 11

dbg all> quit
Shutting down debugger and killing application for 'a'.

Comments (7)

  1. jg piccinali reporter

    Attach

    • cd ~/201607/SciComp.git/Training/mpiomp/ATTACH/
    • cc -g -D_ATTACH mpic.c
    • echo 0 > go ; srun --unbuffered -n2 ./a.out
    • squeue
    JOBID
    400901
    
    • lgdb
    dbg all> attach $a 400901.0
    Attaching to application, please wait...
    ...
    dbg all> break mpic.c:68
    a{0..1}: Breakpoint 2: file mpic.c, line 68.
    
    dbg all> list
    a{0..1}: 68   printf("%d/%d ",rank,size);
    a{0..1}: 69   MPI_Finalize();
    a{0..1}: 70 
    a{0..1}: 71   return 0;
    a{0..1}: 72 }
    
    dbg all> print rank
    a{0}: 0
    a{1}: 1
    
    dbg all> print size
    a{0..1}: 2
    
    dbg all> release $a
    Shutting down debugger and resuming application for 'a'.
    dbg all> quit
    
  2. jg piccinali reporter
    int main(int argc, char **argv) {
      int rank=0 ; // false
      if (rank == 0) {
        char name[255]; gethostname(name, sizeof(name)); bool attached;
        printf("rank %d: pid %d on %s ready to attach\n", rank, getpid(), name);
        while (!attached) { sleep(5); }
        }
    

  3. jg piccinali reporter
    #ifdef _ATTACH
           integer          go, cscs
           go=0
           cscs=0
            if ( myid == 0 ) then
            do while (go /= 9)
    ! ATTACH debugger to RUNNING JOB
    ! INFINITE LOOP => echo 0 > go
    !       TO STOP => echo 9 > go
            OPEN(UNIT=8,FILE='go',STATUS='OLD',FORM='FORMATTED',IOSTAT=cscs)
            READ(UNIT=8,FMT='(I1)',ADVANCE='NO',IOSTAT=cscs) go
            print *,'go=',go
            CLOSE(UNIT=8)
            call sleep(5)
            enddo
            endif
    #endif
    ! -- CSCS: infinite loop to let debugger attach to running job
    

  4. jg piccinali reporter
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <unistd.h>
    
    int main (){
        std::ifstream myfile;
        int attached=9;
        while ( attached != 0 ) {
            myfile.open("go.txt");
            myfile >> attached;
            myfile.close();
            sleep(2);
            std::cout << "attached=" << attached << '\n';
        }
        std::cout << "END attached=" << attached << '\n';
        return 0;
    }
    

  5. Log in to comment