Skip to content

Commit e55bd3e

Browse files
committed
Add a compilation flag that adds unwind info to all files that are present in the stack starting from MPI_Init.
This is so when a debugger attaches using MPIR, it can step out of this stack back into main. This cannot be done with certain aggressive optimisations and missing debug information. Signed-off-by: James Clark <james.clark@arm.com>
1 parent 899afd7 commit e55bd3e

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

config/orte_setup_debugger_flags.m4

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,26 @@ AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
5353

5454
AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS)
5555
AC_SUBST(DEBUGGER_CFLAGS)
56+
57+
# Check for compiler specific flag to add in unwind information.
58+
# This is needed when attaching using MPIR to unwind back to the
59+
# user's main function. Certain optimisations can prevent GDB from
60+
# producing a stack when explicit unwind information is unavailable.
61+
# This is implied by -g, but we want to save space and don't need
62+
# full debug symbols.
63+
if test "x$opal_cv_c_compiler_vendor" = "xibm"; then
64+
MPIR_UNWIND_CFLAGS="-g"
65+
elif test "x$opal_cv_c_compiler_vendor" = "xgnu"; then
66+
MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"
67+
elif test "x$opal_cv_c_compiler_vendor" = "xintel"; then
68+
MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"
69+
elif test "x$opal_cv_c_compiler_vendor" = "xportland group"; then
70+
MPIR_UNWIND_CFLAGS="-Meh_frame -Mframe"
71+
else
72+
MPIR_UNWIND_CFLAGS=
73+
fi
74+
75+
AC_MSG_CHECKING([for MPIR unwind info flags])
76+
AC_MSG_RESULT([$MPIR_UNWIND_CFLAGS])
77+
AC_SUBST(MPIR_UNWIND_CFLAGS)
5678
])

ompi/runtime/Makefile.am

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ headers += \
3232
lib@OMPI_LIBMPI_NAME@_la_SOURCES += \
3333
runtime/ompi_mpi_abort.c \
3434
runtime/ompi_mpi_dynamics.c \
35-
runtime/ompi_mpi_init.c \
3635
runtime/ompi_mpi_finalize.c \
3736
runtime/ompi_mpi_params.c \
3837
runtime/ompi_mpi_preconnect.c \
3938
runtime/ompi_cr.c \
4039
runtime/ompi_info_support.c
40+
41+
# The MPIR portion of the library must be built with flags to
42+
# enable stepping out of MPI_INIT into main.
43+
# Use an intermediate library to isolate the debug object.
44+
noinst_LTLIBRARIES += libompi_mpir.la
45+
libompi_mpir_la_SOURCES = \
46+
runtime/ompi_mpi_init.c
47+
libompi_mpir_la_CFLAGS = $(MPIR_UNWIND_CFLAGS)
48+
49+
lib@OMPI_LIBMPI_NAME@_la_LIBADD += libompi_mpir.la

orte/mca/ess/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
# $HEADER$
1818
#
1919

20-
AM_CPPFLAGS = $(LTDLINCL)
20+
# Add unwind flags because all of the files in this tree are
21+
# involved in startup.
22+
AM_CPPFLAGS = $(LTDLINCL) $(MPIR_UNWIND_CFLAGS)
2123

2224
# main library setup
2325
noinst_LTLIBRARIES = libmca_ess.la

orte/mca/ess/pmi/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# $HEADER$
1212
#
1313

14-
AM_CPPFLAGS = $(ess_pmi_CPPFLAGS)
14+
AM_CPPFLAGS = $(ess_pmi_CPPFLAGS) $(MPIR_UNWIND_CFLAGS)
1515

1616
sources = \
1717
ess_pmi.h \

orte/runtime/Makefile.am

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ headers += \
3838

3939
lib@ORTE_LIB_PREFIX@open_rte_la_SOURCES += \
4040
runtime/orte_finalize.c \
41-
runtime/orte_init.c \
4241
runtime/orte_locks.c \
4342
runtime/orte_globals.c \
4443
runtime/orte_quit.c \
@@ -52,3 +51,12 @@ lib@ORTE_LIB_PREFIX@open_rte_la_SOURCES += \
5251
runtime/orte_cr.c \
5352
runtime/orte_data_server.c \
5453
runtime/orte_info_support.c
54+
55+
# The MPIR portion of the library must be built with flags to
56+
# enable stepping out of MPI_INIT into main.
57+
# Use an intermediate library to isolate the debug object.
58+
noinst_LTLIBRARIES += libruntime_mpir.la
59+
libruntime_mpir_la_SOURCES = \
60+
runtime/orte_init.c
61+
libruntime_mpir_la_CFLAGS = $(MPIR_UNWIND_CFLAGS)
62+
lib@ORTE_LIB_PREFIX@open_rte_la_LIBADD += libruntime_mpir.la

0 commit comments

Comments
 (0)