From: Wouter Wijngaards Date: Wed, 16 Sep 2009 12:56:00 +0000 (+0000) Subject: Fixed memstats for log-ascii format. X-Git-Tag: release-1.4.0rc1~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=795a25c1172d32d0e371338309bc9b573c6401b7;p=thirdparty%2Funbound.git Fixed memstats for log-ascii format. git-svn-id: file:///svn/unbound/trunk@1833 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/testcode/memstats.c b/testcode/memstats.c index 814640738..5fc079dcb 100644 --- a/testcode/memstats.c +++ b/testcode/memstats.c @@ -80,12 +80,16 @@ match(char* line) /* f.e.: * [1187340064] unbound[24604:0] info: ul/rb.c:81 r_create malloc(12) * 0123456789 123456789 123456789 123456789 + * But now also: + * Sep 16 15:18:20 unbound[17428:0] info: ul/nh.c:143 memdup malloc(11) */ if(strlen(line) < 36) /* up to 'info: ' */ return 0; - if(strncmp(line+30, "info: ", 6) != 0) + if(strncmp(line+30, "info: ", 6) != 0 && + strncmp(line+33, "info: ", 6) != 0) return 0; - if(strncmp(line+36, "stat ", 5) == 0) + if(strncmp(line+36, "stat ", 5) == 0 || + strncmp(line+39, "stat ", 5) == 0) return 0; /* skip the hex dumps */ if(strstr(line+36, "malloc(")) return 1; @@ -123,12 +127,13 @@ read_malloc_stat(char* line, rbtree_t* tree) int skip = 0; long num = 0; struct codeline* cl = 0; - if(sscanf(line+36, "%s %s %n", codeline, name, &skip) != 2) { - printf("%s\n%s\n", line, line+36); + line = strstr(line, "info: ")+6; + if(sscanf(line, "%s %s %n", codeline, name, &skip) != 2) { + printf("%s\n", line); fatal_exit("unhandled malloc"); } - if(sscanf(line+36+skip+7, "%ld", &num) != 1) { - printf("%s\n%s\n", line, line+36+skip+7); + if(sscanf(line+skip+7, "%ld", &num) != 1) { + printf("%s\n%s\n", line, line+skip+7); fatal_exit("unhandled malloc"); } cl = get_codeline(tree, codeline, name); @@ -147,12 +152,13 @@ read_calloc_stat(char* line, rbtree_t* tree) int skip = 0; long num = 0, sz = 0; struct codeline* cl = 0; - if(sscanf(line+36, "%s %s %n", codeline, name, &skip) != 2) { - printf("%s\n%s\n", line, line+36); + line = strstr(line, "info: ")+6; + if(sscanf(line, "%s %s %n", codeline, name, &skip) != 2) { + printf("%s\n", line); fatal_exit("unhandled calloc"); } - if(sscanf(line+36+skip+7, "%ld, %ld", &num, &sz) != 2) { - printf("%s\n%s\n", line, line+36+skip+7); + if(sscanf(line+skip+7, "%ld, %ld", &num, &sz) != 2) { + printf("%s\n%s\n", line, line+skip+7); fatal_exit("unhandled calloc"); }