#!/usr/bin/env perl
+#***************************************************************************
+# _ _ ____ _
+# Project ___| | | | _ \| |
+# / __| | | | |_) | |
+# | (__| |_| | _ <| |___
+# \___|\___/|_| \_\_____|
+#
+# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://curl.haxx.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+###########################################################################
#
# Example input:
#
my $callocs=0;
my $reallocs=0;
my $strdups=0;
+my $wcsdups=0;
my $showlimit;
while(1) {
}
-
+my $lnum=0;
while(<FILE>) {
chomp $_;
$line = $_;
-
+ $lnum++;
if($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) {
# new memory limit test prefix
my $i = $3;
if($sizeataddr{$addr}>0) {
# this means weeeeeirdo
- print "Mixed debug compile, rebuild curl now\n";
+ print "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n";
+ print "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n";
}
$sizeataddr{$addr}=$size;
$getmem{$addr}="$source:$linenum";
}
- elsif($function =~ /realloc\(0x([0-9a-f]*), (\d*)\) = 0x([0-9a-f]*)/) {
- $oldaddr = $1;
- $newsize = $2;
- $newaddr = $3;
+ elsif($function =~ /realloc\((\(nil\)|0x([0-9a-f]*)), (\d*)\) = 0x([0-9a-f]*)/) {
+ my ($oldaddr, $newsize, $newaddr) = ($2, $3, $4);
$totalmem -= $sizeataddr{$oldaddr};
if($trace) {
newtotal($totalmem);
$reallocs++;
-
+
$getmem{$oldaddr}="";
$getmem{$newaddr}="$source:$linenum";
}
$totalmem += $size;
if($trace) {
- printf("STRDUP: $size bytes at %s, makes totally: %d bytes\n",
+ printf("STRDUP: $size bytes at %s, makes totally: %d bytes\n",
$getmem{$addr}, $totalmem);
}
newtotal($totalmem);
$strdups++;
}
+ elsif($function =~ /wcsdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) {
+ # wcsdup(a5b50) (8) = df7c0
+
+ $dup = $1;
+ $size = $2;
+ $addr = $3;
+ $getmem{$addr}="$source:$linenum";
+ $sizeataddr{$addr}=$size;
+
+ $totalmem += $size;
+
+ if($trace) {
+ printf("WCSDUP: $size bytes at %s, makes totally: %d bytes\n",
+ $getmem{$addr}, $totalmem);
+ }
+
+ newtotal($totalmem);
+ $wcsdups++;
+ }
else {
print "Not recognized input line: $function\n";
- }
+ }
}
# FD url.c:1282 socket() = 5
elsif($_ =~ /^FD ([^ ]*):(\d*) (.*)/) {
$getfile{$1}="$source:$linenum";
$openfile++;
}
+ elsif($function =~ /socketpair\(\) = (\d*) (\d*)/) {
+ $filedes{$1}=1;
+ $getfile{$1}="$source:$linenum";
+ $openfile++;
+ $filedes{$2}=1;
+ $getfile{$2}="$source:$linenum";
+ $openfile++;
+ }
elsif($function =~ /accept\(\) = (\d*)/) {
$filedes{$1}=1;
$getfile{$1}="$source:$linenum";
$linenum = $2;
$function = $3;
- if($function =~ /fopen\(\"([^\"]*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) {
+ if($function =~ /f[d]*open\(\"(.*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) {
if($3 eq "(nil)") {
;
}
$addrinfofile{$add}="$source:$linenum";
$addrinfos++;
}
+ if($trace) {
+ printf("GETADDRINFO ($source:$linenum)\n");
+ }
}
# fclose(0x1026c8)
elsif($function =~ /freeaddrinfo\(0x([0-9a-f]*)\)/) {
$addrinfo{$1}=0;
$addrinfos--;
}
+ if($trace) {
+ printf("FREEADDRINFO ($source:$linenum)\n");
+ }
}
-
}
else {
print "Not recognized prefix line: $line\n";
"Reallocs: $reallocs\n",
"Callocs: $callocs\n",
"Strdups: $strdups\n",
+ "Wcsdups: $wcsdups\n",
"Frees: $frees\n",
- "Allocations: ".($mallocs + $callocs + $reallocs + $strdups)."\n";
+ "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n";
print "Maximum allocated: $maxmem\n";
}