Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import substage
import sys
import pure_utils
from capstone import *
import os
l = logging.getLogger("")
class FramaCDstEntry(tables.IsDescription):
line = tables.StringCol(512) # file/lineno
lvalue = tables.StringCol(512) # lvalue as reported by framac
dstlo = tables.UInt64Col() # low value of write dst range
dstlolo = tables.UInt32Col() # low value of write dst range
dstlohi = tables.UInt32Col() # low value of write dst range
dsthi = tables.UInt64Col() # high value of write dst range
dsthilo = tables.UInt32Col() # high value of write dst range
dsthihi = tables.UInt32Col() # high value of write dst range
dst_not_in_ram = tables.BoolCol() # true if range is not RAM
writepc = tables.UInt64Col() # corresponding store instruction PC to src line (if just 1)
writepclo = tables.UInt32Col() # corresponding store instruction PC to src line (if just 1)
writepchi = tables.UInt32Col() # corresponding store instruction PC to src line (if just 1)
origpc = tables.UInt64Col() # corresponding store instruction PC to src line (if just 1)
origpclo = tables.UInt32Col() # corresponding store instruction PC to src line (if just 1)
origpchi = tables.UInt32Col() # corresponding store instruction PC to src line (if just 1)
substage = tables.UInt8Col()
class WriteDstTable():
def _find_mux_pc(self, dst):
user = {'res': None,
'dst': long(dst)}
short_name = tables.StringCol(255)
parent_name = tables.StringCol(255)
name = tables.StringCol(255)
comments = tables.StringCol(512)
include_children = tables.BoolCol()
reclassifiable = tables.BoolCol()
do_print = tables.BoolCol()
class MemoryRegionAddrs(tables.IsDescription):
short_name = tables.StringCol(255)
startaddr = tables.UInt64Col()
startaddrlo = tables.UInt32Col()
startaddrhi = tables.UInt32Col()
endaddr = tables.UInt64Col()
endaddrlo = tables.UInt32Col()
endaddrhi = tables.UInt32Col()
class SubstageRelocInfo(tables.IsDescription):
substagenum = tables.UInt8Col()
reloc_name = tables.StringCol(128)
class SubstageRegionPolicy(tables.IsDescription):
default_perms = tables.EnumCol(perms,
'rwx', base='uint8')
short_name = tables.StringCol(255)
symbol_name = tables.StringCol(255) # symbol name in code
symbol_elf_name = tables.StringCol(255) # symbol name in elf filie
region_type = tables.EnumCol(region_types, BOOKKEEPING, base='uint8')
substagenum = tables.UInt8Col()
def _create_singles_table(file, group):
"""Create singles table in PyTables file
Create a singles table containing the ESD singles columns which are
available in the TSV download.
:param file: PyTables file.
:param group: the group to contain the singles table, which need not
exist.
"""
description = {'event_id': tables.UInt32Col(pos=0),
'timestamp': tables.Time32Col(pos=1),
'mas_ch1_low': tables.Int32Col(pos=2),
'mas_ch1_high': tables.Int32Col(pos=3),
'mas_ch2_low': tables.Int32Col(pos=4),
'mas_ch2_high': tables.Int32Col(pos=5),
'slv_ch1_low': tables.Int32Col(pos=6),
'slv_ch1_high': tables.Int32Col(pos=7),
'slv_ch2_low': tables.Int32Col(pos=8),
'slv_ch2_high': tables.Int32Col(pos=9)}
return file.create_table(group, 'singles', description, createparents=True)
def _create_events_table(file, group):
"""Create event table in PyTables file
Create an event table containing the ESD data columns which are
available in the TSV download.
:param file: PyTables file.
:param group: the group to contain the events table, which need not
exist.
"""
description = {'event_id': tables.UInt32Col(pos=0),
'timestamp': tables.Time32Col(pos=1),
'nanoseconds': tables.UInt32Col(pos=2),
'ext_timestamp': tables.UInt64Col(pos=3),
'pulseheights': tables.Int16Col(pos=4, shape=4),
'integrals': tables.Int32Col(pos=5, shape=4),
'n1': tables.Float32Col(pos=6),
'n2': tables.Float32Col(pos=7),
'n3': tables.Float32Col(pos=8),
'n4': tables.Float32Col(pos=9),
't1': tables.Float32Col(pos=10),
't2': tables.Float32Col(pos=11),
't3': tables.Float32Col(pos=12),
't4': tables.Float32Col(pos=13),
't_trigger': tables.Float32Col(pos=14)}
return file.create_table(group, 'events', description, createparents=True)
row.extend( resp )
data.append( row )
self._file_handle.write_chr_table( chr_name, data )
def close( self ):
self._file_handle.close()
class JointExtendedMultiMixTable( IsDescription ):
position = UInt32Col( pos=0 )
ref_base = StringCol( itemsize=1, pos=1 )
normal_counts_A = UInt32Col( pos=2 )
normal_counts_C = UInt32Col( pos=3 )
normal_counts_G = UInt32Col( pos=4 )
normal_counts_T = UInt32Col( pos=5 )
tumour_counts_A = UInt32Col( pos=6 )
tumour_counts_C = UInt32Col( pos=7 )
tumour_counts_G = UInt32Col( pos=8 )
tumour_counts_T = UInt32Col( pos=9 )
p_AA_AA = Float64Col( pos=10 )
p_AA_AC = Float64Col( pos=11 )
p_AA_AG = Float64Col( pos=12 )
print2err('Closing remaining open data files:')
for fileh in open_files:
if verbose:
print2err('%s...' % (open_files[fileh].filename,))
open_files[fileh].close()
if verbose:
print2err('done')
registered_close_open_data_files = True
atexit.register(close_open_data_files, False)
## ---------------------- Pytable Definitions ------------------- ##
class ClassTableMappings(tables.IsDescription):
class_id = UInt32Col(pos=1)
class_type_id = UInt32Col(pos=2) # Device or Event etc.
class_name = StringCol(32, pos=3)
table_path = StringCol(128, pos=4)
class ExperimentMetaData(tables.IsDescription):
experiment_id = UInt32Col(pos=1)
code = StringCol(24, pos=2)
title = StringCol(48, pos=3)
description = StringCol(256, pos=4)
version = StringCol(6, pos=5)
total_sessions_to_run = UInt16Col(pos=9)
class SessionMetaData(tables.IsDescription):
session_id = UInt32Col(pos=1)
def _create_lightning_table(file, group):
"""Create lightning table in PyTables file
Create an lightning table containing the ESD data columns which are
available in the TSV download.
:param file: PyTables file.
:param group: the group to contain the lightning table, which need not
exist.
"""
description = {'event_id': tables.UInt32Col(pos=0),
'timestamp': tables.Time32Col(pos=1),
'nanoseconds': tables.UInt32Col(pos=2),
'ext_timestamp': tables.UInt64Col(pos=3),
'latitude': tables.Float32Col(pos=4),
'longitude': tables.Float32Col(pos=5),
'current': tables.Float32Col(pos=6)}
return file.create_table(group, 'lightning', description, createparents=True)
class TraceWriteRange(tables.IsDescription):
index = tables.UInt32Col()
destlo = tables.UInt64Col()
destlo = tables.UInt32Col()
destlolo = tables.UInt32Col()
destlohi = tables.UInt32Col()
desthi = tables.UInt64Col()
desthilo = tables.UInt32Col()
desthihi = tables.UInt32Col()
pc = tables.UInt64Col()
pclo = tables.UInt32Col()
pchi = tables.UInt32Col()
relocatedpc = tables.UInt64Col()
relocatedpclo = tables.UInt32Col()
relocatedpchi = tables.UInt32Col()
lr = tables.UInt64Col()
lrlo = tables.UInt32Col()
lrhi = tables.UInt32Col()
relocatedlr = tables.UInt64Col()
relocatedlrlo = tables.UInt32Col()
relocatedlrhi = tables.UInt32Col()
byteswritten = tables.UInt64Col()
numops = tables.UInt64Col()
cpsr = tables.UInt64Col()
caller = tables.StringCol(40)
substage = tables.UInt8Col()
class TraceTable():
h5tablename = "writes"
writerangetablename = "write_ranges"
class SubstageEntry(tables.IsDescription):
substagenum = tables.UInt8Col(pos=1)
functionname = tables.StringCol(255)
name = tables.StringCol(255)
stack = tables.StringCol(255)
comments = tables.StringCol(255)
substage_type = tables.EnumCol(substage_types,
BOOKKEEPING, base='uint8')
class SubstageWriteIntervals(tables.IsDescription):
substagenum = tables.UInt8Col()
minaddr = tables.UInt64Col()
minaddrlo = tables.UInt32Col()
minaddrhi = tables.UInt32Col()
maxaddr = tables.UInt64Col()
maxaddrlo = tables.UInt32Col()
maxaddrhi = tables.UInt32Col()
class SubstagesInfo():
CUMULATIVE = "cumulative"
SUBSTAGEONLY = "substageonly"
interval_types = [CUMULATIVE, SUBSTAGEONLY]
mmap_info_table_name = "mmap_info"
mmap_addr_table_name = "mmap_addr"
info_table_name = "info"
region_policy_table_name = "region_policy"
substage_reloc_table_name = "substage_reloc"
def __init__(self, stage,
import tables
from ..utils import pbar
LOGFILE = '/data/hisparc/corsika/logs/generate_overview.log'
DATA_PATH = '/data/hisparc/corsika/data'
OUTPUT_PATH = '/data/hisparc/corsika/corsika_overview.h5'
logger = logging.getLogger(__name__)
class Simulations(tables.IsDescription):
"""Store summary information about CORSIKA simulations"""
seed1 = tables.UInt32Col(pos=0)
seed2 = tables.UInt32Col(pos=1)
particle_id = tables.UInt32Col(pos=2)
energy = tables.Float32Col(pos=3)
first_interaction_altitude = tables.Float32Col(pos=4)
p_x = tables.Float32Col(pos=5)
p_y = tables.Float32Col(pos=6)
p_z = tables.Float32Col(pos=7)
zenith = tables.Float32Col(pos=8)
azimuth = tables.Float32Col(pos=9)
observation_height = tables.Float32Col(pos=10)
n_photon = tables.Float32Col(pos=11)
n_electron = tables.Float32Col(pos=12)
n_muon = tables.Float32Col(pos=13)
n_hadron = tables.Float32Col(pos=14)