Skip to content

[GDB] The breakpoint "kind" should be meaningful #42

@shahab-vahedi

Description

@shahab-vahedi

In GDB and GDBserver code, we have target hooks that need a breakpoint kind to figure what to do:

gdbserver/linux-arc-low.cc
arc_target::sw_breakpoint_from_kind (int kind, int *size)

gdb/arc-tdep.c
arc_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
arc_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)

gdb/arc-linux-tdep.c
arc_linux_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
arc_linux_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)

However, looking at the implementation of these codes, it becomes obvious that we are piggy backing the breakpoint size through the kind. This is at best confusing.

The correct way to handle this is to have an enum and a map to resolve the problem:

enum arc_breakpoint_types {
  ARC_TRAP_S,
  ARC_BRK_S,
  ...
}

std::map<arc_breakpoint_types, uint8_t> = {
  {ARC_TRAP_S, 2},
  {ARC_BRK_S, 2},
   ...
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions