Skip to content

Commit 49d0789

Browse files
author
Git for Windows Build Agent
committed
Update 2 packages
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]>
1 parent a6ff6e9 commit 49d0789

File tree

131 files changed

+3184
-894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+3184
-894
lines changed

mingw32/bin/gdb-add-index

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ trap "rm -f $tmp_files" 0
113113

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

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

@@ -143,35 +143,32 @@ handle_file ()
143143
index="$index5"
144144
section=".debug_names"
145145
fi
146-
debugstradd=false
147-
debugstrupdate=false
148146
if test -s "$debugstr"; then
149147
if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \
150-
/dev/null 2>$debugstrerr; then
151-
cat >&2 $debugstrerr
148+
/dev/null 2> "$debugstrerr"; then
149+
cat >&2 "$debugstrerr"
152150
exit 1
153151
fi
152+
cat "$debugstr" >>"$debugstrmerge"
154153
if grep -q "can't dump section '.debug_str' - it does not exist" \
155-
$debugstrerr; then
156-
debugstradd=true
154+
"$debugstrerr"; then
155+
$OBJCOPY --add-section $section="$index" \
156+
--set-section-flags $section=readonly \
157+
--add-section .debug_str="$debugstrmerge" \
158+
--set-section-flags .debug_str=readonly \
159+
"$fpath" "$fpath"
157160
else
158-
debugstrupdate=true
159-
cat >&2 $debugstrerr
161+
$OBJCOPY --add-section $section="$index" \
162+
--set-section-flags $section=readonly \
163+
--update-section .debug_str="$debugstrmerge" \
164+
"$fpath" "$fpath"
160165
fi
161-
cat "$debugstr" >>"$debugstrmerge"
166+
else
167+
$OBJCOPY --add-section $section="$index" \
168+
--set-section-flags $section=readonly \
169+
"$fpath" "$fpath"
162170
fi
163171

164-
$OBJCOPY --add-section $section="$index" \
165-
--set-section-flags $section=readonly \
166-
$(if $debugstradd; then \
167-
echo --add-section .debug_str="$debugstrmerge"; \
168-
echo --set-section-flags .debug_str=readonly; \
169-
fi; \
170-
if $debugstrupdate; then \
171-
echo --update-section .debug_str="$debugstrmerge"; \
172-
fi) \
173-
"$fpath" "$fpath"
174-
175172
status=$?
176173
else
177174
echo "$myname: No index was created for $fpath" 1>&2

mingw32/bin/gdb.exe

214 KB
Binary file not shown.

mingw32/bin/gdbserver.exe

7.36 KB
Binary file not shown.

