X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fgcore.in;h=f47efbe37e3de8430e54a0dacd691901531e060b;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=6a8f28cd63546c2791a20482e8cda4d6e4611edf;hpb=618f726fcb851883a0094aa7fa17003889b7189f;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/gcore.in b/gdb/gcore.in index 6a8f28cd63..f47efbe37e 100644 --- a/gdb/gcore.in +++ b/gdb/gcore.in @@ -1,6 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash -# Copyright (C) 2003-2016 Free Software Foundation, Inc. +# Copyright (C) 2003-2020 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,27 +20,39 @@ # It starts up gdb, attaches to the given PID and invokes the gcore command. # -if [ "$#" -eq "0" ] -then - echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid" - exit 2 -fi - # Need to check for -o option, but set default basename to "core". -name=core +prefix=core + +# When the -a option is present, this may hold additional commands +# to ensure gdb dumps all mappings (OS dependent). +dump_all_cmds=() + +while getopts :ao: opt; do + case "$opt" in + a) + case "$OSTYPE" in + linux*) + dump_all_cmds=("-ex" "set use-coredump-filter off") + dump_all_cmds+=("-ex" "set dump-excluded-mappings on") + ;; + esac + ;; + o) + prefix=$OPTARG + ;; + *) + echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]" + exit 2 + ;; + esac +done + +shift $((OPTIND-1)) -if [ "$1" = "-o" ] +if [ "$#" -eq "0" ] then - if [ "$#" -lt "3" ] - then - # Not enough arguments. - echo "usage: @GCORE_TRANSFORM_NAME@ [-o filename] pid" - exit 2 - fi - name=$2 - - # Shift over to start of pid list - shift; shift + echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]" + exit 2 fi # Attempt to fetch the absolute path to the gcore script that was @@ -72,7 +84,7 @@ fi # Check if the GDB binary is in the expected path. If not, just # quit with a message. -if [ ! -f "$binary_path"/@GDB_TRANSFORM_NAME@ ]; then +if [ ! -f "$binary_path/@GDB_TRANSFORM_NAME@" ]; then echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found" exit 1 fi @@ -81,18 +93,20 @@ fi rc=0 # Loop through pids -for pid in $* +for pid in "$@" do # `