コード例 #1
0
ファイル: debug.py プロジェクト: gorakhargosh/pypy
def fatalerror(msg, traceback=False):
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop

    if traceback:
        llop.debug_print_traceback(lltype.Void)
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #2
0
 def locate_caller_based_on_retaddr(self, retaddr):
     gcmapstart = llop.gc_asmgcroot_static(llmemory.Address, 0)
     gcmapend   = llop.gc_asmgcroot_static(llmemory.Address, 1)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     gcmapstart2 = self._extra_gcmapstart()
     gcmapend2   = self._extra_gcmapend()
     if gcmapstart2 != gcmapend2:
         # we have a non-empty JIT-produced table to look in
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item.address[1])
             return
         # maybe the JIT-produced table is not sorted?
         sort_gcmap(gcmapstart2, gcmapend2)
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item.address[1])
             return
     # the item may have been not found because the main array was
     # not sorted.  Sort it and try again.
     sort_gcmap(gcmapstart, gcmapend)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
コード例 #3
0
def fatalerror_notb(msg):
    # a variant of fatalerror() that doesn't print the RPython traceback
    if not we_are_translated():
        raise FatalError(msg)
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #4
0
ファイル: asmgcroot.py プロジェクト: alkorzt/pypy
 def locate_caller_based_on_retaddr(self, retaddr):
     gcmapstart = llop.gc_asmgcroot_static(llmemory.Address, 0)
     gcmapend   = llop.gc_asmgcroot_static(llmemory.Address, 1)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     gcmapstart2 = self._extra_gcmapstart()
     gcmapend2   = self._extra_gcmapend()
     if gcmapstart2 != gcmapend2:
         # we have a non-empty JIT-produced table to look in
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item.address[1])
             return
         # maybe the JIT-produced table is not sorted?
         sort_gcmap(gcmapstart2, gcmapend2)
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item.address[1])
             return
     # the item may have been not found because the main array was
     # not sorted.  Sort it and try again.
     win32_follow_gcmap_jmp(gcmapstart, gcmapend)
     sort_gcmap(gcmapstart, gcmapend)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
コード例 #5
0
def fatalerror(msg):
    # print the RPython traceback and abort with a fatal error
    if not we_are_translated():
        raise FatalError(msg)
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop
    llop.debug_print_traceback(lltype.Void)
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #6
0
 def locate_caller_based_on_retaddr(self, retaddr):
     gcmapstart = llop.gc_asmgcroot_static(llmemory.Address, 0)
     gcmapend   = llop.gc_asmgcroot_static(llmemory.Address, 1)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     gcmapstart2 = self._extra_gcmapstart()
     gcmapend2   = self._extra_gcmapend()
     if gcmapstart2 != gcmapend2:
         # we have a non-empty JIT-produced table to look in
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item)
             return
         # maybe the JIT-produced table is not sorted?
         was_already_sorted = self._extra_mark_sorted()
         if not was_already_sorted:
             sort_gcmap(gcmapstart2, gcmapend2)
             item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
             if item:
                 self._shape_decompressor.setaddr(item)
                 return
         # there is a rare risk that the array contains *two* entries
         # with the same key, one of which is dead (null value), and we
         # found the dead one above.  Solve this case by replacing all
         # dead keys with nulls, sorting again, and then trying again.
         replace_dead_entries_with_nulls(gcmapstart2, gcmapend2)
         sort_gcmap(gcmapstart2, gcmapend2)
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item)
             return
     # the item may have been not found because the main array was
     # not sorted.  Sort it and try again.
     win32_follow_gcmap_jmp(gcmapstart, gcmapend)
     sort_gcmap(gcmapstart, gcmapend)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
コード例 #7
0
ファイル: asmgcroot.py プロジェクト: purepython/pypy
 def locate_caller_based_on_retaddr(self, retaddr):
     gcmapstart = llop.gc_asmgcroot_static(llmemory.Address, 0)
     gcmapend = llop.gc_asmgcroot_static(llmemory.Address, 1)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     gcmapstart2 = self._extra_gcmapstart()
     gcmapend2 = self._extra_gcmapend()
     if gcmapstart2 != gcmapend2:
         # we have a non-empty JIT-produced table to look in
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item)
             return
         # maybe the JIT-produced table is not sorted?
         was_already_sorted = self._extra_mark_sorted()
         if not was_already_sorted:
             sort_gcmap(gcmapstart2, gcmapend2)
             item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
             if item:
                 self._shape_decompressor.setaddr(item)
                 return
         # there is a rare risk that the array contains *two* entries
         # with the same key, one of which is dead (null value), and we
         # found the dead one above.  Solve this case by replacing all
         # dead keys with nulls, sorting again, and then trying again.
         replace_dead_entries_with_nulls(gcmapstart2, gcmapend2)
         sort_gcmap(gcmapstart2, gcmapend2)
         item = search_in_gcmap2(gcmapstart2, gcmapend2, retaddr)
         if item:
             self._shape_decompressor.setaddr(item)
             return
     # the item may have been not found because the main array was
     # not sorted.  Sort it and try again.
     win32_follow_gcmap_jmp(gcmapstart, gcmapend)
     sort_gcmap(gcmapstart, gcmapend)
     item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
     if item:
         self._shape_decompressor.setpos(item.signed[1])
         return
     llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
