Skip to content

Commit

Permalink
Update 2 packages
Browse files Browse the repository at this point in the history
mingw-w64-i686-gdb (15.2-2 -> 16.1-1)
mingw-w64-x86_64-gdb (15.2-2 -> 16.1-1)

Signed-off-by: Git for Windows Build Agent <[email protected]>
  • Loading branch information
Git for Windows Build Agent committed Jan 20, 2025
1 parent a6ff6e9 commit 49d0789
Show file tree
Hide file tree
Showing 131 changed files with 3,184 additions and 894 deletions.
41 changes: 19 additions & 22 deletions mingw32/bin/gdb-add-index
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ trap "rm -f $tmp_files" 0

$GDB --batch -nx -iex 'set auto-load no' \
-iex 'set debuginfod enabled off' \
-ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
-ex "file '$file'" -ex "save gdb-index $dwarf5 '$dir'" || {
# Just in case.
status=$?
echo "$myname: gdb error generating index for $file" 1>&2
Expand All @@ -122,7 +122,7 @@ $GDB --batch -nx -iex 'set auto-load no' \

# In some situations gdb can exit without creating an index. This is
# not an error.
# E.g., if $file is stripped. This behaviour is akin to stripping an
# E.g., if $file is stripped. This behavior is akin to stripping an
# already stripped binary, it's a no-op.
status=0

Expand All @@ -143,35 +143,32 @@ handle_file ()
index="$index5"
section=".debug_names"
fi
debugstradd=false
debugstrupdate=false
if test -s "$debugstr"; then
if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \
/dev/null 2>$debugstrerr; then
cat >&2 $debugstrerr
/dev/null 2> "$debugstrerr"; then
cat >&2 "$debugstrerr"
exit 1
fi
cat "$debugstr" >>"$debugstrmerge"
if grep -q "can't dump section '.debug_str' - it does not exist" \
$debugstrerr; then
debugstradd=true
"$debugstrerr"; then
$OBJCOPY --add-section $section="$index" \
--set-section-flags $section=readonly \
--add-section .debug_str="$debugstrmerge" \
--set-section-flags .debug_str=readonly \
"$fpath" "$fpath"
else
debugstrupdate=true
cat >&2 $debugstrerr
$OBJCOPY --add-section $section="$index" \
--set-section-flags $section=readonly \
--update-section .debug_str="$debugstrmerge" \
"$fpath" "$fpath"
fi
cat "$debugstr" >>"$debugstrmerge"
else
$OBJCOPY --add-section $section="$index" \
--set-section-flags $section=readonly \
"$fpath" "$fpath"
fi

$OBJCOPY --add-section $section="$index" \
--set-section-flags $section=readonly \
$(if $debugstradd; then \
echo --add-section .debug_str="$debugstrmerge"; \
echo --set-section-flags .debug_str=readonly; \
fi; \
if $debugstrupdate; then \
echo --update-section .debug_str="$debugstrmerge"; \
fi) \
"$fpath" "$fpath"
status=$?
else
echo "$myname: No index was created for $fpath" 1>&2
Expand Down
Binary file modified mingw32/bin/gdb.exe
Binary file not shown.
Binary file modified mingw32/bin/gdbserver.exe
Binary file not shown.
147 changes: 147 additions & 0 deletions mingw32/bin/gstack
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env bash

# Copyright (C) 2024 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Print a stack trace of a running process.
# Similar to the gcore command, but instead of creating a core file,
# we simply have gdb print out the stack backtrace to the terminal.

GDB=${GDB:-$(command -v gdb)}
GDBARGS=${GDBARGS:-}
AWK=${AWK:-}
PKGVERSION=(GDB)
VERSION=16.1

# Find an appropriate awk interpreter if one was not specified
# via the environment.
awk_prog=""
if [ -z "$AWK" ]; then
for prog in gawk mawk nawk awk; do
awk_prog=$(command -v $prog)
test -n "$awk_prog" && break
done
AWK="$awk_prog"
fi
if [ ! -x "$AWK" ]; then
echo "$0: could not find usable awk interpreter" 1>&2
exit 2
fi

function print_usage() {
echo "Usage: $0 [-h|--help] [-v|--version] PID"
}

function print_try_help() {
echo "Try '$0 --help' for more information."
}

function print_help() {
print_usage
echo "Print a stack trace of a running program"
echo
echo " -h, --help Print this message then exit."
echo " -v, --version Print version information then exit."
}

function print_version() {
echo "GNU gstack (${PKGVERSION}) ${VERSION}"
}

# Parse options.
while getopts hv-: OPT; do
if [ "$OPT" = "-" ]; then
OPT="${OPTARG%%=*}"
OPTARG="${OPTARG#'$OPT'}"
OPTARG="${OPTARG#=}"
fi

case "$OPT" in
h | help)
print_help
exit 0
;;
v | version)
print_version
exit 0
;;
\?)
# getopts has already output an error message.
print_try_help 1>&2
exit 2 ;;
*)
echo "$0: unrecognized option '--$OPT'" 1>&2
print_try_help 1>&2
exit 2
;;
esac
done
shift $((OPTIND-1))

