当前位置: 首页>>代码示例>>Python>>正文


Python gdb.Value方法代码示例

本文整理汇总了Python中gdb.Value方法的典型用法代码示例。如果您正苦于以下问题:Python gdb.Value方法的具体用法?Python gdb.Value怎么用?Python gdb.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdb的用法示例。


在下文中一共展示了gdb.Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def __init__(self, base_addr, size):
        Thread.__init__(self)
        self.base_addr = base_addr  # the vector we are monitoring
        self.size = size            # its size
        self.messages = Queue()     # cross-thread communication
        # store contents of vec
        self.values = []
        int_t = gdb.lookup_type('int')
        for idx in range(0, size):
            self.values.append(int((base_addr + idx).dereference().cast(int_t)))
        self.animations = []

    # Front end code
    # These methods run in the gdb thread in response to breakpoints,
    # and accept gdb.Value objects

    # Updates for instrumented actions 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:19,代码来源:instrument_srs.py

示例2: __stackmap

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def __stackmap(self, frame_items):
        symbolmap = defaultdict(list)
        if not frame_items:
            return symbolmap

        for i in frame_items:
            name = i.symbol().name
            addr = self._frame.read_var(name).address
            if not addr == None:
                # gdb.Value is not "hashable"; keys must be something else
                # so here we use addr converted to int
                sz = i.symbol().type.sizeof
                # mark all dwords in the stack with this symbol
                addr = addr.cast(gdb.lookup_type("void").pointer()) # cast to void*
                # handle sub-dword quantities by just listing everything that overlaps
                for saddr in range(addr, addr+sz, 0x8):
                    symbolmap[int(saddr)].append(i.symbol())
        return symbolmap

# Now create a gdb command that prints the current stack: 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:22,代码来源:stackframe.py

示例3: _BacktraceFromFramePtr

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def _BacktraceFromFramePtr(self, frame_ptr):
    """Assembles and returns what looks exactly like python's backtraces."""
    # expects frame_ptr to be a gdb.Value
    frame_objs = [PyFrameObjectPtr(frame) for frame
                  in self._IterateChainedList(frame_ptr, 'f_back')]

    # We want to output tracebacks in the same format python uses, so we have to
    # reverse the stack
    frame_objs.reverse()
    tb_strings = ['Traceback (most recent call last):']
    for frame in frame_objs:
      line_string = ('  File "%s", line %s, in %s' %
                     (frame.filename(),
                      str(frame.current_line_num()),
                      frame.co_name.proxyval(set())))
      tb_strings.append(line_string)
      line_string = '    %s' % frame.current_line().strip()
      tb_strings.append(line_string)
    return '\n'.join(tb_strings) 
开发者ID:google,项目名称:pyringe,代码行数:21,代码来源:gdb_service.py

示例4: Assign

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def Assign(self, listObj): 
    try: 
      if ( listObj.type == ListInspector.ListType ): 
        self._list = listObj
        return
      else: 
        raise TypeError("Invalid List Object Type!")
    except Exception as exc: 
      #print(" Failed to assign from List object: %s" % str(exc))
      pass
      
    symbol, methodObj = gdb.lookup_symbol(listObj)
    if ( symbol != None ): 
      self._list = symbol.value() 
    else:       
      addrInt = int(listObj, 0)
      listObjPtr = gdb.Value(addrInt).cast(ListInspector.ListType.pointer())
      self._list = listObjPtr.dereference() 
开发者ID:autolycus,项目名称:FreeRTOS-GDB,代码行数:20,代码来源:List.py

示例5: show_swap

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def show_swap(self, a, b):
        # sending gdb.Value objects over the queue doesn't seem to work
        # at least, their addresses are no longer accessible in the other thread
        # So we'll do the calculations here
        a_idx = a.address - self.base_addr
        b_idx = b.address - self.base_addr
        self._send_message('swap', int(a_idx), int(b_idx)) 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:9,代码来源:instrument_srs.py

