]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixed memstats for log-ascii format.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 16 Sep 2009 12:56:00 +0000 (12:56 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 16 Sep 2009 12:56:00 +0000 (12:56 +0000)
git-svn-id: file:///svn/unbound/trunk@1833 be551aaa-1e26-0410-a405-d3ace91eadb9

testcode/memstats.c

index 8146407382fe732f7c17e626da85310763d1dd3b..5fc079dcbdc4a951bf6ccdf2a6f1ff98f1c14ccc 100644 (file)
@@ -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");
        }