1
1

Merge pull request #2598 from rhc54/topic/debugger

Transfer back changes from debugger attach work
Этот коммит содержится в:
rhc54 2016-12-17 13:09:38 -08:00 коммит произвёл GitHub
родитель 16a2f09cd5 269753f5c1
Коммит 54c4925f3f
11 изменённых файлов: 142 добавлений и 28 удалений

Просмотреть файл

@ -799,6 +799,10 @@ int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_da
asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIME\tKey: %s\tValue: %s", prefx,
src->key, ctime(&src->data.time));
break;
case OPAL_NAME:
asprintf(output, "%sOPAL_VALUE: Data type: OPAL_NAME\tKey: %s\tValue: %s", prefx,
src->key, OPAL_NAME_PRINT(src->data.name));
break;
case OPAL_PTR:
asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PTR\tKey: %s", prefx, src->key);
break;

Просмотреть файл

@ -466,11 +466,15 @@ PMIX_EXPORT void pmix_value_load(pmix_value_t *v, void *data,
pmix_data_type_t type)
{
pmix_byte_object_t *bo;
pmix_proc_info_t *pi;
v->type = type;
if (NULL == data) {
/* just set the fields to zero */
memset(&v->data, 0, sizeof(v->data));
if (PMIX_BOOL == type) {
v->data.flag = true; // existence of the attribute indicates true unless specified different
}
} else {
switch(type) {
case PMIX_UNDEF:
@ -529,19 +533,63 @@ PMIX_EXPORT void pmix_value_load(pmix_value_t *v, void *data,
case PMIX_TIMEVAL:
memcpy(&(v->data.tv), data, sizeof(struct timeval));
break;
case PMIX_TIME:
memcpy(&(v->data.time), data, sizeof(time_t));
break;
case PMIX_STATUS:
memcpy(&(v->data.status), data, sizeof(pmix_status_t));
break;
case PMIX_PROC_RANK:
memcpy(&(v->data.rank), data, sizeof(pmix_rank_t));
break;
case PMIX_PROC:
PMIX_PROC_CREATE(v->data.proc, 1);
if (NULL == v->data.proc) {
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
return;
}
memcpy(v->data.proc, data, sizeof(pmix_proc_t));
break;
case PMIX_BYTE_OBJECT:
bo = (pmix_byte_object_t*)data;
v->data.bo.bytes = bo->bytes;
memcpy(&(v->data.bo.size), &bo->size, sizeof(size_t));
break;
case PMIX_PERSIST:
memcpy(&(v->data.persist), data, sizeof(pmix_persistence_t));
break;
case PMIX_SCOPE:
memcpy(&(v->data.scope), data, sizeof(pmix_scope_t));
break;
case PMIX_DATA_RANGE:
memcpy(&(v->data.range), data, sizeof(pmix_data_range_t));
break;
case PMIX_PROC_STATE:
memcpy(&(v->data.state), data, sizeof(pmix_proc_state_t));
break;
case PMIX_PROC_INFO:
PMIX_PROC_INFO_CREATE(v->data.pinfo, 1);
if (NULL == v->data.pinfo) {
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
return;
}
pi = (pmix_proc_info_t*)data;
memcpy(&(v->data.pinfo->proc), &pi->proc, sizeof(pmix_proc_t));
if (NULL != pi->hostname) {
v->data.pinfo->hostname = strdup(pi->hostname);
}
if (NULL != pi->executable_name) {
v->data.pinfo->executable_name = strdup(pi->executable_name);
}
memcpy(&(v->data.pinfo->pid), &pi->pid, sizeof(pid_t));
memcpy(&(v->data.pinfo->exit_code), &pi->exit_code, sizeof(int));
break;
case PMIX_POINTER:
memcpy(&(v->data.ptr), data, sizeof(void*));
break;
default:
/* silence warnings */
PMIX_ERROR_LOG(PMIX_ERR_UNKNOWN_DATA_TYPE);
break;
}
}
@ -551,6 +599,7 @@ pmix_status_t pmix_value_unload(pmix_value_t *kv, void **data,
size_t *sz, pmix_data_type_t type)
{
pmix_status_t rc;
pmix_proc_t *pc;
rc = PMIX_SUCCESS;
if (type != kv->type) {
@ -637,10 +686,29 @@ pmix_status_t pmix_value_unload(pmix_value_t *kv, void **data,
memcpy(*data, &(kv->data.tv), sizeof(struct timeval));
*sz = sizeof(struct timeval);
break;
case PMIX_TIME:
memcpy(*data, &(kv->data.time), sizeof(time_t));
*sz = sizeof(time_t);
break;
case PMIX_STATUS:
memcpy(*data, &(kv->data.status), sizeof(pmix_status_t));
*sz = sizeof(pmix_status_t);
break;
case PMIX_PROC_RANK:
memcpy(*data, &(kv->data.rank), sizeof(pmix_rank_t));
*sz = sizeof(pmix_rank_t);
break;
case PMIX_PROC:
PMIX_PROC_CREATE(pc, 1);
if (NULL == pc) {
PMIX_ERROR_LOG(PMIX_ERR_NOMEM);
rc = PMIX_ERR_NOMEM;
break;
}
memcpy(pc, kv->data.proc, sizeof(pmix_proc_t));
*sz = sizeof(pmix_proc_t);
*data = pc;
break;
case PMIX_BYTE_OBJECT:
if (NULL != kv->data.bo.bytes && 0 < kv->data.bo.size) {
*data = kv->data.bo.bytes;
@ -650,6 +718,22 @@ pmix_status_t pmix_value_unload(pmix_value_t *kv, void **data,
*sz = 0;
}
break;
case PMIX_PERSIST:
memcpy(*data, &(kv->data.persist), sizeof(pmix_persistence_t));
*sz = sizeof(pmix_persistence_t);
break;
case PMIX_SCOPE:
memcpy(*data, &(kv->data.scope), sizeof(pmix_scope_t));
*sz = sizeof(pmix_scope_t);
break;
case PMIX_DATA_RANGE:
memcpy(*data, &(kv->data.range), sizeof(pmix_data_range_t));
*sz = sizeof(pmix_data_range_t);
break;
case PMIX_PROC_STATE:
memcpy(*data, &(kv->data.state), sizeof(pmix_proc_state_t));
*sz = sizeof(pmix_proc_state_t);
break;
case PMIX_POINTER:
memcpy(*data, &(kv->data.ptr), sizeof(void*));
*sz = sizeof(void*);

Просмотреть файл

@ -239,6 +239,9 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
pmix_cmd_t cmd = PMIX_REQ_CMD;
volatile int active;
pmix_status_t code = PMIX_ERR_DEBUGGER_RELEASE;
pmix_proc_t wildcard;
pmix_info_t ginfo;
pmix_value_t *val = NULL;
if (NULL == proc) {
return PMIX_ERR_BAD_PARAM;
@ -271,7 +274,6 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
/* setup the globals */
PMIX_CONSTRUCT(&pmix_client_globals.pending_requests, pmix_list_t);
PMIX_CONSTRUCT(&pmix_client_globals.myserver, pmix_peer_t);
pmix_client_globals.wait_for_debugger = false;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix: init called");
@ -349,14 +351,19 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
return rc;
}
/* check if we are to wait here for debugger attach */
if (pmix_client_globals.wait_for_debugger) {
/* lood for a debugger attach key */
(void)strncpy(wildcard.nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN);
wildcard.rank = PMIX_RANK_WILDCARD;
PMIX_INFO_LOAD(&ginfo, PMIX_IMMEDIATE, NULL, PMIX_BOOL);
if (PMIX_SUCCESS == PMIx_Get(&wildcard, PMIX_DEBUG_STOP_IN_INIT, &ginfo, 1, &val)) {
PMIX_VALUE_FREE(val, 1); // cleanup memory
/* if the value was found, then we need to wait for debugger attach here */
/* register for the debugger release notificaation */
active = -1;
PMIx_Register_event_handler(&code, 1, NULL, 0,
notification_fn, evhandler_reg_callbk, (void*)&active);
while (-1 == active) {
sleep(1);
usleep(100);
}
if (0 != active) {
return active;
@ -364,6 +371,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
/* wait for it to arrive */
PMIX_WAIT_FOR_COMPLETION(waiting_for_debugger);
}
PMIX_INFO_DESTRUCT(&ginfo);
return PMIX_SUCCESS;
}

Просмотреть файл

@ -21,7 +21,6 @@ BEGIN_C_DECLS
typedef struct {
pmix_peer_t myserver; // messaging support to/from my server
pmix_list_t pending_requests; // list of pmix_cb_t pending data requests
bool wait_for_debugger; // stop at the end of PMIx_Init and wait for notification of debugger release
} pmix_client_globals_t;
extern pmix_client_globals_t pmix_client_globals;

Просмотреть файл

@ -309,13 +309,6 @@ static inline pmix_status_t _job_data_store(const char *nspace, void *cbdata)
}
/* cleanup */
PMIX_DESTRUCT(&buf2);
} else if (0 == strcmp(kptr->key, PMIX_DEBUG_STOP_IN_INIT)) {
/* set the flag - we don't store this value */
if (PMIX_UNDEF == kptr->value->type) {
pmix_client_globals.wait_for_debugger = true;
} else {
pmix_client_globals.wait_for_debugger = kptr->value->data.flag;
}
} else {
if (PMIX_SUCCESS != (rc = _add_key_for_rank(PMIX_RANK_WILDCARD, kptr, cb))) {
PMIX_ERROR_LOG(rc);

Просмотреть файл

@ -50,14 +50,16 @@ PMIX_EXPORT pmix_status_t PMIx_Notify_event(pmix_status_t status,
cbfunc, cbdata);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix_server_notify_event source = %s:%d event_status = %d, rc= %d",
source->nspace, source->rank, status, rc);
(NULL == source) ? "UNKNOWN" : source->nspace,
(NULL == source) ? PMIX_RANK_WILDCARD : source->rank, status, rc);
} else {
rc = notify_server_of_event(status, source, range,
info, ninfo,
cbfunc, cbdata);
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix_client_notify_event source = %s:%d event_status =%d, rc=%d",
source->nspace, source->rank, status, rc);
(NULL == source) ? pmix_globals.myid.nspace : source->nspace,
(NULL == source) ? pmix_globals.myid.rank : source->rank, status, rc);
}
return rc;
}
@ -95,10 +97,15 @@ static pmix_status_t notify_server_of_event(pmix_status_t status,
pmix_event_chain_t *chain;
size_t n;
pmix_output_verbose(2, pmix_globals.debug_output,
"client: notifying server %s:%d of status %s",
pmix_globals.myid.nspace, pmix_globals.myid.rank,
PMIx_Error_string(status));
if (!pmix_globals.connected) {
return PMIX_ERR_UNREACH;
}
/* create the msg object */
msg = PMIX_NEW(pmix_buffer_t);
@ -156,6 +163,9 @@ static pmix_status_t notify_server_of_event(pmix_status_t status,
cb->op_cbfunc = cbfunc;
cb->cbdata = cbdata;
/* send to the server */
pmix_output_verbose(2, pmix_globals.debug_output,
"client: notifying server %s:%d - sending",
pmix_globals.myid.nspace, pmix_globals.myid.rank);
rc = pmix_ptl.send_recv(&pmix_client_globals.myserver, msg, notify_event_cbfunc, cb);
if (PMIX_SUCCESS != rc) {
PMIX_ERROR_LOG(rc);
@ -170,6 +180,8 @@ static pmix_status_t notify_server_of_event(pmix_status_t status,
return PMIX_SUCCESS;
cleanup:
pmix_output_verbose(2, pmix_globals.debug_output,
"client: notifying server - unable to send");
PMIX_RELEASE(msg);
/* we were unable to send anything, so we just return the error */
return rc;
@ -339,6 +351,10 @@ void pmix_invoke_local_event_hdlr(pmix_event_chain_t *chain)
pmix_default_event_t *def;
pmix_status_t rc = PMIX_SUCCESS;
pmix_output_verbose(2, pmix_globals.debug_output,
"%s:%d invoke_local_event_hdlr",
pmix_globals.myid.nspace, pmix_globals.myid.rank);
/* sanity check */
if (NULL == chain->info) {
/* should never happen as the return object must
@ -519,6 +535,10 @@ static pmix_status_t notify_client_of_event(pmix_status_t status,
pmix_status_t rc;
size_t n;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix_server: notify client of event %s",
PMIx_Error_string(status));
cd = PMIX_NEW(pmix_notify_caddy_t);
cd->status = status;
if (NULL == source) {
@ -538,15 +558,20 @@ static pmix_status_t notify_client_of_event(pmix_status_t status,
} else if (strncmp(info[n].key, PMIX_EVENT_CUSTOM_RANGE, PMIX_MAX_KEYLEN)) {
/* provides an array of pmix_proc_t identifying the procs
* that are to receive this notification */
if (PMIX_DATA_ARRAY != info[n].value.type ||
NULL == info[n].value.data.darray ||
NULL == info[n].value.data.darray->array) {
/* this is an error */
return PMIX_ERR_BAD_PARAM;
}
if (PMIX_DATA_ARRAY == info[n].value.type &&
NULL != info[n].value.data.darray &&
NULL != info[n].value.data.darray->array) {
cd->ntargets = info[n].value.data.darray->size;
PMIX_PROC_CREATE(cd->targets, cd->ntargets);
memcpy(cd->targets, info[n].value.data.darray->array, cd->ntargets * sizeof(pmix_proc_t));
} else if (PMIX_PROC == info[n].value.type) {
cd->ntargets = 1;
PMIX_PROC_CREATE(cd->targets, cd->ntargets);
memcpy(cd->targets, info[n].value.data.proc, sizeof(pmix_proc_t));
} else {
/* this is an error */
return PMIX_ERR_BAD_PARAM;
}
}
}
}

Просмотреть файл

@ -83,7 +83,7 @@ PMIX_EXPORT pmix_globals_t pmix_globals = {
int pmix_rte_init(pmix_proc_type_t type,
pmix_info_t info[], size_t ninfo,
pmix_ptl_cbfunc_t notifycbfunc)
pmix_ptl_cbfunc_t cbfunc)
{
int ret, debug_level;
char *error = NULL, *evar;
@ -192,6 +192,11 @@ int pmix_rte_init(pmix_proc_type_t type,
error = "pmix_ptl_base_select";
goto return_error;
}
/* set the notification callback function */
if (PMIX_SUCCESS != (ret = pmix_ptl.set_notification_cbfunc(cbfunc))) {
error = "pmix_ptl_set_notification_cbfunc";
goto return_error;
}
/* open the psec and select the active plugins */
if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_psec_base_framework, 0))) {

Просмотреть файл

@ -107,7 +107,7 @@ static void pmix_tool_notify_recv(struct pmix_peer_t *peer,
}
/* unpack the status */
cnt=1;
if (PMIX_SUCCESS != (rc = pmix_bfrop.unpack(buf, &chain->status, &cnt, PMIX_INT))) {
if (PMIX_SUCCESS != (rc = pmix_bfrop.unpack(buf, &chain->status, &cnt, PMIX_STATUS))) {
PMIX_ERROR_LOG(rc);
goto error;
}

Просмотреть файл

@ -784,7 +784,6 @@ static pmix_status_t server_notify_event(pmix_status_t code,
/* convert the source */
if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&src.jobid, source->nspace))) {
opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__);
OBJ_RELEASE(opalcaddy);
return pmix2x_convert_opalrc(rc);
}
@ -881,7 +880,6 @@ static pmix_status_t server_query(pmix_proc_t *proct,
/* convert the requestor */
if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&requestor.jobid, proct->nspace))) {
opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__);
OBJ_RELEASE(opalcaddy);
return pmix2x_convert_opalrc(rc);
}
@ -996,7 +994,6 @@ static void server_log(const pmix_proc_t *proct,
/* convert the requestor */
if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&requestor.jobid, proct->nspace))) {
opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__);
OBJ_RELEASE(opalcaddy);
ret = pmix2x_convert_opalrc(rc);
if (NULL != cbfunc) {

Просмотреть файл

@ -43,7 +43,6 @@ static bool myenvdefined = false;
static orte_schizo_launch_environ_t check_launch_environment(void)
{
char *bind, *list, *ptr;
int i;
if (myenvdefined) {

Просмотреть файл

@ -390,7 +390,7 @@ int pmix_server_notify_event(int code, opal_process_name_t *source,
}
if (0 < ninfo) {
OPAL_LIST_FOREACH(val, info, opal_value_t) {
if (OPAL_SUCCESS != (rc = opal_dss.pack(buf, val, 1, OPAL_VALUE))) {
if (OPAL_SUCCESS != (rc = opal_dss.pack(buf, &val, 1, OPAL_VALUE))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(buf);
return rc;