! @brief Generate GDB memory map XML.
760049
def get_memory_map_xml(self):
        
        root = ElementTree.Element('memory-map')
        for r in  self._context.core.memory_map:
            # Look up the region type name. Regions default to ram if gdb doesn't
            # have a concept of the region type.
            gdbType = GDB_TYPE_MAP.get(r.type, 'ram')
            
            start = hex(r.start).rstrip("L")
            length = hex(r.length).rstrip("L")
            mem = ElementTree.SubElement(root, 'memory', type=gdbType, start=start, length=length)
            if r.is_flash:
                prop = ElementTree.SubElement(mem, 'property', name='blocksize')
                prop.text = hex(r.blocksize).rstrip("L")
        return MAP_XML_HEADER + ElementTree.tostring(root)
1190996
def readMemory(buffer, size, URL, encoding, options):
    
    ret = libxml2mod.xmlReadMemory(buffer, size, URL, encoding, options)
    if ret is None:raise treeError('xmlReadMemory() failed')
    return xmlDoc(_obj=ret)
515215
private void buildNameMap() {
        nameMap = new HashMap<String, GrailsPlugin>();
        for (GrailsPlugin plugin : originalPlugins) {
            nameMap.put(plugin.getName(), plugin);
        }
    }
259034
def _generate_id_maps(self, unique_stmts, poolsize=None,
                          size_cutoff=100, split_idx=None):
        """"""
        # Check arguments relating to multiprocessing
        if poolsize is None:
            logger.debug('combine_related: poolsize not set, '
                         'not using multiprocessing.')
            use_mp = False
        elif sys.version_info[0] >= 3 and sys.version_info[1] >= 4:
            use_mp = True
            logger.info('combine_related: Python >= 3.4 detected, '
                        'using multiprocessing with poolsize %d, '
                        'size_cutoff %d' % (poolsize, size_cutoff))
        else:
            use_mp = False
            logger.info('combine_related: Python < 3.4 detected, '
                        'not using multiprocessing.')
        eh = self.hierarchies['entity']
        # Make a list of Statement types
        stmts_by_type = collections.defaultdict(lambda: [])
        for idx, stmt in enumerate(unique_stmts):
            stmts_by_type[indra_stmt_type(stmt)].append((idx, stmt))

        child_proc_groups = []
        parent_proc_groups = []
        skipped_groups = 0
        # Each Statement type can be preassembled independently
        for stmt_type, stmts_this_type in stmts_by_type.items():
            logger.info('Grouping %s (%s)' %
                        (stmt_type.__name__, len(stmts_this_type)))
            stmt_by_group = self._get_stmt_by_group(stmt_type, stmts_this_type,
                                                    eh)

            # Divide statements by group size
            # If we're not using multiprocessing, then all groups are local
            for g_name, g in stmt_by_group.items():
                if len(g) < 2:
                    skipped_groups += 1
                    continue
                if use_mp and len(g) >= size_cutoff:
                    child_proc_groups.append(g)
                else:
                    parent_proc_groups.append(g)

        # Now run preassembly!
        logger.debug("Groups: %d parent, %d worker, %d skipped." %
                     (len(parent_proc_groups), len(child_proc_groups),
                      skipped_groups))

        supports_func = functools.partial(_set_supports_stmt_pairs,
                                          hierarchies=self.hierarchies,
                                          split_idx=split_idx,
                                          check_entities_match=False)

        # Check if we are running any groups in child processes; note that if
        # use_mp is False, child_proc_groups will be empty
        if child_proc_groups:
            # Get a multiprocessing context
            ctx = mp.get_context('spawn')
            pool = ctx.Pool(poolsize)
            # Run the large groups remotely
            logger.debug("Running %d groups in child processes" %
                         len(child_proc_groups))
            res = pool.map_async(supports_func, child_proc_groups)
            workers_ready = False
        else:
            workers_ready = True

        # Run the small groups locally
        logger.debug("Running %d groups in parent process" %
                     len(parent_proc_groups))
        stmt_ix_map = [supports_func(stmt_tuples)
                       for stmt_tuples in parent_proc_groups]
        logger.debug("Done running parent process groups")

        while not workers_ready:
            logger.debug("Checking child processes")
            if res.ready():
                workers_ready = True
                logger.debug('Child process group comparisons successful? %s' %
                             res.successful())
                if not res.successful():
                    raise Exception("Sorry, there was a problem with "
                                    "preassembly in the child processes.")
                else:
                    stmt_ix_map += res.get()
                logger.debug("Closing pool...")
                pool.close()
                logger.debug("Joining pool...")
                pool.join()
                logger.debug("Pool closed and joined.")
            time.sleep(1)
        logger.debug("Done.")
        # Combine all redundant map edges
        stmt_ix_map_set = set([])
        for group_ix_map in stmt_ix_map:
            for ix_pair in group_ix_map:
                stmt_ix_map_set.add(ix_pair)
        return stmt_ix_map_set
