/* Copyright (C) 2021-2026 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 <ctype.h>#include <stdio.h>#include <dirent.h>#include <unistd.h>#include <sys/types.h>#include <errno.h>#include <sys/param.h> #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" // Bison 3.0 doesn't define YY_NULLPTR. I copied this from QLParser.tab.cc.// Why this is not in QLParser.tab.hh ? YY_NULLPTR is used in QLParser.tab.hh# ifndef YY_NULLPTR# if defined __cplusplus && 201103L <= __cplusplus# define YY_NULLPTR nullptr# else# define YY_NULLPTR 0# endif# endif#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 = _item; ref_count = 0; } void *item; int ref_count;}; Platform_t DbeSession::platform =#if ARCH(SPARC) Sparc;#elif ARCH(Aarch64) Aarch64;#elif ARCH(RISCV) RISCV;#else // ARCH(Intel) Intel;#endif // This constant determines the size of the data object name hash table.static const int HTableSize = 8192;static int DEFAULT_TINY_THRESHOLD = -1; unsigned int mpmt_debug_opt = 0;DbeSession *dbeSession = NULL; DbeSession::DbeSession (Settings *_settings, bool _ipc_mode, bool _rdt_mode){ dbeSession = this; ipc_mode = _ipc_mode; rdt_mode = _rdt_mode; settings = new Settings (_settings); views = new Vector<DbeView*>; exps = new Vector<Experiment*>; lobjs = new Vector<LoadObject*>; objs = new Vector<Histable*>; dobjs = new Vector<DataObject*>; metrics = new Vector<Countable*>; reg_metrics = new Vector<BaseMetric*>; hwcentries = NULL; reg_metrics_tree = NULL; // BaseMetric() requires DbeSession::ql_parse idxobjs = new Vector<HashMap<uint64_t, Histable*>*>; tmp_files = new Vector<char*>; search_path = new Vector<char*>; classpath = new Vector<char*>; classpath_df = NULL; expGroups = new Vector<ExpGroup*>; sourcesMap = new HashMap<char*, SourceFile*>; sources = new Vector<SourceFile*>; comp_lobjs = new HashMap<char*, LoadObject*>; comp_dbelines = new HashMap<char*, DbeLine*>; comp_sources = new HashMap<char*, SourceFile*>; loadObjMap = new DbeSyncMap<LoadObject>; f_special = new Vector<Function*>(LastSpecialFunction); omp_functions = new Vector<Function*>(OMP_LAST_STATE); interactive = false; lib_visibility_used = false; // Define all known property names propNames = new Vector<PropDescr*>; 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_UINT64, 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 = GTXT ("(unknown)"); // define Index objects dyn_indxobj = new Vector<IndexObjType_t*>(); dyn_indxobj_indx = 0; char *s = dbe_sprintf (NTXT ("((EXPID_CMP<<%llu) | THRID)"), (unsigned long long) IndexObject::INDXOBJ_EXPID_SHIFT); indxobj_define (NTXT ("Threads"), GTXT ("Threads"), s, NULL, NULL); free (s); indxobj_define (NTXT ("CPUs"), GTXT ("CPUs"), NTXT ("(CPUID)"), NULL, NULL); indxobj_define (NTXT ("Samples"), GTXT ("Samples"), NTXT ("(SAMPLE_MAP)"), NULL, NULL); indxobj_define (NTXT ("GCEvents"), GTXT ("GCEvents"), NTXT ("(GCEVENT_MAP)"), NULL, NULL); indxobj_define (NTXT ("Seconds"), GTXT ("Seconds"), NTXT ("(TSTAMP/1000000000)"), NULL, NULL); indxobj_define (NTXT ("Processes"), GTXT ("Processes"), NTXT ("(EXPID_CMP)"), NULL, NULL); s = 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, NULL, NULL); free (s); indxobj_define (NTXT ("Datasize"), GTXT ("Datasize"), "(IOHEAPBYTES==0?0:" "((IOHEAPBYTES<=(1<<0)?(1<<0):" "((IOHEAPBYTES<=(1<<2)?(1<<2):" "((IOHEAPBYTES<=(1<<4)?(1<<4):" "((IOHEAPBYTES<=(1<<6)?(1<<6):" "((IOHEAPBYTES<=(1<<8)?(1<<8):" "((IOHEAPBYTES<=(1<<10)?(1<<10):" "((IOHEAPBYTES<=(1<<12)?(1<<12):" "((IOHEAPBYTES<=(1<<14)?(1<<14):" "((IOHEAPBYTES<=(1<<16)?(1<<16):" "((IOHEAPBYTES<=(1<<18)?(1<<18):" "((IOHEAPBYTES<=(1<<20)?(1<<20):" "((IOHEAPBYTES<=(1<<22)?(1<<22):" "((IOHEAPBYTES<=(1<<24)?(1<<24):" "((IOHEAPBYTES<=(1<<26)?(1<<26):" "((IOHEAPBYTES<=(1<<28)?(1<<28):" "((IOHEAPBYTES<=(1<<30)?(1<<30):" "((IOHEAPBYTES<=(1<<32)?(1<<32):" "((IOHEAPBYTES<=(1<<34)?(1<<34):" "((IOHEAPBYTES<=(1<<36)?(1<<36):" "((IOHEAPBYTES<=(1<<38)?(1<<38):" "((IOHEAPBYTES<=(1<<40)?(1<<40):" "((IOHEAPBYTES<=(1<<42)?(1<<42):" "((IOHEAPBYTES<=(1<<44)?(1<<44):" "((IOHEAPBYTES<=(1<<46)?(1<<46):" "((IOHEAPBYTES<=(1<<48)?(1<<48):" "((IOHEAPBYTES<=(1<<50)?(1<<50):" "(IOHEAPBYTES==-1?-1:(1<<50|1)" "))))))))))))))))))))))))))))))))))))))))))))))))))))))", NULL, NULL); indxobj_define (NTXT ("Duration"), GTXT ("Duration"), "((TSTAMP_HI-TSTAMP_LO)==0?0:" "(((TSTAMP_HI-TSTAMP_LO)<=1000?1000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000?10000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000?100000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000?1000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000?10000000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000000?100000000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000000?1000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000000?10000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000000000?100000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000000000?1000000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000000000?10000000000000:" "(10000000000001))))))))))))))))))))))))", NULL, NULL); dyn_indxobj_indx_fixed = dyn_indxobj_indx; Elf::elf_init (); defExpName = NULL; mach_model_loaded = NULL; tmp_dir_name = 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 = 0, sz = hwcentries->size (); i < sz; i++) { Hwcentry *h = hwcentries->get (i); free (h->int_name); free (h->name); delete h; } delete hwcentries; } if (idxobjs) { for (int i = 0; i < idxobjs->size (); ++i) { HashMap<uint64_t, Histable*> *hMap = idxobjs->get (i); if (hMap) { hMap->values ()->destroy (); delete hMap; } } delete idxobjs; } for (int i = 0; i < HTableSize; i++) { List *list = dnameHTable[i]; while (list) { List *tmp = list; list = 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 != NULL) { StringBuilder *sb = new StringBuilder (); sb->append (NTXT ("/bin/rm -rf ")); sb->append (defExpName); char *cmd = sb->toString (); system (cmd); free (cmd); delete sb; free (defExpName); } unlink_tmp_files (); delete tmp_files; dbeSession = NULL;} voidDbeSession::unlink_tmp_files (){ if (tmp_files) { for (int i = 0, sz = tmp_files->size (); i < sz; i++) unlink (tmp_files->fetch (i)); tmp_files->destroy (); delete tmp_files; tmp_files = NULL; } if (tmp_dir_name) { char *cmd = dbe_sprintf (NTXT ("/bin/rm -rf %s"), tmp_dir_name); system (cmd); free (cmd); free (tmp_dir_name); tmp_dir_name = NULL; }} char *DbeSession::get_tmp_file_name (const char *nm, bool for_java){ if (tmp_dir_name == NULL) { tmp_dir_name = dbe_sprintf (NTXT ("/tmp/analyzer.%llu.%lld"), (unsigned long long) getuid (), (long long) getpid ()); mkdir (tmp_dir_name, S_IRWXU); } char *fnm = dbe_sprintf (NTXT ("%s/%s"), tmp_dir_name, nm); if (for_java) for (char *s = fnm + strlen (tmp_dir_name) + 1; *s; s++) if (*s == '/')Lines 1–500 of 3535. Load more
/* Copyright (C) 2021-2026 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 <ctype.h> #include <stdio.h> #include <dirent.h> #include <unistd.h> #include <sys/types.h> #include <errno.h> #include <sys/param.h> #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" // Bison 3.0 doesn't define YY_NULLPTR. I copied this from QLParser.tab.cc. // Why this is not in QLParser.tab.hh ? YY_NULLPTR is used in QLParser.tab.hh # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif #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 = _item; ref_count = 0; } void *item; int ref_count; }; Platform_t DbeSession::platform = #if ARCH(SPARC) Sparc; #elif ARCH(Aarch64) Aarch64; #elif ARCH(RISCV) RISCV; #else // ARCH(Intel) Intel; #endif // This constant determines the size of the data object name hash table. static const int HTableSize = 8192; static int DEFAULT_TINY_THRESHOLD = -1; unsigned int mpmt_debug_opt = 0; DbeSession *dbeSession = NULL; DbeSession::DbeSession (Settings *_settings, bool _ipc_mode, bool _rdt_mode) { dbeSession = this; ipc_mode = _ipc_mode; rdt_mode = _rdt_mode; settings = new Settings (_settings); views = new Vector<DbeView*>; exps = new Vector<Experiment*>; lobjs = new Vector<LoadObject*>; objs = new Vector<Histable*>; dobjs = new Vector<DataObject*>; metrics = new Vector<Countable*>; reg_metrics = new Vector<BaseMetric*>; hwcentries = NULL; reg_metrics_tree = NULL; // BaseMetric() requires DbeSession::ql_parse idxobjs = new Vector<HashMap<uint64_t, Histable*>*>; tmp_files = new Vector<char*>; search_path = new Vector<char*>; classpath = new Vector<char*>; classpath_df = NULL; expGroups = new Vector<ExpGroup*>; sourcesMap = new HashMap<char*, SourceFile*>; sources = new Vector<SourceFile*>; comp_lobjs = new HashMap<char*, LoadObject*>; comp_dbelines = new HashMap<char*, DbeLine*>; comp_sources = new HashMap<char*, SourceFile*>; loadObjMap = new DbeSyncMap<LoadObject>; f_special = new Vector<Function*>(LastSpecialFunction); omp_functions = new Vector<Function*>(OMP_LAST_STATE); interactive = false; lib_visibility_used = false; // Define all known property names propNames = new Vector<PropDescr*>; 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_UINT64, 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 = GTXT ("(unknown)"); // define Index objects dyn_indxobj = new Vector<IndexObjType_t*>(); dyn_indxobj_indx = 0; char *s = dbe_sprintf (NTXT ("((EXPID_CMP<<%llu) | THRID)"), (unsigned long long) IndexObject::INDXOBJ_EXPID_SHIFT); indxobj_define (NTXT ("Threads"), GTXT ("Threads"), s, NULL, NULL); free (s); indxobj_define (NTXT ("CPUs"), GTXT ("CPUs"), NTXT ("(CPUID)"), NULL, NULL); indxobj_define (NTXT ("Samples"), GTXT ("Samples"), NTXT ("(SAMPLE_MAP)"), NULL, NULL); indxobj_define (NTXT ("GCEvents"), GTXT ("GCEvents"), NTXT ("(GCEVENT_MAP)"), NULL, NULL); indxobj_define (NTXT ("Seconds"), GTXT ("Seconds"), NTXT ("(TSTAMP/1000000000)"), NULL, NULL); indxobj_define (NTXT ("Processes"), GTXT ("Processes"), NTXT ("(EXPID_CMP)"), NULL, NULL); s = 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, NULL, NULL); free (s); indxobj_define (NTXT ("Datasize"), GTXT ("Datasize"), "(IOHEAPBYTES==0?0:" "((IOHEAPBYTES<=(1<<0)?(1<<0):" "((IOHEAPBYTES<=(1<<2)?(1<<2):" "((IOHEAPBYTES<=(1<<4)?(1<<4):" "((IOHEAPBYTES<=(1<<6)?(1<<6):" "((IOHEAPBYTES<=(1<<8)?(1<<8):" "((IOHEAPBYTES<=(1<<10)?(1<<10):" "((IOHEAPBYTES<=(1<<12)?(1<<12):" "((IOHEAPBYTES<=(1<<14)?(1<<14):" "((IOHEAPBYTES<=(1<<16)?(1<<16):" "((IOHEAPBYTES<=(1<<18)?(1<<18):" "((IOHEAPBYTES<=(1<<20)?(1<<20):" "((IOHEAPBYTES<=(1<<22)?(1<<22):" "((IOHEAPBYTES<=(1<<24)?(1<<24):" "((IOHEAPBYTES<=(1<<26)?(1<<26):" "((IOHEAPBYTES<=(1<<28)?(1<<28):" "((IOHEAPBYTES<=(1<<30)?(1<<30):" "((IOHEAPBYTES<=(1<<32)?(1<<32):" "((IOHEAPBYTES<=(1<<34)?(1<<34):" "((IOHEAPBYTES<=(1<<36)?(1<<36):" "((IOHEAPBYTES<=(1<<38)?(1<<38):" "((IOHEAPBYTES<=(1<<40)?(1<<40):" "((IOHEAPBYTES<=(1<<42)?(1<<42):" "((IOHEAPBYTES<=(1<<44)?(1<<44):" "((IOHEAPBYTES<=(1<<46)?(1<<46):" "((IOHEAPBYTES<=(1<<48)?(1<<48):" "((IOHEAPBYTES<=(1<<50)?(1<<50):" "(IOHEAPBYTES==-1?-1:(1<<50|1)" "))))))))))))))))))))))))))))))))))))))))))))))))))))))", NULL, NULL); indxobj_define (NTXT ("Duration"), GTXT ("Duration"), "((TSTAMP_HI-TSTAMP_LO)==0?0:" "(((TSTAMP_HI-TSTAMP_LO)<=1000?1000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000?10000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000?100000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000?1000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000?10000000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000000?100000000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000000?1000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000000?10000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=100000000000?100000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=1000000000000?1000000000000:" "(((TSTAMP_HI-TSTAMP_LO)<=10000000000000?10000000000000:" "(10000000000001))))))))))))))))))))))))", NULL, NULL); dyn_indxobj_indx_fixed = dyn_indxobj_indx; Elf::elf_init (); defExpName = NULL; mach_model_loaded = NULL; tmp_dir_name = 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 = 0, sz = hwcentries->size (); i < sz; i++) { Hwcentry *h = hwcentries->get (i); free (h->int_name); free (h->name); delete h; } delete hwcentries; } if (idxobjs) { for (int i = 0; i < idxobjs->size (); ++i) { HashMap<uint64_t, Histable*> *hMap = idxobjs->get (i); if (hMap) { hMap->values ()->destroy (); delete hMap; } } delete idxobjs; } for (int i = 0; i < HTableSize; i++) { List *list = dnameHTable[i]; while (list) { List *tmp = list; list = 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 != NULL) { StringBuilder *sb = new StringBuilder (); sb->append (NTXT ("/bin/rm -rf ")); sb->append (defExpName); char *cmd = sb->toString (); system (cmd); free (cmd); delete sb; free (defExpName); } unlink_tmp_files (); delete tmp_files; dbeSession = NULL; } void DbeSession::unlink_tmp_files () { if (tmp_files) { for (int i = 0, sz = tmp_files->size (); i < sz; i++) unlink (tmp_files->fetch (i)); tmp_files->destroy (); delete tmp_files; tmp_files = NULL; } if (tmp_dir_name) { char *cmd = dbe_sprintf (NTXT ("/bin/rm -rf %s"), tmp_dir_name); system (cmd); free (cmd); free (tmp_dir_name); tmp_dir_name = NULL; } } char * DbeSession::get_tmp_file_name (const char *nm, bool for_java) { if (tmp_dir_name == NULL) { tmp_dir_name = dbe_sprintf (NTXT ("/tmp/analyzer.%llu.%lld"), (unsigned long long) getuid (), (long long) getpid ()); mkdir (tmp_dir_name, S_IRWXU); } char *fnm = dbe_sprintf (NTXT ("%s/%s"), tmp_dir_name, nm); if (for_java) for (char *s = fnm + strlen (tmp_dir_name) + 1; *s; s++) if (*s == '/')