From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2041) id 1A13F385B1A1; Tue, 29 Nov 2022 04:52:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A13F385B1A1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Vladimir Mezentsev To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] gprofng: remove unused gprofng/src/DbeSession.cc.1 X-Act-Checkin: binutils-gdb X-Git-Author: Vladimir Mezentsev X-Git-Refname: refs/heads/master X-Git-Oldrev: d0a2cfbd3141dae38498fa077b01ae6bb394462b X-Git-Newrev: 5a4020d4d4082f0a853631ca69c6944c94575457 Message-Id: <20221129045250.1A13F385B1A1@sourceware.org> Date: Tue, 29 Nov 2022 04:52:50 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2022 04:52:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5a4020d4d408= 2f0a853631ca69c6944c94575457 commit 5a4020d4d4082f0a853631ca69c6944c94575457 Author: Vladimir Mezentsev Date: Mon Nov 28 20:51:19 2022 -0800 gprofng: remove unused gprofng/src/DbeSession.cc.1 Diff: --- gprofng/src/DbeSession.cc.1 | 3531 ---------------------------------------= ---- 1 file changed, 3531 deletions(-) diff --git a/gprofng/src/DbeSession.cc.1 b/gprofng/src/DbeSession.cc.1 deleted file mode 100644 index 7d635d23add..00000000000 --- a/gprofng/src/DbeSession.cc.1 +++ /dev/null @@ -1,3531 +0,0 @@ -/* Copyright (C) 2021 Free Software Foundation, Inc. - Contributed by Oracle. - - This file is part of GNU Binutils. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, 51 Franklin Street - Fifth Floor, Boston, - MA 02110-1301, USA. */ - -#include "config.h" -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" -#include "Application.h" -#include "Experiment.h" -#include "ExpGroup.h" -#include "Expression.h" -#include "DataObject.h" -#include "Elf.h" -#include "Function.h" -#include "DbeSession.h" -#include "LoadObject.h" -#include "DbeSyncMap.h" -#include "DbeThread.h" -#include "ClassFile.h" -#include "IndexObject.h" -#include "PathTree.h" -#include "Print.h" -#include "QLParser.tab.hh" -#include "DbeView.h" -#include "MemorySpace.h" -#include "Module.h" -#include "SourceFile.h" -#include "StringBuilder.h" -#include "BaseMetric.h" -#include "BaseMetricTreeNode.h" -#include "Command.h" -#include "UserLabel.h" -#include "StringMap.h" -#include "DbeFile.h" -#include "DbeJarFile.h" -#include "IOActivity.h" -#include "HeapActivity.h" - -// This is a universal List structure to organize objects -// of various types, even if different. -struct List -{ - List *next; - void *val; -}; - -struct Countable -{ - Countable (void *_item) - { - item =3D _item; - ref_count =3D 0; - } - - void *item; - int ref_count; -}; - -Platform_t DbeSession::platform =3D -#if ARCH(SPARC) - Sparc; -#elif ARCH(Aarch64) - Aarch64; -#else // ARCH(Intel) - Intel; -#endif - -// This constant determines the size of the data object name hash table. -static const int HTableSize =3D 8192; -static int DEFAULT_TINY_THRESHOLD =3D -1; - -unsigned int mpmt_debug_opt =3D 0; -DbeSession *dbeSession =3D NULL; - -DbeSession::DbeSession (Settings *_settings, bool _ipc_mode, bool _rdt_mod= e) -{ - dbeSession =3D this; - ipc_mode =3D _ipc_mode; - rdt_mode =3D _rdt_mode; - settings =3D new Settings (_settings); - views =3D new Vector; - exps =3D new Vector; - lobjs =3D new Vector; - objs =3D new Vector; - dobjs =3D new Vector; - metrics =3D new Vector; - reg_metrics =3D new Vector; - hwcentries =3D NULL; - reg_metrics_tree =3D NULL; // BaseMetric() requires DbeSession::ql_parse - idxobjs =3D new Vector*>; - tmp_files =3D new Vector; - search_path =3D new Vector; - classpath =3D new Vector; - classpath_df =3D NULL; - expGroups =3D new Vector; - sourcesMap =3D new HashMap; - sources =3D new Vector; - comp_lobjs =3D new HashMap; - comp_dbelines =3D new HashMap; - comp_sources =3D new HashMap; - loadObjMap =3D new DbeSyncMap; - f_special =3D new Vector(LastSpecialFunction); - omp_functions =3D new Vector(OMP_LAST_STATE); - interactive =3D false; - lib_visibility_used =3D false; - - // Define all known property names - propNames =3D new Vector; - propNames_name_store (PROP_NONE, NTXT ("")); - propNames_name_store (PROP_ATSTAMP, NTXT ("ATSTAMP")); - propNames_name_store (PROP_ETSTAMP, NTXT ("ETSTAMP")); - propNames_name_store (PROP_TSTAMP, NTXT ("TSTAMP")); - propNames_name_store (PROP_THRID, NTXT ("THRID")); - propNames_name_store (PROP_LWPID, NTXT ("LWPID")); - propNames_name_store (PROP_CPUID, NTXT ("CPUID")); - propNames_name_store (PROP_FRINFO, NTXT ("FRINFO")); - propNames_name_store (PROP_EVT_TIME, NTXT ("EVT_TIME")); - - // Samples - propNames_name_store (PROP_SMPLOBJ, NTXT ("SMPLOBJ")); - propNames_name_store (PROP_SAMPLE, NTXT ("SAMPLE")); - - // GCEvents - propNames_name_store (PROP_GCEVENTOBJ, NTXT ("GCEVENTOBJ")); - propNames_name_store (PROP_GCEVENT, NTXT ("GCEVENT")); - - // Metadata used by some packet types - propNames_name_store (PROP_VOIDP_OBJ, NTXT ("VOIDP_OBJ"), - NULL, TYPE_UINT64, DDFLAG_NOSHOW); - - // Clock profiling properties - propNames_name_store (PROP_UCPU, NTXT ("UCPU")); - propNames_name_store (PROP_SCPU, NTXT ("SCPU")); - propNames_name_store (PROP_TRAP, NTXT ("TRAP")); - propNames_name_store (PROP_TFLT, NTXT ("TFLT")); - propNames_name_store (PROP_DFLT, NTXT ("DFLT")); - propNames_name_store (PROP_KFLT, NTXT ("KFLT")); - propNames_name_store (PROP_ULCK, NTXT ("ULCK")); - propNames_name_store (PROP_TSLP, NTXT ("TSLP")); - propNames_name_store (PROP_WCPU, NTXT ("WCPU")); - propNames_name_store (PROP_TSTP, NTXT ("TSTP")); - - propNames_name_store (PROP_MSTATE, NTXT ("MSTATE")); - propNames_name_store (PROP_NTICK, NTXT ("NTICK")); - propNames_name_store (PROP_OMPSTATE, NTXT ("OMPSTATE")); - - // Synchronization tracing properties - propNames_name_store (PROP_SRQST, NTXT ("SRQST")); - propNames_name_store (PROP_SOBJ, NTXT ("SOBJ")); - - // Hardware counter profiling properties - propNames_name_store (PROP_HWCTAG, NTXT ("HWCTAG")); - propNames_name_store (PROP_HWCINT, NTXT ("HWCINT")); - propNames_name_store (PROP_VADDR, NTXT ("VADDR")); - propNames_name_store (PROP_PADDR, NTXT ("PADDR")); - propNames_name_store (PROP_VIRTPC, NTXT ("VIRTPC")); - propNames_name_store (PROP_PHYSPC, NTXT ("PHYSPC")); - propNames_name_store (PROP_LWP_LGRP_HOME, NTXT ("LWP_LGRP_HOME")); - propNames_name_store (PROP_PS_LGRP_HOME, NTXT ("PS_LGRP_HOME")); - propNames_name_store (PROP_EA_PAGESIZE, NTXT ("EA_PAGESIZE")); - propNames_name_store (PROP_EA_LGRP, NTXT ("EA_LGRP")); - propNames_name_store (PROP_PC_PAGESIZE, NTXT ("PC_PAGESIZE")); - propNames_name_store (PROP_PC_LGRP, NTXT ("PC_LGRP")); - propNames_name_store (PROP_HWCDOBJ, NTXT ("HWCDOBJ")); - propNames_name_store (PROP_MEM_LAT, NTXT ("MEM_LAT")); - propNames_name_store (PROP_MEM_SRC, NTXT ("MEM_SRC")); - - // Heap tracing properties - propNames_name_store (PROP_HTYPE, NTXT ("HTYPE")); - propNames_name_store (PROP_HSIZE, NTXT ("HSIZE")); - propNames_name_store (PROP_HVADDR, NTXT ("HVADDR")); - propNames_name_store (PROP_HOVADDR, NTXT ("HOVADDR")); - propNames_name_store (PROP_HLEAKED, NTXT ("HLEAKED"), - GTXT ("Leaked bytes"), TYPE_UINT64, 0); - propNames_name_store (PROP_HMEM_USAGE, NTXT ("HMEM_USAGE")); - propNames_name_store (PROP_HFREED, NTXT ("HFREED"), - GTXT ("Freed bytes"), TYPE_UINT64, 0); - propNames_name_store (PROP_HCUR_ALLOCS, NTXT ("HCUR_ALLOCS"), - GTXT ("Current allocations"), TYPE_INT64, 0); - propNames_name_store (PROP_HCUR_NET_ALLOC, NTXT ("HCUR_NET_ALLOC"), - NULL, TYPE_INT64, DDFLAG_NOSHOW); - propNames_name_store (PROP_HCUR_LEAKS, NTXT ("HCUR_LEAKS"), - GTXT ("Current leaks"), TYPE_UINT64, 0); - propNames_name_store (PROP_DDSCR_LNK, NTXT ("DDSCR_LNK"), - NULL, TYPE_UINT64, DDFLAG_NOSHOW); - - // IO tracing properties - propNames_name_store (PROP_IOTYPE, NTXT ("IOTYPE")); - propNames_name_store (PROP_IOFD, NTXT ("IOFD")); - propNames_name_store (PROP_IONBYTE, NTXT ("IONBYTE")); - propNames_name_store (PROP_IORQST, NTXT ("IORQST")); - propNames_name_store (PROP_IOOFD, NTXT ("IOOFD")); - propNames_name_store (PROP_IOFNAME, NTXT ("IOFNAME")); - propNames_name_store (PROP_IOVFD, NTXT ("IOVFD")); - propNames_name_store (PROP_IOFSTYPE, NTXT ("IOFSTYPE")); - - // omptrace raw properties - propNames_name_store (PROP_CPRID, NTXT ("CPRID")); - propNames_name_store (PROP_PPRID, NTXT ("PPRID")); - propNames_name_store (PROP_TSKID, NTXT ("TSKID")); - propNames_name_store (PROP_PTSKID, NTXT ("PTSKID")); - propNames_name_store (PROP_PRPC, NTXT ("PRPC")); - - // Data race detection properties - propNames_name_store (PROP_RID, NTXT ("RID")); - propNames_name_store (PROP_RTYPE, NTXT ("RTYPE")); - propNames_name_store (PROP_LEAFPC, NTXT ("LEAFPC")); - propNames_name_store (PROP_RVADDR, NTXT ("RVADDR")); - propNames_name_store (PROP_RCNT, NTXT ("RCNT")); - - // Deadlock detection properties - propNames_name_store (PROP_DID, NTXT ("DID")); - propNames_name_store (PROP_DLTYPE, NTXT ("DLTYPE")); - propNames_name_store (PROP_DTYPE, NTXT ("DTYPE")); - propNames_name_store (PROP_DVADDR, NTXT ("DVADDR")); - - // Synthetic properties (queries only) - propNames_name_store (PROP_STACK, NTXT ("STACK")); - propNames_name_store (PROP_MSTACK, NTXT ("MSTACK")); - propNames_name_store (PROP_USTACK, NTXT ("USTACK")); - propNames_name_store (PROP_XSTACK, NTXT ("XSTACK")); - propNames_name_store (PROP_HSTACK, NTXT ("HSTACK")); - propNames_name_store (PROP_STACKID, NTXT ("STACKID")); - //propNames_name_store( PROP_CPRID, NTXT("CPRID") ); - //propNames_name_store( PROP_TSKID, NTXT("TSKID") ); - propNames_name_store (PROP_JTHREAD, NTXT ("JTHREAD"), - GTXT ("Java thread number"), TYPE_UINT64, 0); - - propNames_name_store (PROP_LEAF, NTXT ("LEAF")); - propNames_name_store (PROP_DOBJ, NTXT ("DOBJ")); - propNames_name_store (PROP_SAMPLE_MAP, NTXT ("SAMPLE_MAP")); - propNames_name_store (PROP_GCEVENT_MAP, NTXT ("GCEVENT_MAP")); - propNames_name_store (PROP_PID, NTXT ("PID"), - GTXT ("Process id"), TYPE_UINT64, 0); - propNames_name_store (PROP_EXPID, NTXT ("EXPID"), - GTXT ("Experiment id"), TYPE_UINT64, DDFLAG_NOSHOW= ); - propNames_name_store (PROP_EXPID_CMP, NTXT ("EXPID_CMP"), - GTXT ("Comparable Experiment Id"), TYPE_UINT64, - DDFLAG_NOSHOW); //YXXX find better description - propNames_name_store (PROP_EXPGRID, NTXT ("EXPGRID"), - GTXT ("Comparison Group id"), TYPE_UINT64, 0); - propNames_name_store (PROP_PARREG, NTXT ("PARREG")); - propNames_name_store (PROP_TSTAMP_LO, NTXT ("TSTAMP_LO"), - GTXT ("Start Timestamp (nanoseconds)"), TYPE_UINT6= 4, 0); - propNames_name_store (PROP_TSTAMP_HI, NTXT ("TSTAMP_HI"), - GTXT ("End Timestamp (nanoseconds)"), TYPE_UINT64,= 0); - propNames_name_store (PROP_TSTAMP2, NTXT ("TSTAMP2"), - GTXT ("End Timestamp (nanoseconds)"), TYPE_UINT64, - DDFLAG_NOSHOW); - propNames_name_store (PROP_FREQ_MHZ, NTXT ("FREQ_MHZ"), - GTXT ("CPU Frequency, MHz"), TYPE_UINT32, 0); - propNames_name_store (PROP_NTICK_USEC, NTXT ("NTICK_USEC"), - GTXT ("Clock Profiling Interval, Microseconds"), - TYPE_UINT64, 0); - - propNames_name_store (PROP_IOHEAPBYTES, NTXT ("IOHEAPBYTES")); - - propNames_name_store (PROP_STACKL, NTXT ("STACKL")); - propNames_name_store (PROP_MSTACKL, NTXT ("MSTACKL")); - propNames_name_store (PROP_USTACKL, NTXT ("USTACKL")); - propNames_name_store (PROP_XSTACKL, NTXT ("XSTACKL")); - - propNames_name_store (PROP_STACKI, NTXT ("STACKI")); - propNames_name_store (PROP_MSTACKI, NTXT ("MSTACKI")); - propNames_name_store (PROP_USTACKI, NTXT ("USTACKI")); - propNames_name_store (PROP_XSTACKI, NTXT ("XSTACKI")); - - // Make sure predefined names are not used for dynamic properties - propNames_name_store (PROP_LAST, NTXT ("")); - - localized_SP_UNKNOWN_NAME =3D GTXT ("(unknown)"); - - // define Index objects - dyn_indxobj =3D new Vector(); - dyn_indxobj_indx =3D 0; - char *s =3D dbe_sprintf (NTXT ("((EXPID_CMP<<%llu) | THRID)"), - (unsigned long long) IndexObject::INDXOBJ_EXPID_S= HIFT); - indxobj_define (NTXT ("Threads"), GTXT ("Threads"), s, NULL, NULL); - free (s); - indxobj_define (NTXT ("CPUs"), GTXT ("CPUs"), NTXT ("(CPUID)"), NULL, NU= LL); - indxobj_define (NTXT ("Samples"), GTXT ("Samples"), NTXT ("(SAMPLE_MAP)"= ), - NULL, NULL); - indxobj_define (NTXT ("GCEvents"), GTXT ("GCEvents"), NTXT ("(GCEVENT_MA= P)"), - NULL, NULL); - indxobj_define (NTXT ("Seconds"), GTXT ("Seconds"), - NTXT ("(TSTAMP/1000000000)"), NULL, NULL); - indxobj_define (NTXT ("Processes"), GTXT ("Processes"), NTXT ("(EXPID_CM= P)"), - NULL, NULL); - s =3D dbe_sprintf (NTXT ("((EXPGRID<<%llu) | (EXPID<<%llu))"), - (unsigned long long) IndexObject::INDXOBJ_EXPGRID_SHIFT, - (unsigned long long) IndexObject::INDXOBJ_EXPID_SHIFT); - indxobj_define (NTXT ("Experiment_IDs"), GTXT ("Experiment_IDs"), s, NUL= L, NULL); - free (s); - indxobj_define (NTXT ("Datasize"), GTXT ("Datasize"), - "(IOHEAPBYTES=3D=3D0?0:" - "((IOHEAPBYTES<=3D(1<<0)?(1<<0):" - "((IOHEAPBYTES<=3D(1<<2)?(1<<2):" - "((IOHEAPBYTES<=3D(1<<4)?(1<<4):" - "((IOHEAPBYTES<=3D(1<<6)?(1<<6):" - "((IOHEAPBYTES<=3D(1<<8)?(1<<8):" - "((IOHEAPBYTES<=3D(1<<10)?(1<<10):" - "((IOHEAPBYTES<=3D(1<<12)?(1<<12):" - "((IOHEAPBYTES<=3D(1<<14)?(1<<14):" - "((IOHEAPBYTES<=3D(1<<16)?(1<<16):" - "((IOHEAPBYTES<=3D(1<<18)?(1<<18):" - "((IOHEAPBYTES<=3D(1<<20)?(1<<20):" - "((IOHEAPBYTES<=3D(1<<22)?(1<<22):" - "((IOHEAPBYTES<=3D(1<<24)?(1<<24):" - "((IOHEAPBYTES<=3D(1<<26)?(1<<26):" - "((IOHEAPBYTES<=3D(1<<28)?(1<<28):" - "((IOHEAPBYTES<=3D(1<<30)?(1<<30):" - "((IOHEAPBYTES<=3D(1<<32)?(1<<32):" - "((IOHEAPBYTES<=3D(1<<34)?(1<<34):" - "((IOHEAPBYTES<=3D(1<<36)?(1<<36):" - "((IOHEAPBYTES<=3D(1<<38)?(1<<38):" - "((IOHEAPBYTES<=3D(1<<40)?(1<<40):" - "((IOHEAPBYTES<=3D(1<<42)?(1<<42):" - "((IOHEAPBYTES<=3D(1<<44)?(1<<44):" - "((IOHEAPBYTES<=3D(1<<46)?(1<<46):" - "((IOHEAPBYTES<=3D(1<<48)?(1<<48):" - "((IOHEAPBYTES<=3D(1<<50)?(1<<50):" - "(IOHEAPBYTES=3D=3D-1?-1:(1<<50|1)" - "))))))))))))))))))))))))))))))))))))))))))))))))))))))", - NULL, NULL); - indxobj_define (NTXT ("Duration"), GTXT ("Duration"), - "((TSTAMP_HI-TSTAMP_LO)=3D=3D0?0:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D1000?1000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D10000?10000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D100000?100000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D1000000?1000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D10000000?10000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D100000000?100000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D1000000000?1000000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D10000000000?10000000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D100000000000?100000000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D1000000000000?1000000000000:" - "(((TSTAMP_HI-TSTAMP_LO)<=3D10000000000000?1000000000000= 0:" - "(10000000000001))))))))))))))))))))))))", NULL, NULL); - dyn_indxobj_indx_fixed =3D dyn_indxobj_indx; - Elf::elf_init (); - defExpName =3D NULL; - mach_model_loaded =3D NULL; - tmp_dir_name =3D NULL; - settings->read_rc (ipc_mode || rdt_mode); - - init (); -} - -DbeSession::~DbeSession () -{ - Destroy (views); - Destroy (exps); - Destroy (dobjs); - Destroy (metrics); - Destroy (search_path); - Destroy (classpath); - Destroy (propNames); - Destroy (expGroups); - Destroy (userLabels); - if (hwcentries) - { - for (long i =3D 0, sz =3D hwcentries->size (); i < sz; i++) - { - Hwcentry *h =3D hwcentries->get (i); - free (h->int_name); - free (h->name); - delete h; - } - delete hwcentries; - } - - if (idxobjs) - { - for (int i =3D 0; i < idxobjs->size (); ++i) - { - HashMap *hMap =3D idxobjs->get (i); - if (hMap) - { - hMap->values ()->destroy (); - delete hMap; - } - } - delete idxobjs; - } - - for (int i =3D 0; i < HTableSize; i++) - { - List *list =3D dnameHTable[i]; - while (list) - { - List *tmp =3D list; - list =3D list->next; - delete tmp; - } - } - delete[] dnameHTable; - delete classpath_df; - Destroy (objs); - Destroy (reg_metrics); - Destroy (dyn_indxobj); - delete lobjs; - delete f_special; - destroy_map (DbeFile *, dbeFiles); - destroy_map (DbeJarFile *, dbeJarFiles); - delete loadObjMap; - delete omp_functions; - delete sourcesMap; - delete sources; - delete comp_lobjs; - delete comp_dbelines; - delete comp_sources; - delete reg_metrics_tree; - delete settings; - free (mach_model_loaded); - - if (defExpName !=3D NULL) - { - StringBuilder *sb =3D new StringBuilder (); - sb->append (NTXT ("/bin/rm -rf ")); - sb->append (defExpName); - char *cmd =3D sb->toString (); - system (cmd); - free (cmd); - delete sb; - free (defExpName); - } - unlink_tmp_files (); - delete tmp_files; - dbeSession =3D NULL; -} - -void -DbeSession::unlink_tmp_files () -{ - if (tmp_files) - { - for (int i =3D 0, sz =3D tmp_files->size (); i < sz; i++) - unlink (tmp_files->fetch (i)); - tmp_files->destroy (); - delete tmp_files; - tmp_files =3D NULL; - } - if (tmp_dir_name) - { - char *cmd =3D dbe_sprintf (NTXT ("/bin/rm -rf %s"), tmp_dir_name); - system (cmd); - free (cmd); - free (tmp_dir_name); - tmp_dir_name =3D NULL; - } -} - -char * -DbeSession::get_tmp_file_name (const char *nm, bool for_java) -{ - if (tmp_dir_name =3D=3D NULL) - { - tmp_dir_name =3D dbe_sprintf (NTXT ("/tmp/analyzer.%llu.%lld"), - (unsigned long long) getuid (), (long long) getpi= d ()); - mkdir (tmp_dir_name, S_IRWXU); - } - char *fnm =3D dbe_sprintf (NTXT ("%s/%s"), tmp_dir_name, nm); - if (for_java) - for (char *s =3D fnm + strlen (tmp_dir_name) + 1; *s; s++) - if (*s =3D=3D '/') - *s =3D '.'; - return fnm; -} - -void -DbeSession::init () -{ - user_exp_id_counter =3D 0; - status_ompavail =3D 0; - archive_mode =3D 0; - -#if DEBUG - char *s =3D getenv (NTXT ("MPMT_DEBUG")); - if (s) - mpmt_debug_opt =3D atoi (s); -#endif /* DEBUG */ - dbeFiles =3D new StringMap(); - dbeJarFiles =3D new StringMap(128, 128); - - // set up the initial (after .rc file reading) search path - set_search_path (settings->str_search_path, true); - userLabels =3D NULL; - - // Preset all objects as they may reuse each other - lo_unknown =3D NULL; - f_unknown =3D NULL; - j_unknown =3D NULL; - lo_total =3D NULL; - sf_unknown =3D NULL; - f_total =3D NULL; - f_jvm =3D NULL; - d_total =3D NULL; - d_scalars =3D NULL; - d_unknown =3D NULL; - expGroups->destroy (); - f_special->reset (); - for (int i =3D 0; i < LastSpecialFunction; i++) - f_special->append (NULL); - - lo_omp =3D NULL; - omp_functions->reset (); - for (int i =3D 0; i < OMP_LAST_STATE; i++) - omp_functions->append (NULL); - - // make sure the metric list is initialized - register_metric (Metric::SIZES); - register_metric (Metric::ADDRESS); - register_metric (Metric::ONAME); - - // This is needed only to maintain loadobject id's - // for and in tests=20 - (void) get_Unknown_LoadObject (); - (void) get_Total_LoadObject (); - - // Create the data object name hash table. - dnameHTable =3D new List*[HTableSize]; - for (int i =3D 0; i < HTableSize; i++) - dnameHTable[i] =3D NULL; - - d_total =3D createDataObject (); - d_total->set_name (NTXT ("")); - - // XXXX only appropriate for Program/Data-oriented analyses - d_scalars =3D createDataObject (); - d_scalars->set_name (GTXT ("")); - - d_unknown =3D createDataObject (); - d_unknown->set_name (GTXT ("")); - - // assign d_unknown's children so data_olayout has consistent sorting - for (unsigned pp_code =3D 1; pp_code < NUM_ABS_PP_CODES + 2; pp_code++) - { - char *errcode; - DataObject* dobj =3D createDataObject (); - switch (pp_code) - { - case NUM_ABS_PP_CODES + 1: - errcode =3D PTXT (DOBJ_UNDETERMINED); - break; - case NUM_ABS_PP_CODES: - errcode =3D PTXT (DOBJ_UNSPECIFIED); - break; - case NUM_ABS_PP_CODES - 1: - errcode =3D PTXT (DOBJ_UNIDENTIFIED); - break; - default: - errcode =3D PTXT (ABS_PP_CODES[pp_code]); - } - dobj->parent =3D d_unknown; - dobj->set_dobjname (errcode, NULL); // dobj->parent must already be = set - } - - for (unsigned rt_code =3D 1; rt_code < NUM_ABS_RT_CODES - 1; rt_code++) - { - DataObject* dobj =3D createDataObject (); - dobj->parent =3D d_unknown; - dobj->set_dobjname (PTXT (ABS_RT_CODES[rt_code]), NULL); // dobj->pa= rent must already be set - } -} - -void -DbeSession::reset_data () -{ - for (long i =3D 0, sz =3D VecSize (idxobjs); i < sz; ++i) - if (idxobjs->get (i)) - idxobjs->get (i)->reset (); -} - -void -DbeSession::reset () -{ - loadObjMap->reset (); - DbeView *dbev; - int index; - - Vec_loop (DbeView*, views, index, dbev) - { - dbev->reset (); - } - - destroy_map (DbeFile *, dbeFiles); - destroy_map (DbeJarFile *, dbeJarFiles); - exps->destroy (); - lobjs->reset (); // all LoadObjects belong to objs - dobjs->destroy (); // deletes d_unknown and d_total as well - objs->destroy (); - comp_lobjs->clear (); - comp_dbelines->clear (); - comp_sources->clear (); - sourcesMap->clear (); - sources->reset (); - - // Delete the data object name hash table. - for (int i =3D 0; i < HTableSize; i++) - { - List *list =3D dnameHTable[i]; - while (list) - { - List *tmp =3D list; - list =3D list->next; - delete tmp; - } - } - delete[] dnameHTable; - - // IndexObect definitions remain, objects themselves may go - for (int i =3D 0; i < idxobjs->size (); ++i) - { - HashMap *v =3D idxobjs->fetch (i); - if (v !=3D NULL) - { - v->values ()->destroy (); - v->clear (); - } - } - init (); -} - -Vector * -DbeSession::get_sources () -{ - return sources; -} - -DbeFile * -DbeSession::getDbeFile (char *filename, int filetype) -{ - Dprintf (DEBUG_DBE_FILE, NTXT ("DbeSession::getDbeFile filetype=3D0x%x = %s\n"), filetype, filename); - if (strncmp (filename, NTXT ("./"), 2) =3D=3D 0) - filename +=3D 2; - DbeFile *dbeFile =3D dbeFiles->get (filename); - if (dbeFile =3D=3D NULL) - { - dbeFile =3D new DbeFile (filename); - dbeFiles->put (filename, dbeFile); - } - dbeFile->filetype |=3D filetype; - return dbeFile; -} - -LoadObject * -DbeSession::get_Total_LoadObject () -{ - if (lo_total =3D=3D NULL) - { - lo_total =3D createLoadObject (NTXT ("")); - lo_total->dbeFile->filetype |=3D DbeFile::F_FICTION; - } - return lo_total; -} - -Function * -DbeSession::get_Total_Function () -{ - if (f_total =3D=3D NULL) - { - f_total =3D createFunction (); - f_total->flags |=3D FUNC_FLAG_SIMULATED | FUNC_FLAG_NO_OFFSET; - f_total->set_name (NTXT ("")); - Module *mod =3D get_Total_LoadObject ()->noname; - f_total->module =3D mod; - mod->functions->append (f_total); - } - return f_total; -} - -LoadObject * -DbeSession::get_Unknown_LoadObject () -{ - if (lo_unknown =3D=3D NULL) - { - lo_unknown =3D createLoadObject (GTXT ("")); - lo_unknown->type =3D LoadObject::SEG_TEXT; // makes it expandable - lo_unknown->dbeFile->filetype |=3D DbeFile::F_FICTION; - - // force creation of the function - (void) get_Unknown_Function (); - } - return lo_unknown; -} - -SourceFile * -DbeSession::get_Unknown_Source () -{ - if (sf_unknown =3D=3D NULL) - { - sf_unknown =3D createSourceFile (localized_SP_UNKNOWN_NAME); - sf_unknown->dbeFile->filetype |=3D DbeFile::F_FICTION; - sf_unknown->flags |=3D SOURCE_FLAG_UNKNOWN; - } - return sf_unknown; -} - -Function * -DbeSession::get_Unknown_Function () -{ - if (f_unknown =3D=3D NULL) - { - f_unknown =3D createFunction (); - f_unknown->flags |=3D FUNC_FLAG_SIMULATED; - f_unknown->set_name (GTXT ("")); - Module *mod =3D get_Unknown_LoadObject ()->noname; - f_unknown->module =3D mod; - mod->functions->append (f_unknown); - } - return f_unknown; -} - -// LIBRARY_VISIBILITY - -Function * -DbeSession::create_hide_function (LoadObject *lo) -{ - Function *h_function =3D createFunction (); - h_function->set_name (lo->get_name ()); - h_function->module =3D lo->noname; - h_function->isHideFunc =3D true; - lo->noname->functions->append (h_function); - return h_function; -} - -Function * -DbeSession::get_JUnknown_Function () -{ - if (j_unknown =3D=3D NULL) - { - j_unknown =3D createFunction (); - j_unknown->flags |=3D FUNC_FLAG_SIMULATED; - j_unknown->set_name (GTXT ("")); - Module *mod =3D get_Unknown_LoadObject ()->noname; - j_unknown->module =3D mod; - mod->functions->append (j_unknown); - } - return j_unknown; -} - -Function * -DbeSession::get_jvm_Function () -{ - if (f_jvm =3D=3D NULL) - { - f_jvm =3D createFunction (); - f_jvm->flags |=3D FUNC_FLAG_SIMULATED | FUNC_FLAG_NO_OFFSET; - f_jvm->set_name (GTXT ("")); - - // Find the JVM LoadObject - LoadObject *jvm =3D get_Unknown_LoadObject (); - for (int i =3D 0; i < lobjs->size (); ++i) - { - LoadObject *lo =3D lobjs->fetch (i); - if (lo->flags & SEG_FLAG_JVM) - { - jvm =3D lo; - break; - } - } - Module *mod =3D jvm->noname; - f_jvm->module =3D mod; - mod->functions->append (f_jvm); - // XXXX is it required? no consistency among all special functions - // jvm->functions->append( f_jvm ); - } - return f_jvm; -} - -Function * -DbeSession::getSpecialFunction (SpecialFunction kind) -{ - if (kind < 0 || kind >=3D LastSpecialFunction) - return NULL; - - Function *func =3D f_special->fetch (kind); - if (func =3D=3D NULL) - { - char *fname; - switch (kind) - { - case TruncatedStackFunc: - fname =3D GTXT (""); - break; - case FailedUnwindFunc: - fname =3D GTXT (""); - break; - default: - return NULL; - } - func =3D createFunction (); - func->flags |=3D FUNC_FLAG_SIMULATED | FUNC_FLAG_NO_OFFSET; - Module *mod =3D get_Total_LoadObject ()->noname; - func->module =3D mod; - mod->functions->append (func); - func->set_name (fname); - f_special->store (kind, func); - } - return func; -} - -LoadObject * -DbeSession::get_OMP_LoadObject () -{ - if (lo_omp =3D=3D NULL) - { - for (int i =3D 0, sz =3D lobjs->size (); i < sz; i++) - { - LoadObject *lo =3D lobjs->fetch (i); - if (lo->flags & SEG_FLAG_OMP) - { - lo_omp =3D lo; - return lo_omp; - } - } - lo_omp =3D createLoadObject (GTXT ("")); - lo_omp->type =3D LoadObject::SEG_TEXT; - lo_omp->dbeFile->filetype |=3D DbeFile::F_FICTION; - } - return lo_omp; -} - -Function * -DbeSession::get_OMP_Function (int n) -{ - if (n < 0 || n >=3D OMP_LAST_STATE) - return NULL; - - Function *func =3D omp_functions->fetch (n); - if (func =3D=3D NULL) - { - char *fname; - switch (n) - { - case OMP_OVHD_STATE: - fname =3D GTXT (""); - break; - case OMP_IDLE_STATE: - fname =3D GTXT (""); - break; - case OMP_RDUC_STATE: - fname =3D GTXT (""); - break; - case OMP_IBAR_STATE: - fname =3D GTXT (""); - break; - case OMP_EBAR_STATE: - fname =3D GTXT (""); - break; - case OMP_LKWT_STATE: - fname =3D GTXT (""); - break; - case OMP_CTWT_STATE: - fname =3D GTXT (""); - break; - case OMP_ODWT_STATE: - fname =3D GTXT (""); - break; - case OMP_ATWT_STATE: - fname =3D GTXT (""); - break; - default: - return NULL; - } - func =3D createFunction (); - func->flags |=3D FUNC_FLAG_SIMULATED | FUNC_FLAG_NO_OFFSET; - func->set_name (fname); - - LoadObject *omp =3D get_OMP_LoadObject (); - func->module =3D omp->noname; - omp->noname->functions->append (func); - omp->functions->append (func); - omp_functions->store (n, func); - } - return func; -} - -// Divide the original createExperiment() into two steps -// In part1, we just create the data structure, in part2, if -// we decide to keep the experiment around, add it to various -// lists in DbeSession -Experiment * -DbeSession::createExperimentPart1 () -{ - Experiment *exp =3D new Experiment (); - return exp; -} - -void -DbeSession::createExperimentPart2 (Experiment *exp) -{ - int ind =3D expGroups->size (); - if (ind > 0) - { - ExpGroup *gr =3D expGroups->fetch (ind - 1); - exp->groupId =3D gr->groupId; - gr->append (exp); - } - exp->setExpIdx (exps->size ()); - exp->setUserExpId (++user_exp_id_counter); - exps->append (exp); -} - -Experiment * -DbeSession::createExperiment () -{ - Experiment *exp =3D new Experiment (); - append (exp); - return exp; -} - -void -DbeSession::append (Experiment *exp) -{ - exp->setExpIdx (exps->size ()); - exp->setUserExpId (++user_exp_id_counter); - exps->append (exp); - if (exp->founder_exp) - { - if (exp->founder_exp->children_exps =3D=3D NULL) - exp->founder_exp->children_exps =3D new Vector; - exp->founder_exp->children_exps->append (exp); - if (exp->founder_exp->groupId > 0) - { - exp->groupId =3D exp->founder_exp->groupId; - expGroups->get (exp->groupId - 1)->append (exp); - } - } - if (exp->groupId =3D=3D 0) - { - long ind =3D VecSize (expGroups); - if (ind > 0) - { - ExpGroup *gr =3D expGroups->get (ind - 1); - exp->groupId =3D gr->groupId; - gr->append (exp); - } - } -} - -void -DbeSession::append (Hwcentry *h) -{ - if (hwcentries =3D=3D NULL) - hwcentries =3D new Vector; - hwcentries->append (h); -} - -int -DbeSession::ngoodexps () -{ - int cnt =3D 0; - for (long i =3D 0, sz =3D VecSize (exps); i < sz; i++) - if (exps->get (i)->get_status () =3D=3D Experiment::SUCCESS) - cnt++; - return cnt; -} - -int -DbeSession::createView (int index, int cloneindex) -{ - // ensure that there is no view with that index - DbeView *dbev =3D getView (index); - if (dbev !=3D NULL) - abort (); - - // find the view to be cloned - dbev =3D getView (cloneindex); - DbeView *newview; - if (dbev =3D=3D NULL) - newview =3D new DbeView (theApplication, settings, index); - else - newview =3D new DbeView (dbev, index); - views->append (newview); - return index; -} - -DbeView * -DbeSession::getView (int index) -{ - int i; - DbeView *dbev; - Vec_loop (DbeView*, views, i, dbev) - { - if (dbev->vindex =3D=3D index) - return dbev; - } - return NULL; -} - -void -DbeSession::dropView (int index) -{ - int i; - DbeView *dbev; - - Vec_loop (DbeView*, views, i, dbev) - { - if (dbev->vindex =3D=3D index) - { - views->remove (i); - delete dbev; - return; - } - } - // view not found; ignore for now -} - -Vector * -DbeSession::get_group_or_expt (char *path) -{ - Vector *exp_list =3D new Vector; - FILE *fptr; - char *new_path, buf[MAXPATHLEN], name[MAXPATHLEN]; - - fptr =3D fopen (path, NTXT ("r")); - if (!fptr || !fgets (buf, (int) sizeof (buf), fptr) - || strncmp (buf, SP_GROUP_HEADER, strlen (SP_GROUP_HEADER))) - { - // it's not an experiment group - new_path =3D dbe_strdup (path); - new_path =3D canonical_path (new_path); - exp_list->append (new_path); - } - else - { - // it is an experiment group, read the list to get them all - while (fgets (buf, (int) sizeof (buf), fptr)) - { - if ((*buf !=3D '#') && (sscanf (buf, NTXT ("%s"), name) =3D=3D 1= )) - { - new_path =3D dbe_strdup (name); - new_path =3D canonical_path (new_path); - exp_list->append (new_path); - } - } - } - if (fptr) - fclose (fptr); - return exp_list; -} - -#define GET_INT_VAL(v, s, len) \ - for (v =3D len =3D 0; isdigit(*s); s++, len++) { v =3D v * 10 + (*s -'= 0'); } - -static int -dir_name_cmp (const void *a, const void *b) -{ - char *s1 =3D *((char **) a); - char *s2 =3D *((char **) b); - while (*s1) - { - if (isdigit (*s1) && isdigit (*s2)) - { - int v1, v2, len1, len2; - GET_INT_VAL (v1, s1, len1); - GET_INT_VAL (v2, s2, len2); - if (v1 !=3D v2) - return v1 - v2; - if (len1 !=3D len2) - return len2 - len1; - continue; - } - if (*s1 !=3D *s2) - break; - s1++; - s2++; - } - return *s1 - *s2; -} - -static int -read_experiment_data_in_parallel (void *arg) -{ - exp_ctx *ctx =3D (exp_ctx *) arg; - Experiment *dexp =3D ctx->exp; - bool read_ahead =3D ctx->read_ahead; - dexp->read_experiment_data (read_ahead); - free (ctx); - return 0; -} - -void -DbeSession::open_experiment (Experiment *exp, char *path) -{ - exp->open (path); - if (exp->get_status () !=3D Experiment::FAILURE) - exp->read_experiment_data (false); - exp->open_epilogue (); - - // Update all DbeViews=20 - for (int i =3D 0, sz =3D views->size (); i < sz; i++) - { - DbeView *dbev =3D views->fetch (i); - dbev->add_experiment (exp->getExpIdx (), true); - } - - if (exp->get_status () =3D=3D Experiment::FAILURE) - { - check_tab_avail (); - return; - } - - char *discard_tiny =3D getenv (NTXT ("SP_ANALYZER_DISCARD_TINY_EXPERIMEN= TS")); - int user_specified_tiny_threshold =3D DEFAULT_TINY_THRESHOLD; // in mill= iseconds - if (discard_tiny !=3D NULL) - { - user_specified_tiny_threshold =3D (atoi (discard_tiny)); - if (user_specified_tiny_threshold < 0) - user_specified_tiny_threshold =3D DEFAULT_TINY_THRESHOLD; - } - - // Open descendant experiments - DIR *exp_dir =3D opendir (path); - if (exp_dir =3D=3D NULL) - { - check_tab_avail (); - return; - } - - Vector *exp_names =3D new Vector(); - struct dirent *entry =3D NULL; - while ((entry =3D readdir (exp_dir)) !=3D NULL) - { - if (entry->d_name[0] !=3D '_') - continue; - size_t len =3D strlen (entry->d_name); - if (len < 3 || strcmp (entry->d_name + len - 3, NTXT (".er")) !=3D 0) - continue; - exp_names->append (dbe_strdup (entry->d_name)); - } - closedir (exp_dir); - exp_names->sort (dir_name_cmp); - Experiment **t_exp_list =3D new Experiment *[exp_names->size ()]; - int nsubexps =3D 0; - - for (int j =3D 0, jsz =3D exp_names->size (); j < jsz; j++) - { - t_exp_list[j] =3D NULL; - - char *lineage_name =3D exp_names->fetch (j); - struct stat64 sbuf; - char *dpath =3D dbe_sprintf (NTXT ("%s/%s"), path, lineage_name); - - // look for experiments with no profile collected - if (user_specified_tiny_threshold =3D=3D DEFAULT_TINY_THRESHOLD) - { - char *frinfoname =3D dbe_sprintf (NTXT ("%s/%s"), dpath, "data."= SP_FRINFO_FILE); - int st =3D dbe_stat (frinfoname, &sbuf); - free (frinfoname); - if (st =3D=3D 0) - { - // if no profile/trace data do not process this experiment a= ny further - if (sbuf.st_size =3D=3D 0) - { - free (dpath); - continue; - } - } - } - else - { // check if dpath is a directory - if (dbe_stat (dpath, &sbuf) !=3D 0) - { - free (dpath); - continue; - } - else if (!S_ISDIR (sbuf.st_mode)) - { - free (dpath); - continue; - } - } - size_t lineage_name_len =3D strlen (lineage_name); - lineage_name[lineage_name_len - 3] =3D 0; /* remove .er */ - Experiment *dexp =3D new Experiment (); - dexp->founder_exp =3D exp; - if (user_specified_tiny_threshold > DEFAULT_TINY_THRESHOLD) - { - dexp->setTinyThreshold (user_specified_tiny_threshold); - dexp->open (dpath); - if (dexp->isDiscardedTinyExperiment ()) - { - delete dexp; - free (dpath); - continue; - } - } - else - dexp->open (dpath); - append (dexp); - t_exp_list[j] =3D dexp; - nsubexps++; - dexp->set_clock (exp->clock); - - // DbeView add_experiment() is split into two parts - // add_subexperiment() is called repeeatedly for - // all sub_experiments, later add_experiment_epilogue() finishes up = the task - for (int i =3D 0, sz =3D views->size (); i < sz; i++) - { - DbeView *dbev =3D views->fetch (i); - bool enabled =3D settings->check_en_desc (lineage_name, dexp->ut= argname); - dbev->add_subexperiment (dexp->getExpIdx (), enabled); - } - free (dpath); - } - - for (int i =3D 0, sz =3D views->size (); i < sz; i++) - { - DbeView *dbev =3D views->fetch (i); - dbev->add_experiment_epilogue (); - } - - DbeThreadPool * threadPool =3D new DbeThreadPool (-1); - for (int j =3D 0, jsz =3D exp_names->size (); j < jsz; j++) - { - if (t_exp_list[j] =3D=3D NULL) continue; - Experiment *dexp =3D t_exp_list[j]; - exp_ctx *new_ctx =3D (exp_ctx*) malloc (sizeof (exp_ctx)); - new_ctx->path =3D NULL; - new_ctx->exp =3D dexp; - new_ctx->ds =3D this; - new_ctx->read_ahead =3D true; - DbeQueue *q =3D new DbeQueue (read_experiment_data_in_parallel, new_= ctx); - threadPool->put_queue (q); - } - threadPool->wait_queues (); - delete threadPool; - - for (long j =3D 0, jsz =3D exp_names->size (); j < jsz; j++) - { - if (t_exp_list[j] =3D=3D NULL) continue; - Experiment *dexp =3D t_exp_list[j]; - dexp->open_epilogue (); - } - exp_names->destroy (); - delete[] t_exp_list; - delete exp_names; - - // update setting for leaklist and dataspace - check_tab_avail (); -} - -void -DbeSession::append_mesgs (StringBuilder *sb, char *path, Experiment *exp) -{ - if (exp->fetch_errors () !=3D NULL) - { - // yes, there were errors - char *ststr =3D pr_mesgs (exp->fetch_errors (), NTXT (""), NTXT ("")= ); - sb->append (path); - sb->append (NTXT (": ")); - sb->append (ststr); - free (ststr); - } - - Emsg *m =3D exp->fetch_warnings (); - if (m !=3D NULL) - { - sb->append (path); - sb->append (NTXT (": ")); - if (!is_interactive ()) - sb->append (GTXT ("Experiment has warnings, see header for details= \n")); - else - sb->append (GTXT ("Experiment has warnings, see experiment panel f= or details\n")); - } - - // Check for descendant experiments that are not loaded - int num_desc =3D VecSize (exp->children_exps); - if ((num_desc > 0) && !settings->check_en_desc (NULL, NULL)) - { - char *s; - if (!is_interactive ()) - s =3D dbe_sprintf (GTXT ("Has %d descendant(s), use commands contr= olling selection to load descendant data\n"), num_desc); - else - s =3D dbe_sprintf (GTXT ("Has %d descendant(s), use filter panel t= o load descendant data\n"), num_desc); - sb->append (path); - sb->append (NTXT (": ")); - sb->append (s); - free (s); - } -} - -Experiment * -DbeSession::get_exp (int exp_ind) -{ - if (exp_ind < 0 || exp_ind >=3D exps->size ()) - return NULL; - Experiment *exp =3D exps->fetch (exp_ind); - exp->setExpIdx (exp_ind); - return exp; -} - -Vector*> * -DbeSession::getExperimensGroups () -{ - if (dbeSession->expGroups =3D=3D NULL || dbeSession->expGroups->size () = =3D=3D 0) - return NULL; - bool compare_mode =3D expGroups->size () > 1; - Vector*> *groups =3D new Vector*> ( - compare_mode ? expGroups->size ()= : 1); - for (int i =3D 0; i < expGroups->size (); i++) - { - ExpGroup *grp =3D expGroups->fetch (i); - Vector *founders =3D grp->get_founders (); - if (founders && founders->size () !=3D 0) - { - Vector *names =3D new Vector (founders->size ()); - for (int j =3D 0; j < founders->size (); j++) - { - Experiment *exp =3D founders->fetch (j); - names->append (dbe_strdup (exp->get_expt_name ())); - } - if (compare_mode || groups->size () =3D=3D 0) - groups->append (names); - else - groups->fetch (0)->addAll (names); - } - delete founders; - } - return groups; -} - -char * -DbeSession::setExperimentsGroups (Vector*> *groups) -{ - StringBuilder sb; - for (int i =3D 0; i < groups->size (); i++) - { - Vector *names =3D groups->fetch (i); - ExpGroup *grp; - if (names->size () =3D=3D 1) - grp =3D new ExpGroup (names->fetch (0)); - else - { - char *nm =3D dbe_sprintf (GTXT ("Group %d"), i + 1); - grp =3D new ExpGroup (nm); - free (nm); - } - expGroups->append (grp); - grp->groupId =3D expGroups->size (); - - for (int j =3D 0; j < names->size (); j++) - { - char *path =3D names->fetch (j); - size_t len =3D strlen (path); - if ((len > 4) && !strcmp (path + len - 4, NTXT (".erg"))) - { - Vector *lst =3D get_group_or_expt (path); - for (int j1 =3D 0; j1 < lst->size (); j1++) - { - Experiment *exp =3D new Experiment (); - append (exp); - open_experiment (exp, lst->get (j1)); - if (exp->get_status () =3D=3D Experiment::FAILURE) - append_mesgs (&sb, path, exp); - } - lst->destroy (); - delete lst; - } - else - { - Experiment *exp =3D new Experiment (); - append (exp); - open_experiment (exp, path); - if (exp->get_status () =3D=3D Experiment::FAILURE) - append_mesgs (&sb, path, exp); - } - } - } - - for (int i =3D 0, sz =3D views->size (); i < sz; i++) - { - DbeView *dbev =3D views->fetch (i); - dbev->update_advanced_filter (); - int cmp =3D dbev->get_settings ()->get_compare_mode (); - dbev->set_compare_mode (CMP_DISABLE); - dbev->set_compare_mode (cmp); - } - return sb.length () =3D=3D 0 ? NULL : sb.toString (); -} - -char * -DbeSession::drop_experiment (int exp_ind) -{ - DbeView *dbev; - int index; - Experiment *exp2; - - status_ompavail =3D -1; - Experiment *exp =3D exps->fetch (exp_ind); - - // If this is a sub experiment, don't do it - if (exp->founder_exp !=3D NULL) // this is a sub experiment; don't d= o it - return (dbe_strdup (GTXT ("Can not drop subexperiments"))); - - if (VecSize (exp->children_exps) > 0) - for (;;) - { - // search the list of experiments to find all that have this one a= s founder - bool found =3D false; - Vec_loop (Experiment*, exps, index, exp2) - { - if (exp2->founder_exp =3D=3D exp) - { - exp2->founder_exp =3D NULL; - drop_experiment (index); - found =3D true; - break; - } - } - if (found =3D=3D false) - break; - } - - // then proceed to finish the drop - Vec_loop (DbeView*, views, index, dbev) - { - dbev->drop_experiment (exp_ind); - } - - int old_cnt =3D expGroups->size (); - for (int i =3D 0; i < old_cnt; i++) - { - ExpGroup *gr =3D expGroups->fetch (i); - if (gr->groupId =3D=3D exp->groupId) - { - gr->drop_experiment (exp); - if ((gr->founder =3D=3D NULL) && (gr->exps->size () =3D=3D 0)) - { - delete gr; - expGroups->remove (i); - } - break; - } - } - delete exps->remove (exp_ind); - if (old_cnt !=3D expGroups->size ()) - { - for (int i =3D 0, sz =3D expGroups->size (); i < sz; i++) - { - ExpGroup *gr =3D expGroups->fetch (i); - gr->groupId =3D i + 1; - Vector *expList =3D gr->exps; - for (int i1 =3D 0, sz1 =3D expList->size (); i1 < sz1; i1++) - expList->fetch (i1)->groupId =3D gr->groupId; - } - for (int i =3D 0, sz =3D views->size (); i < sz; i++) - { - dbev =3D views->fetch (i); - int cmp =3D dbev->get_compare_mode (); - dbev->set_compare_mode (CMP_DISABLE); - dbev->set_compare_mode (cmp); - } - } - check_tab_avail (); // update tab availability - return NULL; -} - -int -DbeSession::find_experiment (char *path) -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (strcmp (exp->get_expt_name (), path) =3D=3D 0) - return exp->getExpIdx (); - } - return -1; -} - -LoadObject * -DbeSession::createLoadObject (const char *nm, int64_t cksum) -{ - return loadObjMap->sync_create_item (nm, cksum); -} - -LoadObject * -DbeSession::createLoadObject (const char *nm, const char *runTimePath, Dbe= File *df) -{ - return loadObjMap->sync_create_item (nm, runTimePath, df); -} - -void -DbeSession::append (LoadObject *lobj) -{ - Histable *obj =3D lobj; // workaround for a C++ problem - objs->append (obj); - lobj->id =3D objs->size () - 1; - lobjs->append (lobj); - lobj->seg_idx =3D lobjs->size () - 1; - char *loname =3D lobj->get_pathname (); - dbeFiles->put (loname, lobj->dbeFile); -} - -DbeJarFile * -DbeSession::get_JarFile (const char *name) -{ - DbeJarFile *jf =3D dbeJarFiles->get (name); - if (jf =3D=3D NULL) - { - jf =3D new DbeJarFile (name); - dbeJarFiles->put (name, jf); - } - return jf; -} - -Module * -DbeSession::createModule (LoadObject *lo, const char *nm) -{ - Module *mod =3D new Module (); - Histable *obj =3D mod; // workaround for a C++ problem - objs->append (obj); - mod->id =3D objs->size () - 1; - mod->loadobject =3D lo; - mod->set_name (dbe_strdup (nm ? nm : localized_SP_UNKNOWN_NAME)); - lo->seg_modules->append (mod); - return mod; -} - -Module * -DbeSession::createUnknownModule (LoadObject *lo) -{ - Module *mod =3D createModule (lo, localized_SP_UNKNOWN_NAME); - mod->flags |=3D MOD_FLAG_UNKNOWN; - mod->set_file_name (dbe_strdup (localized_SP_UNKNOWN_NAME)); - return mod; -} - -SourceFile * -DbeSession::createSourceFile (const char *_path) -{ - char *path =3D (char *) _path; - if (strncmp (path, NTXT ("./"), 2) =3D=3D 0) - path +=3D 2; - SourceFile *source =3D sourcesMap->get (path); - if (source =3D=3D NULL) - { - source =3D new SourceFile (path); - (void) sourcesMap->put (path, source); - append (source); - } - return source; -} - -Function * -DbeSession::createFunction () -{ - Function *func =3D new Function (objs->size ()); - Histable *obj =3D func; // workaround for a C++ problem - objs->append (obj); - return func; -} - -JMethod * -DbeSession::createJMethod () -{ - JMethod *jmthd =3D new JMethod (objs->size ()); - Histable *obj =3D jmthd; // workaround for a C++ problem - objs->append (obj); - return jmthd; -} - -Module * -DbeSession::createClassFile (char *className) -{ - ClassFile *cls =3D new ClassFile (); - cls->set_name (className); - char *clpath =3D cls->get_java_file_name (className, true); - cls->dbeFile =3D getDbeFile (clpath, DbeFile::F_JAVACLASS); - free (clpath); - Histable *obj =3D cls; // workaround for a C++ problem - objs->append (obj); - cls->id =3D objs->size () - 1; - return cls; -} - -Histable * -DbeSession::createHistObject (Histable::Type type) -{ - switch (type) - { - case Histable::DOBJECT: - { - DataObject *dataobj =3D new DataObject (); - dobjs->append (dataobj); - dataobj->id =3D dobjs->size () - 1; - return dataobj; - } - default: - assert (0); - } - return NULL; -} - -DataObject * -DbeSession::createDataObject () -{ - DataObject *dataobj =3D new DataObject (); - dobjs->append (dataobj); - dataobj->id =3D dobjs->size () - 1; - return dataobj; -} - -DataObject * -DbeSession::createDataObject (DataObject *dobj, DataObject *parent) -{ - DataObject *dataobj =3D new DataObject (); - dataobj->size =3D dobj->size; - dataobj->offset =3D dobj->offset; - dataobj->parent =3D parent; - dataobj->set_dobjname (dobj->get_typename (), dobj->get_instname ()); - dobjs->append (dataobj); - dataobj->id =3D dobjs->size () - 1; - return dataobj; -} - -DataObject * -DbeSession::createMasterDataObject (DataObject *dobj) -{ - DataObject *parent =3D NULL; - if (dobj->parent) - { // define master parent first - parent =3D find_dobj_master (dobj->parent); - if (!parent) - { // clone master from this dataobject parent - parent =3D createDataObject (dobj->parent); - parent->scope =3D NULL; // master is scope-less - Dprintf (DEBUG_DATAOBJ, - "Master DataObject(%llu) cloned from (%llu) %s\n", - (ull_t) parent->id, (ull_t) dobj->parent->id, - dobj->parent->get_name ()); - // clone master DataObject elements - Vector *delem =3D get_dobj_elements (dobj->parent); - int element_index =3D 0; - DataObject *element =3D NULL; - Vec_loop (DataObject*, delem, element_index, element) - { - DataObject *master_element =3D createDataObject (element, pare= nt); - master_element->scope =3D NULL; // master is scope-less - Dprintf (DEBUG_DATAOBJ, - "Member DataObject(%llu) cloned from (%llu) %s\n", - (ull_t) master_element->id, (ull_t) element->id, - element->get_name ()); - } - } - else - Dprintf (DEBUG_DATAOBJ, "Master DataObject(%llu) clone found (%llu= ) %s\n", - (ull_t) parent->id, (ull_t) dobj->parent->id, - dobj->parent->get_name ()); - } - - DataObject *master =3D find_dobj_master (dobj); - if (!master) - { // clone master from this dataobject - master =3D createDataObject (dobj, parent); - master->scope =3D NULL; // master is scope-less - Dprintf (DEBUG_DATAOBJ, "Master DataObject(%llu) cloned from (%llu) = %s\n", - (ull_t) master->id, (ull_t) dobj->id, dobj->get_name ()); - } - else - Dprintf (DEBUG_DATAOBJ, "Master DataObject(%llu) clone found (%llu) %s= \n", - (ull_t) master->id, (ull_t) dobj->id, dobj->get_name ()); - return master; -} - -void -DbeSession::insert_metric (BaseMetric *mtr, Vector *mlist) -{ - if ((mtr->get_flavors () & Metric::STATIC) =3D=3D 0) - { - // insert in front of the first STATIC - for (int i =3D 0, mlist_sz =3D mlist->size (); i < mlist_sz; i++) - { - BaseMetric *m =3D mlist->fetch (i); - if (m->get_flavors () & Metric::STATIC) - { - mlist->insert (i, mtr); - return; - } - } - } - mlist->append (mtr); -} - -BaseMetricTreeNode* -DbeSession::get_reg_metrics_tree () -{ - if (reg_metrics_tree =3D=3D NULL) - // Can't init earlier because BaseMetric() requires DbeSession::ql_par= se - reg_metrics_tree =3D new BaseMetricTreeNode (); - return reg_metrics_tree; -} - -void -DbeSession::update_metric_tree (BaseMetric *m) -{ - get_reg_metrics_tree ()->register_metric (m); -} - -BaseMetric * -DbeSession::register_metric_expr (BaseMetric::Type type, char *cmd, char *= expr_spec) -{ - BaseMetric *m =3D find_metric (type, cmd, expr_spec); - if (m) - return m; - BaseMetric *bm =3D find_metric (type, cmd, NULL); // clone this version - m =3D new BaseMetric (*bm); - m->set_expr_spec (expr_spec); - insert_metric (m, reg_metrics); - return m; -} - -BaseMetric * -DbeSession::register_metric (BaseMetric::Type type) -{ - BaseMetric *m =3D find_metric (type, NULL, NULL); - if (m) - return m; - m =3D new BaseMetric (type); - insert_metric (m, reg_metrics); - update_metric_tree (m); - return m; -} - -BaseMetric * -DbeSession::register_metric (Hwcentry *ctr, const char* aux, const char* u= sername) -{ - BaseMetric *m =3D find_metric (BaseMetric::HWCNTR, aux, NULL); - if (m) - // That may be a problem when metrics aren't an exact match. - // For example, memoryspace is disabled in one experiment and not in a= nother. - return m; - if (ctr->timecvt) - { - char *time_cmd =3D dbe_sprintf (NTXT ("t%s"), aux); - char *time_username =3D dbe_sprintf (GTXT ("%s Time"), - ctr->metric ? ctr->metric : - (ctr->name ? ctr->name : ctr->int_n= ame)); - BaseMetric *m1; - if (ipc_mode) - { - // Two visible metrics are presented in GUI - m1 =3D new BaseMetric (ctr, aux, time_cmd, time_username, VAL_TI= MEVAL); - insert_metric (m1, reg_metrics); - update_metric_tree (m1); - m =3D new BaseMetric (ctr, aux, username, VAL_VALUE, m1); - } - else - { - // Only one visible metric is presented in er_print - m1 =3D new BaseMetric (ctr, aux, time_cmd, time_username, VAL_TI= MEVAL | VAL_INTERNAL); - insert_metric (m1, reg_metrics); - m =3D new BaseMetric (ctr, aux, username, VAL_TIMEVAL | VAL_VALU= E, m1); - } - free (time_cmd); - free (time_username); - } - else - m =3D new BaseMetric (ctr, aux, username, VAL_VALUE); - insert_metric (m, reg_metrics); - update_metric_tree (m); - return m; -} - -BaseMetric * -DbeSession::register_metric (char *name, char *username, char *_def) -{ - BaseMetric *m =3D find_metric (BaseMetric::DERIVED, name, NULL); - if (m) - return m; - Definition *p =3D Definition::add_definition (_def); - if (p =3D=3D NULL) - return NULL; - m =3D new BaseMetric (name, username, p); - insert_metric (m, reg_metrics); - update_metric_tree (m); - return m; -} - -void -DbeSession::drop_metric (BaseMetric *mtr) -{ - Countable *cnt; - int index; - - Vec_loop (Countable*, metrics, index, cnt) - { - if (mtr =3D=3D (BaseMetric *) cnt->item) - { - cnt->ref_count--; - if (cnt->ref_count =3D=3D 0) - { - // Remove this metric from all views - DbeView *dbev; - int index2; - Vec_loop (DbeView*, views, index2, dbev) - { - dbev->reset_metrics (); - } - delete metrics->remove (index); - delete mtr; - return; - } - } - } -} - -BaseMetric * -DbeSession::find_metric (BaseMetric::Type type, const char *cmd, const cha= r *expr_spec) -{ - for (int i =3D 0, sz =3D reg_metrics->size (); i < sz; i++) - { - BaseMetric *bm =3D reg_metrics->fetch (i); - if (bm->get_type () =3D=3D type && dbe_strcmp (bm->get_expr_spec (),= expr_spec) =3D=3D 0) - { - if ((type =3D=3D BaseMetric::DERIVED || type =3D=3D BaseMetric::= HWCNTR) - && dbe_strcmp (bm->get_cmd (), cmd) !=3D 0) - continue; - return bm; - } - } - return NULL; -} - -BaseMetric * -DbeSession::find_base_reg_metric (char * mcmd) -{ - for (int i =3D 0, sz =3D reg_metrics->size (); i < sz; i++) - { - BaseMetric *bm =3D reg_metrics->fetch (i); - if (bm->get_expr_spec () !=3D NULL) - continue; // skip compare metrics - if (dbe_strcmp (bm->get_cmd (), mcmd) =3D=3D 0) - return bm; - } - return NULL; -} - -Vector * -DbeSession::get_base_reg_metrics () -{ - Vector *mlist =3D new Vector; - Vector *ml =3D get_all_reg_metrics (); - for (int i =3D 0, sz =3D ml->size (); i < sz; i++) - { - BaseMetric *m =3D ml->fetch (i); - if (m->get_expr_spec () =3D=3D NULL) - mlist->append (m); - } - return mlist; -} - -void -DbeSession::check_tab_avail () -{ - DbeView *dbev; - int index; - // tell the views to update their tab lists - Vec_loop (DbeView*, views, index, dbev) - { - dbev->get_settings ()->updateTabAvailability (); - } -} - -bool -DbeSession::is_datamode_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->dataspaceavail) - return true; - } - return false; -} - -bool -DbeSession::is_leaklist_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->leaklistavail) - return true; - } - return false; -} - -bool -DbeSession::is_heapdata_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->heapdataavail) - return true; - } - return false; -} - -bool -DbeSession::is_iodata_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->iodataavail) - return true; - } - return false; -} - -bool -DbeSession::is_racelist_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->racelistavail) - return true; - } - return false; -} - -bool -DbeSession::is_deadlocklist_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->deadlocklistavail) - return true; - } - return false; -} - -bool -DbeSession::is_timeline_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->timelineavail) - return true; - } - return false; -} - -bool -DbeSession::is_ifreq_available () -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - if (exp->ifreqavail) - return true; - } - return false; -} - -bool -DbeSession::is_omp_available () -{ - if (status_ompavail =3D=3D -1) - { - status_ompavail =3D 0; - for (int i =3D 0, sz =3D exps ? exps->size () : 0; i < sz; i++) - { - Experiment *exp =3D exps->fetch (i); - if (exp->ompavail) - { - status_ompavail =3D 1; - break; - } - } - } - return status_ompavail =3D=3D 1; -} - -bool -DbeSession::has_java () -{ - int status_has_java =3D 0; - for (int i =3D 0, sz =3D exps ? exps->size () : 0; i < sz; i++) - { - Experiment *exp =3D exps->fetch (i); - if (exp->has_java) - { - status_has_java =3D 1; - break; - } - } - return status_has_java =3D=3D 1; -} - -bool -DbeSession::has_ompavail () -{ - int status_has_ompavail =3D 0; - for (int i =3D 0, sz =3D exps ? exps->size () : 0; i < sz; i++) - { - Experiment *exp =3D exps->fetch (i); - if (exp->ompavail) - { - status_has_ompavail =3D 1; - break; - } - } - return status_has_ompavail =3D=3D 1; -} - -int -DbeSession::get_clock (int whichexp) -{ - // XXXX clock frequency should be an attribute of each CPU, - // XXX and not a property of the session - // if whichexp is -1, pick the first exp that has a clock - // otherwise return the clock from the numbered experiment - Experiment *exp; - if (whichexp !=3D -1) - { - exp =3D get_exp (whichexp); - if (exp !=3D NULL) - return exp->clock; - return 0; - } - int n =3D nexps (); - for (int i =3D 0; i < n; i++) - { - exp =3D get_exp (i); - if (exp !=3D NULL && exp->clock !=3D 0) - return exp->clock; - } - return 0; -} - -LoadObject * -DbeSession::find_lobj_by_name (const char *lobj_name, int64_t cksum) -{ - return loadObjMap->get (lobj_name, cksum); -} - -static unsigned -hash (char *s) -{ - unsigned res =3D 0; - for (int i =3D 0; i < 64 && *s; i++) - res =3D res * 13 + *s++; - return res; -} - -// This method is introduced to fix performance -// problems with the data space profiling in the -// current release. A better design is desired. -void -DbeSession::dobj_updateHT (DataObject *dobj) -{ - unsigned index =3D hash (dobj->get_unannotated_name ()) % HTableSize; - List *list =3D new List; - list->val =3D (void*) dobj; - list->next =3D dnameHTable[index]; - dnameHTable[index] =3D list; -} - -DataObject * -DbeSession::find_dobj_by_name (char *dobj_name) -{ - unsigned index =3D hash (dobj_name) % HTableSize; - List *list =3D dnameHTable[index]; - for (; list; list =3D list->next) - { - DataObject *d =3D (DataObject*) list->val; - if (strcmp (d->get_unannotated_name (), dobj_name) =3D=3D 0) - return d; - } - return (DataObject *) NULL; -} - -DataObject * -DbeSession::find_dobj_match (DataObject *dobj) -{ - char *dobj_name =3D dobj->get_unannotated_name (); - unsigned index =3D hash (dobj_name) % HTableSize; - List *list =3D dnameHTable[index]; - for (; list; list =3D list->next) - { - DataObject *d =3D (DataObject*) list->val; - if (strcmp (d->get_unannotated_name (), dobj_name) =3D=3D 0 - && d->size =3D=3D dobj->size && d->offset =3D=3D dobj->offset - && d->scope =3D=3D dobj->scope) - return d; - } - return (DataObject *) NULL; -} - -DataObject * -DbeSession::find_dobj_master (DataObject *dobj) -{ - char *dobj_name =3D dobj->get_unannotated_name (); - unsigned index =3D hash (dobj_name) % HTableSize; - List *list =3D dnameHTable[index]; - for (; list; list =3D list->next) - { - DataObject *d =3D (DataObject*) list->val; - // XXXX should parent also match? - if (strcmp (d->get_unannotated_name (), dobj_name) =3D=3D 0 - && d->size =3D=3D dobj->size && d->offset =3D=3D dobj->offset - && d->master =3D=3D NULL && d->scope =3D=3D NULL) - return d; - } - return (DataObject *) NULL; -} - -Vector* -DbeSession::get_dobj_elements (DataObject *dobj) -{ - DataObject *d; - int index; - Vector *elements =3D new Vector; - if (dobj =3D=3D d_total) - return elements; - Vec_loop (DataObject*, dobjs, index, d) - { - if (d->get_parent () && d->get_parent () =3D=3D dobj) - elements->append (d); - } - return elements; -} - -Vector* -DbeSession::get_text_segments () -{ - LoadObject *lo; - int index; - Vector *tlobjs =3D new Vector; - Vec_loop (LoadObject*, lobjs, index, lo) - { - if (lo->type =3D=3D LoadObject::SEG_TEXT) - tlobjs->append (lo); - } - return tlobjs; -} - -static long long -getNumber (const char *s, char * &last) -{ - long long val; - char *sp; - errno =3D 0; - val =3D strtoll (s, &sp, 0); - if (errno =3D=3D EINVAL) - last =3D NULL; - else - { - while (isspace (*sp)) - sp++; - last =3D sp; - } - return (val); -} - -bool -DbeSession::find_obj (FILE *dis_file, FILE *inp_file, Histable *&obj, - char *name, const char *sel, Histable::Type type, bo= ol xdefault) -{ - Vector *obj_lst; - int which =3D -1; - char *last =3D NULL; - if (type !=3D Histable::FUNCTION && sel) - { - // check that a number has been provided - which =3D (int) getNumber (sel, last); - if (last =3D=3D NULL || *last !=3D '\0') - { - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"), s= el); - sel =3D NULL; - which =3D 0; - } - which--; - } - obj_lst =3D new Vector; - switch (type) - { - case Histable::FUNCTION: - obj =3D map_NametoFunction (name, obj_lst, sel); - break; - case Histable::MODULE: - obj =3D map_NametoModule (name, obj_lst, which); - break; - case Histable::LOADOBJECT: - obj =3D map_NametoLoadObject (name, obj_lst, which); - break; - case Histable::DOBJECT: - obj =3D map_NametoDataObject (name, obj_lst, which); - break; - default: - abort (); // unexpected Histable! - } - - if ((obj =3D=3D NULL) && (obj_lst->size () > 0)) - { - if (obj_lst->size () =3D=3D 1) - which =3D 0; - else - { - if (sel && (which < 0 || which >=3D obj_lst->size ())) - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"),= sel); - if (xdefault) - { - fprintf (stderr, GTXT ("Default selection \"1\" made\n")); - which =3D 0; - } - else - { - which =3D ask_which (dis_file, inp_file, obj_lst, name); - if (which =3D=3D -1) - { - delete obj_lst; - return false; - } - } - } - obj =3D obj_lst->fetch (which); - } - delete obj_lst; - return true; -} - -int -DbeSession::ask_which (FILE *dis_file, FILE *inp_file, - Vector *list, char *name) -{ - Histable *hitem; - Function *func; - Module *module; - int which, index, index1; - char *item_name, *lo_name, *fname, *last; - char buf[BUFSIZ]; - for (;;) - { - fprintf (dis_file, GTXT ("Available name list:\n")); - fprintf (dis_file, GTXT ("%8d) Cancel\n"), 0); - Vec_loop (Histable*, list, index, hitem) - { - index1 =3D index + 1; - item_name =3D hitem->get_name (); - switch (hitem->get_type ()) - { - case Histable::FUNCTION: - func =3D (Function *) hitem; - module =3D func->module; - - // id =3D=3D -1 indicates er_src invocation - if (module =3D=3D NULL || (module->lang_code =3D=3D Sp_lang_ja= va - && module->loadobject->id =3D=3D -1)) - fprintf (dis_file, NTXT ("%8d) %s\n"), index1, item_name); - else - { - lo_name =3D module->loadobject->get_pathname (); - fname =3D (module->file_name && *module->file_name) ? - module->file_name : module->get_name (); - if (fname && *fname) - fprintf (dis_file, NTXT ("%8d) %s %s:0x%llx (%s)\n"), in= dex1, - item_name, lo_name, (ull_t) func->img_offset, f= name); - else - fprintf (dis_file, NTXT ("%8d) %s %s:0x%llx\n"), index1, - item_name, lo_name, (ull_t) func->img_offset); - } - break; - case Histable::MODULE: - module =3D (Module *) hitem; - lo_name =3D module->loadobject->get_pathname (); - if (name[strlen (name) - 1] =3D=3D - module->file_name[strlen (module->file_name) - 1]) - fprintf (dis_file, NTXT ("%8d) %s(%s)\n"), index1, - module->file_name, lo_name); - else - fprintf (dis_file, NTXT ("%8d) %s(%s)\n"), index1, item_name, - lo_name); - break; - default: - fprintf (dis_file, NTXT ("%8d) %s\n"), index1, item_name); - break; - } - } - if (inp_file !=3D stdin) - return -1; - fprintf (dis_file, GTXT ("Enter selection: ")); - if (fgets (buf, (int) sizeof (buf), inp_file) =3D=3D NULL) - { - fprintf (stderr, GTXT ("Error: Invalid number entered:\n")); - return -1; - } - which =3D (int) getNumber (buf, last); - if (last && *last =3D=3D '\0') - if (which >=3D 0 && which <=3D list->size ()) - return which - 1; - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"), buf); - } -} - -static bool -match_basename (char *name, char *full_name, int len =3D -1) -{ - if (full_name =3D=3D NULL) - return false; - if (!strchr (name, '/')) - full_name =3D get_basename (full_name); - if (len =3D=3D -1) - return streq (name, full_name); - return strncmp (name, full_name, len) =3D=3D 0; -} - -LoadObject * -DbeSession::map_NametoLoadObject (char *name, Vector *list, int= which) -{ - // Search the tree to find the first module whose module name - // matches "name" or whose source file name matches "name" - // Issues: is the name a pathname, or a base name? - // Should we look at suffix to disambiguate? - LoadObject *loitem; - int index; - Vec_loop (LoadObject*, lobjs, index, loitem) - { - // try pathname first - // if failed, try object name next - if (match_basename (name, loitem->get_pathname ()) || - match_basename (name, loitem->get_name ())) - { - if (which =3D=3D list->size ()) - return loitem; - list->append (loitem); - } - } - return (LoadObject *) NULL; -} - -Module * -DbeSession::map_NametoModule (char *name, Vector *list, int whi= ch) -{ - // Search the tree to find the first loadobject whose loadobject name - // matches "name". - - // Issues: is the name a pathname, or a base name? - // Should we look at suffix to disambiguate? - LoadObject *loitem; - Module *mitem; - int index1, index2; - Vec_loop (LoadObject*, lobjs, index1, loitem) - { - Vec_loop (Module*, loitem->seg_modules, index2, mitem) - { - // try source name first - // if failed, try object name next - if (match_basename (name, mitem->file_name) || - match_basename (name, mitem->get_name ())) - { - if (which =3D=3D list->size ()) - return mitem; - list->append (mitem); - } - } - } - return (Module *) NULL; -} - -Function * -DbeSession::map_NametoFunction (char *name, Vector *list, - const char *sel) -{ - // Search the tree to find the first function whose - // name matches "name". - // Issues: is the name a full name, or a short name? - // Is it a demangled name? If so, what about spaces - // within the name? - // Is there a way to return all names that match? - // How can the user specify a particular function of that name? - LoadObject *loitem; - Function *fitem, *main_func =3D NULL; - Module *mitem, *main_mod =3D NULL; - int index1, index2, index3, which =3D -1; - if (sel) - { - char *last =3D NULL; - if (*sel =3D=3D '@') - { // 'sel' is "@seg_num:address" - which =3D (int) getNumber (sel + 1, last); - if (last =3D=3D NULL || *last !=3D ':' || (which < 0) || (which = >=3D lobjs->size ())) - { - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"= ), sel); - return NULL; - } - uint64_t address =3D getNumber (last + 1, last); - if (last =3D=3D NULL || *last !=3D '\0') - { - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"= ), sel); - return NULL; - } - loitem =3D lobjs->fetch (which); - Vec_loop (Module*, loitem->seg_modules, index2, mitem) - { - Vec_loop (Function*, mitem->functions, index3, fitem) - { - if (address =3D=3D fitem->img_offset && match_FName (name, f= item)) - return fitem; - } - } - return NULL; - } - - which =3D (int) getNumber (sel, last); - if (last =3D=3D NULL || *last !=3D '\0') - { - fprintf (stderr, GTXT ("Error: Invalid number entered: %s\n"), s= el); - return NULL; - } - which--; - } - - int len_path =3D 0; - char *with_path =3D name; - name =3D StrRchr (name, '`'); - if (name !=3D with_path) - len_path =3D (int) (name - with_path); - else - with_path =3D NULL; - - Vec_loop (LoadObject*, lobjs, index1, loitem) - { - Vec_loop (Module*, loitem->seg_modules, index2, mitem) - { - if (with_path) - { // with file name - // try source name first - // if failed, try object name next - if (!match_basename (with_path, mitem->file_name, len_path) && - !match_basename (with_path, mitem->get_name (), len_path)) - continue; - } - Vec_loop (Function*, mitem->functions, index3, fitem) - { - if (match_FName (name, fitem)) - { - if (which =3D=3D list->size ()) - return fitem; - list->append (fitem); - continue; - } - if (streq (fitem->get_name (), NTXT ("MAIN_")) && mitem->is_fortra= n ()) - { - main_func =3D fitem; - main_mod =3D mitem; - } - } - } - } - - if (main_mod && main_func) - { - main_mod->read_stabs (); - if (streq (main_func->get_match_name (), name) && which <=3D 1) - return main_func; - } - return (Function *) NULL; -} - -DataObject * -DbeSession::map_NametoDataObject (char *name, Vector *list, - int which) -{ - // Search master list to find dataobjects whose names match "name" - // selecting only the entry corresponding to "which" if it is not -1. - // Issues: is the name fully qualified or only partially? - DataObject *ditem =3D NULL; - int index; - char *full_name; - Vec_loop (DataObject*, dobjs, index, ditem) - { - if (ditem->scope) continue; // skip non-master dataobjects - - // try fully-qualified dataobject name first - if ((full_name =3D ditem->get_name ()) !=3D NULL) - { - if (streq (name, full_name)) - { - if (which =3D=3D list->size ()) - return ditem; - list->append (ditem); - } - } - } - if (list->size () > 0) - return ditem; // return fully-qualified match - - // if fully-qualified name doesn't match anything, try a partial match - Vec_loop (DataObject*, dobjs, index, ditem) - { - if (ditem->scope) continue; // skip non-master dataobjects - - // try fully-qualified dataobject name first - if ((full_name =3D ditem->get_name ()) !=3D NULL) - { - if (strstr (full_name, name)) - { - if (which =3D=3D list->size ()) - return ditem; - list->append (ditem); - } - } - } - return (DataObject *) NULL; -} - -bool -DbeSession::match_FName (char *name, Function *func) -{ - size_t len; - char buf[MAXDBUF]; - char *full_name; - if (streq (func->get_name (), name)) // try full name comparison - return true; - if (streq (func->get_mangled_name (), name)) // try mangled name - return true; - if (streq (func->get_match_name (), name)) // try match name - return true; - - Module *md =3D func->module; // try FORTRAN name - if (md && md->is_fortran ()) - { - char *mangled_name =3D func->get_mangled_name (); - len =3D strlen (name); - if (((len + 1) =3D=3D strlen (mangled_name)) && - (strncmp (name, mangled_name, len) =3D=3D 0)) - return true; - } - snprintf (buf, sizeof (buf), NTXT ("%s"), func->get_name ()); - full_name =3D buf; - char *arg =3D NULL; // find modifier and C++ class name - int i =3D get_paren (buf); - if (i >=3D 0) - { - arg =3D buf + i; - *arg =3D '\0'; - } - - char *mod =3D strchr (full_name, ' '); - char *cls =3D strchr (full_name, ':'); - - if (mod) - { - len =3D mod - full_name + 1; - if (!strncmp (full_name, name, len)) - name +=3D len; - full_name +=3D len; - if (streq (full_name, name)) // try without modifier - return true; - } - - size_t len_cmp =3D strlen (name); - if (arg) - { - *arg =3D '('; - len =3D arg - full_name; // try without 'args' - if (len_cmp =3D=3D len && !strncmp (full_name, name, len)) - return true; - if (cls) - { - len =3D arg - cls - 2; // and without 'class name' - if ((len_cmp =3D=3D len) && !strncmp (cls + 2, name, len)) - return true; - } - } - - if (cls) - { - len =3D cls - full_name; // try C++ class name only - if (len_cmp =3D=3D len && !strncmp (full_name, name, len)) - return true; - if (streq (cls + 2, name)) // try without 'class name' - return true; - } - return false; -} - -bool -DbeSession::add_path (char *path) -{ - return add_path (path, get_search_path ()); -} - -bool -DbeSession::add_classpath (char *path) -{ - return add_path (path, classpath); -} - -Vector * -DbeSession::get_classpath () -{ - if (classpath_df =3D=3D NULL) - classpath_df =3D new Vector; - for (int i =3D classpath_df->size (), sz =3D classpath->size (); i < sz;= i++) - classpath_df->store (i, getDbeFile (classpath->fetch (i), - DbeFile::F_DIR_OR_JAR)); - return classpath_df; -} - -bool -DbeSession::add_path (char *path, Vector *pathes) -{ - bool result =3D false; - Vector *tokens =3D split_str (path, ':'); - for (long j =3D 0, jsz =3D VecSize (tokens); j < jsz; j++) - { - char *spath =3D tokens->get (j); - // Don't append path if it's already there - bool got =3D false; - for (int i =3D 0, sz =3D pathes->size (); i < sz; i++) - { - char *nm =3D pathes->get (i); - if (streq (nm, spath)) - { - got =3D true; - break; - } - } - if (!got) - { - pathes->append (spath); - result =3D true; - } - else - free (spath); - } - delete tokens; - return result; -} - -void -DbeSession::set_need_refind () -{ - Vector *f_list =3D dbeFiles->values (); - for (long i =3D 0, sz =3D f_list =3D=3D NULL ? 0 : f_list->size (); i < = sz; i++) - { - DbeFile *f =3D f_list->get (i); - f->set_need_refind (true); - } - delete f_list; - for (long i =3D 0, sz =3D sources =3D=3D NULL ? 0 : sources->size (); i = < sz; i++) - { - SourceFile *f =3D sources->get (i); - if (f && f->dbeFile) - f->dbeFile->set_need_refind (true); - } -} - -void -DbeSession::set_search_path (Vector *path, bool reset) -{ - if (reset) - search_path->destroy (); - for (int i =3D 0, sz =3D path =3D=3D NULL ? 0 : path->size (); i < sz; i= ++) - { - char *name =3D path->fetch (i); - if (add_path (name)) - reset =3D true; - } - if (reset) - { - set_need_refind (); - - // now reset the string setting for it - StringBuilder sb; - for (int i =3D 0, sz =3D search_path =3D=3D NULL ? 0 : search_path->= size (); i < sz; i++) - { - char *name =3D search_path->fetch (i); - if (sb.length () !=3D 0) - sb.append (':'); - sb.append (name); - } - free (settings->str_search_path); - settings->str_search_path =3D sb.toString (); - } -} - -void -DbeSession::set_search_path (char *_lpath, bool reset) -{ - Vector *path =3D new Vector; - char *lpath =3D dbe_strdup (_lpath); - for (char *s =3D lpath; s;) - { - path->append (s); - s =3D strchr (s, ':'); - if (s) - { - *s =3D 0; - s++; - } - } - set_search_path (path, reset); - delete path; - free (lpath); -} - -void -DbeSession::set_pathmaps (Vector *newPathMap) -{ - set_need_refind (); - settings->set_pathmaps (newPathMap); -} - -Vector * -DbeSession::get_pathmaps () -{ - return settings->pathmaps; -} - -void -DbeSession::mobj_define (MemObjType_t *mobj) -{ - settings->mobj_define (mobj, false); - DbeView *dbev; - int index; - Vec_loop (DbeView*, views, index, dbev) - { - dbev->get_settings ()->mobj_define (mobj, false); - } -} - -void -DbeSession::dump_segments (FILE *out) -{ - int index; - LoadObject *loitem; - Vec_loop (LoadObject*, lobjs, index, loitem) - { - fprintf (out, NTXT ("Segment %d -- %s -- %s\n\n"), - index, loitem->get_name (), loitem->get_pathname ()); - loitem->dump_functions (out); - fprintf (out, NTXT ("\n End Segment %d -- %s -- %s\n\n"), - index, loitem->get_name (), loitem->get_pathname ()); - } -} - -void -DbeSession::dump_dataobjects (FILE *out) -{ - DataObject *ditem; - int index; - - fprintf (out, NTXT ("\nMaster list of DataObjects:\n")); - Vec_loop (DataObject*, dobjs, index, ditem) - { - Histable* scope =3D ditem->get_scope (); - DataObject* parent =3D ditem->get_parent (); - DataObject* master =3D ditem->get_master (); - if (parent !=3D NULL) - fprintf (out, "id %6lld: [%4lld] parent =3D %6lld, offset =3D %+4lld= %s\n", - (ll_t) ditem->id, (ll_t) ditem->get_size (), - (ll_t) parent->id, (ll_t) ditem->get_offset (), - ditem->get_name ()); - else - { - // parent is NULL - fprintf (out, NTXT ("id %6lld: [%4lld] %s "), - (ll_t) ditem->id, (ll_t) ditem->get_size (), - ditem->get_name ()); - if (master !=3D NULL) - fprintf (out, NTXT (" master=3D%lld "), (ll_t) master->id); - else if (scope !=3D NULL) - fprintf (out, NTXT (" master=3D?? ")); - else - fprintf (out, NTXT (" MASTER ")); -#if DEBUG - if (scope !=3D NULL) - { - switch (scope->get_type ()) - { - case Histable::LOADOBJECT: - case Histable::FUNCTION: - fprintf (out, NTXT ("%s"), scope->get_name ()); - break; - case Histable::MODULE: - { - char *filename =3D get_basename (scope->get_name ()); - fprintf (out, NTXT ("%s"), filename); - break; - } - default: - fprintf (out, NTXT (" Unexpected scope %d:%s"), - scope->get_type (), scope->get_name ()); - } - } -#endif - fprintf (out, NTXT ("\n")); - } - } -} - -void -DbeSession::dump_map (FILE *out) -{ - Experiment *exp; - int index; - Vec_loop (Experiment*, exps, index, exp) - { - exp->dump_map (out); - } -} - -void -DbeSession::dump_stacks (FILE *outfile) -{ - Experiment *exp; - int n =3D nexps (); - FILE *f =3D (outfile =3D=3D NULL ? stderr : outfile); - for (int i =3D 0; i < n; i++) - { - exp =3D get_exp (i); - fprintf (f, GTXT ("Experiment %d -- %s\n"), i, exp->get_expt_name ()= ); - exp->dump_stacks (f); - } -} - -void -DbeSession::propNames_name_store (int propId, const char *propName) -{ - PropDescr *prop =3D new PropDescr (propId, propName); - prop->flags =3D PRFLAG_NOSHOW; // do not show descriptions - propNames->store (propId, prop); -} - -void -DbeSession::propNames_name_store (int propId, const char* propName, - const char* propUname, VType_type dataTy= pe, - int flags) -{ - PropDescr *prop =3D new PropDescr (propId, propName); - prop->vtype =3D dataType; - prop->uname =3D dbe_strdup (propUname); - prop->flags =3D flags; - propNames->store (propId, prop); -} - -char * -DbeSession::propNames_name_fetch (int i) -{ - PropDescr *prop =3D propNames->fetch (i); - if (prop) - return prop->name; - return NULL; -} - -int -DbeSession::registerPropertyName (const char *name) -{ - if (name =3D=3D NULL) - return PROP_NONE; - for (int i =3D 0; i < propNames->size (); i++) - { - char *pname =3D propNames_name_fetch (i); - if (pname && strcasecmp (pname, name) =3D=3D 0) - return i; - } - int propId =3D propNames->size (); - propNames_name_store (propId, name); - return propId; -} - -int -DbeSession::getPropIdByName (const char *name) -{ - if (name =3D=3D NULL) - return PROP_NONE; - for (int i =3D 0; i < propNames->size (); i++) - { - char *pname =3D propNames_name_fetch (i); - if (pname && strcasecmp (pname, name) =3D=3D 0) - return i; - } - return PROP_NONE; -} - -char * -DbeSession::getPropName (int propId) -{ - if (!propNames) - return NULL; - if (propId < 0 || propId >=3D propNames->size ()) - return NULL; - return dbe_strdup (propNames_name_fetch (propId)); -} - -char * -DbeSession::getPropUName (int propId) -{ - if (!propNames) - return NULL; - if (propId < 0 || propId >=3D propNames->size ()) - return NULL; - PropDescr *prop =3D propNames->fetch (propId); - if (prop) - return dbe_strdup (prop->uname); - return NULL; -} - -void -DbeSession::append (UserLabel *lbl) -{ - if (lbl->expr) - { - if (userLabels =3D=3D NULL) - userLabels =3D new Vector (); - userLabels->append (lbl); - } -} - -void -DbeSession::append (SourceFile *sf) -{ - sources->append (sf); - objs->append (sf); -} - -UserLabel * -DbeSession::findUserLabel (char *name) -{ - for (int i =3D 0, sz =3D userLabels ? userLabels->size () : 0; i < sz; i= ++) - { - UserLabel *lbl =3D userLabels->fetch (i); - if (strcasecmp (lbl->name, name) =3D=3D 0) - return lbl; - } - return NULL; -} - -Expression * -DbeSession::findObjDefByName (char *name) -{ - Expression *expr =3D NULL; - - MemObjType_t *mot =3D MemorySpace::findMemSpaceByName (name); - if (mot !=3D NULL) - { - char *index_expr_str =3D mot->index_expr; - expr =3D ql_parse (index_expr_str); - } - - if (expr =3D=3D NULL) - { - int indxtype =3D findIndexSpaceByName (name); - expr =3D getIndexSpaceExpr (indxtype); - } - if (expr =3D=3D NULL) - { - UserLabel *ulbl =3D findUserLabel (name); - if (ulbl) - expr =3D ulbl->expr; - } - return expr; -} - -Expression * -DbeSession::ql_parse (const char *expr_spec) -{ - /* (This slight duplication means we don't need to worry about copy - constructors for the QL::Result, nor about the lifetime of the - expr_spec.) */ - if (expr_spec !=3D NULL) - { - QL::Result result (expr_spec); - QL::Parser qlparser (result); - if (qlparser () !=3D 0) - return NULL; - return result (); - } - else - { - QL::Result result; - QL::Parser qlparser (result); - if (qlparser () !=3D 0) - return NULL; - return result (); - } -} - -Vector * -DbeSession::getIndxObjDescriptions () -{ - int size =3D dyn_indxobj_indx; - if (size =3D=3D 0) - return NULL; - Vector *type =3D new Vector(dyn_indxobj_indx); - Vector *desc =3D new Vector(dyn_indxobj_indx); - Vector *i18ndesc =3D new Vector(dyn_indxobj_indx); - Vector *mnemonic =3D new Vector(dyn_indxobj_indx); - Vector *orderList =3D new Vector(dyn_indxobj_indx); - Vector *exprList =3D new Vector(dyn_indxobj_indx); - Vector *sdesc =3D new Vector(dyn_indxobj_indx); - Vector *ldesc =3D new Vector(dyn_indxobj_indx); - - for (long i =3D 0, sz =3D VecSize (dyn_indxobj); i < sz; i++) - { - IndexObjType_t *tot =3D dyn_indxobj->get (i); - if (tot->memObj =3D=3D NULL) - { - type->append ((int) tot->type); - desc->append (dbe_strdup (tot->name)); - i18ndesc->append (dbe_strdup (tot->i18n_name)); - sdesc->append (dbe_strdup (tot->short_description)); - ldesc->append (dbe_strdup (tot->long_description)); - mnemonic->append (tot->mnemonic); - orderList->append (settings->indx_tab_order->fetch (i)); - exprList->append (dbe_strdup (tot->index_expr_str)); - } - } - Vector *res =3D new Vector(8); - res->store (0, type); - res->store (1, desc); - res->store (2, mnemonic); - res->store (3, i18ndesc); - res->store (4, orderList); - res->store (5, exprList); - res->store (6, sdesc); - res->store (7, ldesc); - return (res); -} - -// Static function to get a vector of custom index object definitions -Vector * -DbeSession::getCustomIndxObjects () -{ - Vector *name =3D new Vector; - Vector *formula =3D new Vector; - for (long i =3D dyn_indxobj_indx_fixed, sz =3D VecSize (dyn_indxobj); i = < sz; i++) - { - IndexObjType_t *tot =3D dyn_indxobj->get (i); - if (tot->memObj =3D=3D NULL) - { - name->append (dbe_strdup (tot->name)); - formula->append (dbe_strdup (tot->index_expr_str)); - } - } - Vector *res =3D new Vector(2); - res->store (0, name); - res->store (1, formula); - return (res); -} - -// Static function to define a new index object type -char * -DbeSession::indxobj_define (const char *mname, char *i18nname, const char = *index_expr_str, char *short_description, char *long_description) -{ - if (mname =3D=3D NULL) - return dbe_strdup (GTXT ("No index object type name has been specified= .")); - if (isalpha ((int) (mname[0])) =3D=3D 0) - return dbe_sprintf (GTXT ("Index Object type name %s does not begin wi= th an alphabetic character"), - mname); - const char *p =3D mname; - while (*p !=3D 0) - { - if ((isalnum ((int) (*p)) =3D=3D 0) && (*p !=3D '_')) - return dbe_sprintf (GTXT ("Index Object type name %s contains a no= n-alphanumeric character"), - mname); - p++; - } - - // make sure the name is not in use - if (MemorySpace::findMemSpaceByName (mname) !=3D NULL) - return dbe_sprintf (GTXT ("Memory/Index Object type name %s is already= defined"), - mname); - - int idxx =3D findIndexSpaceByName (mname); - if (idxx >=3D 0) - { - IndexObjType_t *mt =3D dyn_indxobj->fetch (idxx); - if (strcmp (mt->index_expr_str, index_expr_str) =3D=3D 0) - // It's a redefinition, but the new definition is the same - return NULL; - return dbe_sprintf (GTXT ("Memory/Index Object type name %s is alrea= dy defined"), - mname); - } - if (index_expr_str =3D=3D NULL) - return dbe_strdup (GTXT ("No index-expr has been specified.")); - if (strlen (index_expr_str) =3D=3D 0) - return dbe_sprintf (GTXT ("Index Object index expression is invalid: %= s"), - index_expr_str); - - // verify that the index expression parses correctly - char *expr_str =3D dbe_strdup (index_expr_str); - Expression *expr =3D ql_parse (expr_str); - if (expr =3D=3D NULL) - return dbe_sprintf (GTXT ("Index Object index expression is invalid: %= s"), - expr_str); - - // It's OK, create the new table entry - IndexObjType_t *tot =3D new IndexObjType_t; - tot->type =3D dyn_indxobj_indx++; - tot->name =3D dbe_strdup (mname); - tot->i18n_name =3D dbe_strdup (i18nname); - tot->short_description =3D dbe_strdup (short_description); - tot->long_description =3D dbe_strdup (long_description); - tot->index_expr_str =3D expr_str; - tot->index_expr =3D expr; - tot->mnemonic =3D mname[0]; - - // add it to the list - dyn_indxobj->append (tot); - idxobjs->append (new HashMap); - - // tell the session - settings->indxobj_define (tot->type, false); - - DbeView *dbev; - int index; - Vec_loop (DbeView*, views, index, dbev) - { - dbev->addIndexSpace (tot->type); - } - return NULL; -} - -char * -DbeSession::getIndexSpaceName (int index) -{ - if (index < 0 || index >=3D dyn_indxobj->size ()) - return NULL; - return dyn_indxobj->fetch (index)->name; -} - -char * -DbeSession::getIndexSpaceDescr (int index) -{ - if (index < 0 || index >=3D dyn_indxobj->size ()) - return NULL; - return dyn_indxobj->fetch (index)->i18n_name; -} - -Expression * -DbeSession::getIndexSpaceExpr (int index) -{ - if (index < 0 || index >=3D dyn_indxobj->size ()) - return NULL; - return dyn_indxobj->fetch (index)->index_expr; -} - -char * -DbeSession::getIndexSpaceExprStr (int index) -{ - if (index < 0 || index >=3D dyn_indxobj->size ()) - return NULL; - return dyn_indxobj->fetch (index)->index_expr_str; -} - -int -DbeSession::findIndexSpaceByName (const char *mname) -{ - int idx; - IndexObjType_t *mt; - Vec_loop (IndexObjType_t*, dyn_indxobj, idx, mt) - { - if (strcasecmp (mt->name, mname) =3D=3D 0) - return idx; - } - return -1; -} - -void -DbeSession::removeIndexSpaceByName (const char *mname) -{ - IndexObjType_t *indObj =3D findIndexSpace (mname); - if (indObj) - indObj->name[0] =3D 0; -} - -IndexObjType_t * -DbeSession::getIndexSpace (int index) -{ - return ((index < 0) || (index >=3D VecSize (dyn_indxobj))) ? NULL : dyn_= indxobj->get (index); -} - -IndexObjType_t * -DbeSession::findIndexSpace (const char *mname) -{ - return getIndexSpace (findIndexSpaceByName (mname)); -} - -void -DbeSession::get_filter_keywords (Vector *res) -{ - Vector *kwCategory =3D (Vector*) res->fetch (0); - Vector *kwCategoryI18N =3D (Vector*) res->fetch (1); - Vector *kwDataType =3D (Vector*) res->fetch (2); - Vector *kwKeyword =3D (Vector*) res->fetch (3); - Vector *kwFormula =3D (Vector*) res->fetch (4); - Vector *kwDescription =3D (Vector*) res->fetch (5); - Vector *kwEnumDescs =3D (Vector*) res->fetch (6); - - char *vtypeNames[] =3D VTYPE_TYPE_NAMES; - for (long i =3D 0, sz =3D userLabels ? userLabels->size () : 0; i < sz; = i++) - { - UserLabel *lbl =3D userLabels->fetch (i); - kwCategory->append (dbe_strdup (NTXT ("FK_LABEL"))); - kwCategoryI18N->append (dbe_strdup (GTXT ("Labels"))); - kwDataType->append (dbe_strdup (vtypeNames[TYPE_BOOL])); - kwKeyword->append (dbe_strdup (lbl->name)); - kwFormula->append (dbe_strdup (lbl->str_expr)); - kwDescription->append (dbe_strdup (lbl->comment)); - kwEnumDescs->append (NULL); - } - - for (long i =3D 0, sz =3D propNames ? propNames->size () : 0; i < sz; i+= +) - { - PropDescr *prop =3D propNames->fetch (i); - char *pname =3D prop ? prop->name : NULL; - if (pname =3D=3D NULL || *pname =3D=3D 0 || prop->flags & PRFLAG_NOS= HOW) - continue; - int vtypeNum =3D prop->vtype; - if (vtypeNum < 0 || vtypeNum >=3D TYPE_LAST) - vtypeNum =3D TYPE_NONE; - kwCategory->append (dbe_strdup (NTXT ("FK_EVTPROP"))); //Event Prope= rty - kwCategoryI18N->append (dbe_strdup (GTXT ("Misc. Definitions"))); - kwDataType->append (dbe_strdup (vtypeNames[vtypeNum])); - kwKeyword->append (dbe_strdup (pname)); - kwFormula->append (NULL); - kwDescription->append (dbe_strdup (prop->uname)); - kwEnumDescs->append (NULL); - } - - for (long i =3D 0, sz =3D dyn_indxobj ? dyn_indxobj->size () : 0; i < sz= ; i++) - { - IndexObjType_t *obj =3D dyn_indxobj->get (i); - if (obj->memObj) - continue; - kwCategory->append (dbe_strdup (NTXT ("FK_IDXOBJ"))); - kwCategoryI18N->append (dbe_strdup (GTXT ("Index Object Definitions"= ))); - kwDataType->append (dbe_strdup (vtypeNames[TYPE_INT64])); - kwKeyword->append (dbe_strdup (obj->name)); - kwFormula->append (dbe_strdup (obj->index_expr_str)); - kwDescription->append (dbe_strdup (obj->i18n_name)); - kwEnumDescs->append (NULL); - } -} - -Histable * -DbeSession::findIndexObject (int idxtype, uint64_t idx) -{ - HashMap *iobjs =3D idxobjs->fetch (idxtype); - return iobjs->get (idx); -} - -Histable * -DbeSession::createIndexObject (int idxtype, int64_t idx) -{ - HashMap *iobjs =3D idxobjs->fetch (idxtype); - - Histable *idxobj =3D iobjs->get (idx); - if (idxobj =3D=3D NULL) - { - idxobj =3D new IndexObject (idxtype, idx); - if (idx =3D=3D -1) - idxobj->set_name (dbe_strdup (GTXT (""))); - iobjs->put (idx, idxobj); - } - - return idxobj; -} - -Histable * -DbeSession::createIndexObject (int idxtype, Histable *hobj) -{ - HashMap *iobjs =3D idxobjs->fetch (idxtype); - int64_t idx =3D hobj ? hobj->id : -1; - Histable *idxobj =3D iobjs->get (idx); - if (idxobj =3D=3D NULL) - { - idxobj =3D new IndexObject (idxtype, hobj); - if (idx =3D=3D -1) - idxobj->set_name (dbe_strdup (GTXT (""))); - iobjs->put (idx, idxobj); - } - - return idxobj; -} - -Histable * -DbeSession::findObjectById (Histable::Type type, int subtype, uint64_t id) -{ - switch (type) - { - case Histable::FUNCTION: - case Histable::MODULE: - case Histable::LOADOBJECT: - return ( id < (uint64_t) objs->size ()) ? objs->fetch ((int) id) : N= ULL; - case Histable::INDEXOBJ: - return findIndexObject (subtype, id); - // ignoring the following cases - case Histable::INSTR: - case Histable::LINE: - case Histable::EADDR: - case Histable::MEMOBJ: - case Histable::PAGE: - case Histable::DOBJECT: - case Histable::SOURCEFILE: - case Histable::IOACTFILE: - case Histable::IOACTVFD: - case Histable::IOCALLSTACK: - case Histable::HEAPCALLSTACK: - case Histable::OTHER: - case Histable::EXPERIMENT: - break; - } - return NULL; -} - -// return a vector of Functions that match the regular expression input st= ring -Vector * -DbeSession::match_java_threads (char *ustr, int matchParent, - Vector * &grids, - Vector * &expids) -{ - if (ustr =3D=3D NULL) - return NULL; - - char *str =3D dbe_sprintf (NTXT ("^%s$"), ustr); - regex_t regex_desc; - int rc =3D regcomp (®ex_desc, str, REG_EXTENDED | REG_NOSUB | REG_NEW= LINE); - free (str); - if (rc) // syntax error in parsing string - return NULL; - - // allocate the new vector - Vector *ret =3D new Vector; - grids =3D new Vector; - expids =3D new Vector; - - int index; - JThread *jthread; - int expid; - Experiment* exp; - Vec_loop (Experiment*, exps, expid, exp) - { - - Vec_loop (JThread*, exp->get_jthreads (), index, jthread) - { - const char * name; - if (matchParent) - name =3D jthread->parent_name; - else - name =3D jthread->group_name; - if (name =3D=3D NULL) - name =3D ""; - if (!regexec (®ex_desc, name, 0, NULL, 0)) - { - // this one matches - ret->append (jthread); - grids->append (exp->groupId); - expids->append (exp->getUserExpId ()); - } - } - } - - regfree (®ex_desc); - return ret; -} - -// return a vector of Functions that match the regular expression input st= ring -Vector * -DbeSession::match_func_names (const char *ustr, Histable::NameFormat nfmt) -{ - if (ustr =3D=3D NULL) - return NULL; - char *str =3D dbe_sprintf (NTXT ("^%s$"), ustr); - regex_t regex_desc; - int rc =3D regcomp (®ex_desc, str, REG_EXTENDED | REG_NOSUB | REG_NEW= LINE); - free (str); - if (rc) // syntax error in parsing string - return NULL; - - // allocate the new vector - Vector *ret =3D new Vector; - - int index; - Histable *obj; - Vec_loop (Histable*, objs, index, obj) - { - if (obj->get_type () =3D=3D Histable::FUNCTION) - { - Function *func =3D (Function*) obj; - if (!regexec (®ex_desc, func->get_name (nfmt), 0, NULL, 0)) - // this one matches - ret->append (func); - } - } - regfree (®ex_desc); - return ret; -} - -// return a vector of Functions that match the regular expression input st= ring -Vector * -DbeSession::match_file_names (char *ustr, Histable::NameFormat nfmt) -{ - if (ustr =3D=3D NULL) - return NULL; - char *str =3D dbe_sprintf (NTXT ("^%s$"), ustr); - regex_t regex_desc; - int rc =3D regcomp (®ex_desc, str, REG_EXTENDED | REG_NOSUB | REG_NEW= LINE); - free (str); - if (rc) // syn[...] [diff truncated at 100000 bytes]