1370005
void generateIronjacamarXml(Definition def, String outputDir)
   {
      try
      {
         String resourceDir = outputDir + File.separatorChar + "src" + File.separatorChar +
               "main" + File.separatorChar + "resources";
         writeIronjacamarXml(def, resourceDir);

         if (def.getBuild().equals("maven"))
         {
            String rarDir = outputDir + File.separatorChar + "src" + File.separatorChar +
                  "main" + File.separatorChar + "rar";
            writeIronjacamarXml(def, rarDir);
         }
      }
      catch (IOException ioe)
      {
         ioe.printStackTrace();
      }
   }
480270
private Memory createNodeMemory( MemoryFactory node,
                                     InternalWorkingMemory wm ) {
        try {
            this.lock.lock();
            // need to try again in a synchronized code block to make sure
            // it was not created yet
            Memory memory = this.memories.get( node.getMemoryId() );
            if( memory == null ) {
                memory = node.createMemory( this.kBase.getConfiguration(), wm );

                if( !this.memories.compareAndSet( node.getMemoryId(), null, memory ) ) {
                    memory = this.memories.get( node.getMemoryId() );
                }

            }
            return memory;
        } finally {
            this.lock.unlock();

        }
    }
1037569
def process_memory_map(attrs=None, where=None):
    '''
    
    '''
    if __grains__['os_family'] in ['RedHat', 'Debian']:
        return _osquery_cmd(table='process_memory_map', attrs=attrs, where=where)
    return {'result': False, 'comment': 'Only available on Red Hat or Debian based systems.'}
692213
def generate(basename, xml):
    ''''''
    if basename.endswith('.py'):
        filename = basename
    else:
        filename = basename + '.py'

    msgs = []
    enums = []
    filelist = []
    for x in xml:
        msgs.extend(x.message)
        enums.extend(x.enum)
        filelist.append(os.path.basename(x.filename))

    for m in msgs:
        if xml[0].little_endian:
            m.fmtstr = '<'
        else:
            m.fmtstr = '>'
        m.native_fmtstr = m.fmtstr
        for f in m.ordered_fields:
            m.fmtstr += mavfmt(f)
            m.native_fmtstr += native_mavfmt(f)
        m.order_map = [ 0 ] * len(m.fieldnames)
        m.len_map = [ 0 ] * len(m.fieldnames)
        m.array_len_map = [ 0 ] * len(m.fieldnames)
        for i in range(0, len(m.fieldnames)):
            m.order_map[i] = m.ordered_fieldnames.index(m.fieldnames[i])
            m.array_len_map[i] = m.ordered_fields[i].array_length
        for i in range(0, len(m.fieldnames)):
            n = m.order_map[i]
            m.len_map[n] = m.fieldlengths[i]

    print("Generating %s" % filename)
    outf = open(filename, "w")
    generate_preamble(outf, msgs, basename, filelist, xml[0])
    generate_enums(outf, enums)
    generate_message_ids(outf, msgs)
    generate_classes(outf, msgs)
    generate_mavlink_class(outf, msgs, xml[0])
    generate_methods(outf, msgs)
    outf.close()
    print("Generated %s OK" % filename)