mingw32/bin/gstack

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2024 Free Software Foundation, Inc.
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
7+
# the Free Software Foundation; either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
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.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
# Print a stack trace of a running process.
19+
# Similar to the gcore command, but instead of creating a core file,
20+
# we simply have gdb print out the stack backtrace to the terminal.
21+
22+
GDB=${GDB:-$(command -v gdb)}
23+
GDBARGS=${GDBARGS:-}
24+
AWK=${AWK:-}
25+
PKGVERSION=(GDB)
26+
VERSION=16.1
27+
28+
# Find an appropriate awk interpreter if one was not specified
29+
# via the environment.
30+
awk_prog=""
31+
if [ -z "$AWK" ]; then
32+
for prog in gawk mawk nawk awk; do
33+
awk_prog=$(command -v $prog)
34+
test -n "$awk_prog" && break
35+
done
36+
AWK="$awk_prog"
37+
fi
38+
if [ ! -x "$AWK" ]; then
39+
echo "$0: could not find usable awk interpreter" 1>&2
40+
exit 2
41+
fi
42+
43+
function print_usage() {
44+
echo "Usage: $0 [-h|--help] [-v|--version] PID"
45+
}
46+
47+
function print_try_help() {
48+
echo "Try '$0 --help' for more information."
49+
}
50+
51+
function print_help() {
52+
print_usage
53+
echo "Print a stack trace of a running program"
54+
echo
55+
echo " -h, --help Print this message then exit."
56+
echo " -v, --version Print version information then exit."
57+
}
58+
59+
function print_version() {
60+
echo "GNU gstack (${PKGVERSION}) ${VERSION}"
61+
}
62+
63+
# Parse options.
64+
while getopts hv-: OPT; do
65+
if [ "$OPT" = "-" ]; then
66+
OPT="${OPTARG%%=*}"
67+
OPTARG="${OPTARG#'$OPT'}"
68+
OPTARG="${OPTARG#=}"
69+
fi
70+
71+
case "$OPT" in
72+
h | help)
73+
print_help
74+
exit 0
75+
;;
76+
v | version)
77+
print_version
78+
exit 0
79+
;;
80+
\?)
81+
# getopts has already output an error message.
82+
print_try_help 1>&2
83+
exit 2 ;;
84+
*)
85+
echo "$0: unrecognized option '--$OPT'" 1>&2
86+
print_try_help 1>&2
87+
exit 2
88+
;;
89+
esac
90+
done
91+
shift $((OPTIND-1))
92+
93+
# The sole remaining argument should be the PID of the process
94+
# whose backtrace is desired.
95+
if [ $# -ne 1 ]; then
96+
print_usage 1>&2
97+
exit 1
98+
fi
99+
100+
PID=$1
101+
102+
awk_script=$(cat << EOF
103+
BEGIN {
104+
first=1
105+
attach_okay=0
106+
}
107+
108+
/ATTACHED/ {
109+
attach_okay=1
110+
}
111+
112+
/^#/ {
113+
if (attach_okay) {
114+
print \$0
115+
}
116+
}
117+
118+
/^Thread/ {
119+
if (attach_okay) {
120+
if (first == 0)
121+
print ""
122+
first=0
123+
print \$0
124+
}
125+
}
126+
127+
END {
128+
if (attach_okay == 0)
129+
exit 2
130+
}
131+
EOF
132+
)
133+
134+
# Run GDB and remove some unwanted noise.
135+
"$GDB" --quiet -nx --readnever $GDBARGS <<EOF |
136+
set width 0
137+
set height 0
138+
set pagination no
139+
set debuginfod enabled off
140+
define attach-bt
141+
attach \$arg0
142+
echo "ATTACHED"
143+
thread apply all bt
144+
end
145+
attach-bt $PID
146+
EOF
147+
$AWK -- "$awk_script"

mingw32/share/gdb/python/gdb/FrameDecorator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ def fetch_frame_locals(self, follow_link=False):
285285
# returns False for arguments as well. Anyway,
286286
# don't include non-variables here.
287287
continue
288+
elif sym.is_artificial:
289+
# Skip artificial symbols.
290+
continue
288291
lvars.append(SymValueWrapper(frame, sym))
289292

290293
if block.function is not None:

mingw32/share/gdb/python/gdb/__init__.py

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ def write(self, s):
8787
frame_filters = {}
8888
# Initial frame unwinders.
8989
frame_unwinders = []
90-
# Initial missing debug handlers.
91-
missing_debug_handlers = []
90+
# The missing file handlers. Each item is a tuple with the form
91+
# (TYPE, HANDLER) where TYPE is a string either 'debug' or 'objfile'.
92+
missing_file_handlers = []
9293

9394

9495
def _execute_unwinders(pending_frame):
@@ -271,6 +272,61 @@ def start(self):
271272
super().start()
272273

273274

