(self)
| 7321 | return any(hex(address) in b for b in bp_locations) |
| 7322 | |
| 7323 | def context_code(self) -> None: |
| 7324 | nb_insn = self["nb_lines_code"] |
| 7325 | nb_insn_prev = self["nb_lines_code_prev"] |
| 7326 | show_opcodes_size = "show_opcodes_size" in self and self["show_opcodes_size"] |
| 7327 | past_insns_color = gef.config["theme.old_context"] |
| 7328 | cur_insn_color = gef.config["theme.disassemble_current_instruction"] |
| 7329 | pc = gef.arch.pc |
| 7330 | breakpoints = gdb.breakpoints() or [] |
| 7331 | bp_locations = [b.location for b in breakpoints if b.location and b.location.startswith("*")] |
| 7332 | |
| 7333 | frame = gdb.selected_frame() |
| 7334 | arch_name = f"{gef.arch.arch.lower()}:{gef.arch.mode}" |
| 7335 | |
| 7336 | self.context_title(f"code:{arch_name}") |
| 7337 | |
| 7338 | try: |
| 7339 | |
| 7340 | |
| 7341 | for insn in self.instruction_iterator(pc, nb_insn, nb_prev=nb_insn_prev): |
| 7342 | line = [] |
| 7343 | is_taken = False |
| 7344 | target = None |
| 7345 | bp_prefix = Color.redify(BP_GLYPH) if self.addr_has_breakpoint(insn.address, bp_locations) else " " |
| 7346 | |
| 7347 | if show_opcodes_size == 0: |
| 7348 | text = str(insn) |
| 7349 | else: |
| 7350 | insn_fmt = f"{{:{show_opcodes_size}o}}" |
| 7351 | text = insn_fmt.format(insn) |
| 7352 | |
| 7353 | if insn.address < pc: |
| 7354 | line += f"{bp_prefix} {Color.colorify(text, past_insns_color)}" |
| 7355 | |
| 7356 | elif insn.address == pc: |
| 7357 | line += f"{bp_prefix}{Color.colorify(f'{RIGHT_ARROW[1:]}{text}', cur_insn_color)}" |
| 7358 | |
| 7359 | if gef.arch.is_conditional_branch(insn): |
| 7360 | is_taken, reason = gef.arch.is_branch_taken(insn) |
| 7361 | if is_taken: |
| 7362 | target = insn.operands[-1].split()[0] |
| 7363 | reason = f"[Reason: {reason}]" if reason else "" |
| 7364 | line += Color.colorify(f"\tTAKEN {reason}", "bold green") |
| 7365 | else: |
| 7366 | reason = f"[Reason: !({reason})]" if reason else "" |
| 7367 | line += Color.colorify(f"\tNOT taken {reason}", "bold red") |
| 7368 | elif gef.arch.is_call(insn) and self["peek_calls"] is True: |
| 7369 | target = insn.operands[-1].split()[0] |
| 7370 | elif gef.arch.is_ret(insn) and self["peek_ret"] is True: |
| 7371 | target = gef.arch.get_ra(insn, frame) |
| 7372 | |
| 7373 | else: |
| 7374 | line += f"{bp_prefix} {text}" |
| 7375 | |
| 7376 | gef_print("".join(line)) |
| 7377 | |
| 7378 | if target: |
| 7379 | try: |
| 7380 | address = int(target, 0) if isinstance(target, str) else target |
nothing calls this directly
no test coverage detected