master
1#!/usr/bin/env perl
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
25#
26# This script grew out of help from Przemyslaw Iskra and Balint Szilakszi
27# a late evening in the #curl IRC channel.
28#
30use strict;
31use warnings;
32use vars qw($Cpreprocessor);
34#
35# configurehelp perl module is generated by configure script
36#
37my $rc = eval {
38 require configurehelp;
39 configurehelp->import(qw(
40 $Cpreprocessor
41 ));
42 1;
43};
44# Set default values if configure has not generated a configurehelp.pm file.
45# This is the case with cmake.
46if(!$rc) {
47 $Cpreprocessor = 'cpp';
48}
50# we may get the directory root pointed out
51my $root = $ARGV[0] || ".";
53# need an include directory when building out-of-tree
54my $i = ($ARGV[1]) ? "-I$ARGV[1] " : '';
56my $verbose = 0;
57my $summary = 0;
58my $misses = 0;
60my @manrefs;
61my @syms;
62my %doc;
63my %rem;
65# scanenum runs the preprocessor on curl.h so it processes all enums
66# included by it, which *should* be all headers
67sub scanenum {
68 my ($file) = @_;
69 local $ENV{'MSYS2_ARG_CONV_EXCL'} = '/D';
70 open(my $h_in, "-|", "$Cpreprocessor $i$file") or die "Cannot preprocess $file";
71 while(<$h_in>) {
72 if(/enum\s+(\S+\s+)?{/ .. /}/) {
73 s/^\s+//;
74 next unless /^CURL/;
75 chomp;
76 s/[,\s].*//;
77 push @syms, $_;
78 }
79 }
80 close $h_in or die "Error preprocessing $file";
81}
83sub scanheader {
84 my ($f) = @_;
85 open(my $h, "<", $f);
86 while(<$h>) {
87 if(/^#define ((LIB|)CURL[A-Za-z0-9_]*)/) {
88 push @syms, $1;
89 }
90 }
91 close $h;
92}
94sub scanallheaders {
95 my $d = "$root/include/curl";
96 opendir(my $dh, $d) or die "Cannot opendir: $!";
97 my @headers = grep { /.h\z/ } readdir($dh);
98 closedir $dh;
99 foreach my $h (@headers) {
100 scanenum("$d/$h");
101 scanheader("$d/$h");
102 }
103}
105sub checkmanpage {
106 my ($m) = @_;
108 # detect global-looking 'CURL[BLABLA]_*' symbols
109 my $global_pat = '\W(CURL(AUTH|E|H|MOPT|OPT|SHOPT|UE|M|SSH|SSLBACKEND|HEADER|FORM|FTP|PIPE|MIMEOPT|GSSAPI|' .
110 'ALTSVC|PROTO|PROXY|UPART|USESSL|_READFUNC|_WRITEFUNC|_CSELECT|_FORMADD|_IPRESOLVE|_REDIR|_RTSPREQ|' .
111 '_TIMECOND|_VERSION)_[a-zA-Z0-9_]+)';
112 my $global_re = qr/$global_pat/;
114 open(my $mh, "<", $m);
115 my $line = 1;
116 while(<$mh>) {
117 # strip off formatting
118 $_ =~ s/(^|[^A-Z0-9])[*_]+/ /;
119 while(s/$global_re//) {
120 my $s = $1;
121 # skip two "special" ones
122 if($s !~ /(^(CURLE_OBSOLETE|CURLOPT_TEMPLATE))|_$/) {
123 push @manrefs, "$s:$m:$line";
124 }
125 }
126 $line++;
127 }
128 close($mh);
129}
131sub scanman_md_dir {
132 my ($d) = @_;
133 opendir(my $dh, $d) or die "Cannot opendir: $!";
134 my @mans = grep { /.md\z/ } readdir($dh);
135 closedir $dh;
136 for my $m (@mans) {
137 checkmanpage("$d/$m");
138 }
139}
141scanallheaders();
142scanman_md_dir("$root/docs/libcurl");
143scanman_md_dir("$root/docs/libcurl/opts");
145open(my $s, "<", "$root/docs/libcurl/symbols-in-versions");
146while(<$s>) {
147 if(/(^[^ \n]+) +(.*)/) {
148 my ($sym, $rest) = ($1, $2);
149 if($doc{$sym}) {
150 print "Detected duplicate symbol: $sym\n";
151 $misses++;
152 next;
153 }
154 $doc{$sym} = $sym;
155 my @a = split(/ +/, $rest);
156 if($a[2]) {
157 # this symbol is documented to have been present the last time
158 # in this release
159 $rem{$sym} = $a[2];
160 }
161 }
162}
163close $s;
165my $ignored = 0;
166for my $e (sort @syms) {
167 # OBSOLETE - names that are placeholders for a position where we
168 # previously had a name, that is now removed. The OBSOLETE names should
169 # never be used for anything.
170 #
171 # CURL_EXTERN - is a define used for libcurl functions that are external,
172 # public. No app or other code should ever use it.
173 #
174 # CURLINC_ - defines for header dual-include prevention, ignore those.
175 #
176 # CURL_TEMP_ - are defined and *undefined* again within the file
177 #
178 # *_LAST and *_LASTENTRY are suffix for the placeholders used for the
179 # last entry in many enum series.
180 #
182 if($e =~ /(OBSOLETE|CURLE_RESERVED|^CURL_EXTERN|^CURLINC_|_LAST\z|_LASTENTRY\z|^CURL_TEMP_)/) {
183 $ignored++;
184 next;
185 }
186 if($doc{$e}) {
187 if($verbose) {
188 print $e . "\n";
189 }
190 $doc{$e} = "used";
191 next;
192 }
193 else {
194 print $e . "\n";
195 $misses++;
196 }
197}
199#
200# now scan through all symbols that were present in the symbols-in-versions
201# but not in the headers
202#
203# If the symbols were marked 'removed' in symbols-in-versions we do not output
204# anything about it since that is perfectly fine.
205#
207my $anyremoved;
209for my $e (sort keys %doc) {
210 if(($doc{$e} ne "used") && !$rem{$e}) {
212 if(!$anyremoved++) {
213 print "Missing symbols mentioned in symbols-in-versions\n";
214 print "Add them to a header, or mark them as removed.\n";
215 }
217 print "$e\n";
218 $misses++;
219 }
220}
222my %warned;
223for my $r (@manrefs) {
224 if($r =~ /^([^:]+):(.*)/) {
225 my ($sym, $file) = ($1, $2);
226 if(!$doc{$sym} && !$warned{$sym, $file}) {
227 print "$file: $sym is not a public symbol\n";
228 $warned{$sym, $file} = 1;
229 }
230 }
231}
233if($summary) {
234 print "Summary:\n";
235 printf "%d symbols in headers (out of which %d are ignored)\n", scalar(@syms),
236 $ignored;
237 printf "%d symbols in headers are interesting\n",
238 scalar(@syms)- $ignored;
239 printf "%d symbols are listed in symbols-in-versions\n (out of which %d are listed as removed)\n", scalar(keys %doc), scalar(keys %rem);
240 printf "%d symbols in symbols-in-versions should match the ones in headers\n", scalar(keys %doc) - scalar(keys %rem);
241}
243if($misses) {
244 exit 0; # there are stuff to attend to!
245}
246else {
247 print "OK\n";
248}
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2003.0 KiB · hit23 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=23 git.response.bytes=3032 git.response.cache=HIT git.response.duration_ms=23 git.fetch.wants=f8303b8cef95a0e5b927416e674e9fb9382c1d4f git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=3032 git.pkt.payload.max=3011 git.sideband.band1.bytes=3010 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1c3388dee36cd
- Request
- 62dea4cb…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format