275+
def _filter_missing_file_handlers(handlers, handler_type):
276+
"""Each list of missing file handlers is a list of tuples, the first
277+
item in the tuple is a string either 'debug' or 'objfile' to
278+
indicate what type of handler it is. The second item in the tuple
279+
is the actual handler object.
280+
281+
This function takes HANDLER_TYPE which is a string, either 'debug'
282+
or 'objfile' and HANDLERS, a list of tuples. The function returns
283+
an iterable over all of the handler objects (extracted from the
284+
tuples) which match HANDLER_TYPE.
285+
"""
286+
287+
return map(lambda t: t[1], filter(lambda t: t[0] == handler_type, handlers))
288+
289+
290+
def _handle_missing_files(pspace, handler_type, cb):
291+
"""Helper for _handle_missing_debuginfo and _handle_missing_objfile.
292+
293+
Arguments:
294+
pspace: The gdb.Progspace in which we're operating. Used to
295+
lookup program space specific handlers.
296+
handler_type: A string, either 'debug' or 'objfile', this is the
297+
type of handler we're looking for.
298+
cb: A callback which takes a handler and returns the result of
299+
calling the handler.
300+
301+
Returns:
302+
None: No suitable file could be found.
303+
False: A handler has decided that the requested file cannot be
304+
found, and no further searching should be done.
305+
True: The file has been found and installed in a location
306+
where GDB would normally look for it. GDB should
307+
repeat its lookup process, the file should now be in
308+
place.
309+
A string: This is the filename of where the missing file can
310+
be found.
311+
"""
312+
313+
for handler in _filter_missing_file_handlers(
314+
pspace.missing_file_handlers, handler_type
315+
):
316+
if handler.enabled:
317+
result = cb(handler)
318+
if result is not None:
319+
return result
320+
321+
for handler in _filter_missing_file_handlers(missing_file_handlers, handler_type):
322+
if handler.enabled:
323+
result = cb(handler)
324+
if result is not None:
325+
return result
326+
327+
return None
328+
329+
274330
def _handle_missing_debuginfo(objfile):
275331
"""Internal function called from GDB to execute missing debug
276332
handlers.
@@ -293,18 +349,46 @@ def _handle_missing_debuginfo(objfile):
293349
A string: This is the filename of a file containing the
294350
required debug information.
295351
"""
352+
296353
pspace = objfile.progspace
297354

298-
for handler in pspace.missing_debug_handlers:
299-
if handler.enabled:
300-
result = handler(objfile)
301-
if result is not None:
302-
return result
355+
return _handle_missing_files(pspace, "debug", lambda h: h(objfile))
303356

304-
for handler in missing_debug_handlers:
305-
if handler.enabled:
306-
result = handler(objfile)
307-
if result is not None:
308-
return result
309357

310-
return None
358+
def _handle_missing_objfile(pspace, buildid, filename):
359+
"""Internal function called from GDB to execute missing objfile
360+
handlers.
361+
362+
Run each of the currently registered, and enabled missing objfile
363+
handler objects for the gdb.Progspace passed in as an argument,
364+
and then from the global list. Stop after the first handler that
365+
returns a result other than None.
366+
367+
Arguments:
368+
pspace: A gdb.Progspace for which the missing objfile handlers
369+
should be run. This is the program space in which an
370+
objfile was found to be missing.
371+
buildid: A string containing the build-id we're looking for.
372+
filename: The filename of the file GDB tried to find but
373+
couldn't. This is not where the file should be
374+
placed if found, in fact, this file might already
375+
exist on disk but have the wrong build-id. This is
376+
mostly provided in order to be used in messages to
377+
the user.
378+
379+
Returns:
380+
None: No objfile could be found for this build-id.
381+
False: A handler has done all it can with for this build-id,
382+
but no objfile could be found.
383+
True: An objfile might have been installed by a handler, GDB
384+
should check again. The only place GDB checks is within
385+
the .build-id sub-directory within the
386+
debug-file-directory. If the required file was not
387+
installed there then GDB will not find it.
388+
A string: This is the filename of a file containing the
389+
missing objfile.
390+
"""
391+
392+
return _handle_missing_files(
393+
pspace, "objfile", lambda h: h(pspace, buildid, filename)
394+
)

0 commit comments

Comments
 (0)