1157378
private function _memory()
    {
        if (CommonFunctions::executeProgram('sysinfo', '-mem', $bufr, PSI_DEBUG)) {
            if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) {
                $this->sys->setMemTotal($ar_buf[3]);
                $this->sys->setMemFree($ar_buf[1]);
                $this->sys->setMemCache($ar_buf[4]);
                $this->sys->setMemUsed($ar_buf[2]);
            }
        }
        if (CommonFunctions::executeProgram('vmstat', '', $bufr, PSI_DEBUG)) {
            if (preg_match("/max swap space:\s+(.*)\nfree swap space:\s+(.*)\n/", $bufr, $ar_buf)) {
                if ($ar_buf[1]>0) {
                    $dev = new DiskDevice();
                    $dev->setMountPoint("/boot/common/var/swap");
                    $dev->setName("SWAP");
                    $dev->setTotal($ar_buf[1]);
                    $dev->setFree($ar_buf[2]);
                    $dev->setUSed($ar_buf[1]-$ar_buf[2]);
                    $this->sys->setSwapDevices($dev);
                }
            }
        }
    }
1127550
def NewMemory(self, buffer, size, URL, encoding, options):
        
        ret = libxml2mod.xmlReaderNewMemory(self._o, buffer, size, URL, encoding, options)
        return ret
564869
def build_xml(opts = {})
      opts = {:bus => @bus, :os_type => :hvm}.merge!(opts)

      builder = Builder::XmlMarkup.new(:indent => 2)

      xml = builder.domain(:type => opts[:domain_type].to_s) do |domain|
        domain.name(@appliance_name)
        domain.description(@appliance_config.summary)
        domain.memory(@appliance_config.hardware.memory * 1024) #KB
        domain.vcpu(@appliance_config.hardware.cpus)
        domain.os do |os|
          os.type(opts[:os_type].to_s, :arch => @appliance_config.hardware.arch)
          os.boot(:dev => 'hd')
        end
        domain.devices do |devices|
          devices.disk(:type => 'file', :device => 'disk') do |disk|
            disk.source(:file => "#{@libvirt_image_uri}/#{File.basename(@previous_deliverables.disk)}")
            disk.target(:dev => 'hda', :bus => opts[:bus].to_s)
          end
          devices.interface(:type => 'network') do |interface|
            interface.source(:network => @network)
            interface.mac(:address => @mac) if @mac
          end
          devices.console(:type => 'pty') unless @noautoconsole
          devices.graphics(:type => 'vnc', :port => -1) unless @novnc
        end
        domain.features do |features|
          features.pae if @appliance_config.os.pae
        end
      end
      @log.debug xml

      # Let the user modify the XML specification to their requirements
      if @script
        @log.info "Attempting to run user provided script for modifying libVirt XML..."
        xml = IO::popen("#{@script} --domain '#{xml}'").read
        @log.debug "Response was: #{xml}"
      end
      xml
    end
166572
def write_memory_dump():
    
    # first do a full garbage collection run
    gc.collect()
    if gc.garbage:
        log.warn(LOG_CHECK, "Unreachabe objects: %s", pprint.pformat(gc.garbage))
    from meliae import scanner
    fo, filename = get_temp_file(mode='wb', suffix='.json', prefix='lcdump_')
    try:
        scanner.dump_all_objects(fo)
    finally:
        fo.close()
    return filename
38360
def spawn_gdb(pid, address=DFLT_ADDRESS, gdb='gdb', verbose=False,
              ctx=None, proc_iut=None):
    """"""

    parent, child = socket.socketpair()
    proc = Popen([gdb, '--interpreter=mi', '-nx'],
                    bufsize=0, stdin=child, stdout=child, stderr=STDOUT)
    child.close()

    connections = {}
    gdb = GdbSocket(ctx, address, proc, proc_iut, parent, verbose,
                    connections)
    gdb.mi_command('-target-attach %d' % pid)
    gdb.cli_command('python import pdb_clone.bootstrappdb_gdb')
    asyncore.loop(map=connections)
    proc.wait()
    return gdb.error
