struct app_info_t app_info;
struct target_info_t target_info;
struct msg_t *msg_reply;
+ struct conf_t conf;
LOGI("MY HANDLE %s (%X)\n", msg_ID_str(msg->id), msg->id);
return -1;
}
- if (startProfiling(prof_session.conf.use_features) < 0) {
+ if (start_profiling() < 0) {
sendACKToHost(msg->id, ERR_CANNOT_START_PROFILING, 0, 0);
return -1;
}
sendACKToHost(msg->id, ERR_NO, 0, 0);
break;
case NMSG_CONFIG:
- if (!parse_msg_config(msg->payload, &prof_session.conf)) {
+ if (!parse_msg_config(msg->payload, &conf)) {
LOGE("config parsing error\n");
sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0);
return -1;
}
+ if (!reconfigure(conf)) {
+ LOGE("Cannot change configuration\n");
+ return -1;
+ }
sendACKToHost(msg->id,ERR_NO,0,0);
break;
case NMSG_BINARY_INFO:
static void epoll_add_input_events();
static void epoll_del_input_events();
-int startProfiling(long launchflag)
+int start_profiling()
{
const struct app_info_t *app_info = &prof_session.app_info;
int res = 0;
#ifndef LOCALTEST
smack_lsetlabel(SCREENSHOT_DIR, "*", SMACK_LABEL_ACCESS);
#endif
- manager.config_flag = launchflag;
if (IS_OPT_SET(FL_CPU | FL_MEMORY)) {
if (samplingStart() < 0) {
recording_stop:
if (IS_OPT_SET(FL_RECORDING))
epoll_del_input_events();
-
-sampling_stop:
if (IS_OPT_SET(FL_CPU | FL_MEMORY))
samplingStop();
samplingStop();
}
+static void reconfigure_recording(struct conf_t conf)
+{
+ uint64_t old_features = prof_session.conf.use_features;
+ uint64_t new_features = conf.use_features;
+ uint64_t to_enable = (new_features ^ old_features) & new_features;
+ uint64_t to_disable = (new_features ^ old_features) & old_features;
+
+ if (IS_OPT_SET_IN(FL_RECORDING, to_disable)) {
+ epoll_del_input_events();
+ prof_session.conf.use_features &= ~FL_RECORDING;
+ }
+
+ if (IS_OPT_SET_IN(FL_RECORDING, to_enable)) {
+ epoll_add_input_events();
+ prof_session.conf.use_features |= FL_RECORDING;
+ }
+
+}
+
+static int reconfigure_cpu_and_memory(struct conf_t conf)
+{
+ uint64_t old_features = prof_session.conf.use_features;
+ uint64_t new_features = conf.use_features;
+ uint64_t to_enable = (new_features ^ old_features) & new_features;
+ uint64_t to_disable = (new_features ^ old_features) & old_features;
+
+ prof_session.conf.system_trace_period = conf.system_trace_period;
+
+ if (IS_OPT_SET(FL_CPU | FL_MEMORY))
+ samplingStop();
+
+ if (IS_OPT_SET_IN(FL_CPU | FL_MEMORY, to_disable)) {
+ prof_session.conf.use_features &= ~(FL_CPU | FL_MEMORY);
+ return 0;
+ }
+
+ if (IS_OPT_SET_IN(FL_CPU | FL_MEMORY, to_enable)) {
+ if (samplingStart() < 0) {
+ LOGE("Cannot start sampling\n");
+ return -1;
+ }
+ prof_session.conf.use_features |= (FL_CPU | FL_MEMORY);
+ }
+
+ return 0;
+}
+
+int reconfigure(struct conf_t conf)
+{
+ reconfigure_recording(conf);
+ if (reconfigure_cpu_and_memory(conf)) {
+ LOGE("Cannot reconf cpu and memory\n");
+ return -1;
+ }
+
+ return 0;
+}
+
// just send stop message to all target process
static void terminate_all_target()
{
// send config message to target process
log.type = MSG_OPTION;
- log.length = sprintf(log.data, "%u", manager.config_flag);
- send(manager.target[index].socket, &log, sizeof(log.type) + sizeof(log.length) + log.length, MSG_NOSIGNAL);
+ log.length = sprintf(log.data, "%u",
+ prof_session.conf.use_features);
+ send(manager.target[index].socket, &log,
+ sizeof(log.type) + sizeof(log.length) + log.length,
+ MSG_NOSIGNAL);
// make event fd
manager.target[index].event_fd = eventfd(0, EFD_NONBLOCK);
#include "da_data.h"
//#define DEBUG_GSI
-#define TIMER_INTERVAL_SEC 1
-#define TIMER_INTERVAL_USEC 0
static void* recvThread(void* data)
{
int samplingStart()
{
struct itimerval timerval;
+ time_t sec = prof_session.conf.system_trace_period / 1000;
+ suseconds_t usec = prof_session.conf.system_trace_period * 1000 %
+ 1000000;
if(manager.sampling_thread != -1) // already started
return 1;
return -1;
}
- timerval.it_interval.tv_sec = TIMER_INTERVAL_SEC;
- timerval.it_interval.tv_usec = TIMER_INTERVAL_USEC;
- timerval.it_value.tv_sec = TIMER_INTERVAL_SEC;
- timerval.it_value.tv_usec = TIMER_INTERVAL_USEC;
+ timerval.it_interval.tv_sec = sec;
+ timerval.it_interval.tv_usec = usec;
+ timerval.it_value.tv_sec = sec;
+ timerval.it_value.tv_usec = usec;
setitimer(ITIMER_REAL, &timerval, NULL);
return 0;