Python gdb.string_to_argv() Examples

The following are 22 code examples of gdb.string_to_argv(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gdb , or try the search function .
Example #1
Source File: command_wrapper.py    From Pwngdb with GNU General Public License v3.0 6 votes vote down vote up
def invoke(self,args,from_tty):
        global angelheap_cmd
        self.dont_repeat()
        expressions = gdb.string_to_argv(args)
        arg = self.eval_argv(expressions)
        if len(arg) > 0 :
            cmd = arg[0]

            if cmd in angelheap_cmd.commands :
                func = getattr(angelheap_cmd,cmd)
                func(*arg[1:])
            else :
                print("Unknown command")
        else :
            print("Unknow command")

        return 
Example #2
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 6 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)
            result = []

            if len(argv) != 1:
                raise gdb.GdbError('vmmap -f takes 1 arg')

            try:
                mapping = Strongdb.run_cmd('info proc mapping')
                mapping = mapping[mapping.find('0x'):].split('\n')

                for item in mapping:
                    item_list = item.split(None)

                    if len(item_list) == 5 and item_list[4].find(argv[0]) != -1:
                        result.append('\t\t'.join(item_list))

                Strongdb.display('\n'.join(result) + '\n\n')
            except Exception, e:
                print e
                return 
Example #3
Source File: GDBCommands.py    From FreeRTOS-GDB with GNU General Public License v2.0 6 votes vote down vote up
def invoke(self, arg, from_tty):
    argv = gdb.string_to_argv(arg)    

    CastTypeStr = None
    if ( len(argv) > 0):
      symbolArg = argv[0]
    
    if ( len(argv) > 1 ):
      CastTypeStr = argv[1]
      
    listVal = ListInspector(symbolArg)
    
    elems = listVal.GetElements( CastTypeStr )

    for  elem in elems :
      print("Elem: %s" % str(elem)) 
Example #4
Source File: commands.py    From angrgdb with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def invoke(self, arg, from_tty):
        global _ctx
        self.dont_repeat()

        argv = gdb.string_to_argv(_prepare_args(arg))
        if len(argv) == 0:
            raise AngrGDBError("angrdbg avoid: at least a parameter is needed")

        _ctx.avoid = []
        for a in argv:
            addr = _to_int(a)
            if addr is None:
                raise AngrGDBError(
                    "angrdbg avoid: failed to convert '%s' to int" %
                    a)
            _ctx.avoid.append(addr) 
Example #5
Source File: commands.py    From angrgdb with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def invoke(self, arg, from_tty):
        global _ctx
        self.dont_repeat()

        argv = gdb.string_to_argv(_prepare_args(arg))
        if len(argv) == 0:
            raise AngrGDBError("angrdbg find: at least a parameter is needed")

        _ctx.find = []
        for a in argv:
            addr = _to_int(a)
            if addr is None:
                raise AngrGDBError(
                    "angrdbg find: failed to convert '%s' to int" %
                    a)
            _ctx.find.append(addr) 
Example #6
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color code-highlight takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.code_highlight_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color list subcmd 
Example #7
Source File: command.py    From debugger-utils with MIT License 5 votes vote down vote up
def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) != 2:
            raise gdb.GdbError('输入参数数目不对,help mv以获得用法')
        gdb.execute('delete ' + argv[0])
        gdb.execute('break ' + argv[1]) 
Example #8
Source File: gdb_tools.py    From bootloader_instrumentation_suite with MIT License 5 votes vote down vote up
def invoke(self, arg, from_tty):
        def parse_global(a):
            pargs = self.parser.parse_args(a)
            for c in self.cmds:
                if hasattr(pargs, c) and (getattr(pargs, c) is True):
                    getattr(self, c)(pargs)
                    return True
            return False
        argv = gdb.string_to_argv(arg)
        parser_name = argv[0]
        argv = argv[1:]
        if parser_name == self.name:
            if parse_global(argv):
                return
        else:
            if parser_name in self.subcommand_parsers.iterkeys():
                sub = self.subcommand_parsers[parser_name]
                if argv[0] in sub.cmds:
                    pargs = sub.parser.parse_args(argv)
                    for subc in sub.cmds:
                        if hasattr(pargs, subc) and (getattr(pargs, subc) is True):
                            getattr(sub.plugin, subc)(pargs)
                            return
            if parse_global(argv):
                return
        self.gdb_print("unknown command %s\n" % arg) 
Example #9
Source File: GDBCommands.py    From FreeRTOS-GDB with GNU General Public License v2.0 5 votes vote down vote up
def invoke(self, arg, from_tty):
    argv = gdb.string_to_argv(arg)
    if ( len(argv) != 1 ):
      print("Invalid Argument: Requires one handle arg")
    handle = int( argv[0], 0)
    reg = HandleRegistry()
    name = reg.GetName(handle)
    print("Handle 0x%08x: %s" % (handle, name)) 
Example #10
Source File: GDBCommands.py    From FreeRTOS-GDB with GNU General Public License v2.0 5 votes vote down vote up
def invoke(self, arg, from_tty): 
    argv = gdb.string_to_argv(arg)
    
    qTypes = []     
    if( len(argv) > 0 ):
      for a in argv: 
        try: 
          qType = QueueMode.Map[a]
          qTypes.append(qType)
        except KeyError: 
          print("Arg %s does not map to a Queue Type!" % a)
    
    reg = HandleRegistry()
    qToShow = []
    if ( len(qTypes) > 0 ):
      # We will only print info about queues 
      for qType in qTypes: 
        qObjs = reg.FilterBy(qType)
        qToShow.extend(qObjs)
    else: 
      qToShow = reg.FilterBy(None)

    print("Num Queues: %d" % len(qToShow))
    print("%20s %4s %16s %16s" % ("NAME", "CNT", "SEND", "RECEIVE") )
    for q in qToShow:
      self.PrintQueueInfo(q) 
