1 /*****************************************************************************\ 2 * pdebug.h - ptrace functions for slurmstepd 3 ***************************************************************************** 4 * Copyright (C) 2002-2007 The Regents of the University of California. 5 * Copyright (C) 2008-2010 Lawrence Livermore National Security. 6 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). 7 * Written by Mark Grondona <mgrondona@llnl.gov>. 8 * CODE-OCEC-09-009. All rights reserved. 9 * 10 * This file is part of Slurm, a resource management program. 11 * For details, see <https://slurm.schedmd.com/>. 12 * Please also read the included file: DISCLAIMER. 13 * 14 * Slurm is free software; you can redistribute it and/or modify it under 15 * the terms of the GNU General Public License as published by the Free 16 * Software Foundation; either version 2 of the License, or (at your option) 17 * any later version. 18 * 19 * In addition, as a special exception, the copyright holders give permission 20 * to link the code of portions of this program with the OpenSSL library under 21 * certain conditions as described in each individual source file, and 22 * distribute linked combinations including the two. You must obey the GNU 23 * General Public License in all respects for all of the code used other than 24 * OpenSSL. If you modify file(s) with this exception, you may extend this 25 * exception to your version of the file(s), but you are not obligated to do 26 * so. If you do not wish to do so, delete this exception statement from your 27 * version. If you delete this exception statement from all source files in 28 * the program, then also delete it here. 29 * 30 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY 31 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 32 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 33 * details. 34 * 35 * You should have received a copy of the GNU General Public License along 36 * with Slurm; if not, write to the Free Software Foundation, Inc., 37 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 38 \*****************************************************************************/ 39 40 #ifndef _PDEBUG_H 41 #define _PDEBUG_H 42 43 #include "config.h" 44 45 #include <sys/param.h> 46 #include <sys/wait.h> 47 #include <unistd.h> 48 49 #ifdef HAVE_SYS_PTRACE_H 50 # include <sys/ptrace.h> 51 #endif 52 53 #include "src/slurmd/slurmstepd/slurmstepd_job.h" 54 55 /* 56 * Stop current task on exec() for connection from a parallel debugger 57 */ 58 void pdebug_stop_current(stepd_step_rec_t *job); 59 60 /* 61 * Prepare task for parallel debugger attach 62 * Returns SLURM_SUCCESS or SLURM_ERROR. 63 */ 64 int pdebug_trace_process(stepd_step_rec_t *job, pid_t pid); 65 66 /* 67 * Wake tasks currently stopped for parallel debugger attach 68 */ 69 void pdebug_wake_process(stepd_step_rec_t *job, pid_t pid); 70 71 #ifdef HAVE_PTRACE64 72 # define _PTRACE(r,p,a,d) ptrace64((r),(long long)(p),(long long)(a),(d),NULL) 73 #else 74 # ifdef PTRACE_FIVE_ARGS 75 # define _PTRACE(r,p,a,d) ptrace((r),(p),(a),(d),NULL) 76 # elif defined BSD 77 # define _PTRACE(r,p,a,d) ptrace((r),(p),(a),(d)) 78 # else 79 # define _PTRACE(r,p,a,d) ptrace((r),(p),(a),(void *)(d)) 80 # endif 81 #endif 82 83 #endif 84