コード例 #8
0
def fatalerror(msg, traceback=False):
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop
    if traceback:
        llop.debug_print_traceback(lltype.Void)
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #9
0
ファイル: asmgcroot.py プロジェクト: antoine1fr/pygirl
    def walk_to_parent_frame(self, callee, caller):
        """Starting from 'callee', walk the next older frame on the stack
        and fill 'caller' accordingly.  Also invokes the collect_stack_root()
        callback from the GC code for each GC root found in 'caller'.
        """
        #
        # The gcmap table is a list of entries, two machine words each:
        #     void *SafePointAddress;
        #     int Shape;
        #
        # A "safe point" is the return address of a call.
        # The "shape" of a safe point is a list of integers
        # that represent "locations".  A "location" can be
        # either in the stack or in a register.  See
        # getlocation() for the decoding of this integer.
        # The locations stored in a "shape" are as follows:
        #
        #   * The "location" of the return address.  This is just
        #     after the end of the frame of 'callee'; it is the
        #     first word of the frame of 'caller' (see picture
        #     below).
        #
        #   * Four "locations" that specify where the function saves
        #     each of the four callee-saved registers (%ebx, %esi,
        #     %edi, %ebp).
        #
        #   * The number of live GC roots around the call.
        #
        #   * For each GC root, an integer that specify where the
        #     GC pointer is stored.  This is a "location" too.
        #
        # XXX the details are completely specific to X86!!!
        # a picture of the stack may help:
        #                                           ^ ^ ^
        #     |     ...      |                 to older frames
        #     +--------------+
        #     |   ret addr   |  <------ caller_frame (addr of retaddr)
        #     |     ...      |
        #     | caller frame |
        #     |     ...      |
        #     +--------------+
        #     |   ret addr   |  <------ callee_frame (addr of retaddr)
        #     |     ...      |
        #     | callee frame |
        #     |     ...      |                 lower addresses
        #     +--------------+                      v v v
        #

        retaddr = callee.frame_address.address[0]
        #
        # try to locate the caller function based on retaddr.
        #
        gcmapstart = llop.llvm_gcmapstart(llmemory.Address)
        gcmapend   = llop.llvm_gcmapend(llmemory.Address)
        item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
        if not item:
            # the item may have been not found because the array was
            # not sorted.  Sort it and try again.
            sort_gcmap(gcmapstart, gcmapend)
            item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
            if not item:
                llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
                return False
        #
        # found!  Enumerate the GC roots in the caller frame
        #
        shape = item.signed[1]
        if shape < 0:
            shape = ~ shape     # can ignore this "range" marker here
        self._shape_decompressor.setpos(shape)
        collect_stack_root = self.gcdata._gc_collect_stack_root
        gc = self.gc
        while True:
            location = self._shape_decompressor.next()
            if location == 0:
                break
            addr = self.getlocation(callee, location)
            if addr.address[0] != llmemory.NULL:
                collect_stack_root(gc, addr)
        #
        # track where the caller_frame saved the registers from its own
        # caller
        #
        reg = CALLEE_SAVED_REGS - 1
        while reg >= 0:
            location = self._shape_decompressor.next()
            addr = self.getlocation(callee, location)
            caller.regs_stored_at[reg] = addr
            reg -= 1

        location = self._shape_decompressor.next()
        caller.frame_address = self.getlocation(callee, location)
        # we get a NULL marker to mean "I'm the frame
        # of the entry point, stop walking"
        return caller.frame_address != llmemory.NULL
コード例 #10
0
ファイル: llvmgcroot.py プロジェクト: griels/pypy-sc
            def walk_to_parent_frame(self):
                #
                # The gcmap table is a list of pairs of pointers:
                #     void *SafePointAddress;
                #     void *Shape;
                #
                # A "safe point" is the return address of a call.
                # The "shape" of a safe point records the size of the
                # frame of the function containing it, as well as a
                # list of the variables that contain gc roots at that
                # time.  Each variable is described by its offset in
                # the frame.
                #
                callee_frame = self.stack_current
                if llmemory.cast_adr_to_int(callee_frame) & 1:
                    return False   # odd bit set here when the callee_frame
                                   # is the frame of main(), i.e. when there
                                   # is nothing more for us in the stack.
                #
                # XXX the details are completely specific to X86!!!
                # a picture of the stack may help:
                #                                           ^ ^ ^
                #     |     ...      |                 to older frames
                #     +--------------+
                #     |  first word  |  <------ caller_frame (addr of 1st word)
                #     +              +
                #     | caller frame |
                #     |     ...      |
                #     |  frame data  |  <------ frame_data_base
                #     +--------------+
                #     |   ret addr   |
                #     +--------------+
                #     |  first word  |  <------ callee_frame (addr of 1st word)
                #     +              +
                #     | callee frame |
                #     |     ...      |
                #     |  frame data  |                 lower addresses
                #     +--------------+                      v v v
                #
                retaddr = callee_frame.address[1]
                #
                # try to locate the caller function based on retaddr.
                #
                gcmapstart = llop.llvm_gcmapstart(llmemory.Address)
                gcmapend   = llop.llvm_gcmapend(llmemory.Address)
                item = binary_search(gcmapstart, gcmapend, retaddr)
                if item.address[0] == retaddr:
                    #
                    # found!  Setup pointers allowing us to
                    # parse the caller's frame structure...
                    #
                    shape = item.address[1]
                    # XXX assumes that .signed is 32-bit
                    framesize = shape.signed[0]   # odd if it's main()
                    livecount = shape.signed[1]
                    caller_frame = callee_frame + 4 + framesize
                    self.stack_current = caller_frame
                    self.frame_data_base = callee_frame + 8
                    self.remaining_roots_in_current_frame = livecount
                    self.liveoffsets = shape + 8
                    return True

                # retaddr not found!
                llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
                return False
