Changeset: c268a1159906 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c268a1159906
Modified Files:
        clients/mapiclient/eventparser.c
        clients/mapiclient/stethoscope.c
Branch: compactprofiler
Log Message:

Minor changes in eventparser and stethoscope


diffs (279 lines):

diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -81,11 +81,11 @@ argparser(char *txt, EventRecord *ev){
        (void) ev;
        (void) key;
        /* First determine the number arguments to deal with */
-       while( *c){
+       while(*c){
                skipto(c, '\t');
                if(*c){
                        c++;
-                       if( *c == '}')
+                       if(*c == '}')
                                cnt ++;
                }
        }
@@ -98,10 +98,10 @@ argparser(char *txt, EventRecord *ev){
 
        /* parse the event argument structures, using the \t field separator */
        c=  txt + 1;
-       while( *c){
-               if( *c == '{' || *c == '[')
+       while(*c){
+               if(*c == '{' || *c == '[')
                        c++;
-               if( *c == '}' || *c == ']')
+               if(*c == '}' || *c == ']')
                        break;
 
                skipto(c, '"');
@@ -116,37 +116,37 @@ argparser(char *txt, EventRecord *ev){
                if(*c){ --c; *c = 0; c++;}
 
                /* These components should be the first */
-               if( strstr(key,"ret")) {
+               if(strstr(key,"ret")) {
                        arg = atoi(val);
                        ev->args[arg].kind = MDB_RET;
                        continue;
                }
-               if( strstr(key,"arg")) {
+               if(strstr(key,"arg")) {
                        arg = atoi(val);
                        ev->args[arg].kind = MDB_ARG;
                        continue;
                }
                assert(arg> -1 && arg < ev->maxarg);
-               if( strstr(key,"bid")) { ev->args[arg].bid = atoi(val); 
continue;}
-               if( strstr(key,"alias")) { ev->args[arg].alias = getstr(val); 
continue;}
-               if( strstr(key,"name")) { ev->args[arg].name = getstr(val); 
continue;}
-               if( strstr(key,"type")) { ev->args[arg].type = 
getstr(val);continue;}
-               if( strstr(key,"view")) { ev->args[arg].view = getstr(val); 
continue;}
-               if( strstr(key,"parent")) { ev->args[arg].parent = getstr(val); 
continue;}
-               if( strstr(key,"persistence")) { ev->args[arg].persistence = 
getstr(val); continue;}
-               if( strstr(key,"file")) { ev->args[arg].file = getstr(val); 
continue;}
-               if( strstr(key,"seqbase")) { ev->args[arg].seqbase = 
getstr(val); continue;}
-               if( strstr(key,"sorted")) { ev->args[arg].sorted = getstr(val); 
continue;}
-               if( strstr(key,"revsorted")) { ev->args[arg].revsorted = 
getstr(val); continue;}
-               if( strstr(key,"nonil")) { ev->args[arg].nonil = getstr(val); 
continue;}
-               if( strstr(key,"nil")) { ev->args[arg].nil = getstr(val); 
continue;}
-               if( strstr(key,"key")) { ev->args[arg].key = getstr(val); 
continue;}
-               if( strstr(key,"unique")) { ev->args[arg].unique = getstr(val); 
continue;}
-               if( strstr(key,"count")) { ev->args[arg].count = atol(val); 
continue;}
-               if( strstr(key,"size")) { ev->args[arg].size = getstr(val); 
continue;}
-               if( strstr(key,"value")) { ev->args[arg].value = getstr(val); 
continue;}
-               if( strstr(key,"debug")) { ev->args[arg].debug = getstr(val); 
continue;}
-               if( strstr(key,"const")) { ev->args[arg].constant = atoi(val); 
continue;}
+               if(strstr(key,"bid")) { ev->args[arg].bid = atoi(val); 
continue;}
+               if(strstr(key,"alias")) { ev->args[arg].alias = getstr(val); 
continue;}
+               if(strstr(key,"name")) { ev->args[arg].name = getstr(val); 
continue;}
+               if(strstr(key,"type")) { ev->args[arg].type = 
getstr(val);continue;}
+               if(strstr(key,"view")) { ev->args[arg].view = getstr(val); 
continue;}
+               if(strstr(key,"parent")) { ev->args[arg].parent = getstr(val); 
continue;}
+               if(strstr(key,"persistence")) { ev->args[arg].persistence = 
getstr(val); continue;}
+               if(strstr(key,"file")) { ev->args[arg].file = getstr(val); 
continue;}
+               if(strstr(key,"seqbase")) { ev->args[arg].seqbase = 
getstr(val); continue;}
+               if(strstr(key,"sorted")) { ev->args[arg].sorted = getstr(val); 
continue;}
+               if(strstr(key,"revsorted")) { ev->args[arg].revsorted = 
getstr(val); continue;}
+               if(strstr(key,"nonil")) { ev->args[arg].nonil = getstr(val); 
continue;}
+               if(strstr(key,"nil")) { ev->args[arg].nil = getstr(val); 
continue;}
+               if(strstr(key,"key")) { ev->args[arg].key = getstr(val); 
continue;}
+               if(strstr(key,"unique")) { ev->args[arg].unique = getstr(val); 
continue;}
+               if(strstr(key,"count")) { ev->args[arg].count = atol(val); 
continue;}
+               if(strstr(key,"size")) { ev->args[arg].size = getstr(val); 
continue;}
+               if(strstr(key,"value")) { ev->args[arg].value = getstr(val); 
continue;}
+               if(strstr(key,"debug")) { ev->args[arg].debug = getstr(val); 
continue;}
+               if(strstr(key,"const")) { ev->args[arg].constant = atoi(val); 
continue;}
        }
        return 1;
 }
@@ -157,11 +157,11 @@ keyvalueparser(char *txt, EventRecord *e
        char *c, *key, *val;
        c = txt;
 
-       if( *c == '{'){
+       if(*c == '{'){
                resetEventRecord(ev);
                return 0;
        }
-       if( *c == '}')
+       if(*c == '}')
                return 1;
 
        skipto(c, '"');
@@ -170,18 +170,18 @@ keyvalueparser(char *txt, EventRecord *e
        *c++ = 0;
        skipto(c, ':');
        c++;
-       while( *c && isspace((unsigned char) *c)) c++;
-       if( *c == '"'){
+       while(*c && isspace((unsigned char) *c)) c++;
+       if(*c == '"'){
                val = ++c;
                skipstr();
                *c = 0;
        } else val =c;
 
-       if( strstr(key,"mclk")){
+       if(strstr(key,"mclk")){
                ev->usec = atol(val);
                return 0;
        }
-       if( strstr(key,"clk")){
+       if(strstr(key,"clk")){
                time_t sec;
                uint64_t microsec;
                struct tm curr_time;
@@ -217,24 +217,24 @@ keyvalueparser(char *txt, EventRecord *e
                }
                return 0;
        }
-       if( strstr(key,"version")) { ev->version= strdup(val); return 0;}
-       if( strstr(key,"user")){ ev->user= strdup(val); return 0;}
-       if( strstr(key,"session")) { ev->session= strdup(val); return 0;}
-       if( strstr(key,"function")){ ev->function= strdup(val); return 0;}
-       if( strstr(key,"tag")){ ev->tag= atoi(val); return 0;}
-       if( strstr(key,"thread")){ ev->thread= atoi(val); return 0;}
-       if( strstr(key,"module")){ ev->module= strdup(val); return 0;}
-       if( strstr(key,"instruction")){ ev->instruction= strdup(val); return 0;}
-       if( strstr(key,"pc")){ ev->pc= atoi(val); return 0;}
-       if( strstr(key,"state")){ ev->state= strdup(val);}
-       if( strstr(key,"stmt")){ ev->stmt= strdup(val);}
-       if( strstr(key,"usec")) { ev->ticks= atoi(val); return 0;}
-       if( strstr(key,"rss")) { ev->rss= atol(val); return 0;}
-       if( strstr(key,"inblock")) { ev->inblock= atol(val); return 0;}
-       if( strstr(key,"oublock")) { ev->oublock= atol(val); return 0;}
-       if( strstr(key,"majflt")) { ev->majflt= atol(val); return 0;}
-       if( strstr(key,"swaps")) { ev->swaps= atol(val); return 0;}
-       if( strstr(key,"nvcsw")) { ev->nvcsw= atol(val); return 0;}
+       if(strstr(key,"version")) { ev->version= strdup(val); return 0;}
+       if(strstr(key,"user")){ ev->user= strdup(val); return 0;}
+       if(strstr(key,"session")) { ev->session= strdup(val); return 0;}
+       if(strstr(key,"function")){ ev->function= strdup(val); return 0;}
+       if(strstr(key,"tag")){ ev->tag= atoi(val); return 0;}
+       if(strstr(key,"thread")){ ev->thread= atoi(val); return 0;}
+       if(strstr(key,"module")){ ev->module= strdup(val); return 0;}
+       if(strstr(key,"instruction")){ ev->instruction= strdup(val); return 0;}
+       if(strstr(key,"pc")){ ev->pc= atoi(val); return 0;}
+       if(strstr(key,"state")){ ev->state= strdup(val);}
+       if(strstr(key,"stmt")){ ev->stmt= strdup(val);}
+       if(strstr(key,"usec")) { ev->ticks= atoi(val); return 0;}
+       if(strstr(key,"rss")) { ev->rss= atol(val); return 0;}
+       if(strstr(key,"inblock")) { ev->inblock= atol(val); return 0;}
+       if(strstr(key,"oublock")) { ev->oublock= atol(val); return 0;}
+       if(strstr(key,"majflt")) { ev->majflt= atol(val); return 0;}
+       if(strstr(key,"swaps")) { ev->swaps= atol(val); return 0;}
+       if(strstr(key,"nvcsw")) { ev->nvcsw= atol(val); return 0;}
 
        if (strstr(key,"args")) 
                argparser(val,ev);
@@ -252,15 +252,15 @@ renderArgs(FILE *fd, EventRecord *ev, in
 {
        int i;
        for(i=start; i< ev->maxarg && ev->args[i].kind == kind; i++){
-               if( ev->args[i].constant)
+               if(ev->args[i].constant)
                        fprintf(fd, "%s:%s ", ev->args[i].value, 
ev->args[i].type);
                else {
-                       if( strncmp(ev->args[i].type, "bat",3) == 0)
+                       if(strncmp(ev->args[i].type, "bat",3) == 0)
                                fprintf(fd, "%s=[%ld]:%s ", ev->args[i].name, 
ev->args[i].count, ev->args[i].type);
                        else
                                fprintf(fd, "%s=%s:%s ", ev->args[i].name, 
ev->args[i].value, ev->args[i].type);
                }
-               if( i< ev->maxarg-1 && ev->args[i+1].kind == kind) 
fprintf(fd,",");
+               if(i< ev->maxarg-1 && ev->args[i+1].kind == kind) 
fprintf(fd,",");
        }
        return i;
 }
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -103,7 +103,7 @@ static void
 stopListening(int i)
 {
        fprintf(stderr,"stethoscope: signal %d received\n",i);
-       if( dbh)
+       if(dbh)
                doQ("profiler.stop();");
 stop_disconnect:
        // show follow up action only once
@@ -148,7 +148,7 @@ main(int argc, char **argv)
                { 0, 0, 0, 0 }
        };
 
-       if( ev == NULL) {
+       if(ev == NULL) {
                fprintf(stderr,"could not allocate space\n");
                exit(-1);
        }
@@ -264,19 +264,19 @@ main(int argc, char **argv)
                fprintf(stderr,"-- connection with server %s\n", uri ? uri : 
host);
 
        snprintf(buf,BUFSIZ-1,"profiler.setheartbeat(%d);",beat);
-       if( debug)
+       if(debug)
                fprintf(stderr,"-- %s\n",buf);
        doQ(buf);
 
        snprintf(buf, BUFSIZ, "profiler.openstream();");
-       if( debug)
+       if(debug)
                fprintf(stderr,"--%s\n",buf);
        doQ(buf);
 
        if(filename != NULL) {
                trace = fopen(filename,"w");
 
-               if( trace == NULL) {
+               if(trace == NULL) {
                        fprintf(stderr,"Could not create file '%s', printing to 
stdout instead...\n", filename);
                        filename = NULL;
                }
@@ -285,12 +285,12 @@ main(int argc, char **argv)
        len = 0;
        buflen = BUFSIZ;
        buffer = (char *) malloc(buflen);
-       if( buffer == NULL){
+       if(buffer == NULL){
                fprintf(stderr,"Could not create input buffer\n");
                exit(-1);
        }
        conn = mapi_get_from(dbh);
-       if( !trace)
+       if(!trace)
                trace = stdout;
        if(!json)
                renderHeader(trace);
@@ -300,7 +300,7 @@ main(int argc, char **argv)
                        break;
                buffer[len + n] = 0;
                response = buffer;
-               if( debug)
+               if(debug)
                                printf("%s", response);
                if(json) {
                        if(trace != NULL) {
@@ -319,7 +319,7 @@ main(int argc, char **argv)
                                if (debug)
                                        printf("%s\n", response);
                                done= keyvalueparser(response,ev);
-                               if( done== 1){
+                               if(done== 1){
                                        renderSummary(trace, ev, "");
                                        first = 0;
                                }
@@ -329,9 +329,9 @@ main(int argc, char **argv)
 
                /* handle the case that the line is too long to
                 * fit in the buffer */
-               if( response == buffer){
+               if(response == buffer){
                        char *new =  (char *) realloc(buffer, buflen + BUFSIZ);
-                       if( new == NULL){
+                       if(new == NULL){
                                fprintf(stderr,"Could not extend input 
buffer\n");
                                exit(-1);
                        }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to