Ejemplo n.º 1
0
/** Reinstall a breakpoint */
void			e2dbg_breakpoint_reinstall()
{
  elfshbp_t		*bp;
  char			buf[32];
  int			ret;

  /* Test if we need to reinstall a breakpoint */
  snprintf(buf, sizeof(buf), XFMT, e2dbgworld.stoppedthread->past);
  bp = hash_get(&e2dbgworld.bp, buf);
  
  /* Call the architecture dependant hook for putting back the breakpoint */
  if (bp)
    {
      ret = e2dbg_setbreak(bp->obj, bp);
      if (ret < 0)
	{
	  e2dbg_output(" [E] Breakpoint reinsertion failed");
	  return;
	}
      
      //#if __DEBUG_BP__
      fprintf(stderr, " [D] Breakpoint reinserted at " AFMT " ! \n", bp->addr);
      //#endif
      
      e2dbgworld.stoppedthread->past = 0;
    }
  else
    fprintf(stderr, " [D] Breakpoint was deleted from " AFMT " : not reinstalling ! \n",
	    e2dbgworld.stoppedthread->past);
}
Ejemplo n.º 2
0
/*
 * @brief Add a breakpoint 
*/
int		elfsh_bp_add(hash_t	*bps, 
			     elfshobj_t *file, 
			     char	*resolv, 
			     eresi_Addr addr)

{
  static int	lastbpid = 1;
  elfshbp_t	*bp;
  char		tmp[32];
  int		ret;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  if (file == NULL || addr == 0 || bps == 0) 
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		      "Invalid NULL parameter", -1);

  /* Breakpoints handlers must be initialized */
  elfsh_setup_hooks();
  XALLOC(__FILE__, __FUNCTION__, __LINE__,bp , sizeof(elfshbp_t), (-1));
  bp->obj     = file;
  bp->type    = INSTR;
  bp->addr    = addr;
  bp->symname = strdup(resolv);
  snprintf(tmp, 32, XFMT, addr);   
  if (hash_get(bps, tmp))
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		      "Breakpoint already exist", -1);

  /* Call the architecture dependent hook for breakpoints */
  ret = e2dbg_setbreak(file, bp);
  if (ret < 0)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
			"Breakpoint insertion failed", (-1));

  /* Add new breakpoint to hash table */
  bp->id = lastbpid++;
  hash_add(bps, strdup(tmp), bp); 
 
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}