Ejemplo n.º 1
0
static SCM
frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior)
{
    frame_smob *f_smob, f_smob_for_lookup;
    SCM f_scm;
    htab_t htab;
    eqable_gdb_smob **slot;
    struct frame_id frame_id = null_frame_id;
    struct gdbarch *gdbarch = NULL;
    int frame_id_is_next = 0;

    /* If we've already created a gsmob for this frame, return it.
       This makes frames eq?-able.  */
    htab = frscm_inferior_frame_map (inferior);
    f_smob_for_lookup.frame_id = get_frame_id (frame);
    f_smob_for_lookup.inferior = inferior;
    slot = gdbscm_find_eqable_gsmob_ptr_slot (htab, &f_smob_for_lookup.base);
    if (*slot != NULL)
        return (*slot)->containing_scm;

    TRY
    {
        /* Try to get the previous frame, to determine if this is the last frame
        in a corrupt stack.  If so, we need to store the frame_id of the next
         frame and not of this one (which is possibly invalid).  */
        if (get_prev_frame (frame) == NULL
        && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
        && get_next_frame (frame) != NULL)
        {
            frame_id = get_frame_id (get_next_frame (frame));
            frame_id_is_next = 1;
        }
        else
        {
            frame_id = get_frame_id (frame);
            frame_id_is_next = 0;
        }
        gdbarch = get_frame_arch (frame);
    }
    CATCH (except, RETURN_MASK_ALL)
    {
        return gdbscm_scm_from_gdb_exception (except);
    }
    END_CATCH

    f_scm = frscm_make_frame_smob ();
    f_smob = (frame_smob *) SCM_SMOB_DATA (f_scm);
    f_smob->frame_id = frame_id;
    f_smob->gdbarch = gdbarch;
    f_smob->inferior = inferior;
    f_smob->frame_id_is_next = frame_id_is_next;

    gdbscm_fill_eqable_gsmob_ptr_slot (slot, &f_smob->base);

    return f_scm;
}
Ejemplo n.º 2
0
static CORE_ADDR
alphanbsd_sigcontext_addr (struct frame_info *frame)
{
  /* FIXME: This is not correct for all versions of NetBSD/alpha.
     We will probably need to disassemble the trampoline to figure
     out which trampoline frame type we have.  */
  if (!get_next_frame (frame))
    return 0;
  return get_frame_base (get_next_frame (frame));
}
Ejemplo n.º 3
0
/*
 *	Set the animation for the model.
 */
void set_model_animation(enum MD3_ANIMATIONS id) {
	struct md3_anim_names_t* inf = NULL;
	struct md3_model_t* m = NULL;
	
	#if 0
	if (id == NO_ANIM) {
		/* turn off animation */
		world_disable_model_animation();
		return;
	}
	#endif
	
	inf = get_animation_by_id(id);
	if (!inf)
		return;
	
	/* body */
	if ((inf->flags & ANIM_BODY) == ANIM_BODY) {
		/* get the model pointer */
		m = world_get_model_by_type(MD3_TORSO);
		
		if (!m)
			return;
		
		m->anim_state.animated = 1;
		m->anim_state.id = inf->id;
		
		/* set starting frame for the animation */
		m->anim_state.frame = g_world->anims[m->anim_state.id].first_frame;
		m->anim_state.next_frame = get_next_frame(&m->anim_state);
	}

	/* legs */
	if ((inf->flags & ANIM_LEGS) == ANIM_LEGS) {
		/* get the model pointer */
		m = world_get_model_by_type(MD3_LEGS);

		if (!m)
			return;

		m->anim_state.animated = 1;
		m->anim_state.id = inf->id;
		
		/* set starting frame for the animation */
		m->anim_state.frame = g_world->anims[m->anim_state.id].first_frame;
		m->anim_state.next_frame = get_next_frame(&m->anim_state);
	}
}
Ejemplo n.º 4
0
static int
record_btrace_tailcall_frame_sniffer (const struct frame_unwind *self,
				      struct frame_info *this_frame,
				      void **this_cache)
{
  const struct btrace_function *bfun, *callee;
  struct btrace_frame_cache *cache;
  struct frame_info *next;

  next = get_next_frame (this_frame);
  if (next == NULL)
    return 0;

  callee = btrace_get_frame_function (next);
  if (callee == NULL)
    return 0;

  if ((callee->flags & BFUN_UP_LINKS_TO_TAILCALL) == 0)
    return 0;

  bfun = callee->up;
  if (bfun == NULL)
    return 0;

  DEBUG ("[frame] sniffed tailcall frame for %s on level %d",
	 btrace_get_bfun_name (bfun), bfun->level);

  /* This is our frame.  Initialize the frame cache.  */
  cache = bfcache_new (this_frame);
  cache->tp = find_thread_ptid (inferior_ptid);
  cache->bfun = bfun;

  *this_cache = cache;
  return 1;
}
static int
tailcall_frame_sniffer (const struct frame_unwind *self,
			 struct frame_info *this_frame, void **this_cache)
{
  struct frame_info *next_frame;
  int next_levels;
  struct tailcall_cache *cache;

