Version 1.1 update:
authorDoug Deao <d-deao@ti.com>
Thu, 12 Sep 2013 18:40:40 +0000 (13:40 -0500)
committerDoug Deao <d-deao@ti.com>
Thu, 12 Sep 2013 18:40:40 +0000 (13:40 -0500)
- Made minor ctprof_srv modification to eliminate pipe warning
  when terminating (when using -t with ctprof_sync.sh script).
- Improved ctprof_ex to make it usable for all examples in wiki
  documentation.

ctprof_sync.sh
example_app/ctprof_ex.c
example_app/ctprof_utility.c
example_app/ctprof_utility.h
example_app/makefile
server/ctoolsprof_srv_main.c
server/makefile
server/remote_commands.c

index 5819670e108610af573c65134ac28ab65bd393a4..11fb0d2a730604a6f7efb56cebdaadd01cb97507 100644 (file)
@@ -47,6 +47,10 @@ do
             break
         fi
     fi
+    if [[ ! -f $pipe ]]; then
+        break
+    fi
+
 done
 
 echo "ctprof_sync exiting"
index 4e44a2566ee716b57993adecb97e5e6323e713a5..839baee36356456346a606549058a935989337e4 100644 (file)
@@ -45,7 +45,7 @@
 #include <fcntl.h>
 #include "ctprof_utility.h"
 
-const int g_major_version = 0;
+const int g_major_version = 1;
 const int g_minor_version = 1;
 const int g_copyright_year = 2013;
 
@@ -64,7 +64,7 @@ struct memory_blk_t memory_table[] = {
     {"Corepac L2_0", 0x10800000, 0, 1024*1024}, /* Corepac 0 L2 */
     {"Corepac L2_1", 0x11800000, 0, 1024*1024}, /* Corepac 1 L2 */
     {"Corepac L2_2", 0x12800000, 0, 1024*1024}, /* Corepac 2 L2 */
-    {"Corepac L2_3", 0x13800000, 0, 1024*1024} /* Corepac 3 L2 */
+    {"Corepac L2_3", 0x13800000, 0, 1024*1024}  /* Corepac 3 L2 */
 };
 
 const int zero_test_words = 65536;