コード例 #11
0
ファイル: debug.py プロジェクト: are-prabhu/pypy
def fatalerror_notb(msg):
    # a variant of fatalerror() that doesn't print the RPython traceback
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #12
0
ファイル: debug.py プロジェクト: are-prabhu/pypy
def fatalerror(msg):
    # print the RPython traceback and abort with a fatal error
    from pypy.rpython.lltypesystem import lltype
    from pypy.rpython.lltypesystem.lloperation import llop
    llop.debug_print_traceback(lltype.Void)
    llop.debug_fatalerror(lltype.Void, msg)
コード例 #13
0
ファイル: asmgcroot.py プロジェクト: chyyuu/pygirl
    def walk_to_parent_frame(self, callee, caller):
        """Starting from 'callee', walk the next older frame on the stack
        and fill 'caller' accordingly.  Also invokes the collect_stack_root()
        callback from the GC code for each GC root found in 'caller'.
        """
        #
        # The gcmap table is a list of entries, two machine words each:
        #     void *SafePointAddress;
        #     int Shape;
        #
        # A "safe point" is the return address of a call.
        # The "shape" of a safe point is a list of integers
        # that represent "locations".  A "location" can be
        # either in the stack or in a register.  See
        # getlocation() for the decoding of this integer.
        # The locations stored in a "shape" are as follows:
        #
        #   * The "location" of the return address.  This is just
        #     after the end of the frame of 'callee'; it is the
        #     first word of the frame of 'caller' (see picture
        #     below).
        #
        #   * Four "locations" that specify where the function saves
        #     each of the four callee-saved registers (%ebx, %esi,
        #     %edi, %ebp).
        #
        #   * The number of live GC roots around the call.
        #
        #   * For each GC root, an integer that specify where the
        #     GC pointer is stored.  This is a "location" too.
        #
        # XXX the details are completely specific to X86!!!
        # a picture of the stack may help:
        #                                           ^ ^ ^
        #     |     ...      |                 to older frames
        #     +--------------+
        #     |   ret addr   |  <------ caller_frame (addr of retaddr)
        #     |     ...      |
        #     | caller frame |
        #     |     ...      |
        #     +--------------+
        #     |   ret addr   |  <------ callee_frame (addr of retaddr)
        #     |     ...      |
        #     | callee frame |
        #     |     ...      |                 lower addresses
        #     +--------------+                      v v v
        #

        retaddr = callee.frame_address.address[0]
        #
        # try to locate the caller function based on retaddr.
        #
        gcmapstart = llop.llvm_gcmapstart(llmemory.Address)
        gcmapend = llop.llvm_gcmapend(llmemory.Address)
        item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
        if not item:
            # the item may have been not found because the array was
            # not sorted.  Sort it and try again.
            sort_gcmap(gcmapstart, gcmapend)
            item = search_in_gcmap(gcmapstart, gcmapend, retaddr)
            if not item:
                llop.debug_fatalerror(lltype.Void, "cannot find gc roots!")
                return False
        #
        # found!  Enumerate the GC roots in the caller frame
        #
        shape = item.signed[1]
        if shape < 0:
            shape = ~shape  # can ignore this "range" marker here
        self._shape_decompressor.setpos(shape)
        collect_stack_root = self.gcdata._gc_collect_stack_root
        gc = self.gc
        while True:
            location = self._shape_decompressor.next()
            if location == 0:
                break
            addr = self.getlocation(callee, location)
            if addr.address[0] != llmemory.NULL:
                collect_stack_root(gc, addr)
        #
        # track where the caller_frame saved the registers from its own
        # caller
        #
        reg = CALLEE_SAVED_REGS - 1
        while reg >= 0:
            location = self._shape_decompressor.next()
            addr = self.getlocation(callee, location)
            caller.regs_stored_at[reg] = addr
            reg -= 1

        location = self._shape_decompressor.next()
        caller.frame_address = self.getlocation(callee, location)
        # we get a NULL marker to mean "I'm the frame
        # of the entry point, stop walking"
        return caller.frame_address != llmemory.NULL