示例6: show_move

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def show_move(self, a, b):  # a moved into from b
        # a is always an address and b is an rvalue reference
        # so we use "a" and "b.address"

        # detect whether a or b is a temporary
        a_in_vec = (a >= self.base_addr) and (a < (self.base_addr + self.size))
        b_in_vec = (b.address >= self.base_addr) and (b.address < (self.base_addr + self.size))

        # we will supply temporaries as their address in string form,
        # and in-vector quantities as their offset (a Python int)
        # this way gdb.Value objects don't outlive their frame

        if a_in_vec and b_in_vec:
            a_idx = a - self.base_addr
            b_idx = b.address - self.base_addr
            self._send_message('move', int(b_idx), int(a_idx))
        elif a_in_vec:
            # source is a temporary; stringify its address to use as a token representing it
            a_idx = a - self.base_addr
            self._send_message('move_from_temp', str(b.address), int(a_idx))
        elif b_in_vec:
            # dest is a temporary
            b_idx = b.address - self.base_addr
            self._send_message('move_to_temp', int(b_idx), str(a))
        else:
            # I've never seen a move from temporary to temporary
            raise RuntimeError('saw an unexpected move from temporary to temporary') 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:29,代码来源:instrument_srs.py

示例7: _UnpackGdbVal

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def _UnpackGdbVal(self, gdb_value):
    """Unpacks gdb.Value objects and returns the best-matched python object."""
    val_type = gdb_value.type.code
    if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM:
      return int(gdb_value)
    if val_type == gdb.TYPE_CODE_VOID:
      return None
    if val_type == gdb.TYPE_CODE_PTR:
      return long(gdb_value)
    if val_type == gdb.TYPE_CODE_ARRAY:
      # This is probably a string
      return str(gdb_value)
    # I'm out of ideas, let's return it as a string
    return str(gdb_value) 
开发者ID:google,项目名称:pyringe,代码行数:16,代码来源:gdb_service.py

示例8: field

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def field(self, name):
        '''
        Get the gdb.Value for the given field within the PyObject, coping with
        some python 2 versus python 3 differences.

        Various libpython types are defined using the "PyObject_HEAD" and
        "PyObject_VAR_HEAD" macros.

        In Python 2, this these are defined so that "ob_type" and (for a var
        object) "ob_size" are fields of the type in question.

        In Python 3, this is defined as an embedded PyVarObject type thus:
           PyVarObject ob_base;
        so that the "ob_size" field is located insize the "ob_base" field, and
        the "ob_type" is most easily accessed by casting back to a (PyObject*).
        '''
        if self.is_null():
            raise NullPyObjectPtr(self)

        if name == 'ob_type':
            pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
            return pyo_ptr.dereference()[name]

        if name == 'ob_size':
            try:
            # Python 2:
                return self._gdbval.dereference()[name]
            except RuntimeError:
                # Python 3:
                return self._gdbval.dereference()['ob_base'][name]

        # General case: look it up inside the object:
        return self._gdbval.dereference()[name] 
开发者ID:google,项目名称:pyringe,代码行数:35,代码来源:libpython.py

示例9: proxyval

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def proxyval(self, visited):
        '''
        Scrape a value from the inferior process, and try to represent it
        within the gdb process, whilst (hopefully) avoiding crashes when
        the remote data is corrupt.

        Derived classes will override this.

        For example, a PyIntObject* with ob_ival 42 in the inferior process
        should result in an int(42) in this process.

        visited: a set of all gdb.Value pyobject pointers already visited
        whilst generating this value (to guard against infinite recursion when
        visiting object graphs with loops).  Analogous to Py_ReprEnter and
        Py_ReprLeave
        '''

        class FakeRepr(object):
            """
            Class representing a non-descript PyObject* value in the inferior
            process for when we don't have a custom scraper, intended to have
            a sane repr().
            """

            def __init__(self, tp_name, address):
                self.tp_name = tp_name
                self.address = address

            def __repr__(self):
                # For the NULL pointer, we have no way of knowing a type, so
                # special-case it as per
                # http://bugs.python.org/issue8032#msg100882
                if self.address == 0:
                    return '0x0'
                return '<%s at remote 0x%x>' % (self.tp_name, self.address)

        return FakeRepr(self.safe_tp_name(),
                        long(self._gdbval)) 
开发者ID:google,项目名称:pyringe,代码行数:40,代码来源:libpython.py

