Bug 16797 - GDB for mips-elf target will crash the remote embedded target
Summary: GDB for mips-elf target will crash the remote embedded target
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: tdep (show other bugs)
Version: 7.7
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-02 08:48 UTC by ggs334
Modified: 2022-04-08 02:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ggs334 2014-04-02 08:48:13 UTC
In the function mips-tdep.c:heuristic_pro_start(struct *gdbarch, CORE_ADDR pc)
If the pc value < instlen,
Are we still need to search back for previous return.

static CORE_ADDR
heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
{
  CORE_ADDR start_pc;
  CORE_ADDR fence;
  int instlen;
  int seen_adjsp = 0;
  struct inferior *inf;

  pc = gdbarch_addr_bits_remove (gdbarch, pc);
  start_pc = pc;
  fence = start_pc - heuristic_fence_post;
  if (start_pc == 0)
    return 0;

  if (heuristic_fence_post == UINT_MAX || fence < VM_MIN_ADDRESS)
    fence = VM_MIN_ADDRESS;

  instlen = mips_pc_is_mips (pc) ? MIPS_INSN32_SIZE : MIPS_INSN16_SIZE;

  inf = current_inferior ();

/* Search back for previous return.  */ 
/* if pc (start_pc ) < instlen, the first value of start_pc -= instlen will skip over 0xffffffff, 
In this case, GDB will try to read the memory at string address, which will crash the remote embedded target. 
Is this true ? */
  for (start_pc -= instlen;; start_pc -= instlen)
    if (start_pc < fence)
      {