1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc. 2 Contributed by Oracle. 3 4 This file is part of GNU Binutils. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, 51 Franklin Street - Fifth Floor, Boston, 19 MA 02110-1301, USA. */ 20 21 #include "config.h" 22 #include <stdio.h> 23 #include <signal.h> 24 #include <stdarg.h> 25 #include <fcntl.h> // creat 26 #include <unistd.h> // sleep 27 #include <pthread.h> // pthread_exit 28 #include <sys/wait.h> // wait 29 #include <locale.h> 30 31 #include "DbeApplication.h" 32 #include "Histable.h" 33 #include "ipcio.h" 34 #include "Dbe.h" 35 #include "DbeSession.h" 36 #include "DbeThread.h" 37 #include "DbeView.h" 38 39 int ipc_flags = 0; 40 IPCTraceLevel ipc_trace_level = TRACE_LVL_0; 41 int ipc_single_threaded_mode = 0; 42 const char *IPC_PROTOCOL_UNKNOWN = "IPC_PROTOCOL_UNKNOWN"; 43 const char *IPC_PROTOCOL_CURR = IPC_PROTOCOL_STR; 44 char const *ipc_protocol = NULL; 45 46 DbeThreadPool *ipcThreadPool; 47 48 extern int currentRequestID; 49 extern int currentChannelID; 50 extern BufferPool *responseBufferPool; 51 extern bool cancelNeeded (int); 52 extern void reexec (); 53 54 /* Simple implementation of support for cancel of open experiment. Since we have only one cancellable 55 operation supported at this moment, we are using just a global variable. 56 As we support more and more cancellable ops we need a more sophisticated data struture such 57 as a mt-safe array to keep track of all cancellable requests/channels and update the supporting 58 routines - setCancellableChannel, cancelNeeded (in ipcio.cc) setCancelRequestedCh */ 59 int cancellableChannelID = 0xFFFFFFFF; 60 int cancelRequestedChannelID; 61 62 static const char *table_name (int); 63 64 #define VSIZE(v) ((long long) ((v) ? (v)->size() : 0)) 65 66 inline const char* 67 bool2str (bool v) 68 { 69 return v ? "true" : "false"; 70 } 71 72 inline const char* 73 str2str (const char* v) 74 { 75 return v ? v : "NULL"; 76 } 77 78 inline const char* 79 str2s (const char* v) 80 { 81 return v ? v : ""; 82 } 83 84 inline DbeView * 85 getView (int index) 86 { 87 return dbeSession->getView (index); 88 } 89 90 extern "C" 91 { 92 typedef void (*SignalHandler)(int); 93 } 94 95 /* 96 * Fatal error handlers 97 */ 98 static int fatalErrorCode = 1; 99 static int fatalErrorCounter = 0; 100 static void *fatalErrorContext = 0; 101 static siginfo_t *fatalErrorInfo = 0; 102 static char *fatalErrorDynamicMemory = NULL; 103 104 extern "C" void 105 fatalErrorHadler (int sig, siginfo_t *info, void *context) 106 { 107 if (fatalErrorCounter > 0) 108 { // Need synchronization here 109 //sleep(10); // Wait 10 seconds to make sure previous processing is done 110 return; // exit(fatalErrorCode); // Already in processing 111 } 112 fatalErrorCounter = 1; 113 fatalErrorCode = sig; 114 fatalErrorContext = context; 115 fatalErrorInfo = info; 116 // Free reserved memory 117 if (fatalErrorDynamicMemory != NULL) 118 { 119 free (fatalErrorDynamicMemory); 120 fatalErrorDynamicMemory = NULL; 121 } 122 // Get process ID 123 pid_t pid = getpid (); 124 // Create dump file 125 char fname[128]; 126 snprintf (fname, sizeof (fname), "/tmp/gprofng.%lld", (long long) pid); 127 mkdir (fname, 0700); 128 snprintf (fname, sizeof (fname), "/tmp/gprofng.%lld/crash.sig%d.%lld", 129 (long long) pid, sig, (long long) pid); 130 // Dump stack trace in background using pstack 131 char buf[256]; 132 snprintf (buf, sizeof (buf), "/usr/bin/pstack %lld > %s.pstack", 133 (long long) pid, fname); 134 system (buf); 135 int fd = creat (fname, 0600); 136 if (fd >= 0) 137 { 138 // Write error message 139 dbe_write (fd, "A fatal error has been detected by er_print: Signal %d\n", 140 sig); 141 dbe_write (fd, "Protocol Version: %d\n", IPC_VERSION_NUMBER); 142 close (fd); 143 } 144 wait (0); // wait for pstack 145 //sleep(10); // Wait 10 seconds to make sure processing of fatal error is done 146 // Exit with correct status 147 exit (fatalErrorCode); 148 } 149 150 // SIGABRT Handler 151 extern "C" void 152 sigABRT_handler (int sig, siginfo_t *info, void *context) 153 { 154 fatalErrorHadler (sig, info, context); 155 pthread_exit (&fatalErrorCode); 156 } 157 158 // SIGSEGV Handler 159 extern "C" void 160 sigSEGV_handler (int sig, siginfo_t *info, void *context) 161 { 162 //if (fatalErrorCounter > 0) sleep(1); // Wait 1 second 163 fatalErrorHadler (sig, info, context); 164 pthread_exit (&fatalErrorCode); 165 } 166 167 // SIGTERM Handler 168 extern "C" void sigterm_handler (int sig, siginfo_t *info, void *context); 169 struct sigaction old_sigterm_handler; 170 171 volatile int term_flag; 172 int error_flag; 173 174 extern "C" void 175 sigterm_handler (int, siginfo_t *, void *) 176 { 177 if (fatalErrorCounter > 0) 178 { 179 //sleep(10); // Wait 10 seconds to make sure processing of fatal error is done 180 //return; // Fatal error processing will exit it 181 pthread_exit (&fatalErrorCode); 182 } 183 term_flag = 1; 184 } 185 186 #define ipc_log ipc_default_log 187 #define ipc_request_trace ipc_request_log 188 #define ipc_response_trace ipc_response_log 189 static const char *ipc_log_name = NULL; 190 static const char *ipc_request_log_name = NULL; 191 static const char *ipc_response_log_name = NULL; 192 static FILE *requestLogFileP = stderr; 193 static FILE *responseLogFileP = stderr; 194 static hrtime_t begin_time; 195 static long long delta_time = 0; 196 197 void 198 ipc_default_log (const char *fmt, ...) 199 { 200 if (!ipc_log_name || !ipc_flags) 201 return; 202 if (ipc_trace_level >= TRACE_LVL_3) 203 { 204 hrtime_t cur_time = gethrtime (); 205 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time; 206 fprintf (stderr, "%7llu: ", time_stamp); 207 } 208 va_list vp; 209 va_start (vp, fmt); 210 vfprintf (stderr, fmt, vp); 211 va_end (vp); 212 fflush (stderr); 213 } 214 215 extern "C" void sigint_handler (int sig, siginfo_t *info, void *context); 216 struct sigaction old_sigint_handler; 217 218 extern "C" void 219 sigint_handler (int, siginfo_t *, void *) 220 { 221 ipc_log ("SIGINT signal happens\n"); 222 } 223 224 void 225 ipc_request_log (IPCTraceLevel trace_level, const char *fmt, ...) 226 { 227 if (!ipc_request_log_name || !ipc_flags || trace_level > ipc_trace_level) 228 return; 229 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ()); 230 if (ipc_trace_level >= TRACE_LVL_3) 231 { 232 hrtime_t cur_time = gethrtime (); 233 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time; 234 fprintf (requestLogFileP, "%7llu: ", time_stamp); 235 } 236 va_list vp; 237 va_start (vp, fmt); 238 vfprintf (requestLogFileP, fmt, vp); 239 va_end (vp); 240 fflush (requestLogFileP); 241 } 242 243 void 244 ipc_response_log (IPCTraceLevel trace_level, const char *fmt, ...) 245 { 246 if (!ipc_response_log_name || !ipc_flags || trace_level > ipc_trace_level) 247 return; 248 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ()); 249 if (ipc_trace_level >= TRACE_LVL_3) 250 { 251 hrtime_t cur_time = gethrtime (); 252 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time; 253 fprintf (responseLogFileP, "%7llu: ", time_stamp); 254 } 255 va_list vp; 256 va_start (vp, fmt); 257 vfprintf (responseLogFileP, fmt, vp); 258 va_end (vp); 259 fflush (responseLogFileP); 260 } 261 262 #ifdef IPC_LOG 263 void 264 ipc_dump (char *s, Vector<bool> *v) 265 { 266 if (v == NULL) 267 { 268 ipc_log (" Vector<bool> %s is NULL\n", str2s (s)); 269 return; 270 } 271 ipc_log (" Vector<bool> %s size=%lld\n", str2s (s), VSIZE (v)); 272 for (int i = 0; i < v->size (); i++) 273 ipc_log (" [%d]: %s\n", i, bool2str (v->fetch (i))); 274 } 275 276 void 277 ipc_dump (char *s, Vector<String> *v) 278 { 279 if (v == NULL) 280 { 281 ipc_log (" Vector<bool> %s is NULL\n", str2s (s)); 282 return; 283 } 284 ipc_log (" Vector<String> %s size=%lld\n", str2s (s), VSIZE (v)); 285 for (int i = 0; i < v->size (); i++) 286 { 287 String str = v->fetch (i); 288 ipc_log (" [%d]: '%s'\n", i, str2str (str)); 289 } 290 } 291 292 void 293 ipc_dump (char *s, Vector<Obj> *v) 294 { 295 if (v == NULL) 296 { 297 ipc_log (" Vector<Obj> %s is NULL\n", str2s (s)); 298 return; 299 } 300 ipc_log (" Vector<void *> %s size=%lld\n", str2s (s), VSIZE (v)); 301 for (int i = 0; i < v->size (); i++) 302 ipc_log (" [%d]: 0x%08llx\n", i, (long long) (v->fetch (i))); 303 } 304 305 #else 306 #define ipc_dump(s, v) 307 #endif 308 309 static MetricList * 310 readMetricListV2 (int dbevindex, IPCrequest* req) 311 { 312 MetricType mtype = (MetricType) readInt (req); 313 Vector<int> *type = (Vector<int>*)readArray (req); 314 Vector<int> *subtype = (Vector<int>*)readArray (req); 315 Vector<bool> *sort = (Vector<bool>*)readArray (req); 316 Vector<int> *vis = (Vector<int>*)readArray (req); 317 Vector<char*> *cmd = (Vector<char*>*)readArray (req); 318 Vector<char*> *expr_spec = (Vector<char*>*)readArray (req); 319 Vector<char*> *legends = (Vector<char*>*)readArray (req); 320 MetricList *mlist = dbeGetMetricListV2 (dbevindex, mtype, type, subtype, sort, 321 vis, cmd, expr_spec, legends); 322 return mlist; 323 } 324 325 static void 326 setCancellableChannel (int chID) 327 { 328 cancellableChannelID = chID; 329 } 330 331 /* Add more entries here for other cancellable operations */ 332 static void 333 checkCancellableOp (char *inp, IPCrequest* req) 334 { 335 if (!strcmp (inp, "setFilterStr")) 336 setCancellableChannel (currentChannelID); 337 else if (!strcmp (inp, "openExperimentList")) 338 setCancellableChannel (currentChannelID); 339 else if (!strcmp (inp, "getFiles") || !strcmp (inp, "getFileAttributes")) 340 { 341 setCancellableChannel (currentChannelID); 342 req->setCancelImmediate (); 343 } 344 } 345 346 /* This is what used to be the core of ipc_mainLoop before asynch ipc. 347 Read the details of the request from the request buffer: name, args etc 348 do the work by calling the appropriate dbe routine(s) and write the 349 response to a response buffer and queue it up in the response queue */ 350 351 int 352 ipc_doWork (void *arg) 353 { 354 IPCrequest *req = (IPCrequest *) arg; 355 currentRequestID = req->getRequestID (); 356 currentChannelID = req->getChannelID (); 357 req->setStatus (IN_PROGRESS); 358 String inp = readString (req); 359 if (inp == NULL) 360 { 361 ipc_log ("NULL ipc command received, exiting\n"); 362 return 0; 363 } 364 ipc_log ("ipc: %s Req %x Ch %x\n", inp, req->getRequestID (), req->getChannelID ()); 365 checkCancellableOp (inp, req); 366 if (!strcmp (inp, "initApplication")) 367 { 368 bool nbm = readBoolean (req); 369 String arg1 = readString (req); 370 String arg2 = readString (req); 371 Vector<String> *arg3 = (Vector<String>*)readArray (req); 372 ipc_log (" nbm: %s, arg1: '%s', arg2: '%s'\n", bool2str (nbm), str2str (arg1), str2str (arg2)); 373 ipc_dump ("arg3", arg3); 374 // set the session to be interactive 375 dbeSession->set_interactive (true); 376 if (nbm) 377 theApplication->set_name ("analyzer-NBM"); 378 else 379 theApplication->set_name ("analyzer"); 380 381 // XXX Why does it reset the install directory???? Or a licensing directory??? 382 // Vector<String> *res = theDbeApplication->initApplication (arg1, arg2, &setProgress); 383 Vector<String> *res = theDbeApplication->initApplication (NULL, NULL, &setProgress); 384 writeArray (res, req); 385 free (arg1); 386 free (arg2); 387 destroy (arg3); 388 destroy (res); 389 } 390 else if (!strcmp (inp, "syncTime")) 391 { 392 long long anl_time = readLong (req); 393 hrtime_t cur_time = gethrtime (); 394 long long time_stamp = (cur_time - begin_time) / 1000000; 395 delta_time = anl_time - time_stamp; 396 ipc_log (" syncTime %llu %llu \n", anl_time, delta_time); 397 writeString (NULL, req); 398 } 399 else if (!strcmp (inp, "getInitMessages")) 400 { 401 Vector<String> *res = dbeGetInitMessages (); 402 ipc_log (" returned = %lld msgs\n", VSIZE (res)); 403 writeArray (res, req); 404 destroy (res); 405 } 406 else if (!strcmp (inp, "reExec")) 407 { 408 ipc_log (" started reexec()\n"); 409 reexec (); 410 } 411 else if (!strcmp (inp, "dbeCreateDirectories")) 412 { 413 String arg1 = readString (req); // path 414 ipc_log (" arg = %s\n", arg1); 415 String res = dbeCreateDirectories (arg1); 416 writeString (res, req); 417 free (arg1); 418 free (res); 419 } 420 else if (!strcmp (inp, "dbeDeleteFile")) 421 { 422 String arg1 = readString (req); // path 423 ipc_log (" arg = %s\n", arg1); 424 String res = dbeDeleteFile (arg1); 425 writeString (res, req); 426 free (arg1); 427 free (res); 428 } 429 else if (!strcmp (inp, "dbeReadFile")) 430 { 431 String arg1 = readString (req); 432 ipc_log (" arg = %s\n", arg1); // path 433 Vector<String> *res = dbeReadFile (arg1); 434 writeArray (res, req); 435 free (arg1); 436 destroy (res); 437 } 438 else if (!strcmp (inp, "dbeWriteFile")) 439 { 440 String arg1 = readString (req); // path 441 String arg2 = readString (req); // contents 442 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2); 443 int res = dbeWriteFile (arg1, arg2); 444 writeInt (res, req); 445 free (arg1); 446 } 447 else if (!strcmp (inp, "getExpPreview")) 448 { 449 // XXX add another argument == DbeView index 450 String arg1 = readString (req); 451 ipc_log (" arg = %s\n", arg1); 452 Vector<String> *res = dbeGetExpPreview (0, arg1); 453 writeArray (res, req); 454 free (arg1); 455 destroy (res); 456 } 457 else if (!strcmp (inp, "getFileAttributes")) 458 { 459 String arg1 = readString (req); // filename 460 String arg2 = readString (req); // format 461 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2); 462 String res = dbeGetFileAttributes (arg1, arg2); 463 writeString (res, req); 464 free (arg1); 465 free (arg2); 466 free (res); 467 } 468 else if (!strcmp (inp, "getFiles")) 469 { 470 String arg1 = readString (req); // dirname 471 String arg2 = readString (req); // format 472 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2); 473 String res = dbeGetFiles (arg1, arg2); 474 writeString (res, req); 475 free (arg1); 476 free (arg2); 477 free (res); 478 } 479 else if (!strcmp (inp, "getOSFamily")) 480 writeString ("Linux", req); 481 else if (!strcmp (inp, "getRunningProcesses")) 482 { 483 String arg1 = readString (req); // format 484 ipc_log (" arg = %s\n", arg1); 485 String res = dbeGetRunningProcesses (arg1); 486 writeString (res, req); 487 free (arg1); 488 free (res); 489 } 490 else if (!strcmp (inp, "getCurrentDirectory")) 491 { 492 char buf [2048]; 493 String res = getcwd (buf, (size_t) sizeof (buf)); // Get current directory 494 writeString (res, req); 495 } 496 else if (!strcmp (inp, "getHomeDirectory")) 497 { 498 String res = getenv ("HOME"); // Get HOME directory 499 writeString (res, req); 500 } 501 else if (!strcmp (inp, "setCurrentDirectory")) 502 { 503 String arg1 = readString (req); // dirname 504 ipc_log (" arg = %s\n", arg1); 505 int res = chdir (arg1); // Change directory 506 writeInt (res, req); 507 free (arg1); 508 } 509 else if (!strcmp (inp, "getLocale")) 510 { 511 String res = setlocale (LC_ALL, ""); // Get locale 512 writeString (res, req); 513 } 514 else if (!strcmp (inp, "setLocale")) 515 { 516 String arg1 = readString (req); // locale 517 ipc_log (" arg = %s\n", arg1); 518 String res = setlocale (LC_ALL, arg1); // Set locale 519 writeString (res, req); 520 free (arg1); 521 } 522 else if (!strcmp (inp, "readRCFile")) 523 { 524 int arg1 = readInt (req); 525 String arg2 = readString (req); // file name 526 ipc_log (" arg1=%d, arg2=%s\n", arg1, arg2); 527 String res = dbeReadRCFile (arg1, arg2); // Read RC File 528 writeString (res, req); 529 free (res); 530 } 531 else if (!strcmp (inp, "dbeGetExpParams")) 532 { 533 // XXX add another argument == DbeView index 534 String arg1 = readString (req); 535 ipc_log (" arg = %s\n", arg1); 536 String res = dbeGetExpParams (0, arg1); 537 writeString (res, req); 538 free (arg1); 539 free (res); 540 } 541 else if (!strcmp (inp, "getExperimentsGroups")) 542 { 543 Vector<Vector<char*>*> *groups = dbeGetExperimensGroups (); 544 writeArray (groups, req); 545 destroy (groups); 546 } 547 else if (!strcmp (inp, "setExperimentsGroups")) 548 { 549 Vector<Vector<char*>*> *groups = (Vector<Vector<char*>*> *)readArray (req); 550 ipc_log (" groups.size = %lld\n", VSIZE (groups)); 551 char *msg_str = dbeSetExperimentsGroups (groups); 552 writeString (msg_str, req); 553 free (msg_str); 554 destroy (groups); 555 } 556 else if (!strcmp (inp, "dropExperiment")) 557 { 558 int arg1 = readInt (req); 559 Vector<int> *arg2 = (Vector<int>*)readArray (req); 560 ipc_log (" arg = %d, exps = %lld\n", arg1, VSIZE (arg2)); 561 char *res = dbeDropExperiment (arg1, arg2); 562 writeString (res, req); 563 free (res); 564 delete arg2; 565 } 566 else if (!strcmp (inp, "getUserExpId")) 567 { 568 Vector<int> *arg = (Vector<int>*)readArray (req); 569 ipc_log (" expIds = %lld\n", VSIZE (arg)); 570 Vector<int> *res = dbeGetUserExpId (arg); 571 writeArray (res, req); 572 delete res; 573 } 574 else if (!strcmp (inp, "getFounderExpId")) 575 { 576 Vector<int> *arg = (Vector<int>*)readArray (req); 577 ipc_log (" expIds = %lld\n", VSIZE (arg)); 578 Vector<int> *res = dbeGetFounderExpId (arg); 579 writeArray (res, req); 580 delete res; 581 } 582 else if (!strcmp (inp, "getExpGroupId")) 583 { 584 Vector<int> *arg = (Vector<int>*)readArray (req); 585 ipc_log (" expIds = %lld\n", VSIZE (arg)); 586 Vector<int> *res = dbeGetExpGroupId (arg); 587 writeArray (res, req); 588 delete res; 589 } 590 else if (!strcmp (inp, "getExpsProperty")) 591 { 592 String arg = readString (req); 593 Vector<String> *res = dbeGetExpsProperty (arg); 594 writeArray (res, req); 595 destroy (res); 596 } 597 else if (!strcmp (inp, "getExpName")) 598 { 599 // XXX add argument == DbeView index 600 Vector<String> *res = dbeGetExpName (0); 601 writeArray (res, req); 602 destroy (res); 603 } 604 else if (!strcmp (inp, "getExpState")) 605 { 606 // XXX add argument == DbeView index 607 Vector<int> *res = dbeGetExpState (0); 608 writeArray (res, req); 609 delete res; 610 } 611 else if (!strcmp (inp, "getExpEnable")) 612 { 613 int arg1 = readInt (req); 614 ipc_log (" arg1 = %d\n", arg1); 615 Vector<bool> *res = dbeGetExpEnable (arg1); 616 writeArray (res, req); 617 delete res; 618 } 619 else if (!strcmp (inp, "setExpEnable")) 620 { 621 int arg1 = readInt (req); 622 Vector<bool> *arg2 = (Vector<bool>*)readArray (req); 623 ipc_log (" arg1=%d\n", arg1); 624 ipc_dump ("arg2", arg2); 625 bool b = dbeSetExpEnable (arg1, arg2); 626 writeBoolean (b, req); 627 ipc_log (" dbeSetExpEnable returns %s\n", bool2str (b)); 628 delete arg2; 629 } 630 else if (!strcmp (inp, "getExpInfo")) 631 { 632 int arg1 = readInt (req); 633 ipc_log (" args = %d\n", arg1); 634 Vector<String> *res = dbeGetExpInfo (arg1); 635 writeArray (res, req); 636 destroy (res); 637 } 638 else if (!strcmp (inp, "getViewModeEnable")) 639 { 640 bool res = dbeGetViewModeEnable (); 641 writeBoolean (res, req); 642 } 643 else if (!strcmp (inp, "getJavaEnable")) 644 { 645 bool res = dbeGetJavaEnable (); 646 writeBoolean (res, req); 647 } 648 else if (!strcmp (inp, "updateNotes")) 649 { 650 int arg1 = readInt (req); 651 int arg2 = readInt (req); 652 int arg3 = readInt (req); 653 String arg4 = readString (req); 654 bool arg5 = readBoolean (req); 655 ipc_log (" args = %d, %d\n", arg1, arg2); 656 int i = dbeUpdateNotes (arg1, arg2, arg3, arg4, arg5); 657 writeInt (i, req); 658 } 659 else if (!strcmp (inp, "getLoadObjectList")) 660 { 661 int arg1 = readInt (req); 662 ipc_log (" arg = %d\n", arg1); 663 Vector<void *> *res = dbeGetLoadObjectList (arg1); 664 if (res == NULL) 665 ipc_log (" returning = NULL for LoadObjectList\n"); 666 else 667 { 668 Vector<char*> *s = (Vector<char*> *) res->fetch (0); 669 ipc_log (" returning = %lld vectors for %lld LoadObjects\n", 670 VSIZE (res), VSIZE (s)); 671 } 672 writeArray (res, req); 673 destroy (res); 674 } 675 else if (!strcmp (inp, "getLoadObjectName")) 676 { 677 int arg1 = readInt (req); 678 ipc_log (" arg = %d\n", arg1); 679 Vector<String> *res = dbeGetLoadObjectName (arg1); 680 ipc_log (" returning = %lld strings\n", VSIZE (res)); 681 writeArray (res, req); 682 destroy (res); 683 } 684 else if (!strcmp (inp, "getTabListInfo")) 685 { 686 int arg1 = readInt (req); 687 ipc_log (" arg = %d\n", arg1); 688 Vector<void*> *res = dbeGetTabListInfo (arg1); 689 writeArray (res, req); 690 destroy (res); 691 } 692 else if (!strcmp (inp, "getSearchPath")) 693 { 694 // XXX add argument == DbeView index 695 ipc_log (" no args\n"); 696 Vector<String> *res = dbeGetSearchPath (0); 697 writeArray (res, req); 698 destroy (res); 699 } 700 else if (!strcmp (inp, "setSearchPath")) 701 { 702 // XXX add another argument == DbeView index 703 Vector<String> *res = (Vector<String>*)readArray (req); 704 ipc_log (" %lld strings\n", VSIZE (res)); 705 dbeSetSearchPath (0, res); 706 writeString (NULL, req); 707 destroy (res); 708 } 709 else if (!strcmp (inp, "getPathmaps")) 710 { 711 Vector<void*> *res = dbeGetPathmaps (0); 712 ipc_log (" returns = %lld objects, number of pathmaps = %lld\n", 713 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0))); 714 writeArray (res, req); 715 destroy (res); 716 } 717 else if (!strcmp (inp, "setPathmaps")) 718 { 719 Vector<String> *from = (Vector<String>*)readArray (req); 720 Vector<String> *to = (Vector<String>*)readArray (req); 721 char *res = dbeSetPathmaps (from, to); 722 writeString (res, req); 723 free (res); 724 if (from) 725 { 726 from->destroy (); 727 delete from; 728 } 729 if (to) 730 { 731 to->destroy (); 732 delete to; 733 } 734 } 735 else if (!strcmp (inp, "addPathmap")) 736 { 737 // XXX add another argument == DbeView index 738 String arg1 = readString (req); 739 String arg2 = readString (req); 740 ipc_log (" args = '%s', '%s'\n", arg1 ? arg1 : "NULL", arg2 ? arg2 : "NULL"); 741 char *res = dbeAddPathmap (0, arg1, arg2); 742 ipc_log (" returns = '%s'\n", (res != NULL ? res : "NULL")); 743 writeString (res, req); 744 free (arg1); 745 free (arg2); 746 } 747 else if (!strcmp (inp, "getMsg")) 748 { 749 int arg1 = readInt (req); 750 int arg2 = readInt (req); 751 ipc_log (" args = %d, %d\n", arg1, arg2); 752 String res = dbeGetMsg (arg1, arg2); 753 ipc_log (" returns = '%s'\n", (res != NULL ? res : "<NULL>")); 754 writeString (res, req); 755 free (res); 756 } 757 else if (!strcmp (inp, "initView")) 758 { 759 int arg1 = readInt (req); 760 int arg2 = readInt (req); 761 ipc_log (" new view = %d; clone of view %d\n", arg1, arg2); 762 dbeInitView (arg1, arg2); 763 writeString (NULL, req); 764 } 765 else if (!strcmp (inp, "disposeWindow")) 766 { 767 int arg1 = readInt (req); 768 ipc_log (" args = %d\n", arg1); 769 dbeDeleteView (arg1); 770 writeString (NULL, req); 771 } 772 #if 0 773 else if (!strcmp (inp, "createMapfile")) 774 { 775 int arg1 = readInt (); 776 String arg2 = readString (); 777 int arg3 = readInt (); 778 ipc_log (" args = %d, %s, %d\n", arg1, arg2, arg3); 779 String res = dbeCreateMapfile (arg1, arg2, arg3); 780 writeString (res); 781 free (arg2); 782 free (res); 783 } 784 #endif 785 else if (!strcmp (inp, "setCompareModeV2")) 786 { 787 int dbevindex = readInt (req); 788 int cmp_mode = readInt (req); 789 getView (dbevindex)->set_compare_mode (cmp_mode); 790 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, req->getRequestID (), req->getChannelID ()); 791 } 792 else if (!strcmp (inp, "getCompareModeV2")) 793 { 794 int dbevindex = readInt (req); 795 int res = CMP_DISABLE; 796 if (dbeSession->expGroups && dbeSession->expGroups->size () > 1) 797 res = getView (dbevindex)->get_compare_mode (); 798 ipc_log (" %s: %d returns %d\n", inp, dbevindex, res); 799 writeInt (res, req); 800 } 801 else if (!strcmp (inp, "getRefMetricsV2")) 802 { 803 Vector<void*> *res = dbeGetRefMetricsV2 (); 804 writeArray (res, req); 805 destroy (res); 806 } 807 else if (!strcmp (inp, "setCurMetricsV2")) 808 { 809 int dbevindex = readInt (req); 810 int cmp_mode = readInt (req); 811 MetricList *mlist = readMetricListV2 (dbevindex, req); 812 getView (dbevindex)->reset_metric_list (mlist, cmp_mode); 813 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, req->getRequestID (), req->getChannelID ()); 814 } 815 else if (!strcmp (inp, "getCurMetricsV2")) 816 { 817 int arg1 = readInt (req); 818 MetricType arg2 = (MetricType) readInt (req); 819 ipc_log (" args = %d, %d\n", arg1, arg2); 820 Vector<void*> *res = dbeGetCurMetricsV2 (arg1, arg2); 821 writeArray (res, req); 822 destroy (res); 823 } 824 else if (!strcmp (inp, "getRefMetricTree")) 825 { 826 int dbevindex = readInt (req); 827 bool include_unregistered = readBoolean (req); 828 ipc_log (" args = %d, %d\n", dbevindex, include_unregistered); 829 Vector<void*> *res = dbeGetRefMetricTree (dbevindex, include_unregistered); 830 writeArray (res, req); 831 destroy (res); 832 } 833 else if (!strcmp (inp, "getRefMetricTreeValues")) 834 { 835 int dbevindex = readInt (req); 836 Vector<String> *metcmds = (Vector<String>*)readArray (req); 837 Vector<String> *nonmetcmds = (Vector<String>*)readArray (req); 838 ipc_log (" args = %d, metcmds->size()=%lld, nonmetcmds->size()=%lld\n", 839 dbevindex, VSIZE (metcmds), VSIZE (nonmetcmds)); 840 ipc_dump ("metcmds", metcmds); 841 ipc_dump ("nonmetcmds", nonmetcmds); 842 Vector<void*> *res = dbeGetRefMetricTreeValues (dbevindex, metcmds, nonmetcmds); 843 #ifdef IPC_LOG 844 if (res != NULL) 845 ipc_log (" returns = %lld objects, length = %lld\n", 846 VSIZE (res), VSIZE (((Vector<int>*)res->fetch (0)))); 847 else 848 ipc_log (" returns NULL\n"); 849 #endif 850 writeArray (res, req); 851 destroy (res); 852 } 853 else if (!strcmp (inp, "getOverviewText")) 854 { 855 int arg1 = readInt (req); 856 ipc_log (" args = %d\n", arg1); 857 Vector<char*> *res = dbeGetOverviewText (arg1); 858 writeArray (res, req); 859 destroy (res); 860 } 861 else if (!strcmp (inp, "setSort")) 862 { 863 int arg1 = readInt (req); 864 int arg2 = readInt (req); 865 MetricType arg3 = (MetricType) readInt (req); 866 bool arg4 = readBoolean (req); 867 ipc_log (" args = %d, %d, %d, %c\n", arg1, arg2, arg3, (arg4 ? 'T' : 'F')); 868 dbeSetSort (arg1, arg2, arg3, arg4); 869 writeString (NULL, req); 870 } 871 872 else if (!strcmp (inp, "getAnoValue")) 873 { 874 int arg1 = readInt (req); 875 ipc_log (" args = %d\n", arg1); 876 Vector<int> *res = dbeGetAnoValue (arg1); 877 writeArray (res, req); 878 delete res; 879 } 880 else if (!strcmp (inp, "setAnoValue")) 881 { 882 int arg1 = readInt (req); 883 ipc_log (" args = %d, array\n", arg1); 884 Vector<int> *arg2 = (Vector<int>*)readArray (req); 885 dbeSetAnoValue (arg1, arg2); 886 writeString (NULL, req); 887 delete arg2; 888 } 889 else if (!strcmp (inp, "getNameFormat")) 890 { 891 int arg1 = readInt (req); 892 ipc_log (" args = %d\n", arg1); 893 int b = dbeGetNameFormat (arg1); 894 writeInt (b, req); 895 } 896 else if (!strcmp (inp, "getSoName")) 897 { 898 int arg1 = readInt (req); 899 ipc_log (" args = %d\n", arg1); 900 bool b = dbeGetSoName (arg1); 901 writeBoolean (b, req); 902 } 903 else if (!strcmp (inp, "setNameFormat")) 904 { 905 int arg1 = readInt (req); 906 int arg2 = readInt (req); 907 bool arg3 = readBoolean (req); 908 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3); 909 dbeSetNameFormat (arg1, arg2, arg3); 910 writeString (NULL, req); 911 } 912 else if (!strcmp (inp, "getViewMode")) 913 { 914 int arg1 = readInt (req); 915 ipc_log (" args = %d\n", arg1); 916 int i = dbeGetViewMode (arg1); 917 ipc_log (" returns = %d\n", i); 918 writeInt (i, req); 919 } 920 else if (!strcmp (inp, "setViewMode")) 921 { 922 int arg1 = readInt (req); 923 int arg2 = readInt (req); 924 ipc_log (" args = %d, %d\n", arg1, arg2); 925 dbeSetViewMode (arg1, arg2); 926 writeString (NULL, req); 927 } 928 else if (!strcmp (inp, "getTLValue")) 929 { 930 int arg1 = readInt (req); 931 ipc_log (" args = %d\n", arg1); 932 Vector<void*> *res = dbeGetTLValue (arg1); 933 ipc_log (" returns = %lld void*'s\n", VSIZE (res)); 934 writeArray (res, req); 935 delete res; 936 } 937 else if (!strcmp (inp, "setTLValue")) 938 { 939 int arg1 = readInt (req); 940 ipc_log (" args = %d\n", arg1); 941 String tldata_cmd = readString (req); 942 int entity_prop_id = readInt (req); 943 int align = readInt (req); 944 int depth = readInt (req); 945 dbeSetTLValue (arg1, tldata_cmd, entity_prop_id, align, depth); 946 writeString (NULL, req); 947 free (tldata_cmd); 948 } 949 else if (!strcmp (inp, "getExpFounderDescendants")) 950 { 951 Vector<void*> *res = dbeGetExpFounderDescendants (); 952 writeArray (res, req); 953 destroy (res); 954 } 955 else if (!strcmp (inp, "getExpSelection")) 956 { 957 int arg1 = readInt (req); 958 ipc_log (" args = %d\n", arg1); 959 Vector<void*> *res = dbeGetExpSelection (arg1); 960 writeArray (res, req); 961 destroy (res); 962 } 963 964 else if (!strcmp (inp, "setFilterStr")) 965 { 966 int arg1 = readInt (req); 967 String arg2 = readString (req); 968 ipc_log (" args = %d, %s\n", arg1, arg2); 969 String res = dbeSetFilterStr (arg1, arg2); 970 ipc_log (" returns = '%s'\n", res ? res : "NULL"); 971 writeString (res, req); 972 free (arg2); 973 free (res); 974 } 975 976 else if (!strcmp (inp, "getFilterStr")) 977 { 978 int arg1 = readInt (req); 979 ipc_log (" args = %d\n", arg1); 980 String res = dbeGetFilterStr (arg1); 981 ipc_log (" returns = '%s'\n", res ? res : "NULL"); 982 writeString (res, req); 983 free (res); 984 } 985 986 else if (!strcmp (inp, "validateFilterExpression")) 987 { 988 String arg1 = readString (req); 989 int res = dbeValidateFilterExpression (arg1); 990 ipc_log (" validateFilterExpression('%s') returned %d\n", str2str (arg1), res); 991 free (arg1); 992 writeInt (res, req); 993 } 994 995 else if (!strcmp (inp, "getFilterKeywords")) 996 { 997 int dbevindex = readInt (req); 998 Vector<void*>*res = dbeGetFilterKeywords (dbevindex); 999 writeArray (res, req); 1000 destroy (res); 1001 } 1002 1003 else if (!strcmp (inp, "getFilters")) 1004 { 1005 int arg1 = readInt (req); 1006 int arg2 = readInt (req); 1007 ipc_log (" args: view = %d, experiment = %d\n", arg1, arg2); 1008 Vector<void*>*res = dbeGetFilters (arg1, arg2); 1009 ipc_log (" -- returned %lld Filters\n", VSIZE (res)); 1010 writeArray (res, req); 1011 delete res; 1012 } 1013 1014 else if (!strcmp (inp, "updateFilters")) 1015 { 1016 int arg1 = readInt (req); 1017 Vector<bool> *arg2 = (Vector<bool>*)readArray (req); 1018 Vector<String> *arg3 = (Vector<String>*)readArray (req); 1019 ipc_log ("arg1=%d arg2->size()=%lld arg3->size()=%lld\n", 1020 arg1, VSIZE (arg2), VSIZE (arg3)); 1021 ipc_dump ("arg2", arg2); 1022 ipc_dump ("arg3", arg3); 1023 bool b = dbeUpdateFilters (arg1, arg2, arg3); 1024 writeBoolean (b, req); 1025 ipc_log (" returns %s\n", (b == true ? "true" : "false")); 1026 delete arg2; 1027 delete arg3; 1028 } 1029 else if (!strcmp (inp, "getLoadObjectState")) 1030 { 1031 int arg1 = readInt (req); 1032 ipc_log (" args = %d \n", arg1); 1033 Vector<int> *res = dbeGetLoadObjectState (arg1); 1034 ipc_log (" returning = %lld int's\n", VSIZE (res)); 1035 writeArray (res, req); 1036 delete res; 1037 } 1038 else if (!strcmp (inp, "setLoadObjectState")) 1039 { 1040 int arg1 = readInt (req); 1041 Vector<int> *arg2 = (Vector<int>*)readArray (req); 1042 ipc_log (" args = %d, %lld objects\n", arg1, VSIZE (arg2)); 1043 dbeSetLoadObjectState (arg1, arg2); 1044 writeString (NULL, req); 1045 delete arg2; 1046 } 1047 else if (!strcmp (inp, "setLoadObjectDefaults")) 1048 { 1049 int arg1 = readInt (req); 1050 ipc_log (" args = %d\n", arg1); 1051 dbeSetLoadObjectDefaults (arg1); 1052 writeString (NULL, req); 1053 } 1054 else if (!strcmp (inp, "getMemTabSelectionState")) 1055 { 1056 int arg1 = readInt (req); 1057 ipc_log (" arg = %d\n", arg1); 1058 Vector<bool> *res = dbeGetMemTabSelectionState (arg1); 1059 writeArray (res, req); 1060 destroy (res); 1061 } 1062 else if (!strcmp (inp, "setMemTabSelectionState")) 1063 { 1064 int arg1 = readInt (req); 1065 Vector<bool> *arg2 = (Vector<bool> *)readArray (req); 1066 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2)); 1067 dbeSetMemTabSelectionState (arg1, arg2); 1068 writeString (NULL, req); 1069 destroy (arg2); 1070 } 1071 else if (!strcmp (inp, "getIndxTabSelectionState")) 1072 { 1073 int arg1 = readInt (req); 1074 ipc_log (" arg = %d\n", arg1); 1075 Vector<bool> *res = dbeGetIndxTabSelectionState (arg1); 1076 ipc_log (" -- returned %lld-vector [bool]\n", VSIZE (res)); 1077 writeArray (res, req); 1078 destroy (res); 1079 } 1080 else if (!strcmp (inp, "setIndxTabSelectionState")) 1081 { 1082 int arg1 = readInt (req); 1083 Vector<bool> *arg2 = (Vector<bool> *)readArray (req); 1084 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2)); 1085 dbeSetIndxTabSelectionState (arg1, arg2); 1086 writeString (NULL, req); 1087 destroy (arg2); 1088 } 1089 else if (!strcmp (inp, "getTabSelectionState")) 1090 { 1091 int arg1 = readInt (req); 1092 ipc_log (" args = %d\n", arg1); 1093 Vector<bool> *res = dbeGetTabSelectionState (arg1); 1094 writeArray (res, req); 1095 delete res; 1096 } 1097 else if (!strcmp (inp, "setTabSelectionState")) 1098 { 1099 int arg1 = readInt (req); 1100 Vector<bool> *arg2 = (Vector<bool>*)readArray (req); 1101 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2)); 1102 dbeSetTabSelectionState (arg1, arg2); 1103 writeString (NULL, req); 1104 delete arg2; 1105 } 1106 else if (!strcmp (inp, "getMemObjects")) 1107 { 1108 int arg1 = readInt (req); 1109 ipc_log (" args = %d\n", arg1); 1110 Vector<void*> *res = dbeGetMemObjects (arg1); 1111 1112 #ifdef IPC_LOG 1113 if (res == NULL) 1114 ipc_log (" -- returned NULL\n"); 1115 else 1116 { 1117 Vector<int> *mo_types = (Vector<int> *)res->fetch (0); 1118 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n", 1119 VSIZE (res), VSIZE (mo_types)); 1120 } 1121 #endif 1122 writeArray (res, req); 1123 destroy (res); 1124 } 1125 else if (!strcmp (inp, "loadMachineModel")) 1126 { 1127 String arg1 = readString (req); 1128 #ifdef IPC_LOG 1129 ipc_log (" arg = `%s'\n", arg1); 1130 #endif 1131 String sts = dbeLoadMachineModel (arg1); 1132 #ifdef IPC_LOG 1133 ipc_log (" returns '%s'\n", sts ? sts : "NULL"); 1134 #endif 1135 writeString (sts, req); 1136 free (arg1); 1137 } 1138 else if (!strcmp (inp, "getMachineModel")) 1139 { 1140 String sts = dbeGetMachineModel (); 1141 #ifdef IPC_LOG 1142 ipc_log (" returns '%s'\n", sts ? sts : "NULL"); 1143 #endif 1144 writeString (sts, req); 1145 } 1146 else if (!strcmp (inp, "getCPUVerMachineModel")) 1147 { 1148 int arg1 = readInt (req); 1149 ipc_log (" args = %d\n", arg1); 1150 Vector<char*> *res = dbeGetCPUVerMachineModel (arg1); 1151 writeArray (res, req); 1152 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1153 destroy (res); 1154 } 1155 else if (!strcmp (inp, "listMachineModels")) 1156 { 1157 Vector<String> *res = dbeListMachineModels (); 1158 #ifdef IPC_LOG 1159 if (res != NULL) 1160 ipc_log (" returns = %lld strings\n", VSIZE (res)); 1161 else 1162 ipc_log (" returns NULL\n"); 1163 #endif 1164 writeArray (res, req); 1165 destroy (res); 1166 } 1167 else if (!strcmp (inp, "defineMemObj")) 1168 { 1169 String arg1 = readString (req); 1170 String arg2 = readString (req); 1171 String arg3 = readString (req); 1172 String arg4 = readString (req); 1173 #ifdef IPC_LOG 1174 ipc_log (" args = %s, %s, %s, %s\n", arg1, arg2, arg3 == NULL ? "NULL" : arg3, arg4 == NULL ? "NULL" : arg4); 1175 #endif 1176 String sts = dbeDefineMemObj (arg1, arg2, NULL, arg3, arg4); 1177 #ifdef IPC_LOG 1178 ipc_log (" returns '%s'\n", sts ? sts : "NULL"); 1179 #endif 1180 writeString (sts, req); 1181 free (arg1); 1182 free (arg2); 1183 free (arg3); 1184 free (arg4); 1185 } 1186 else if (!strcmp (inp, "deleteMemObj")) 1187 { 1188 String arg1 = readString (req); 1189 #ifdef IPC_LOG 1190 ipc_log (" args = %s\n", arg1); 1191 #endif 1192 String sts = dbeDeleteMemObj (arg1); 1193 #ifdef IPC_LOG 1194 ipc_log (" returns '%s'\n", sts ? sts : "NULL"); 1195 #endif 1196 writeString (sts, req); 1197 free (arg1); 1198 } 1199 else if (!strcmp (inp, "getIndxObjDescriptions")) 1200 { 1201 int arg1 = readInt (req); 1202 ipc_log (" args = %d\n", arg1); 1203 Vector<void*> *res = dbeGetIndxObjDescriptions (arg1); 1204 #ifdef IPC_LOG 1205 if (res == NULL) 1206 ipc_log (" -- returned NULL\n"); 1207 else 1208 { 1209 Vector<int> *indxo_types = (Vector<int> *)res->fetch (0); 1210 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n", 1211 VSIZE (res), VSIZE (indxo_types)); 1212 } 1213 #endif 1214 writeArray (res, req); 1215 destroy (res); 1216 } 1217 else if (!strcmp (inp, "getCustomIndxObjects")) 1218 { 1219 int arg1 = readInt (req); 1220 ipc_log (" args = %d\n", arg1); 1221 Vector<void*> *res = dbeGetCustomIndxObjects (arg1); 1222 #ifdef IPC_LOG 1223 if (res == NULL) 1224 ipc_log (" -- returned NULL\n"); 1225 else 1226 { 1227 Vector<char *> *indxo_names = (Vector<char *> *)res->fetch (0); 1228 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n", 1229 VSIZE (res), VSIZE (indxo_names)); 1230 } 1231 #endif 1232 writeArray (res, req); 1233 destroy (res); 1234 } 1235 else if (!strcmp (inp, "defineIndxObj")) 1236 { 1237 String arg1 = readString (req); 1238 String arg2 = readString (req); 1239 String arg3 = readString (req); 1240 String arg4 = readString (req); 1241 ipc_log (" args = %s, %s, %s, %s\n", arg1, arg2, arg3 == NULL ? "NULL" : arg3, arg4 == NULL ? "NULL" : arg4); 1242 String sts = dbeDefineIndxObj (arg1, arg2, arg3, arg4); 1243 ipc_log (" returns '%s'\n", sts ? sts : "NULL"); 1244 writeString (sts, req); 1245 free (arg1); 1246 free (arg2); 1247 free (arg3); 1248 free (arg4); 1249 } 1250 else if (!strcmp (inp, "setSelObj")) 1251 { 1252 int arg1 = readInt (req); 1253 Obj arg2 = readObject (req); 1254 int arg3 = readInt (req); 1255 int arg4 = readInt (req); 1256 ipc_log (" args = %d, %ld, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4); 1257 dbeSetSelObj (arg1, arg2, arg3, arg4); 1258 writeString (NULL, req); 1259 } 1260 else if (!strcmp (inp, "setSelObjV2")) 1261 { 1262 int arg1 = readInt (req); 1263 uint64_t arg2 = readLong (req); 1264 ipc_log (" args = %d, %lld\n", arg1, (long long) arg2); 1265 dbeSetSelObjV2 (arg1, arg2); 1266 writeString (NULL, req); 1267 } 1268 else if (!strcmp (inp, "getSelObj")) 1269 { 1270 int arg1 = readInt (req); 1271 int arg2 = readInt (req); 1272 int arg3 = readInt (req); 1273 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3); 1274 Obj i = dbeGetSelObj (arg1, arg2, arg3); 1275 ipc_log (" returns = %ld (0x%08lx)\n", (long) i, (long) i); 1276 writeObject (i, req); 1277 } 1278 else if (!strcmp (inp, "getSelObjV2")) 1279 { 1280 int arg1 = readInt (req); 1281 String arg2 = readString (req); 1282 ipc_log (" arg1 = %d agr2 = %s\n", arg1, arg2 ? arg2 : "NULL"); 1283 Obj res = dbeGetSelObjV2 (arg1, arg2); 1284 ipc_log (" returns = %lld\n", (long long) res); 1285 writeObject (res, req); 1286 free (arg2); 1287 } 1288 else if (!strcmp (inp, "getSelObjIO")) 1289 { 1290 int arg1 = readInt (req); 1291 uint64_t arg2 = readLong (req); 1292 int arg3 = readInt (req); 1293 ipc_log (" arg1 = %d, arg2 = %lld, arg3 = %d\n", arg1, (long long) arg2, arg3); 1294 Vector<uint64_t> *res = dbeGetSelObjIO (arg1, arg2, arg3); 1295 writeArray (res, req); 1296 delete res; 1297 } 1298 else if (!strcmp (inp, "getSelObjsIO")) 1299 { 1300 int arg1 = readInt (req); 1301 Vector<uint64_t> *arg2 = (Vector<uint64_t>*)readArray (req); 1302 int arg3 = readInt (req); 1303 ipc_log (" arg1 = %d, arg2 size = %lld, arg3 = %d\n", 1304 arg1, VSIZE (arg2), arg3); 1305 Vector<uint64_t> *res = dbeGetSelObjsIO (arg1, arg2, arg3); 1306 writeArray (res, req); 1307 delete res; 1308 } 1309 else if (!strcmp (inp, "getSelObjHeapTimestamp")) 1310 { 1311 int arg1 = readInt (req); 1312 uint64_t arg2 = readLong (req); 1313 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2); 1314 uint64_t st = dbeGetSelObjHeapTimestamp (arg1, arg2); 1315 ipc_log (" returns = %llu\n", (unsigned long long) st); 1316 writeLong (st, req); 1317 } 1318 else if (!strcmp (inp, "getSelObjHeapUserExpId")) 1319 { 1320 int arg1 = readInt (req); 1321 uint64_t arg2 = readLong (req); 1322 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2); 1323 int userExpId = dbeGetSelObjHeapUserExpId (arg1, arg2); 1324 ipc_log (" returns = %d\n", userExpId); 1325 writeInt (userExpId, req); 1326 } 1327 else if (!strcmp (inp, "getSelIndex")) 1328 { 1329 int arg1 = readInt (req); 1330 Obj arg2 = readObject (req); 1331 int arg3 = readInt (req); 1332 int arg4 = readInt (req); 1333 ipc_log (" args = %d, 0x%08lx, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4); 1334 int i = dbeGetSelIndex (arg1, arg2, arg3, arg4); 1335 ipc_log (" returns = %d\n", i); 1336 writeInt (i, req); 1337 } 1338 else if (!strcmp (inp, "printData")) 1339 { 1340 int arg1 = readInt (req); 1341 int arg2 = readInt (req); 1342 int arg3 = readInt (req); 1343 String arg4 = readString (req); 1344 String arg5 = readString (req); 1345 ipc_log (" args = %d, %s, %d, `%s', `%s'\n", 1346 arg1, table_name (arg2), arg3, 1347 (arg4 == NULL ? "NULL" : arg4), 1348 (arg5 == NULL ? "NULL" : arg5)); 1349 String res = dbePrintData (arg1, arg2, arg3, arg4, arg5, NULL); 1350 writeString (res, req); 1351 free (arg4); 1352 free (arg5); 1353 free (res); 1354 } 1355 else if (!strcmp (inp, "getPrintLimit")) 1356 { 1357 int arg1 = readInt (req); 1358 ipc_log (" args = %d\n", arg1); 1359 int i = dbeGetPrintLimit (arg1); 1360 ipc_log (" returns = %d\n", i); 1361 writeInt (i, req); 1362 } 1363 else if (!strcmp (inp, "setPrintLimit")) 1364 { 1365 int arg1 = readInt (req); 1366 int arg2 = readInt (req); 1367 ipc_log (" args = %d, %d\n", arg1, arg2); 1368 String res = dbeSetPrintLimit (arg1, arg2); 1369 writeString (res, req); 1370 free (res); 1371 } 1372 else if (!strcmp (inp, "getPrintMode")) 1373 { 1374 int arg1 = readInt (req); 1375 ipc_log (" args = %d\n", arg1); 1376 int i = dbeGetPrintMode (arg1); 1377 ipc_log (" returns = %d\n", i); 1378 writeInt (i, req); 1379 } 1380 else if (!strcmp (inp, "setPrintMode")) 1381 { 1382 int arg1 = readInt (req); 1383 String arg2 = readString (req); 1384 ipc_log (" args = %d, %s\n", arg1, arg2); 1385 String res = dbeSetPrintMode (arg1, arg2); 1386 writeString (res, req); 1387 free (arg2); 1388 free (res); 1389 } 1390 else if (!strcmp (inp, "getPrintDelim")) 1391 { 1392 int arg1 = readInt (req); 1393 ipc_log (" args = %d\n", arg1); 1394 char i = dbeGetPrintDelim (arg1); 1395 ipc_log (" returns = %c\n", i); 1396 writeInt ((int) i, req); 1397 } 1398 else if (!strcmp (inp, "getHotMarks")) 1399 { 1400 int arg1 = readInt (req); 1401 int arg2 = readInt (req); 1402 ipc_log (" args = %d, %s (%d) \n", arg1, table_name (arg2), arg2); 1403 Vector<void*> *res = dbeGetHotMarks (arg1, arg2); 1404 writeArray (res, req); 1405 destroy (res); 1406 } 1407 else if (!strcmp (inp, "getHotMarksInc")) 1408 { 1409 int arg1 = readInt (req); 1410 int arg2 = readInt (req); 1411 ipc_log (" args = %d, %s (%d) \n", arg1, table_name (arg2), arg2); 1412 Vector<void*> *res = dbeGetHotMarksInc (arg1, arg2); 1413 writeArray (res, req); 1414 destroy (res); 1415 } 1416 else if (!strcmp (inp, "getSummaryHotMarks")) 1417 { 1418 int arg1 = readInt (req); 1419 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req); 1420 int arg3 = readInt (req); 1421 ipc_log (" args = %d, 0x%llx, %s (%d)\n", arg1, (long long) arg2, table_name (arg3), arg3); 1422 Vector<void*> *res = dbeGetSummaryHotMarks (arg1, arg2, arg3); 1423 writeArray (res, req); 1424 destroy (res); 1425 } 1426 else if (!strcmp (inp, "getFuncId")) 1427 { 1428 int arg1 = readInt (req); 1429 int arg2 = readInt (req); 1430 int arg3 = readInt (req); 1431 int arg4 = readInt (req); 1432 ipc_log (" args = %d, %s, %d, %d\n", arg1, table_name (arg2), arg3, arg4); 1433 Vector<uint64_t> *res = dbeGetFuncId (arg1, arg2, arg3, arg4); 1434 writeArray (res, req); 1435 delete res; 1436 } 1437 else if (!strcmp (inp, "getFuncCalleeInfo")) 1438 { 1439 int arg1 = readInt (req); 1440 int arg2 = readInt (req); 1441 Vector<int> *arg3 = (Vector<int>*)readArray (req); 1442 int arg4 = readInt (req); 1443 ipc_log (" args = %d, %s, %lld, %d\n", arg1, table_name (arg2), VSIZE (arg3), arg4); 1444 Vector<void*> *res = dbeGetFuncCalleeInfo (arg1, arg2, arg3, arg4); 1445 writeArray (res, req); 1446 destroy (res); 1447 } 1448 else if (!strcmp (inp, "getFuncCallerInfo")) 1449 { 1450 int arg1 = readInt (req); 1451 int arg2 = readInt (req); 1452 Vector<int> *arg3 = (Vector<int>*)readArray (req); 1453 int arg4 = readInt (req); 1454 ipc_log (" args = %d, %s, %lld, %d\n", arg1, table_name (arg2), VSIZE (arg3), arg4); 1455 Vector<void*> *res = dbeGetFuncCallerInfo (arg1, arg2, arg3, arg4); 1456 writeArray (res, req); 1457 destroy (res); 1458 } 1459 else if (!strcmp (inp, "setFuncData")) 1460 { 1461 int arg1 = readInt (req); 1462 Obj arg2 = readObject (req); 1463 int arg3 = readInt (req); 1464 int arg4 = readInt (req); 1465 ipc_log (" args = %d, %ld, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4); 1466 int i = dbeSetFuncData (arg1, arg2, arg3, arg4); 1467 ipc_log (" returns = %d\n", i); 1468 writeInt (i, req); 1469 } 1470 else if (!strcmp (inp, "setFuncDataV2")) 1471 { 1472 int dbevindex = readInt (req); 1473 Obj sel_obj = readObject (req); 1474 int type = readInt (req); 1475 int subtype = readInt (req); 1476 Vector<long long> *longs = new Vector<long long>(2); 1477 Vector<char *> *strings = new Vector<char *>(2); 1478 1479 longs->append (dbeSetFuncData (dbevindex, sel_obj, type, subtype)); 1480 strings->append (dbeGetMsg (dbevindex, ERROR_MSG)); 1481 String sf_name = NULL; 1482 long long sf_id = 0; 1483 switch (type) 1484 { 1485 case DSP_SOURCE: 1486 case DSP_DISASM: 1487 { 1488 Histable *obj = (Histable *) sel_obj; 1489 if (obj) 1490 { 1491 Histable *sf = obj->convertto (Histable::SOURCEFILE); 1492 if (sf) 1493 { 1494 sf_id = sf->id; 1495 sf_name = dbe_strdup (sf->get_name ()); 1496 } 1497 } 1498 break; 1499 } 1500 } 1501 longs->append (sf_id); 1502 strings->append (sf_name); 1503 ipc_log (" setFuncData(%d, %ld, %s, %d) returns (%lld, %lld)\n (%s, %s)\n", 1504 dbevindex, (long) sel_obj, table_name (type), subtype, longs->get (0), longs->get (1), 1505 STR (strings->get (0)), STR (strings->get (1))); 1506 1507 Vector<void *> *res = new Vector<void *>(2); 1508 res->append (longs); 1509 res->append (strings); 1510 writeArray (res, req); 1511 destroy (res); 1512 } 1513 else if (!strcmp (inp, "getFuncList")) 1514 { 1515 int arg1 = readInt (req); 1516 int arg2 = readInt (req); 1517 int arg3 = readInt (req); 1518 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3); 1519 Vector<void*> *res = dbeGetFuncList (arg1, arg2, arg3); 1520 #ifdef IPC_LOG 1521 if (res != NULL) 1522 ipc_log (" returns = %lld objects, length = %lld\n", 1523 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0))); 1524 else 1525 ipc_log (" returns NULL\n"); 1526 #endif 1527 writeArray (res, req); 1528 destroy (res); 1529 } 1530 else if (!strcmp (inp, "getFuncListV2")) 1531 { 1532 int dbevindex = readInt (req); 1533 int mtype = readInt (req); 1534 Obj sel_obj = readObject (req); 1535 int type = readInt (req); 1536 int subtype = readInt (req); 1537 Vector<void*> *res = dbeGetFuncListV2 (dbevindex, mtype, sel_obj, type, subtype); 1538 ipc_log (" args = %d 0x%x %ld, %s, %d returns = %d objects, length = %d\n", 1539 dbevindex, mtype, (long) sel_obj, table_name (type), subtype, 1540 (int) (res ? res->size () : 0), 1541 (int) (res ? ((Vector<int>*)res->fetch (0))->size () : 0)); 1542 writeArray (res, req); 1543 destroy (res); 1544 } 1545 else if (!strcmp (inp, "getFuncListMini")) 1546 { 1547 int arg1 = readInt (req); 1548 int arg2 = readInt (req); 1549 int arg3 = readInt (req); 1550 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3); 1551 Vector<void*> *res = dbeGetFuncListMini (arg1, arg2, arg3); 1552 #ifdef IPC_LOG 1553 if (res != NULL) 1554 ipc_log (" returns = %lld objects, length = %lld\n", 1555 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0))); 1556 else 1557 ipc_log (" returns NULL\n"); 1558 #endif 1559 writeArray (res, req); 1560 destroy (res); 1561 } 1562 else if (!strcmp (inp, "dbeGetTotals")) 1563 { 1564 int dbevindex = readInt (req); 1565 int dsptype = readInt (req); 1566 int subtype = readInt (req); 1567 Vector<void *> *res = dbeGetTotals (dbevindex, dsptype, subtype); 1568 ipc_log (" dbeGetTotals(%d, %d, %d) returns %lld objects\n", 1569 dbevindex, dsptype, subtype, VSIZE (res)); 1570 writeArray (res, req); 1571 destroy (res); 1572 } 1573 else if (!strcmp (inp, "getComparableObjsV2")) 1574 { 1575 int arg1 = readInt (req); 1576 Obj arg2 = readObject (req); 1577 int arg3 = readInt (req); 1578 Vector<Obj> *res = dbeGetComparableObjsV2 (arg1, arg2, arg3); 1579 ipc_log (" args = %d 0x%lx %d\n", arg1, (long) arg2, arg3); 1580 ipc_dump ("getComparableObjsV2:res", res); 1581 writeArray (res, req); 1582 destroy (res); 1583 } 1584 else if (!strcmp (inp, "dbeConvertSelObj")) 1585 { 1586 Obj obj = readObject (req); 1587 int type = readInt (req); 1588 Obj res = dbeConvertSelObj (obj, type); 1589 ipc_log (" args = %lld %d res=%lld \n", (long long) obj, type, 1590 (long long) res); 1591 writeObject (res, req); 1592 } 1593 else if (!strcmp (inp, "getTableDataV2")) 1594 { 1595 int arg1 = readInt (req); 1596 String arg2 = readString (req); 1597 String arg3 = readString (req); 1598 String arg4 = readString (req); 1599 String arg5 = readString (req); 1600 Vector<uint64_t> *arg6 = (Vector<uint64_t>*)readArray (req); 1601 ipc_log (" args = %d, %s, %s, %s, %s, %lld\n", arg1, STR (arg2), 1602 STR (arg3), STR (arg4), STR (arg5), VSIZE (arg6)); 1603 Vector<void*> *res = dbeGetTableDataV2 (arg1, arg2, arg3, arg4, arg5, arg6); 1604 #ifdef IPC_LOG 1605 if (res != NULL) 1606 ipc_log (" returns = %lld objects, length = %lld\n", 1607 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0))); 1608 else 1609 ipc_log (" returns NULL\n"); 1610 #endif 1611 writeArray (res, req); 1612 //destroy( arg6 ); 1613 destroy (res); 1614 } 1615 else if (!strcmp (inp, "getCallTreeNumLevels")) 1616 { 1617 int arg1 = readInt (req); 1618 ipc_log (" args = %d\n", arg1); 1619 int res = dbeGetCallTreeNumLevels (arg1); 1620 #ifdef IPC_LOG 1621 ipc_log (" returns = %d\n", res); 1622 #endif 1623 writeInt (res, req); 1624 } 1625 else if (!strcmp (inp, "getCallTreeLevel")) 1626 { 1627 int arg1 = readInt (req); 1628 String arg2 = readString (req); 1629 int arg3 = readInt (req); 1630 ipc_log (" args = %d, %s, %d\n", arg1, arg2, arg3); 1631 Vector<void*> *res = dbeGetCallTreeLevel (arg1, arg2, arg3); 1632 writeArray (res, req); 1633 destroy (res); 1634 } 1635 else if (!strcmp (inp, "getCallTreeChildren")) 1636 { 1637 int arg1 = readInt (req); 1638 String arg2 = readString (req); 1639 Vector<int> *arg3 = (Vector<int> *) readArray (req); /*NodeIdx array*/ 1640 ipc_log (" args = %d, %s, vec_size=%lld\n", arg1, arg2, (long long) (arg3 ? arg3->size () : 0)); 1641 Vector<void*> *res = dbeGetCallTreeChildren (arg1, arg2, arg3); 1642 writeArray (res, req); 1643 destroy (res); 1644 } 1645 else if (!strcmp (inp, "getCallTreeLevels")) 1646 { 1647 int arg1 = readInt (req); 1648 String arg2 = readString (req); 1649 ipc_log (" args = %d, %s\n", arg1, arg2); 1650 Vector<void*> *res = dbeGetCallTreeLevels (arg1, arg2); 1651 writeArray (res, req); 1652 destroy (res); 1653 } 1654 else if (!strcmp (inp, "getCallTreeLevelFuncs")) 1655 { 1656 int arg1 = readInt (req); 1657 int arg2 = readInt (req); 1658 int arg3 = readInt (req); 1659 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3); 1660 Vector<void*> *res = dbeGetCallTreeLevelFuncs (arg1, arg2, arg3); 1661 writeArray (res, req); 1662 destroy (res); 1663 } 1664 else if (!strcmp (inp, "getCallTreeFuncs")) 1665 { 1666 int arg1 = readInt (req); 1667 ipc_log (" args = %d\n", arg1); 1668 Vector<void*> *res = dbeGetCallTreeFuncs (arg1); 1669 writeArray (res, req); 1670 destroy (res); 1671 } 1672 else if (!strcmp (inp, "getGroupIds")) 1673 { 1674 int arg1 = readInt (req); 1675 Vector<int> *res = dbeGetGroupIds (arg1); 1676 writeArray (res, req); 1677 delete res; 1678 } 1679 else if (!strcmp (inp, "getNames")) 1680 { 1681 int arg1 = readInt (req); 1682 int arg2 = readInt (req); 1683 Obj arg3 = readObject (req); 1684 #ifdef IPC_LOG 1685 ipc_log (" args = %d, %s 0x%lx\n", arg1, table_name (arg2), (long) arg3); 1686 #endif 1687 Vector<String> *res = dbeGetNames (arg1, arg2, arg3); 1688 writeArray (res, req); 1689 destroy (res); 1690 } 1691 else if (!strcmp (inp, "getTotalMax")) 1692 { 1693 int arg1 = readInt (req); 1694 int arg2 = readInt (req); 1695 int arg3 = readInt (req); 1696 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3); 1697 Vector<void*> *res = dbeGetTotalMax (arg1, arg2, arg3); 1698 #ifdef IPC_LOG 1699 if (res != NULL) 1700 ipc_log (" returns = %lld vectors, length %lld\n", 1701 VSIZE (res), VSIZE ((Vector<void*>*)res->fetch (0))); 1702 else 1703 ipc_log (" returns NULL\n"); 1704 #endif 1705 writeArray (res, req); 1706 destroy (res); 1707 } 1708 else if (!strcmp (inp, "composeFilterClause")) 1709 { 1710 int arg1 = readInt (req); 1711 int arg2 = readInt (req); 1712 int arg3 = readInt (req); 1713 Vector<int> *arg4 = (Vector<int>*)readArray (req); 1714 ipc_log (" args = %d, %s, %d, %lld selections\n", 1715 arg1, table_name (arg2), arg3, VSIZE (arg4)); 1716 String s = dbeComposeFilterClause (arg1, arg2, arg3, arg4); 1717 ipc_log (" returns %s\n", (s == NULL ? "<NULL>" : s)); 1718 writeString (s, req); 1719 } 1720 else if (!strcmp (inp, "getStatisOverviewList")) 1721 { 1722 int arg1 = readInt (req); 1723 ipc_log (" args = %d\n", arg1); 1724 Vector<Object> *res = dbeGetStatisOverviewList (arg1); 1725 ipc_log (" dbeStatisGetOverviewList returns = %lld objects\n", VSIZE (res)); 1726 writeArray (res, req); 1727 destroy (res); 1728 } 1729 else if (!strcmp (inp, "getStatisList")) 1730 { 1731 int arg1 = readInt (req); 1732 ipc_log (" args = %d\n", arg1); 1733 Vector<Object> *res = dbeGetStatisList (arg1); 1734 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1735 writeArray (res, req); 1736 destroy (res); 1737 } 1738 else if (!strcmp (inp, "getSummary")) 1739 { 1740 int arg1 = readInt (req); 1741 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req); 1742 int arg3 = readInt (req); 1743 int arg4 = readInt (req); 1744 ipc_log (" args = %d, 0x%llx, %s (%d), %d\n", arg1, (long long) arg2, table_name (arg3), arg3, arg4); 1745 Vector<Object> *res = dbeGetSummary (arg1, arg2, arg3, arg4); 1746 ipc_log (" dbeGetSummary returns = %lld objects\n", VSIZE (res)); 1747 writeArray (res, req); 1748 destroy (res); 1749 } 1750 else if (!strcmp (inp, "getSummaryV2")) 1751 { 1752 int dbevindex = readInt (req); 1753 Vector<Obj> *sel_objs = (Vector<Obj>*)readArray (req); 1754 int type = readInt (req); 1755 int subtype = readInt (req); 1756 Vector<void*> *res = dbeGetSummaryV2 (dbevindex, sel_objs, type, subtype); 1757 ipc_log (" args = %d, [%lld], %s (%d), %d res=[%lld] 0x%llx \n", 1758 dbevindex, VSIZE (sel_objs), table_name (type), type, subtype, 1759 VSIZE (res), (unsigned long long) res); 1760 writeArray (res, req); 1761 destroy (res); 1762 } 1763 else if (!strcmp (inp, "getExpName1")) 1764 { 1765 // XXX add an argument = DbeView index 1766 String arg1 = readString (req); 1767 ipc_log (" arg = `%s'\n", arg1 ? arg1 : "NULL"); 1768 String res = dbeGetExpName (0, arg1); 1769 writeString (res, req); 1770 ipc_log (" returns `%s'\n", res ? res : "NULL"); 1771 free (arg1); 1772 free (res); 1773 } 1774 else if (!strcmp (inp, "getHwcHelp")) 1775 { 1776 // XXX add an argument = DbeView index 1777 bool forKernel = readBoolean (req); 1778 Vector<String> *res = dbeGetHwcHelp (0, forKernel); 1779 writeArray (res, req); 1780 destroy (res); 1781 } 1782 else if (!strcmp (inp, "getHwcSets")) 1783 { 1784 // XXX add an argument = DbeView index 1785 bool forKernel = readBoolean (req); 1786 Vector<Vector<char*>*> *res = dbeGetHwcSets (0, forKernel); 1787 writeArray (res, req); 1788 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1789 destroy (res); 1790 } 1791 else if (!strcmp (inp, "getHwcsAll")) 1792 { 1793 // XXX add an argument = DbeView index 1794 bool forKernel = readBoolean (req); 1795 Vector<void*> *res = dbeGetHwcsAll (0, forKernel); 1796 writeArray (res, req); 1797 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1798 destroy (res); 1799 } 1800 else if (!strcmp (inp, "getHwcAttrList")) 1801 { 1802 // XXX add an argument = DbeView index 1803 bool forKernel = readBoolean (req); 1804 Vector<char*> *res = dbeGetHwcAttrList (0, forKernel); 1805 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1806 writeArray (res, req); 1807 destroy (res); 1808 } 1809 else if (!strcmp (inp, "getHwcMaxConcurrent")) 1810 { 1811 // XXX add an argument = DbeView index 1812 bool forKernel = readBoolean (req); 1813 int res = dbeGetHwcMaxConcurrent (0, forKernel); 1814 writeInt (res, req); 1815 } 1816 else if (!strcmp (inp, "getIfreqData")) 1817 { 1818 int arg1 = readInt (req); 1819 ipc_log (" args = %d\n", arg1); 1820 Vector<char*> *res = dbeGetIfreqData (arg1); 1821 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1822 writeArray (res, req); 1823 destroy (res); 1824 } 1825 else if (!strcmp (inp, "getNewLeakListInfo")) 1826 { 1827 int arg1 = readInt (req); 1828 bool arg2 = readBoolean (req); 1829 ipc_log (" args = %d, %d\n", arg1, arg2); 1830 Vector<void*> *res = dbeGetLeakListInfo (arg1, arg2); 1831 ipc_log (" returns %lld void*'s\n", VSIZE (res)); 1832 writeArray (res, req); 1833 destroy (res); 1834 } 1835 else if (!strcmp (inp, "getObject")) 1836 { 1837 int arg1 = readInt (req); 1838 Obj arg2 = readObject (req); 1839 Obj arg3 = readObject (req); 1840 Obj i = dbeGetObject (arg1, arg2, arg3); 1841 writeObject (i, req); 1842 } 1843 else if (!strcmp (inp, "getExpVerboseName")) 1844 { 1845 Vector<int> *arg = (Vector<int>*)readArray (req); 1846 ipc_log (" expIds = %lld\n", VSIZE (arg)); 1847 Vector<String> *res = dbeGetExpVerboseName (arg); 1848 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1849 writeArray (res, req); 1850 destroy (res); 1851 } 1852 else if (!strcmp (inp, "getName")) 1853 { 1854 // XXX add an argument = DbeView index 1855 int arg1 = readInt (req); 1856 String res = dbeGetName (0, arg1); 1857 writeString (res, req); 1858 free (res); 1859 } 1860 else if (!strcmp (inp, "getStartTime")) 1861 { 1862 // XXX add an argument = DbeView index 1863 int arg1 = readInt (req); 1864 long long l = dbeGetStartTime (0, arg1); 1865 ipc_log (" returns = %llu\n", l); 1866 writeLong (l, req); 1867 } 1868 else if (!strcmp (inp, "getRelativeStartTime")) 1869 { 1870 // XXX add an argument = DbeView index 1871 int arg1 = readInt (req); 1872 long long l = dbeGetRelativeStartTime (0, arg1); 1873 ipc_log (" returns = %llu\n", l); 1874 writeLong (l, req); 1875 } 1876 else if (!strcmp (inp, "getEndTime")) 1877 { 1878 // XXX add an argument = DbeView index 1879 int arg1 = readInt (req); 1880 long long l = dbeGetEndTime (0, arg1); 1881 ipc_log (" returns = %llu\n", l); 1882 writeLong (l, req); 1883 } 1884 else if (!strcmp (inp, "getClock")) 1885 { 1886 // XXX add an argument = DbeView index 1887 int arg1 = readInt (req); 1888 int i = dbeGetClock (0, arg1); 1889 writeInt (i, req); 1890 } 1891 /* 1892 else if ( !strcmp( inp, "getFounderExpId" ) ) { 1893 // XXX add an argument = DbeView index 1894 int arg1 = readInt(req); 1895 int i = dbeGetFounderExpId(0, arg1 ); 1896 writeInt( i, req ); 1897 } 1898 */ 1899 else if (!strcmp (inp, "getEntityProps")) 1900 { 1901 int arg1 = readInt (req); 1902 ipc_log (" args = %d\n", arg1); 1903 Vector<void*> *res = dbeGetEntityProps (arg1); 1904 writeArray (res, req); 1905 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1906 destroy (res); 1907 } 1908 else if (!strcmp (inp, "getEntities")) 1909 { 1910 int arg1 = readInt (req); 1911 int arg2 = readInt (req); 1912 int arg3 = readInt (req); 1913 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3); 1914 Vector<void*> *res = dbeGetEntities (arg1, arg2, arg3); 1915 writeArray (res, req); 1916 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1917 destroy (res); 1918 } 1919 else if (!strcmp (inp, "getEntitiesV2")) 1920 { 1921 int arg1 = readInt (req); 1922 Vector<int> *arg2 = (Vector<int>*)readArray (req); 1923 int arg3 = readInt (req); 1924 ipc_log (" args = %d, %lld, %d\n", arg1, VSIZE (arg2), arg3); 1925 Vector<void*> *res = dbeGetEntitiesV2 (arg1, arg2, arg3); 1926 writeArray (res, req); 1927 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1928 destroy (res); 1929 } 1930 else if (!strcmp (inp, "getTLDetails")) 1931 {//TBR 1932 int arg1 = readInt (req); 1933 int arg2 = readInt (req); 1934 int arg3 = readInt (req); 1935 int arg4 = readInt (req); 1936 long long arg5 = readLong (req); 1937 ipc_log (" dbevindex= %d, exp_id = %d, data_id = %d, " 1938 "entity_prop_id = %d, event_id = %lld\n", 1939 arg1, arg2, arg3, arg4, arg5); 1940 Vector<void*> *res = dbeGetTLDetails (arg1, arg2, arg3, arg4, arg5); 1941 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1942 writeArray (res, req); 1943 destroy (res); 1944 } 1945 else if (!strcmp (inp, "getStackNames")) 1946 { 1947 int arg1 = readInt (req); 1948 Obj arg2 = readObject (req); 1949 ipc_log (" args = %d, %ld\n", arg1, (long) arg2); 1950 Vector<String> *res = dbeGetStackNames (arg1, arg2); 1951 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1952 writeArray (res, req); 1953 destroy (res); 1954 } 1955 else if (!strcmp (inp, "getStackFunctions")) 1956 { 1957 // XXX add an argument = DbeView index 1958 Obj arg1 = readObject (req); 1959 ipc_log (" args = %ld\n", (long) arg1); 1960 Vector<Obj> *res = dbeGetStackFunctions (0, arg1); 1961 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1962 writeArray (res, req); 1963 delete res; 1964 } 1965 else if (!strcmp (inp, "getStacksFunctions")) 1966 { 1967 // XXX add an argument = DbeView index 1968 Vector<Obj> *arg1 = (Vector<Obj>*)readArray (req); 1969 ipc_log (" argc = %ld\n", (long) arg1->size ()); 1970 Vector<void*> *res = dbeGetStacksFunctions (0, arg1); 1971 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1972 writeArray (res, req); 1973 delete res; 1974 } 1975 else if (!strcmp (inp, "getStackPCs")) 1976 { 1977 // XXX add an argument = DbeView index 1978 Obj arg1 = readObject (req); 1979 ipc_log (" args = %ld\n", (long) arg1); 1980 Vector<Obj> *res = dbeGetStackPCs (0, arg1); 1981 ipc_log (" returns = %lld objects\n", VSIZE (res)); 1982 writeArray (res, req); 1983 delete res; 1984 } 1985 else if (!strcmp (inp, "getIOStatistics")) 1986 { 1987 int dbevindex = readInt (req); 1988 Vector<Vector<char*>*> *res = dbeGetIOStatistics (dbevindex); 1989 writeArray (res, req); 1990 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1991 destroy (res); 1992 } 1993 else if (!strcmp (inp, "getHeapStatistics")) 1994 { 1995 int dbevindex = readInt (req); 1996 Vector<Vector<char*>*> *res = dbeGetHeapStatistics (dbevindex); 1997 writeArray (res, req); 1998 ipc_log (" returns %lld char*'s\n", VSIZE (res)); 1999 destroy (res); 2000 } 2001 else if (!strcmp (inp, "getSamples")) 2002 { 2003 int dbev_id = readInt (req); 2004 int exp_id = readInt (req); 2005 int64_t lo = readLong (req); 2006 int64_t hi = readLong (req); 2007 ipc_log (" dbevindex= %d, exp_id = %d, lo_idx:%lld, hi_idx:%lld\n", 2008 dbev_id, exp_id, (long long) lo, (long long) hi); 2009 Vector<void*> *res = dbeGetSamples (dbev_id, exp_id, lo, hi); 2010 writeArray (res, req); 2011 destroy (res); 2012 } 2013 else if (!strcmp (inp, "getGCEvents")) 2014 { 2015 int dbev_id = readInt (req); 2016 int exp_id = readInt (req); 2017 int64_t lo = readLong (req); 2018 int64_t hi = readLong (req); 2019 ipc_log (" dbevindex= %d, exp_id = %d, lo_idx:%lld, hi_idx:%lld\n", 2020 dbev_id, exp_id, (long long) lo, (long long) hi); 2021 Vector<void*> *res = dbeGetGCEvents (dbev_id, exp_id, lo, hi); 2022 writeArray (res, req); 2023 destroy (res); 2024 } 2025 else if (!strcmp (inp, "getFuncNames")) 2026 { 2027 int arg1 = readInt (req); 2028 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req); 2029 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2)); 2030 Vector<String> *res = dbeGetFuncNames (arg1, arg2); 2031 writeArray (res, req); 2032 delete arg2; 2033 destroy (res); 2034 } 2035 else if (!strcmp (inp, "getFuncIds")) 2036 { 2037 int arg1 = readInt (req); 2038 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req); 2039 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2)); 2040 Vector<uint64_t> *res = dbeGetFuncIds (arg1, arg2); 2041 writeArray (res, req); 2042 delete arg2; 2043 destroy (res); 2044 } 2045 else if (!strcmp (inp, "getObjNamesV2")) 2046 { 2047 int arg1 = readInt (req); 2048 Vector<uint64_t> *arg2 = (Vector<uint64_t>*)readArray (req); 2049 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2)); 2050 Vector<String> *res = dbeGetObjNamesV2 (arg1, arg2); 2051 writeArray (res, req); 2052 delete arg2; 2053 destroy (res); 2054 } 2055 else if (!strcmp (inp, "getFuncName")) 2056 { 2057 int arg1 = readInt (req); 2058 Obj arg2 = readObject (req); 2059 ipc_log (" arg1 = %d, arg2 = %lld\n", arg1, (long long) arg2); 2060 String res = dbeGetFuncName (arg1, arg2); 2061 ipc_log (" returning = %s\n", res ? res : "NULL"); 2062 writeString (res, req); 2063 free (res); 2064 } 2065 else if (!strcmp (inp, "getObjNameV2")) 2066 { 2067 int arg1 = readInt (req); 2068 uint64_t arg2 = readLong (req); 2069 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2); 2070 String res = dbeGetObjNameV2 (arg1, arg2); 2071 ipc_log (" returning = %s\n", res ? res : "NULL"); 2072 writeString (res, req); 2073 free (res); 2074 } 2075 else if (!strcmp (inp, "getDataspaceTypeDesc")) 2076 { 2077 // XXX add an argument = DbeView index 2078 Obj arg1 = readObject (req); 2079 ipc_log (" arg1 absent, index = %ld\n", (long) arg1); 2080 String res = dbeGetDataspaceTypeDesc (0, arg1); 2081 ipc_log (" returning = %s\n", res ? res : "NULL"); 2082 writeString (res, req); 2083 free (res); 2084 } 2085 /* 2086 * New Interface with Timeline 2087 */ 2088 #if 0 //YXXX TBR 2089 else if (!strcmp (inp, "dbeInit")) 2090 dbeInit (); 2091 else if (!strcmp (inp, "getDefaultExperimentName")) 2092 { 2093 String res = dbeGetDefaultExperimentName (); 2094 ipc_log (" returning = %s\n", res); 2095 writeString (res); 2096 free (res); 2097 } 2098 else if (!strcmp (inp, "getExperimentState")) 2099 { 2100 String res = dbeGetExperimentState (); 2101 ipc_log (" returning = %s\n", res); 2102 writeString (res); 2103 free (res); 2104 } 2105 else if (!strcmp (inp, "getExpStartTime")) 2106 { 2107 long long l = dbeGetExpStartTime (); 2108 ipc_log (" returns = %llu\n", l); 2109 writeLong (l); 2110 } 2111 else if (!strcmp (inp, "getExpEndTime")) 2112 { 2113 long long l = dbeGetExpEndTime (); 2114 ipc_log (" returns = %llu\n", l); 2115 writeLong (l); 2116 } 2117 #endif 2118 else if (!strcmp (inp, "getDataDescriptorsV2")) 2119 {//TBR? TBD 2120 int exp_id = readInt (req); 2121 ipc_log (" exp_id = %d\n", exp_id); 2122 Vector<void*> *res = dbeGetDataDescriptorsV2 (exp_id); 2123 ipc_log (" returns = %lld objects\n", VSIZE (res)); 2124 writeArray (res, req); 2125 destroy (res); 2126 } 2127 else if (!strcmp (inp, "getDataPropertiesV2")) 2128 {//TBR? TBD 2129 int exp_id = readInt (req); 2130 int arg2 = readInt (req); 2131 ipc_log (" exp_id = %d, data_idx = %d\n", exp_id, arg2); 2132 Vector<void*> *res = dbeGetDataPropertiesV2 (exp_id, arg2); 2133 ipc_log (" returns = %lld objects\n", VSIZE (res)); 2134 writeArray (res, req); 2135 destroy (res); 2136 } 2137 else if (!strcmp (inp, "getExperimentTimeInfo")) 2138 { 2139 Vector<int> *exp_ids = (Vector<int>*)readArray (req); 2140 ipc_log (" cnt = %lld\n", VSIZE (exp_ids)); 2141 Vector<void*> *res = dbeGetExperimentTimeInfo (exp_ids); 2142 ipc_log (" returns = %lld objects\n", VSIZE (res)); 2143 writeArray (res, req); 2144 destroy (res); 2145 } 2146 else if (!strcmp (inp, "getExperimentDataDescriptors")) 2147 { 2148 Vector<int> *exp_ids = (Vector<int>*)readArray (req); 2149 ipc_log (" cnt = %lld\n", VSIZE (exp_ids)); 2150 Vector<void*> *res = dbeGetExperimentDataDescriptors (exp_ids); 2151 ipc_log (" returns = %lld objects\n", VSIZE (res)); 2152 writeArray (res, req); 2153 destroy (res); 2154 } 2155 #if 0 //YXXX TBR? 2156 else if (!strcmp (inp, "getExprValues")) 2157 {//TBR? TBD 2158 int arg1 = readInt (); 2159 String arg2 = readString (); 2160 ipc_log (" data_idx = %d expr = %s\n", arg1, arg2 ? arg2 : "NULL"); 2161 Vector<long long> *res = dbeGetExprValues (arg1, arg2); 2162 ipc_log (" returns = %d objects\n", res ? res->size () : 0); 2163 writeArray (res); 2164 delete res; 2165 free (arg2); 2166 } 2167 #endif 2168 else if (!strcmp (inp, "hasTLData")) 2169 { 2170 int dbevindex = readInt (req); 2171 Vector<int> *exp_ids = (Vector<int>*)readArray (req); 2172 Vector<int> *data_ids = (Vector<int>*)readArray (req); 2173 Vector<int> *eprop_ids = (Vector<int>*)readArray (req); 2174 Vector<int> *eprop_vals = (Vector<int>*)readArray (req); 2175 Vector<int> *auxs = (Vector<int>*)readArray (req); 2176 ipc_log (" dbev_id = %d, cnt = %lld\n", dbevindex, VSIZE (exp_ids)); 2177 Vector<bool> *res = dbeHasTLData (dbevindex, 2178 exp_ids, data_ids, eprop_ids, eprop_vals, auxs); 2179 writeArray (res, req); 2180 destroy (res); 2181 } 2182 else if (!strcmp (inp, "getTLData")) 2183 { 2184 int dbevindex = readInt (req); 2185 int exp_id = readInt (req); 2186 int tldata_type = readInt (req); 2187 int entity_prop_id = readInt (req); 2188 int entity_prop_val = readInt (req); 2189 int aux = readInt (req); 2190 long long arg5 = readLong (req); 2191 long long arg6 = readLong (req); 2192 int arg7 = readInt (req); 2193 bool getReps = readBoolean (req); 2194 Vector<String> *secondaryProps = (Vector<String>*)readArray (req); 2195 2196 ipc_log (" args = %d:%d; tldata_type=%d entity_prop_id=%d ent=%d aux=%d" 2197 "\n tstart=%lld delta=%lld ndeltas=%d getReps=%d nProps=%lld\n", 2198 dbevindex, exp_id, 2199 tldata_type, entity_prop_id, entity_prop_val, aux, 2200 arg5, arg6, arg7, (int) getReps, VSIZE (secondaryProps)); 2201 Vector<void*> *res = dbeGetTLData (dbevindex, exp_id, 2202 tldata_type, entity_prop_id, entity_prop_val, aux, 2203 arg5, arg6, arg7, getReps, secondaryProps); 2204 #ifdef IPC_LOG 2205 if (res) 2206 { 2207 Vector<Obj> *reps = (Vector<Obj>*)res->fetch (0); 2208 Vector<Obj> *props = (Vector<Obj>*)res->fetch (1); 2209 if (reps) 2210 { 2211 Vector <long long> *fids = (Vector <long long> *)reps->fetch (2); 2212 int sz = fids ? fids->size () : 0; 2213 ipc_log (" returning TL reps (dDscrs); nreps=%d:", sz); 2214 int i; 2215 for (i = 0; i < sz && i < 7; i++) 2216 ipc_log (" %lld", fids->fetch (i)); 2217 if (i < sz) 2218 ipc_log (" ... %lld", fids->fetch (sz - 1)); 2219 ipc_log ("\n"); 2220 } 2221 if (props) 2222 { 2223 int nprops = props->size (); 2224 ipc_log (" returning values for %d properties:\n", nprops); 2225 assert (secondaryProps->size () == nprops); 2226 } 2227 } 2228 else 2229 ipc_log (" returning NULL\n"); 2230 #endif 2231 writeArray (res, req); 2232 destroy (res); 2233 destroy (secondaryProps); 2234 } 2235 else if (!strcmp (inp, "getTLEventCenterTime")) 2236 { 2237 int dbevindex = readInt (req); 2238 int exp_id = readInt (req); 2239 int tldata_type = readInt (req); 2240 int entity_prop_id = readInt (req); 2241 int entity_prop_val = readInt (req); 2242 int aux = readInt (req); 2243 long long event_id = readLong (req); 2244 long long move_count = readLong (req); 2245 ipc_log (" args = %d:%d; tldata_type = %d entity_prop_id = %d " 2246 "ent = %d aux = %d idx = %lld move=%lld\n", 2247 dbevindex, exp_id, 2248 tldata_type, entity_prop_id, entity_prop_val, aux, event_id, move_count); 2249 Vector<long long> * res = dbeGetTLEventCenterTime (dbevindex, exp_id, 2250 tldata_type, entity_prop_id, entity_prop_val, aux, event_id, move_count); 2251 ipc_log (" returning idx = %lld, time = %lld\n", 2252 res ? res->fetch (0) : -1, res ? res->fetch (1) : -1); 2253 writeArray (res, req); 2254 } 2255 else if (!strcmp (inp, "getTLEventIdxNearTime")) 2256 { 2257 int dbevindex = readInt (req); 2258 int exp_id = readInt (req); 2259 int tldata_type = readInt (req); 2260 int entity_prop_id = readInt (req); 2261 int entity_prop_val = readInt (req); 2262 int aux = readInt (req); 2263 int searchDirection = readInt (req); 2264 long long value = readLong (req); 2265 ipc_log (" args = %d:%d; tldata_type = %d entity_prop_id = %d " 2266 "ent = %d aux = %d direction = %d value = %lld(0x%llx)\n", 2267 dbevindex, exp_id, 2268 tldata_type, entity_prop_id, entity_prop_val, aux, 2269 searchDirection, value, value); 2270 long long res = dbeGetTLEventIdxNearTime (dbevindex, exp_id, 2271 tldata_type, entity_prop_id, entity_prop_val, aux, 2272 searchDirection, value); 2273 ipc_log (" returning = %lld\n", res); 2274 writeLong (res, req); 2275 } 2276 else if (!strcmp (inp, "getAggregatedValue")) 2277 { 2278 int arg1 = readInt (req); 2279 String arg2 = readString (req); 2280 String arg3 = readString (req); 2281 String arg4 = readString (req); 2282 long long arg5 = readLong (req); 2283 long long arg6 = readLong (req); 2284 int arg7 = readInt (req); 2285 String arg8 = readString (req); 2286 String arg9 = readString (req); 2287 ipc_log (" data_idx = %d lfilter = \"%s\" fexpr = \"%s\" " 2288 "time = \"%s\" tstart = %lld delta = %lld " 2289 "num = %d key = \"%s\" aggr = \"%s\"\n", 2290 arg1, arg2 ? arg2 : "NULL", arg3 ? arg3 : "NULL", 2291 arg4 ? arg4 : "NULL", arg5, arg6, 2292 arg7, arg8 ? arg8 : "NULL", arg9 ? arg9 : "NULL"); 2293 Vector<long long> *res = dbeGetAggregatedValue (arg1, arg2, arg3, 2294 arg4, arg5, arg6, arg7, arg8, arg9); 2295 #ifdef IPC_LOG 2296 if (res) 2297 { 2298 int sz = res->size (); 2299 ipc_log (" returning = %d values:", sz); 2300 if (sz > 10) 2301 sz = 10; 2302 for (int i = 0; i < sz; i++) 2303 ipc_log (" %lld", res->fetch (i)); 2304 ipc_log ("\n"); 2305 } 2306 else 2307 ipc_log (" returning NULL\n"); 2308 #endif 2309 writeArray (res, req); 2310 delete res; 2311 free (arg2); 2312 free (arg3); 2313 free (arg4); 2314 free (arg8); 2315 free (arg9); 2316 } 2317 #if 0//YXXX TBR 2318 else if (!strcmp (inp, "getExprValue")) 2319 { 2320 int exp_id = readInt (); 2321 int arg1 = readInt (); 2322 int arg2 = readInt (); 2323 String arg3 = readString (); 2324 ipc_log (" exp_id %d, data_id = %d, event_id = %d, expr = %s\n", 2325 exp_id, arg1, arg2, arg3 ? arg3 : "NULL"); 2326 String res = dbeGetExprValue (exp_id, arg1, arg2, arg3); 2327 ipc_log (" returning = %s\n", res ? res : ""); 2328 writeString (res); 2329 free (res); 2330 free (arg3); 2331 } 2332 else if (!strcmp (inp, "getListValues")) 2333 { 2334 Obj arg1 = readObject (); 2335 ipc_log (" stack = %lu\n", (long) arg1); 2336 Vector<Obj> *res = dbeGetListValues (arg1); 2337 ipc_log (" returns = %d objects\n", res ? res->size () : 0); 2338 writeArray (res); 2339 destroy (res); 2340 } 2341 else if (!strcmp (inp, "getListNames")) 2342 { 2343 Obj arg1 = readObject (); 2344 ipc_log (" stack = %lu\n", (long) arg1); 2345 Vector<String> *res = dbeGetListNames (arg1); 2346 ipc_log (" returns = %d objects\n", res ? res->size () : 0); 2347 writeArray (res); 2348 destroy (res); 2349 } 2350 #endif 2351 else if (!strcmp (inp, "getLineInfo")) 2352 { 2353 Obj arg1 = readObject (req); 2354 ipc_log (" pc = %lu\n", (long) arg1); 2355 Vector<String> *res = dbeGetLineInfo (arg1); 2356 ipc_log (" returning File name: '%s'\n", res ? res->fetch (0) : ""); 2357 ipc_log (" returning Lineno: '%s'\n", res ? res->fetch (1) : ""); 2358 writeArray (res, req); 2359 destroy (res); 2360 } 2361 else if (!strcmp (inp, "setAlias")) 2362 { 2363 String arg1 = readString (req); 2364 String arg2 = readString (req); 2365 String arg3 = readString (req); 2366 ipc_log (" name=\"%s\" uname=\"%s\" expr=\"%s\"\n", 2367 arg1 ? arg1 : "", arg2 ? arg2 : "", arg3 ? arg3 : ""); 2368 int res = dbeSetAlias (arg1, arg2, arg3); 2369 ipc_log (" returning = %d\n", res); 2370 writeInt (res, req); 2371 } 2372 else if (!strcmp (inp, "getAlias")) 2373 { 2374 String arg1 = readString (req); 2375 ipc_log (" name=\"%s\"\n", arg1 ? arg1 : ""); 2376 Vector<char*> *res = dbeGetAlias (arg1); 2377 ipc_log (" returning uname: '%s'\n", res && res->fetch (0) ? res->fetch (0) : ""); 2378 ipc_log (" returning expr: '%s'\n", res && res->fetch (1) ? res->fetch (0) : ""); 2379 writeArray (res, req); 2380 destroy (res); 2381 } 2382 else if (!strcmp (inp, "getXYPlotData")) 2383 { 2384 int arg1 = readInt (req); 2385 String arg2 = readString (req); 2386 String arg3 = readString (req); 2387 String arg4 = readString (req); 2388 String arg5 = readString (req); 2389 String arg6 = readString (req); 2390 String arg7 = readString (req); 2391 String arg8 = readString (req); 2392 String arg9 = readString (req); 2393 ipc_log (" data_idx = %d lfilter = \"%s\" arg = \"%s\" " 2394 "func1 = \"%s\" aggr1 = \"%s\" " 2395 "func2 = \"%s\" aggr2 = \"%s\" " 2396 "func3 = \"%s\" aggr3 = \"%s\" \n", 2397 arg1, arg2 ? arg2 : "NULL", arg3 ? arg3 : "NULL", 2398 arg4 ? arg4 : "NULL", arg5 ? arg5 : "NULL", arg6 ? arg6 : "NULL", 2399 arg7 ? arg7 : "NULL", arg8 ? arg8 : "NULL", arg9 ? arg9 : "NULL"); 2400 Vector<Vector<long long>*> *res = dbeGetXYPlotData (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); 2401 2402 #ifdef IPC_LOG 2403 if (res) 2404 { 2405 long nvals = res->size (); 2406 for (long i = 0; i < nvals; ++i) 2407 { 2408 Vector<long long> *vals = res->fetch (i); 2409 long long sz = VSIZE (vals); 2410 ipc_log (" returning = %lld values:", sz); 2411 if (sz > 10) 2412 sz = 10; 2413 for (long j = 0; j < sz; j++) 2414 ipc_log (" %lld", vals->fetch (j)); 2415 ipc_log ("\n"); 2416 } 2417 } 2418 else 2419 ipc_log (" returning NULL\n"); 2420 #endif 2421 writeArray (res, req); 2422 destroy (res); 2423 } 2424 else if (strcmp (inp, "dbe_archive") == 0) 2425 { 2426 Vector<long long> *ids = (Vector<long long> *) readArray (req); 2427 Vector<const char*> *locations = (Vector<const char*> *) readArray (req); 2428 dbe_archive (ids, locations); 2429 delete ids; 2430 destroy (locations); 2431 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, req->getRequestID (), req->getChannelID ()); 2432 } 2433 else if (strcmp (inp, "dbeSetLocations") == 0) 2434 { 2435 Vector<const char*> *fnames = (Vector<const char*> *) readArray (req); 2436 Vector<const char*> *locations = (Vector<const char*> *) readArray (req); 2437 dbeSetLocations (fnames, locations); 2438 destroy (fnames); 2439 destroy (locations); 2440 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, req->getRequestID (), req->getChannelID ()); 2441 } 2442 else if (strcmp (inp, "dbeResolvedWith_setpath") == 0) 2443 { 2444 char *path = readString (req); 2445 Vector<void *> *res = dbeResolvedWith_setpath (path); 2446 free (path); 2447 writeArray (res, req); 2448 destroy (res); 2449 } 2450 else if (strcmp (inp, "dbeResolvedWith_pathmap") == 0) 2451 { 2452 char *old_prefix = readString (req); 2453 char *new_prefix = readString (req); 2454 Vector<void *> *res = dbeResolvedWith_pathmap (old_prefix, new_prefix); 2455 free (old_prefix); 2456 free (new_prefix); 2457 writeArray (res, req); 2458 destroy (res); 2459 } 2460 else if (!strcmp (inp, "getCollectorControlValue")) 2461 { 2462 /* int dbevindex =*/ readInt (req); 2463 char *control = readString (req); 2464 ipc_log (" args = %s\n", control); 2465 char *ret = dbeGetCollectorControlValue (control); 2466 ipc_log (" returning %s\n", STR (ret)); 2467 writeString (ret, req); 2468 } 2469 else if (!strcmp (inp, "setCollectorControlValue")) 2470 { 2471 /* int dbevindex =*/ readInt (req); 2472 char *control = readString (req); 2473 char *value = readString (req); 2474 #ifdef IPC_LOG 2475 ipc_log (" args = %s %s\n", control, value); 2476 #endif 2477 char *ret = dbeSetCollectorControlValue (control, value); 2478 #ifdef IPC_LOG 2479 if (ret) 2480 ipc_log (" returning %s\n", ret); 2481 else 2482 ipc_log (" returning NULL\n"); 2483 #endif 2484 writeString (ret, req); 2485 } 2486 else if (!strcmp (inp, "unsetCollectorControlValue")) 2487 { 2488 /* int dbevindex =*/ readInt (req); 2489 char *control = readString (req); 2490 ipc_log (" args = %s\n", control); 2491 char *ret = dbeUnsetCollectorControlValue (control); 2492 ipc_log (" returning %s\n", STR (ret)); 2493 writeString (ret, req); 2494 } 2495 else if (!strcmp (inp, "getSignalValue")) 2496 { 2497 String arg1 = readString (req); 2498 ipc_log (" arg1=\"%s\"\n", arg1 ? arg1 : ""); 2499 int res = dbeGetSignalValue (arg1); 2500 ipc_log (" returning = %d\n", res); 2501 writeInt (res, req); 2502 } 2503 else if (!strcmp (inp, "sendSignal")) 2504 { 2505 long long p = readLong (req); 2506 int signum = readInt (req); 2507 ipc_log (" args = %llu, %d\n", (long long) p, signum); 2508 char * ret = dbeSendSignal ((pid_t) p, signum); 2509 #ifdef IPC_LOG 2510 if (ret) 2511 ipc_log (" returning %s\n", ret); 2512 else 2513 ipc_log (" returning NULL\n"); 2514 #endif 2515 writeString (ret, req); 2516 } 2517 else if (!strcmp (inp, "checkConnection")) 2518 { 2519 String arg1 = readString (req); 2520 ipc_log (" arg = `%s'\n", arg1 ? arg1 : "NULL"); 2521 String res = dbeCheckConnection (arg1); 2522 writeString (res, req); 2523 ipc_log (" returns `%s'\n", res ? res : "NULL"); 2524 free (arg1); 2525 free (res); 2526 } 2527 else if (!strcmp (inp, "QUIT")) 2528 { 2529 #ifdef IPC_LOG 2530 ipc_log (" %s\n", inp); 2531 #endif 2532 exit (0); 2533 } 2534 else 2535 { 2536 ipc_log ("Unrecognized input cmd \"%s\"; Aborting.\n", inp); 2537 return 1; 2538 } 2539 ipc_log (" processing IPC command %s complete\n", inp); 2540 free (inp); 2541 fflush (stdout); 2542 if (req->getStatus () != CANCELLED_IMMEDIATE) 2543 // wake up the main working thread, let it take care of delete 2544 req->setStatus (COMPLETED); 2545 delete req; 2546 return 0; 2547 } 2548 2549 void 2550 check_env_args (int argc, char *argv[]) 2551 { 2552 int indx = 2; // Skip "-IPC" 2553 const char *MINUS_E = "-E"; 2554 const char *SP_ER_PRINT_TRACE_LEVEL = "SP_ER_PRINT_TRACE_LEVEL"; 2555 const char *SP_IPC_PROTOCOL = "SP_IPC_PROTOCOL"; 2556 const char SEPARATOR = '='; 2557 char *cmd_env_var = NULL; 2558 while (argc - indx >= 2) 2559 { 2560 char *option = argv[indx++]; 2561 if (!streq (option, MINUS_E)) 2562 continue; 2563 cmd_env_var = argv[indx++]; 2564 char *separator = strchr (cmd_env_var, SEPARATOR); 2565 if (!separator) 2566 // Unrecognized option. Fatal error? 2567 continue; 2568 char *cmd_env_var_val = separator + 1; 2569 if (!strncmp (cmd_env_var, SP_ER_PRINT_TRACE_LEVEL, 2570 strlen (SP_ER_PRINT_TRACE_LEVEL))) 2571 { 2572 if (streq (cmd_env_var_val, "1")) 2573 ipc_trace_level = TRACE_LVL_1; 2574 else if (streq (cmd_env_var_val, "2")) 2575 ipc_trace_level = TRACE_LVL_2; 2576 else if (streq (cmd_env_var_val, "3")) 2577 ipc_trace_level = TRACE_LVL_3; 2578 else if (streq (cmd_env_var_val, "4")) 2579 ipc_trace_level = TRACE_LVL_4; 2580 continue; 2581 } 2582 if (!strncmp (cmd_env_var, SP_IPC_PROTOCOL, strlen (SP_IPC_PROTOCOL))) 2583 { 2584 if (streq (cmd_env_var_val, IPC_PROTOCOL_CURR)) 2585 // Only one protocol is currently supported 2586 ipc_protocol = IPC_PROTOCOL_CURR; 2587 else 2588 ipc_protocol = IPC_PROTOCOL_UNKNOWN; 2589 continue; 2590 } 2591 // Unrecognized option. Fatal error? 2592 } 2593 } 2594 2595 void 2596 print_ipc_protocol_confirmation () 2597 { 2598 if (NULL != ipc_protocol) 2599 { 2600 fprintf (stdout, "ER_IPC: %s\n", ipc_protocol); 2601 fflush (stdout); 2602 } 2603 } 2604 2605 void 2606 ipc_mainLoop (int argc, char *argv[]) 2607 { 2608 if (getenv ("GPROFNG_DBE_DELAY")) 2609 sleep (20); 2610 #ifdef IPC_LOG 2611 ipc_flags = 1; 2612 #endif 2613 // check_env_args(argc, argv); 2614 2615 char *er_print_trace_level = getenv ("SP_ER_PRINT_TRACE_LEVEL"); 2616 if (er_print_trace_level != NULL) 2617 { 2618 if (streq (er_print_trace_level, "1")) 2619 ipc_trace_level = TRACE_LVL_1; 2620 else if (streq (er_print_trace_level, "2")) 2621 ipc_trace_level = TRACE_LVL_2; 2622 else if (streq (er_print_trace_level, "3")) 2623 ipc_trace_level = TRACE_LVL_3; 2624 else if (streq (er_print_trace_level, "4")) 2625 ipc_trace_level = TRACE_LVL_4; 2626 } 2627 check_env_args (argc, argv); 2628 print_ipc_protocol_confirmation (); 2629 2630 if (ipc_flags || getenv ("SP_ER_PRINT_IPC_FLAG") || ipc_trace_level > TRACE_LVL_0) 2631 { 2632 ipc_flags = 1; 2633 if (ipc_trace_level == TRACE_LVL_0) 2634 ipc_trace_level = TRACE_LVL_1; 2635 // reopen stderr as file "ipc_log" 2636 ipc_log_name = getenv ("SP_ER_PRINT_IPC_LOG"); 2637 if (ipc_log_name == NULL) 2638 ipc_log_name = "ipc_log"; 2639 freopen (ipc_log_name, "w", stderr); 2640 if (ipc_trace_level >= TRACE_LVL_2) 2641 { 2642 ipc_request_log_name = "ipc_request_log"; 2643 ipc_response_log_name = "ipc_response_log"; 2644 requestLogFileP = fopen (ipc_request_log_name, "w"); 2645 responseLogFileP = fopen (ipc_response_log_name, "w"); 2646 } 2647 else 2648 { 2649 ipc_request_log_name = "ipc_log"; 2650 ipc_response_log_name = "ipc_log"; 2651 } 2652 begin_time = gethrtime (); 2653 } 2654 else 2655 // Reopen stderr as /dev/null 2656 freopen ("/dev/null", "w", stderr); 2657 2658 struct sigaction act; 2659 memset (&act, 0, sizeof (struct sigaction)); 2660 term_flag = 0; 2661 /* install a handler for TERM */ 2662 ipc_request_trace (TRACE_LVL_1, "Installing SIGTERM handler to abort on error\n"); 2663 sigemptyset (&act.sa_mask); 2664 act.sa_handler = (SignalHandler) sigterm_handler; 2665 act.sa_flags = SA_RESTART | SA_SIGINFO; 2666 if (sigaction (SIGTERM, &act, &old_sigterm_handler) == -1) 2667 { 2668 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGTERM handler\n"); 2669 abort (); 2670 } 2671 /* install a handler for INT */ 2672 ipc_request_trace (TRACE_LVL_1, "Installing SIGINT handler to send message to analyzer\n"); 2673 sigemptyset (&act.sa_mask); 2674 act.sa_handler = (SignalHandler) sigint_handler; 2675 act.sa_flags = SA_RESTART | SA_SIGINFO; 2676 if (sigaction (SIGINT, &act, &old_sigint_handler) == -1) 2677 { 2678 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGINT handler\n"); 2679 abort (); 2680 } 2681 ipc_log ("Installed SIGINT handler to handle Ctrl-C properly\n"); 2682 int er_print_catch_crash = 1; // Default: catch fatal signals 2683 char *s = getenv ("GPROFNG_ALLOW_CORE_DUMP"); 2684 if (s && (strcasecmp (s, "no") == 0 || strcmp (s, "0") == 0)) 2685 er_print_catch_crash = 0; 2686 if (er_print_catch_crash) 2687 { 2688 /* reserve memory for fatal error processing */ 2689 fatalErrorDynamicMemory = (char *) malloc (4 * 1024 * 1024); // reserve 4 MB 2690 /* install a handler for SIGABRT */ 2691 ipc_request_trace (TRACE_LVL_1, "Installing SIGABRT handler to send message to analyzer\n"); 2692 sigemptyset (&act.sa_mask); 2693 act.sa_handler = (SignalHandler) sigABRT_handler; 2694 act.sa_flags = SA_RESTART | SA_SIGINFO; 2695 if (sigaction (SIGABRT, &act, NULL) == -1) 2696 { 2697 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGABRT handler\n"); 2698 // abort(); 2699 } 2700 else 2701 ipc_log ("Installed SIGABRT handler to handle crash properly\n"); 2702 /* install a handler for SIGSEGV */ 2703 ipc_request_trace (TRACE_LVL_1, "Installing SIGABRT handler to send message to analyzer\n"); 2704 sigemptyset (&act.sa_mask); 2705 act.sa_handler = (SignalHandler) sigSEGV_handler; 2706 act.sa_flags = SA_RESTART | SA_SIGINFO; 2707 if (sigaction (SIGSEGV, &act, NULL) == -1) 2708 { 2709 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGSEGV handler\n"); 2710 // abort(); 2711 } 2712 else 2713 ipc_log ("Installed SIGSEGV handler to handle crash properly\n"); 2714 } 2715 ipc_request_trace (TRACE_LVL_1, "Entering ipc_mainLoop; run dir `%s'\n", 2716 theApplication->get_run_dir ()); 2717 cancelRequestedChannelID = 0xFFFFFFFF; 2718 ipcThreadPool = new DbeThreadPool (0); // DbeThreadPool (-1); 2719 responseBufferPool = new BufferPool (); 2720 ipc_log (ipc_single_threaded_mode ? 2721 "RUNNING er_print -IPC IN SINGLE THREADED MODE\n" : 2722 "RUNNING er_print -IPC IN MULTITHREAD MODE\n"); 2723 2724 /* Send "Ready" signal to the GUI */ 2725 setProgress (100, "Restart engine"); 2726 2727 /* start listening for requests */ 2728 error_flag = 0; 2729 for (;;) 2730 { 2731 readRequestHeader (); 2732 if (term_flag == 1 || error_flag == 1) 2733 { 2734 ipc_request_trace (TRACE_LVL_1, "SIGTERM received, exiting\n"); 2735 return; 2736 } 2737 } 2738 } 2739 2740 static const char * 2741 table_name (int flavor) 2742 { 2743 static char def_name[64]; 2744 2745 switch ((FuncListDisp_type) flavor) 2746 { 2747 case DSP_FUNCTION: 2748 return ("FUNCTION"); 2749 case DSP_LINE: 2750 return ("LINE"); 2751 case DSP_PC: 2752 return ("PC"); 2753 case DSP_SOURCE: 2754 return ("SOURCE"); 2755 case DSP_DISASM: 2756 return ("DISASM"); 2757 case DSP_SELF: 2758 return ("SELF"); 2759 case DSP_CALLER: 2760 return ("CALLER"); 2761 case DSP_CALLEE: 2762 return ("CALLEE"); 2763 case DSP_CALLTREE: 2764 return ("CALLTREE"); 2765 case DSP_TIMELINE: 2766 return ("TIMELINE"); 2767 case DSP_STATIS: 2768 return ("STATIS"); 2769 case DSP_EXP: 2770 return ("EXP"); 2771 case DSP_LEAKLIST: 2772 return ("LEAKLIST"); 2773 case DSP_HEAPCALLSTACK: 2774 return ("HEAP"); 2775 case DSP_MEMOBJ: 2776 return ("MEMOBJ"); 2777 case DSP_DATAOBJ: 2778 return ("DATAOBJ"); 2779 case DSP_DLAYOUT: 2780 return ("DLAYOUT"); 2781 case DSP_SRC_FILE: 2782 return ("SRC_FILE"); 2783 case DSP_IFREQ: 2784 return ("IFREQ"); 2785 case DSP_RACES: 2786 return ("RACES"); 2787 case DSP_INDXOBJ: 2788 return ("INDXOBJ"); 2789 case DSP_DUALSOURCE: 2790 return ("DUALSOURCE"); 2791 case DSP_SOURCE_DISASM: 2792 return ("SOURCE_DISASM"); 2793 case DSP_DEADLOCKS: 2794 return ("DEADLOCKS"); 2795 case DSP_SOURCE_V2: 2796 return ("SOURCE_V2"); 2797 case DSP_DISASM_V2: 2798 return ("DISASM_V2"); 2799 case DSP_IOACTIVITY: 2800 return ("IOACTIVITY"); 2801 case DSP_OVERVIEW: 2802 return ("OVERVIEW"); 2803 case DSP_SAMPLE: 2804 return ("SAMPLE -- UNEXPECTED"); 2805 default: 2806 snprintf (def_name, sizeof (def_name), "table number %d", flavor); 2807 return (def_name); 2808 } 2809 } 2810