  /* Inner tail call element does not make sense for a sentinel frame.  */
  next_frame = get_next_frame (this_frame);
  if (next_frame == NULL)
    return 0;

  cache = cache_find (next_frame);
  if (cache == NULL)
    return 0;

  cache_ref (cache);

  next_levels = existing_next_levels (this_frame, cache);

  /* NEXT_LEVELS is -1 only in dwarf2_tailcall_sniffer_first.  */
  gdb_assert (next_levels >= 0);
  gdb_assert (next_levels <= cache->chain_levels);

  if (next_levels == cache->chain_levels)
    {
      cache_unref (cache);
      return 0;
    }

  *this_cache = cache;
  return 1;
}
Ejemplo n.º 6
0
/*
 *	Update the animation state for the given model.
 */
void world_tick_model(struct md3_model_t* m) {
	double now, elapsed, frame_duration;
	
	if (!m->anim_state.animated)
		/* if we are not in a state of animation t should not change */
		return;

	now = get_time_in_ms();
	elapsed = (now - m->anim_state.last_time);
	frame_duration = (1000.0 / g_world->anims[m->anim_state.id].fps);
	
	#ifdef USE_INTERPOLATION
	if (WORLD_IS_SET(ENGINE_INTERPOLATE))
		m->anim_state.t = (elapsed / frame_duration);
	#endif

	if (elapsed >= frame_duration) {
		/* tick the frame to the next key frame */
		m->anim_state.frame++;
		m->anim_state.frame = m->anim_state.next_frame;
		m->anim_state.next_frame = get_next_frame(&m->anim_state);
		m->anim_state.last_time = now;
		m->anim_state.t = 0;
	}
}
Ejemplo n.º 7
0
static void *mpeg4_loop( void *d )
{
	struct mpeg4_decoder *en = (struct mpeg4_decoder *)d;
	xvid_dec_frame_t xvid_dec_frame;
	xvid_dec_stats_t xvid_dec_stats;
	struct frame *out, *input;
	int used, pos;

	for(;;)
	{
		input = get_next_frame( en->ex, 1 );

		if( en->reset_pending && en->xvid_handle ) mpeg4_stop( en );
		if( ! en->xvid_handle ) mpeg4_start( en, input );

		out = new_frame();
		out->width = en->width;
		out->height = en->height;

		pos = 0;

		while( input->length - pos > 0 )
		{
			memset( &xvid_dec_frame, 0, sizeof( xvid_dec_frame ) );
			xvid_dec_frame.version = XVID_VERSION;
			xvid_dec_frame.general = 0;
			xvid_dec_frame.bitstream = input->d + pos;
			xvid_dec_frame.length = input->length - pos;
			xvid_dec_frame.output.plane[0] = out->d;
			xvid_dec_frame.output.stride[0] = 2 * out->width;
			xvid_dec_frame.output.csp = XVID_CSP_UYVY;
			xvid_dec_stats.version = XVID_VERSION;

			used = xvid_decore( en->xvid_handle, XVID_DEC_DECODE,
					&xvid_dec_frame, &xvid_dec_stats );
			if( used < 0 )
			{
				out->length = 0;
				spook_log( SL_WARN, "mpeg4: XviD decoding failed!" );
			}
			if( xvid_dec_stats.type == XVID_TYPE_VOL )
			{
				out->width = en->width = xvid_dec_stats.data.vol.width;
				out->height = en->height = xvid_dec_stats.data.vol.height;
			}
			pos += used;
		}

		out->format = FORMAT_RAW_UYVY;
		out->length = 2 * out->width * out->height;
		out->key = 1;

		deliver_frame( en->ex, out );

		unref_frame( input );
	}

	return NULL;
}
Ejemplo n.º 8
0
static int
wrap_get_next_frame (char *opaque_arg)
{
  struct gdb_wrapper_arguments **args = (struct gdb_wrapper_arguments **) opaque_arg;
  struct frame_info *fi = (struct frame_info *) (*args)->args[0].ptr;

  (*args)->result.ptr = get_next_frame (fi);
  return 1;
}
Ejemplo n.º 9
0
static CORE_ADDR
alpha_osf1_sigcontext_addr (struct frame_info *frame)
{
  struct frame_info *next_frame = get_next_frame (frame);

  if (next_frame != NULL)
    return (read_memory_integer (get_frame_base (next_frame), 8));
  else
    return (read_memory_integer (get_frame_base (frame), 8));
}
Ejemplo n.º 10
0
static CORE_ADDR
alpha_osf1_sigcontext_addr (struct frame_info *this_frame)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  struct frame_info *next_frame = get_next_frame (this_frame);
  struct frame_id next_id = null_frame_id;
  
  if (next_frame != NULL)
    next_id = get_frame_id (next_frame);

  return (read_memory_integer (next_id.stack_addr, 8, byte_order));
}
Ejemplo n.º 11
0
void Sprite::update() {
	int next_frame;
	uint32_t now = System::now();

	//only check for animation with multiple frames.
	while(!finished && now >= next_frame_date && get_frame_delay() > 0) {
		next_frame = get_next_frame();
	    if(next_frame == -1) {
			this->finished = true;
	    } else {
		    current_frame = next_frame;
			next_frame_date += get_frame_delay();
	    }
	}
}
Ejemplo n.º 12
0
static int
record_btrace_frame_sniffer (const struct frame_unwind *self,
			     struct frame_info *this_frame,
			     void **this_cache)
{
  const struct btrace_function *bfun;
  struct btrace_frame_cache *cache;
  struct thread_info *tp;
  struct frame_info *next;

  /* THIS_FRAME does not contain a reference to its thread.  */
  tp = find_thread_ptid (inferior_ptid);
  gdb_assert (tp != NULL);

  bfun = NULL;
  next = get_next_frame (this_frame);
  if (next == NULL)
    {
      const struct btrace_insn_iterator *replay;

      replay = tp->btrace.replay;
      if (replay != NULL)
	bfun = replay->function;
    }
  else
    {
      const struct btrace_function *callee;

      callee = btrace_get_frame_function (next);
      if (callee != NULL && (callee->flags & BFUN_UP_LINKS_TO_TAILCALL) == 0)
	bfun = callee->up;
    }

  if (bfun == NULL)
    return 0;

  DEBUG ("[frame] sniffed frame for %s on level %d",
	 btrace_get_bfun_name (bfun), bfun->level);

  /* This is our frame.  Initialize the frame cache.  */
  cache = bfcache_new (this_frame);
  cache->tp = tp;
  cache->bfun = bfun;

  *this_cache = cache;
  return 1;
}
Ejemplo n.º 13
0
static void *capture_loop( void *d )
{
	struct rtp_spook_input *conf = (struct rtp_spook_input *)d;
	struct frame *f;
	int status;
    unsigned char buffer[38400];
    int have_more, err, stream_received=0;
    uint32_t ts=0;

    do
    {
		have_more=1;
		while (have_more)
        {
			err=rtp_session_recv_with_ts(conf->session,buffer,sizeof(buffer),ts,&have_more);
			if (err>0) 
			{
                stream_received=1;
			}
			
			if ((stream_received) && (err>0)) 
            {
				if( ( f = get_next_frame( conf->ex, 0 ) ) )
        		{
        			f->length = err;
        			f->format = conf->format;
        			f->width = conf->width;
        			f->height = conf->height;
        			f->key = 1;

        			memcpy( f->d, buffer, err);

        			deliver_frame( conf->ex, f );
					printf("\r\nDeliver packet with length %d", err);
        		} 
                else
        		{
        			spook_log( SL_WARN, "video: dropping frame" );
        		}
			}
		}
		ts+=160;
		//ortp_message("Receiving packet.");
	}while(1);

	return NULL;
}
static void
tailcall_frame_this_id (struct frame_info *this_frame, void **this_cache,
			struct frame_id *this_id)
{
  struct tailcall_cache *cache = *this_cache;
  struct frame_info *next_frame;

