move sparc-sol-thread.c back into sol-thread.c.
[deliverable/binutils-gdb.git] / gdb / gcore.in
CommitLineData
627bf7c1
EZ
1#!/bin/sh
2
28e7fd62 3# Copyright (C) 2003-2013 Free Software Foundation, Inc.
627bf7c1
EZ
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
50efebf8 7# the Free Software Foundation; either version 3 of the License, or
627bf7c1 8# (at your option) any later version.
50efebf8 9#
627bf7c1
EZ
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
50efebf8 14#
627bf7c1 15# You should have received a copy of the GNU General Public License
50efebf8 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
627bf7c1 17
627bf7c1 18#
627bf7c1
EZ
19# Script to generate a core file of a running program.
20# It starts up gdb, attaches to the given PID and invokes the gcore command.
21#
22
23if [ "$#" -eq "0" ]
24then
b292c783 25 echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid"
627bf7c1
EZ
26 exit 2
27fi
28
29# Need to check for -o option, but set default basename to "core".
30name=core
31
32if [ "$1" = "-o" ]
33then
34 if [ "$#" -lt "3" ]
35 then
36 # Not enough arguments.
b292c783 37 echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid"
627bf7c1
EZ
38 exit 2
39 fi
40 name=$2
41
42 # Shift over to start of pid list
43 shift; shift
44fi
45
46# Initialise return code.
47rc=0
48
49# Loop through pids
50for pid in $*
51do
3a674486
JK
52 # `</dev/null' to avoid touching interactive terminal if it is
53 # available but not accessible as GDB would get stopped on SIGTTIN.
b292c783 54 @GDB_TRANSFORM_NAME@ </dev/null --nx --batch \
3a674486
JK
55 -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
56 -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
dfb893af 57
627bf7c1
EZ
58 if [ -r $name.$pid ] ; then
59 rc=0
60 else
b292c783 61 echo "@GCORE_TRANSFORM_NAME@: failed to create $name.$pid"
627bf7c1
EZ
62 rc=1
63 break
64 fi
65
66
67done
68
69exit $rc
This page took 0.860626 seconds and 4 git commands to generate.