@@ -74,6 +74,7 @@ typedef struct {
7474 * info from a query */
7575typedef struct {
7676 mylock_t lock ;
77+ pmix_status_t status ;
7778 pmix_info_t * info ;
7879 size_t ninfo ;
7980} myquery_data_t ;
@@ -105,14 +106,14 @@ static void cbfunc(pmix_status_t status,
105106 myquery_data_t * mq = (myquery_data_t * )cbdata ;
106107 size_t n ;
107108
109+ mq -> status = status ;
108110 /* save the returned info - the PMIx library "owns" it
109111 * and will release it and perform other cleanup actions
110112 * when release_fn is called */
111113 if (0 < ninfo ) {
112114 PMIX_INFO_CREATE (mq -> info , ninfo );
113115 mq -> ninfo = ninfo ;
114116 for (n = 0 ; n < ninfo ; n ++ ) {
115- fprintf (stderr , "Transferring %s\n" , info [n ].key );
116117 PMIX_INFO_XFER (& mq -> info [n ], & info [n ]);
117118 }
118119 }
@@ -337,9 +338,11 @@ int main(int argc, char **argv)
337338 /* check to see if we are using an intermediate launcher - we only
338339 * support those we recognize */
339340 found = false;
340- for (n = 0 ; NULL != launchers [n ]; n ++ ) {
341- if (0 == strcmp (argv [1 ], launchers [n ])) {
342- found = true;
341+ if (1 < argc ) {
342+ for (n = 0 ; NULL != launchers [n ]; n ++ ) {
343+ if (0 == strcmp (argv [1 ], launchers [n ])) {
344+ found = true;
345+ }
343346 }
344347 }
345348 if (found ) {
@@ -507,6 +510,61 @@ int main(int argc, char **argv)
507510 PMIX_INFO_FREE (info , ninfo );
508511 PMIX_APP_FREE (app , napps );
509512
513+ /* get the proctable for this nspace */
514+ PMIX_QUERY_CREATE (query , 1 );
515+ PMIX_ARGV_APPEND (rc , query [0 ].keys , PMIX_QUERY_PROC_TABLE );
516+ query [0 ].nqual = 1 ;
517+ PMIX_INFO_CREATE (query -> qualifiers , query [0 ].nqual );
518+ PMIX_INFO_LOAD (& query -> qualifiers [0 ], PMIX_NSPACE , clientspace , PMIX_STRING );
519+
520+ DEBUG_CONSTRUCT_LOCK (& myquery_data .lock );
521+ myquery_data .info = NULL ;
522+ myquery_data .ninfo = 0 ;
523+
524+ if (PMIX_SUCCESS != (rc = PMIx_Query_info_nb (query , 1 , cbfunc , (void * )& myquery_data ))) {
525+ fprintf (stderr , "Debugger[%s:%d] Proctable query failed: %d\n" , myproc .nspace , myproc .rank , rc );
526+ goto done ;
527+ }
528+ /* wait to get a response */
529+ DEBUG_WAIT_THREAD (& myquery_data .lock );
530+ DEBUG_DESTRUCT_LOCK (& myquery_data .lock );
531+
532+ /* we should have gotten a response */
533+ if (PMIX_SUCCESS != myquery_data .status ) {
534+ fprintf (stderr , "Debugger[%s:%d] Proctable query failed: %s\n" ,
535+ myproc .nspace , myproc .rank , PMIx_Error_string (myquery_data .status ));
536+ goto done ;
537+ }
538+ /* there should hvae been data */
539+ if (NULL == myquery_data .info || 0 == myquery_data .ninfo ) {
540+ fprintf (stderr , "Debugger[%s:%d] Proctable query return no results\n" ,
541+ myproc .nspace , myproc .rank );
542+ goto done ;
543+ }
544+ /* the query should have returned a data_array */
545+ if (PMIX_DATA_ARRAY != myquery_data .info [0 ].value .type ) {
546+ fprintf (stderr , "Debugger[%s:%d] Query returned incorrect data type: %s\n" , PMIx_Data_type_string (myquery_data .info [0 ].value .type ));
547+ return -1 ;
548+ }
549+ if (NULL == myquery_data .info [0 ].value .data .darray -> array ) {
550+ fprintf (stderr , "Debugger[%s:%d] Query returned no proctable info\n" );
551+ goto done ;
552+ }
553+ /* the data array consists of a struct:
554+ * size_t size;
555+ * void* array;
556+ *
557+ * In this case, the array is composed of pmix_proc_info_t structs:
558+ * pmix_proc_t proc; // contains the nspace,rank of this proc
559+ * char* hostname;
560+ * char* executable_name;
561+ * pid_t pid;
562+ * int exit_code;
563+ * pmix_proc_state_t state;
564+ */
565+ fprintf (stderr , "Received %d array elements\n" , (int )myquery_data .info [0 ].value .data .darray -> size );
566+ goto done ;
567+
510568 /* now launch the debugger daemons */
511569 if (PMIX_SUCCESS != (rc = spawn_debugger (clientspace ))) {
512570 goto done ;
0 commit comments