Example #11
Source File: commands.py    From angrgdb with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def invoke(self, arg, from_tty):
        global _ctx
        self.dont_repeat()
        
        argv = gdb.string_to_argv(_prepare_args(arg))
        if len(argv) == 0:
            raise AngrGDBError("angrdbg sim: at least a parameter is needed")
        elif len(argv) == 1:
            _ctx.symbolics[self._process_argv0(argv[0])] = None
        else:
            siz = _to_int(argv[1])
            if siz is None:
                raise AngrGDBError(
                    "angrdbg sim: the second parameter (length) must be a number")
            _ctx.symbolics[self._process_argv0(argv[0])] = siz 
Example #12
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)

        if len(argv) != 1:
            raise gdb.GdbError('solib takes 1 arg')

        Strongdb.run_cmd('set solib-search-path %s' % (argv[0])) 
Example #13
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)

        if len(argv) != 1:
            raise gdb.GdbError('set jnienv takes 1 arg')

        if not argv[0].isdigit():
            raise gdb.GdbError('invalid argument')

        Strongdb.run_cmd('set $sgdb_jnienv = ' + argv[0]) 
Example #14
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color code takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.code_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color code highlight subcmd 
Example #15
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color stack-data takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.stack_data_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color code subcmd 
Example #16
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color reg-value-highlight takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.reg_value_highlight_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color address subcmd 
Example #17
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color reg-value takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.reg_value_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color reg-value-highlight subcmd 
Example #18
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color reg-name takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.reg_name_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color reg-value subcmd 
Example #19
Source File: strongdb.py    From strongdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self, args, from_tty):
            argv = gdb.string_to_argv(args)

            if len(argv) != 1:
                raise gdb.GdbError('color border takes 1 arg')

            try:
                Colors.COLORS[argv[0]]
                Colors.border_color = argv[0]
            except KeyError:
                raise gdb.GdbError('invalid argument, see "color list"')

    # color reg-name subcmd 
Example #20
Source File: pwngdb.py    From Pwngdb with GNU General Public License v3.0 5 votes vote down vote up
def invoke(self,args,from_tty):
        self.dont_repeat()
        # Don't eval expression in PwngdbCmd commands
        #expressions = gdb.string_to_argv(args)
        #arg = self.eval_argv(expressions)
        arg = args.split()
        if len(arg) > 0 :
            cmd = arg[0]
            if cmd in pwncmd.commands :
                func = getattr(pwncmd,cmd)
                func(*arg[1:])
            else :
                print("Unknown command")
        else :
            print("Unknown command")

        return 
Example #21
Source File: commands.py    From gxf with MIT License 5 votes vote down vote up
def invoke(self, args, isatty):

        if not self.repeat:
            self.dont_repeat()

        self.parser.set_defaults(isatty=isatty)

        # Not sure we trust gdb to split the line as we want it, but
        # until there are problems we'll let him give it a shot.
        args = gdb.string_to_argv(args)

        try:
            args = self.parser.parse_args(args)
            self.run(args)
        except KeyboardInterrupt as e:
            pass
        except SystemExit as e:
            if isinstance(e.code, int):
                raise gdb.GdbError("command exited with status %s." % e.code)
            elif e.code:
                raise gdb.GdbError(str(e))
        except gdb.GdbError:
            # This type of error can be used to report failure to gdb.
            # We let is pass through so that applications can print errors.
            # Still, the prefered way for an extension to do this
            # would be to simply use exit().
            raise
        except BaseException as e:
            # This is a bug or unexpected circumstance.
            if getattr(args, "isatty", True):
                gxf.errors.show_error(e)
            else:
                raise 
Example #22
Source File: pretty_printers.py    From BinderFilter with MIT License 4 votes vote down vote up
def parse_printer_regexps(arg):
    """Internal utility to parse a pretty-printer command argv.

    Arguments:
        arg: The arguments to the command.  The format is:
             [object-regexp [name-regexp]].
             Individual printers in a collection are named as
             printer-name;subprinter-name.

    Returns:
        The result is a 3-tuple of compiled regular expressions, except that
        the resulting compiled subprinter regexp is None if not provided.

    Raises:
        SyntaxError: an error processing ARG
    """

    argv = gdb.string_to_argv(arg);
    argc = len(argv)
    object_regexp = ""  # match everything
    name_regexp = ""  # match everything
    subname_regexp = None
    if argc > 3:
        raise SyntaxError("too many arguments")
    if argc >= 1:
        object_regexp = argv[0]
    if argc >= 2:
        name_subname = argv[1].split(";", 1)
        name_regexp = name_subname[0]
        if len(name_subname) == 2:
            subname_regexp = name_subname[1]
    # That re.compile raises SyntaxError was determined empirically.
    # We catch it and reraise it to provide a slightly more useful
    # error message for the user.
    try:
        object_re = re.compile(object_regexp)
    except SyntaxError:
        raise SyntaxError("invalid object regexp: %s" % object_regexp)
    try:
        name_re = re.compile (name_regexp)
    except SyntaxError:
        raise SyntaxError("invalid name regexp: %s" % name_regexp)
    if subname_regexp is not None:
        try:
            subname_re = re.compile(subname_regexp)
        except SyntaxError:
            raise SyntaxError("invalid subname regexp: %s" % subname_regexp)
    else:
        subname_re = None
    return(object_re, name_re, subname_re)