[mpich-discuss] Displaying source after attaching to an MPI job

Peter Thompson peter.thompson at roguewave.com
Tue Sep 22 15:38:17 CDT 2015


This question came to me in my support role for TotalVIew.   When you are 
debugging an MPI job, and attach after the job goes parallel, why don't you see 
the source for the main program? Instead you are usually located in the 
assembler code someplace, in some library above MPI_Init,  and you have to go 
down the stack frame to see the source for your program.

There is a solution though.   Way back when, when the MPIR_proctable interface 
was designed to help the debugger acquire processes automatically, there was a 
global variable defined MPIR_force_to_main.  If this is defined in debugger.c as 
a global variable, then indeed, when you start up TotalView.   Here's a diff of 
the change:

*** debugger.c~ 2015-07-22 17:59:51.000000000 -0400
--- debugger.c  2015-09-22 16:18:21.000000000 -0400
***************
*** 11,17 ****
   int MPIR_proctable_size = 0;
   int MPIR_i_am_starter = 0;
   int MPIR_partial_attach_ok = 0;
!
   volatile int MPIR_debug_state = 0;
   char *MPIR_debug_abort_string = 0;

--- 11,17 ----
   int MPIR_proctable_size = 0;
   int MPIR_i_am_starter = 0;
   int MPIR_partial_attach_ok = 0;
! int MPIR_force_to_main = 0;
   volatile int MPIR_debug_state = 0;
   char *MPIR_debug_abort_string = 0;


The MPI being discussed was Intel MPI, but I've always understood that to be 
based on MPICH, and I thought this would be a good place to start.   I had the 
same discussion in the Open MPI group a few years ago, and they had dropped the 
variable at one point since it did not appear to be used in any way.   The code 
certainly doesn't make use of it, but when the debugger starts looking for it, 
that's when the magic happens.  ;-)  I tried just defining the variable in 
debugger.h, but I think it got optimized away since I just set up

extern int MPIR_force_to_main;

and didn't assign a value at that point.

Cheers,
PeterT

-- 
Peter Thompson | Principal Technical Support Engineer |
Rogue Wave Software, Inc.
Accelerating Great Code


| P 508-652-7734 | F 508-652-7701 |
www.roguewave.com / peter.thompson at roguewave.com


_______________________________________________
discuss mailing list     discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss


More information about the discuss mailing list