Esempio n. 1
0
    def iter_def(self, inpipe):
        if not inpipe:
            yield from (as_voidptr(gdb.Value(ele))
                        for ele in self.called_funcs_class.hypothetical_stack)
            return

        for _ in inpipe:
            yield from (as_voidptr(gdb.Value(ele))
                        for ele in self.called_funcs_class.hypothetical_stack)
Esempio n. 2
0
 def iter_def(self, inpipe):
     for symbol in search_symbols(self.func_regexp, self.file_regexp,
                                  self.include_dynlibs):
         # TODO For some very strange reason, assigning a symbol.value()
         # this to a convenience variable ends up with the convenience
         # variable set to NULL.
         # Hence passing this across as a voidptr.
         yield as_voidptr(symbol.value())
Esempio n. 3
0
    def iter_def(self, inpipe):
        if not inpipe:
            self.__add_addr(eval_uint(self.start_expr), 0)
            yield from self.__iter_helper()
            return

        # Deal with each given function (and all their descendants) in turn.
        for element in inpipe:
            type(self).hypothetical_stack = []
            self.__add_addr(
                int(as_voidptr(self.eval_command(element, self.start_expr))),
                0)
            yield from self.__iter_helper()
Esempio n. 4
0
    def __iter_helper(self):
        '''
        Iterate over all instructions in a function, put each `call`
        instruction on a stack.

        Continue until no more functions are found, or until `maxdepth` is
        exceeded.

        Skip any recursion by ignoring any functions already in the
        hypothetical stack we have built up.

        '''
        while self.func_stack:
            func_addr, depth = self.func_stack.pop()
            if self.maxdepth >= 0 and depth > self.maxdepth:
                continue

            # If func_dis is None no debugging info was found for this function
            # and the user required filtering by filename (which we don't know
            # without debugging info) -- hence ignore this.
            func_dis, _, fname = function_disassembly(func_addr, self.arch,
                                                      self.dont_fallback)
            if not func_dis or not re.match(self.file_regexp,
                                            '' if not fname else fname):
                continue

            # Store the current value in the hypothetical_stack for someone
            # else to query - remember to set the class attribute.
            type(self).hypothetical_stack[depth:] = [func_addr]
            yield as_voidptr(gdb.Value(func_addr))

            # Go backwards through the list so that we pop off elements in the
            # order they will be called.
            for val in func_dis[::-1]:
                new_addr = self.__func_addr(val)
                self.__add_addr(new_addr, depth + 1)
Esempio n. 5
0
 def iter_helper(self, start, end, count):
     start, end, count = (int(as_voidptr(x)) for x in (start, end, count))
     for instruction in self.disass(start, end, count):
         temp = gdb.Value(instruction['addr'])
         yield as_voidptr(temp)
Esempio n. 6
0
 def iter_def(self, inpipe):
     for filename in self.filenames:
         with open(filename, 'r') as infile:
             for line in infile:
                 yield as_voidptr(gdb.Value(int(line, base=16)))