# The sole remaining argument should be the PID of the process
# whose backtrace is desired.
if [ $# -ne 1 ]; then
print_usage 1>&2
exit 1
fi

PID=$1

awk_script=$(cat << EOF
BEGIN {
first=1
attach_okay=0
}
/ATTACHED/ {
attach_okay=1
}
/^#/ {
if (attach_okay) {
print \$0
}
}
/^Thread/ {
if (attach_okay) {
if (first == 0)
print ""
first=0
print \$0
}
}
END {
if (attach_okay == 0)
exit 2
}
EOF
)

# Run GDB and remove some unwanted noise.
"$GDB" --quiet -nx --readnever $GDBARGS <<EOF |
set width 0
set height 0
set pagination no
set debuginfod enabled off
define attach-bt
attach \$arg0
echo "ATTACHED"
thread apply all bt
end
attach-bt $PID
EOF
$AWK -- "$awk_script"
3 changes: 3 additions & 0 deletions mingw32/share/gdb/python/gdb/FrameDecorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ def fetch_frame_locals(self, follow_link=False):
# returns False for arguments as well. Anyway,
# don't include non-variables here.
continue
elif sym.is_artificial:
# Skip artificial symbols.
continue
lvars.append(SymValueWrapper(frame, sym))

if block.function is not None:
Expand Down
110 changes: 97 additions & 13 deletions mingw32/share/gdb/python/gdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def write(self, s):
frame_filters = {}
# Initial frame unwinders.
frame_unwinders = []
# Initial missing debug handlers.
missing_debug_handlers = []
# The missing file handlers. Each item is a tuple with the form
# (TYPE, HANDLER) where TYPE is a string either 'debug' or 'objfile'.
missing_file_handlers = []


def _execute_unwinders(pending_frame):
Expand Down Expand Up @@ -271,6 +272,61 @@ def start(self):
super().start()


def _filter_missing_file_handlers(handlers, handler_type):
"""Each list of missing file handlers is a list of tuples, the first
item in the tuple is a string either 'debug' or 'objfile' to
indicate what type of handler it is. The second item in the tuple
is the actual handler object.
This function takes HANDLER_TYPE which is a string, either 'debug'
or 'objfile' and HANDLERS, a list of tuples. The function returns
an iterable over all of the handler objects (extracted from the
tuples) which match HANDLER_TYPE.
"""

return map(lambda t: t[1], filter(lambda t: t[0] == handler_type, handlers))


def _handle_missing_files(pspace, handler_type, cb):
"""Helper for _handle_missing_debuginfo and _handle_missing_objfile.
Arguments:
pspace: The gdb.Progspace in which we're operating. Used to
lookup program space specific handlers.
handler_type: A string, either 'debug' or 'objfile', this is the
type of handler we're looking for.
cb: A callback which takes a handler and returns the result of
calling the handler.
Returns:
None: No suitable file could be found.
False: A handler has decided that the requested file cannot be
found, and no further searching should be done.
True: The file has been found and installed in a location
where GDB would normally look for it. GDB should
repeat its lookup process, the file should now be in
place.
A string: This is the filename of where the missing file can
be found.
"""

for handler in _filter_missing_file_handlers(
pspace.missing_file_handlers, handler_type
):
if handler.enabled:
result = cb(handler)
if result is not None:
return result

for handler in _filter_missing_file_handlers(missing_file_handlers, handler_type):
if handler.enabled:
result = cb(handler)
if result is not None:
return result

return None


def _handle_missing_debuginfo(objfile):
"""Internal function called from GDB to execute missing debug
handlers.
Expand All @@ -293,18 +349,46 @@ def _handle_missing_debuginfo(objfile):
A string: This is the filename of a file containing the
required debug information.
"""

pspace = objfile.progspace

for handler in pspace.missing_debug_handlers:
if handler.enabled:
result = handler(objfile)
if result is not None:
return result
return _handle_missing_files(pspace, "debug", lambda h: h(objfile))

for handler in missing_debug_handlers:
if handler.enabled:
result = handler(objfile)
if result is not None:
return result

return None
def _handle_missing_objfile(pspace, buildid, filename):
"""Internal function called from GDB to execute missing objfile
handlers.
Run each of the currently registered, and enabled missing objfile
handler objects for the gdb.Progspace passed in as an argument,
and then from the global list. Stop after the first handler that
returns a result other than None.
Arguments:
pspace: A gdb.Progspace for which the missing objfile handlers
should be run. This is the program space in which an
objfile was found to be missing.
buildid: A string containing the build-id we're looking for.
filename: The filename of the file GDB tried to find but
couldn't. This is not where the file should be
placed if found, in fact, this file might already
exist on disk but have the wrong build-id. This is
mostly provided in order to be used in messages to
the user.
Returns:
None: No objfile could be found for this build-id.
False: A handler has done all it can with for this build-id,
but no objfile could be found.
True: An objfile might have been installed by a handler, GDB
should check again. The only place GDB checks is within
the .build-id sub-directory within the
debug-file-directory. If the required file was not
installed there then GDB will not find it.
A string: This is the filename of a file containing the
missing objfile.
"""

return _handle_missing_files(
pspace, "objfile", lambda h: h(pspace, buildid, filename)
)
Loading

0 comments on commit 49d0789

Please sign in to comment.