ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
debug_mpi.h
Go to the documentation of this file.
1 /*
2  * debug_mpi.h
3  *
4  * Created by Tim Ewart on 14.03.11.
5  * Copyright 2011 University of Geneva. All rights reserved.
6  *
7  */
8 
9 #ifndef __DEBUG_MPI__
10 #define __DEBUG_MPI__
11 
12 /*
13  How to use :
14  1- place a break point in the code where you need information
15  2- start the code with mpi, you get the pid of the process, attach gdb to the process (Xcode->Run->attach to process)
16  3- set the state variable to 1 (gdb command : set var state = 1)
17 
18  Enjoy the graphic debuger, unfortunately only on one process in xcode, the second one must be controled
19  by hand using gdb/terminal
20 
21 */
22 
24 {
25 public:
26  breakpoint():state(0)
27  {
28  gethostname(hostname, sizeof(hostname));
29  printf("PID %d on %s ready for attach\n", getpid(), hostname);
30  fflush(stdout);
31  stop();
32  }
33 
34  void stop()
35  {
36  while(state == 0)
37  sleep(1);
38  }
39 
40 private:
41  int state;
42  char hostname[256];
43 
44 };
45 
46 
47 #endif
48 
void stop()
Definition: debug_mpi.h:34
breakpoint()
Definition: debug_mpi.h:26