summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Deao2013-09-12 13:40:40 -0500
committerDoug Deao2013-09-12 13:40:40 -0500
commitf68709be3b4cacfc21546f23677614903e43942f (patch)
tree9497294ce5cf7e0f83021881f9e51fb540b3e1ca
parent2905d556c486fafa1bfdbeaee5177c53ff9cba28 (diff)
downloadctprof_srv-f68709be3b4cacfc21546f23677614903e43942f.tar.gz
ctprof_srv-f68709be3b4cacfc21546f23677614903e43942f.tar.xz
ctprof_srv-f68709be3b4cacfc21546f23677614903e43942f.zip
Version 1.1 update:
- 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.
-rw-r--r--ctprof_sync.sh4
-rw-r--r--example_app/ctprof_ex.c50
-rw-r--r--example_app/ctprof_utility.c1
-rw-r--r--example_app/ctprof_utility.h2
-rw-r--r--example_app/makefile4
-rw-r--r--server/ctoolsprof_srv_main.c4
-rw-r--r--server/makefile4
-rw-r--r--server/remote_commands.c12
8 files changed, 46 insertions, 35 deletions
diff --git a/ctprof_sync.sh b/ctprof_sync.sh
index 5819670..11fb0d2 100644
--- a/ctprof_sync.sh
+++ b/ctprof_sync.sh
@@ -47,6 +47,10 @@ do
47 break 47 break
48 fi 48 fi
49 fi 49 fi
50 if [[ ! -f $pipe ]]; then
51 break
52 fi
53
50done 54done
51 55
52echo "ctprof_sync exiting" 56echo "ctprof_sync exiting"
diff --git a/example_app/ctprof_ex.c b/example_app/ctprof_ex.c
index 4e44a25..839baee 100644
--- a/example_app/ctprof_ex.c
+++ b/example_app/ctprof_ex.c
@@ -45,7 +45,7 @@
45#include <fcntl.h> 45#include <fcntl.h>
46#include "ctprof_utility.h" 46#include "ctprof_utility.h"
47 47
48const int g_major_version = 0; 48const int g_major_version = 1;
49const int g_minor_version = 1; 49const int g_minor_version = 1;
50const int g_copyright_year = 2013; 50const int g_copyright_year = 2013;
51 51
@@ -64,7 +64,7 @@ struct memory_blk_t memory_table[] = {
64 {"Corepac L2_0", 0x10800000, 0, 1024*1024}, /* Corepac 0 L2 */ 64 {"Corepac L2_0", 0x10800000, 0, 1024*1024}, /* Corepac 0 L2 */
65 {"Corepac L2_1", 0x11800000, 0, 1024*1024}, /* Corepac 1 L2 */ 65 {"Corepac L2_1", 0x11800000, 0, 1024*1024}, /* Corepac 1 L2 */
66 {"Corepac L2_2", 0x12800000, 0, 1024*1024}, /* Corepac 2 L2 */ 66 {"Corepac L2_2", 0x12800000, 0, 1024*1024}, /* Corepac 2 L2 */
67 {"Corepac L2_3", 0x13800000, 0, 1024*1024} /* Corepac 3 L2 */ 67 {"Corepac L2_3", 0x13800000, 0, 1024*1024} /* Corepac 3 L2 */
68}; 68};
69 69
70const int zero_test_words = 65536; 70const int zero_test_words = 65536;
@@ -72,17 +72,16 @@ const int memory_table_elements = sizeof(memory_table)/sizeof(struct memory_blk_
72 72
73static struct option long_options[] = { 73static struct option long_options[] = {
74 {"interations", required_argument, 0, 'i'}, 74 {"interations", required_argument, 0, 'i'},
75 {"pipe", no_argument, 0, 'P'},
75 {"quiet", no_argument, 0,'q'}, 76 {"quiet", no_argument, 0,'q'},
76 {"help", no_argument, 0, 'h'}, 77 {"help", no_argument, 0, 'h'},
77 {"version", no_argument, 0, 'v'} 78 {"version", no_argument, 0, 'v'}
78}; 79};
79 80
80static char * short_options = "i:qhv"; 81static char * short_options = "i:qhvP";
81 82
82static int test_iterations = 1; 83static int test_iterations = 1;
83 84static bool pipe_enable = false;
84
85#define USE_SIGNALS 1
86 85
87int main(int argc, char *argv[]) 86int main(int argc, char *argv[])
88{ 87{
@@ -110,18 +109,21 @@ int main(int argc, char *argv[])
110 case 'h': 109 case 'h':
111 fprintf(g_stdout, "Usage: ctprof_ex [ihqv]\n"); 110 fprintf(g_stdout, "Usage: ctprof_ex [ihqv]\n");
112 fprintf(g_stdout, " --iterations/-i <n> Run test n times\n"); 111 fprintf(g_stdout, " --iterations/-i <n> Run test n times\n");
112 fprintf(g_stdout, " --pipe/-P Use pipe to coordiante with ctprof_srv\n");
113 fprintf(g_stdout, " --help/-h Print this\n"); 113 fprintf(g_stdout, " --help/-h Print this\n");
114 fprintf(g_stdout, " --quiet/-q Send stdout to /dev/null\n"); 114 fprintf(g_stdout, " --quiet/-q Send stdout to /dev/null\n");
115 fprintf(g_stdout, " --version/-v Print version\n"); 115 fprintf(g_stdout, " --version/-v Print version\n");
116 fprintf(g_stdout, "\n"); 116 fprintf(g_stdout, "\n");
117 exit(0); 117 exit(0);
118 case 'P':
119 pipe_enable = true;
120 break;
118 case 'v': 121 case 'v':
119 fprintf(g_stdout, "ctprof_ex version %d.%d\n", 122 fprintf(g_stdout, "ctprof_ex version %d.%d\n",
120 g_major_version, g_minor_version); 123 g_major_version, g_minor_version);
121 fprintf(g_stdout, "Copyright (C) %d Texas Instruments, Inc.\n", 124 fprintf(g_stdout, "Copyright (C) %d Texas Instruments, Inc.\n",
122 g_copyright_year); 125 g_copyright_year);
123 exit(0); 126 exit(0);
124 break;
125 default: 127 default:
126 fprintf(g_stderr,"Invalid option - try -h\n"); 128 fprintf(g_stderr,"Invalid option - try -h\n");
127 exit(0); 129 exit(0);
@@ -132,17 +134,16 @@ int main(int argc, char *argv[])
132 /************************************************************/ 134 /************************************************************/
133 /* Wait until ctprof is recording to start */ 135 /* Wait until ctprof is recording to start */
134 /************************************************************/ 136 /************************************************************/
135 if (ctprof_pipe_open() == -1) { 137 if (pipe_enable) {
136 fprintf(g_stderr, "Can't open pipe to ctprof\n"); 138 if (ctprof_pipe_open() == -1) {
137 exit(-1); 139 fprintf(g_stderr, "Can't open pipe to ctprof\n");
140 exit(-1);
141 }
142
143 ctprof_ready_wait();
144 ctprof_start_recording();
145 ctprof_recording_wait();
138 } 146 }
139
140#if USE_SIGNALS
141 ctprof_ready_wait();
142 ctprof_start_recording();
143#endif
144 ctprof_recording_wait();
145
146 /************************************************************/ 147 /************************************************************/
147 /* Map each memory table element */ 148 /* Map each memory table element */
148 /************************************************************/ 149 /************************************************************/
@@ -170,12 +171,13 @@ int main(int argc, char *argv[])
170 /* This test writes zero to the first 64K words of each memory_table element */ 171 /* This test writes zero to the first 64K words of each memory_table element */
171 for (int i = 0; i < memory_table_elements; i++) { 172 for (int i = 0; i < memory_table_elements; i++) {
172 173
173#if USE_SIGNALS 174 if (pipe_enable) {
174 if (i == 2) { 175 if (i == 2) {
175 ctprof_end_recording(); 176 ctprof_end_recording();
176 ctprof_stopped_wait(); 177 ctprof_stopped_wait();
178 }
177 } 179 }
178#endif 180
179 fprintf(g_stdout, "\r%s:Testing %d words of %s\n", g_whoami, zero_test_words, memory_table[i].name); 181 fprintf(g_stdout, "\r%s:Testing %d words of %s\n", g_whoami, zero_test_words, memory_table[i].name);
180 182
181 uint32_t * addr = (uint32_t *)memory_table[i].v_addr; 183 uint32_t * addr = (uint32_t *)memory_table[i].v_addr;
@@ -199,8 +201,10 @@ int main(int argc, char *argv[])
199 201
200 } /* End of while*/ 202 } /* End of while*/
201 203
204 if (pipe_enable) {
205 ctprof_pipe_close();
206 }
202 fprintf(g_stdout, "\r%s:Exiting\n", g_whoami); 207 fprintf(g_stdout, "\r%s:Exiting\n", g_whoami);
203 ctprof_pipe_close();
204 exit(0); 208 exit(0);
205} 209}
206 210
diff --git a/example_app/ctprof_utility.c b/example_app/ctprof_utility.c
index d3a836d..6524696 100644
--- a/example_app/ctprof_utility.c
+++ b/example_app/ctprof_utility.c
@@ -95,6 +95,7 @@ int ctprof_pipe_open(void)
95 } 95 }
96 96
97 ctprof_pipe_read((char *)&ctprof_srv_pid, sizeof(pid_t)); 97 ctprof_pipe_read((char *)&ctprof_srv_pid, sizeof(pid_t));
98 return 0;
98} 99}
99 100
100void ctprof_pipe_close(void) 101void ctprof_pipe_close(void)
diff --git a/example_app/ctprof_utility.h b/example_app/ctprof_utility.h
index e062dce..d57508c 100644
--- a/example_app/ctprof_utility.h
+++ b/example_app/ctprof_utility.h
@@ -41,7 +41,7 @@
41typedef enum { 41typedef enum {
42 CTPROF_READY, 42 CTPROF_READY,
43 CTPROF_STOPPED, 43 CTPROF_STOPPED,
44 CTPROF_RECORDING, 44 CTPROF_RECORDING
45} ctprof_state_t; 45} ctprof_state_t;
46 46
47int ctprof_pipe_open(void); 47int ctprof_pipe_open(void);
diff --git a/example_app/makefile b/example_app/makefile
index 1b5a5c4..706b0f4 100644
--- a/example_app/makefile
+++ b/example_app/makefile
@@ -7,7 +7,7 @@
7# To Use CROSS_COMPILE: 7# To Use CROSS_COMPILE:
8# make clean debug arm DESTDIR=your-destination-dir install 8# make clean debug arm DESTDIR=your-destination-dir install
9# make clean release arm DESTDIR=your-destination-dir install 9# make clean release arm DESTDIR=your-destination-dir install
10# make arm all DESTDIR=your-destination-dir 10# make all arm DESTDIR=your-destination-dir
11 11
12ifeq ($(findstring arm, $(MAKECMDGOALS)), arm) 12ifeq ($(findstring arm, $(MAKECMDGOALS)), arm)
13 CC= $(CROSS_COMPILE)gcc 13 CC= $(CROSS_COMPILE)gcc
@@ -27,7 +27,7 @@ INCLUDE_PATH = -I ../example_app
27 27
28.PHONY: clean debug release install arm 28.PHONY: clean debug release install arm
29 29
30all: clean release arm install 30all: clean release install
31 31
32# 32#
33# Declare.c and .h dependencies 33# Declare.c and .h dependencies
diff --git a/server/ctoolsprof_srv_main.c b/server/ctoolsprof_srv_main.c
index 4d17b43..d420c96 100644
--- a/server/ctoolsprof_srv_main.c
+++ b/server/ctoolsprof_srv_main.c
@@ -56,7 +56,7 @@
56#include "ctoolsprof.h" 56#include "ctoolsprof.h"
57 57
58const int g_major_version = 1; 58const int g_major_version = 1;
59const int g_minor_version = 0; 59const int g_minor_version = 1;
60const int g_copyright_year = 2013; 60const int g_copyright_year = 2013;
61 61
62FILE *g_stdout; 62FILE *g_stdout;
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
312 312
313 if (g_terminate) { 313 if (g_terminate) {
314 if (g_fifo_enabled) { 314 if (g_fifo_enabled) {
315 char * broken_pipe_msg = "terminating"; 315 char * broken_pipe_msg = NULL;
316 remote_pipe_write(msg_terminate, strlen(msg_terminate), broken_pipe_msg); 316 remote_pipe_write(msg_terminate, strlen(msg_terminate), broken_pipe_msg);
317 317
318 LOGMSG1("%s:write to the pipe %s", __func__, msg_terminate); 318 LOGMSG1("%s:write to the pipe %s", __func__, msg_terminate);
diff --git a/server/makefile b/server/makefile
index de76d0e..1a8bcab 100644
--- a/server/makefile
+++ b/server/makefile
@@ -7,7 +7,7 @@
7# To Use CROSS_COMPILE: 7# To Use CROSS_COMPILE:
8# make clean debug arm DESTDIR=your-destination-dir install 8# make clean debug arm DESTDIR=your-destination-dir install
9# make clean release arm DESTDIR=your-destination-dir install 9# make clean release arm DESTDIR=your-destination-dir install
10# make arm all DESTDIR=your-destination-dir 10# make all arm DESTDIR=your-destination-dir
11 11
12ifeq ($(findstring arm, $(MAKECMDGOALS)), arm) 12ifeq ($(findstring arm, $(MAKECMDGOALS)), arm)
13 CC= $(CROSS_COMPILE)gcc 13 CC= $(CROSS_COMPILE)gcc
@@ -37,7 +37,7 @@ VPATH = $(COMMON)
37 37
38.PHONY: clean debug release install arm 38.PHONY: clean debug release install arm
39 39
40all: clean release arm install 40all: clean release install
41 41
42# 42#
43# Declare.c and .h dependencies 43# Declare.c and .h dependencies
diff --git a/server/remote_commands.c b/server/remote_commands.c
index 90d06a9..7d9f118 100644
--- a/server/remote_commands.c
+++ b/server/remote_commands.c
@@ -1127,11 +1127,13 @@ void remote_pipe_write(const char * wr_buf_p, size_t wr_bytecnt, char * broken_p
1127 size_t rc = write(g_fifo_fd, wr_buf_p, wr_bytecnt); 1127 size_t rc = write(g_fifo_fd, wr_buf_p, wr_bytecnt);
1128 1128
1129 if ((rc == -1) && (errno == EPIPE)) { 1129 if ((rc == -1) && (errno == EPIPE)) {
1130 fprintf(g_stdout,"%s:warning - pipe reading end closed when sending %s.\n" 1130 if (broken_pipe_msg != NULL) {
1131 "%s: This can be caused by issuing a client operation before\n" 1131 fprintf(g_stdout,"%s:warning - pipe reading end closed when sending %s.\n"
1132 "%s: starting the task that opens the pipe's reading end OR\n" 1132 "%s: This can be caused by issuing a client operation before\n"
1133 "%s: early termination of the task that opens the pipe's reading end.\n", 1133 "%s: starting the task that opens the pipe's reading end OR\n"
1134 g_whoami, broken_pipe_msg, g_whoami, g_whoami, g_whoami); 1134 "%s: early termination of the task that opens the pipe's reading end.\n",
1135 g_whoami, broken_pipe_msg, g_whoami, g_whoami, g_whoami);
1136 }
1135 break; 1137 break;
1136 } 1138 }
1137 if ((rc == -1) && (errno == EINTR)) { 1139 if ((rc == -1) && (errno == EINTR)) {