add a command to force subbuffer switch
authorAlexis Hallé <alexis.halle@polymtl.ca>
Wed, 14 Jul 2010 18:52:00 +0000 (14:52 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 21 Jul 2010 02:21:26 +0000 (22:21 -0400)
libust/tracectl.c
libustcmd/ustcmd.c
libustcmd/ustcmd.h
ustctl/ustctl.c

index 1b684445e63f1a2efa38bd59f0678f018adb6a9a..a82c107c24364e35bfde21413215c412402cad76 100644 (file)
@@ -788,6 +788,15 @@ static void listener_cleanup(void *ptr)
        ustcomm_fini_app(&ustcomm_app, 0);
 }
 
+static void do_cmd_force_switch()
+{
+       struct blocked_consumer *bc;
+
+       list_for_each_entry(bc, &blocked_consumers, list) {
+               ltt_force_switch(bc->buf, FORCE_FLUSH);
+       }
+}
+
 int process_client_cmd(char *recvbuf, struct ustcomm_source *src)
 {
        int result;
@@ -1013,6 +1022,9 @@ int process_client_cmd(char *recvbuf, struct ustcomm_source *src)
                if(result)
                        ERR("cannot set UST_DAEMON_SOCKET environment variable");
        }
+       else if(nth_token_is(recvbuf, "force_switch", 0) == 1) {
+               do_cmd_force_switch();
+       }
        else {
                ERR("unable to parse message: %s", recvbuf);
        }
index 1c5894be4dd41657c88b721a62f1864db512fcb2..46a95618439915336fc654f9a90495b479d11039 100644 (file)
@@ -470,6 +470,18 @@ int ustcmd_get_sock_path(char **sock_path, pid_t pid)
        return 0;
 }
 
+int ustcmd_force_switch(pid_t pid)
+{
+       int result;
+
+       result = ustcmd_send_cmd("force_switch", pid, NULL);
+       if (result != 1) {
+               return USTCMD_ERR_GEN;
+       }
+
+       return 0;
+}
+
 /**
  * Sends a given command to a traceable process
  *
index 06e534526404bf343e3369dff25af92f6e5bb962..2e40d72ff75c1a9c35208f888c73fcb0dbeb2e21 100644 (file)
@@ -64,5 +64,6 @@ extern int ustcmd_send_cmd(const char *, pid_t, char **);
 extern int ustcmd_get_cmsf(struct marker_status **, pid_t);
 extern int ustcmd_set_sock_path(const char *, pid_t);
 extern int ustcmd_get_sock_path(char **, pid_t);
+extern int ustcmd_force_switch(pid_t);
 
 #endif /* _USTCMD_H */
index 50e0d012abff05ff861e0c1f9a9fe4546804975d..b9f2dce83b43913bc6aaedd766d160d9a81accdb 100644 (file)
@@ -42,6 +42,7 @@ enum command {
        GET_SUBBUF_NUM,
        GET_SOCK_PATH,
        SET_SOCK_PATH,
+       FORCE_SWITCH,
        UNKNOWN
 };
 
@@ -73,6 +74,7 @@ Commands:\n\
     --enable-marker \"CHANNEL/MARKER\"\tEnable a marker\n\
     --disable-marker \"CHANNEL/MARKER\"\tDisable a marker\n\
     --list-markers\t\t\tList the markers of the process, their\n\t\t\t\t\t  state and format string\n\
+    --force-switch\t\t\tForce a subbuffer switch\n\
 \
 ");
 }
@@ -103,6 +105,7 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                        { "get-subbuf-num", 1, 0, GET_SUBBUF_NUM },
                        { "get-sock-path", 0, 0, GET_SOCK_PATH },
                        { "set-sock-path", 1, 0, SET_SOCK_PATH },
+                       { "force-switch", 0, 0, FORCE_SWITCH },
                        { 0, 0, 0, 0 }
                };
 
@@ -332,6 +335,13 @@ int main(int argc, char *argv[])
                                }
                                break;
 
+                       case FORCE_SWITCH:
+                               result = ustcmd_force_switch(*pidit);
+                               if (result) {
+                                       ERR("error while trying to force switch for PID %u\n", (unsigned int) *pidit);
+                               }
+                               break;
+
                        default:
                                ERR("unknown command\n");
                        break;
This page took 0.025773 seconds and 4 git commands to generate.