示例10: __getitem__

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def __getitem__(self, i):
        # Get the gdb.Value for the (PyObject*) with the given index:
        field_ob_item = self.field('ob_item')
        return field_ob_item[i] 
开发者ID:google,项目名称:pyringe,代码行数:6,代码来源:libpython.py

示例11: field

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def field(self, name):
        '''
        Get the gdb.Value for the given field within the PyObject, coping with
        some python 2 versus python 3 differences.

        Various libpython types are defined using the "PyObject_HEAD" and
        "PyObject_VAR_HEAD" macros.

        In Python 2, this these are defined so that "ob_type" and (for a var
        object) "ob_size" are fields of the type in question.

        In Python 3, this is defined as an embedded PyVarObject type thus:
           PyVarObject ob_base;
        so that the "ob_size" field is located insize the "ob_base" field, and
        the "ob_type" is most easily accessed by casting back to a (PyObject*).
        '''
        if self.is_null():
            raise NullPyObjectPtr(self)

        if name == 'ob_type':
            pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
            return pyo_ptr.dereference()[name]

        if name == 'ob_size':
            try:
                # Python 2:
                return self._gdbval.dereference()[name]
            except RuntimeError:
                # Python 3:
                return self._gdbval.dereference()['ob_base'][name]

        # General case: look it up inside the object:
        return self._gdbval.dereference()[name] 
开发者ID:google,项目名称:copr-sundry,代码行数:35,代码来源:python-gdb.py

示例12: field

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def field(self, name):
        '''
        Get the gdb.Value for the given field within the PyObject, coping with
        some python 2 versus python 3 differences.

        Various libpython types are defined using the "PyObject_HEAD" and
        "PyObject_VAR_HEAD" macros.

        In Python 2, this these are defined so that "ob_type" and (for a var
        object) "ob_size" are fields of the type in question.

        In Python 3, this is defined as an embedded PyVarObject type thus:
           PyVarObject ob_base;
        so that the "ob_size" field is located insize the "ob_base" field, and
        the "ob_type" is most easily accessed by casting back to a (PyObject*).
        '''
        if self.is_null():
            raise NullPyObjectPtr(self)

        if name == 'ob_type':
            pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
            return pyo_ptr.dereference()[name]

        if name == 'ob_size':
            pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type())
            return pyo_ptr.dereference()[name]

        # General case: look it up inside the object:
        return self._gdbval.dereference()[name] 
开发者ID:google,项目名称:copr-sundry,代码行数:31,代码来源:python-gdb.py

示例13: __init__

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def __init__(self, handle): 
    self._tcb = None
    #print("Task: Pass Handle: %s" % str(handle))

    try: 
      if ( handle.type == TaskInspector.TCBType ): 
        self._tcb = handle 
        return
      else: 
        print("Handle Type: %s" % str(handle.type))

    except AttributeError as aexc:
      print("Attribute Error: %s" % str(aexc))
      pass
    except Exception as exc: 
      print("Error Initializing Task Inspector: %s" % str(exc))
      raise

    try:       
      tcbPtr = gdb.Value(handle).cast(TaskInspector.TCBType.pointer())
      self._tcb  = tcbPtr.dereference()
      return
    except Exception as exc:
      print("Failed to convert Handle Pointer: %s" % str(handle))
      
    self._tcb = handle 
开发者ID:autolycus,项目名称:FreeRTOS-GDB,代码行数:28,代码来源:Task.py

示例14: __init__

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def __init__(self, handle): 
    """
    """
    self._evtgrp = gdb.Value(handle).cast(EventGroupInspector.EvtGrpType) 
开发者ID:autolycus,项目名称:FreeRTOS-GDB,代码行数:6,代码来源:EventGroup.py

示例15: GetEventBits

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import Value [as 别名]
def GetEventBits(self): 
    """ Get the Event Flag Bits 
      @return L{gdb.Value} of EventBits_t 
    """ 
    return(self._evtgrp['uxEventBits']) 
开发者ID:autolycus,项目名称:FreeRTOS-GDB,代码行数:7,代码来源:EventGroup.py


注:本文中的gdb.Value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。