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


Python gdb.error方法代码示例

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


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

示例1: Refresh

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def Refresh():
    """looks up symbols within the inferior and caches their names / values.

    If debugging information is only partial, this method does its best to
    find as much information as it can, validation can be done using
    IsSymbolFileSane.
    """
    try:
      GdbCache.DICT = gdb.lookup_type('PyDictObject').pointer()
      GdbCache.TYPE = gdb.lookup_type('PyTypeObject').pointer()
    except gdb.error as err:
      # The symbol file we're using doesn't seem to provide type information.
      pass
    interp_head_name = GdbCache.FuzzySymbolLookup('interp_head')
    if interp_head_name:
      GdbCache.INTERP_HEAD = gdb.parse_and_eval(interp_head_name)
    else:
      # As a last resort, ask the inferior about it.
      GdbCache.INTERP_HEAD = gdb.parse_and_eval('PyInterpreterState_Head()')
    GdbCache.PENDINGBUSY = GdbCache.FuzzySymbolLookup('pendingbusy')
    GdbCache.PENDINGCALLS_TO_DO = GdbCache.FuzzySymbolLookup('pendingcalls_to_do') 
开发者ID:google,项目名称:pyringe,代码行数:23,代码来源:gdb_service.py

示例2: get_reg

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def get_reg(self, name):
        if name == "efl" or name == "eflags":
            value = 0
            for f in self.efl_map:
                if f in str(gdb.parse_and_eval("$eflags")):
                    value |= self.efl_map[f]
            return value
        else:
            reg_val = gdb.parse_and_eval("$" + name)
            if reg_val.type.code == gdb.TYPE_CODE_UNION: #SSE
                value = 0
                for i in range(8):
                    try:
                        v = int(reg_val["v8_int32"][i].cast(self.long_type)) << i * 32
                    except gdb.error:
                        break
                    value |= v
                return value
            else:
                return int(reg_val.cast(self.long_type)) 
开发者ID:andreafioraldi,项目名称:angrgdb,代码行数:22,代码来源:debugger.py

示例3: print_stack

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def print_stack(self):
        def repr_stack(stack, sp):
            for line in stack.splitlines():
                addr, values = line.split(':')
                values = values.split()
                if addr == sp:
                    top = values[0]
                    rest = ' '.join(values[1:])
                    line = '==> {} {} {}'.format(
                        red(addr), red(top, back='green'),
                        yellow(rest))
                else:
                    line = '    {} {}'.format(
                        red(addr), cyan(' '.join(values)))
                print(line)
        try:
            stack = self.get_stack()
        except IOError as error:
            self.logger.error(error)
        else:
            repr_stack(stack, self.get_reg(self.env.SP))
            print() 
开发者ID:NoviceLive,项目名称:bintut,代码行数:24,代码来源:debuggers.py

示例4: print_asm

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def print_asm(self):
        command = 'u {} l10'.format(self.env.IP)
        try:
            asms = self.execute(command)
        except self.pykd.DbgException as error:
            self.logger.error(error)
        else:
            ip = self.pykd.reg(self.env.IP)
            for line in asms.splitlines()[1:]:
                try:
                    address, opcode, ins = line.split(None, 2)
                except ValueError as error:
                    print(red('{}: {}'.format(line, error)))
                else:
                    line = '{:25} {:25} {}'.format(
                        cyan(address, res=False),
                        yellow(opcode, res=False), red(ins))
                    if int(address, 16) == ip:
                        print(Back.GREEN + line)
                    else:
                        print(line) 
开发者ID:NoviceLive,项目名称:bintut,代码行数:23,代码来源:debuggers.py

示例5: __init__

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def __init__(self, name, controller, stage, no_rec):
        self.name = name
        self.no_rec = no_rec
        self.stage = stage
        self.depth = 0
        self.plugin = controller.subcommand_parsers[self.plugin_name].plugin
        try:
            i = gdb.execute("x/x %s" % self.name, to_string=True).split()[0]
        except gdb.error as e:
            controller.gdb_print("%s cannot set breakpoint for %s\n" % (e,
                                                                        self.name),
                                 self.plugin.name)
            return
        i = re.sub(':', '', i)
        self.fnloc = long(i, 0)
        spec = "*(0x%x)" % self.fnloc
        self.line = re.sub(":",
                           "::",
                           pure_utils.addr2line(self.fnloc,
                                                stage.elf)) if self.plugin._sourceinfo else ""
        gdb_tools.TargetBreak.__init__(self, spec, controller, True, stage) 
开发者ID:bx,项目名称:bootloader_instrumentation_suite,代码行数:23,代码来源:calltrace.py

示例6: invoke

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def invoke(self, arg, from_tty):
        result = gdb.execute('mo leak full', False, True)
        while result.find('are definitely lost in loss record') is -1:
            try:
                gdb.execute('step', to_string = True)  # QUIETLY step
            except gdb.error:
                print('error while stepping')  # BOZO handle
                break
            result = gdb.execute('mo leak full', False, True)
        print('loss report:\n%s'%result)
        print('leak first noticed at:\n')
        gdb.execute('bt') 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:14,代码来源:vgleaks.py

示例7: invoke

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def invoke (self, arg, from_tty):
        try:
            print(FramePrinter(gdb.newest_frame()))
        except gdb.error:
            print("gdb got an error. Maybe we are not currently running?") 