@@ -72,17 +72,16 @@ const int memory_table_elements = sizeof(memory_table)/sizeof(struct memory_blk_
 
 static struct option long_options[] = {
     {"interations", required_argument, 0, 'i'},
+    {"pipe", no_argument, 0, 'P'},
     {"quiet", no_argument, 0,'q'},
     {"help", no_argument, 0, 'h'},
     {"version", no_argument, 0, 'v'}
 };
 
-static char * short_options = "i:qhv";
+static char * short_options = "i:qhvP";
 
 static int test_iterations = 1;
-
-
-#define USE_SIGNALS 1
+static bool pipe_enable = false;
 
 int main(int argc, char *argv[])
 {
@@ -110,18 +109,21 @@ int main(int argc, char *argv[])
         case 'h':
             fprintf(g_stdout, "Usage: ctprof_ex [ihqv]\n");
             fprintf(g_stdout, " --iterations/-i <n>     Run test n times\n");
+            fprintf(g_stdout, " --pipe/-P               Use pipe to coordiante with ctprof_srv\n");
             fprintf(g_stdout, " --help/-h               Print this\n");
             fprintf(g_stdout, " --quiet/-q              Send stdout to /dev/null\n");
             fprintf(g_stdout, " --version/-v            Print version\n");
             fprintf(g_stdout, "\n");
             exit(0);
+        case 'P':
+            pipe_enable = true;
+            break;
         case 'v':
             fprintf(g_stdout, "ctprof_ex version %d.%d\n", 
                                              g_major_version, g_minor_version);
             fprintf(g_stdout, "Copyright (C) %d Texas Instruments, Inc.\n", 
                                                              g_copyright_year); 
             exit(0);
-            break;
         default:
             fprintf(g_stderr,"Invalid option - try -h\n");
             exit(0); 
@@ -132,17 +134,16 @@ int main(int argc, char *argv[])
     /************************************************************/
     /* Wait until ctprof is recording to start                  */
     /************************************************************/
-    if (ctprof_pipe_open() == -1) {
-        fprintf(g_stderr, "Can't open pipe to ctprof\n");
-        exit(-1);
+    if (pipe_enable) {
+        if (ctprof_pipe_open() == -1) {
+            fprintf(g_stderr, "Can't open pipe to ctprof\n");
+            exit(-1);
+        }
+        ctprof_ready_wait();
+        ctprof_start_recording();
+        ctprof_recording_wait();
     }
-
-#if USE_SIGNALS
-    ctprof_ready_wait();
-    ctprof_start_recording();
-#endif
-    ctprof_recording_wait();
-
     /************************************************************/
     /* Map each memory table element                            */
     /************************************************************/
@@ -170,12 +171,13 @@ int main(int argc, char *argv[])
         /* This test writes zero to the first 64K words of each memory_table element */
         for (int i = 0; i <  memory_table_elements; i++) {
 
-#if USE_SIGNALS
-            if (i == 2) {
-                ctprof_end_recording();
-                ctprof_stopped_wait();
+            if (pipe_enable) {
+                if (i == 2) {
+                    ctprof_end_recording();
+                    ctprof_stopped_wait();
+                }
             }
-#endif
+
             fprintf(g_stdout, "\r%s:Testing %d words of %s\n", g_whoami, zero_test_words, memory_table[i].name);
 
             uint32_t * addr = (uint32_t *)memory_table[i].v_addr;
@@ -199,8 +201,10 @@ int main(int argc, char *argv[])
 
     } /* End of while*/
 
+    if (pipe_enable) {
+        ctprof_pipe_close();
+    }
     fprintf(g_stdout, "\r%s:Exiting\n", g_whoami);
-    ctprof_pipe_close();
     exit(0);
 }
 
index d3a836d8e285548365d28d8c97ebfc96b1af6293..6524696bde7d8c3eeb8a3f5026963fafe775e039 100644 (file)
@@ -95,6 +95,7 @@ int ctprof_pipe_open(void)
     }
 
     ctprof_pipe_read((char *)&ctprof_srv_pid, sizeof(pid_t));
+    return 0;
 }
 
 void ctprof_pipe_close(void)
index e062dceee15563031ba1ad4e70d79cb785850844..d57508c1b031dffa8035349e1055fdd9bc109ec1 100644 (file)
@@ -41,7 +41,7 @@
 typedef enum {
     CTPROF_READY,
     CTPROF_STOPPED,
-    CTPROF_RECORDING,
+    CTPROF_RECORDING
 } ctprof_state_t;
 
 int ctprof_pipe_open(void);
index 1b5a5c4170b018736f51d0518f261b13f38430a6..706b0f4f5e75e0cbd635fb47fd4fb0eb8e8986a0 100644 (file)
@@ -7,7 +7,7 @@
 # To Use CROSS_COMPILE:
 # make clean debug arm DESTDIR=your-destination-dir install
 # make clean release arm DESTDIR=your-destination-dir install 
-# make arm all DESTDIR=your-destination-dir
+# make all arm DESTDIR=your-destination-dir
 
 ifeq ($(findstring arm, $(MAKECMDGOALS)), arm) 
        CC= $(CROSS_COMPILE)gcc
@@ -27,7 +27,7 @@ INCLUDE_PATH = -I ../example_app
 
 .PHONY: clean debug release install arm
 
-all: clean release arm install
+all: clean release install
 
 #
 # Declare.c and .h dependencies
index 4d17b433dfa22a7a5d5f4b6ba0fa2f94eecd807d..d420c96b1362305e1102ac6e070d206511293f9c 100644 (file)
@@ -56,7 +56,7 @@
 #include "ctoolsprof.h"
 
 const int g_major_version = 1;
-const int g_minor_version = 0;
+const int g_minor_version = 1;
 const int g_copyright_year = 2013;
 
 FILE *g_stdout;
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
 
             if (g_terminate) {
                 if (g_fifo_enabled) {            
-                    char * broken_pipe_msg = "terminating";
+                    char * broken_pipe_msg = NULL;
                     remote_pipe_write(msg_terminate, strlen(msg_terminate), broken_pipe_msg);
 
                     LOGMSG1("%s:write to the pipe %s", __func__, msg_terminate);
index de76d0e18d7219cf072e6bbc23e412335aeabed9..1a8bcab384f84086a1ba7bd957d786e9066e432c 100644 (file)
@@ -7,7 +7,7 @@
 # To Use CROSS_COMPILE:
 # make clean debug arm DESTDIR=your-destination-dir install
 # make clean release arm DESTDIR=your-destination-dir install 
-# make arm all DESTDIR=your-destination-dir   
+# make all arm DESTDIR=your-destination-dir   
 
 ifeq ($(findstring arm, $(MAKECMDGOALS)), arm) 
        CC= $(CROSS_COMPILE)gcc
@@ -37,7 +37,7 @@ VPATH = $(COMMON)
 
 .PHONY: clean debug release install arm
 
-all: clean release arm install
+all: clean release install
 
 #
 # Declare.c and .h dependencies
index 90d06a970a4b48af25aa9b4f0a574aa72eb62aa8..7d9f118f66dc7f4d02160098fe6d7cc00deda147 100644 (file)
@@ -1127,11 +1127,13 @@ void remote_pipe_write(const char * wr_buf_p, size_t wr_bytecnt, char * broken_p
         size_t rc = write(g_fifo_fd, wr_buf_p, wr_bytecnt);
 
         if ((rc == -1) && (errno == EPIPE)) {
-            fprintf(g_stdout,"%s:warning - pipe reading end closed when sending %s.\n"                    
-                             "%s:  This can be caused by issuing a client operation before\n"
-                             "%s:  starting the task that opens the pipe's reading end OR\n"
-                             "%s:  early termination of the task that opens the pipe's reading end.\n",
-                    g_whoami, broken_pipe_msg, g_whoami, g_whoami, g_whoami);
+            if (broken_pipe_msg != NULL) {
+                fprintf(g_stdout,"%s:warning - pipe reading end closed when sending %s.\n"                    
+                                 "%s:  This can be caused by issuing a client operation before\n"
+                                 "%s:  starting the task that opens the pipe's reading end OR\n"
+                                 "%s:  early termination of the task that opens the pipe's reading end.\n",
+                        g_whoami, broken_pipe_msg, g_whoami, g_whoami, g_whoami);
+            }
             break;
         }
         if ((rc == -1) && (errno == EINTR)) {