Skip to content

Commit

Permalink
Support breakpoint.locations (#1068)
Browse files Browse the repository at this point in the history
If gdb is recent enough this patch uses `breakpoint.locations` to
extract directly the address at which the breakpoints are set instead of
parsing the command used by the user.
  • Loading branch information
Angelo942 committed Feb 23, 2024
1 parent 0fca698 commit cdaf158
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -7619,7 +7619,12 @@ def context_code(self) -> None:
cur_insn_color = gef.config["theme.disassemble_current_instruction"]
pc = gef.arch.pc
breakpoints = gdb.breakpoints() or []
bp_locations = [b.location for b in breakpoints if b.location and b.location.startswith("*")]
# breakpoint.locations was introduced in gdb 13.1
if len(breakpoints) and hasattr(breakpoints[-1], "locations"):
bp_locations = [hex(location.address) for b in breakpoints for location in b.locations if location is not None]
else:
# location relies on the user setting the breakpoints with "b *{hex(address)}"
bp_locations = [b.location for b in breakpoints if b.location and b.location.startswith("*")]

frame = gdb.selected_frame()
arch_name = f"{gef.arch.arch.lower()}:{gef.arch.mode}"
Expand Down

0 comments on commit cdaf158

Please sign in to comment.