开发者ID:jefftrull,项目名称:gdb_python_api,代码行数:7,代码来源:stackframe.py

示例8: FuzzySymbolLookup

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def FuzzySymbolLookup(symbol_name):
    try:
      gdb.parse_and_eval(symbol_name)
      return symbol_name
    except gdb.error as err:
      # No symbol in current context. We might be dealing with static symbol
      # disambiguation employed by compilers. For example, on debian's current
      # python build, the 'interp_head' symbol (which we need) has been renamed
      # to 'interp_head.42174'. This mangling is of course compiler-specific.
      # We try to get around it by using gdb's built-in regex support when
      # looking up variables
      # Format:
      # All variables matching regular expression "<symbol_name>":
      #
      # File <source_file>:
      # <Type><real_symbol_name>;
      #
      # Non-debugging symbols:
      # 0x<address>  <real_symbol_name>

      # We're only interested in <real_symbol_name>. The latter part
      # ('Non-debugging symbols') is only relevant if debugging info is partial.
      listing = gdb.execute('info variables %s' % symbol_name, to_string=True)
      # sigh... We want whatever was in front of ;, but barring any *s.
      # If you are a compiler dev who mangles symbols using ';' and '*',
      # you deserve this breakage.
      mangled_name = (re.search(r'\**(\S+);$', listing, re.MULTILINE)
                      or re.search(r'^0x[0-9a-fA-F]+\s+(\S+)$', listing, re.MULTILINE))
      if not mangled_name:
        raise err
      try:
        gdb.parse_and_eval('\'%s\'' % mangled_name.group(1))
        return '\'%s\'' % mangled_name.group(1)
      except gdb.error:
        # We could raise this, but the original exception will likely describe
        # the problem better
        raise err 
开发者ID:google,项目名称:pyringe,代码行数:39,代码来源:gdb_service.py

示例9: Attach

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def Attach(self, position):
    pos = [position[0], position[1], None]
    # Using ExecuteRaw here would throw us into an infinite recursion, we have
    # to side-step it.
    gdb.execute('attach ' + str(pos[0]), to_string=True)

    try:
      # Shortcut for handling single-threaded python applications if we've got
      # the right symbol file loaded already
      GdbCache.Refresh()
      self.selected_tstate = self._ThreadPtrs(pos)[0]
    except gdb.error:
      pass 
开发者ID:google,项目名称:pyringe,代码行数:15,代码来源:gdb_service.py

示例10: show_error

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def show_error(e):
    """
    Decorate a function so it masks tracebacks when debug=False
    """
    if gxf.basics.debug:
        # Gdb can't give us a full traceback. If this is a tty
        # or if error occured during argument parsing we do it.
        print("%s" % (traceback.format_exc(),), end="")
    print(e)
    if not gxf.basics.debug:
        print("    If that's weird check `python gxf.basics.debug = True`") 
开发者ID:wapiflapi,项目名称:gxf,代码行数:13,代码来源:errors.py

示例11: get_stack

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def get_stack(self):
        wide = '32wx' if self.env.BITS == 32 else '16gx'
        command = 'x/{} ${}'.format(wide, self.env.SP)
        try:
            output = self.execute(command)
        except gdb.error:
            raise IOError()
        else:
            return output 
开发者ID:NoviceLive,项目名称:bintut,代码行数:11,代码来源:debuggers.py

示例12: get_pc_asm

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def get_pc_asm(self):
        command = 'x/i ${}'.format(self.env.IP)
        try:
            output = self.execute(command)
        except self.gdb.MemoryError as error:
            self.logger.debug('Original error: %s', error)
            sp = self.get_reg(self.env.SP)
            pattern = error.args[0].split()[-1]
            self.logger.debug('sp: %s pattern: %s', sp, pattern)
            raise IOError(sp, pattern)
        else:
            return output 
开发者ID:NoviceLive,项目名称:bintut,代码行数:14,代码来源:debuggers.py

示例13: get_reg

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def get_reg(self, name):
        command = 'info registers {}'.format(name)
        try:
            output = self.execute(command)
        except gdb.error as error:
            self.logger.error(error)
            return None
        else:
            return output.split()[-2] 
开发者ID:NoviceLive,项目名称:bintut,代码行数:11,代码来源:debuggers.py

示例14: step

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def step(self):
        command = 'stepi'
        try:
            self.execute(command)
        except self.gdb.MemoryError as error:
            self.logger.error(error)
            raise IOError 
开发者ID:NoviceLive,项目名称:bintut,代码行数:9,代码来源:debuggers.py

示例15: print_reg

# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import error [as 别名]
def print_reg(self):
        try:
            ip = hex(self.pykd.getIP()).strip('L')
            sp = hex(self.pykd.getSP())
            bp = self.get_reg(self.env.BP)
        except self.pykd.DbgException as error:
            self.logger.error(error)
        else:
            print('{}: {} {}: {} {}: {}'.format(
                self.env.IP.upper(), red(ip),
                self.env.SP.upper(), yellow(sp),
                self.env.BP.upper(), cyan(bp))) 
开发者ID:NoviceLive,项目名称:bintut,代码行数:14,代码来源:debuggers.py


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