| 1 |
Index: package/src/ca/utils/ca_oprofile_controller.cpp
|
| 2 |
===================================================================
|
| 3 |
--- package/src/ca/utils/ca_oprofile_controller.cpp
|
| 4 |
+++ package/src/ca/utils/ca_oprofile_controller.cpp
|
| 5 |
@@ -44,6 +44,9 @@
|
| 6 |
static int sigkill = 0;
|
| 7 |
static int rmlock = 0;
|
| 8 |
static int reset = 0;
|
| 9 |
+static int load = 0;
|
| 10 |
+static int unload = 0;
|
| 11 |
+static char* devConfig = NULL;
|
| 12 |
|
| 13 |
enum {
|
| 14 |
OPT_START = 1,
|
| 15 |
@@ -51,19 +54,25 @@
|
| 16 |
OPT_KILL,
|
| 17 |
OPT_RMLOCK,
|
| 18 |
OPT_RESET,
|
| 19 |
+ OPT_LOAD,
|
| 20 |
+ OPT_UNLOAD,
|
| 21 |
+ OPT_DEVCONFIG,
|
| 22 |
OPT_VERSION,
|
| 23 |
OPT_HELP
|
| 24 |
};
|
| 25 |
|
| 26 |
static struct poptOption options[] = {
|
| 27 |
-{ "start" , 's', POPT_ARG_STRING, &start, OPT_START , "", NULL },
|
| 28 |
-{ "term" , 't', POPT_ARG_NONE, &sigterm, OPT_TERM , "", NULL },
|
| 29 |
-{ "kill" , 'k', POPT_ARG_NONE, &sigkill, OPT_KILL , "", NULL },
|
| 30 |
-{ "rmlock" , 'r', POPT_ARG_NONE, &rmlock , OPT_RMLOCK, "", NULL },
|
| 31 |
-{ "reset" , 'e', POPT_ARG_NONE, &reset, OPT_RESET , "", NULL },
|
| 32 |
-{ "version" , 'v', POPT_ARG_NONE, NULL, OPT_VERSION , "", NULL },
|
| 33 |
-{ "help" , 'h', POPT_ARG_NONE, NULL, OPT_HELP , "", NULL },
|
| 34 |
-{ NULL, 0, 0, NULL, 0, NULL, NULL },
|
| 35 |
+{ "start" , 's', POPT_ARG_STRING, &start, OPT_START , "", NULL },
|
| 36 |
+{ "term" , 't', POPT_ARG_NONE, &sigterm, OPT_TERM , "", NULL },
|
| 37 |
+{ "kill" , 'k', POPT_ARG_NONE, &sigkill, OPT_KILL , "", NULL },
|
| 38 |
+{ "rmlock" , 'r', POPT_ARG_NONE, &rmlock , OPT_RMLOCK, "", NULL },
|
| 39 |
+{ "reset" , 'e', POPT_ARG_NONE, &reset , OPT_RESET , "", NULL },
|
| 40 |
+{ "load-drv" , 'l', POPT_ARG_NONE, &load , OPT_LOAD , "", NULL },
|
| 41 |
+{ "unload-drv" , 'u', POPT_ARG_NONE, &unload , OPT_UNLOAD, "", NULL },
|
| 42 |
+{ "dev-config" , 'd', POPT_ARG_STRING, &devConfig, OPT_DEVCONFIG , "", NULL },
|
| 43 |
+{ "version" , 'v', POPT_ARG_NONE, NULL, OPT_VERSION , "", NULL },
|
| 44 |
+{ "help" , 'h', POPT_ARG_NONE, NULL, OPT_HELP , "", NULL },
|
| 45 |
+{ NULL , 0, 0, NULL, 0, NULL, NULL },
|
| 46 |
};
|
| 47 |
|
| 48 |
void show_version()
|
| 49 |
@@ -87,6 +96,10 @@
|
| 50 |
" -k|--kill Send SIGKILL to Oprofile daemon.\n"
|
| 51 |
" -r|--rmlock Remove Oprofile lock file (/var/lib/oprofile/samples/oprofiled.log).\n"
|
| 52 |
" -e|--reset Delete Oprofile sample files in /var/lib/oprofile/samples/current.\n"
|
| 53 |
+ " -l|--load-drv Load OProfile driver.\n"
|
| 54 |
+ " -u|--unload-drv Unload OProfile driver.\n"
|
| 55 |
+ " -d|--dev_config=<file>:<value>\n"
|
| 56 |
+ " Configure OProfile /dev/oprofile/<file> device file.\n"
|
| 57 |
" -v|--version Show version number.\n"
|
| 58 |
" -h|--help Show this message.\n"
|
| 59 |
"\n"
|
| 60 |
@@ -118,6 +131,9 @@
|
| 61 |
case OPT_KILL:
|
| 62 |
case OPT_RMLOCK:
|
| 63 |
case OPT_RESET:
|
| 64 |
+ case OPT_LOAD:
|
| 65 |
+ case OPT_UNLOAD:
|
| 66 |
+ case OPT_DEVCONFIG:
|
| 67 |
break;
|
| 68 |
case OPT_HELP:
|
| 69 |
show_usage();
|
| 70 |
@@ -179,6 +195,11 @@
|
| 71 |
return system("rm -rf /var/lib/oprofile/samples/current/*");
|
| 72 |
}
|
| 73 |
|
| 74 |
+int remove_var_lib_oprofile_samples_ca_oprofile_cg()
|
| 75 |
+{
|
| 76 |
+ return system("rm -rf /var/lib/oprofile/samples/ca_oprofile.cg");
|
| 77 |
+}
|
| 78 |
+
|
| 79 |
int remove_var_lib_oprofile_jitdump_star()
|
| 80 |
{
|
| 81 |
return system("rm -rf /var/lib/oprofile/jitdump/*");
|
| 82 |
@@ -341,16 +362,67 @@
|
| 83 |
return ret;
|
| 84 |
}
|
| 85 |
|
| 86 |
+int device_config(const char * filePath, const char * val, int size)
|
| 87 |
+{
|
| 88 |
+ int ret = -1;
|
| 89 |
+ FILE * file = NULL;
|
| 90 |
+ string devFile = ("/dev/oprofile/");
|
| 91 |
+
|
| 92 |
+ if (!filePath || !val || !size)
|
| 93 |
+ return ret;
|
| 94 |
+
|
| 95 |
+ devFile += filePath;
|
| 96 |
+
|
| 97 |
+ file = fopen(devFile.c_str(), "w" );
|
| 98 |
+ if (!file) {
|
| 99 |
+ perror(devFile.c_str());
|
| 100 |
+ return ret;
|
| 101 |
+ }
|
| 102 |
+
|
| 103 |
+ ret = fwrite(val, 1, size, file);
|
| 104 |
+
|
| 105 |
+ fclose(file);
|
| 106 |
+
|
| 107 |
+ return ret;
|
| 108 |
+}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+int device_config()
|
| 112 |
+{
|
| 113 |
+ // Parse input
|
| 114 |
+ string str(devConfig);
|
| 115 |
+
|
| 116 |
+ int found = str.find_first_of(":");
|
| 117 |
+
|
| 118 |
+ if (!found)
|
| 119 |
+ return -1;
|
| 120 |
+
|
| 121 |
+ string path = str.substr(0, found);
|
| 122 |
+ string val = str.substr(found+1, string::npos);
|
| 123 |
+
|
| 124 |
+ return device_config(path.c_str(), val.c_str(), val.size());
|
| 125 |
+
|
| 126 |
+}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
int main(int argc, char const * argv[])
|
| 130 |
{
|
| 131 |
int ret = 1;
|
| 132 |
|
| 133 |
// Check if root user
|
| 134 |
- if(0 != getuid()){
|
| 135 |
- fprintf(stderr,"ca_oprofile_controller: Error, must be root.\n");
|
| 136 |
- goto out;
|
| 137 |
- }
|
| 138 |
+ if(0 == getuid())
|
| 139 |
+ goto permissionOk;
|
| 140 |
|
| 141 |
+ /*
|
| 142 |
+ *NOTE:
|
| 143 |
+ * In sudo approach, we check if this is a root user.
|
| 144 |
+ * Only root can run this.
|
| 145 |
+ */
|
| 146 |
+ fprintf(stderr,"ca_oprofile_controller: Error, must be root.\n");
|
| 147 |
+ goto out;
|
| 148 |
+
|
| 149 |
+permissionOk:
|
| 150 |
+
|
| 151 |
// Parse options
|
| 152 |
if (0 != (ret = do_options(argc, argv))) {
|
| 153 |
fprintf(stderr,"ca_oprofile_controller: Error, parsing option.\n");
|
| 154 |
@@ -367,10 +439,12 @@
|
| 155 |
// Handle Reset
|
| 156 |
if(reset) {
|
| 157 |
if( remove_var_lib_oprofile_samples_current_star() == 0
|
| 158 |
+ && remove_var_lib_oprofile_samples_ca_oprofile_cg() == 0
|
| 159 |
&& remove_var_lib_oprofile_samples_oprofiled_log() == 0
|
| 160 |
&& remove_var_lib_oprofile_jitdump_star() == 0
|
| 161 |
- && remove_var_lib_oprofile_jit_star() == 0
|
| 162 |
- && remove_var_lib_oprofile_Java_star() == 0
|
| 163 |
+ // TODO: [Suravee] Clean out this directory when no jitted process running
|
| 164 |
+ //&& remove_var_lib_oprofile_jit_star() == 0
|
| 165 |
+ //&& remove_var_lib_oprofile_Java_star() == 0
|
| 166 |
&& mkdir_var_lib_oprofile_samples_current() == 0
|
| 167 |
&& mkdir_var_lib_oprofile_jitdump() == 0
|
| 168 |
&& mkdir_var_lib_oprofile_jit() == 0
|
| 169 |
@@ -387,6 +461,31 @@
|
| 170 |
goto out;
|
| 171 |
}
|
| 172 |
|
| 173 |
+ // Handle driver load
|
| 174 |
+ if(load) {
|
| 175 |
+ string cmd(OP_BINDIR);
|
| 176 |
+ cmd += "/opcontrol --init 2> /dev/null > /dev/null";
|
| 177 |
+ ret = system(cmd.c_str());
|
| 178 |
+ goto out;
|
| 179 |
+ }
|
| 180 |
+
|
| 181 |
+ // Handle driver unload
|
| 182 |
+ if(unload) {
|
| 183 |
+ string cmd(OP_BINDIR);
|
| 184 |
+ cmd += "/opcontrol --deinit 2> /dev/null > /dev/null";
|
| 185 |
+ ret = system(cmd.c_str());
|
| 186 |
+ goto out;
|
| 187 |
+ }
|
| 188 |
+
|
| 189 |
+ // Handle device file configuration
|
| 190 |
+ if (devConfig) {
|
| 191 |
+ if((ret = device_config()) <= 0)
|
| 192 |
+ fprintf(stderr,"ca_oprofile_controller: Error, Cannot configure /dev/oprofile.\n");
|
| 193 |
+ else
|
| 194 |
+ ret = 0;
|
| 195 |
+ goto out;
|
| 196 |
+ }
|
| 197 |
+
|
| 198 |
// Sending SIGTERM or SIGKILL
|
| 199 |
ret = send_signal();
|
| 200 |
out:
|
| 201 |
Index: package/src/ca/gui/helperAPI.h
|
| 202 |
===================================================================
|
| 203 |
--- package/src/ca/gui/helperAPI.h
|
| 204 |
+++ package/src/ca/gui/helperAPI.h
|
| 205 |
@@ -0,0 +1,49 @@
|
| 206 |
+/*
|
| 207 |
+// CodeAnalyst for Open Source
|
| 208 |
+// Copyright 2002 . 2009 Advanced Micro Devices, Inc.
|
| 209 |
+// You may redistribute this program and/or modify this program under the terms
|
| 210 |
+// of the GNU General Public License as published by the Free Software
|
| 211 |
+// Foundation; either version 2 of the License, or (at your option) any later
|
| 212 |
+// version.
|
| 213 |
+//
|
| 214 |
+// This program is distributed WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
|
| 215 |
+// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 216 |
+// GNU General Public License for more details.
|
| 217 |
+//
|
| 218 |
+// You should have received a copy of the GNU General Public License along with
|
| 219 |
+// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
| 220 |
+// Place, Suite 330, Boston, MA 02111-1307 USA.
|
| 221 |
+*/
|
| 222 |
+
|
| 223 |
+#ifndef _HELPERAPI_H_
|
| 224 |
+#define _HELPERAPI_H_
|
| 225 |
+
|
| 226 |
+#include <qdir.h>
|
| 227 |
+
|
| 228 |
+extern bool folderRemove (const QDir & _d);
|
| 229 |
+
|
| 230 |
+extern void untar_packed_file(QString * packed_path, QString * temp_dir );
|
| 231 |
+
|
| 232 |
+extern unsigned int rename_files(QString * temp_dir,
|
| 233 |
+ QString * op_sample_path,
|
| 234 |
+ QString * cpuinfo_path,
|
| 235 |
+ QString * dispatched_ops_path);
|
| 236 |
+
|
| 237 |
+extern int getBitness(const char * path);
|
| 238 |
+
|
| 239 |
+extern int ca_exec_command(QStringList & args,
|
| 240 |
+ QString & stdOut,
|
| 241 |
+ QString & stdErr,
|
| 242 |
+ int & status,
|
| 243 |
+ bool isBlock = true);
|
| 244 |
+
|
| 245 |
+extern int ca_exec_sudo_command(QStringList & args,
|
| 246 |
+ QString & stdOut,
|
| 247 |
+ QString & stdErr,
|
| 248 |
+ int & status,
|
| 249 |
+ bool isBlock = true);
|
| 250 |
+
|
| 251 |
+extern bool cssConversion(QString cgOutput);
|
| 252 |
+
|
| 253 |
+#endif //_HELPERAPI_H_
|
| 254 |
+
|
| 255 |
Index: package/src/ca/gui/Makefile.am
|
| 256 |
===================================================================
|
| 257 |
--- package/src/ca/gui/Makefile.am
|
| 258 |
+++ package/src/ca/gui/Makefile.am
|
| 259 |
@@ -134,7 +134,8 @@
|
| 260 |
EventMaskEncoding.cpp \
|
| 261 |
CpuAffinityDlg.cpp \
|
| 262 |
ProcessFilterDlg.cpp \
|
| 263 |
- NewDiffSessionDlg.cpp
|
| 264 |
+ NewDiffSessionDlg.cpp \
|
| 265 |
+ helperAPI.cpp
|
| 266 |
|
| 267 |
|
| 268 |
CodeAnalyst_generated_headers= iAboutDlg.h \
|
| 269 |
Index: package/src/ca/gui/application.cpp
|
| 270 |
===================================================================
|
| 271 |
--- package/src/ca/gui/application.cpp
|
| 272 |
+++ package/src/ca/gui/application.cpp
|
| 273 |
@@ -48,6 +48,7 @@
|
| 274 |
#include "catranslate_gui_display.h"
|
| 275 |
#include "opxmldata_handler.h"
|
| 276 |
#include "config.h"
|
| 277 |
+#include "helperAPI.h"
|
| 278 |
|
| 279 |
#define _CODEANALYST_ICONS_
|
| 280 |
#include "xpm.h"
|
| 281 |
@@ -757,8 +758,8 @@
|
| 282 |
+ "This user does not have sufficient permission to run a profile.\n\n"
|
| 283 |
+ "Please make sure :\n"
|
| 284 |
+ " - You are root or a member of \"amdca\" group.\n"
|
| 285 |
- + " - amdca group has the permission to sudo \n\n"
|
| 286 |
- + " "+ CA_SBIN_DIR + "/ca_oprofile_controller\n\n"
|
| 287 |
+ + " - amdca group has the permission to run\n\n"
|
| 288 |
+ + " sudo " + CA_SBIN_DIR + "/ca_oprofile_controller\n\n"
|
| 289 |
+ "Please use \"ca_user_manager\" to manage CodeAnalyst users.";
|
| 290 |
QMessageBox::critical(this, "CodeAnalyst Error", errMsg);
|
| 291 |
return;
|
| 292 |
@@ -767,14 +768,15 @@
|
| 293 |
/* 2. Check to make sure that CodeAnalyst service is setup and ready.
|
| 294 |
* otherwise, we will try to start it.
|
| 295 |
*/
|
| 296 |
- if (!m_opIf.codeanalyst_service_status() && !m_opIf.codeanalyst_service_start())
|
| 297 |
+ if (!m_opIf.checkOprofileDriverStatus() && !m_opIf.loadOprofileDriver())
|
| 298 |
{
|
| 299 |
QMessageBox::critical (this, "Error starting profile",
|
| 300 |
- "Checking CodeAnalyst service (/etc/init.d/codeanalyst status)\n"
|
| 301 |
- "returns failure, and an attempt to start CodeAnalyst service\n"
|
| 302 |
- "(/etc/init.d/codeanalyst start) also failed.\n."
|
| 303 |
+ "Checking OProfile driver (/dev/oprofile) returns failure\n"
|
| 304 |
+ " and an attempt to load the driver also failed.\n."
|
| 305 |
"CodeAnalyst will not be able to run profile.\n\n."
|
| 306 |
- "Please make sure to start the service as root.\n."
|
| 307 |
+ "Please make sure :\n"
|
| 308 |
+ " - The user is a member of group amdca\n."
|
| 309 |
+ " - OProfle driver is installed and can be started properly\n."
|
| 310 |
);
|
| 311 |
return;
|
| 312 |
}
|
| 313 |
@@ -896,21 +898,21 @@
|
| 314 |
// check if driver is ok
|
| 315 |
if (!m_opIf.checkMuxSupportInDriver()
|
| 316 |
|| m_opIf.getNumEventCounters() == MAX_EVENTNUM) {
|
| 317 |
- QMessageBox::warning(NULL, "CodeAnalyst Warning",QString("Warning:\n\n") +
|
| 318 |
- + "Current CodeAnalyst Kernel Module does not support event multiplexing.\n"
|
| 319 |
- + "CodeAnalyst will start profile only with events in the first group.\n\n"
|
| 320 |
- + "Please update the CodeAnalyst Kernel Module in order to profile more than "
|
| 321 |
- + "one event group.");
|
| 322 |
+ QMessageBox::warning(this, "CodeAnalyst Warning",QString("Warning:\n\n") +
|
| 323 |
+ + "Current CodeAnalyst Kernel Module does not support event multiplexing.\n"
|
| 324 |
+ + "CodeAnalyst will start profile only with events in the first group.\n\n"
|
| 325 |
+ + "Please update the CodeAnalyst Kernel Module in order to profile more than "
|
| 326 |
+ + "one event group.");
|
| 327 |
static_cast <EBP_OPTIONS *>(m_pSession)->countEventGroups = 1;
|
| 328 |
}
|
| 329 |
|
| 330 |
// check if daemon is ok
|
| 331 |
if (!m_opIf.checkMuxSupportInDaemon()) {
|
| 332 |
- QMessageBox::warning(NULL, "CodeAnalyst Warning",QString("Warning:\n\n") +
|
| 333 |
- + "Current OProfile daemon does not support event multiplexing.\n"
|
| 334 |
- + "CodeAnalyst will start profile only with events in the first group.\n\n"
|
| 335 |
- + "Please use CodeAnalyst provided OProfile in order to profile more than "
|
| 336 |
- + "one event group.");
|
| 337 |
+ QMessageBox::warning(this, "CodeAnalyst Warning",QString("Warning:\n\n") +
|
| 338 |
+ + "Current OProfile daemon does not support event multiplexing.\n"
|
| 339 |
+ + "CodeAnalyst will start profile only with events in the first group.\n\n"
|
| 340 |
+ + "Please use CodeAnalyst provided OProfile in order to profile more than "
|
| 341 |
+ + "one event group.");
|
| 342 |
static_cast <EBP_OPTIONS *>(m_pSession)->countEventGroups = 1;
|
| 343 |
}
|
| 344 |
}
|
| 345 |
@@ -2748,13 +2750,21 @@
|
| 346 |
|
| 347 |
if (oie_rt == OIE_OK) {
|
| 348 |
if(m_pSession->Trigger == EVENT_TRIGGER)
|
| 349 |
- oie_rt = m_opIf.do_start_daemon (novmlinux, vmlinux_dir,
|
| 350 |
- buffer_size, watershed_size, cpu_buf_size,
|
| 351 |
- ca_active_profiling, pEventSession->msMpxInterval);
|
| 352 |
+ oie_rt = m_opIf.do_start_daemon (novmlinux,
|
| 353 |
+ vmlinux_dir,
|
| 354 |
+ buffer_size,
|
| 355 |
+ watershed_size,
|
| 356 |
+ cpu_buf_size,
|
| 357 |
+ ca_active_profiling,
|
| 358 |
+ pEventSession->msMpxInterval);
|
| 359 |
else
|
| 360 |
- oie_rt = m_opIf.do_start_daemon (novmlinux, vmlinux_dir,
|
| 361 |
- buffer_size, watershed_size, cpu_buf_size,
|
| 362 |
- ca_active_profiling,0);
|
| 363 |
+ oie_rt = m_opIf.do_start_daemon (novmlinux,
|
| 364 |
+ vmlinux_dir,
|
| 365 |
+ buffer_size,
|
| 366 |
+ watershed_size,
|
| 367 |
+ cpu_buf_size,
|
| 368 |
+ ca_active_profiling,
|
| 369 |
+ 0);
|
| 370 |
}
|
| 371 |
|
| 372 |
|
| 373 |
Index: package/src/ca/gui/helperAPI.cpp
|
| 374 |
===================================================================
|
| 375 |
--- package/src/ca/gui/helperAPI.cpp
|
| 376 |
+++ package/src/ca/gui/helperAPI.cpp
|
| 377 |
@@ -0,0 +1,372 @@
|
| 378 |
+/*
|
| 379 |
+// CodeAnalyst for Open Source
|
| 380 |
+// Copyright 2002 . 2009 Advanced Micro Devices, Inc.
|
| 381 |
+// You may redistribute this program and/or modify this program under the terms
|
| 382 |
+// of the GNU General Public License as published by the Free Software
|
| 383 |
+// Foundation; either version 2 of the License, or (at your option) any later
|
| 384 |
+// version.
|
| 385 |
+//
|
| 386 |
+// This program is distributed WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
|
| 387 |
+// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 388 |
+// GNU General Public License for more details.
|
| 389 |
+//
|
| 390 |
+// You should have received a copy of the GNU General Public License along with
|
| 391 |
+// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
| 392 |
+// Place, Suite 330, Boston, MA 02111-1307 USA.
|
| 393 |
+*/
|
| 394 |
+
|
| 395 |
+#include "config.h"
|
| 396 |
+#include "helperAPI.h"
|
| 397 |
+
|
| 398 |
+#include <stdlib.h>
|
| 399 |
+#include <qstring.h>
|
| 400 |
+#include <qstringlist.h>
|
| 401 |
+#include <qfileinfo.h>
|
| 402 |
+#include <qdir.h>
|
| 403 |
+#include <qprocess.h>
|
| 404 |
+#include <qtimer.h>
|
| 405 |
+#include <qmessagebox.h>
|
| 406 |
+
|
| 407 |
+#include <elf.h>
|
| 408 |
+
|
| 409 |
+#define PACKED_DIR_NAME "capacked"
|
| 410 |
+
|
| 411 |
+/*
|
| 412 |
+* folderRemove:
|
| 413 |
+* Recursive contents within the folder and the folder
|
| 414 |
+* itself.
|
| 415 |
+* It is the same code from oprofile_interface.cpp
|
| 416 |
+*/
|
| 417 |
+bool folderRemove (const QDir & _d)
|
| 418 |
+{
|
| 419 |
+ QDir d = _d;
|
| 420 |
+
|
| 421 |
+ QStringList entries = d.entryList(QDir::All|QDir::Hidden);
|
| 422 |
+ QStringList::Iterator it = entries.begin();
|
| 423 |
+
|
| 424 |
+ for (; it != entries.end (); ++it)
|
| 425 |
+ {
|
| 426 |
+ if (*it == "." || *it == "..")
|
| 427 |
+ continue;
|
| 428 |
+ QFileInfo info (d, *it);
|
| 429 |
+ if (info.isDir ())
|
| 430 |
+ {
|
| 431 |
+ if (!folderRemove (QDir (info.filePath ())))
|
| 432 |
+ return false;
|
| 433 |
+ }
|
| 434 |
+ else
|
| 435 |
+ {
|
| 436 |
+ d.remove (info.filePath ());
|
| 437 |
+ }
|
| 438 |
+ }
|
| 439 |
+
|
| 440 |
+ QString name = d.dirName ();
|
| 441 |
+
|
| 442 |
+ if (!d.cdUp ())
|
| 443 |
+ return false;
|
| 444 |
+
|
| 445 |
+ d.rmdir (name);
|
| 446 |
+ return true;
|
| 447 |
+}
|
| 448 |
+
|
| 449 |
+void untar_packed_file(QString * packed_path, QString * temp_dir )
|
| 450 |
+{
|
| 451 |
+ QDir dir;
|
| 452 |
+ if (!QFile::exists(*packed_path)) {
|
| 453 |
+ return;
|
| 454 |
+ }
|
| 455 |
+
|
| 456 |
+ srand(time(0));
|
| 457 |
+ temp_dir->sprintf("/tmp/CA%ld/", random());
|
| 458 |
+ dir.mkdir(*temp_dir);
|
| 459 |
+
|
| 460 |
+ // todo hook the output to the dialog
|
| 461 |
+ // todo use a randomly generated directory
|
| 462 |
+ QString command = "tar zxf " + *packed_path + " -C " + *temp_dir;
|
| 463 |
+ system(command.data());
|
| 464 |
+}
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+void mkdir_p(QString & absPath)
|
| 468 |
+{
|
| 469 |
+ QStringList list = QStringList::split("/", absPath);
|
| 470 |
+ QStringList::iterator it = list.begin();
|
| 471 |
+
|
| 472 |
+ QString dir_path = "/";
|
| 473 |
+ for (; it != list.end(); ++it) {
|
| 474 |
+ dir_path = dir_path + (*it) + "/";
|
| 475 |
+ QDir dir(dir_path);
|
| 476 |
+
|
| 477 |
+ if (!dir.exists()) {
|
| 478 |
+ if (!dir.mkdir(dir_path))
|
| 479 |
+ qDebug("mkdir failed");
|
| 480 |
+ }
|
| 481 |
+
|
| 482 |
+ }
|
| 483 |
+}
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+void copy_files(QFileInfo & info, QString & dest_dir)
|
| 487 |
+{
|
| 488 |
+ // Copy any non-directory file to the new path
|
| 489 |
+ QDir dir = QDir(info.filePath());
|
| 490 |
+ dir.setFilter(QDir::Files);
|
| 491 |
+ QStringList file_list = dir.entryList();
|
| 492 |
+ QStringList::Iterator itFile = file_list.begin();
|
| 493 |
+ for (; itFile != file_list.end(); ++itFile) {
|
| 494 |
+ QFileInfo info(dir, (*itFile));
|
| 495 |
+
|
| 496 |
+ QString command = "cp \"" + info.absFilePath() + "\" \"" + dest_dir + "\"";
|
| 497 |
+
|
| 498 |
+ system(command.data());
|
| 499 |
+ }
|
| 500 |
+}
|
| 501 |
+
|
| 502 |
+
|
| 503 |
+void recurse_dirs(QString & parent_dir_str,
|
| 504 |
+ QString & dest_dir_str,
|
| 505 |
+ QString & subs_dir,
|
| 506 |
+ bool prev_dep)
|
| 507 |
+{
|
| 508 |
+ QDir current_dir = QDir(parent_dir_str);
|
| 509 |
+
|
| 510 |
+ current_dir.setFilter(QDir::Dirs);
|
| 511 |
+ QStringList old_dir_list = current_dir.entryList();
|
| 512 |
+ QStringList::Iterator it = old_dir_list.begin();
|
| 513 |
+
|
| 514 |
+ for (; it != old_dir_list.end(); ++it) {
|
| 515 |
+ bool dep = false;
|
| 516 |
+ if (*it == "." || *it == "..")
|
| 517 |
+ continue;
|
| 518 |
+
|
| 519 |
+ QFileInfo info(current_dir, *it);
|
| 520 |
+ QString path = info.filePath();
|
| 521 |
+
|
| 522 |
+ QString temp = dest_dir_str + "/" + *it;
|
| 523 |
+
|
| 524 |
+ if ((*it).contains("{dep}"))
|
| 525 |
+ dep = true;
|
| 526 |
+ else if (((*it).contains("{root}") || (*it).contains("{kern}"))
|
| 527 |
+ && prev_dep == true)
|
| 528 |
+ temp += subs_dir;
|
| 529 |
+ else
|
| 530 |
+ dep =false;
|
| 531 |
+
|
| 532 |
+ mkdir_p(temp);
|
| 533 |
+ copy_files(info, temp);
|
| 534 |
+ recurse_dirs(path, temp, subs_dir, dep);
|
| 535 |
+ }
|
| 536 |
+}
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+unsigned int rename_files(QString * temp_dir,
|
| 540 |
+ QString * op_sample_path,
|
| 541 |
+ QString * cpuinfo_path,
|
| 542 |
+ QString * dispatched_ops_path)
|
| 543 |
+{
|
| 544 |
+ //todo capacked is hard coded right now.
|
| 545 |
+ QString top_dir = *temp_dir;
|
| 546 |
+ QString op_current_dir_str = *temp_dir + PACKED_DIR_NAME + "/current";
|
| 547 |
+ QDir op_current_dir(op_current_dir_str );
|
| 548 |
+
|
| 549 |
+ // Move the sample file to correct directory structure
|
| 550 |
+ // For example: sample files in
|
| 551 |
+ // /tmp/CA_982/capacked/current/{root}/bin/basename
|
| 552 |
+ // needs to be moved to
|
| 553 |
+ // /tmp/CA_982/capacked/current/{root}/tmp/CA_982/capacked/binary/bin/basename/
|
| 554 |
+
|
| 555 |
+ // Since we will be recursing capacked/current directory tree tree
|
| 556 |
+ // the new structure is crecated at at capacked/new_current
|
| 557 |
+ QString dest_topdir_str = top_dir + "capacked/samples/current/{root}"
|
| 558 |
+ + *temp_dir + "capacked/binary";
|
| 559 |
+
|
| 560 |
+ *op_sample_path = top_dir + "capacked/samples/current/";
|
| 561 |
+
|
| 562 |
+ *cpuinfo_path = top_dir + "capacked/cpuinfo";
|
| 563 |
+
|
| 564 |
+ *dispatched_ops_path = top_dir + "capacked/cainfo/dispatched_ops";
|
| 565 |
+
|
| 566 |
+ QString subs_dir = *temp_dir + "capacked/binary/{root}/";
|
| 567 |
+
|
| 568 |
+ // Loop through the original directory structure and create
|
| 569 |
+ // correspondent directory under the new directory tree structure
|
| 570 |
+ recurse_dirs(op_current_dir_str, dest_topdir_str, subs_dir, false);
|
| 571 |
+
|
| 572 |
+ return 0;
|
| 573 |
+}
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+int getBitness(const char * path)
|
| 577 |
+{
|
| 578 |
+ char elf_header[EI_NIDENT];
|
| 579 |
+ FILE *fp;
|
| 580 |
+ int ret = -1;
|
| 581 |
+
|
| 582 |
+ if (!path)
|
| 583 |
+ goto out;
|
| 584 |
+
|
| 585 |
+ fp = fopen(path, "r");
|
| 586 |
+
|
| 587 |
+ /**
|
| 588 |
+ * The reporting libraries does not return correct path
|
| 589 |
+ * of kernel module under 2.6.1. This function will not
|
| 590 |
+ * under this situation.
|
| 591 |
+ */
|
| 592 |
+ if (NULL == fp)
|
| 593 |
+ goto out;
|
| 594 |
+
|
| 595 |
+ fread(&elf_header, 16, 1, fp);
|
| 596 |
+ if (ferror(fp)) {
|
| 597 |
+ fclose (fp);
|
| 598 |
+ goto out;
|
| 599 |
+ }
|
| 600 |
+ fclose(fp);
|
| 601 |
+
|
| 602 |
+ if (0 != strncmp(elf_header, ELFMAG, SELFMAG))
|
| 603 |
+ goto out;
|
| 604 |
+
|
| 605 |
+ switch (elf_header[EI_CLASS]) {
|
| 606 |
+ case ELFCLASS32:
|
| 607 |
+ ret = 32;
|
| 608 |
+ break;
|
| 609 |
+ case ELFCLASS64:
|
| 610 |
+ ret = 64;
|
| 611 |
+ break;
|
| 612 |
+ }
|
| 613 |
+out:
|
| 614 |
+ return ret;
|
| 615 |
+
|
| 616 |
+}
|
| 617 |
+
|
| 618 |
+
|
| 619 |
+int ca_exec_command (QStringList & args,
|
| 620 |
+ QString & stdOut,
|
| 621 |
+ QString & stdErr,
|
| 622 |
+ int & status,
|
| 623 |
+ bool isBlock)
|
| 624 |
+{
|
| 625 |
+ int rt = -1;
|
| 626 |
+
|
| 627 |
+ QProcess * proc = new QProcess();
|
| 628 |
+ if (!proc)
|
| 629 |
+ goto out;
|
| 630 |
+
|
| 631 |
+ proc->setArguments (args);
|
| 632 |
+
|
| 633 |
+// fprintf(stderr,"ca_exec_command = %s\n", proc->arguments().join(" ").ascii());
|
| 634 |
+
|
| 635 |
+ if(!proc->start ()) {
|
| 636 |
+ goto out;
|
| 637 |
+ }
|
| 638 |
+
|
| 639 |
+ // Since the process being launch are non-blocking daemon,
|
| 640 |
+ // sysctl, mknod, etc, just wait for the command to finish
|
| 641 |
+ while (proc->isRunning ()) {
|
| 642 |
+ if (!isBlock)
|
| 643 |
+ break;
|
| 644 |
+ }
|
| 645 |
+
|
| 646 |
+ // Get exit status/stdOut/stdErr
|
| 647 |
+ status = proc->exitStatus();
|
| 648 |
+ stdErr = QString(proc->readStderr());
|
| 649 |
+ stdOut = QString(proc->readStdout());
|
| 650 |
+
|
| 651 |
+ // Check for normal Exit
|
| 652 |
+ if (proc->normalExit () && status == 0)
|
| 653 |
+ rt = 0;
|
| 654 |
+out:
|
| 655 |
+ if (proc)
|
| 656 |
+ delete proc;
|
| 657 |
+ return rt;
|
| 658 |
+}
|
| 659 |
+
|
| 660 |
+
|
| 661 |
+int ca_exec_sudo_command (QStringList & args,
|
| 662 |
+ QString & stdOut,
|
| 663 |
+ QString & stdErr,
|
| 664 |
+ int & status,
|
| 665 |
+ bool isBlock)
|
| 666 |
+{
|
| 667 |
+ int rt = -1;
|
| 668 |
+
|
| 669 |
+ QStringList cmd;
|
| 670 |
+ cmd.append("sudo");
|
| 671 |
+ cmd.append("-S");
|
| 672 |
+ cmd += args;
|
| 673 |
+
|
| 674 |
+ QProcess * proc = new QProcess();
|
| 675 |
+ if (!proc)
|
| 676 |
+ goto out;
|
| 677 |
+
|
| 678 |
+ proc->setArguments (cmd);
|
| 679 |
+
|
| 680 |
+// fprintf(stderr,"ca_exec_command = %s\n", proc->arguments().join(" ").ascii());
|
| 681 |
+
|
| 682 |
+ if(!proc->start ()) {
|
| 683 |
+ goto out;
|
| 684 |
+ }
|
| 685 |
+
|
| 686 |
+ /* NOTE:
|
| 687 |
+ * sudo, should never output to the stderr.
|
| 688 |
+ * We consider this error and will just exit out.
|
| 689 |
+ */
|
| 690 |
+ while (proc->isRunning ()) {
|
| 691 |
+ if (!isBlock)
|
| 692 |
+ break;
|
| 693 |
+ if (proc->readStderr().size() != 0){
|
| 694 |
+ proc->tryTerminate();
|
| 695 |
+ QTimer::singleShot(1000, proc, SLOT(kill()));
|
| 696 |
+ break;
|
| 697 |
+ }
|
| 698 |
+ }
|
| 699 |
+
|
| 700 |
+ // Get exit status/stdOut/stdErr
|
| 701 |
+ status = proc->exitStatus();
|
| 702 |
+ stdErr = QString(proc->readStderr());
|
| 703 |
+ stdOut = QString(proc->readStdout());
|
| 704 |
+
|
| 705 |
+ // Check for normal Exit
|
| 706 |
+ if (proc->normalExit () && status == 0)
|
| 707 |
+ rt = 0;
|
| 708 |
+out:
|
| 709 |
+ if (proc)
|
| 710 |
+ delete proc;
|
| 711 |
+ return rt;
|
| 712 |
+}
|
| 713 |
+
|
| 714 |
+
|
| 715 |
+bool cssConversion(QString cgOutput)
|
| 716 |
+{
|
| 717 |
+ // TODO: [Suravee] Currently we directly call cgreport
|
| 718 |
+ // since we want cgprocessing code to be a standalone utility.
|
| 719 |
+ // and can eliminate the build dependency. We might want
|
| 720 |
+ // to integrate this into the gui in the future.
|
| 721 |
+ QString cgreportPath = QString(CA_BIN_DIR) + "/cgreport";
|
| 722 |
+ QString cgFile = QString("/var/lib/oprofile/samples/ca_oprofile.cg");
|
| 723 |
+
|
| 724 |
+ if (!QFile::exists (cgreportPath)) {
|
| 725 |
+ QMessageBox::critical(NULL, "CSS Conversion Error",
|
| 726 |
+ QString("CodeAnalyst could not process call-stack sampling data.\n") +
|
| 727 |
+ "Please install " + cgreportPath + ".\n");
|
| 728 |
+ return false;
|
| 729 |
+ }
|
| 730 |
+
|
| 731 |
+ if (!QFile::exists (cgFile)) {
|
| 732 |
+ QMessageBox::critical(NULL, "CSS Conversion Error",
|
| 733 |
+ cgFile + " not found.\n" +
|
| 734 |
+ "Please rerun the profile with proper CSS setting.\n");
|
| 735 |
+ return false;
|
| 736 |
+ }
|
| 737 |
+
|
| 738 |
+ QStringList cmd;
|
| 739 |
+ cmd.append(cgreportPath);
|
| 740 |
+ cmd.append(QString("-i"));
|
| 741 |
+ cmd.append(cgFile);
|
| 742 |
+ cmd.append(QString("-o"));
|
| 743 |
+ cmd.append(cgOutput + "/callgrind.out");
|
| 744 |
+
|
| 745 |
+ QString stdOut, stdErr;
|
| 746 |
+ int status;
|
| 747 |
+ return (ca_exec_command(cmd, stdOut, stdErr, status) == 0
|
| 748 |
+ && status == 0);
|
| 749 |
+}
|
| 750 |
Index: package/src/ca/gui/oprofile_interface.h
|
| 751 |
===================================================================
|
| 752 |
--- package/src/ca/gui/oprofile_interface.h
|
| 753 |
+++ package/src/ca/gui/oprofile_interface.h
|
| 754 |
@@ -63,23 +63,27 @@ class oprofile_interface:QObject {
|
| 755 |
public:
|
| 756 |
|
| 757 |
oprofile_interface ();
|
| 758 |
- int do_start_daemon (bool novmlinux,
|
| 759 |
- QString & vmlinux_dir,
|
| 760 |
- unsigned int buffer_size,
|
| 761 |
- unsigned int buffer_watershed_size,
|
| 762 |
- unsigned int cpu_buf_size,
|
| 763 |
- profiling_types active_profiling,
|
| 764 |
- unsigned int multiplex_interval);
|
| 765 |
+ int do_start_daemon (bool vmlinux,
|
| 766 |
+ QString & vmlinux_dir,
|
| 767 |
+ unsigned int buffer_size,
|
| 768 |
+ unsigned int buffer_watershed_size,
|
| 769 |
+ unsigned int cpu_buf_size,
|
| 770 |
+ profiling_types active_profiling,
|
| 771 |
+ unsigned int multiplex_interval);
|
| 772 |
|
| 773 |
void set_op_events (op_event_property * properties);
|
| 774 |
void set_op_ibs ( op_ibs_property * properties);
|
| 775 |
+ bool set_css(unsigned int cssDepth,
|
| 776 |
+ unsigned int cssInterval,
|
| 777 |
+ unsigned int cssTgid,
|
| 778 |
+ unsigned int cssBitness);
|
| 779 |
void do_dump ();
|
| 780 |
void do_kill_daemon ();
|
| 781 |
void do_pause_daemon ();
|
| 782 |
void do_resume_daemon();
|
| 783 |
|
| 784 |
|
| 785 |
- QString get_kernel_range ();
|
| 786 |
+ QString get_kernel_range (QString vmlinux_dir);
|
| 787 |
QString & get_std_err();
|
| 788 |
|
| 789 |
bool do_setup ();
|
| 790 |
@@ -90,9 +94,9 @@ public:
|
| 791 |
|
| 792 |
bool havePermissionToProfile();
|
| 793 |
|
| 794 |
- bool codeanalyst_service_start();
|
| 795 |
+ bool loadOprofileDriver();
|
| 796 |
|
| 797 |
- bool codeanalyst_service_status();
|
| 798 |
+ bool checkOprofileDriverStatus();
|
| 799 |
|
| 800 |
int checkIbsSupportInDaemon();
|
| 801 |
|
| 802 |
@@ -104,16 +108,32 @@ public:
|
| 803 |
|
| 804 |
bool checkMuxSupportInDriver();
|
| 805 |
|
| 806 |
+ bool checkCssSupportInDaemon();
|
| 807 |
+
|
| 808 |
+ bool checkCssSupportInDriver();
|
| 809 |
+
|
| 810 |
+ static bool set_param (QString field,
|
| 811 |
+ unsigned long int value,
|
| 812 |
+ QString & stdOut,
|
| 813 |
+ QString & stdErr,
|
| 814 |
+ int & status);
|
| 815 |
+
|
| 816 |
private:
|
| 817 |
+
|
| 818 |
+ bool set_param (QString field, unsigned long int value);
|
| 819 |
+
|
| 820 |
+ int exec_command (QStringList & args);
|
| 821 |
+
|
| 822 |
+ int exec_sudo_command (QStringList & args);
|
| 823 |
+
|
| 824 |
int do_reset();
|
| 825 |
|
| 826 |
- int help_start_daemon (bool novmlinux,
|
| 827 |
+ int help_start_daemon (bool vmlinux,
|
| 828 |
QString & vmlinux_dir,
|
| 829 |
profiling_types active_profiling);
|
| 830 |
|
| 831 |
bool get_daemon_pid(unsigned int &pid);
|
| 832 |
|
| 833 |
- int exec_command (QStringList & args);
|
| 834 |
|
| 835 |
bool do_sysctl_setup (unsigned int buffer_size,
|
| 836 |
unsigned int buffer_watershed_size,
|
| 837 |
@@ -125,24 +145,25 @@ private:
|
| 838 |
|
| 839 |
void generate_op_event_arg (QString & arg);
|
| 840 |
|
| 841 |
- void do_stop ();
|
| 842 |
+ bool set_ctr_param (int event, QString field, unsigned long int value);
|
| 843 |
|
| 844 |
- bool set_ctr_param (int event, QString field, unsigned long long int value);
|
| 845 |
-
|
| 846 |
- bool set_param (QString field, int value);
|
| 847 |
|
| 848 |
bool do_ebs_setup(profiling_types active_profiling);
|
| 849 |
|
| 850 |
bool do_ibs_setup(profiling_types active_profiling);
|
| 851 |
|
| 852 |
QString simplifyPath(QString path);
|
| 853 |
+
|
| 854 |
+ bool is_driver_loaded();
|
| 855 |
+
|
| 856 |
+ bool is_oprofilefs_mounted();
|
| 857 |
|
| 858 |
private:
|
| 859 |
- QProcess * m_proc;
|
| 860 |
op_ibs_property * m_pIbsProperties;
|
| 861 |
op_event_property m_EventProperties[MAX_EVENTNUM_MULTIPLEXING];
|
| 862 |
- QString m_StdErr;
|
| 863 |
- QString m_StdOut;
|
| 864 |
+ QString m_stderr;
|
| 865 |
+ QString m_stdout;
|
| 866 |
+ int m_status;
|
| 867 |
int m_numEventCountersAvailable;
|
| 868 |
bool m_isDaemonStarted;
|
| 869 |
unsigned int m_daemon_pid;
|
| 870 |
Index: package/src/ca/gui/oprofile_interface.cpp
|
| 871 |
===================================================================
|
| 872 |
--- package/src/ca/gui/oprofile_interface.cpp
|
| 873 |
+++ package/src/ca/gui/oprofile_interface.cpp
|
| 874 |
@@ -40,9 +40,9 @@
|
| 875 |
#include "application.h"
|
| 876 |
#include "config.h"
|
| 877 |
#include "oprofile_interface.h"
|
| 878 |
-//#include "op_config.h"
|
| 879 |
#include "atuneoptions.h"
|
| 880 |
#include "symbolengine.h"
|
| 881 |
+#include "helperAPI.h"
|
| 882 |
|
| 883 |
|
| 884 |
namespace OPROFILE_INTERFACE {
|
| 885 |
@@ -66,7 +66,6 @@ using namespace std;
|
| 886 |
// Constructor
|
| 887 |
oprofile_interface::oprofile_interface ()
|
| 888 |
{
|
| 889 |
- m_proc=NULL;
|
| 890 |
m_pIbsProperties = NULL;
|
| 891 |
m_isDaemonStarted = false;
|
| 892 |
m_daemon_pid = 0;
|
| 893 |
@@ -82,11 +81,10 @@ oprofile_interface::oprofile_interface (
|
| 894 |
int oprofile_interface::do_reset ()
|
| 895 |
{
|
| 896 |
QStringList cmd;
|
| 897 |
- cmd.append("sudo");
|
| 898 |
cmd.append(CA_OPROFILE_CONTROLLER);
|
| 899 |
cmd.append("--reset");
|
| 900 |
|
| 901 |
- return exec_command (cmd);
|
| 902 |
+ return exec_sudo_command (cmd);
|
| 903 |
}
|
| 904 |
|
| 905 |
|
| 906 |
@@ -127,94 +125,15 @@ void oprofile_interface::set_op_ibs ( op
|
| 907 |
}
|
| 908 |
|
| 909 |
|
| 910 |
-bool oprofile_interface::codeanalyst_service_start()
|
| 911 |
+int oprofile_interface::exec_sudo_command (QStringList & args)
|
| 912 |
{
|
| 913 |
- bool ret = false;
|
| 914 |
-
|
| 915 |
- QStringList cmd;
|
| 916 |
-
|
| 917 |
- cmd.append ("/etc/init.d/codeanalyst");
|
| 918 |
- cmd.append ("start");
|
| 919 |
-
|
| 920 |
- if(exec_command (cmd) == 0)
|
| 921 |
- ret = true;
|
| 922 |
- else
|
| 923 |
- ret = false;
|
| 924 |
-
|
| 925 |
- return ret;
|
| 926 |
-}
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-bool oprofile_interface::codeanalyst_service_status()
|
| 930 |
-{
|
| 931 |
- bool ret = false;
|
| 932 |
-
|
| 933 |
- QStringList cmd;
|
| 934 |
-
|
| 935 |
- cmd.append ("/etc/init.d/codeanalyst");
|
| 936 |
- cmd.append ("status");
|
| 937 |
-
|
| 938 |
- if(exec_command (cmd) == 0)
|
| 939 |
- ret = true;
|
| 940 |
- else
|
| 941 |
- ret = false;
|
| 942 |
-
|
| 943 |
- return ret;
|
| 944 |
+ return ca_exec_sudo_command(args, m_stdout, m_stderr, m_status);
|
| 945 |
}
|
| 946 |
|
| 947 |
|
| 948 |
int oprofile_interface::exec_command (QStringList & args)
|
| 949 |
{
|
| 950 |
- if (NULL != m_proc) {
|
| 951 |
- delete m_proc;
|
| 952 |
- m_proc = NULL;
|
| 953 |
- }
|
| 954 |
-
|
| 955 |
- m_proc = new QProcess();
|
| 956 |
- m_proc->setArguments (args);
|
| 957 |
-
|
| 958 |
-#if 0 // DEBUG
|
| 959 |
- fprintf(stderr,"Command = ");
|
| 960 |
- QStringList list = m_proc->arguments();
|
| 961 |
- QStringList::Iterator it = list.begin();
|
| 962 |
- while( it != list.end() ) {
|
| 963 |
- fprintf(stderr,"%s ", (*it).data() );
|
| 964 |
- ++it;
|
| 965 |
- }
|
| 966 |
- fprintf(stderr,"\n");
|
| 967 |
-#endif
|
| 968 |
-
|
| 969 |
- int rt = 0;
|
| 970 |
-
|
| 971 |
- if(!m_proc->start ()) {
|
| 972 |
- rt = -1;
|
| 973 |
- }
|
| 974 |
-
|
| 975 |
- // Since the process being launch are non-blocking daemon,
|
| 976 |
- // sysctl, mknod, etc, just wait for the command to finish
|
| 977 |
- while (rt == 0 && m_proc->isRunning ()) {
|
| 978 |
- }
|
| 979 |
-
|
| 980 |
- // Check for normal Exit
|
| 981 |
- if (!m_proc->normalExit ()) {
|
| 982 |
- rt = -1;
|
| 983 |
- }
|
| 984 |
-
|
| 985 |
- // Check for exit status
|
| 986 |
- if (m_proc->exitStatus() != 0) {
|
| 987 |
- rt = -1;
|
| 988 |
- }
|
| 989 |
-
|
| 990 |
- m_StdErr = QString(m_proc->readStderr());
|
| 991 |
- m_StdOut = QString(m_proc->readStdout());
|
| 992 |
-
|
| 993 |
- // Daemon will exit with normal status,
|
| 994 |
- // event if it failed to start. Must check
|
| 995 |
- // stderr to know the correct exit status.
|
| 996 |
- //if (0 != m_StdErr.length())
|
| 997 |
- // rt = -1;
|
| 998 |
-
|
| 999 |
- return rt;
|
| 1000 |
+ return ca_exec_command(args, m_stdout, m_stderr, m_status);
|
| 1001 |
}
|
| 1002 |
|
| 1003 |
|
| 1004 |
@@ -239,7 +158,7 @@ void oprofile_interface::generate_op_eve
|
| 1005 |
}
|
| 1006 |
|
| 1007 |
|
| 1008 |
-int oprofile_interface::help_start_daemon (bool novmlinux,
|
| 1009 |
+int oprofile_interface::help_start_daemon (bool noVmlinux,
|
| 1010 |
QString & vmlinux_dir,
|
| 1011 |
profiling_types active_profiling)
|
| 1012 |
{
|
| 1013 |
@@ -250,7 +169,6 @@ int oprofile_interface::help_start_daemo
|
| 1014 |
m_isDaemonStarted = false;
|
| 1015 |
|
| 1016 |
QStringList cmd_OPROFILED_START;
|
| 1017 |
- cmd_OPROFILED_START.append ("sudo");
|
| 1018 |
cmd_OPROFILED_START.append (CA_OPROFILE_CONTROLLER);
|
| 1019 |
|
| 1020 |
// BEGIN CMD LINE APPENDING.
|
| 1021 |
@@ -267,8 +185,8 @@ int oprofile_interface::help_start_daemo
|
| 1022 |
//********************************************************
|
| 1023 |
// VMLINUX stuff
|
| 1024 |
buf = "";
|
| 1025 |
- if (!novmlinux) {
|
| 1026 |
- kernel_range = get_kernel_range ();
|
| 1027 |
+ if (!noVmlinux && QFile::exists(vmlinux_dir)) {
|
| 1028 |
+ kernel_range = get_kernel_range (vmlinux_dir);
|
| 1029 |
buf = "--vmlinux=";
|
| 1030 |
buf += vmlinux_dir + " ";
|
| 1031 |
opd_args.append (buf);
|
| 1032 |
@@ -367,11 +285,7 @@ int oprofile_interface::help_start_daemo
|
| 1033 |
cmd_pidof.append(PIDOF);
|
| 1034 |
cmd_pidof.append("oprofiled");
|
| 1035 |
|
| 1036 |
- if (exec_command(cmd_pidof) == 0)
|
| 1037 |
- {
|
| 1038 |
- // m_StdErr = QString("CodeAnalyst detected a running oprofile daemon ")
|
| 1039 |
- // + "(oprofiled)\n.Please make sure oprofile daemon is not "
|
| 1040 |
- // + "currently running.\n";
|
| 1041 |
+ if (exec_command(cmd_pidof) == 0) {
|
| 1042 |
rt = -OIE_DAEMON_RUNNING;
|
| 1043 |
}
|
| 1044 |
|
| 1045 |
@@ -385,16 +299,16 @@ int oprofile_interface::help_start_daemo
|
| 1046 |
if( !lockFile.exists ())
|
| 1047 |
{
|
| 1048 |
// Starting oprofile daemon
|
| 1049 |
- if(exec_command (cmd_OPROFILED_START) == 0)
|
| 1050 |
+ if(exec_sudo_command (cmd_OPROFILED_START) == 0)
|
| 1051 |
{
|
| 1052 |
#if _DEBUG_
|
| 1053 |
- fprintf(stderr,"help_start_daemon: stdout = %s\n",m_StdOut.ascii());
|
| 1054 |
- fprintf(stderr,"help_start_daemon: stderr = %s\n",m_StdErr.ascii());
|
| 1055 |
+ fprintf(stderr,"help_start_daemon: stdout = %s\n",m_stdout.ascii());
|
| 1056 |
+ fprintf(stderr,"help_start_daemon: stderr = %s\n",m_stderr.ascii());
|
| 1057 |
#endif
|
| 1058 |
|
| 1059 |
m_isDaemonStarted = true;
|
| 1060 |
|
| 1061 |
- m_StdErr = QString("Failed to check ") + LOCK_FILE
|
| 1062 |
+ m_stderr = QString("Failed to check ") + LOCK_FILE
|
| 1063 |
+ "\n\nPlease make sure oprofile daemon is not "
|
| 1064 |
+ "currently running.\n";
|
| 1065 |
rt = -OIE_DAEMON_NOTSTART;
|
| 1066 |
@@ -407,7 +321,7 @@ int oprofile_interface::help_start_daemo
|
| 1067 |
{
|
| 1068 |
if (QFile::exists (LOCK_FILE))
|
| 1069 |
{
|
| 1070 |
- m_StdErr = "";
|
| 1071 |
+ m_stderr = "";
|
| 1072 |
rt = OIE_OK;
|
| 1073 |
break;
|
| 1074 |
} else {
|
| 1075 |
@@ -421,15 +335,15 @@ int oprofile_interface::help_start_daemo
|
| 1076 |
|
| 1077 |
}else{
|
| 1078 |
#if _DEBUG_
|
| 1079 |
- fprintf(stderr,"help_start_daemon: stdout = %s\n",m_StdOut.ascii());
|
| 1080 |
- fprintf(stderr,"help_start_daemon: stderr = %s\n",m_StdErr.ascii());
|
| 1081 |
+ fprintf(stderr,"help_start_daemon: stdout = %s\n",m_stdout.ascii());
|
| 1082 |
+ fprintf(stderr,"help_start_daemon: stderr = %s\n",m_stderr.ascii());
|
| 1083 |
fprintf(stderr,"help_start_daemon: Failed to start daemon\n");
|
| 1084 |
#endif
|
| 1085 |
- m_StdErr = "Failed to start daemon.\n";
|
| 1086 |
+ m_stderr = "Failed to start daemon.\n";
|
| 1087 |
rt = -OIE_DAEMON_NOTSTART;
|
| 1088 |
}
|
| 1089 |
}else{
|
| 1090 |
- m_StdErr = QString("File /var/lib/oprofile/lock exists.\n")
|
| 1091 |
+ m_stderr = QString("File /var/lib/oprofile/lock exists.\n")
|
| 1092 |
+ "Please remove this file and make sure oprofile "
|
| 1093 |
+ "daemon is not currently running.\n";
|
| 1094 |
rt = -OIE_LOCK_EXIST;
|
| 1095 |
@@ -444,31 +358,30 @@ int oprofile_interface::help_start_daemo
|
| 1096 |
*/
|
| 1097 |
if (rt == OIE_OK)
|
| 1098 |
{
|
| 1099 |
- char wrBuf = '1';
|
| 1100 |
- char rdBuf = '\0';
|
| 1101 |
- QString enable = MOUNT + "/enable";
|
| 1102 |
- QFile enable_file(enable);
|
| 1103 |
- if (enable_file.open (IO_ReadWrite)) {
|
| 1104 |
- // Write 1 to enable
|
| 1105 |
- if (-1 == enable_file.writeBlock (&wrBuf, sizeof (wrBuf))) {
|
| 1106 |
- do_kill_daemon();
|
| 1107 |
- m_StdErr = QString("Oprofile Driver error.\n")
|
| 1108 |
- + "There was a problem writing to the /dev/oprofile/enable.";
|
| 1109 |
- rt = -OIE_DRV;
|
| 1110 |
- }
|
| 1111 |
+ // Write 1 to enable
|
| 1112 |
+ if (!set_param (QString("enable"),1)) {
|
| 1113 |
+ do_kill_daemon();
|
| 1114 |
+ m_stderr = QString("Oprofile Driver error.\n")
|
| 1115 |
+ + "There was a problem writing to the /dev/oprofile/enable.";
|
| 1116 |
+ rt = -OIE_DRV;
|
| 1117 |
+ }
|
| 1118 |
+
|
| 1119 |
+ QFile enable_file(MOUNT + "/enable");
|
| 1120 |
+ if (enable_file.open (IO_ReadOnly)) {
|
| 1121 |
+ char rdBuf = '\0';
|
| 1122 |
// Read to confirm
|
| 1123 |
if ( rt == OIE_OK
|
| 1124 |
&& -1 == enable_file.readBlock (&rdBuf, sizeof (rdBuf))) {
|
| 1125 |
do_kill_daemon();
|
| 1126 |
- m_StdErr = QString("Oprofile Driver error.\n")
|
| 1127 |
+ m_stderr = QString("Oprofile Driver error.\n")
|
| 1128 |
+ "There was a problem reading from the /dev/oprofile/enable.";
|
| 1129 |
rt = -OIE_DRV;
|
| 1130 |
}
|
| 1131 |
// Compare Read to Write
|
| 1132 |
if( rt == OIE_OK
|
| 1133 |
- && rdBuf != wrBuf ) {
|
| 1134 |
+ && rdBuf != '1' ) {
|
| 1135 |
do_kill_daemon();
|
| 1136 |
- m_StdErr = QString("Oprofile Driver error.\n")
|
| 1137 |
+ m_stderr = QString("Oprofile Driver error.\n")
|
| 1138 |
+ "There was a problem enabling driver.";
|
| 1139 |
rt = -OIE_DRV;
|
| 1140 |
}
|
| 1141 |
@@ -476,7 +389,7 @@ int oprofile_interface::help_start_daemo
|
| 1142 |
enable_file.close ();
|
| 1143 |
}else{
|
| 1144 |
do_kill_daemon();
|
| 1145 |
- m_StdErr = QString("Oprofile Driver error.\n")
|
| 1146 |
+ m_stderr = QString("Oprofile Driver error.\n")
|
| 1147 |
+ "There was a problem openning /dev/oprofile/enable.";
|
| 1148 |
rt = -OIE_DRV;
|
| 1149 |
}
|
| 1150 |
@@ -510,19 +423,19 @@ bool oprofile_interface::get_daemon_pid(
|
| 1151 |
|
| 1152 |
QString & oprofile_interface::get_std_err()
|
| 1153 |
{
|
| 1154 |
- return m_StdErr;
|
| 1155 |
+ return m_stderr;
|
| 1156 |
}
|
| 1157 |
|
| 1158 |
|
| 1159 |
-int oprofile_interface::do_start_daemon (bool novmlinux,
|
| 1160 |
- QString & vmlinux_dir,
|
| 1161 |
- unsigned int buffer_size,
|
| 1162 |
- unsigned int watershed_size,
|
| 1163 |
- unsigned int cpu_buf_size,
|
| 1164 |
- profiling_types active_profiling,
|
| 1165 |
- unsigned int multiplex_interval)
|
| 1166 |
+int oprofile_interface::do_start_daemon (bool noVmlinux,
|
| 1167 |
+ QString & vmlinux_dir,
|
| 1168 |
+ unsigned int buffer_size,
|
| 1169 |
+ unsigned int watershed_size,
|
| 1170 |
+ unsigned int cpu_buf_size,
|
| 1171 |
+ profiling_types active_profiling,
|
| 1172 |
+ unsigned int multiplex_interval)
|
| 1173 |
{
|
| 1174 |
- m_StdErr = "";
|
| 1175 |
+ m_stderr = "";
|
| 1176 |
|
| 1177 |
if(!do_sysctl_setup(buffer_size,
|
| 1178 |
watershed_size,
|
| 1179 |
@@ -531,68 +444,53 @@ int oprofile_interface::do_start_daemon
|
| 1180 |
multiplex_interval))
|
| 1181 |
return -OIE_ERR;
|
| 1182 |
|
| 1183 |
- return help_start_daemon(novmlinux, vmlinux_dir, active_profiling);
|
| 1184 |
+ return help_start_daemon(noVmlinux, vmlinux_dir, active_profiling);
|
| 1185 |
}
|
| 1186 |
|
| 1187 |
|
| 1188 |
-bool oprofile_interface::set_ctr_param (int event, QString field, unsigned long long int value)
|
| 1189 |
+bool oprofile_interface::set_ctr_param (int event, QString field, unsigned long int value)
|
| 1190 |
{
|
| 1191 |
- bool rt = true;
|
| 1192 |
- QStringList args;
|
| 1193 |
- QString buf;
|
| 1194 |
- QString st_event;
|
| 1195 |
- QString st_value;
|
| 1196 |
+ QString fname = QString::number(event) + "/" + field;
|
| 1197 |
|
| 1198 |
+ return set_param(fname, value);
|
| 1199 |
+}
|
| 1200 |
|
| 1201 |
- st_event.setNum (event);
|
| 1202 |
- st_value.setNum (value);
|
| 1203 |
-
|
| 1204 |
- QString fname;
|
| 1205 |
- fname.sprintf ("%s/%s/%s", MOUNT.data (), st_event.data (), field.data ());
|
| 1206 |
- QFile param_file (fname);;
|
| 1207 |
|
| 1208 |
- if (param_file.open (IO_WriteOnly))
|
| 1209 |
- {
|
| 1210 |
- if (-1 == param_file.writeBlock (st_value.data (), st_value.length ()))
|
| 1211 |
- {
|
| 1212 |
- m_StdErr = QString("Cannot write to ") + fname + ".\n";
|
| 1213 |
- rt = false;
|
| 1214 |
- }
|
| 1215 |
- param_file.close ();
|
| 1216 |
- } else {
|
| 1217 |
- m_StdErr = QString("Cannot open ") + fname + ".\n";
|
| 1218 |
- rt = false;
|
| 1219 |
- }
|
| 1220 |
- return rt;
|
| 1221 |
+bool oprofile_interface::set_param (QString field, unsigned long int value)
|
| 1222 |
+{
|
| 1223 |
+ return set_param(field, value, m_stdout, m_stderr, m_status);
|
| 1224 |
+
|
| 1225 |
}
|
| 1226 |
|
| 1227 |
-bool oprofile_interface::set_param (QString field, int value)
|
| 1228 |
-{
|
| 1229 |
- bool rt = true;
|
| 1230 |
- QStringList args;
|
| 1231 |
- QString buf;
|
| 1232 |
- QString st_value;
|
| 1233 |
|
| 1234 |
- st_value.setNum (value);
|
| 1235 |
+bool oprofile_interface::set_param (QString field,
|
| 1236 |
+ unsigned long int value,
|
| 1237 |
+ QString & stdOut,
|
| 1238 |
+ QString & stdErr,
|
| 1239 |
+ int & status)
|
| 1240 |
+{
|
| 1241 |
+ QStringList cmd_DEVCONFIG;
|
| 1242 |
+ cmd_DEVCONFIG.append (CA_OPROFILE_CONTROLLER);
|
| 1243 |
+
|
| 1244 |
+ // BEGIN CMD LINE APPENDING.
|
| 1245 |
+ QString args;
|
| 1246 |
+
|
| 1247 |
+ // Note: this is a string, we don't need the " for arguments.
|
| 1248 |
+ args.append ("--dev-config=");
|
| 1249 |
+ args.append (field);
|
| 1250 |
+ args.append (":");
|
| 1251 |
+ args.append (QString::number(value));
|
| 1252 |
|
| 1253 |
- QString fname;
|
| 1254 |
- fname.sprintf ("%s/%s", MOUNT.data (), field.data ());
|
| 1255 |
- QFile param_file (fname);;
|
| 1256 |
+ cmd_DEVCONFIG.append(args);
|
| 1257 |
|
| 1258 |
- if (param_file.open (IO_WriteOnly))
|
| 1259 |
+ if(ca_exec_sudo_command (cmd_DEVCONFIG, stdOut, stdErr, status) == -1)
|
| 1260 |
{
|
| 1261 |
- if (-1 == param_file.writeBlock (st_value.data (), st_value.length ()))
|
| 1262 |
- {
|
| 1263 |
- m_StdErr = QString("Cannot write to ") + fname + ".\n";
|
| 1264 |
- rt = false;
|
| 1265 |
- }
|
| 1266 |
- param_file.close ();
|
| 1267 |
-
|
| 1268 |
- }else {
|
| 1269 |
- m_StdErr = QString("Cannot open ") + fname + ".\n";
|
| 1270 |
- rt = false;
|
| 1271 |
- }
|
| 1272 |
- return rt;
|
| 1273 |
+ QMessageBox::critical(NULL, "Oprofile Device File Error",
|
| 1274 |
+ QString("Error:\nca_oprofile_controller could not configure file\n")
|
| 1275 |
+ + "/dev/oprofile/" + field + " with value " + QString::number(value));
|
| 1276 |
+ return false;
|
| 1277 |
+ }
|
| 1278 |
+ return true;
|
| 1279 |
}
|
| 1280 |
|
| 1281 |
|
| 1282 |
@@ -665,19 +563,19 @@ bool oprofile_interface::do_sysctl_setup
|
| 1283 |
|
| 1284 |
/* Setting /dev/oprofile/buffer_size */
|
| 1285 |
if(buffer_size != 0 && !set_param("buffer_size", buffer_size)) {
|
| 1286 |
- m_StdErr = QString("Cannot configure /dev/oprofile/buffer_size.\n");
|
| 1287 |
+ m_stderr = QString("Cannot configure /dev/oprofile/buffer_size.\n");
|
| 1288 |
goto errOut;
|
| 1289 |
}
|
| 1290 |
|
| 1291 |
/* Setting /dev/oprofile/buffer_watershed */
|
| 1292 |
if(buffer_size != 0 && !set_param("buffer_watershed", watershed_size)) {
|
| 1293 |
- m_StdErr = QString("Cannot configure /dev/oprofile/buffer_watershed.\n");
|
| 1294 |
+ m_stderr = QString("Cannot configure /dev/oprofile/buffer_watershed.\n");
|
| 1295 |
goto errOut;
|
| 1296 |
}
|
| 1297 |
|
| 1298 |
/* Setting /dev/oprofile/cpu_buffer_size */
|
| 1299 |
if(cpu_buf_size != 0 && !set_param ("cpu_buffer_size", cpu_buf_size)) {
|
| 1300 |
- m_StdErr = QString("Cannot configure /dev/oprofile/cpu_buffer_size.\n");
|
| 1301 |
+ m_stderr = QString("Cannot configure /dev/oprofile/cpu_buffer_size.\n");
|
| 1302 |
goto errOut;
|
| 1303 |
}
|
| 1304 |
|
| 1305 |
@@ -698,7 +596,7 @@ bool oprofile_interface::do_sysctl_setup
|
| 1306 |
} else {
|
| 1307 |
if(!set_param (MUX_DRIVER_INTERFACE, multiplex_interval)) {
|
| 1308 |
/* This usually means driver error */
|
| 1309 |
- m_StdErr = QString("Cannot configure /dev/oprofile/")
|
| 1310 |
+ m_stderr = QString("Cannot configure /dev/oprofile/")
|
| 1311 |
+ MUX_DRIVER_INTERFACE +".\n";
|
| 1312 |
goto errOut;
|
| 1313 |
}
|
| 1314 |
@@ -710,31 +608,31 @@ bool oprofile_interface::do_sysctl_setup
|
| 1315 |
|
| 1316 |
/* Initialize all counters */
|
| 1317 |
for (int i = 0; i < m_numEventCountersAvailable; i++) {
|
| 1318 |
- m_StdErr = QString("Cannot clear /dev/oprofile/0,1,2,3...\n");
|
| 1319 |
+ m_stderr = QString("Cannot clear /dev/oprofile/0,1,2,3...\n");
|
| 1320 |
if(!set_ctr_param (i, QString ("enabled"), 0)) goto errOut;
|
| 1321 |
if(!set_ctr_param (i, QString ("event"), 0)) goto errOut;
|
| 1322 |
if(!set_ctr_param (i, QString ("count"), 0)) goto errOut;
|
| 1323 |
}
|
| 1324 |
|
| 1325 |
if (!do_ebs_setup(active_profiling)) {
|
| 1326 |
- m_StdErr = QString("Failed to setup driver for EBP.\n");
|
| 1327 |
+ m_stderr = QString("Failed to setup driver for EBP.\n");
|
| 1328 |
goto errOut;
|
| 1329 |
}
|
| 1330 |
|
| 1331 |
if (!do_ibs_setup(active_profiling)) {
|
| 1332 |
- m_StdErr = QString("Failed to setup driver for IBS.\n");
|
| 1333 |
+ m_stderr = QString("Failed to setup driver for IBS.\n");
|
| 1334 |
goto errOut;
|
| 1335 |
}
|
| 1336 |
|
| 1337 |
- m_StdErr = "";
|
| 1338 |
+ m_stderr = "";
|
| 1339 |
return rt;
|
| 1340 |
|
| 1341 |
errOut:
|
| 1342 |
- m_StdErr += QString("\nPlease also make sure that :\n")
|
| 1343 |
+ m_stderr += QString("\nPlease also make sure that :\n")
|
| 1344 |
+ " 1. /dev/oprofile/... exists.\n"
|
| 1345 |
+ " 2. User is in the \"amdca\" group.\n\n"
|
| 1346 |
+ "Otherwise, please do one of the followings:\n"
|
| 1347 |
- + " 1. Run \"/etc/init.d/codeanalyst start\" as root.\n"
|
| 1348 |
+ + " 1. Run \"opcontrol --init\" as root.\n"
|
| 1349 |
+ " 2. Or reboot the system.\n";
|
| 1350 |
rt = false;
|
| 1351 |
return rt;
|
| 1352 |
@@ -742,13 +640,12 @@ errOut:
|
| 1353 |
}
|
| 1354 |
|
| 1355 |
|
| 1356 |
-QString oprofile_interface::get_kernel_range ()
|
| 1357 |
+QString oprofile_interface::get_kernel_range (QString vmlinux_dir)
|
| 1358 |
{
|
| 1359 |
char buf[LONG_STR_MAX * 2 + 1];
|
| 1360 |
char buf2[LONG_STR_MAX];
|
| 1361 |
char buf3[LONG_STR_MAX];
|
| 1362 |
CATuneOptions ao;
|
| 1363 |
- QString vmlinux_dir = "";
|
| 1364 |
QString range = "";
|
| 1365 |
ObjDump objdump;
|
| 1366 |
SymbolEngine symengine;
|
| 1367 |
@@ -756,9 +653,7 @@ QString oprofile_interface::get_kernel_r
|
| 1368 |
bfd_size_type size = 0;
|
| 1369 |
bfd_vma str_addr;
|
| 1370 |
|
| 1371 |
- ao.getVmlinuxDir (vmlinux_dir);
|
| 1372 |
-
|
| 1373 |
- int symengineCode = symengine.open(vmlinux_dir.data ());
|
| 1374 |
+ int symengineCode = symengine.open(vmlinux_dir.ascii());
|
| 1375 |
|
| 1376 |
if ((SymbolEngine::OKAY == symengineCode) ||
|
| 1377 |
(SymbolEngine::NO_SYMBOLS == symengineCode) ||
|
| 1378 |
@@ -785,10 +680,6 @@ QString oprofile_interface::get_kernel_r
|
| 1379 |
*/
|
| 1380 |
void oprofile_interface::do_dump ()
|
| 1381 |
{
|
| 1382 |
- char buf = '1';
|
| 1383 |
- QString dump = MOUNT + "/dump";
|
| 1384 |
- QFile dump_file (dump);
|
| 1385 |
-
|
| 1386 |
QString complete_dump = "/var/lib/oprofile/complete_dump";
|
| 1387 |
QFileInfo complete_dump_info (complete_dump);
|
| 1388 |
QDateTime last_dump;
|
| 1389 |
@@ -807,13 +698,9 @@ void oprofile_interface::do_dump ()
|
| 1390 |
|
| 1391 |
//---------------------------
|
| 1392 |
// Write 1 to /dev/oprofile/dump
|
| 1393 |
- if ((! dump_file.open (IO_WriteOnly))
|
| 1394 |
- || (-1 == dump_file.writeBlock (&buf, sizeof (buf))))
|
| 1395 |
+ if (! set_param ("dump", 1))
|
| 1396 |
QMessageBox::critical(NULL, "Writing error", "There was a problem "
|
| 1397 |
"writing a block to the dump");
|
| 1398 |
-
|
| 1399 |
- dump_file.close ();
|
| 1400 |
-
|
| 1401 |
//---------------------------
|
| 1402 |
// Wait for complete_dump to be refresh.
|
| 1403 |
|
| 1404 |
@@ -836,31 +723,12 @@ void oprofile_interface::do_dump ()
|
| 1405 |
}
|
| 1406 |
|
| 1407 |
|
| 1408 |
-
|
| 1409 |
-void oprofile_interface::do_stop ()
|
| 1410 |
-{
|
| 1411 |
- QString command;
|
| 1412 |
-
|
| 1413 |
- command = "echo \"0\">" + MOUNT + "/enable";
|
| 1414 |
- system(command.data());
|
| 1415 |
-}
|
| 1416 |
-
|
| 1417 |
void oprofile_interface::do_resume_daemon()
|
| 1418 |
{
|
| 1419 |
/* NOTE:
|
| 1420 |
* To Resume, write 1 to /dev/oprofile/enable file
|
| 1421 |
*/
|
| 1422 |
- char buf = '1';
|
| 1423 |
- QString enable = MOUNT + "/enable";
|
| 1424 |
- QFile enable_file(enable);
|
| 1425 |
- if (enable_file.open (IO_WriteOnly)) {
|
| 1426 |
- if (-1 == enable_file.writeBlock (&buf, sizeof (buf))) {
|
| 1427 |
- QMessageBox::information (NULL, "Writing error", "There was a "
|
| 1428 |
- "problem writing a block to the "
|
| 1429 |
- "enable");
|
| 1430 |
- }
|
| 1431 |
- enable_file.close ();
|
| 1432 |
- }
|
| 1433 |
+ set_param("enable", 1);
|
| 1434 |
}
|
| 1435 |
|
| 1436 |
|
| 1437 |
@@ -870,36 +738,25 @@ void oprofile_interface::do_pause_daemon
|
| 1438 |
/* NOTE:
|
| 1439 |
* To Resume, write 0 to /dev/oprofile/enable file
|
| 1440 |
*/
|
| 1441 |
- char buf = '0';
|
| 1442 |
- QString enable = MOUNT + "/enable";
|
| 1443 |
- QFile enable_file(enable);
|
| 1444 |
- if (enable_file.open (IO_WriteOnly))
|
| 1445 |
- {
|
| 1446 |
- if (-1 == enable_file.writeBlock (&buf, sizeof (buf)))
|
| 1447 |
- {
|
| 1448 |
- QMessageBox::information (NULL, "Writing error", "There was a "
|
| 1449 |
- "problem writing a block to the "
|
| 1450 |
- "enable");
|
| 1451 |
- }
|
| 1452 |
- enable_file.close ();
|
| 1453 |
- }
|
| 1454 |
+ set_param("enable", 0);
|
| 1455 |
}
|
| 1456 |
|
| 1457 |
+
|
| 1458 |
bool oprofile_interface::remove_lock_file()
|
| 1459 |
{
|
| 1460 |
bool rt = false;
|
| 1461 |
|
| 1462 |
QStringList cmd_OPROFILE_RMLOCK;
|
| 1463 |
- cmd_OPROFILE_RMLOCK.append("sudo");
|
| 1464 |
cmd_OPROFILE_RMLOCK.append(CA_OPROFILE_CONTROLLER);
|
| 1465 |
cmd_OPROFILE_RMLOCK.append("--rmlock");
|
| 1466 |
- if (exec_command(cmd_OPROFILE_RMLOCK) == 0)
|
| 1467 |
+ if (exec_sudo_command(cmd_OPROFILE_RMLOCK) == 0)
|
| 1468 |
{
|
| 1469 |
rt = true;
|
| 1470 |
}
|
| 1471 |
return rt;
|
| 1472 |
}
|
| 1473 |
|
| 1474 |
+
|
| 1475 |
/* Note: The logic in this function should be similar to opcontrol script*/
|
| 1476 |
void oprofile_interface::do_kill_daemon ()
|
| 1477 |
{
|
| 1478 |
@@ -914,7 +771,7 @@ void oprofile_interface::do_kill_daemon
|
| 1479 |
if (exec_command(cmd_pidof) == 0)
|
| 1480 |
{
|
| 1481 |
isDaemonRunning = true;
|
| 1482 |
- daemonPid = m_StdOut.simplifyWhiteSpace();
|
| 1483 |
+ daemonPid = m_stdout.simplifyWhiteSpace();
|
| 1484 |
}
|
| 1485 |
|
| 1486 |
/* NOTE:
|
| 1487 |
@@ -965,7 +822,9 @@ void oprofile_interface::do_kill_daemon
|
| 1488 |
QString("Warning:\n") +
|
| 1489 |
"A different Oprofile daemon is running.\n" +
|
| 1490 |
"Profile result might be inaccurate.\n" +
|
| 1491 |
- "Please rerun the profile");
|
| 1492 |
+ "Please rerun the profile ("+
|
| 1493 |
+ QString::number(cur_daemon_pid)+","+
|
| 1494 |
+ QString::number(m_daemon_pid)+")");
|
| 1495 |
return;
|
| 1496 |
}
|
| 1497 |
|
| 1498 |
@@ -988,16 +847,14 @@ void oprofile_interface::do_kill_daemon
|
| 1499 |
do_pause_daemon();
|
| 1500 |
|
| 1501 |
QStringList cmd_OPROFILED_TERM;
|
| 1502 |
- cmd_OPROFILED_TERM.append("sudo");
|
| 1503 |
cmd_OPROFILED_TERM.append(CA_OPROFILE_CONTROLLER);
|
| 1504 |
cmd_OPROFILED_TERM.append("--term");
|
| 1505 |
|
| 1506 |
QStringList cmd_OPROFILED_KILL;
|
| 1507 |
- cmd_OPROFILED_KILL.append("sudo");
|
| 1508 |
cmd_OPROFILED_KILL.append(CA_OPROFILE_CONTROLLER);
|
| 1509 |
cmd_OPROFILED_KILL.append("--kill");
|
| 1510 |
|
| 1511 |
- if(exec_command (cmd_OPROFILED_TERM) == -1)
|
| 1512 |
+ if(exec_sudo_command (cmd_OPROFILED_TERM) == -1)
|
| 1513 |
{
|
| 1514 |
QMessageBox::warning(NULL, "Oprofile Daemon Warning",
|
| 1515 |
"Warning:\nca_oprofile_controller return error. "
|
| 1516 |
@@ -1018,10 +875,10 @@ void oprofile_interface::do_kill_daemon
|
| 1517 |
temp.tv_nsec = 0;
|
| 1518 |
while (exec_command(cmd_pidof) != -1) {
|
| 1519 |
if (0 == i) {
|
| 1520 |
- exec_command(cmd_OPROFILED_KILL);
|
| 1521 |
+ exec_sudo_command(cmd_OPROFILED_KILL);
|
| 1522 |
break;
|
| 1523 |
}
|
| 1524 |
- exec_command(cmd_OPROFILED_TERM);
|
| 1525 |
+ exec_sudo_command(cmd_OPROFILED_TERM);
|
| 1526 |
// fprintf(stderr,"DEBUG: Stopping Daemon count down %d\n",i);
|
| 1527 |
nanosleep (&temp, NULL);
|
| 1528 |
i--;
|
| 1529 |
@@ -1047,6 +904,7 @@ void oprofile_interface::customEvent (QC
|
| 1530 |
Q_UNUSED (pCustEvent);
|
| 1531 |
}
|
| 1532 |
|
| 1533 |
+
|
| 1534 |
QString oprofile_interface::simplifyPath(QString path)
|
| 1535 |
{
|
| 1536 |
QString ret = path;
|
| 1537 |
@@ -1055,84 +913,21 @@ QString oprofile_interface::simplifyPath
|
| 1538 |
return ret;
|
| 1539 |
}
|
| 1540 |
|
| 1541 |
+
|
| 1542 |
bool oprofile_interface::havePermissionToProfile()
|
| 1543 |
{
|
| 1544 |
- bool ret = false;
|
| 1545 |
- int count;
|
| 1546 |
-
|
| 1547 |
- // NOTE: We need to parse output of sudo -S -l
|
| 1548 |
- // for 3 different cases:
|
| 1549 |
- //
|
| 1550 |
- // Case root User:
|
| 1551 |
- // User root may run the following commands on this host:
|
| 1552 |
- // (ALL) ALL
|
| 1553 |
- //
|
| 1554 |
- // Case Good User:
|
| 1555 |
- // User suravee may run the following commands on this host:
|
| 1556 |
- // (root) NOPASSWD: /usr/sbin/ca_oprofile_controller
|
| 1557 |
- //
|
| 1558 |
- // Case Bad User:
|
| 1559 |
- // [sudo] password for suravee1:
|
| 1560 |
+ bool ret = true;
|
| 1561 |
|
| 1562 |
- QProcess proc;
|
| 1563 |
+ /* NOTE
|
| 1564 |
+ * We use ca_oprofile_controller --help
|
| 1565 |
+ * to check for permission to run profile.
|
| 1566 |
+ */
|
| 1567 |
QStringList cmd;
|
| 1568 |
- QString line_stdout;
|
| 1569 |
-
|
| 1570 |
- cmd.append ("sudo");
|
| 1571 |
- cmd.append ("-S");
|
| 1572 |
- cmd.append ("-l");
|
| 1573 |
- proc.setArguments (cmd);
|
| 1574 |
-
|
| 1575 |
- if(!proc.start ()) {
|
| 1576 |
- return ret;
|
| 1577 |
- }
|
| 1578 |
-
|
| 1579 |
- // Wait for the 1 sec for the stdout
|
| 1580 |
- count = 2;
|
| 1581 |
- timespec temp;
|
| 1582 |
- temp.tv_sec = 0;
|
| 1583 |
- temp.tv_nsec = FIVE_HUNDRED_MS;
|
| 1584 |
- while(proc.isRunning ()) {
|
| 1585 |
- count--;
|
| 1586 |
- nanosleep (&temp, NULL);
|
| 1587 |
- if(proc.canReadLineStdout())
|
| 1588 |
- break;
|
| 1589 |
- if(count == 0) {
|
| 1590 |
- // Write to stdin to stop
|
| 1591 |
- // process gracefully.
|
| 1592 |
- proc.writeToStdin("");
|
| 1593 |
- return ret;
|
| 1594 |
- }
|
| 1595 |
- }
|
| 1596 |
-
|
| 1597 |
- // Read first line of stdout
|
| 1598 |
- line_stdout = QString(proc.readLineStdout());
|
| 1599 |
-
|
| 1600 |
- // Handling bad case
|
| 1601 |
- if(!line_stdout.startsWith("User ")) {
|
| 1602 |
- proc.kill();
|
| 1603 |
- return ret;
|
| 1604 |
- }
|
| 1605 |
-
|
| 1606 |
- // Processing stdout
|
| 1607 |
- while( (line_stdout = proc.readLineStdout())
|
| 1608 |
- != QString::null )
|
| 1609 |
- {
|
| 1610 |
- // For root user
|
| 1611 |
- if(line_stdout.contains("(ALL) ALL")) {
|
| 1612 |
- proc.kill();
|
| 1613 |
- ret = true;
|
| 1614 |
- break;
|
| 1615 |
- }
|
| 1616 |
-
|
| 1617 |
- // For non-root user
|
| 1618 |
- QString tmp = simplifyPath(line_stdout.section(" ",-1));
|
| 1619 |
-
|
| 1620 |
- if(tmp == CA_OPROFILE_CONTROLLER) {
|
| 1621 |
- proc.kill();
|
| 1622 |
- ret = true;
|
| 1623 |
- break;
|
| 1624 |
- }
|
| 1625 |
+ cmd.append (CA_OPROFILE_CONTROLLER);
|
| 1626 |
+ cmd.append ("--help");
|
| 1627 |
+
|
| 1628 |
+ if(exec_sudo_command (cmd) == -1) {
|
| 1629 |
+ ret = false;
|
| 1630 |
}
|
| 1631 |
|
| 1632 |
return ret;
|
| 1633 |
@@ -1233,3 +1028,85 @@ bool oprofile_interface::checkMuxSupport
|
| 1634 |
QFile mux_ctrl(QString("/dev/oprofile/")+ MUX_DRIVER_INTERFACE);
|
| 1635 |
return ((mux_ctrl.exists())? true: false);
|
| 1636 |
}
|
| 1637 |
+
|
| 1638 |
+bool oprofile_interface::is_driver_loaded()
|
| 1639 |
+{
|
| 1640 |
+ QString command = QString("grep oprofile /proc/modules 2> /dev/null > /dev/null");
|
| 1641 |
+
|
| 1642 |
+ return ((system(command.ascii()) == 0)? true: false);
|
| 1643 |
+}
|
| 1644 |
+
|
| 1645 |
+
|
| 1646 |
+bool oprofile_interface::is_oprofilefs_mounted()
|
| 1647 |
+{
|
| 1648 |
+ QString command = QString("grep oprofilefs /etc/mtab 2> /dev/null > /dev/null");
|
| 1649 |
+
|
| 1650 |
+ return ((system(command.ascii()) == 0)? true: false);
|
| 1651 |
+
|
| 1652 |
+}
|
| 1653 |
+
|
| 1654 |
+
|
| 1655 |
+bool oprofile_interface::checkOprofileDriverStatus()
|
| 1656 |
+{
|
| 1657 |
+ bool ret = false;
|
| 1658 |
+
|
| 1659 |
+ // Check if driver is loaded
|
| 1660 |
+ ret = is_driver_loaded();
|
| 1661 |
+
|
| 1662 |
+ // Check if OProfile filesystem is mounted
|
| 1663 |
+ if (ret) ret = is_oprofilefs_mounted();
|
| 1664 |
+
|
| 1665 |
+ return ret;
|
| 1666 |
+}
|
| 1667 |
+
|
| 1668 |
+
|
| 1669 |
+bool oprofile_interface::loadOprofileDriver()
|
| 1670 |
+{
|
| 1671 |
+ bool ret = true;
|
| 1672 |
+ QStringList cmd_LOAD;
|
| 1673 |
+ cmd_LOAD.append (CA_OPROFILE_CONTROLLER);
|
| 1674 |
+ cmd_LOAD.append ("--load-drv");
|
| 1675 |
+
|
| 1676 |
+ if(exec_sudo_command (cmd_LOAD) == -1) {
|
| 1677 |
+ QMessageBox::critical(NULL, "Oprofile Error",
|
| 1678 |
+ "Error:\nca_oprofile_controller return error. "
|
| 1679 |
+ "Could not load OProfile driver.");
|
| 1680 |
+ ret = false;
|
| 1681 |
+ }
|
| 1682 |
+ return ret;
|
| 1683 |
+}
|
| 1684 |
+
|
| 1685 |
+
|
| 1686 |
+bool oprofile_interface::set_css(unsigned int cssDepth,
|
| 1687 |
+ unsigned int cssInterval,
|
| 1688 |
+ unsigned int cssTgid,
|
| 1689 |
+ unsigned int cssBitness)
|
| 1690 |
+{
|
| 1691 |
+ if(!set_param ("backtrace_depth" , cssDepth)) goto errOut;
|
| 1692 |
+ if(!set_param ("backtrace_interval" , cssInterval)) goto errOut;
|
| 1693 |
+ if(!set_param ("backtrace_tgid" , cssTgid)) goto errOut;
|
| 1694 |
+ if(!set_param ("backtrace_tgid_bitness" , cssBitness)) goto errOut;
|
| 1695 |
+ return true;
|
| 1696 |
+
|
| 1697 |
+errOut:
|
| 1698 |
+ return false;
|
| 1699 |
+
|
| 1700 |
+}
|
| 1701 |
+
|
| 1702 |
+bool oprofile_interface::checkCssSupportInDaemon()
|
| 1703 |
+{
|
| 1704 |
+ // TODO: [Suravee] This is to be defined
|
| 1705 |
+ return true;
|
| 1706 |
+}
|
| 1707 |
+
|
| 1708 |
+
|
| 1709 |
+bool oprofile_interface::checkCssSupportInDriver()
|
| 1710 |
+{
|
| 1711 |
+ QFile btDepth (MOUNT + "/backtrace_depth");
|
| 1712 |
+ QFile btInterval (MOUNT + "/backtrace_interval");
|
| 1713 |
+ QFile btTgid (MOUNT + "/backtrace_tgid");
|
| 1714 |
+ QFile btTgidBitness(MOUNT + "/backtrace_tgid_bitness");
|
| 1715 |
+ return ((btDepth.exists()
|
| 1716 |
+ && btInterval.exists()
|
| 1717 |
+ && btTgid.exists())? true: false);
|
| 1718 |
+}
|
| 1719 |
Index: package/src/ca/scripts/Uninstall.sh
|
| 1720 |
===================================================================
|
| 1721 |
--- package/src/ca/scripts/Uninstall.sh
|
| 1722 |
+++ package/src/ca/scripts/Uninstall.sh
|
| 1723 |
@@ -4,13 +4,13 @@
|
| 1724 |
AMDCA_GRP=amdca
|
| 1725 |
GREP=/bin/grep
|
| 1726 |
GROUPDEL="/usr/sbin/groupdel"
|
| 1727 |
-ETC="/etc"
|
| 1728 |
-INITD="$ETC/init.d"
|
| 1729 |
-RCD="$ETC/rc.d"
|
| 1730 |
-RC3D="$RCD/rc3.d"
|
| 1731 |
-RC5D="$RCD/rc5.d"
|
| 1732 |
-CODEANALYST_INIT="$INITD/codeanalyst"
|
| 1733 |
-CODEANALYST_LN="S99codeanalyst"
|
| 1734 |
+#ETC="/etc"
|
| 1735 |
+#INITD="$ETC/init.d"
|
| 1736 |
+#RCD="$ETC/rc.d"
|
| 1737 |
+#RC3D="$RCD/rc3.d"
|
| 1738 |
+#RC5D="$RCD/rc5.d"
|
| 1739 |
+#CODEANALYST_INIT="$INITD/codeanalyst"
|
| 1740 |
+#CODEANALYST_LN="S99codeanalyst"
|
| 1741 |
family10=$PREFIX/share/oprofile/x86-64/family10
|
| 1742 |
family10h=$PREFIX/share/oprofile/x86-64/family10h
|
| 1743 |
|
| 1744 |
@@ -66,27 +66,27 @@
|
| 1745 |
#
|
| 1746 |
# Stop codeanalyst service
|
| 1747 |
#
|
| 1748 |
-$CODEANALYST_INIT stop
|
| 1749 |
+#$CODEANALYST_INIT stop
|
| 1750 |
|
| 1751 |
#
|
| 1752 |
# Remove service at runlevel 3 and 5
|
| 1753 |
#
|
| 1754 |
-if test -e $RCD; then
|
| 1755 |
- print_action "Remove codeanalyst service in $RC3D"
|
| 1756 |
- rm -f $RC3D/$CODEANALYST_LN
|
| 1757 |
- RETVAL=$?; print_ok_no $RETVAL
|
| 1758 |
+#if test -e $RCD; then
|
| 1759 |
+# print_action "Remove codeanalyst service in $RC3D"
|
| 1760 |
+# rm -f $RC3D/$CODEANALYST_LN
|
| 1761 |
+# RETVAL=$?; print_ok_no $RETVAL
|
| 1762 |
+#
|
| 1763 |
+# print_action "Remove codeanalyst service in $RC5D"
|
| 1764 |
+# rm -f $RC5D/$CODEANALYST_LN
|
| 1765 |
+# RETVAL=$?; print_ok_no $RETVAL
|
| 1766 |
+#fi
|
| 1767 |
|
| 1768 |
- print_action "Remove codeanalyst service in $RC5D"
|
| 1769 |
- rm -f $RC5D/$CODEANALYST_LN
|
| 1770 |
- RETVAL=$?; print_ok_no $RETVAL
|
| 1771 |
-fi
|
| 1772 |
-
|
| 1773 |
#
|
| 1774 |
# Remove codeanalyst service
|
| 1775 |
#
|
| 1776 |
-print_action "Remove $CODEANALYST_INIT script"
|
| 1777 |
-rm -f $CODEANALYST_INIT
|
| 1778 |
-RETVAL=$?; print_ok_no $RETVAL
|
| 1779 |
+#print_action "Remove $CODEANALYST_INIT script"
|
| 1780 |
+#rm -f $CODEANALYST_INIT
|
| 1781 |
+#RETVAL=$?; print_ok_no $RETVAL
|
| 1782 |
|
| 1783 |
|
| 1784 |
#
|
| 1785 |
Index: package/src/ca/scripts/Setup.sh
|
| 1786 |
===================================================================
|
| 1787 |
--- package/src/ca/scripts/Setup.sh
|
| 1788 |
+++ package/src/ca/scripts/Setup.sh
|
| 1789 |
@@ -24,11 +24,11 @@
|
| 1790 |
AMDCA_GRP=amdca
|
| 1791 |
GROUPADD="/usr/sbin/groupadd -r"
|
| 1792 |
LN="/bin/ln -sf"
|
| 1793 |
-ETC="/etc"
|
| 1794 |
-INITD="$ETC/init.d"
|
| 1795 |
-RCD="$ETC/rc.d"
|
| 1796 |
-CODEANALYST_INIT="$INITD/codeanalyst"
|
| 1797 |
-CODEANALYST_LN="S99codeanalyst"
|
| 1798 |
+#ETC="/etc"
|
| 1799 |
+#INITD="$ETC/init.d"
|
| 1800 |
+#RCD="$ETC/rc.d"
|
| 1801 |
+#CODEANALYST_INIT="$INITD/codeanalyst"
|
| 1802 |
+#CODEANALYST_LN="S99codeanalyst"
|
| 1803 |
family10=$PREFIX/share/oprofile/x86-64/family10
|
| 1804 |
family10h=$PREFIX/share/oprofile/x86-64/family10h
|
| 1805 |
|
| 1806 |
@@ -124,39 +124,39 @@
|
| 1807 |
#
|
| 1808 |
# Installing codeanalyst service
|
| 1809 |
#
|
| 1810 |
-print_action "Install codeanalyst service."
|
| 1811 |
-if [ -f scripts/codeanalyst ] ; then
|
| 1812 |
- install -m 755 scripts/codeanalyst $INITD
|
| 1813 |
- RETVAL=$?; print_ok_no $RETVAL
|
| 1814 |
-else
|
| 1815 |
- print_error "scripts/codeanalyst not found."
|
| 1816 |
-fi
|
| 1817 |
+#print_action "Install codeanalyst service."
|
| 1818 |
+#if [ -f scripts/codeanalyst ] ; then
|
| 1819 |
+# install -m 755 scripts/codeanalyst $INITD
|
| 1820 |
+# RETVAL=$?; print_ok_no $RETVAL
|
| 1821 |
+#else
|
| 1822 |
+# print_error "scripts/codeanalyst not found."
|
| 1823 |
+#fi
|
| 1824 |
|
| 1825 |
#
|
| 1826 |
# Installing service at runlevel 3 and 5
|
| 1827 |
#
|
| 1828 |
-if test -e $RCD/rc3.d ; then
|
| 1829 |
- # SUSE and REDHAT
|
| 1830 |
- RC3D="$RCD/rc3.d"
|
| 1831 |
- RC5D="$RCD/rc5.d"
|
| 1832 |
-else if test -e $ETC/rc3.d ; then
|
| 1833 |
- # UBUNTU
|
| 1834 |
- RC3D="$ETC/rc3.d"
|
| 1835 |
- RC5D="$ETC/rc5.d"
|
| 1836 |
-fi fi
|
| 1837 |
+#if test -e $RCD/rc3.d ; then
|
| 1838 |
+# # SUSE and REDHAT
|
| 1839 |
+# RC3D="$RCD/rc3.d"
|
| 1840 |
+# RC5D="$RCD/rc5.d"
|
| 1841 |
+#else if test -e $ETC/rc3.d ; then
|
| 1842 |
+# # UBUNTU
|
| 1843 |
+# RC3D="$ETC/rc3.d"
|
| 1844 |
+# RC5D="$ETC/rc5.d"
|
| 1845 |
+#fi fi
|
| 1846 |
|
| 1847 |
-print_action "Install codeanalyst service in $RC3D"
|
| 1848 |
-$LN $CODEANALYST_INIT $RC3D/$CODEANALYST_LN
|
| 1849 |
-RETVAL=$?; print_ok_no $RETVAL
|
| 1850 |
+#print_action "Install codeanalyst service in $RC3D"
|
| 1851 |
+#$LN $CODEANALYST_INIT $RC3D/$CODEANALYST_LN
|
| 1852 |
+#RETVAL=$?; print_ok_no $RETVAL
|
| 1853 |
|
| 1854 |
-print_action "Install codeanalyst service in $RC5D"
|
| 1855 |
-$LN $CODEANALYST_INIT $RC5D/$CODEANALYST_LN
|
| 1856 |
-RETVAL=$?; print_ok_no $RETVAL
|
| 1857 |
+#print_action "Install codeanalyst service in $RC5D"
|
| 1858 |
+#$LN $CODEANALYST_INIT $RC5D/$CODEANALYST_LN
|
| 1859 |
+#RETVAL=$?; print_ok_no $RETVAL
|
| 1860 |
|
| 1861 |
#
|
| 1862 |
# Restart codeanalyst service
|
| 1863 |
#
|
| 1864 |
-$CODEANALYST_INIT restart
|
| 1865 |
+#$CODEANALYST_INIT restart
|
| 1866 |
|
| 1867 |
|
| 1868 |
echo "* Post-Install Setup Finished."
|
| 1869 |
Index: package/src/ca/Makefile.am
|
| 1870 |
===================================================================
|
| 1871 |
--- package/src/ca/Makefile.am
|
| 1872 |
+++ package/src/ca/Makefile.am
|
| 1873 |
@@ -4,7 +4,6 @@
|
| 1874 |
diffgui \
|
| 1875 |
utils \
|
| 1876 |
scripts
|
| 1877 |
- #ca_opflat
|
| 1878 |
|
| 1879 |
install-exec-hook:
|
| 1880 |
@if test -e "scripts/Setup.sh"; then \
|
| 1881 |
Index: package/CAInstaller.sh
|
| 1882 |
===================================================================
|
| 1883 |
--- package/CAInstaller.sh
|
| 1884 |
+++ package/CAInstaller.sh
|
| 1885 |
@@ -482,6 +482,34 @@
|
| 1886 |
fi
|
| 1887 |
echo ""
|
| 1888 |
}
|
| 1889 |
+
|
| 1890 |
+loadCAKM()
|
| 1891 |
+{
|
| 1892 |
+ echo ".... Load OProfile Kernel Module"
|
| 1893 |
+ grep oprofilefs /proc/filesystems > /dev/null
|
| 1894 |
+ if test "$?" -ne 0; then
|
| 1895 |
+ modprobe oprofile
|
| 1896 |
+ if test "$?" != "0"; then
|
| 1897 |
+ # couldn't load the module
|
| 1898 |
+ return 1
|
| 1899 |
+ fi
|
| 1900 |
+ grep oprofile /proc/modules > /dev/null
|
| 1901 |
+ if test "$?" != "0"; then
|
| 1902 |
+ # didn't find module
|
| 1903 |
+ return 1
|
| 1904 |
+ fi
|
| 1905 |
+ grep oprofilefs /proc/filesystems >/dev/null
|
| 1906 |
+ if test "$?" -ne 0; then
|
| 1907 |
+ # filesystem still not around
|
| 1908 |
+ return 1
|
| 1909 |
+ fi
|
| 1910 |
+ fi
|
| 1911 |
+ mkdir /dev/oprofile > /dev/null 2>&1
|
| 1912 |
+ grep oprofilefs /etc/mtab >/dev/null
|
| 1913 |
+ if test "$?" -ne 0; then
|
| 1914 |
+ mount -t oprofilefs nodev /dev/oprofile >/dev/null
|
| 1915 |
+ fi
|
| 1916 |
+}
|
| 1917 |
#-------------------------------------------------------------------------------
|
| 1918 |
# CONFIGURATION
|
| 1919 |
|
| 1920 |
@@ -576,13 +604,7 @@
|
| 1921 |
# uninstallCAKM
|
| 1922 |
./src/cakm/mod_install.sh -r -n
|
| 1923 |
checkErrorOut
|
| 1924 |
- /sbin/lsmod | grep oprofile
|
| 1925 |
- if test "$?" = "0"; then
|
| 1926 |
- echo ".... Unload CA Kernel Module."
|
| 1927 |
- /etc/init.d/codeanalyst stop
|
| 1928 |
- fi
|
| 1929 |
- echo ".... Load CA Kernel Module."
|
| 1930 |
- /etc/init.d/codeanalyst start
|
| 1931 |
+ loadCAKM
|
| 1932 |
fi
|
| 1933 |
|
| 1934 |
|