Beispiel #1
0
 def str_chunk_size_flag(self):
     msg = []
     msg.append("PREV_INUSE flag: {}".format(
         Color.greenify("On") if self.has_p_bit() else Color.redify("Off")))
     msg.append("IS_MMAPPED flag: {}".format(
         Color.greenify("On") if self.has_m_bit() else Color.redify("Off")))
     msg.append("NON_MAIN_ARENA flag: {}".format(
         Color.greenify("On") if self.has_n_bit() else Color.redify("Off")))
     return "\n".join(msg)
Beispiel #2
0
    def context_trace(self):
        self.context_title("trace")

        nb_backtrace = self.get_setting("nb_lines_backtrace")
        if nb_backtrace <= 0:
            return None
        orig_frame = current_frame = gdb.selected_frame()
        i = 0

        # backward compat for gdb (gdb < 7.10)
        if not hasattr(gdb, "FrameDecorator"):
            gdb.execute("backtrace {:d}".format(nb_backtrace))
            return None

        while current_frame:
            current_frame.select()
            if not current_frame.is_valid():
                continue

            pc = current_frame.pc()
            name = current_frame.name()
            items = []
            items.append("{:#x}".format(pc))
            if name:
                frame_args = gdb.FrameDecorator.FrameDecorator(
                    current_frame).frame_args() or []
                m = "{}({})".format(
                    Color.greenify(name), ", ".join([
                        "{}={!s}".format(Color.yellowify(x.sym),
                                         x.sym.value(current_frame))
                        for x in frame_args
                    ]))
                items.append(m)
            else:
                try:
                    insn = next(disass.gef_disassemble(pc, 1))
                except gdb.MemoryError:
                    break
                items.append(
                    Color.redify("{} {}".format(insn.mnemonic,
                                                ", ".join(insn.operands))))

            print("[{}] {}".format(
                Color.colorify("#{}".format(i), "bold pink"),
                config_arrow_right.join(items)))
            current_frame = current_frame.older()
            i += 1
            nb_backtrace -= 1
            if nb_backtrace == 0:
                break

        orig_frame.select()
        return None