Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
e56bad6
abilist
aout
argp
assert
bare
bits
catgets
conf
conform
crypt
csu
ctype
debug
Depend
Makefile
Versions
backtrace-tst.c
backtrace.c
backtracesyms.c
backtracesymsfd.c
catchsegv.sh
chk_fail.c
confstr_chk.c
execinfo.h
fgets_chk.c
fgets_u_chk.c
fgetws_chk.c
fgetws_u_chk.c
fprintf_chk.c
fwprintf_chk.c
getcwd_chk.c
getdomainname_chk.c
getgroups_chk.c
gethostname_chk.c
getlogin_r_chk.c
gets_chk.c
getwd_chk.c
mbsnrtowcs_chk.c
mbsrtowcs_chk.c
mbstowcs_chk.c
memcpy_chk.c
memmove_chk.c
mempcpy_chk.c
memset_chk.c
noophooks.c
pcprofile.c
pcprofiledump.c
pread64_chk.c
pread_chk.c
printf_chk.c
ptsname_r_chk.c
read_chk.c
readlink_chk.c
readonly-area.c
realpath_chk.c
recv_chk.c
recvfrom_chk.c
segfault.c
snprintf_chk.c
sprintf_chk.c
stack_chk_fail.c
stack_chk_fail_local.c
stpcpy_chk.c
stpncpy_chk.c
strcat_chk.c
strcpy_chk.c
strncat_chk.c
strncpy_chk.c
swprintf_chk.c
test-stpcpy_chk.c
test-strcpy_chk.c
tst-chk1.c
tst-chk2.c
tst-chk3.c
tst-lfschk1.c
tst-lfschk2.c
tst-lfschk3.c
ttyname_r_chk.c
vfprintf_chk.c
vfwprintf_chk.c
vprintf_chk.c
vsnprintf_chk.c
vsprintf_chk.c
vswprintf_chk.c
vwprintf_chk.c
warning-nop.c
wcpcpy_chk.c
wcpncpy_chk.c
wcrtomb_chk.c
wcscat_chk.c
wcscpy_chk.c
wcsncat_chk.c
wcsncpy_chk.c
wcsnrtombs_chk.c
wcsrtombs_chk.c
wcstombs_chk.c
wctomb_chk.c
wmemcpy_chk.c
wmemmove_chk.c
wmempcpy_chk.c
wmemset_chk.c
wprintf_chk.c
xtrace.sh
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
locale
localedata
login
mach
malloc
manual
math
misc
nis
nptl
nptl_db
nscd
nss
po
posix
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CANCEL-FCT-WAIVE
CANCEL-FILE-WAIVE
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
INTERFACE
LICENSES
MakeTAGS
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README.libm
README.template
Rules
Versions.def
WUR-REPORT
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
o-iterator.mk
shlib-versions
test-skeleton.c
tls.make.c
version.h
Breadcrumbs
glibc
/
debug
/
xtrace.sh
Copy path
Blame
Blame
Latest commit
History
History
executable file
·
195 lines (171 loc) · 5.17 KB
Breadcrumbs
glibc
/
debug
/
xtrace.sh
Top
File metadata and controls
Code
Blame
executable file
·
195 lines (171 loc) · 5.17 KB
Raw
#! @BASH@ # Copyright (C) 1999, 2001-2004, 2005, 2006 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper <drepper@gnu.org>, 1999. # The GNU C Library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # The GNU C Library 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 # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with the GNU C Library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA. pcprofileso=@SLIBDIR@/libpcprofile.so pcprofiledump=@BINDIR@/pcprofiledump TEXTDOMAIN=libc # Print usage message. do_usage() { printf $"Usage: xtrace [OPTION]... PROGRAM [PROGRAMOPTION]...\n" exit 0 } # Refer to --help option. help_info() { printf >&2 $"Try \`xtrace --help' for more information.\n" exit 1 } # Message for missing argument. do_missing_arg() { printf >&2 $"xtrace: option \`$1' requires an argument.\n" help_info } # Print help message do_help() { printf $"Usage: xtrace [OPTION]... PROGRAM [PROGRAMOPTION]...\n" printf $"Trace execution of program by printing currently executed function. --data=FILE Don't run the program, just print the data from FILE. -?,--help Print this help and exit --usage Give a short usage message -V,--version Print version information and exit Mandatory arguments to long options are also mandatory for any corresponding short options. For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>.\n" exit 0 } do_version() { echo 'xtrace (GNU libc) @VERSION@' printf $"Copyright (C) %s Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " "2006" printf $"Written by %s. " "Ulrich Drepper" exit 0 } # Print out function name, file, and line number in a nicely formatted way. format_line() { fct=$1 file=${2%%:*} line=${2##*:} width=$(expr $COLUMNS - 30) filelen=$(expr length $file) if test "$filelen" -gt "$width"; then rwidth=$(expr $width - 3) file="...$(expr substr $file $(expr 1 + $filelen - $rwidth) $rwidth)" fi printf '%-20s %-*s %6s\n' $fct $width $file $line } # If the variable COLUMNS is not set do this now. COLUMNS=${COLUMNS:-80} # If `TERMINAL_PROG' is not set, set it to `xterm'. TERMINAL_PROG=${TERMINAL_PROG:-xterm} # The data file to process, if any. data= # Process arguments. But stop as soon as the program name is found. while test $# -gt 0; do case "$1" in --d | --da | --dat | --data) if test $# -eq 1; then do_missing_arg $1 fi shift data="$1" ;; --d=* | --da=* | --dat=* | --data=*) data=${1##*=} ;; -\? | --h | --he | --hel | --help) do_help ;; -V | --v | --ve | --ver | --vers | --versi | --versio | --version) do_version ;; --u | --us | --usa | --usag | --usage) do_usage ;; --) # Stop processing arguments. shift break ;; --*) printf >&2 $"xtrace: unrecognized option \`$1'\n" help_info ;; *) # Unknown option. This means the rest is the program name and parameters. break ;; esac shift done # See whether any arguments are left. if test $# -eq 0; then printf >&2 $"No program name given\n" help_info fi # Determine the program name and check whether it exists. program=$1 shift if test ! -f "$program"; then printf >&2 $"executable \`$program' not found\n" help_info fi if test ! -x "$program"; then printf >&2 $"\`$program' is no executable\n" help_info fi # We have two modes. If a data file is given simply print the included data. printf "%-20s %-*s %6s\n" Function $(expr $COLUMNS - 30) File Line for i in $(seq 1 $COLUMNS); do printf -; done; printf '\n' if test -n "$data"; then $pcprofiledump "$data" | sed 's/this = \([^,]*\).*/\1/' | addr2line -fC -e "$program" | while read fct; do read file if test "$fct" != '??' -a "$file" != '??:0'; then format_line $fct $file fi done else fifo=$(mktemp -u ${TMPDIR:-/tmp}/xtrace.XXXXXX) mkfifo -m 0600 $fifo || exit 1 trap 'rm $fifo; exit 1' SIGINT SIGTERM SIGPIPE # Now start the program and let it write to the FIFO. $TERMINAL_PROG -T "xtrace - $program $*" -e /bin/sh -c "LD_PRELOAD=$pcprofileso PCPROFILE_OUTPUT=$fifo $program $*; read < $fifo" & termpid=$! $pcprofiledump -u $fifo | while read line; do echo $line | sed 's/this = \([^,]*\).*/\1/' | addr2line -fC -e $program done | while read fct; do read file if test "$fct" != '??' -a "$file" != '??:0'; then format_line $fct $file fi done read -p "Press return here to close $TERMINAL_PROG($program)." echo > $fifo rm $fifo fi exit 0 # Local Variables: # mode:ksh # End:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
You can’t perform that action at this time.