This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/4] Add "-a" argument to gcore.in


On Tuesday, November 28 2017, Sergio Lopez wrote:

> The new "-a" argument instructs the gcore script to disable both
> use-coredump-filter and honor-dontdump-flag before generating the core
> file.
>
> This allows the user to unconditionally dump all memory regions,
> mimicking the behavior of previous gdb/gcore versions (before support
> for coredump_filter was implemented).



> 2017-11-28  Sergio Lopez  <slp@redhat.com>
>         * gcore.in: Add "-a" argument for disabling both
>         use-coredump-filter and honor-dontdump-flag.
> ---
>  gdb/ChangeLog |  4 ++++
>  gdb/gcore.in  | 25 +++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index ce68fee776..ba8826c84c 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,7 @@
> +2017-11-28  Sergio Lopez  <slp@redhat.com>
> +	* gcore.in: Add "-a" argument for disabling both
> +	use-coredump-filter and honor-dontdump-flag.
> +
>  2017-11-28  Sergio Lopez  <slp@redhat.com>
>  
>  	* linux-tdep.c (honor_dontdump_flag): New variable.
> diff --git a/gdb/gcore.in b/gdb/gcore.in
> index 632f21bdfa..32e597dc4f 100644
> --- a/gdb/gcore.in
> +++ b/gdb/gcore.in
> @@ -22,10 +22,29 @@
>  
>  if [ "$#" -eq "0" ]
>  then
> -    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
> +    echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o filename] pid"
>      exit 2
>  fi
>  
> +# Check for -a option, default to honor coredump_filter and VM_DONTDUMP.
> +use_coredump_filter=on
> +honor_dontdump_flag=on
> +
> +if [ "$1" = "-a" ]
> +then
> +    if [ "$#" -lt "2" ]
> +    then
> +        # Not enough arguments.
> +	echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o filename] pid"
> +	exit 2
> +    fi
> +    use_coredump_filter=off
> +    honor_dontdump_flag=off
> +
> +    # Shift over to the next argument
> +    shift;
> +fi

This is forcing the '-a' flag to come first, right?  Can you implement a
better argument parsing here, so that the user can pass '-a' anywhere in
the command line?  You can use getopt or even do your own loop.

> +
>  # Need to check for -o option, but set default basename to "core".
>  name=core
>  
> @@ -34,7 +53,7 @@ then
>      if [ "$#" -lt "3" ]
>      then
>  	# Not enough arguments.
> -	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
> +	echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o filename] pid"
>  	exit 2
>      fi
>      name=$2
> @@ -87,6 +106,8 @@ do
>  	# available but not accessible as GDB would get stopped on SIGTTIN.
>  	$binary_path/@GDB_TRANSFORM_NAME@ </dev/null --nx --batch \
>  	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
> +	    -ex "set use-coredump-filter $use_coredump_filter" \
> +	    -ex "set honor-dontdump-flag $honor_dontdump_flag" \
>  	    -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
>  
>  	if [ -r $name.$pid ] ; then 
> -- 
> 2.14.3

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]