766619
def dump
      out  = ""
      out << "Page #{current}\n"
      out << "  type:            #{MiqBdbPage.type2string(ptype)}\n"
      out << "  prev:            #{prev}\n"
      out << "  next:            #{@header['next_pgno']}\n"
      out << "  log seq num:     file=#{@header['lsn_file']}  offset=#{@header['lsn_offset']}\n"
      out << "  level:           #{level}\n"

      if @header['p_type'] == P_OVERFLOW
        out << "  ref cnt:         #{nentries}\n"
        out << "  len:             #{offset}\n"
      else
        out << "  entries:         #{nentries}\n"
        out << "  offset:          #{offset}\n"
      end
      out << "  data size:       #{@data.size}\n"
      out << "  data:            "

      @data.bytes.take(20).each do |c|
        out << sprintf("%.2x ", c)
      end
      out << "..." if @data.size > 20

      out << "\n\n"
      out
    end
124878
def generate_xmltags(fn, returntag, ignore_tags, ns=None):
    
    xmlns = create_namespace(ns)
    ns_ignore = ['{0}{1}'.format(xmlns, x) for x in ignore_tags]
    for ac, el in etree.iterparse(fn):
        if el.tag == '{0}{1}'.format(xmlns, returntag):
            yield el
        elif el.tag in ns_ignore:
            formatting.clear_el(el)
1270557
function MemoryAdapter(initialFiles) {
    if (!(this instanceof MemoryAdapter)) {
        return new MemoryAdapter(initialFiles);
    }

    this.entries = new Map();

    // load initial file buffers
    if (typeof initialFiles === "object" && initialFiles) {
        Object.keys(initialFiles).forEach((fileName) => {
            const buf = Buffer.from(initialFiles[fileName]);
            this.entries.set(fileName, buf);
        });
    }
}
551660
private function _buildMemory()
    {
        $memory = $this->_xml->addChild('Memory');
        $memory->addAttribute('Free', $this->_sys->getMemFree());
        $memory->addAttribute('Used', $this->_sys->getMemUsed());
        $memory->addAttribute('Total', $this->_sys->getMemTotal());
        $memory->addAttribute('Percent', $this->_sys->getMemPercentUsed());
        if (($this->_sys->getMemApplication() !== null) || ($this->_sys->getMemBuffer() !== null) || ($this->_sys->getMemCache() !== null)) {
            $details = $memory->addChild('Details');
            if ($this->_sys->getMemApplication() !== null) {
                $details->addAttribute('App', $this->_sys->getMemApplication());
                $details->addAttribute('AppPercent', $this->_sys->getMemPercentApplication());
            }
            if ($this->_sys->getMemBuffer() !== null) {
                $details->addAttribute('Buffers', $this->_sys->getMemBuffer());
                $details->addAttribute('BuffersPercent', $this->_sys->getMemPercentBuffer());
            }
            if ($this->_sys->getMemCache() !== null) {
                $details->addAttribute('Cached', $this->_sys->getMemCache());
                $details->addAttribute('CachedPercent', $this->_sys->getMemPercentCache());
            }
        }
        if (count($this->_sys->getSwapDevices()) > 0) {
            $swap = $memory->addChild('Swap');
            $swap->addAttribute('Free', $this->_sys->getSwapFree());
            $swap->addAttribute('Used', $this->_sys->getSwapUsed());
            $swap->addAttribute('Total', $this->_sys->getSwapTotal());
            $swap->addAttribute('Percent', $this->_sys->getSwapPercentUsed());
            $i = 1;
            foreach ($this->_sys->getSwapDevices() as $dev) {
                $swapMount = $swap->addChild('Mount');
                $this->_fillDevice($swapMount, $dev, $i++);
            }
        }
    }