1 /* Copyright (C) 2021 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*
bool2str(bool v)67 bool2str (bool v)
68 {
69 return v ? "true" : "false";
70 }
71
72 inline char*
str2str(String v)73 str2str (String v)
74 {
75 return (char*) (v ? v : "NULL");
76 }
77
78 inline char*
str2s(String v)79 str2s (String v)
80 {
81 return (char*) (v ? v : "");
82 }
83
84 inline DbeView *
getView(int index)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
fatalErrorHadler(int sig,siginfo_t * info,void * context)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
sigABRT_handler(int sig,siginfo_t * info,void * context)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
sigSEGV_handler(int sig,siginfo_t * info,void * context)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
sigterm_handler(int,siginfo_t *,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 FILE *requestLogFileP = stderr;
193 FILE *responseLogFileP = stderr;
194 hrtime_t begin_time;
195 long long delta_time = 0;
196 int ipc_delay_microsec = 0;
197
198 void
ipc_default_log(const char * fmt,...)199 ipc_default_log (const char *fmt, ...)
200 {
201 if (!ipc_log_name || !ipc_flags)
202 return;
203 if (ipc_trace_level >= TRACE_LVL_3)
204 {
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);
208 }
209 va_list vp;
210 va_start (vp, fmt);
211 vfprintf (stderr, fmt, vp);
212 va_end (vp);
213 fflush (stderr);
214 }
215
216 extern "C" void sigint_handler (int sig, siginfo_t *info, void *context);
217 struct sigaction old_sigint_handler;
218
219 extern "C" void
sigint_handler(int,siginfo_t *,void *)220 sigint_handler (int, siginfo_t *, void *)
221 {
222 ipc_log ("SIGINT signal happens\n");
223 }
224
225 void
ipc_request_log(IPCTraceLevel trace_level,const char * fmt,...)226 ipc_request_log (IPCTraceLevel trace_level, const char *fmt, ...)
227 {
228 if (!ipc_request_log_name || !ipc_flags || trace_level > ipc_trace_level)
229 return;
230 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ());
231 if (ipc_trace_level >= TRACE_LVL_3)
232 {
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);
236 }
237 va_list vp;
238 va_start (vp, fmt);
239 vfprintf (requestLogFileP, fmt, vp);
240 va_end (vp);
241 fflush (requestLogFileP);
242 }
243
244 void
ipc_response_log(IPCTraceLevel trace_level,const char * fmt,...)245 ipc_response_log (IPCTraceLevel trace_level, const char *fmt, ...)
246 {
247 if (!ipc_response_log_name || !ipc_flags || trace_level > ipc_trace_level)
248 return;
249 fprintf (responseLogFileP, "thr: %llu ", (unsigned long long) pthread_self ());
250 if (ipc_trace_level >= TRACE_LVL_3)
251 {
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);
255 }
256 va_list vp;
257 va_start (vp, fmt);
258 vfprintf (responseLogFileP, fmt, vp);
259 va_end (vp);
260 fflush (responseLogFileP);
261 }
262
263 #ifdef IPC_LOG
264 void
ipc_dump(char * s,Vector<bool> * v)265 ipc_dump (char *s, Vector<bool> *v)
266 {
267 if (v == NULL)
268 {
269 ipc_log (" Vector<bool> %s is NULL\n", str2s (s));
270 return;
271 }
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)));
275 }
276
277 void
ipc_dump(char * s,Vector<String> * v)278 ipc_dump (char *s, Vector<String> *v)
279 {
280 if (v == NULL)
281 {
282 ipc_log (" Vector<bool> %s is NULL\n", str2s (s));
283 return;
284 }
285 ipc_log (" Vector<String> %s size=%lld\n", str2s (s), VSIZE (v));
286 for (int i = 0; i < v->size (); i++)
287 {
288 String str = v->fetch (i);
289 ipc_log (" [%d]: '%s'\n", i, str2str (str));
290 }
291 }
292
293 void
ipc_dump(char * s,Vector<Obj> * v)294 ipc_dump (char *s, Vector<Obj> *v)
295 {
296 if (v == NULL)
297 {
298 ipc_log (" Vector<Obj> %s is NULL\n", str2s (s));
299 return;
300 }
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)));
304 }
305
306 #else
307 #define ipc_dump(s, v)
308 #endif
309
310 static MetricList *
readMetricListV2(int dbevindex,IPCrequest * req)311 readMetricListV2 (int dbevindex, IPCrequest* req)
312 {
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);
323 return mlist;
324 }
325
326 static void
setCancellableChannel(int chID)327 setCancellableChannel (int chID)
328 {
329 cancellableChannelID = chID;
330 }
331
332 /* Add more entries here for other cancellable operations */
333 static void
checkCancellableOp(char * inp,IPCrequest * req)334 checkCancellableOp (char *inp, IPCrequest* req)
335 {
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"))
341 {
342 setCancellableChannel (currentChannelID);
343 req->setCancelImmediate ();
344 }
345 }
346
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 */
351
352 int
ipc_doWork(void * arg)353 ipc_doWork (void *arg)
354 {
355 IPCrequest *req = (IPCrequest *) arg;
356 currentRequestID = req->getRequestID ();
357 currentChannelID = req->getChannelID ();
358 req->setStatus (IN_PROGRESS);
359 String inp = readString (req);
360 if (inp == NULL)
361 {
362 ipc_log ("NULL ipc command received, exiting\n");
363 return 0;
364 }
365 ipc_log ("ipc: %s Req %x Ch %x\n", inp, currentRequestID, currentChannelID);
366 checkCancellableOp (inp, req);
367 if (!strcmp (inp, "initApplication"))
368 {
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);
377 if (nbm)
378 theApplication->set_name ("analyzer-NBM");
379 else
380 theApplication->set_name ("analyzer");
381
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);
386 free (arg1);
387 free (arg2);
388 destroy (arg3);
389 destroy (res);
390 }
391 else if (!strcmp (inp, "syncTime"))
392 {
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);
399 }
400 else if (!strcmp (inp, "getInitMessages"))
401 {
402 Vector<String> *res = dbeGetInitMessages ();
403 ipc_log (" returned = %lld msgs\n", VSIZE (res));
404 writeArray (res, req);
405 destroy (res);
406 }
407 else if (!strcmp (inp, "reExec"))
408 {
409 ipc_log (" started reexec()\n");
410 reexec ();
411 }
412 else if (!strcmp (inp, "dbeCreateDirectories"))
413 {
414 String arg1 = readString (req); // path
415 ipc_log (" arg = %s\n", arg1);
416 String res = dbeCreateDirectories (arg1);
417 writeString (res, req);
418 free (arg1);
419 free (res);
420 }
421 else if (!strcmp (inp, "dbeDeleteFile"))
422 {
423 String arg1 = readString (req); // path
424 ipc_log (" arg = %s\n", arg1);
425 String res = dbeDeleteFile (arg1);
426 writeString (res, req);
427 free (arg1);
428 free (res);
429 }
430 else if (!strcmp (inp, "dbeReadFile"))
431 {
432 String arg1 = readString (req);
433 ipc_log (" arg = %s\n", arg1); // path
434 Vector<String> *res = dbeReadFile (arg1);
435 writeArray (res, req);
436 free (arg1);
437 destroy (res);
438 }
439 else if (!strcmp (inp, "dbeWriteFile"))
440 {
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);
445 writeInt (res, req);
446 free (arg1);
447 }
448 else if (!strcmp (inp, "getExpPreview"))
449 {
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);
455 free (arg1);
456 destroy (res);
457 }
458 else if (!strcmp (inp, "getFileAttributes"))
459 {
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);
465 free (arg1);
466 free (arg2);
467 free (res);
468 }
469 else if (!strcmp (inp, "getFiles"))
470 {
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);
476 free (arg1);
477 free (arg2);
478 free (res);
479 }
480 else if (!strcmp (inp, "getOSFamily"))
481 writeString ("Linux", req);
482 else if (!strcmp (inp, "getRunningProcesses"))
483 {
484 String arg1 = readString (req); // format
485 ipc_log (" arg = %s\n", arg1);
486 String res = dbeGetRunningProcesses (arg1);
487 writeString (res, req);
488 free (arg1);
489 free (res);
490 }
491 else if (!strcmp (inp, "getCurrentDirectory"))
492 {
493 char buf [2048];
494 String res = getcwd (buf, (size_t) sizeof (buf)); // Get current directory
495 writeString (res, req);
496 }
497 else if (!strcmp (inp, "getHomeDirectory"))
498 {
499 String res = getenv ("HOME"); // Get HOME directory
500 writeString (res, req);
501 }
502 else if (!strcmp (inp, "setCurrentDirectory"))
503 {
504 String arg1 = readString (req); // dirname
505 ipc_log (" arg = %s\n", arg1);
506 int res = chdir (arg1); // Change directory
507 writeInt (res, req);
508 free (arg1);
509 }
510 else if (!strcmp (inp, "getLocale"))
511 {
512 String res = setlocale (LC_ALL, ""); // Get locale
513 writeString (res, req);
514 }
515 else if (!strcmp (inp, "setLocale"))
516 {
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);
521 free (arg1);
522 }
523 else if (!strcmp (inp, "readRCFile"))
524 {
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);
530 free (res);
531 }
532 else if (!strcmp (inp, "dbeGetExpParams"))
533 {
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);
539 free (arg1);
540 free (res);
541 }
542 else if (!strcmp (inp, "getExperimentsGroups"))
543 {
544 Vector<Vector<char*>*> *groups = dbeGetExperimensGroups ();
545 writeArray (groups, req);
546 destroy (groups);
547 }
548 else if (!strcmp (inp, "setExperimentsGroups"))
549 {
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);
554 free (msg_str);
555 destroy (groups);
556 }
557 else if (!strcmp (inp, "dropExperiment"))
558 {
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);
564 free (res);
565 delete arg2;
566 }
567 else if (!strcmp (inp, "getUserExpId"))
568 {
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);
573 delete res;
574 }
575 else if (!strcmp (inp, "getFounderExpId"))
576 {
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);
581 delete res;
582 }
583 else if (!strcmp (inp, "getExpGroupId"))
584 {
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);
589 delete res;
590 }
591 else if (!strcmp (inp, "getExpsProperty"))
592 {
593 String arg = readString (req);
594 Vector<String> *res = dbeGetExpsProperty (arg);
595 writeArray (res, req);
596 destroy (res);
597 }
598 else if (!strcmp (inp, "getExpName"))
599 {
600 // XXX add argument == DbeView index
601 Vector<String> *res = dbeGetExpName (0);
602 writeArray (res, req);
603 destroy (res);
604 }
605 else if (!strcmp (inp, "getExpState"))
606 {
607 // XXX add argument == DbeView index
608 Vector<int> *res = dbeGetExpState (0);
609 writeArray (res, req);
610 delete res;
611 }
612 else if (!strcmp (inp, "getExpEnable"))
613 {
614 int arg1 = readInt (req);
615 ipc_log (" arg1 = %d\n", arg1);
616 Vector<bool> *res = dbeGetExpEnable (arg1);
617 writeArray (res, req);
618 delete res;
619 }
620 else if (!strcmp (inp, "setExpEnable"))
621 {
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));
629 delete arg2;
630 }
631 else if (!strcmp (inp, "getExpInfo"))
632 {
633 int arg1 = readInt (req);
634 ipc_log (" args = %d\n", arg1);
635 Vector<String> *res = dbeGetExpInfo (arg1);
636 writeArray (res, req);
637 destroy (res);
638 }
639 else if (!strcmp (inp, "getViewModeEnable"))
640 {
641 bool res = dbeGetViewModeEnable ();
642 writeBoolean (res, req);
643 }
644 else if (!strcmp (inp, "getJavaEnable"))
645 {
646 bool res = dbeGetJavaEnable ();
647 writeBoolean (res, req);
648 }
649 else if (!strcmp (inp, "updateNotes"))
650 {
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);
658 writeInt (i, req);
659 }
660 else if (!strcmp (inp, "getLoadObjectList"))
661 {
662 int arg1 = readInt (req);
663 ipc_log (" arg = %d\n", arg1);
664 Vector<void *> *res = dbeGetLoadObjectList (arg1);
665 if (res == NULL)
666 ipc_log (" returning = NULL for LoadObjectList\n");
667 else
668 {
669 Vector<char*> *s = (Vector<char*> *) res->fetch (0);
670 ipc_log (" returning = %lld vectors for %lld LoadObjects\n",
671 VSIZE (res), VSIZE (s));
672 }
673 writeArray (res, req);
674 destroy (res);
675 }
676 else if (!strcmp (inp, "getLoadObjectName"))
677 {
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);
683 destroy (res);
684 }
685 else if (!strcmp (inp, "getTabListInfo"))
686 {
687 int arg1 = readInt (req);
688 ipc_log (" arg = %d\n", arg1);
689 Vector<void*> *res = dbeGetTabListInfo (arg1);
690 writeArray (res, req);
691 destroy (res);
692 }
693 else if (!strcmp (inp, "getSearchPath"))
694 {
695 // XXX add argument == DbeView index
696 ipc_log (" no args\n");
697 Vector<String> *res = dbeGetSearchPath (0);
698 writeArray (res, req);
699 destroy (res);
700 }
701 else if (!strcmp (inp, "setSearchPath"))
702 {
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);
708 destroy (res);
709 }
710 else if (!strcmp (inp, "getPathmaps"))
711 {
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);
716 destroy (res);
717 }
718 else if (!strcmp (inp, "setPathmaps"))
719 {
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);
724 free (res);
725 if (from)
726 {
727 from->destroy ();
728 delete from;
729 }
730 if (to)
731 {
732 to->destroy ();
733 delete to;
734 }
735 }
736 else if (!strcmp (inp, "addPathmap"))
737 {
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);
745 free (arg1);
746 free (arg2);
747 }
748 else if (!strcmp (inp, "getMsg"))
749 {
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);
756 free (res);
757 }
758 else if (!strcmp (inp, "initView"))
759 {
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);
765 }
766 else if (!strcmp (inp, "disposeWindow"))
767 {
768 int arg1 = readInt (req);
769 ipc_log (" args = %d\n", arg1);
770 dbeDeleteView (arg1);
771 writeString (NULL, req);
772 }
773 #if 0
774 else if (!strcmp (inp, "createMapfile"))
775 {
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);
781 writeString (res);
782 free (arg2);
783 free (res);
784 }
785 #endif
786 else if (!strcmp (inp, "setCompareModeV2"))
787 {
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);
792 }
793 else if (!strcmp (inp, "getCompareModeV2"))
794 {
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);
800 writeInt (res, req);
801 }
802 else if (!strcmp (inp, "getRefMetricsV2"))
803 {
804 Vector<void*> *res = dbeGetRefMetricsV2 ();
805 writeArray (res, req);
806 destroy (res);
807 }
808 else if (!strcmp (inp, "setCurMetricsV2"))
809 {
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);
815 }
816 else if (!strcmp (inp, "getCurMetricsV2"))
817 {
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);
823 destroy (res);
824 }
825 else if (!strcmp (inp, "getRefMetricTree"))
826 {
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);
832 destroy (res);
833 }
834 else if (!strcmp (inp, "getRefMetricTreeValues"))
835 {
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);
844 #ifdef IPC_LOG
845 if (res != NULL)
846 ipc_log (" returns = %lld objects, length = %lld\n",
847 VSIZE (res), VSIZE (((Vector<int>*)res->fetch (0))));
848 else
849 ipc_log (" returns NULL\n");
850 #endif
851 writeArray (res, req);
852 destroy (res);
853 }
854 else if (!strcmp (inp, "getOverviewText"))
855 {
856 int arg1 = readInt (req);
857 ipc_log (" args = %d\n", arg1);
858 Vector<char*> *res = dbeGetOverviewText (arg1);
859 writeArray (res, req);
860 destroy (res);
861 }
862 else if (!strcmp (inp, "setSort"))
863 {
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);
871 }
872
873 else if (!strcmp (inp, "getAnoValue"))
874 {
875 int arg1 = readInt (req);
876 ipc_log (" args = %d\n", arg1);
877 Vector<int> *res = dbeGetAnoValue (arg1);
878 writeArray (res, req);
879 delete res;
880 }
881 else if (!strcmp (inp, "setAnoValue"))
882 {
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);
888 delete arg2;
889 }
890 else if (!strcmp (inp, "getNameFormat"))
891 {
892 int arg1 = readInt (req);
893 ipc_log (" args = %d\n", arg1);
894 int b = dbeGetNameFormat (arg1);
895 writeInt (b, req);
896 }
897 else if (!strcmp (inp, "getSoName"))
898 {
899 int arg1 = readInt (req);
900 ipc_log (" args = %d\n", arg1);
901 bool b = dbeGetSoName (arg1);
902 writeBoolean (b, req);
903 }
904 else if (!strcmp (inp, "setNameFormat"))
905 {
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);
912 }
913 else if (!strcmp (inp, "getViewMode"))
914 {
915 int arg1 = readInt (req);
916 ipc_log (" args = %d\n", arg1);
917 int i = dbeGetViewMode (arg1);
918 ipc_log (" returns = %d\n", i);
919 writeInt (i, req);
920 }
921 else if (!strcmp (inp, "setViewMode"))
922 {
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);
928 }
929 else if (!strcmp (inp, "getTLValue"))
930 {
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);
936 delete res;
937 }
938 else if (!strcmp (inp, "setTLValue"))
939 {
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);
948 free (tldata_cmd);
949 }
950 else if (!strcmp (inp, "getExpFounderDescendants"))
951 {
952 Vector<void*> *res = dbeGetExpFounderDescendants ();
953 writeArray (res, req);
954 destroy (res);
955 }
956 else if (!strcmp (inp, "getExpSelection"))
957 {
958 int arg1 = readInt (req);
959 ipc_log (" args = %d\n", arg1);
960 Vector<void*> *res = dbeGetExpSelection (arg1);
961 writeArray (res, req);
962 destroy (res);
963 }
964
965 else if (!strcmp (inp, "setFilterStr"))
966 {
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);
973 free (arg2);
974 free (res);
975 }
976
977 else if (!strcmp (inp, "getFilterStr"))
978 {
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);
984 free (res);
985 }
986
987 else if (!strcmp (inp, "validateFilterExpression"))
988 {
989 String arg1 = readString (req);
990 int res = dbeValidateFilterExpression (arg1);
991 ipc_log (" validateFilterExpression('%s') returned %d\n", str2str (arg1), res);
992 free (arg1);
993 writeInt (res, req);
994 }
995
996 else if (!strcmp (inp, "getFilterKeywords"))
997 {
998 int dbevindex = readInt (req);
999 Vector<void*>*res = dbeGetFilterKeywords (dbevindex);
1000 writeArray (res, req);
1001 destroy (res);
1002 }
1003
1004 else if (!strcmp (inp, "getFilters"))
1005 {
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);
1012 delete res;
1013 }
1014
1015 else if (!strcmp (inp, "updateFilters"))
1016 {
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"));
1027 delete arg2;
1028 delete arg3;
1029 }
1030 else if (!strcmp (inp, "getLoadObjectState"))
1031 {
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);
1037 delete res;
1038 }
1039 else if (!strcmp (inp, "setLoadObjectState"))
1040 {
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);
1046 delete arg2;
1047 }
1048 else if (!strcmp (inp, "setLoadObjectDefaults"))
1049 {
1050 int arg1 = readInt (req);
1051 ipc_log (" args = %d\n", arg1);
1052 dbeSetLoadObjectDefaults (arg1);
1053 writeString (NULL, req);
1054 }
1055 else if (!strcmp (inp, "getMemTabSelectionState"))
1056 {
1057 int arg1 = readInt (req);
1058 ipc_log (" arg = %d\n", arg1);
1059 Vector<bool> *res = dbeGetMemTabSelectionState (arg1);
1060 writeArray (res, req);
1061 destroy (res);
1062 }
1063 else if (!strcmp (inp, "setMemTabSelectionState"))
1064 {
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);
1070 destroy (arg2);
1071 }
1072 else if (!strcmp (inp, "getIndxTabSelectionState"))
1073 {
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);
1079 destroy (res);
1080 }
1081 else if (!strcmp (inp, "setIndxTabSelectionState"))
1082 {
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);
1088 destroy (arg2);
1089 }
1090 else if (!strcmp (inp, "getTabSelectionState"))
1091 {
1092 int arg1 = readInt (req);
1093 ipc_log (" args = %d\n", arg1);
1094 Vector<bool> *res = dbeGetTabSelectionState (arg1);
1095 writeArray (res, req);
1096 delete res;
1097 }
1098 else if (!strcmp (inp, "setTabSelectionState"))
1099 {
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);
1105 delete arg2;
1106 }
1107 else if (!strcmp (inp, "getMemObjects"))
1108 {
1109 int arg1 = readInt (req);
1110 ipc_log (" args = %d\n", arg1);
1111 Vector<void*> *res = dbeGetMemObjects (arg1);
1112
1113 #ifdef IPC_LOG
1114 if (res == NULL)
1115 ipc_log (" -- returned NULL\n");
1116 else
1117 {
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));
1121 }
1122 #endif
1123 writeArray (res, req);
1124 destroy (res);
1125 }
1126 else if (!strcmp (inp, "loadMachineModel"))
1127 {
1128 String arg1 = readString (req);
1129 #ifdef IPC_LOG
1130 ipc_log (" arg = `%s'\n", arg1);
1131 #endif
1132 String sts = dbeLoadMachineModel (arg1);
1133 #ifdef IPC_LOG
1134 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1135 #endif
1136 writeString (sts, req);
1137 free (arg1);
1138 }
1139 else if (!strcmp (inp, "getMachineModel"))
1140 {
1141 String sts = dbeGetMachineModel ();
1142 #ifdef IPC_LOG
1143 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1144 #endif
1145 writeString (sts, req);
1146 }
1147 else if (!strcmp (inp, "getCPUVerMachineModel"))
1148 {
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));
1154 destroy (res);
1155 }
1156 else if (!strcmp (inp, "listMachineModels"))
1157 {
1158 Vector<String> *res = dbeListMachineModels ();
1159 #ifdef IPC_LOG
1160 if (res != NULL)
1161 ipc_log (" returns = %lld strings\n", VSIZE (res));
1162 else
1163 ipc_log (" returns NULL\n");
1164 #endif
1165 writeArray (res, req);
1166 destroy (res);
1167 }
1168 else if (!strcmp (inp, "defineMemObj"))
1169 {
1170 String arg1 = readString (req);
1171 String arg2 = readString (req);
1172 String arg3 = readString (req);
1173 String arg4 = readString (req);
1174 #ifdef IPC_LOG
1175 ipc_log (" args = %s, %s, %s, %s\n", arg1, arg2, arg3 == NULL ? "NULL" : arg3, arg4 == NULL ? "NULL" : arg4);
1176 #endif
1177 String sts = dbeDefineMemObj (arg1, arg2, NULL, arg3, arg4);
1178 #ifdef IPC_LOG
1179 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1180 #endif
1181 writeString (sts, req);
1182 free (arg1);
1183 free (arg2);
1184 free (arg3);
1185 free (arg4);
1186 }
1187 else if (!strcmp (inp, "deleteMemObj"))
1188 {
1189 String arg1 = readString (req);
1190 #ifdef IPC_LOG
1191 ipc_log (" args = %s\n", arg1);
1192 #endif
1193 String sts = dbeDeleteMemObj (arg1);
1194 #ifdef IPC_LOG
1195 ipc_log (" returns '%s'\n", sts ? sts : "NULL");
1196 #endif
1197 writeString (sts, req);
1198 free (arg1);
1199 }
1200 else if (!strcmp (inp, "getIndxObjDescriptions"))
1201 {
1202 int arg1 = readInt (req);
1203 ipc_log (" args = %d\n", arg1);
1204 Vector<void*> *res = dbeGetIndxObjDescriptions (arg1);
1205 #ifdef IPC_LOG
1206 if (res == NULL)
1207 ipc_log (" -- returned NULL\n");
1208 else
1209 {
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));
1213 }
1214 #endif
1215 writeArray (res, req);
1216 destroy (res);
1217 }
1218 else if (!strcmp (inp, "getCustomIndxObjects"))
1219 {
1220 int arg1 = readInt (req);
1221 ipc_log (" args = %d\n", arg1);
1222 Vector<void*> *res = dbeGetCustomIndxObjects (arg1);
1223 #ifdef IPC_LOG
1224 if (res == NULL)
1225 ipc_log (" -- returned NULL\n");
1226 else
1227 {
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));
1231 }
1232 #endif
1233 writeArray (res, req);
1234 destroy (res);
1235 }
1236 else if (!strcmp (inp, "defineIndxObj"))
1237 {
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);
1246 free (arg1);
1247 free (arg2);
1248 free (arg3);
1249 free (arg4);
1250 }
1251 else if (!strcmp (inp, "setSelObj"))
1252 {
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);
1260 }
1261 else if (!strcmp (inp, "setSelObjV2"))
1262 {
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);
1268 }
1269 else if (!strcmp (inp, "getSelObj"))
1270 {
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);
1278 }
1279 else if (!strcmp (inp, "getSelObjV2"))
1280 {
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);
1287 free (arg2);
1288 }
1289 else if (!strcmp (inp, "getSelObjIO"))
1290 {
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);
1297 delete res;
1298 }
1299 else if (!strcmp (inp, "getSelObjsIO"))
1300 {
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);
1308 delete res;
1309 }
1310 else if (!strcmp (inp, "getSelObjHeapTimestamp"))
1311 {
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);
1318 }
1319 else if (!strcmp (inp, "getSelObjHeapUserExpId"))
1320 {
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);
1327 }
1328 else if (!strcmp (inp, "getSelIndex"))
1329 {
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);
1337 writeInt (i, req);
1338 }
1339 else if (!strcmp (inp, "printData"))
1340 {
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);
1352 free (arg4);
1353 free (arg5);
1354 free (res);
1355 }
1356 else if (!strcmp (inp, "getPrintLimit"))
1357 {
1358 int arg1 = readInt (req);
1359 ipc_log (" args = %d\n", arg1);
1360 int i = dbeGetPrintLimit (arg1);
1361 ipc_log (" returns = %d\n", i);
1362 writeInt (i, req);
1363 }
1364 else if (!strcmp (inp, "setPrintLimit"))
1365 {
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);
1371 free (res);
1372 }
1373 else if (!strcmp (inp, "getPrintMode"))
1374 {
1375 int arg1 = readInt (req);
1376 ipc_log (" args = %d\n", arg1);
1377 int i = dbeGetPrintMode (arg1);
1378 ipc_log (" returns = %d\n", i);
1379 writeInt (i, req);
1380 }
1381 else if (!strcmp (inp, "setPrintMode"))
1382 {
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);
1388 free (arg2);
1389 free (res);
1390 }
1391 else if (!strcmp (inp, "getPrintDelim"))
1392 {
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);
1398 }
1399 else if (!strcmp (inp, "getHotMarks"))
1400 {
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);
1406 destroy (res);
1407 }
1408 else if (!strcmp (inp, "getHotMarksInc"))
1409 {
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);
1415 destroy (res);
1416 }
1417 else if (!strcmp (inp, "getSummaryHotMarks"))
1418 {
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);
1425 destroy (res);
1426 }
1427 else if (!strcmp (inp, "getFuncId"))
1428 {
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);
1436 delete res;
1437 }
1438 else if (!strcmp (inp, "getFuncCalleeInfo"))
1439 {
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);
1447 destroy (res);
1448 }
1449 else if (!strcmp (inp, "getFuncCallerInfo"))
1450 {
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);
1458 destroy (res);
1459 }
1460 else if (!strcmp (inp, "setFuncData"))
1461 {
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);
1469 writeInt (i, req);
1470 }
1471 else if (!strcmp (inp, "setFuncDataV2"))
1472 {
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);
1479
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;
1484 switch (type)
1485 {
1486 case DSP_SOURCE:
1487 case DSP_DISASM:
1488 {
1489 Histable *obj = (Histable *) sel_obj;
1490 if (obj)
1491 {
1492 Histable *sf = obj->convertto (Histable::SOURCEFILE);
1493 if (sf)
1494 {
1495 sf_id = sf->id;
1496 sf_name = dbe_strdup (sf->get_name ());
1497 }
1498 }
1499 break;
1500 }
1501 }
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)));
1507
1508 Vector<void *> *res = new Vector<void *>(2);
1509 res->append (longs);
1510 res->append (strings);
1511 writeArray (res, req);
1512 destroy (res);
1513 }
1514 else if (!strcmp (inp, "getFuncList"))
1515 {
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);
1521 #ifdef IPC_LOG
1522 if (res != NULL)
1523 ipc_log (" returns = %lld objects, length = %lld\n",
1524 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1525 else
1526 ipc_log (" returns NULL\n");
1527 #endif
1528 writeArray (res, req);
1529 destroy (res);
1530 }
1531 else if (!strcmp (inp, "getFuncListV2"))
1532 {
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);
1544 destroy (res);
1545 }
1546 else if (!strcmp (inp, "getFuncListMini"))
1547 {
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);
1553 #ifdef IPC_LOG
1554 if (res != NULL)
1555 ipc_log (" returns = %lld objects, length = %lld\n",
1556 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1557 else
1558 ipc_log (" returns NULL\n");
1559 #endif
1560 writeArray (res, req);
1561 destroy (res);
1562 }
1563 else if (!strcmp (inp, "dbeGetTotals"))
1564 {
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);
1572 destroy (res);
1573 }
1574 else if (!strcmp (inp, "getComparableObjsV2"))
1575 {
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);
1583 destroy (res);
1584 }
1585 else if (!strcmp (inp, "dbeConvertSelObj"))
1586 {
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,
1591 (long long) res);
1592 writeObject (res, req);
1593 }
1594 else if (!strcmp (inp, "getTableDataV2"))
1595 {
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);
1605 #ifdef IPC_LOG
1606 if (res != NULL)
1607 ipc_log (" returns = %lld objects, length = %lld\n",
1608 VSIZE (res), VSIZE ((Vector<int>*)res->fetch (0)));
1609 else
1610 ipc_log (" returns NULL\n");
1611 #endif
1612 writeArray (res, req);
1613 //destroy( arg6 );
1614 destroy (res);
1615 }
1616 else if (!strcmp (inp, "getCallTreeNumLevels"))
1617 {
1618 int arg1 = readInt (req);
1619 ipc_log (" args = %d\n", arg1);
1620 int res = dbeGetCallTreeNumLevels (arg1);
1621 #ifdef IPC_LOG
1622 ipc_log (" returns = %d\n", res);
1623 #endif
1624 writeInt (res, req);
1625 }
1626 else if (!strcmp (inp, "getCallTreeLevel"))
1627 {
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);
1634 destroy (res);
1635 }
1636 else if (!strcmp (inp, "getCallTreeChildren"))
1637 {
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);
1644 destroy (res);
1645 }
1646 else if (!strcmp (inp, "getCallTreeLevels"))
1647 {
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);
1653 destroy (res);
1654 }
1655 else if (!strcmp (inp, "getCallTreeLevelFuncs"))
1656 {
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);
1663 destroy (res);
1664 }
1665 else if (!strcmp (inp, "getCallTreeFuncs"))
1666 {
1667 int arg1 = readInt (req);
1668 ipc_log (" args = %d\n", arg1);
1669 Vector<void*> *res = dbeGetCallTreeFuncs (arg1);
1670 writeArray (res, req);
1671 destroy (res);
1672 }
1673 else if (!strcmp (inp, "getGroupIds"))
1674 {
1675 int arg1 = readInt (req);
1676 Vector<int> *res = dbeGetGroupIds (arg1);
1677 writeArray (res, req);
1678 delete res;
1679 }
1680 else if (!strcmp (inp, "getNames"))
1681 {
1682 int arg1 = readInt (req);
1683 int arg2 = readInt (req);
1684 Obj arg3 = readObject (req);
1685 #ifdef IPC_LOG
1686 ipc_log (" args = %d, %s 0x%lx\n", arg1, table_name (arg2), (long) arg3);
1687 #endif
1688 Vector<String> *res = dbeGetNames (arg1, arg2, arg3);
1689 writeArray (res, req);
1690 destroy (res);
1691 }
1692 else if (!strcmp (inp, "getTotalMax"))
1693 {
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);
1699 #ifdef IPC_LOG
1700 if (res != NULL)
1701 ipc_log (" returns = %lld vectors, length %lld\n",
1702 VSIZE (res), VSIZE ((Vector<void*>*)res->fetch (0)));
1703 else
1704 ipc_log (" returns NULL\n");
1705 #endif
1706 writeArray (res, req);
1707 destroy (res);
1708 }
1709 else if (!strcmp (inp, "composeFilterClause"))
1710 {
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);
1720 }
1721 else if (!strcmp (inp, "getStatisOverviewList"))
1722 {
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);
1728 destroy (res);
1729 }
1730 else if (!strcmp (inp, "getStatisList"))
1731 {
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);
1737 destroy (res);
1738 }
1739 else if (!strcmp (inp, "getSummary"))
1740 {
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);
1749 destroy (res);
1750 }
1751 else if (!strcmp (inp, "getSummaryV2"))
1752 {
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);
1762 destroy (res);
1763 }
1764 else if (!strcmp (inp, "getExpName1"))
1765 {
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");
1772 free (arg1);
1773 free (res);
1774 }
1775 else if (!strcmp (inp, "getHwcHelp"))
1776 {
1777 // XXX add an argument = DbeView index
1778 bool forKernel = readBoolean (req);
1779 Vector<String> *res = dbeGetHwcHelp (0, forKernel);
1780 writeArray (res, req);
1781 destroy (res);
1782 }
1783 else if (!strcmp (inp, "getHwcSets"))
1784 {
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));
1790 destroy (res);
1791 }
1792 else if (!strcmp (inp, "getHwcsAll"))
1793 {
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));
1799 destroy (res);
1800 }
1801 else if (!strcmp (inp, "getHwcAttrList"))
1802 {
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);
1808 destroy (res);
1809 }
1810 else if (!strcmp (inp, "getHwcMaxConcurrent"))
1811 {
1812 // XXX add an argument = DbeView index
1813 bool forKernel = readBoolean (req);
1814 int res = dbeGetHwcMaxConcurrent (0, forKernel);
1815 writeInt (res, req);
1816 }
1817 else if (!strcmp (inp, "getIfreqData"))
1818 {
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);
1824 destroy (res);
1825 }
1826 else if (!strcmp (inp, "getNewLeakListInfo"))
1827 {
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);
1834 destroy (res);
1835 }
1836 else if (!strcmp (inp, "getObject"))
1837 {
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);
1843 }
1844 else if (!strcmp (inp, "getExpVerboseName"))
1845 {
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);
1851 destroy (res);
1852 }
1853 else if (!strcmp (inp, "getName"))
1854 {
1855 // XXX add an argument = DbeView index
1856 int arg1 = readInt (req);
1857 String res = dbeGetName (0, arg1);
1858 writeString (res, req);
1859 free (res);
1860 }
1861 else if (!strcmp (inp, "getStartTime"))
1862 {
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);
1867 writeLong (l, req);
1868 }
1869 else if (!strcmp (inp, "getRelativeStartTime"))
1870 {
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);
1875 writeLong (l, req);
1876 }
1877 else if (!strcmp (inp, "getEndTime"))
1878 {
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);
1883 writeLong (l, req);
1884 }
1885 else if (!strcmp (inp, "getClock"))
1886 {
1887 // XXX add an argument = DbeView index
1888 int arg1 = readInt (req);
1889 int i = dbeGetClock (0, arg1);
1890 writeInt (i, req);
1891 }
1892 /*
1893 else if ( !strcmp( inp, "getFounderExpId" ) ) {
1894 // XXX add an argument = DbeView index
1895 int arg1 = readInt(req);
1896 int i = dbeGetFounderExpId(0, arg1 );
1897 writeInt( i, req );
1898 }
1899 */
1900 else if (!strcmp (inp, "getEntityProps"))
1901 {
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));
1907 destroy (res);
1908 }
1909 else if (!strcmp (inp, "getEntities"))
1910 {
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));
1918 destroy (res);
1919 }
1920 else if (!strcmp (inp, "getEntitiesV2"))
1921 {
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));
1929 destroy (res);
1930 }
1931 else if (!strcmp (inp, "getTLDetails"))
1932 {//TBR
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);
1944 destroy (res);
1945 }
1946 else if (!strcmp (inp, "getStackNames"))
1947 {
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);
1954 destroy (res);
1955 }
1956 else if (!strcmp (inp, "getStackFunctions"))
1957 {
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);
1964 delete res;
1965 }
1966 else if (!strcmp (inp, "getStacksFunctions"))
1967 {
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);
1974 delete res;
1975 }
1976 else if (!strcmp (inp, "getStackPCs"))
1977 {
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);
1984 delete res;
1985 }
1986 else if (!strcmp (inp, "getIOStatistics"))
1987 {
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));
1992 destroy (res);
1993 }
1994 else if (!strcmp (inp, "getHeapStatistics"))
1995 {
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));
2000 destroy (res);
2001 }
2002 else if (!strcmp (inp, "getSamples"))
2003 {
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);
2012 destroy (res);
2013 }
2014 else if (!strcmp (inp, "getGCEvents"))
2015 {
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);
2024 destroy (res);
2025 }
2026 else if (!strcmp (inp, "getFuncNames"))
2027 {
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);
2033 delete arg2;
2034 destroy (res);
2035 }
2036 else if (!strcmp (inp, "getFuncIds"))
2037 {
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);
2043 delete arg2;
2044 destroy (res);
2045 }
2046 else if (!strcmp (inp, "getObjNamesV2"))
2047 {
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);
2053 delete arg2;
2054 destroy (res);
2055 }
2056 else if (!strcmp (inp, "getFuncName"))
2057 {
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);
2064 free (res);
2065 }
2066 else if (!strcmp (inp, "getObjNameV2"))
2067 {
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);
2074 free (res);
2075 }
2076 else if (!strcmp (inp, "getDataspaceTypeDesc"))
2077 {
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);
2084 free (res);
2085 }
2086 /*
2087 * New Interface with Timeline
2088 */
2089 #if 0 //YXXX TBR
2090 else if (!strcmp (inp, "dbeInit"))
2091 dbeInit ();
2092 else if (!strcmp (inp, "getDefaultExperimentName"))
2093 {
2094 String res = dbeGetDefaultExperimentName ();
2095 ipc_log (" returning = %s\n", res);
2096 writeString (res);
2097 free (res);
2098 }
2099 else if (!strcmp (inp, "getExperimentState"))
2100 {
2101 String res = dbeGetExperimentState ();
2102 ipc_log (" returning = %s\n", res);
2103 writeString (res);
2104 free (res);
2105 }
2106 else if (!strcmp (inp, "getExpStartTime"))
2107 {
2108 long long l = dbeGetExpStartTime ();
2109 ipc_log (" returns = %llu\n", l);
2110 writeLong (l);
2111 }
2112 else if (!strcmp (inp, "getExpEndTime"))
2113 {
2114 long long l = dbeGetExpEndTime ();
2115 ipc_log (" returns = %llu\n", l);
2116 writeLong (l);
2117 }
2118 #endif
2119 else if (!strcmp (inp, "getDataDescriptorsV2"))
2120 {//TBR? TBD
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);
2126 destroy (res);
2127 }
2128 else if (!strcmp (inp, "getDataPropertiesV2"))
2129 {//TBR? TBD
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);
2136 destroy (res);
2137 }
2138 else if (!strcmp (inp, "getExperimentTimeInfo"))
2139 {
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);
2145 destroy (res);
2146 }
2147 else if (!strcmp (inp, "getExperimentDataDescriptors"))
2148 {
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);
2154 destroy (res);
2155 }
2156 #if 0 //YXXX TBR?
2157 else if (!strcmp (inp, "getExprValues"))
2158 {//TBR? TBD
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);
2164 writeArray (res);
2165 delete res;
2166 free (arg2);
2167 }
2168 #endif
2169 else if (!strcmp (inp, "hasTLData"))
2170 {
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);
2181 destroy (res);
2182 }
2183 else if (!strcmp (inp, "getTLData"))
2184 {
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);
2196
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",
2199 dbevindex, exp_id,
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);
2205 #ifdef IPC_LOG
2206 if (res)
2207 {
2208 Vector<Obj> *reps = (Vector<Obj>*)res->fetch (0);
2209 Vector<Obj> *props = (Vector<Obj>*)res->fetch (1);
2210 if (reps)
2211 {
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);
2215 int i;
2216 for (i = 0; i < sz && i < 7; i++)
2217 ipc_log (" %lld", fids->fetch (i));
2218 if (i < sz)
2219 ipc_log (" ... %lld", fids->fetch (sz - 1));
2220 ipc_log ("\n");
2221 }
2222 if (props)
2223 {
2224 int nprops = props->size ();
2225 ipc_log (" returning values for %d properties:\n", nprops);
2226 assert (secondaryProps->size () == nprops);
2227 }
2228 }
2229 else
2230 ipc_log (" returning NULL\n");
2231 #endif
2232 writeArray (res, req);
2233 destroy (res);
2234 destroy (secondaryProps);
2235 }
2236 else if (!strcmp (inp, "getTLEventCenterTime"))
2237 {
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",
2248 dbevindex, exp_id,
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);
2255 }
2256 else if (!strcmp (inp, "getTLEventIdxNearTime"))
2257 {
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",
2268 dbevindex, exp_id,
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);
2276 }
2277 else if (!strcmp (inp, "getAggregatedValue"))
2278 {
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);
2296 #ifdef IPC_LOG
2297 if (res)
2298 {
2299 int sz = res->size ();
2300 ipc_log (" returning = %d values:", sz);
2301 if (sz > 10)
2302 sz = 10;
2303 for (int i = 0; i < sz; i++)
2304 ipc_log (" %lld", res->fetch (i));
2305 ipc_log ("\n");
2306 }
2307 else
2308 ipc_log (" returning NULL\n");
2309 #endif
2310 writeArray (res, req);
2311 delete res;
2312 free (arg2);
2313 free (arg3);
2314 free (arg4);
2315 free (arg8);
2316 free (arg9);
2317 }
2318 #if 0//YXXX TBR
2319 else if (!strcmp (inp, "getExprValue"))
2320 {
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 : "");
2329 writeString (res);
2330 free (res);
2331 free (arg3);
2332 }
2333 else if (!strcmp (inp, "getListValues"))
2334 {
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);
2339 writeArray (res);
2340 destroy (res);
2341 }
2342 else if (!strcmp (inp, "getListNames"))
2343 {
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);
2348 writeArray (res);
2349 destroy (res);
2350 }
2351 #endif
2352 else if (!strcmp (inp, "getLineInfo"))
2353 {
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);
2360 destroy (res);
2361 }
2362 else if (!strcmp (inp, "setAlias"))
2363 {
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);
2372 }
2373 else if (!strcmp (inp, "getAlias"))
2374 {
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);
2381 destroy (res);
2382 }
2383 else if (!strcmp (inp, "getXYPlotData"))
2384 {
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);
2402
2403 #ifdef IPC_LOG
2404 if (res)
2405 {
2406 long nvals = res->size ();
2407 for (long i = 0; i < nvals; ++i)
2408 {
2409 Vector<long long> *vals = res->fetch (i);
2410 long long sz = VSIZE (vals);
2411 ipc_log (" returning = %lld values:", sz);
2412 if (sz > 10)
2413 sz = 10;
2414 for (long j = 0; j < sz; j++)
2415 ipc_log (" %lld", vals->fetch (j));
2416 ipc_log ("\n");
2417 }
2418 }
2419 else
2420 ipc_log (" returning NULL\n");
2421 #endif
2422 writeArray (res, req);
2423 destroy (res);
2424 }
2425 else if (strcmp (inp, "dbe_archive") == 0)
2426 {
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);
2430 delete ids;
2431 destroy (locations);
2432 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
2433 }
2434 else if (strcmp (inp, "dbeSetLocations") == 0)
2435 {
2436 Vector<const char*> *fnames = (Vector<const char*> *) readArray (req);
2437 Vector<const char*> *locations = (Vector<const char*> *) readArray (req);
2438 dbeSetLocations (fnames, locations);
2439 destroy (fnames);
2440 destroy (locations);
2441 writeResponseGeneric (RESPONSE_STATUS_SUCCESS, currentRequestID, currentChannelID);
2442 }
2443 else if (strcmp (inp, "dbeResolvedWith_setpath") == 0)
2444 {
2445 char *path = readString (req);
2446 Vector<void *> *res = dbeResolvedWith_setpath (path);
2447 free (path);
2448 writeArray (res, req);
2449 destroy (res);
2450 }
2451 else if (strcmp (inp, "dbeResolvedWith_pathmap") == 0)
2452 {
2453 char *old_prefix = readString (req);
2454 char *new_prefix = readString (req);
2455 Vector<void *> *res = dbeResolvedWith_pathmap (old_prefix, new_prefix);
2456 free (old_prefix);
2457 free (new_prefix);
2458 writeArray (res, req);
2459 destroy (res);
2460 }
2461 else if (!strcmp (inp, "getCollectorControlValue"))
2462 {
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);
2469 }
2470 else if (!strcmp (inp, "setCollectorControlValue"))
2471 {
2472 /* int dbevindex =*/ readInt (req);
2473 char *control = readString (req);
2474 char *value = readString (req);
2475 #ifdef IPC_LOG
2476 ipc_log (" args = %s %s\n", control, value);
2477 #endif
2478 char *ret = dbeSetCollectorControlValue (control, value);
2479 #ifdef IPC_LOG
2480 if (ret)
2481 ipc_log (" returning %s\n", ret);
2482 else
2483 ipc_log (" returning NULL\n");
2484 #endif
2485 writeString (ret, req);
2486 }
2487 else if (!strcmp (inp, "unsetCollectorControlValue"))
2488 {
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);
2495 }
2496 else if (!strcmp (inp, "getSignalValue"))
2497 {
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);
2503 }
2504 else if (!strcmp (inp, "sendSignal"))
2505 {
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);
2510 #ifdef IPC_LOG
2511 if (ret)
2512 ipc_log (" returning %s\n", ret);
2513 else
2514 ipc_log (" returning NULL\n");
2515 #endif
2516 writeString (ret, req);
2517 }
2518 else if (!strcmp (inp, "checkConnection"))
2519 {
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");
2525 free (arg1);
2526 free (res);
2527 }
2528 else if (!strcmp (inp, "QUIT"))
2529 {
2530 #ifdef IPC_LOG
2531 ipc_log (" %s\n", inp);
2532 #endif
2533 exit (0);
2534 }
2535 else
2536 {
2537 ipc_log ("Unrecognized input cmd \"%s\"; Aborting.\n", inp);
2538 return 1;
2539 }
2540 ipc_log (" processing IPC command %s complete\n", inp);
2541 free (inp);
2542 fflush (stdout);
2543 if (req->getStatus () != CANCELLED_IMMEDIATE)
2544 // wake up the main working thread, let it take care of delete
2545 req->setStatus (COMPLETED);
2546 delete req;
2547 return 0;
2548 }
2549
2550 void
check_env_args(int argc,char * argv[])2551 check_env_args (int argc, char *argv[])
2552 {
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)
2560 {
2561 char *option = argv[indx++];
2562 if (!streq (option, MINUS_E))
2563 continue;
2564 cmd_env_var = argv[indx++];
2565 char *separator = strchr (cmd_env_var, SEPARATOR);
2566 if (!separator)
2567 // Unrecognized option. Fatal error?
2568 continue;
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)))
2572 {
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;
2581 continue;
2582 }
2583 if (!strncmp (cmd_env_var, SP_IPC_PROTOCOL, strlen (SP_IPC_PROTOCOL)))
2584 {
2585 if (streq (cmd_env_var_val, IPC_PROTOCOL_CURR))
2586 // Only one protocol is currently supported
2587 ipc_protocol = IPC_PROTOCOL_CURR;
2588 else
2589 ipc_protocol = IPC_PROTOCOL_UNKNOWN;
2590 continue;
2591 }
2592 // Unrecognized option. Fatal error?
2593 }
2594 }
2595
2596 void
print_ipc_protocol_confirmation()2597 print_ipc_protocol_confirmation ()
2598 {
2599 if (NULL != ipc_protocol)
2600 {
2601 fprintf (stdout, "ER_IPC: %s\n", ipc_protocol);
2602 fflush (stdout);
2603 }
2604 }
2605
2606 void
ipc_mainLoop(int argc,char * argv[])2607 ipc_mainLoop (int argc, char *argv[])
2608 {
2609 if (getenv ("GPROFNG_DBE_DELAY"))
2610 sleep (20);
2611 #ifdef IPC_LOG
2612 ipc_flags = 1;
2613 #endif
2614 // check_env_args(argc, argv);
2615
2616 char *er_print_trace_level = getenv ("SP_ER_PRINT_TRACE_LEVEL");
2617 if (er_print_trace_level != NULL)
2618 {
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;
2627 }
2628 check_env_args (argc, argv);
2629 print_ipc_protocol_confirmation ();
2630
2631 if (ipc_flags || getenv ("SP_ER_PRINT_IPC_FLAG") || ipc_trace_level > TRACE_LVL_0)
2632 {
2633 ipc_flags = 1;
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)
2642 {
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");
2647 }
2648 else
2649 {
2650 ipc_request_log_name = "ipc_log";
2651 ipc_response_log_name = "ipc_log";
2652 }
2653 begin_time = gethrtime ();
2654 }
2655 else
2656 // Reopen stderr as /dev/null
2657 freopen ("/dev/null", "w", stderr);
2658
2659 struct sigaction act;
2660 memset (&act, 0, sizeof (struct sigaction));
2661 term_flag = 0;
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)
2668 {
2669 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGTERM handler\n");
2670 abort ();
2671 }
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)
2678 {
2679 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGINT handler\n");
2680 abort ();
2681 }
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)
2688 {
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)
2697 {
2698 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGABRT handler\n");
2699 // abort();
2700 }
2701 else
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)
2709 {
2710 ipc_request_trace (TRACE_LVL_1, "Unable to install SIGSEGV handler\n");
2711 // abort();
2712 }
2713 else
2714 ipc_log ("Installed SIGSEGV handler to handle crash properly\n");
2715 }
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");
2724
2725 /* Send "Ready" signal to the GUI */
2726 setProgress (100, "Restart engine");
2727
2728 /* start listening for requests */
2729 error_flag = 0;
2730 for (;;)
2731 {
2732 readRequestHeader ();
2733 if (term_flag == 1 || error_flag == 1)
2734 {
2735 ipc_request_trace (TRACE_LVL_1, "SIGTERM received, exiting\n");
2736 return;
2737 }
2738 }
2739 }
2740
2741 static const char *
table_name(int flavor)2742 table_name (int flavor)
2743 {
2744 static char def_name[64];
2745
2746 switch ((FuncListDisp_type) flavor)
2747 {
2748 case DSP_FUNCTION:
2749 return ("FUNCTION");
2750 case DSP_LINE:
2751 return ("LINE");
2752 case DSP_PC:
2753 return ("PC");
2754 case DSP_SOURCE:
2755 return ("SOURCE");
2756 case DSP_DISASM:
2757 return ("DISASM");
2758 case DSP_SELF:
2759 return ("SELF");
2760 case DSP_CALLER:
2761 return ("CALLER");
2762 case DSP_CALLEE:
2763 return ("CALLEE");
2764 case DSP_CALLTREE:
2765 return ("CALLTREE");
2766 case DSP_TIMELINE:
2767 return ("TIMELINE");
2768 case DSP_STATIS:
2769 return ("STATIS");
2770 case DSP_EXP:
2771 return ("EXP");
2772 case DSP_LEAKLIST:
2773 return ("LEAKLIST");
2774 case DSP_HEAPCALLSTACK:
2775 return ("HEAP");
2776 case DSP_MEMOBJ:
2777 return ("MEMOBJ");
2778 case DSP_DATAOBJ:
2779 return ("DATAOBJ");
2780 case DSP_DLAYOUT:
2781 return ("DLAYOUT");
2782 case DSP_SRC_FILE:
2783 return ("SRC_FILE");
2784 case DSP_IFREQ:
2785 return ("IFREQ");
2786 case DSP_RACES:
2787 return ("RACES");
2788 case DSP_INDXOBJ:
2789 return ("INDXOBJ");
2790 case DSP_DUALSOURCE:
2791 return ("DUALSOURCE");
2792 case DSP_SOURCE_DISASM:
2793 return ("SOURCE_DISASM");
2794 case DSP_DEADLOCKS:
2795 return ("DEADLOCKS");
2796 case DSP_SOURCE_V2:
2797 return ("SOURCE_V2");
2798 case DSP_DISASM_V2:
2799 return ("DISASM_V2");
2800 case DSP_IOACTIVITY:
2801 return ("IOACTIVITY");
2802 case DSP_OVERVIEW:
2803 return ("OVERVIEW");
2804 case DSP_SAMPLE:
2805 return ("SAMPLE -- UNEXPECTED");
2806 default:
2807 snprintf (def_name, sizeof (def_name), "table number %d", flavor);
2808 return (def_name);
2809 }
2810 }
2811