  /* Tail call does not make sense for a sentinel frame.  */
  next_frame = get_next_frame (this_frame);
  gdb_assert (next_frame != NULL);

  *this_id = get_frame_id (next_frame);
  (*this_id).code_addr = get_frame_pc (this_frame);
  (*this_id).code_addr_p = 1;
  (*this_id).artificial_depth = (cache->chain_levels
				 - existing_next_levels (this_frame, cache));
  gdb_assert ((*this_id).artificial_depth > 0);
}
static struct tailcall_cache *
cache_find (struct frame_info *fi)
{
  struct tailcall_cache *cache;
  void **slot;

  while (frame_is_tailcall (fi))
    {
      fi = get_next_frame (fi);
      gdb_assert (fi != NULL);
    }

  slot = htab_find_slot (cache_htab, &fi, NO_INSERT);
  if (slot == NULL)
    return NULL;

  cache = *slot;
  gdb_assert (cache != NULL);
  return cache;
}
Ejemplo n.º 16
0
static void *mpeg4_loop( void *d )
{
	struct mpeg4_encoder *en = (struct mpeg4_encoder *)d;
	xvid_enc_frame_t xvid_enc_frame;
	struct frame *mpeg, *input;

	for(;;)
	{
		input = get_next_frame( en->ex, 1 );

		if( en->reset_pending && en->xvid_handle ) mpeg4_stop( en );
		if( ! en->xvid_handle ) mpeg4_start( en, input );

		if( input->width != en->width || input->height != en->height )
		{
			spook_log( SL_WARN,
				"mpeg4: image size changed midstream!" );
			unref_frame( input );
			continue;
		}

		mpeg = new_frame();

		memset( &xvid_enc_frame, 0, sizeof( xvid_enc_frame ) );
		xvid_enc_frame.version = XVID_VERSION;
		xvid_enc_frame.bitstream = mpeg->d;
		xvid_enc_frame.length = -1;
		xvid_enc_frame.input.plane[0] = input->d;
		switch( input->format )
		{
		case FORMAT_RAW_BGR24:
			xvid_enc_frame.input.csp = XVID_CSP_BGR;
			xvid_enc_frame.input.stride[0] = en->width * 3;
			break;
		case FORMAT_RAW_UYVY:
			xvid_enc_frame.input.csp = XVID_CSP_UYVY;
			xvid_enc_frame.input.stride[0] = en->width * 2;
			break;
		}
		xvid_enc_frame.vol_flags = 0;
		xvid_enc_frame.vop_flags = 0;
		xvid_enc_frame.type = XVID_TYPE_AUTO;
		xvid_enc_frame.quant = 0;
		xvid_enc_frame.motion = XVID_ME_ADVANCEDDIAMOND16;
		xvid_enc_frame.quant_intra_matrix = NULL;
		xvid_enc_frame.quant_inter_matrix = NULL;

		mpeg->length = xvid_encore( en->xvid_handle, XVID_ENC_ENCODE,
					&xvid_enc_frame, NULL );
		if( mpeg->length < 0 )
		{
			mpeg->length = 0;
			spook_log( SL_WARN, "mpeg4: XviD encoding failed!" );
		}

		mpeg->format = FORMAT_MPEG4;
		mpeg->width = en->width;
		mpeg->height = en->height;
		mpeg->key = xvid_enc_frame.out_flags & XVID_KEYFRAME;

		deliver_frame( en->ex, mpeg );

		unref_frame( input );
	}

	return NULL;
}
Ejemplo n.º 17
0
/**
 * \brief Checks whether the frame has to be changed.
 *
 * If the frame changes, next_frame_date is updated.
 */
