1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
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)
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.
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. */
25 #include <fcntl.h> // creat
26 #include <unistd.h> // sleep
27 #include <pthread.h> // pthread_exit
28 #include <sys/wait.h> // wait
31 #include "DbeApplication.h"
35 #include "DbeSession.h"
36 #include "DbeThread.h"
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;
46 DbeThreadPool *ipcThreadPool;
48 extern int currentRequestID;
49 extern int currentChannelID;
50 extern BufferPool *responseBufferPool;
51 extern bool cancelNeeded (int);
52 extern void reexec ();
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;
62 static const char *table_name (int);
64 #define VSIZE(v) ((long long) ((v) ? (v)->size() : 0))
69 return v ? "true" : "false";
75 return (char*) (v ? v : "NULL");
81 return (char*) (v ? v : "");
87 return dbeSession->getView (index);
92 typedef void (*SignalHandler)(int);
96 * Fatal error handlers
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;
105 fatalErrorHadler (int sig, siginfo_t *info, void *context)
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
112 fatalErrorCounter = 1;
113 fatalErrorCode = sig;
114 fatalErrorContext = context;
115 fatalErrorInfo = info;
116 // Free reserved memory
117 if (fatalErrorDynamicMemory != NULL)
119 free (fatalErrorDynamicMemory);
120 fatalErrorDynamicMemory = NULL;
123 pid_t pid = getpid ();
126 snprintf (fname, sizeof (fname), "/tmp/gprofng.%lld", (long long) pid);
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
132 snprintf (buf, sizeof (buf), "/usr/bin/pstack %lld > %s.pstack",
133 (long long) pid, fname);
135 int fd = creat (fname, 0600);
138 // Write error message
139 dbe_write (fd, "A fatal error has been detected by er_print: Signal %d\n",
141 dbe_write (fd, "Protocol Version: %d\n", IPC_VERSION_NUMBER);
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);
152 sigABRT_handler (int sig, siginfo_t *info, void *context)
154 fatalErrorHadler (sig, info, context);
155 pthread_exit (&fatalErrorCode);
160 sigSEGV_handler (int sig, siginfo_t *info, void *context)
162 //if (fatalErrorCounter > 0) sleep(1); // Wait 1 second
163 fatalErrorHadler (sig, info, context);
164 pthread_exit (&fatalErrorCode);
168 extern "C" void sigterm_handler (int sig, siginfo_t *info, void *context);
169 struct sigaction old_sigterm_handler;
171 volatile int term_flag;
175 sigterm_handler (int, siginfo_t *, void *)
177 if (fatalErrorCounter > 0)
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);
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 FILE *requestLogFileP = stderr;
193 FILE *responseLogFileP = stderr;
195 long long delta_time = 0;
196 int ipc_delay_microsec = 0;
199 ipc_default_log (const char *fmt, ...)
201 if (!ipc_log_name || !ipc_flags)
203 if (ipc_trace_level >= TRACE_LVL_3)
205 hrtime_t cur_time = gethrtime ();
206 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time;
207 fprintf (stderr, "%7llu: ", time_stamp);
211 vfprintf (stderr, fmt, vp);
216 extern "C" void sigint_handler (int sig, siginfo_t *info, void *context);
217 struct sigaction old_sigint_handler;
220 sigint_handler (int, siginfo_t *, void *)
222 ipc_log ("SIGINT signal happens\n");
226 ipc_request_log (IPCTraceLevel trace_level, const char *fmt, ...)
228 if (!ipc_request_log_name || !ipc_flags || trace_level > ipc_trace_level)
230 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ());
231 if (ipc_trace_level >= TRACE_LVL_3)
233 hrtime_t cur_time = gethrtime ();
234 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time;
235 fprintf (requestLogFileP, "%7llu: ", time_stamp);
239 vfprintf (requestLogFileP, fmt, vp);
241 fflush (requestLogFileP);
245 ipc_response_log (IPCTraceLevel trace_level, const char *fmt, ...)
247 if (!ipc_response_log_name || !ipc_flags || trace_level > ipc_trace_level)
249 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ());
250 if (ipc_trace_level >= TRACE_LVL_3)
252 hrtime_t cur_time = gethrtime ();
253 unsigned long long time_stamp = (cur_time - begin_time) / 1000000 + delta_time;
254 fprintf (responseLogFileP, "%7llu: ", time_stamp);
258 vfprintf (responseLogFileP, fmt, vp);
260 fflush (responseLogFileP);
265 ipc_dump (char *s, Vector<bool> *v)
269 ipc_log (" Vector<bool> %s is NULL\n", str2s (s));
272 ipc_log (" Vector<bool> %s size=%lld\n", str2s (s), VSIZE (v));
273 for (int i = 0; i < v->size (); i++)
274 ipc_log (" [%d]: %s\n", i, bool2str (v->fetch (i)));
278 ipc_dump (char *s, Vector<String> *v)
282 ipc_log (" Vector<bool> %s is NULL\n", str2s (s));
285 ipc_log (" Vector<String> %s size=%lld\n", str2s (s), VSIZE (v));
286 for (int i = 0; i < v->size (); i++)
288 String str = v->fetch (i);
289 ipc_log (" [%d]: '%s'\n", i, str2str (str));
294 ipc_dump (char *s, Vector<Obj> *v)
298 ipc_log (" Vector<Obj> %s is NULL\n", str2s (s));
301 ipc_log (" Vector<void *> %s size=%lld\n", str2s (s), VSIZE (v));
302 for (int i = 0; i < v->size (); i++)
303 ipc_log (" [%d]: 0x%08llx\n", i, (long long) (v->fetch (i)));
307 #define ipc_dump(s, v)
311 readMetricListV2 (int dbevindex, IPCrequest* req)
313 MetricType mtype = (MetricType) readInt (req);
314 Vector<int> *type = (Vector<int>*)readArray (req);
315 Vector<int> *subtype = (Vector<int>*)readArray (req);
316 Vector<bool> *sort = (Vector<bool>*)readArray (req);
317 Vector<int> *vis = (Vector<int>*)readArray (req);
318 Vector<char*> *cmd = (Vector<char*>*)readArray (req);
319 Vector<char*> *expr_spec = (Vector<char*>*)readArray (req);
320 Vector<char*> *legends = (Vector<char*>*)readArray (req);
321 MetricList *mlist = dbeGetMetricListV2 (dbevindex, mtype, type, subtype, sort,
322 vis, cmd, expr_spec, legends);
327 setCancellableChannel (int chID)
329 cancellableChannelID = chID;
332 /* Add more entries here for other cancellable operations */
334 checkCancellableOp (char *inp, IPCrequest* req)
336 if (!strcmp (inp, "setFilterStr"))
337 setCancellableChannel (currentChannelID);
338 else if (!strcmp (inp, "openExperimentList"))
339 setCancellableChannel (currentChannelID);
340 else if (!strcmp (inp, "getFiles") || !strcmp (inp, "getFileAttributes"))
342 setCancellableChannel (currentChannelID);
343 req->setCancelImmediate ();
347 /* This is what used to be the core of ipc_mainLoop before asynch ipc.
348 Read the details of the request from the request buffer: name, args etc
349 do the work by calling the appropriate dbe routine(s) and write the
350 response to a response buffer and queue it up in the response queue */
353 ipc_doWork (void *arg)
355 IPCrequest *req = (IPCrequest *) arg;
356 currentRequestID = req->getRequestID ();
357 currentChannelID = req->getChannelID ();
358 req->setStatus (IN_PROGRESS);
359 String inp = readString (req);
362 ipc_log ("NULL ipc command received, exiting\n");
365 ipc_log ("ipc: %s Req %x Ch %x\n", inp, currentRequestID, currentChannelID);
366 checkCancellableOp (inp, req);
367 if (!strcmp (inp, "initApplication"))
369 bool nbm = readBoolean (req);
370 String arg1 = readString (req);
371 String arg2 = readString (req);
372 Vector<String> *arg3 = (Vector<String>*)readArray (req);
373 ipc_log (" nbm: %s, arg1: '%s', arg2: '%s'\n", bool2str (nbm), str2str (arg1), str2str (arg2));
374 ipc_dump ("arg3", arg3);
375 // set the session to be interactive
376 dbeSession->set_interactive (true);
378 theApplication->set_name ("analyzer-NBM");
380 theApplication->set_name ("analyzer");
382 // XXX Why does it reset the install directory???? Or a licensing directory???
383 // Vector<String> *res = theDbeApplication->initApplication (arg1, arg2, &setProgress);
384 Vector<String> *res = theDbeApplication->initApplication (NULL, NULL, &setProgress);
385 writeArray (res, req);
391 else if (!strcmp (inp, "syncTime"))
393 long long anl_time = readLong (req);
394 hrtime_t cur_time = gethrtime ();
395 long long time_stamp = (cur_time - begin_time) / 1000000;
396 delta_time = anl_time - time_stamp;
397 ipc_log (" syncTime %llu %llu \n", anl_time, delta_time);
398 writeString (NULL, req);
400 else if (!strcmp (inp, "getInitMessages"))
402 Vector<String> *res = dbeGetInitMessages ();
403 ipc_log (" returned = %lld msgs\n", VSIZE (res));
404 writeArray (res, req);
407 else if (!strcmp (inp, "reExec"))
409 ipc_log (" started reexec()\n");
412 else if (!strcmp (inp, "dbeCreateDirectories"))
414 String arg1 = readString (req); // path
415 ipc_log (" arg = %s\n", arg1);
416 String res = dbeCreateDirectories (arg1);
417 writeString (res, req);
421 else if (!strcmp (inp, "dbeDeleteFile"))
423 String arg1 = readString (req); // path
424 ipc_log (" arg = %s\n", arg1);
425 String res = dbeDeleteFile (arg1);
426 writeString (res, req);
430 else if (!strcmp (inp, "dbeReadFile"))
432 String arg1 = readString (req);
433 ipc_log (" arg = %s\n", arg1); // path
434 Vector<String> *res = dbeReadFile (arg1);
435 writeArray (res, req);
439 else if (!strcmp (inp, "dbeWriteFile"))
441 String arg1 = readString (req); // path
442 String arg2 = readString (req); // contents
443 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2);
444 int res = dbeWriteFile (arg1, arg2);
448 else if (!strcmp (inp, "getExpPreview"))
450 // XXX add another argument == DbeView index
451 String arg1 = readString (req);
452 ipc_log (" arg = %s\n", arg1);
453 Vector<String> *res = dbeGetExpPreview (0, arg1);
454 writeArray (res, req);
458 else if (!strcmp (inp, "getFileAttributes"))
460 String arg1 = readString (req); // filename
461 String arg2 = readString (req); // format
462 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2);
463 String res = dbeGetFileAttributes (arg1, arg2);
464 writeString (res, req);
469 else if (!strcmp (inp, "getFiles"))
471 String arg1 = readString (req); // dirname
472 String arg2 = readString (req); // format
473 ipc_log (" arg1 = %s arg2 = %s\n", arg1, arg2);
474 String res = dbeGetFiles (arg1, arg2);
475 writeString (res, req);
480 else if (!strcmp (inp, "getOSFamily"))
481 writeString ("Linux", req);
482 else if (!strcmp (inp, "getRunningProcesses"))
484 String arg1 = readString (req); // format
485 ipc_log (" arg = %s\n", arg1);
486 String res = dbeGetRunningProcesses (arg1);
487 writeString (res, req);
491 else if (!strcmp (inp, "getCurrentDirectory"))
494 String res = getcwd (buf, (size_t) sizeof (buf)); // Get current directory
495 writeString (res, req);
497 else if (!strcmp (inp, "getHomeDirectory"))
499 String res = getenv ("HOME"); // Get HOME directory
500 writeString (res, req);
502 else if (!strcmp (inp, "setCurrentDirectory"))
504 String arg1 = readString (req); // dirname
505 ipc_log (" arg = %s\n", arg1);
506 int res = chdir (arg1); // Change directory
510 else if (!strcmp (inp, "getLocale"))
512 String res = setlocale (LC_ALL, ""); // Get locale
513 writeString (res, req);
515 else if (!strcmp (inp, "setLocale"))
517 String arg1 = readString (req); // locale
518 ipc_log (" arg = %s\n", arg1);
519 String res = setlocale (LC_ALL, arg1); // Set locale
520 writeString (res, req);
523 else if (!strcmp (inp, "readRCFile"))
525 int arg1 = readInt (req);
526 String arg2 = readString (req); // file name
527 ipc_log (" arg1=%d, arg2=%s\n", arg1, arg2);
528 String res = dbeReadRCFile (arg1, arg2); // Read RC File
529 writeString (res, req);
532 else if (!strcmp (inp, "dbeGetExpParams"))
534 // XXX add another argument == DbeView index
535 String arg1 = readString (req);
536 ipc_log (" arg = %s\n", arg1);
537 String res = dbeGetExpParams (0, arg1);
538 writeString (res, req);
542 else if (!strcmp (inp, "getExperimentsGroups"))
544 Vector<Vector<char*>*> *groups = dbeGetExperimensGroups ();
545 writeArray (groups, req);
548 else if (!strcmp (inp, "setExperimentsGroups"))
550 Vector<Vector<char*>*> *groups = (Vector<Vector<char*>*> *)readArray (req);
551 ipc_log (" groups.size = %lld\n", VSIZE (groups));
552 char *msg_str = dbeSetExperimentsGroups (groups);
553 writeString (msg_str, req);
557 else if (!strcmp (inp, "dropExperiment"))
559 int arg1 = readInt (req);
560 Vector<int> *arg2 = (Vector<int>*)readArray (req);
561 ipc_log (" arg = %d, exps = %lld\n", arg1, VSIZE (arg2));
562 char *res = dbeDropExperiment (arg1, arg2);
563 writeString (res, req);
567 else if (!strcmp (inp, "getUserExpId"))
569 Vector<int> *arg = (Vector<int>*)readArray (req);
570 ipc_log (" expIds = %lld\n", VSIZE (arg));
571 Vector<int> *res = dbeGetUserExpId (arg);
572 writeArray (res, req);
575 else if (!strcmp (inp, "getFounderExpId"))
577 Vector<int> *arg = (Vector<int>*)readArray (req);
578 ipc_log (" expIds = %lld\n", VSIZE (arg));
579 Vector<int> *res = dbeGetFounderExpId (arg);
580 writeArray (res, req);
583 else if (!strcmp (inp, "getExpGroupId"))
585 Vector<int> *arg = (Vector<int>*)readArray (req);
586 ipc_log (" expIds = %lld\n", VSIZE (arg));
587 Vector<int> *res = dbeGetExpGroupId (arg);
588 writeArray (res, req);
591 else if (!strcmp (inp, "getExpsProperty"))
593 String arg = readString (req);
594 Vector<String> *res = dbeGetExpsProperty (arg);
595 writeArray (res, req);
598 else if (!strcmp (inp, "getExpName"))
600 // XXX add argument == DbeView index
601 Vector<String> *res = dbeGetExpName (0);
602 writeArray (res, req);
605 else if (!strcmp (inp, "getExpState"))
607 // XXX add argument == DbeView index
608 Vector<int> *res = dbeGetExpState (0);
609 writeArray (res, req);
612 else if (!strcmp (inp, "getExpEnable"))
614 int arg1 = readInt (req);
615 ipc_log (" arg1 = %d\n", arg1);
616 Vector<bool> *res = dbeGetExpEnable (arg1);
617 writeArray (res, req);
620 else if (!strcmp (inp, "setExpEnable"))
622 int arg1 = readInt (req);
623 Vector<bool> *arg2 = (Vector<bool>*)readArray (req);
624 ipc_log (" arg1=%d\n", arg1);
625 ipc_dump ("arg2", arg2);
626 bool b = dbeSetExpEnable (arg1, arg2);
627 writeBoolean (b, req);
628 ipc_log (" dbeSetExpEnable returns %s\n", bool2str (b));
631 else if (!strcmp (inp, "getExpInfo"))
633 int arg1 = readInt (req);
634 ipc_log (" args = %d\n", arg1);
635 Vector<String> *res = dbeGetExpInfo (arg1);
636 writeArray (res, req);
639 else if (!strcmp (inp, "getViewModeEnable"))
641 bool res = dbeGetViewModeEnable ();
642 writeBoolean (res, req);
644 else if (!strcmp (inp, "getJavaEnable"))
646 bool res = dbeGetJavaEnable ();
647 writeBoolean (res, req);
649 else if (!strcmp (inp, "updateNotes"))
651 int arg1 = readInt (req);
652 int arg2 = readInt (req);
653 int arg3 = readInt (req);
654 String arg4 = readString (req);
655 bool arg5 = readBoolean (req);
656 ipc_log (" args = %d, %d\n", arg1, arg2);
657 int i = dbeUpdateNotes (arg1, arg2, arg3, arg4, arg5);
660 else if (!strcmp (inp, "getLoadObjectList"))
662 int arg1 = readInt (req);
663 ipc_log (" arg = %d\n", arg1);
664 Vector<void *> *res = dbeGetLoadObjectList (arg1);
666 ipc_log (" returning = NULL for LoadObjectList\n");
669 Vector<char*> *s = (Vector<char*> *) res->fetch (0);
670 ipc_log (" returning = %lld vectors for %lld LoadObjects\n",
671 VSIZE (res), VSIZE (s));
673 writeArray (res, req);
676 else if (!strcmp (inp, "getLoadObjectName"))
678 int arg1 = readInt (req);
679 ipc_log (" arg = %d\n", arg1);
680 Vector<String> *res = dbeGetLoadObjectName (arg1);
681 ipc_log (" returning = %lld strings\n", VSIZE (res));
682 writeArray (res, req);
685 else if (!strcmp (inp, "getTabListInfo"))
687 int arg1 = readInt (req);
688 ipc_log (" arg = %d\n", arg1);
689 Vector<void*> *res = dbeGetTabListInfo (arg1);
690 writeArray (res, req);
693 else if (!strcmp (inp, "getSearchPath"))
695 // XXX add argument == DbeView index
696 ipc_log (" no args\n");
697 Vector<String> *res = dbeGetSearchPath (0);
698 writeArray (res, req);
701 else if (!strcmp (inp, "setSearchPath"))
703 // XXX add another argument == DbeView index
704 Vector<String> *res = (Vector<String>*)readArray (req);
705 ipc_log (" %lld strings\n", VSIZE (res));
706 dbeSetSearchPath (0, res);
707 writeString (NULL, req);
710 else if (!strcmp (inp, "getPathmaps"))
712 Vector<void*> *res = dbeGetPathmaps (0);
713 ipc_log (" returns = %lld objects, number of pathmaps = %lld\n",
714 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
715 writeArray (res, req);
718 else if (!strcmp (inp, "setPathmaps"))
720 Vector<String> *from = (Vector<String>*)readArray (req);
721 Vector<String> *to = (Vector<String>*)readArray (req);
722 char *res = dbeSetPathmaps (from, to);
723 writeString (res, req);
736 else if (!strcmp (inp, "addPathmap"))
738 // XXX add another argument == DbeView index
739 String arg1 = readString (req);
740 String arg2 = readString (req);
741 ipc_log (" args = '%s', '%s'\n", arg1 ? arg1 : "NULL", arg2 ? arg2 : "NULL");
742 char *res = dbeAddPathmap (0, arg1, arg2);
743 ipc_log (" returns = '%s'\n", (res != NULL ? res : "NULL"));
744 writeString (res, req);
748 else if (!strcmp (inp, "getMsg"))
750 int arg1 = readInt (req);
751 int arg2 = readInt (req);
752 ipc_log (" args = %d, %d\n", arg1, arg2);
753 String res = dbeGetMsg (arg1, arg2);
754 ipc_log (" returns = '%s'\n", (res != NULL ? res : "<NULL>"));
755 writeString (res, req);
758 else if (!strcmp (inp, "initView"))
760 int arg1 = readInt (req);
761 int arg2 = readInt (req);
762 ipc_log (" new view = %d; clone of view %d\n", arg1, arg2);
763 dbeInitView (arg1, arg2);
764 writeString (NULL, req);
766 else if (!strcmp (inp, "disposeWindow"))
768 int arg1 = readInt (req);
769 ipc_log (" args = %d\n", arg1);
770 dbeDeleteView (arg1);
771 writeString (NULL, req);
774 else if (!strcmp (inp, "createMapfile"))
776 int arg1 = readInt ();
777 String arg2 = readString ();
778 int arg3 = readInt ();
779 ipc_log (" args = %d, %s, %d\n", arg1, arg2, arg3);
780 String res = dbeCreateMapfile (arg1, arg2, arg3);
786 else if (!strcmp (inp, "setCompareModeV2"))
788 int dbevindex = readInt (req);
789 int cmp_mode = readInt (req);
790 getView (dbevindex)->set_compare_mode (cmp_mode);
791 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
793 else if (!strcmp (inp, "getCompareModeV2"))
795 int dbevindex = readInt (req);
796 int res = CMP_DISABLE;
797 if (dbeSession->expGroups && dbeSession->expGroups->size () > 1)
798 res = getView (dbevindex)->get_compare_mode ();
799 ipc_log (" %s: %d returns %d\n", inp, dbevindex, res);
802 else if (!strcmp (inp, "getRefMetricsV2"))
804 Vector<void*> *res = dbeGetRefMetricsV2 ();
805 writeArray (res, req);
808 else if (!strcmp (inp, "setCurMetricsV2"))
810 int dbevindex = readInt (req);
811 int cmp_mode = readInt (req);
812 MetricList *mlist = readMetricListV2 (dbevindex, req);
813 getView (dbevindex)->reset_metric_list (mlist, cmp_mode);
814 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
816 else if (!strcmp (inp, "getCurMetricsV2"))
818 int arg1 = readInt (req);
819 MetricType arg2 = (MetricType) readInt (req);
820 ipc_log (" args = %d, %d\n", arg1, arg2);
821 Vector<void*> *res = dbeGetCurMetricsV2 (arg1, arg2);
822 writeArray (res, req);
825 else if (!strcmp (inp, "getRefMetricTree"))
827 int dbevindex = readInt (req);
828 bool include_unregistered = readBoolean (req);
829 ipc_log (" args = %d, %d\n", dbevindex, include_unregistered);
830 Vector<void*> *res = dbeGetRefMetricTree (dbevindex, include_unregistered);
831 writeArray (res, req);
834 else if (!strcmp (inp, "getRefMetricTreeValues"))
836 int dbevindex = readInt (req);
837 Vector<String> *metcmds = (Vector<String>*)readArray (req);
838 Vector<String> *nonmetcmds = (Vector<String>*)readArray (req);
839 ipc_log (" args = %d, metcmds->size()=%lld, nonmetcmds->size()=%lld\n",
840 dbevindex, VSIZE (metcmds), VSIZE (nonmetcmds));
841 ipc_dump ("metcmds", metcmds);
842 ipc_dump ("nonmetcmds", nonmetcmds);
843 Vector<void*> *res = dbeGetRefMetricTreeValues (dbevindex, metcmds, nonmetcmds);
846 ipc_log (" returns = %lld objects, length = %lld\n",
847 VSIZE (res), VSIZE (((Vector<int>*)res->fetch (0))));
849 ipc_log (" returns NULL\n");
851 writeArray (res, req);
854 else if (!strcmp (inp, "getOverviewText"))
856 int arg1 = readInt (req);
857 ipc_log (" args = %d\n", arg1);
858 Vector<char*> *res = dbeGetOverviewText (arg1);
859 writeArray (res, req);
862 else if (!strcmp (inp, "setSort"))
864 int arg1 = readInt (req);
865 int arg2 = readInt (req);
866 MetricType arg3 = (MetricType) readInt (req);
867 bool arg4 = readBoolean (req);
868 ipc_log (" args = %d, %d, %d, %c\n", arg1, arg2, arg3, (arg4 ? 'T' : 'F'));
869 dbeSetSort (arg1, arg2, arg3, arg4);
870 writeString (NULL, req);
873 else if (!strcmp (inp, "getAnoValue"))
875 int arg1 = readInt (req);
876 ipc_log (" args = %d\n", arg1);
877 Vector<int> *res = dbeGetAnoValue (arg1);
878 writeArray (res, req);
881 else if (!strcmp (inp, "setAnoValue"))
883 int arg1 = readInt (req);
884 ipc_log (" args = %d, array\n", arg1);
885 Vector<int> *arg2 = (Vector<int>*)readArray (req);
886 dbeSetAnoValue (arg1, arg2);
887 writeString (NULL, req);
890 else if (!strcmp (inp, "getNameFormat"))
892 int arg1 = readInt (req);
893 ipc_log (" args = %d\n", arg1);
894 int b = dbeGetNameFormat (arg1);
897 else if (!strcmp (inp, "getSoName"))
899 int arg1 = readInt (req);
900 ipc_log (" args = %d\n", arg1);
901 bool b = dbeGetSoName (arg1);
902 writeBoolean (b, req);
904 else if (!strcmp (inp, "setNameFormat"))
906 int arg1 = readInt (req);
907 int arg2 = readInt (req);
908 bool arg3 = readBoolean (req);
909 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3);
910 dbeSetNameFormat (arg1, arg2, arg3);
911 writeString (NULL, req);
913 else if (!strcmp (inp, "getViewMode"))
915 int arg1 = readInt (req);
916 ipc_log (" args = %d\n", arg1);
917 int i = dbeGetViewMode (arg1);
918 ipc_log (" returns = %d\n", i);
921 else if (!strcmp (inp, "setViewMode"))
923 int arg1 = readInt (req);
924 int arg2 = readInt (req);
925 ipc_log (" args = %d, %d\n", arg1, arg2);
926 dbeSetViewMode (arg1, arg2);
927 writeString (NULL, req);
929 else if (!strcmp (inp, "getTLValue"))
931 int arg1 = readInt (req);
932 ipc_log (" args = %d\n", arg1);
933 Vector<void*> *res = dbeGetTLValue (arg1);
934 ipc_log (" returns = %lld void*'s\n", VSIZE (res));
935 writeArray (res, req);
938 else if (!strcmp (inp, "setTLValue"))
940 int arg1 = readInt (req);
941 ipc_log (" args = %d\n", arg1);
942 String tldata_cmd = readString (req);
943 int entity_prop_id = readInt (req);
944 int align = readInt (req);
945 int depth = readInt (req);
946 dbeSetTLValue (arg1, tldata_cmd, entity_prop_id, align, depth);
947 writeString (NULL, req);
950 else if (!strcmp (inp, "getExpFounderDescendants"))
952 Vector<void*> *res = dbeGetExpFounderDescendants ();
953 writeArray (res, req);
956 else if (!strcmp (inp, "getExpSelection"))
958 int arg1 = readInt (req);
959 ipc_log (" args = %d\n", arg1);
960 Vector<void*> *res = dbeGetExpSelection (arg1);
961 writeArray (res, req);
965 else if (!strcmp (inp, "setFilterStr"))
967 int arg1 = readInt (req);
968 String arg2 = readString (req);
969 ipc_log (" args = %d, %s\n", arg1, arg2);
970 String res = dbeSetFilterStr (arg1, arg2);
971 ipc_log (" returns = '%s'\n", res ? res : "NULL");
972 writeString (res, req);
977 else if (!strcmp (inp, "getFilterStr"))
979 int arg1 = readInt (req);
980 ipc_log (" args = %d\n", arg1);
981 String res = dbeGetFilterStr (arg1);
982 ipc_log (" returns = '%s'\n", res ? res : "NULL");
983 writeString (res, req);
987 else if (!strcmp (inp, "validateFilterExpression"))
989 String arg1 = readString (req);
990 int res = dbeValidateFilterExpression (arg1);
991 ipc_log (" validateFilterExpression('%s') returned %d\n", str2str (arg1), res);
996 else if (!strcmp (inp, "getFilterKeywords"))
998 int dbevindex = readInt (req);
999 Vector<void*>*res = dbeGetFilterKeywords (dbevindex);
1000 writeArray (res, req);
1004 else if (!strcmp (inp, "getFilters"))
1006 int arg1 = readInt (req);
1007 int arg2 = readInt (req);
1008 ipc_log (" args: view = %d, experiment = %d\n", arg1, arg2);
1009 Vector<void*>*res = dbeGetFilters (arg1, arg2);
1010 ipc_log (" -- returned %lld Filters\n", VSIZE (res));
1011 writeArray (res, req);
1015 else if (!strcmp (inp, "updateFilters"))
1017 int arg1 = readInt (req);
1018 Vector<bool> *arg2 = (Vector<bool>*)readArray (req);
1019 Vector<String> *arg3 = (Vector<String>*)readArray (req);
1020 ipc_log ("arg1=%d arg2->size()=%lld arg3->size()=%lld\n",
1021 arg1, VSIZE (arg2), VSIZE (arg3));
1022 ipc_dump ("arg2", arg2);
1023 ipc_dump ("arg3", arg3);
1024 bool b = dbeUpdateFilters (arg1, arg2, arg3);
1025 writeBoolean (b, req);
1026 ipc_log (" returns %s\n", (b == true ? "true" : "false"));
1030 else if (!strcmp (inp, "getLoadObjectState"))
1032 int arg1 = readInt (req);
1033 ipc_log (" args = %d \n", arg1);
1034 Vector<int> *res = dbeGetLoadObjectState (arg1);
1035 ipc_log (" returning = %lld int's\n", VSIZE (res));
1036 writeArray (res, req);
1039 else if (!strcmp (inp, "setLoadObjectState"))
1041 int arg1 = readInt (req);
1042 Vector<int> *arg2 = (Vector<int>*)readArray (req);
1043 ipc_log (" args = %d, %lld objects\n", arg1, VSIZE (arg2));
1044 dbeSetLoadObjectState (arg1, arg2);
1045 writeString (NULL, req);
1048 else if (!strcmp (inp, "setLoadObjectDefaults"))
1050 int arg1 = readInt (req);
1051 ipc_log (" args = %d\n", arg1);
1052 dbeSetLoadObjectDefaults (arg1);
1053 writeString (NULL, req);
1055 else if (!strcmp (inp, "getMemTabSelectionState"))
1057 int arg1 = readInt (req);
1058 ipc_log (" arg = %d\n", arg1);
1059 Vector<bool> *res = dbeGetMemTabSelectionState (arg1);
1060 writeArray (res, req);
1063 else if (!strcmp (inp, "setMemTabSelectionState"))
1065 int arg1 = readInt (req);
1066 Vector<bool> *arg2 = (Vector<bool> *)readArray (req);
1067 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2));
1068 dbeSetMemTabSelectionState (arg1, arg2);
1069 writeString (NULL, req);
1072 else if (!strcmp (inp, "getIndxTabSelectionState"))
1074 int arg1 = readInt (req);
1075 ipc_log (" arg = %d\n", arg1);
1076 Vector<bool> *res = dbeGetIndxTabSelectionState (arg1);
1077 ipc_log (" -- returned %lld-vector [bool]\n", VSIZE (res));
1078 writeArray (res, req);
1081 else if (!strcmp (inp, "setIndxTabSelectionState"))
1083 int arg1 = readInt (req);
1084 Vector<bool> *arg2 = (Vector<bool> *)readArray (req);
1085 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2));
1086 dbeSetIndxTabSelectionState (arg1, arg2);
1087 writeString (NULL, req);
1090 else if (!strcmp (inp, "getTabSelectionState"))
1092 int arg1 = readInt (req);
1093 ipc_log (" args = %d\n", arg1);
1094 Vector<bool> *res = dbeGetTabSelectionState (arg1);
1095 writeArray (res, req);
1098 else if (!strcmp (inp, "setTabSelectionState"))
1100 int arg1 = readInt (req);
1101 Vector<bool> *arg2 = (Vector<bool>*)readArray (req);
1102 ipc_log (" args = %d\n arg2 = %lld objects\n", arg1, VSIZE (arg2));
1103 dbeSetTabSelectionState (arg1, arg2);
1104 writeString (NULL, req);
1107 else if (!strcmp (inp, "getMemObjects"))
1109 int arg1 = readInt (req);
1110 ipc_log (" args = %d\n", arg1);
1111 Vector<void*> *res = dbeGetMemObjects (arg1);
1115 ipc_log (" -- returned NULL\n");
1118 Vector<int> *mo_types = (Vector<int> *)res->fetch (0);
1119 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n",
1120 VSIZE (res), VSIZE (mo_types));
1123 writeArray (res, req);
1126 else if (!strcmp (inp, "loadMachineModel"))
1128 String arg1 = readString (req);
1130 ipc_log (" arg = `%s'\n", arg1);
1132 String sts = dbeLoadMachineModel (arg1);
1134 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1136 writeString (sts, req);
1139 else if (!strcmp (inp, "getMachineModel"))
1141 String sts = dbeGetMachineModel ();
1143 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1145 writeString (sts, req);
1147 else if (!strcmp (inp, "getCPUVerMachineModel"))
1149 int arg1 = readInt (req);
1150 ipc_log (" args = %d\n", arg1);
1151 Vector<char*> *res = dbeGetCPUVerMachineModel (arg1);
1152 writeArray (res, req);
1153 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1156 else if (!strcmp (inp, "listMachineModels"))
1158 Vector<String> *res = dbeListMachineModels ();
1161 ipc_log (" returns = %lld strings\n", VSIZE (res));
1163 ipc_log (" returns NULL\n");
1165 writeArray (res, req);
1168 else if (!strcmp (inp, "defineMemObj"))
1170 String arg1 = readString (req);
1171 String arg2 = readString (req);
1172 String arg3 = readString (req);
1173 String arg4 = readString (req);
1175 ipc_log (" args = %s, %s, %s, %s\n", arg1, arg2, arg3 == NULL ? "NULL" : arg3, arg4 == NULL ? "NULL" : arg4);
1177 String sts = dbeDefineMemObj (arg1, arg2, NULL, arg3, arg4);
1179 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1181 writeString (sts, req);
1187 else if (!strcmp (inp, "deleteMemObj"))
1189 String arg1 = readString (req);
1191 ipc_log (" args = %s\n", arg1);
1193 String sts = dbeDeleteMemObj (arg1);
1195 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1197 writeString (sts, req);
1200 else if (!strcmp (inp, "getIndxObjDescriptions"))
1202 int arg1 = readInt (req);
1203 ipc_log (" args = %d\n", arg1);
1204 Vector<void*> *res = dbeGetIndxObjDescriptions (arg1);
1207 ipc_log (" -- returned NULL\n");
1210 Vector<int> *indxo_types = (Vector<int> *)res->fetch (0);
1211 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n",
1212 VSIZE (res), VSIZE (indxo_types));
1215 writeArray (res, req);
1218 else if (!strcmp (inp, "getCustomIndxObjects"))
1220 int arg1 = readInt (req);
1221 ipc_log (" args = %d\n", arg1);
1222 Vector<void*> *res = dbeGetCustomIndxObjects (arg1);
1225 ipc_log (" -- returned NULL\n");
1228 Vector<char *> *indxo_names = (Vector<char *> *)res->fetch (0);
1229 ipc_log (" -- returned %lld-vector [ %lld-vectors]\n",
1230 VSIZE (res), VSIZE (indxo_names));
1233 writeArray (res, req);
1236 else if (!strcmp (inp, "defineIndxObj"))
1238 String arg1 = readString (req);
1239 String arg2 = readString (req);
1240 String arg3 = readString (req);
1241 String arg4 = readString (req);
1242 ipc_log (" args = %s, %s, %s, %s\n", arg1, arg2, arg3 == NULL ? "NULL" : arg3, arg4 == NULL ? "NULL" : arg4);
1243 String sts = dbeDefineIndxObj (arg1, arg2, arg3, arg4);
1244 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1245 writeString (sts, req);
1251 else if (!strcmp (inp, "setSelObj"))
1253 int arg1 = readInt (req);
1254 Obj arg2 = readObject (req);
1255 int arg3 = readInt (req);
1256 int arg4 = readInt (req);
1257 ipc_log (" args = %d, %ld, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4);
1258 dbeSetSelObj (arg1, arg2, arg3, arg4);
1259 writeString (NULL, req);
1261 else if (!strcmp (inp, "setSelObjV2"))
1263 int arg1 = readInt (req);
1264 uint64_t arg2 = readLong (req);
1265 ipc_log (" args = %d, %lld\n", arg1, (long long) arg2);
1266 dbeSetSelObjV2 (arg1, arg2);
1267 writeString (NULL, req);
1269 else if (!strcmp (inp, "getSelObj"))
1271 int arg1 = readInt (req);
1272 int arg2 = readInt (req);
1273 int arg3 = readInt (req);
1274 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3);
1275 Obj i = dbeGetSelObj (arg1, arg2, arg3);
1276 ipc_log (" returns = %ld (0x%08lx)\n", (long) i, (long) i);
1277 writeObject (i, req);
1279 else if (!strcmp (inp, "getSelObjV2"))
1281 int arg1 = readInt (req);
1282 String arg2 = readString (req);
1283 ipc_log (" arg1 = %d agr2 = %s\n", arg1, arg2 ? arg2 : "NULL");
1284 Obj res = dbeGetSelObjV2 (arg1, arg2);
1285 ipc_log (" returns = %lld\n", (long long) res);
1286 writeObject (res, req);
1289 else if (!strcmp (inp, "getSelObjIO"))
1291 int arg1 = readInt (req);
1292 uint64_t arg2 = readLong (req);
1293 int arg3 = readInt (req);
1294 ipc_log (" arg1 = %d, arg2 = %lld, arg3 = %d\n", arg1, (long long) arg2, arg3);
1295 Vector<uint64_t> *res = dbeGetSelObjIO (arg1, arg2, arg3);
1296 writeArray (res, req);
1299 else if (!strcmp (inp, "getSelObjsIO"))
1301 int arg1 = readInt (req);
1302 Vector<uint64_t> *arg2 = (Vector<uint64_t>*)readArray (req);
1303 int arg3 = readInt (req);
1304 ipc_log (" arg1 = %d, arg2 size = %lld, arg3 = %d\n",
1305 arg1, VSIZE (arg2), arg3);
1306 Vector<uint64_t> *res = dbeGetSelObjsIO (arg1, arg2, arg3);
1307 writeArray (res, req);
1310 else if (!strcmp (inp, "getSelObjHeapTimestamp"))
1312 int arg1 = readInt (req);
1313 uint64_t arg2 = readLong (req);
1314 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2);
1315 uint64_t st = dbeGetSelObjHeapTimestamp (arg1, arg2);
1316 ipc_log (" returns = %llu\n", (unsigned long long) st);
1317 writeLong (st, req);
1319 else if (!strcmp (inp, "getSelObjHeapUserExpId"))
1321 int arg1 = readInt (req);
1322 uint64_t arg2 = readLong (req);
1323 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2);
1324 int userExpId = dbeGetSelObjHeapUserExpId (arg1, arg2);
1325 ipc_log (" returns = %d\n", userExpId);
1326 writeInt (userExpId, req);
1328 else if (!strcmp (inp, "getSelIndex"))
1330 int arg1 = readInt (req);
1331 Obj arg2 = readObject (req);
1332 int arg3 = readInt (req);
1333 int arg4 = readInt (req);
1334 ipc_log (" args = %d, 0x%08lx, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4);
1335 int i = dbeGetSelIndex (arg1, arg2, arg3, arg4);
1336 ipc_log (" returns = %d\n", i);
1339 else if (!strcmp (inp, "printData"))
1341 int arg1 = readInt (req);
1342 int arg2 = readInt (req);
1343 int arg3 = readInt (req);
1344 String arg4 = readString (req);
1345 String arg5 = readString (req);
1346 ipc_log (" args = %d, %s, %d, `%s', `%s'\n",
1347 arg1, table_name (arg2), arg3,
1348 (arg4 == NULL ? "NULL" : arg4),
1349 (arg5 == NULL ? "NULL" : arg5));
1350 String res = dbePrintData (arg1, arg2, arg3, arg4, arg5, NULL);
1351 writeString (res, req);
1356 else if (!strcmp (inp, "getPrintLimit"))
1358 int arg1 = readInt (req);
1359 ipc_log (" args = %d\n", arg1);
1360 int i = dbeGetPrintLimit (arg1);
1361 ipc_log (" returns = %d\n", i);
1364 else if (!strcmp (inp, "setPrintLimit"))
1366 int arg1 = readInt (req);
1367 int arg2 = readInt (req);
1368 ipc_log (" args = %d, %d\n", arg1, arg2);
1369 String res = dbeSetPrintLimit (arg1, arg2);
1370 writeString (res, req);
1373 else if (!strcmp (inp, "getPrintMode"))
1375 int arg1 = readInt (req);
1376 ipc_log (" args = %d\n", arg1);
1377 int i = dbeGetPrintMode (arg1);
1378 ipc_log (" returns = %d\n", i);
1381 else if (!strcmp (inp, "setPrintMode"))
1383 int arg1 = readInt (req);
1384 String arg2 = readString (req);
1385 ipc_log (" args = %d, %s\n", arg1, arg2);
1386 String res = dbeSetPrintMode (arg1, arg2);
1387 writeString (res, req);
1391 else if (!strcmp (inp, "getPrintDelim"))
1393 int arg1 = readInt (req);
1394 ipc_log (" args = %d\n", arg1);
1395 char i = dbeGetPrintDelim (arg1);
1396 ipc_log (" returns = %c\n", i);
1397 writeInt ((int) i, req);
1399 else if (!strcmp (inp, "getHotMarks"))
1401 int arg1 = readInt (req);
1402 int arg2 = readInt (req);
1403 ipc_log (" args = %d, %s (%d) \n", arg1, table_name (arg2), arg2);
1404 Vector<void*> *res = dbeGetHotMarks (arg1, arg2);
1405 writeArray (res, req);
1408 else if (!strcmp (inp, "getHotMarksInc"))
1410 int arg1 = readInt (req);
1411 int arg2 = readInt (req);
1412 ipc_log (" args = %d, %s (%d) \n", arg1, table_name (arg2), arg2);
1413 Vector<void*> *res = dbeGetHotMarksInc (arg1, arg2);
1414 writeArray (res, req);
1417 else if (!strcmp (inp, "getSummaryHotMarks"))
1419 int arg1 = readInt (req);
1420 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req);
1421 int arg3 = readInt (req);
1422 ipc_log (" args = %d, 0x%llx, %s (%d)\n", arg1, (long long) arg2, table_name (arg3), arg3);
1423 Vector<void*> *res = dbeGetSummaryHotMarks (arg1, arg2, arg3);
1424 writeArray (res, req);
1427 else if (!strcmp (inp, "getFuncId"))
1429 int arg1 = readInt (req);
1430 int arg2 = readInt (req);
1431 int arg3 = readInt (req);
1432 int arg4 = readInt (req);
1433 ipc_log (" args = %d, %s, %d, %d\n", arg1, table_name (arg2), arg3, arg4);
1434 Vector<uint64_t> *res = dbeGetFuncId (arg1, arg2, arg3, arg4);
1435 writeArray (res, req);
1438 else if (!strcmp (inp, "getFuncCalleeInfo"))
1440 int arg1 = readInt (req);
1441 int arg2 = readInt (req);
1442 Vector<int> *arg3 = (Vector<int>*)readArray (req);
1443 int arg4 = readInt (req);
1444 ipc_log (" args = %d, %s, %lld, %d\n", arg1, table_name (arg2), VSIZE (arg3), arg4);
1445 Vector<void*> *res = dbeGetFuncCalleeInfo (arg1, arg2, arg3, arg4);
1446 writeArray (res, req);
1449 else if (!strcmp (inp, "getFuncCallerInfo"))
1451 int arg1 = readInt (req);
1452 int arg2 = readInt (req);
1453 Vector<int> *arg3 = (Vector<int>*)readArray (req);
1454 int arg4 = readInt (req);
1455 ipc_log (" args = %d, %s, %lld, %d\n", arg1, table_name (arg2), VSIZE (arg3), arg4);
1456 Vector<void*> *res = dbeGetFuncCallerInfo (arg1, arg2, arg3, arg4);
1457 writeArray (res, req);
1460 else if (!strcmp (inp, "setFuncData"))
1462 int arg1 = readInt (req);
1463 Obj arg2 = readObject (req);
1464 int arg3 = readInt (req);
1465 int arg4 = readInt (req);
1466 ipc_log (" args = %d, %ld, %s, %d\n", arg1, (long) arg2, table_name (arg3), arg4);
1467 int i = dbeSetFuncData (arg1, arg2, arg3, arg4);
1468 ipc_log (" returns = %d\n", i);
1471 else if (!strcmp (inp, "setFuncDataV2"))
1473 int dbevindex = readInt (req);
1474 Obj sel_obj = readObject (req);
1475 int type = readInt (req);
1476 int subtype = readInt (req);
1477 Vector<long long> *longs = new Vector<long long>(2);
1478 Vector<char *> *strings = new Vector<char *>(2);
1480 longs->append (dbeSetFuncData (dbevindex, sel_obj, type, subtype));
1481 strings->append (dbeGetMsg (dbevindex, ERROR_MSG));
1482 String sf_name = NULL;
1483 long long sf_id = 0;
1489 Histable *obj = (Histable *) sel_obj;
1492 Histable *sf = obj->convertto (Histable::SOURCEFILE);
1496 sf_name = dbe_strdup (sf->get_name ());
1502 longs->append (sf_id);
1503 strings->append (sf_name);
1504 ipc_log (" setFuncData(%d, %ld, %s, %d) returns (%lld, %lld)\n (%s, %s)\n",
1505 dbevindex, (long) sel_obj, table_name (type), subtype, longs->get (0), longs->get (1),
1506 STR (strings->get (0)), STR (strings->get (1)));
1508 Vector<void *> *res = new Vector<void *>(2);
1509 res->append (longs);
1510 res->append (strings);
1511 writeArray (res, req);
1514 else if (!strcmp (inp, "getFuncList"))
1516 int arg1 = readInt (req);
1517 int arg2 = readInt (req);
1518 int arg3 = readInt (req);
1519 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3);
1520 Vector<void*> *res = dbeGetFuncList (arg1, arg2, arg3);
1523 ipc_log (" returns = %lld objects, length = %lld\n",
1524 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1526 ipc_log (" returns NULL\n");
1528 writeArray (res, req);
1531 else if (!strcmp (inp, "getFuncListV2"))
1533 int dbevindex = readInt (req);
1534 int mtype = readInt (req);
1535 Obj sel_obj = readObject (req);
1536 int type = readInt (req);
1537 int subtype = readInt (req);
1538 Vector<void*> *res = dbeGetFuncListV2 (dbevindex, mtype, sel_obj, type, subtype);
1539 ipc_log (" args = %d 0x%x %ld, %s, %d returns = %d objects, length = %d\n",
1540 dbevindex, mtype, (long) sel_obj, table_name (type), subtype,
1541 (int) (res ? res->size () : 0),
1542 (int) (res ? ((Vector<int>*)res->fetch (0))->size () : 0));
1543 writeArray (res, req);
1546 else if (!strcmp (inp, "getFuncListMini"))
1548 int arg1 = readInt (req);
1549 int arg2 = readInt (req);
1550 int arg3 = readInt (req);
1551 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3);
1552 Vector<void*> *res = dbeGetFuncListMini (arg1, arg2, arg3);
1555 ipc_log (" returns = %lld objects, length = %lld\n",
1556 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1558 ipc_log (" returns NULL\n");
1560 writeArray (res, req);
1563 else if (!strcmp (inp, "dbeGetTotals"))
1565 int dbevindex = readInt (req);
1566 int dsptype = readInt (req);
1567 int subtype = readInt (req);
1568 Vector<void *> *res = dbeGetTotals (dbevindex, dsptype, subtype);
1569 ipc_log (" dbeGetTotals(%d, %d, %d) returns %lld objects\n",
1570 dbevindex, dsptype, subtype, VSIZE (res));
1571 writeArray (res, req);
1574 else if (!strcmp (inp, "getComparableObjsV2"))
1576 int arg1 = readInt (req);
1577 Obj arg2 = readObject (req);
1578 int arg3 = readInt (req);
1579 Vector<Obj> *res = dbeGetComparableObjsV2 (arg1, arg2, arg3);
1580 ipc_log (" args = %d 0x%lx %d\n", arg1, (long) arg2, arg3);
1581 ipc_dump ("getComparableObjsV2:res", res);
1582 writeArray (res, req);
1585 else if (!strcmp (inp, "dbeConvertSelObj"))
1587 Obj obj = readObject (req);
1588 int type = readInt (req);
1589 Obj res = dbeConvertSelObj (obj, type);
1590 ipc_log (" args = %lld %d res=%lld \n", (long long) obj, type,
1592 writeObject (res, req);
1594 else if (!strcmp (inp, "getTableDataV2"))
1596 int arg1 = readInt (req);
1597 String arg2 = readString (req);
1598 String arg3 = readString (req);
1599 String arg4 = readString (req);
1600 String arg5 = readString (req);
1601 Vector<uint64_t> *arg6 = (Vector<uint64_t>*)readArray (req);
1602 ipc_log (" args = %d, %s, %s, %s, %s, %lld\n", arg1, STR (arg2),
1603 STR (arg3), STR (arg4), STR (arg5), VSIZE (arg6));
1604 Vector<void*> *res = dbeGetTableDataV2 (arg1, arg2, arg3, arg4, arg5, arg6);
1607 ipc_log (" returns = %lld objects, length = %lld\n",
1608 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1610 ipc_log (" returns NULL\n");
1612 writeArray (res, req);
1616 else if (!strcmp (inp, "getCallTreeNumLevels"))
1618 int arg1 = readInt (req);
1619 ipc_log (" args = %d\n", arg1);
1620 int res = dbeGetCallTreeNumLevels (arg1);
1622 ipc_log (" returns = %d\n", res);
1624 writeInt (res, req);
1626 else if (!strcmp (inp, "getCallTreeLevel"))
1628 int arg1 = readInt (req);
1629 String arg2 = readString (req);
1630 int arg3 = readInt (req);
1631 ipc_log (" args = %d, %s, %d\n", arg1, arg2, arg3);
1632 Vector<void*> *res = dbeGetCallTreeLevel (arg1, arg2, arg3);
1633 writeArray (res, req);
1636 else if (!strcmp (inp, "getCallTreeChildren"))
1638 int arg1 = readInt (req);
1639 String arg2 = readString (req);
1640 Vector<int> *arg3 = (Vector<int> *) readArray (req); /*NodeIdx array*/
1641 ipc_log (" args = %d, %s, vec_size=%lld\n", arg1, arg2, (long long) (arg3 ? arg3->size () : 0));
1642 Vector<void*> *res = dbeGetCallTreeChildren (arg1, arg2, arg3);
1643 writeArray (res, req);
1646 else if (!strcmp (inp, "getCallTreeLevels"))
1648 int arg1 = readInt (req);
1649 String arg2 = readString (req);
1650 ipc_log (" args = %d, %s\n", arg1, arg2);
1651 Vector<void*> *res = dbeGetCallTreeLevels (arg1, arg2);
1652 writeArray (res, req);
1655 else if (!strcmp (inp, "getCallTreeLevelFuncs"))
1657 int arg1 = readInt (req);
1658 int arg2 = readInt (req);
1659 int arg3 = readInt (req);
1660 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3);
1661 Vector<void*> *res = dbeGetCallTreeLevelFuncs (arg1, arg2, arg3);
1662 writeArray (res, req);
1665 else if (!strcmp (inp, "getCallTreeFuncs"))
1667 int arg1 = readInt (req);
1668 ipc_log (" args = %d\n", arg1);
1669 Vector<void*> *res = dbeGetCallTreeFuncs (arg1);
1670 writeArray (res, req);
1673 else if (!strcmp (inp, "getGroupIds"))
1675 int arg1 = readInt (req);
1676 Vector<int> *res = dbeGetGroupIds (arg1);
1677 writeArray (res, req);
1680 else if (!strcmp (inp, "getNames"))
1682 int arg1 = readInt (req);
1683 int arg2 = readInt (req);
1684 Obj arg3 = readObject (req);
1686 ipc_log (" args = %d, %s 0x%lx\n", arg1, table_name (arg2), (long) arg3);
1688 Vector<String> *res = dbeGetNames (arg1, arg2, arg3);
1689 writeArray (res, req);
1692 else if (!strcmp (inp, "getTotalMax"))
1694 int arg1 = readInt (req);
1695 int arg2 = readInt (req);
1696 int arg3 = readInt (req);
1697 ipc_log (" args = %d, %s, %d\n", arg1, table_name (arg2), arg3);
1698 Vector<void*> *res = dbeGetTotalMax (arg1, arg2, arg3);
1701 ipc_log (" returns = %lld vectors, length %lld\n",
1702 VSIZE (res), VSIZE ((Vector<void*>*)res->fetch (0)));
1704 ipc_log (" returns NULL\n");
1706 writeArray (res, req);
1709 else if (!strcmp (inp, "composeFilterClause"))
1711 int arg1 = readInt (req);
1712 int arg2 = readInt (req);
1713 int arg3 = readInt (req);
1714 Vector<int> *arg4 = (Vector<int>*)readArray (req);
1715 ipc_log (" args = %d, %s, %d, %lld selections\n",
1716 arg1, table_name (arg2), arg3, VSIZE (arg4));
1717 String s = dbeComposeFilterClause (arg1, arg2, arg3, arg4);
1718 ipc_log (" returns %s\n", (s == NULL ? "<NULL>" : s));
1719 writeString (s, req);
1721 else if (!strcmp (inp, "getStatisOverviewList"))
1723 int arg1 = readInt (req);
1724 ipc_log (" args = %d\n", arg1);
1725 Vector<Object> *res = dbeGetStatisOverviewList (arg1);
1726 ipc_log (" dbeStatisGetOverviewList returns = %lld objects\n", VSIZE (res));
1727 writeArray (res, req);
1730 else if (!strcmp (inp, "getStatisList"))
1732 int arg1 = readInt (req);
1733 ipc_log (" args = %d\n", arg1);
1734 Vector<Object> *res = dbeGetStatisList (arg1);
1735 ipc_log (" returns = %lld objects\n", VSIZE (res));
1736 writeArray (res, req);
1739 else if (!strcmp (inp, "getSummary"))
1741 int arg1 = readInt (req);
1742 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req);
1743 int arg3 = readInt (req);
1744 int arg4 = readInt (req);
1745 ipc_log (" args = %d, 0x%llx, %s (%d), %d\n", arg1, (long long) arg2, table_name (arg3), arg3, arg4);
1746 Vector<Object> *res = dbeGetSummary (arg1, arg2, arg3, arg4);
1747 ipc_log (" dbeGetSummary returns = %lld objects\n", VSIZE (res));
1748 writeArray (res, req);
1751 else if (!strcmp (inp, "getSummaryV2"))
1753 int dbevindex = readInt (req);
1754 Vector<Obj> *sel_objs = (Vector<Obj>*)readArray (req);
1755 int type = readInt (req);
1756 int subtype = readInt (req);
1757 Vector<void*> *res = dbeGetSummaryV2 (dbevindex, sel_objs, type, subtype);
1758 ipc_log (" args = %d, [%lld], %s (%d), %d res=[%lld] 0x%llx \n",
1759 dbevindex, VSIZE (sel_objs), table_name (type), type, subtype,
1760 VSIZE (res), (unsigned long long) res);
1761 writeArray (res, req);
1764 else if (!strcmp (inp, "getExpName1"))
1766 // XXX add an argument = DbeView index
1767 String arg1 = readString (req);
1768 ipc_log (" arg = `%s'\n", arg1 ? arg1 : "NULL");
1769 String res = dbeGetExpName (0, arg1);
1770 writeString (res, req);
1771 ipc_log (" returns `%s'\n", res ? res : "NULL");
1775 else if (!strcmp (inp, "getHwcHelp"))
1777 // XXX add an argument = DbeView index
1778 bool forKernel = readBoolean (req);
1779 Vector<String> *res = dbeGetHwcHelp (0, forKernel);
1780 writeArray (res, req);
1783 else if (!strcmp (inp, "getHwcSets"))
1785 // XXX add an argument = DbeView index
1786 bool forKernel = readBoolean (req);
1787 Vector<Vector<char*>*> *res = dbeGetHwcSets (0, forKernel);
1788 writeArray (res, req);
1789 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1792 else if (!strcmp (inp, "getHwcsAll"))
1794 // XXX add an argument = DbeView index
1795 bool forKernel = readBoolean (req);
1796 Vector<void*> *res = dbeGetHwcsAll (0, forKernel);
1797 writeArray (res, req);
1798 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1801 else if (!strcmp (inp, "getHwcAttrList"))
1803 // XXX add an argument = DbeView index
1804 bool forKernel = readBoolean (req);
1805 Vector<char*> *res = dbeGetHwcAttrList (0, forKernel);
1806 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1807 writeArray (res, req);
1810 else if (!strcmp (inp, "getHwcMaxConcurrent"))
1812 // XXX add an argument = DbeView index
1813 bool forKernel = readBoolean (req);
1814 int res = dbeGetHwcMaxConcurrent (0, forKernel);
1815 writeInt (res, req);
1817 else if (!strcmp (inp, "getIfreqData"))
1819 int arg1 = readInt (req);
1820 ipc_log (" args = %d\n", arg1);
1821 Vector<char*> *res = dbeGetIfreqData (arg1);
1822 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1823 writeArray (res, req);
1826 else if (!strcmp (inp, "getNewLeakListInfo"))
1828 int arg1 = readInt (req);
1829 bool arg2 = readBoolean (req);
1830 ipc_log (" args = %d, %d\n", arg1, arg2);
1831 Vector<void*> *res = dbeGetLeakListInfo (arg1, arg2);
1832 ipc_log (" returns %lld void*'s\n", VSIZE (res));
1833 writeArray (res, req);
1836 else if (!strcmp (inp, "getObject"))
1838 int arg1 = readInt (req);
1839 Obj arg2 = readObject (req);
1840 Obj arg3 = readObject (req);
1841 Obj i = dbeGetObject (arg1, arg2, arg3);
1842 writeObject (i, req);
1844 else if (!strcmp (inp, "getExpVerboseName"))
1846 Vector<int> *arg = (Vector<int>*)readArray (req);
1847 ipc_log (" expIds = %lld\n", VSIZE (arg));
1848 Vector<String> *res = dbeGetExpVerboseName (arg);
1849 ipc_log (" returns = %lld objects\n", VSIZE (res));
1850 writeArray (res, req);
1853 else if (!strcmp (inp, "getName"))
1855 // XXX add an argument = DbeView index
1856 int arg1 = readInt (req);
1857 String res = dbeGetName (0, arg1);
1858 writeString (res, req);
1861 else if (!strcmp (inp, "getStartTime"))
1863 // XXX add an argument = DbeView index
1864 int arg1 = readInt (req);
1865 long long l = dbeGetStartTime (0, arg1);
1866 ipc_log (" returns = %llu\n", l);
1869 else if (!strcmp (inp, "getRelativeStartTime"))
1871 // XXX add an argument = DbeView index
1872 int arg1 = readInt (req);
1873 long long l = dbeGetRelativeStartTime (0, arg1);
1874 ipc_log (" returns = %llu\n", l);
1877 else if (!strcmp (inp, "getEndTime"))
1879 // XXX add an argument = DbeView index
1880 int arg1 = readInt (req);
1881 long long l = dbeGetEndTime (0, arg1);
1882 ipc_log (" returns = %llu\n", l);
1885 else if (!strcmp (inp, "getClock"))
1887 // XXX add an argument = DbeView index
1888 int arg1 = readInt (req);
1889 int i = dbeGetClock (0, arg1);
1893 else if ( !strcmp( inp, "getFounderExpId" ) ) {
1894 // XXX add an argument = DbeView index
1895 int arg1 = readInt(req);
1896 int i = dbeGetFounderExpId(0, arg1 );
1900 else if (!strcmp (inp, "getEntityProps"))
1902 int arg1 = readInt (req);
1903 ipc_log (" args = %d\n", arg1);
1904 Vector<void*> *res = dbeGetEntityProps (arg1);
1905 writeArray (res, req);
1906 ipc_log (" returns = %lld objects\n", VSIZE (res));
1909 else if (!strcmp (inp, "getEntities"))
1911 int arg1 = readInt (req);
1912 int arg2 = readInt (req);
1913 int arg3 = readInt (req);
1914 ipc_log (" args = %d, %d, %d\n", arg1, arg2, arg3);
1915 Vector<void*> *res = dbeGetEntities (arg1, arg2, arg3);
1916 writeArray (res, req);
1917 ipc_log (" returns = %lld objects\n", VSIZE (res));
1920 else if (!strcmp (inp, "getEntitiesV2"))
1922 int arg1 = readInt (req);
1923 Vector<int> *arg2 = (Vector<int>*)readArray (req);
1924 int arg3 = readInt (req);
1925 ipc_log (" args = %d, %lld, %d\n", arg1, VSIZE (arg2), arg3);
1926 Vector<void*> *res = dbeGetEntitiesV2 (arg1, arg2, arg3);
1927 writeArray (res, req);
1928 ipc_log (" returns = %lld objects\n", VSIZE (res));
1931 else if (!strcmp (inp, "getTLDetails"))
1933 int arg1 = readInt (req);
1934 int arg2 = readInt (req);
1935 int arg3 = readInt (req);
1936 int arg4 = readInt (req);
1937 long long arg5 = readLong (req);
1938 ipc_log (" dbevindex= %d, exp_id = %d, data_id = %d, "
1939 "entity_prop_id = %d, event_id = %lld\n",
1940 arg1, arg2, arg3, arg4, arg5);
1941 Vector<void*> *res = dbeGetTLDetails (arg1, arg2, arg3, arg4, arg5);
1942 ipc_log (" returns = %lld objects\n", VSIZE (res));
1943 writeArray (res, req);
1946 else if (!strcmp (inp, "getStackNames"))
1948 int arg1 = readInt (req);
1949 Obj arg2 = readObject (req);
1950 ipc_log (" args = %d, %ld\n", arg1, (long) arg2);
1951 Vector<String> *res = dbeGetStackNames (arg1, arg2);
1952 ipc_log (" returns = %lld objects\n", VSIZE (res));
1953 writeArray (res, req);
1956 else if (!strcmp (inp, "getStackFunctions"))
1958 // XXX add an argument = DbeView index
1959 Obj arg1 = readObject (req);
1960 ipc_log (" args = %ld\n", (long) arg1);
1961 Vector<Obj> *res = dbeGetStackFunctions (0, arg1);
1962 ipc_log (" returns = %lld objects\n", VSIZE (res));
1963 writeArray (res, req);
1966 else if (!strcmp (inp, "getStacksFunctions"))
1968 // XXX add an argument = DbeView index
1969 Vector<Obj> *arg1 = (Vector<Obj>*)readArray (req);
1970 ipc_log (" argc = %ld\n", (long) arg1->size ());
1971 Vector<void*> *res = dbeGetStacksFunctions (0, arg1);
1972 ipc_log (" returns = %lld objects\n", VSIZE (res));
1973 writeArray (res, req);
1976 else if (!strcmp (inp, "getStackPCs"))
1978 // XXX add an argument = DbeView index
1979 Obj arg1 = readObject (req);
1980 ipc_log (" args = %ld\n", (long) arg1);
1981 Vector<Obj> *res = dbeGetStackPCs (0, arg1);
1982 ipc_log (" returns = %lld objects\n", VSIZE (res));
1983 writeArray (res, req);
1986 else if (!strcmp (inp, "getIOStatistics"))
1988 int dbevindex = readInt (req);
1989 Vector<Vector<char*>*> *res = dbeGetIOStatistics (dbevindex);
1990 writeArray (res, req);
1991 ipc_log (" returns %lld char*'s\n", VSIZE (res));
1994 else if (!strcmp (inp, "getHeapStatistics"))
1996 int dbevindex = readInt (req);
1997 Vector<Vector<char*>*> *res = dbeGetHeapStatistics (dbevindex);
1998 writeArray (res, req);
1999 ipc_log (" returns %lld char*'s\n", VSIZE (res));
2002 else if (!strcmp (inp, "getSamples"))
2004 int dbev_id = readInt (req);
2005 int exp_id = readInt (req);
2006 int64_t lo = readLong (req);
2007 int64_t hi = readLong (req);
2008 ipc_log (" dbevindex= %d, exp_id = %d, lo_idx:%lld, hi_idx:%lld\n",
2009 dbev_id, exp_id, (long long) lo, (long long) hi);
2010 Vector<void*> *res = dbeGetSamples (dbev_id, exp_id, lo, hi);
2011 writeArray (res, req);
2014 else if (!strcmp (inp, "getGCEvents"))
2016 int dbev_id = readInt (req);
2017 int exp_id = readInt (req);
2018 int64_t lo = readLong (req);
2019 int64_t hi = readLong (req);
2020 ipc_log (" dbevindex= %d, exp_id = %d, lo_idx:%lld, hi_idx:%lld\n",
2021 dbev_id, exp_id, (long long) lo, (long long) hi);
2022 Vector<void*> *res = dbeGetGCEvents (dbev_id, exp_id, lo, hi);
2023 writeArray (res, req);
2026 else if (!strcmp (inp, "getFuncNames"))
2028 int arg1 = readInt (req);
2029 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req);
2030 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2));
2031 Vector<String> *res = dbeGetFuncNames (arg1, arg2);
2032 writeArray (res, req);
2036 else if (!strcmp (inp, "getFuncIds"))
2038 int arg1 = readInt (req);
2039 Vector<Obj> *arg2 = (Vector<Obj>*)readArray (req);
2040 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2));
2041 Vector<uint64_t> *res = dbeGetFuncIds (arg1, arg2);
2042 writeArray (res, req);
2046 else if (!strcmp (inp, "getObjNamesV2"))
2048 int arg1 = readInt (req);
2049 Vector<uint64_t> *arg2 = (Vector<uint64_t>*)readArray (req);
2050 ipc_log (" arg1 = %d, arg2 absent, size = %lld\n", arg1, VSIZE (arg2));
2051 Vector<String> *res = dbeGetObjNamesV2 (arg1, arg2);
2052 writeArray (res, req);
2056 else if (!strcmp (inp, "getFuncName"))
2058 int arg1 = readInt (req);
2059 Obj arg2 = readObject (req);
2060 ipc_log (" arg1 = %d, arg2 = %lld\n", arg1, (long long) arg2);
2061 String res = dbeGetFuncName (arg1, arg2);
2062 ipc_log (" returning = %s\n", res ? res : "NULL");
2063 writeString (res, req);
2066 else if (!strcmp (inp, "getObjNameV2"))
2068 int arg1 = readInt (req);
2069 uint64_t arg2 = readLong (req);
2070 ipc_log (" arg1 = %d, arg2 = %llu\n", arg1, (unsigned long long) arg2);
2071 String res = dbeGetObjNameV2 (arg1, arg2);
2072 ipc_log (" returning = %s\n", res ? res : "NULL");
2073 writeString (res, req);
2076 else if (!strcmp (inp, "getDataspaceTypeDesc"))
2078 // XXX add an argument = DbeView index
2079 Obj arg1 = readObject (req);
2080 ipc_log (" arg1 absent, index = %ld\n", (long) arg1);
2081 String res = dbeGetDataspaceTypeDesc (0, arg1);
2082 ipc_log (" returning = %s\n", res ? res : "NULL");
2083 writeString (res, req);
2087 * New Interface with Timeline
2090 else if (!strcmp (inp, "dbeInit"))
2092 else if (!strcmp (inp, "getDefaultExperimentName"))
2094 String res = dbeGetDefaultExperimentName ();
2095 ipc_log (" returning = %s\n", res);
2099 else if (!strcmp (inp, "getExperimentState"))
2101 String res = dbeGetExperimentState ();
2102 ipc_log (" returning = %s\n", res);
2106 else if (!strcmp (inp, "getExpStartTime"))
2108 long long l = dbeGetExpStartTime ();
2109 ipc_log (" returns = %llu\n", l);
2112 else if (!strcmp (inp, "getExpEndTime"))
2114 long long l = dbeGetExpEndTime ();
2115 ipc_log (" returns = %llu\n", l);
2119 else if (!strcmp (inp, "getDataDescriptorsV2"))
2121 int exp_id = readInt (req);
2122 ipc_log (" exp_id = %d\n", exp_id);
2123 Vector<void*> *res = dbeGetDataDescriptorsV2 (exp_id);
2124 ipc_log (" returns = %lld objects\n", VSIZE (res));
2125 writeArray (res, req);
2128 else if (!strcmp (inp, "getDataPropertiesV2"))
2130 int exp_id = readInt (req);
2131 int arg2 = readInt (req);
2132 ipc_log (" exp_id = %d, data_idx = %d\n", exp_id, arg2);
2133 Vector<void*> *res = dbeGetDataPropertiesV2 (exp_id, arg2);
2134 ipc_log (" returns = %lld objects\n", VSIZE (res));
2135 writeArray (res, req);
2138 else if (!strcmp (inp, "getExperimentTimeInfo"))
2140 Vector<int> *exp_ids = (Vector<int>*)readArray (req);
2141 ipc_log (" cnt = %lld\n", VSIZE (exp_ids));
2142 Vector<void*> *res = dbeGetExperimentTimeInfo (exp_ids);
2143 ipc_log (" returns = %lld objects\n", VSIZE (res));
2144 writeArray (res, req);
2147 else if (!strcmp (inp, "getExperimentDataDescriptors"))
2149 Vector<int> *exp_ids = (Vector<int>*)readArray (req);
2150 ipc_log (" cnt = %lld\n", VSIZE (exp_ids));
2151 Vector<void*> *res = dbeGetExperimentDataDescriptors (exp_ids);
2152 ipc_log (" returns = %lld objects\n", VSIZE (res));
2153 writeArray (res, req);
2157 else if (!strcmp (inp, "getExprValues"))
2159 int arg1 = readInt ();
2160 String arg2 = readString ();
2161 ipc_log (" data_idx = %d expr = %s\n", arg1, arg2 ? arg2 : "NULL");
2162 Vector<long long> *res = dbeGetExprValues (arg1, arg2);
2163 ipc_log (" returns = %d objects\n", res ? res->size () : 0);
2169 else if (!strcmp (inp, "hasTLData"))
2171 int dbevindex = readInt (req);
2172 Vector<int> *exp_ids = (Vector<int>*)readArray (req);
2173 Vector<int> *data_ids = (Vector<int>*)readArray (req);
2174 Vector<int> *eprop_ids = (Vector<int>*)readArray (req);
2175 Vector<int> *eprop_vals = (Vector<int>*)readArray (req);
2176 Vector<int> *auxs = (Vector<int>*)readArray (req);
2177 ipc_log (" dbev_id = %d, cnt = %lld\n", dbevindex, VSIZE (exp_ids));
2178 Vector<bool> *res = dbeHasTLData (dbevindex,
2179 exp_ids, data_ids, eprop_ids, eprop_vals, auxs);
2180 writeArray (res, req);
2183 else if (!strcmp (inp, "getTLData"))
2185 int dbevindex = readInt (req);
2186 int exp_id = readInt (req);
2187 int tldata_type = readInt (req);
2188 int entity_prop_id = readInt (req);
2189 int entity_prop_val = readInt (req);
2190 int aux = readInt (req);
2191 long long arg5 = readLong (req);
2192 long long arg6 = readLong (req);
2193 int arg7 = readInt (req);
2194 bool getReps = readBoolean (req);
2195 Vector<String> *secondaryProps = (Vector<String>*)readArray (req);
2197 ipc_log (" args = %d:%d; tldata_type=%d entity_prop_id=%d ent=%d aux=%d"
2198 "\n tstart=%lld delta=%lld ndeltas=%d getReps=%d nProps=%lld\n",
2200 tldata_type, entity_prop_id, entity_prop_val, aux,
2201 arg5, arg6, arg7, (int) getReps, VSIZE (secondaryProps));
2202 Vector<void*> *res = dbeGetTLData (dbevindex, exp_id,
2203 tldata_type, entity_prop_id, entity_prop_val, aux,
2204 arg5, arg6, arg7, getReps, secondaryProps);
2208 Vector<Obj> *reps = (Vector<Obj>*)res->fetch (0);
2209 Vector<Obj> *props = (Vector<Obj>*)res->fetch (1);
2212 Vector <long long> *fids = (Vector <long long> *)reps->fetch (2);
2213 int sz = fids ? fids->size () : 0;
2214 ipc_log (" returning TL reps (dDscrs); nreps=%d:", sz);
2216 for (i = 0; i < sz && i < 7; i++)
2217 ipc_log (" %lld", fids->fetch (i));
2219 ipc_log (" ... %lld", fids->fetch (sz - 1));
2224 int nprops = props->size ();
2225 ipc_log (" returning values for %d properties:\n", nprops);
2226 assert (secondaryProps->size () == nprops);
2230 ipc_log (" returning NULL\n");
2232 writeArray (res, req);
2234 destroy (secondaryProps);
2236 else if (!strcmp (inp, "getTLEventCenterTime"))
2238 int dbevindex = readInt (req);
2239 int exp_id = readInt (req);
2240 int tldata_type = readInt (req);
2241 int entity_prop_id = readInt (req);
2242 int entity_prop_val = readInt (req);
2243 int aux = readInt (req);
2244 long long event_id = readLong (req);
2245 long long move_count = readLong (req);
2246 ipc_log (" args = %d:%d; tldata_type = %d entity_prop_id = %d "
2247 "ent = %d aux = %d idx = %lld move=%lld\n",
2249 tldata_type, entity_prop_id, entity_prop_val, aux, event_id, move_count);
2250 Vector<long long> * res = dbeGetTLEventCenterTime (dbevindex, exp_id,
2251 tldata_type, entity_prop_id, entity_prop_val, aux, event_id, move_count);
2252 ipc_log (" returning idx = %lld, time = %lld\n",
2253 res ? res->fetch (0) : -1, res ? res->fetch (1) : -1);
2254 writeArray (res, req);
2256 else if (!strcmp (inp, "getTLEventIdxNearTime"))
2258 int dbevindex = readInt (req);
2259 int exp_id = readInt (req);
2260 int tldata_type = readInt (req);
2261 int entity_prop_id = readInt (req);
2262 int entity_prop_val = readInt (req);
2263 int aux = readInt (req);
2264 int searchDirection = readInt (req);
2265 long long value = readLong (req);
2266 ipc_log (" args = %d:%d; tldata_type = %d entity_prop_id = %d "
2267 "ent = %d aux = %d direction = %d value = %lld(0x%llx)\n",
2269 tldata_type, entity_prop_id, entity_prop_val, aux,
2270 searchDirection, value, value);
2271 long long res = dbeGetTLEventIdxNearTime (dbevindex, exp_id,
2272 tldata_type, entity_prop_id, entity_prop_val, aux,
2273 searchDirection, value);
2274 ipc_log (" returning = %lld\n", res);
2275 writeLong (res, req);
2277 else if (!strcmp (inp, "getAggregatedValue"))
2279 int arg1 = readInt (req);
2280 String arg2 = readString (req);
2281 String arg3 = readString (req);
2282 String arg4 = readString (req);
2283 long long arg5 = readLong (req);
2284 long long arg6 = readLong (req);
2285 int arg7 = readInt (req);
2286 String arg8 = readString (req);
2287 String arg9 = readString (req);
2288 ipc_log (" data_idx = %d lfilter = \"%s\" fexpr = \"%s\" "
2289 "time = \"%s\" tstart = %lld delta = %lld "
2290 "num = %d key = \"%s\" aggr = \"%s\"\n",
2291 arg1, arg2 ? arg2 : "NULL", arg3 ? arg3 : "NULL",
2292 arg4 ? arg4 : "NULL", arg5, arg6,
2293 arg7, arg8 ? arg8 : "NULL", arg9 ? arg9 : "NULL");
2294 Vector<long long> *res = dbeGetAggregatedValue (arg1, arg2, arg3,
2295 arg4, arg5, arg6, arg7, arg8, arg9);
2299 int sz = res->size ();
2300 ipc_log (" returning = %d values:", sz);
2303 for (int i = 0; i < sz; i++)
2304 ipc_log (" %lld", res->fetch (i));
2308 ipc_log (" returning NULL\n");
2310 writeArray (res, req);
2319 else if (!strcmp (inp, "getExprValue"))
2321 int exp_id = readInt ();
2322 int arg1 = readInt ();
2323 int arg2 = readInt ();
2324 String arg3 = readString ();
2325 ipc_log (" exp_id %d, data_id = %d, event_id = %d, expr = %s\n",
2326 exp_id, arg1, arg2, arg3 ? arg3 : "NULL");
2327 String res = dbeGetExprValue (exp_id, arg1, arg2, arg3);
2328 ipc_log (" returning = %s\n", res ? res : "");
2333 else if (!strcmp (inp, "getListValues"))
2335 Obj arg1 = readObject ();
2336 ipc_log (" stack = %lu\n", (long) arg1);
2337 Vector<Obj> *res = dbeGetListValues (arg1);
2338 ipc_log (" returns = %d objects\n", res ? res->size () : 0);
2342 else if (!strcmp (inp, "getListNames"))
2344 Obj arg1 = readObject ();
2345 ipc_log (" stack = %lu\n", (long) arg1);
2346 Vector<String> *res = dbeGetListNames (arg1);
2347 ipc_log (" returns = %d objects\n", res ? res->size () : 0);
2352 else if (!strcmp (inp, "getLineInfo"))
2354 Obj arg1 = readObject (req);
2355 ipc_log (" pc = %lu\n", (long) arg1);
2356 Vector<String> *res = dbeGetLineInfo (arg1);
2357 ipc_log (" returning File name: '%s'\n", res ? res->fetch (0) : "");
2358 ipc_log (" returning Lineno: '%s'\n", res ? res->fetch (1) : "");
2359 writeArray (res, req);
2362 else if (!strcmp (inp, "setAlias"))
2364 String arg1 = readString (req);
2365 String arg2 = readString (req);
2366 String arg3 = readString (req);
2367 ipc_log (" name=\"%s\" uname=\"%s\" expr=\"%s\"\n",
2368 arg1 ? arg1 : "", arg2 ? arg2 : "", arg3 ? arg3 : "");
2369 int res = dbeSetAlias (arg1, arg2, arg3);
2370 ipc_log (" returning = %d\n", res);
2371 writeInt (res, req);
2373 else if (!strcmp (inp, "getAlias"))
2375 String arg1 = readString (req);
2376 ipc_log (" name=\"%s\"\n", arg1 ? arg1 : "");
2377 Vector<char*> *res = dbeGetAlias (arg1);
2378 ipc_log (" returning uname: '%s'\n", res && res->fetch (0) ? res->fetch (0) : "");
2379 ipc_log (" returning expr: '%s'\n", res && res->fetch (1) ? res->fetch (0) : "");
2380 writeArray (res, req);
2383 else if (!strcmp (inp, "getXYPlotData"))
2385 int arg1 = readInt (req);
2386 String arg2 = readString (req);
2387 String arg3 = readString (req);
2388 String arg4 = readString (req);
2389 String arg5 = readString (req);
2390 String arg6 = readString (req);
2391 String arg7 = readString (req);
2392 String arg8 = readString (req);
2393 String arg9 = readString (req);
2394 ipc_log (" data_idx = %d lfilter = \"%s\" arg = \"%s\" "
2395 "func1 = \"%s\" aggr1 = \"%s\" "
2396 "func2 = \"%s\" aggr2 = \"%s\" "
2397 "func3 = \"%s\" aggr3 = \"%s\" \n",
2398 arg1, arg2 ? arg2 : "NULL", arg3 ? arg3 : "NULL",
2399 arg4 ? arg4 : "NULL", arg5 ? arg5 : "NULL", arg6 ? arg6 : "NULL",
2400 arg7 ? arg7 : "NULL", arg8 ? arg8 : "NULL", arg9 ? arg9 : "NULL");
2401 Vector<Vector<long long>*> *res = dbeGetXYPlotData (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
2406 long nvals = res->size ();
2407 for (long i = 0; i < nvals; ++i)
2409 Vector<long long> *vals = res->fetch (i);
2410 long long sz = VSIZE (vals);
2411 ipc_log (" returning = %lld values:", sz);
2414 for (long j = 0; j < sz; j++)
2415 ipc_log (" %lld", vals->fetch (j));
2420 ipc_log (" returning NULL\n");
2422 writeArray (res, req);
2425 else if (strcmp (inp, "dbe_archive") == 0)
2427 Vector<long long> *ids = (Vector<long long> *) readArray (req);
2428 Vector<const char*> *locations = (Vector<const char*> *) readArray (req);
2429 dbe_archive (ids, locations);
2431 destroy (locations);
2432 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
2434 else if (strcmp (inp, "dbeSetLocations") == 0)
2436 Vector<const char*> *fnames = (Vector<const char*> *) readArray (req);
2437 Vector<const char*> *locations = (Vector<const char*> *) readArray (req);
2438 dbeSetLocations (fnames, locations);
2440 destroy (locations);
2441 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
2443 else if (strcmp (inp, "dbeResolvedWith_setpath") == 0)
2445 char *path = readString (req);
2446 Vector<void *> *res = dbeResolvedWith_setpath (path);
2448 writeArray (res, req);
2451 else if (strcmp (inp, "dbeResolvedWith_pathmap") == 0)
2453 char *old_prefix = readString (req);
2454 char *new_prefix = readString (req);
2455 Vector<void *> *res = dbeResolvedWith_pathmap (old_prefix, new_prefix);
2458 writeArray (res, req);
2461 else if (!strcmp (inp, "getCollectorControlValue"))
2463 /* int dbevindex =*/ readInt (req);
2464 char *control = readString (req);
2465 ipc_log (" args = %s\n", control);
2466 char *ret = dbeGetCollectorControlValue (control);
2467 ipc_log (" returning %s\n", STR (ret));
2468 writeString (ret, req);
2470 else if (!strcmp (inp, "setCollectorControlValue"))
2472 /* int dbevindex =*/ readInt (req);
2473 char *control = readString (req);
2474 char *value = readString (req);
2476 ipc_log (" args = %s %s\n", control, value);
2478 char *ret = dbeSetCollectorControlValue (control, value);
2481 ipc_log (" returning %s\n", ret);
2483 ipc_log (" returning NULL\n");
2485 writeString (ret, req);
2487 else if (!strcmp (inp, "unsetCollectorControlValue"))
2489 /* int dbevindex =*/ readInt (req);
2490 char *control = readString (req);
2491 ipc_log (" args = %s\n", control);
2492 char *ret = dbeUnsetCollectorControlValue (control);
2493 ipc_log (" returning %s\n", STR (ret));
2494 writeString (ret, req);
2496 else if (!strcmp (inp, "getSignalValue"))
2498 String arg1 = readString (req);
2499 ipc_log (" arg1=\"%s\"\n", arg1 ? arg1 : "");
2500 int res = dbeGetSignalValue (arg1);
2501 ipc_log (" returning = %d\n", res);
2502 writeInt (res, req);
2504 else if (!strcmp (inp, "sendSignal"))
2506 long long p = readLong (req);
2507 int signum = readInt (req);
2508 ipc_log (" args = %llu, %d\n", (long long) p, signum);
2509 char * ret = dbeSendSignal ((pid_t) p, signum);
2512 ipc_log (" returning %s\n", ret);
2514 ipc_log (" returning NULL\n");
2516 writeString (ret, req);
2518 else if (!strcmp (inp, "checkConnection"))
2520 String arg1 = readString (req);
2521 ipc_log (" arg = `%s'\n", arg1 ? arg1 : "NULL");
2522 String res = dbeCheckConnection (arg1);
2523 writeString (res, req);
2524 ipc_log (" returns `%s'\n", res ? res : "NULL");
2528 else if (!strcmp (inp, "QUIT"))
2531 ipc_log (" %s\n", inp);
2537 ipc_log ("Unrecognized input cmd \"%s\"; Aborting.\n", inp);
2540 ipc_log (" processing IPC command %s complete\n", inp);
2543 if (req->getStatus () != CANCELLED_IMMEDIATE)
2544 // wake up the main working thread, let it take care of delete
2545 req->setStatus (COMPLETED);
2551 check_env_args (int argc, char *argv[])
2553 int indx = 2; // Skip "-IPC"
2554 const char *MINUS_E = "-E";
2555 const char *SP_ER_PRINT_TRACE_LEVEL = "SP_ER_PRINT_TRACE_LEVEL";
2556 const char *SP_IPC_PROTOCOL = "SP_IPC_PROTOCOL";
2557 const char SEPARATOR = '=';
2558 char *cmd_env_var = NULL;
2559 while (argc - indx >= 2)
2561 char *option = argv[indx++];
2562 if (!streq (option, MINUS_E))
2564 cmd_env_var = argv[indx++];
2565 char *separator = strchr (cmd_env_var, SEPARATOR);
2567 // Unrecognized option. Fatal error?
2569 char *cmd_env_var_val = separator + 1;
2570 if (!strncmp (cmd_env_var, SP_ER_PRINT_TRACE_LEVEL,
2571 strlen (SP_ER_PRINT_TRACE_LEVEL)))
2573 if (streq (cmd_env_var_val, "1"))
2574 ipc_trace_level = TRACE_LVL_1;
2575 else if (streq (cmd_env_var_val, "2"))
2576 ipc_trace_level = TRACE_LVL_2;
2577 else if (streq (cmd_env_var_val, "3"))
2578 ipc_trace_level = TRACE_LVL_3;
2579 else if (streq (cmd_env_var_val, "4"))
2580 ipc_trace_level = TRACE_LVL_4;
2583 if (!strncmp (cmd_env_var, SP_IPC_PROTOCOL, strlen (SP_IPC_PROTOCOL)))
2585 if (streq (cmd_env_var_val, IPC_PROTOCOL_CURR))
2586 // Only one protocol is currently supported
2587 ipc_protocol = IPC_PROTOCOL_CURR;
2589 ipc_protocol = IPC_PROTOCOL_UNKNOWN;
2592 // Unrecognized option. Fatal error?
2597 print_ipc_protocol_confirmation ()
2599 if (NULL != ipc_protocol)
2601 fprintf (stdout, "ER_IPC: %s\n", ipc_protocol);
2607 ipc_mainLoop (int argc, char *argv[])
2609 if (getenv ("GPROFNG_DBE_DELAY"))
2614 // check_env_args(argc, argv);
2616 char *er_print_trace_level = getenv ("SP_ER_PRINT_TRACE_LEVEL");
2617 if (er_print_trace_level != NULL)
2619 if (streq (er_print_trace_level, "1"))
2620 ipc_trace_level = TRACE_LVL_1;
2621 else if (streq (er_print_trace_level, "2"))
2622 ipc_trace_level = TRACE_LVL_2;
2623 else if (streq (er_print_trace_level, "3"))
2624 ipc_trace_level = TRACE_LVL_3;
2625 else if (streq (er_print_trace_level, "4"))
2626 ipc_trace_level = TRACE_LVL_4;
2628 check_env_args (argc, argv);
2629 print_ipc_protocol_confirmation ();
2631 if (ipc_flags || getenv ("SP_ER_PRINT_IPC_FLAG") || ipc_trace_level > TRACE_LVL_0)
2634 if (ipc_trace_level == TRACE_LVL_0)
2635 ipc_trace_level = TRACE_LVL_1;
2636 // reopen stderr as file "ipc_log"
2637 ipc_log_name = getenv ("SP_ER_PRINT_IPC_LOG");
2638 if (ipc_log_name == NULL)
2639 ipc_log_name = "ipc_log";
2640 freopen (ipc_log_name, "w", stderr);
2641 if (ipc_trace_level >= TRACE_LVL_2)
2643 ipc_request_log_name = "ipc_request_log";
2644 ipc_response_log_name = "ipc_response_log";
2645 requestLogFileP = fopen (ipc_request_log_name, "w");
2646 responseLogFileP = fopen (ipc_response_log_name, "w");
2650 ipc_request_log_name = "ipc_log";
2651 ipc_response_log_name = "ipc_log";
2653 begin_time = gethrtime ();
2656 // Reopen stderr as /dev/null
2657 freopen ("/dev/null", "w", stderr);
2659 struct sigaction act;
2660 memset (&act, 0, sizeof (struct sigaction));
2662 /* install a handler for TERM */
2663 ipc_request_trace (TRACE_LVL_1, "Installing SIGTERM handler to abort on error\n");
2664 sigemptyset (&act.sa_mask);
2665 act.sa_handler = (SignalHandler) sigterm_handler;
2666 act.sa_flags = SA_RESTART | SA_SIGINFO;
2667 if (sigaction (SIGTERM, &act, &old_sigterm_handler) == -1)
2669 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGTERM handler\n");
2672 /* install a handler for INT */
2673 ipc_request_trace (TRACE_LVL_1, "Installing SIGINT handler to send message to analyzer\n");
2674 sigemptyset (&act.sa_mask);
2675 act.sa_handler = (SignalHandler) sigint_handler;
2676 act.sa_flags = SA_RESTART | SA_SIGINFO;
2677 if (sigaction (SIGINT, &act, &old_sigint_handler) == -1)
2679 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGINT handler\n");
2682 ipc_log ("Installed SIGINT handler to handle Ctrl-C properly\n");
2683 int er_print_catch_crash = 1; // Default: catch fatal signals
2684 char *s = getenv ("GPROFNG_ALLOW_CORE_DUMP");
2685 if (s && (strcasecmp (s, "no") == 0 || strcmp (s, "0") == 0))
2686 er_print_catch_crash = 0;
2687 if (er_print_catch_crash)
2689 /* reserve memory for fatal error processing */
2690 fatalErrorDynamicMemory = (char *) malloc (4 * 1024 * 1024); // reserve 4 MB
2691 /* install a handler for SIGABRT */
2692 ipc_request_trace (TRACE_LVL_1, "Installing SIGABRT handler to send message to analyzer\n");
2693 sigemptyset (&act.sa_mask);
2694 act.sa_handler = (SignalHandler) sigABRT_handler;
2695 act.sa_flags = SA_RESTART | SA_SIGINFO;
2696 if (sigaction (SIGABRT, &act, NULL) == -1)
2698 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGABRT handler\n");
2702 ipc_log ("Installed SIGABRT handler to handle crash properly\n");
2703 /* install a handler for SIGSEGV */
2704 ipc_request_trace (TRACE_LVL_1, "Installing SIGABRT handler to send message to analyzer\n");
2705 sigemptyset (&act.sa_mask);
2706 act.sa_handler = (SignalHandler) sigSEGV_handler;
2707 act.sa_flags = SA_RESTART | SA_SIGINFO;
2708 if (sigaction (SIGSEGV, &act, NULL) == -1)
2710 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGSEGV handler\n");
2714 ipc_log ("Installed SIGSEGV handler to handle crash properly\n");
2716 ipc_request_trace (TRACE_LVL_1, "Entering ipc_mainLoop; run dir `%s'\n",
2717 theApplication->get_run_dir ());
2718 cancelRequestedChannelID = 0xFFFFFFFF;
2719 ipcThreadPool = new DbeThreadPool (0); // DbeThreadPool (-1);
2720 responseBufferPool = new BufferPool ();
2721 ipc_log (ipc_single_threaded_mode ?
2722 "RUNNING er_print -IPC IN SINGLE THREADED MODE\n" :
2723 "RUNNING er_print -IPC IN MULTITHREAD MODE\n");
2725 /* Send "Ready" signal to the GUI */
2726 setProgress (100, "Restart engine");
2728 /* start listening for requests */
2732 readRequestHeader ();
2733 if (term_flag == 1 || error_flag == 1)
2735 ipc_request_trace (TRACE_LVL_1, "SIGTERM received, exiting\n");
2742 table_name (int flavor)
2744 static char def_name[64];
2746 switch ((FuncListDisp_type) flavor)
2749 return ("FUNCTION");
2765 return ("CALLTREE");
2767 return ("TIMELINE");
2773 return ("LEAKLIST");
2774 case DSP_HEAPCALLSTACK:
2783 return ("SRC_FILE");
2790 case DSP_DUALSOURCE:
2791 return ("DUALSOURCE");
2792 case DSP_SOURCE_DISASM:
2793 return ("SOURCE_DISASM");
2795 return ("DEADLOCKS");
2797 return ("SOURCE_V2");
2799 return ("DISASM_V2");
2800 case DSP_IOACTIVITY:
2801 return ("IOACTIVITY");
2803 return ("OVERVIEW");
2805 return ("SAMPLE -- UNEXPECTED");
2807 snprintf (def_name, sizeof (def_name), "table number %d", flavor);