gcore: add -v or --version option to show version number

Based on the work in this commit:

  commit fb2ded33c1e519659743047ed7817166545b6d91
  Date:   Fri Dec 20 12:46:11 2024 -0800

      Add gstack script

This commit adds a '-v' or '--version' option to the existing gcore
script.  This new option causes the script to print its version
number, and then exit.

I needed to adjust the getopts handling a little in order to support
the long form '--version' argument, but as this makes gcore more
consistent with gstack, then this seems like a good thing.

The usage message is now getting a little long.  Don't worry, I plan
to clean that up in the next commit.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32325
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
6 files changed