void Sprite::update() {

  Drawable::update();

  if (suspended || paused) {
    return;
  }

  frame_changed = false;
  uint32_t now = System::now();

  // update the current frame
  if (synchronize_to == NULL
      || current_animation_name != synchronize_to->get_current_animation()
      || synchronize_to->get_current_direction() > get_nb_directions()
      || synchronize_to->get_current_frame() > get_nb_frames()) {
    // update the frames normally (with the time)
    int next_frame;
    while (!finished && !suspended && !paused && get_frame_delay() > 0
        && now >= next_frame_date) {

      // we get the next frame
      next_frame = get_next_frame();

      // test whether the animation is finished
      if (next_frame == -1) {
        finished = true;
        if (lua_context != NULL) {
          lua_context->sprite_on_animation_finished(*this, current_animation_name);
        }
      }
      else {
        current_frame = next_frame;
        next_frame_date += get_frame_delay();
      }
      set_frame_changed(true);

      if (lua_context != NULL) {
        lua_context->sprite_on_frame_changed(*this, current_animation_name, current_frame);
      }
    }
  }
  else {
    // take the same frame as the other sprite
    if (synchronize_to->is_animation_finished()) {
      finished = true;
      if (lua_context != NULL) {
        lua_context->sprite_on_animation_finished(*this, current_animation_name);
      }
    }
    else {
      int other_frame = synchronize_to->get_current_frame();
      if (other_frame != current_frame) {
        current_frame = other_frame;
        next_frame_date = now + get_frame_delay();
        set_frame_changed(true);

        if (lua_context != NULL) {
          lua_context->sprite_on_frame_changed(*this, current_animation_name, current_frame);
        }
      }
    }
  }

  // update the special effects
  if (is_blinking()) {
    // the sprite is blinking

    while (now >= blink_next_change_date) {
      blink_is_sprite_visible = !blink_is_sprite_visible;
      blink_next_change_date += blink_delay;
    }
  }
}
Ejemplo n.º 18
0
static CORE_ADDR
mn10300_analyze_prologue (struct frame_info *fi, 
			  void **this_cache, 
			  CORE_ADDR pc)
{
  CORE_ADDR func_addr, func_end, addr, stop;
  long      stack_size;
  int imm_size;
  unsigned char buf[4];
  int status, movm_args = 0;
  char *name;

  /* Use the PC in the frame if it's provided to look up the
     start of this function.

     Note: kevinb/2003-07-16: We used to do the following here:
	pc = (fi ? get_frame_pc (fi) : pc);
     But this is (now) badly broken when called from analyze_dummy_frame().
  */
  if (fi)
    {
      pc = (pc ? pc : get_frame_pc (fi));
      /* At the start of a function our frame is in the stack pointer.  */
      my_frame_is_in_sp (fi, this_cache);
    }

  /* Find the start of this function.  */
  status = find_pc_partial_function (pc, &name, &func_addr, &func_end);

  /* Do nothing if we couldn't find the start of this function 

     MVS: comment went on to say "or if we're stopped at the first
     instruction in the prologue" -- but code doesn't reflect that, 
     and I don't want to do that anyway.  */
  if (status == 0)
    {
      return pc;
    }

  /* If we're in start, then give up.  */
  if (strcmp (name, "start") == 0)
    {
      if (fi != NULL)
	my_frame_is_last (fi);
      return pc;
    }

#if 0
  /* Get the next two bytes into buf, we need two because rets is a two
     byte insn and the first isn't enough to uniquely identify it.  */
  status = deprecated_read_memory_nobpt (pc, buf, 2);
  if (status != 0)
    return pc;

  /* Note: kevinb/2003-07-16: We shouldn't be making these sorts of
     changes to the frame in prologue examination code.  */
  /* If we're physically on an "rets" instruction, then our frame has
     already been deallocated.  Note this can also be true for retf
     and ret if they specify a size of zero.

     In this case fi->frame is bogus, we need to fix it.  */
  if (fi && buf[0] == 0xf0 && buf[1] == 0xfc)
    {
      if (get_next_frame (fi) == NULL)
	deprecated_update_frame_base_hack (fi, read_sp ());
      return get_frame_pc (fi);
    }

  /* Similarly if we're stopped on the first insn of a prologue as our
     frame hasn't been allocated yet.  */
  if (fi && get_frame_pc (fi) == func_addr)
    {
      if (get_next_frame (fi) == NULL)
	deprecated_update_frame_base_hack (fi, read_sp ());
      return get_frame_pc (fi);
    }
#endif

  /* NOTE: from here on, we don't want to return without jumping to
     finish_prologue.  */


  /* Figure out where to stop scanning.  */
  stop = fi ? pc : func_end;

  /* Don't walk off the end of the function.  */
  stop = stop > func_end ? func_end : stop;

  /* Start scanning on the first instruction of this function.  */
  addr = func_addr;

  /* Suck in two bytes.  */
  if (addr + 2 >= stop
      || (status = deprecated_read_memory_nobpt (addr, buf, 2)) != 0)
    goto finish_prologue;

  /* First see if this insn sets the stack pointer from a register; if
     so, it's probably the initialization of the stack pointer in _start,
     so mark this as the bottom-most frame.  */
  if (buf[0] == 0xf2 && (buf[1] & 0xf3) == 0xf0)
    {
      if (fi)
	my_frame_is_last (fi);
      goto finish_prologue;
    }

  /* Now look for movm [regs],sp, which saves the callee saved registers.

     At this time we don't know if fi->frame is valid, so we only note
     that we encountered a movm instruction.  Later, we'll set the entries
     in fsr.regs as needed.  */
  if (buf[0] == 0xcf)
    {
      /* Extract the register list for the movm instruction.  */
      movm_args = buf[1];

      addr += 2;

      /* Quit now if we're beyond the stop point.  */
      if (addr >= stop)
	goto finish_prologue;

      /* Get the next two bytes so the prologue scan can continue.  */
      status = deprecated_read_memory_nobpt (addr, buf, 2);
      if (status != 0)
	goto finish_prologue;
    }

  /* Now see if we set up a frame pointer via "mov sp,a3" */
  if (buf[0] == 0x3f)
    {
      addr += 1;

      /* The frame pointer is now valid.  */
      if (fi)
	{
	  my_frame_is_in_fp (fi, this_cache);
	}

      /* Quit now if we're beyond the stop point.  */
      if (addr >= stop)
	goto finish_prologue;

      /* Get two more bytes so scanning can continue.  */
      status = deprecated_read_memory_nobpt (addr, buf, 2);
      if (status != 0)
	goto finish_prologue;
    }

  /* Next we should allocate the local frame.  No more prologue insns
     are found after allocating the local frame.

     Search for add imm8,sp (0xf8feXX)
     or add imm16,sp (0xfafeXXXX)
     or add imm32,sp (0xfcfeXXXXXXXX).

     If none of the above was found, then this prologue has no 
     additional stack.  */

  imm_size = 0;
  if (buf[0] == 0xf8 && buf[1] == 0xfe)
    imm_size = 1;
  else if (buf[0] == 0xfa && buf[1] == 0xfe)
    imm_size = 2;
  else if (buf[0] == 0xfc && buf[1] == 0xfe)
    imm_size = 4;

  if (imm_size != 0)
    {
      /* Suck in imm_size more bytes, they'll hold the size of the
         current frame.  */
      status = deprecated_read_memory_nobpt (addr + 2, buf, imm_size);
      if (status != 0)
	goto finish_prologue;

      /* Note the size of the stack in the frame info structure.  */
      stack_size = extract_signed_integer (buf, imm_size);
      if (fi)
	set_my_stack_size (fi, stack_size);

      /* We just consumed 2 + imm_size bytes.  */
      addr += 2 + imm_size;

      /* No more prologue insns follow, so begin preparation to return.  */
      goto finish_prologue;
    }
  /* Do the essentials and get out of here.  */
 finish_prologue:
  /* Note if/where callee saved registers were saved.  */
  if (fi)
    set_movm_offsets (fi, this_cache, movm_args);
  return addr;
}