Пример #1
0
 def get_instructions(self):
   # return spe_mfc_getb(speid, ls, (void *)ea, size, tag, tid, rid);
   tag = 5
   ea = self.code._prologue.inst_addr()
   spu_exec.spu_getb(self.spe_id, self.lsa, ea, self.size, tag, 0, 0)
   spu_exec.read_tag_status_all(self.spe_id, 1 << tag);
   return
Пример #2
0
 def get_instructions(self):
     # return spe_mfc_getb(speid, ls, (void *)ea, size, tag, tid, rid);
     tag = 5
     ea = self.code._prologue.inst_addr()
     spu_exec.spu_getb(self.spe_id, self.lsa, ea, self.size, tag, 0, 0)
     spu_exec.read_tag_status_all(self.spe_id, 1 << tag)
     return
Пример #3
0
  def dump_regs(self):
    mbox   = 28 # write out mbox channel

    # Pseudo-code:
    #  1) Save code is: (do this as an array, not an instruction stream)
    save_size = 128 * 2 + 4
    save_code = extarray.extarray('I', range(save_size))
    
    for i in range(0, 128 * 2, 2):
      save_code[i] = spu.wrch(i / 2, mbox, ignore_active = True).render()
      save_code[i + 1] = spu.stop(0x6, ignore_active = True).render()

    # branch back to the debug stop
    save_code[128 * 2] = spu.stop(0x7, ignore_active = True).render()
    ret = spu.bra(self.debug_lsa, ignore_active = True)
    save_code[128 * 2 + 1] = ret.render()

    #aligned_save_code = aligned_memory(save_size, typecode = 'I')
    #aligned_save_code.copy_to(save_code.buffer_info()[0], len(save_code))

    #  2) Save lsa[0:len(save_code)]
    # TODO: do this with putb

    #  3) Push save code to lsa[0:]
    tag = 2
    spu_exec.spu_getb(self.spe_id, 0, save_code.buffer_info()[0], save_size * 4, tag, 0, 0)
    spu_exec.read_tag_status_all(self.spe_id, 1 << tag);
    
    #  3) Replace the debug branch with a branch to 0
    self.replace(self.debug_branch, spu.bra(0, ignore_active = True))
    self.get_instructions()

    #  4) Resume
    self.resume(self.spe_id)    

    #  5) Read the register values and send the ok signal
    regs = []
    for i in range(128):
      while spu_exec.stat_out_mbox(self.spe_id) == 0: pass
      value = spu_exec.read_out_mbox(self.spe_id)
      regs.append(value)

      r = spu_exec.wait_stop_event(self.spe_id)
      self.resume(self.spe_id)

    r = spu_exec.wait_stop_event(self.spe_id)
    print 'next stop', r
    #  6) Restore code at original pc
    self.restore(self.debug_branch)
    self.get_instructions()

    #  7) Restore lsa[0:len(save_code)]
    # TODO: do this with putb

    #  8) Resume
    # self.resume(self.spe_id)    
    # r = spu_exec.wait_stop_event(self.spe_id)
    self.resume(self.spe_id)
    r = self.wait_debug()

    return regs
Пример #4
0
    def dump_regs(self):
        mbox = 28  # write out mbox channel

        # Pseudo-code:
        #  1) Save code is: (do this as an array, not an instruction stream)
        save_size = 128 * 2 + 4
        save_code = extarray.extarray('I', range(save_size))

        for i in range(0, 128 * 2, 2):
            save_code[i] = spu.wrch(i / 2, mbox, ignore_active=True).render()
            save_code[i + 1] = spu.stop(0x6, ignore_active=True).render()

        # branch back to the debug stop
        save_code[128 * 2] = spu.stop(0x7, ignore_active=True).render()
        ret = spu.bra(self.debug_lsa, ignore_active=True)
        save_code[128 * 2 + 1] = ret.render()

        #aligned_save_code = aligned_memory(save_size, typecode = 'I')
        #aligned_save_code.copy_to(save_code.buffer_info()[0], len(save_code))

        #  2) Save lsa[0:len(save_code)]
        # TODO: do this with putb

        #  3) Push save code to lsa[0:]
        tag = 2
        spu_exec.spu_getb(self.spe_id, 0,
                          save_code.buffer_info()[0], save_size * 4, tag, 0, 0)
        spu_exec.read_tag_status_all(self.spe_id, 1 << tag)

        #  3) Replace the debug branch with a branch to 0
        self.replace(self.debug_branch, spu.bra(0, ignore_active=True))
        self.get_instructions()

        #  4) Resume
        self.resume(self.spe_id)

        #  5) Read the register values and send the ok signal
        regs = []
        for i in range(128):
            while spu_exec.stat_out_mbox(self.spe_id) == 0:
                pass
            value = spu_exec.read_out_mbox(self.spe_id)
            regs.append(value)

            r = spu_exec.wait_stop_event(self.spe_id)
            self.resume(self.spe_id)

        r = spu_exec.wait_stop_event(self.spe_id)
        print 'next stop', r
        #  6) Restore code at original pc
        self.restore(self.debug_branch)
        self.get_instructions()

        #  7) Restore lsa[0:len(save_code)]
        # TODO: do this with putb

        #  8) Resume
        # self.resume(self.spe_id)
        # r = spu_exec.wait_stop_event(self.spe_id)
        self.resume(self.spe_id)
        r = self.wait_debug()

        return regs