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>
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Co-authored-by: Jeff Squyres <jsquyres@cisco.com>
(cherry-picked from 20f5840
)
This commit is contained in:
parent
9a1b6cfc79
commit
d8dc69feb5
@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
||||
dnl University of Stuttgart. All rights reserved.
|
||||
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2009 Sun Microsystems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
|
||||
dnl reserved.
|
||||
@ -24,6 +24,28 @@ dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
dnl Check to see if specific CFLAGS work
|
||||
dnl $1: compiler flags to check
|
||||
dnl $2: Action if the flags work
|
||||
dnl $3: Action if the flags do not work
|
||||
AC_DEFUN([_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS],[
|
||||
OPAL_VAR_SCOPE_PUSH([ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save])
|
||||
|
||||
ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save=$CFLAGS
|
||||
AC_MSG_CHECKING([if $1 compiler flag works])
|
||||
CFLAGS="$CFLAGS $1"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[int i = 3;])],
|
||||
[ORTE_SETUP_DEBUGGER_FLAGS_HAPPY=yes],
|
||||
[ORTE_SETUP_DEBUGGER_FLAGS_HAPPY=no])
|
||||
AC_MSG_RESULT([$ORTE_SETUP_DEBUGGER_FLAGS_HAPPY])
|
||||
CFLAGS=$ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save
|
||||
|
||||
OPAL_VAR_SCOPE_POP
|
||||
|
||||
AS_IF([test $ORTE_SETUP_DEBUGGER_FLAGS_HAPPY = yes],
|
||||
[$2], [$3])
|
||||
])
|
||||
|
||||
AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
|
||||
#
|
||||
# Do a final process of the CFLAGS to make a WITHOUT_OPTFLAGS
|
||||
@ -53,4 +75,22 @@ AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
|
||||
|
||||
AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS)
|
||||
AC_SUBST(DEBUGGER_CFLAGS)
|
||||
|
||||
# Check for compiler specific flag to add in unwind information.
|
||||
# This is needed when attaching using MPIR to unwind back to the
|
||||
# user's main function. Certain optimisations can prevent GDB from
|
||||
# producing a stack when explicit unwind information is unavailable.
|
||||
# This is implied by -g, but we want to save space and don't need
|
||||
# full debug symbols.
|
||||
_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-fasynchronous-unwind-tables],
|
||||
[MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"],
|
||||
[_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-Meh_frame -Mframe],
|
||||
[MPIR_UNWIND_CFLAGS="-Meh_frame -Mframe"],
|
||||
[MPIR_UNWIND_CFLAGS=-g])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([for final compiler unwind flags])
|
||||
AC_MSG_RESULT([$MPIR_UNWIND_CFLAGS])
|
||||
|
||||
AC_SUBST(MPIR_UNWIND_CFLAGS)
|
||||
])
|
||||
|
@ -33,10 +33,19 @@ headers += \
|
||||
lib@OMPI_LIBMPI_NAME@_la_SOURCES += \
|
||||
runtime/ompi_mpi_abort.c \
|
||||
runtime/ompi_mpi_dynamics.c \
|
||||
runtime/ompi_mpi_init.c \
|
||||
runtime/ompi_mpi_finalize.c \
|
||||
runtime/ompi_mpi_params.c \
|
||||
runtime/ompi_mpi_preconnect.c \
|
||||
runtime/ompi_cr.c \
|
||||
runtime/ompi_info_support.c \
|
||||
runtime/ompi_spc.c
|
||||
|
||||
# The MPIR portion of the library must be built with flags to
|
||||
# enable stepping out of MPI_INIT into main.
|
||||
# Use an intermediate library to isolate the debug object.
|
||||
noinst_LTLIBRARIES += libompi_mpir.la
|
||||
libompi_mpir_la_SOURCES = \
|
||||
runtime/ompi_mpi_init.c
|
||||
libompi_mpir_la_CFLAGS = $(MPIR_UNWIND_CFLAGS)
|
||||
|
||||
lib@OMPI_LIBMPI_NAME@_la_LIBADD += libompi_mpir.la
|
||||
|
@ -19,6 +19,10 @@
|
||||
|
||||
AM_CPPFLAGS = $(LTDLINCL)
|
||||
|
||||
# Add unwind flags because files in this tree are
|
||||
# involved in startup.
|
||||
AM_CFLAGS = $(MPIR_UNWIND_CFLAGS)
|
||||
|
||||
# main library setup
|
||||
noinst_LTLIBRARIES = libmca_ess.la
|
||||
libmca_ess_la_SOURCES =
|
||||
|
@ -11,6 +11,12 @@
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
# Add MPIR unwind flags because files in this tree are
|
||||
# involved in startup. This is not needed in the other
|
||||
# subdirs in orte/mca/ess because the other components are
|
||||
# solely used by daemons and thus are not accessible by the debugger.
|
||||
AM_CFLAGS = $(MPIR_UNWIND_CFLAGS)
|
||||
|
||||
AM_CPPFLAGS = $(ess_pmi_CPPFLAGS)
|
||||
|
||||
sources = \
|
||||
|
@ -38,7 +38,6 @@ headers += \
|
||||
|
||||
lib@ORTE_LIB_PREFIX@open_rte_la_SOURCES += \
|
||||
runtime/orte_finalize.c \
|
||||
runtime/orte_init.c \
|
||||
runtime/orte_locks.c \
|
||||
runtime/orte_globals.c \
|
||||
runtime/orte_quit.c \
|
||||
@ -52,3 +51,12 @@ lib@ORTE_LIB_PREFIX@open_rte_la_SOURCES += \
|
||||
runtime/orte_cr.c \
|
||||
runtime/orte_data_server.c \
|
||||
runtime/orte_info_support.c
|
||||
|
||||
# The MPIR portion of the library must be built with flags to
|
||||
# enable stepping out of MPI_INIT into main.
|
||||
# Use an intermediate library to isolate the debug object.
|
||||
noinst_LTLIBRARIES += libruntime_mpir.la
|
||||
libruntime_mpir_la_SOURCES = \
|
||||
runtime/orte_init.c
|
||||
libruntime_mpir_la_CFLAGS = $(MPIR_UNWIND_CFLAGS)
|
||||
lib@ORTE_LIB_PREFIX@open_rte_la_LIBADD += libruntime_mpir.la
|
||||
|
Loading…
Reference in New Issue
Block a user