Skip to content

Commit 1ba8545

Browse files
authored
Merge pull request #8890 from awlauria/v5.0.x_breakpoint_port
v5.0.x: Add a soft "breakpoint" capability
2 parents 469e944 + c27f9ab commit 1ba8545

File tree

2 files changed

+45
-22
lines changed

2 files changed

+45
-22
lines changed

ompi/runtime/ompi_rte.c

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,32 +1022,35 @@ static void _release_fn(size_t refid, pmix_status_t status,
10221022
debugger_event_active = false;
10231023
}
10241024

1025-
/*
1026-
* Wait for a debugger if asked. We support two ways of waiting for
1027-
* attaching debuggers
1028-
*/
1029-
void ompi_rte_wait_for_debugger(void)
1025+
void ompi_rte_breakpoint(char *name)
10301026
{
10311027
pmix_info_t directive;
10321028
char *evar;
1033-
int time, code = PMIX_ERR_DEBUGGER_RELEASE;
1034-
pmix_info_t info;
1029+
int rc, code = PMIX_DEBUGGER_RELEASE;
1030+
pmix_info_t info[2];
1031+
uint32_t u32, *u32ptr;
1032+
opal_process_name_t pname;
1033+
1034+
if (NULL != name
1035+
&& NULL != (evar = getenv("OMPI_BREAKPOINT"))
1036+
&& 0 != strcasecmp(evar, name)) {
1037+
/* they don't want to stop here */
1038+
return;
1039+
}
10351040

10361041
/* check PMIx to see if we are under a debugger */
1037-
if (NULL == getenv("PMIX_DEBUG_WAIT_FOR_NOTIFY") &&
1038-
NULL == getenv("PMIX_TEST_DEBUGGER_ATTACH")) {
1042+
u32ptr = &u32;
1043+
pname.jobid = opal_process_info.my_name.jobid;
1044+
pname.vpid = OPAL_VPID_WILDCARD;
1045+
OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, "PMIX_DEBUG_STOP_IN_APP",
1046+
&pname, &u32ptr, PMIX_PROC_RANK);
1047+
if (PMIX_SUCCESS != rc) {
10391048
/* if not, just return */
10401049
return;
10411050
}
1042-
1043-
/* if we are being debugged, then we need to find
1044-
* the correct plug-ins
1045-
*/
1046-
ompi_debugger_setup_dlls();
1047-
1048-
if (NULL != (evar = getenv("PMIX_TEST_DEBUGGER_SLEEP"))) {
1049-
time = strtol(evar, NULL, 10);
1050-
sleep(time);
1051+
/* are we included? */
1052+
if (!PMIX_CHECK_RANK(u32, opal_process_info.myprocid.rank)) {
1053+
/* no - ignore it */
10511054
return;
10521055
}
10531056

@@ -1057,11 +1060,13 @@ void ompi_rte_wait_for_debugger(void)
10571060
PMIX_INFO_DESTRUCT(&directive);
10581061

10591062
/* notify the host that we are waiting */
1060-
PMIX_INFO_LOAD(&info, PMIX_EVENT_NON_DEFAULT, NULL, PMIX_BOOL);
1061-
PMIx_Notify_event(PMIX_DEBUG_WAITING_FOR_NOTIFY,
1063+
PMIX_INFO_LOAD(&info[0], PMIX_EVENT_NON_DEFAULT, NULL, PMIX_BOOL);
1064+
PMIX_INFO_LOAD(&info[1], PMIX_BREAKPOINT, "mpi-init", PMIX_STRING);
1065+
PMIx_Notify_event(PMIX_READY_FOR_DEBUG,
10621066
&opal_process_info.myprocid,
1063-
PMIX_RANGE_RM, &info, 1, NULL, NULL);
1064-
PMIX_INFO_DESTRUCT(&info);
1067+
PMIX_RANGE_RM, info, 2, NULL, NULL);
1068+
PMIX_INFO_DESTRUCT(&info[0]);
1069+
PMIX_INFO_DESTRUCT(&info[1]);
10651070

10661071
/* let the MPI progress engine run while we wait for debugger release */
10671072
OMPI_WAIT_FOR_COMPLETION(debugger_event_active);
@@ -1070,6 +1075,22 @@ void ompi_rte_wait_for_debugger(void)
10701075
PMIx_Deregister_event_handler(handler, NULL, NULL);
10711076
}
10721077

1078+
/*
1079+
* Wait for a debugger if asked. We support two ways of waiting for
1080+
* attaching debuggers
1081+
*/
1082+
void ompi_rte_wait_for_debugger(void)
1083+
{
1084+
if (NULL != getenv("PMIX_TEST_DEBUGGER_ATTACH")
1085+
|| NULL == getenv("OMPI_BREAKPOINT")) {
1086+
ompi_rte_breakpoint(NULL);
1087+
return;
1088+
}
1089+
1090+
/* check for the "mpi-init" breakpoint */
1091+
ompi_rte_breakpoint("mpi-init");
1092+
}
1093+
10731094
static int _setup_top_session_dir(char **sdir)
10741095
{
10751096
char *tmpdir;

ompi/runtime/ompi_rte.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ OMPI_DECLSPEC int ompi_rte_convert_string_to_process_name(opal_process_name_t *n
216216
OMPI_DECLSPEC int ompi_rte_convert_process_name_to_string(char** name_string,
217217
const opal_process_name_t *name);
218218

219+
OMPI_DECLSPEC void ompi_rte_breakpoint(char *name);
220+
219221
#define OMPI_LOCAL_JOBID(n) \
220222
( (n) & 0x0000ffff)
221223
#define OMPI_JOB_FAMILY(n) \

0 commit comments

Comments
 (0)