Skip to content

Commit 23b7103

Browse files
nsarkajanjust
authored andcommitted
CORE: Add UCC_DEBUGGER_WAIT env
1 parent a3f5f74 commit 23b7103

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/core/ucc_context.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "utils/ucc_log.h"
1313
#include "utils/ucc_list.h"
1414
#include "utils/ucc_string.h"
15+
#include "utils/ucc_debug.h"
1516
#include "ucc_progress_queue.h"
1617

1718
static uint32_t ucc_context_seq_num = 0;
@@ -633,6 +634,9 @@ ucc_status_t ucc_context_create_proc_info(ucc_lib_h lib,
633634
b_params.thread_mode = lib->attr.thread_mode;
634635
if (params->mask & UCC_CONTEXT_PARAM_FIELD_OOB) {
635636
ctx->rank = params->oob.oob_ep;
637+
#ifdef ENABLE_DEBUG
638+
ucc_check_wait_for_debugger(ctx->rank);
639+
#endif
636640
}
637641
status = ucc_create_tl_contexts(ctx, config, b_params);
638642
if (UCC_OK != status) {

src/utils/ucc_debug.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2020-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* See file LICENSE for terms.
5+
*/
6+
7+
#ifndef UCC_DEBUG_H_
8+
#define UCC_DEBUG_H_
9+
10+
#include "config.h"
11+
#include "ucc/api/ucc.h"
12+
13+
static inline void ucc_check_wait_for_debugger(ucc_rank_t ctx_rank)
14+
{
15+
const char *wait_for_rank;
16+
if (NULL != (wait_for_rank = getenv("UCC_DEBUGGER_WAIT"))) {
17+
volatile int waiting = 1;
18+
if (atoi(wait_for_rank) == ctx_rank) {
19+
char hostname[256];
20+
gethostname(hostname, sizeof(hostname));
21+
printf("PID %d (ctx rank %d) waiting for attach on %s\n"
22+
"Set var waiting = 0 in debugger to continue\n",
23+
getpid(), ctx_rank, hostname);
24+
while (waiting) {
25+
sleep(1);
26+
}
27+
}
28+
}
29+
}
30+
31+
#endif
32+

0 commit comments

Comments
 (0)