Ejemplo n.º 1
0
static int
gdbsim_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
			     int write, struct mem_attrib *attrib,
			     struct target_ops *target)
{
  if (!program_loaded)
    error ("No program loaded.");

  if (sr_get_debug ())
    {
      /* FIXME: Send to something other than STDOUT? */
      printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x");
      gdb_print_host_address (myaddr, gdb_stdout);
      printf_filtered (", memaddr 0x%s, len %d, write %d\n",
		       paddr_nz (memaddr), len, write);
      if (sr_get_debug () && write)
	dump_mem (myaddr, len);
    }

  if (write)
    {
      len = sim_write (gdbsim_desc, memaddr, myaddr, len);
    }
  else
    {
      len = sim_read (gdbsim_desc, memaddr, myaddr, len);
      if (sr_get_debug () && len > 0)
	dump_mem (myaddr, len);
    }
  return len;
}
Ejemplo n.º 2
0
static int
gdbsim_xfer_inferior_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
			     int write, struct mem_attrib *attrib,
			     struct target_ops *target)
{
  /* If no program is running yet, then ignore the simulator for
     memory.  Pass the request down to the next target, hopefully
     an exec file.  */
  if (!target_has_execution)
    return 0;

  if (!program_loaded)
    error (_("No program loaded."));

  if (sr_get_debug ())
    {
      /* FIXME: Send to something other than STDOUT? */
      printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x");
      gdb_print_host_address (myaddr, gdb_stdout);
      printf_filtered (", memaddr 0x%s, len %d, write %d\n",
		       paddr_nz (memaddr), len, write);
      if (sr_get_debug () && write)
	dump_mem (myaddr, len);
    }

  if (write)
    {
      len = sim_write (gdbsim_desc, memaddr, myaddr, len);
    }
  else
    {
      len = sim_read (gdbsim_desc, memaddr, myaddr, len);
      if (sr_get_debug () && len > 0)
	dump_mem (myaddr, len);
    }
  return len;
}
Ejemplo n.º 3
0
void
read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
  sim_read (gdbsim_desc, memaddr, myaddr, len);
}
Ejemplo n.º 4
0
void uartbuf_read(uint8_t buf, void *ptr, uint8_t n) {
	assert(buf == BUF_RXHOST);
	sim_read(ptr, n);
}
Ejemplo n.º 5
0
uint8_t comm_u8(uint8_t buf) {
	assert(buf == BUF_RXHOST);
	uint8_t x;
	sim_read(&x, sizeof(x));
	return x;
}
Ejemplo n.º 6
0
void do_action (unsigned int tp_id, action * current_action, frame_buffer * record_fb)
{
    int size;
    unsigned char * buffer ;
    collect_record * current_collect_record;
    unsigned int base_reg_val;
    unsigned char *registers;

    //point to the lase record in the frame buffer
    if (record_fb==NULL) return;
    if (record_fb->head_record !=NULL)
    {
        current_collect_record =record_fb->head_record;
        while (current_collect_record->next !=NULL)
        {
            current_collect_record = current_collect_record->next;
        }
        current_collect_record->next = (collect_record *) malloc (sizeof (collect_record));
        current_collect_record=current_collect_record->next;
    }
    else
    {
        record_fb->head_record = (collect_record *) malloc (sizeof (collect_record));
        current_collect_record=record_fb->head_record;
    }

    if (current_action!=NULL)
    {
        switch (current_action->type)
        {
        case ACTION_COLLECT :
        {
            switch (current_action->action_data.ca.type)
            {
            case COLLECT_REGISTERS:
            {
                current_collect_record->collect_data= (char *)malloc (current_reg_type->register_bytes);
                fetch_inferior_registers (-1, current_collect_record ->collect_data);
                current_collect_record->collect_data_length=current_reg_type->register_bytes;
                current_collect_record->ca=&(current_action->action_data.ca);
                current_collect_record->next=NULL;
            }
            break;
            case COLLECT_MEMORY:
            {
                current_collect_record->collect_data= (char *)malloc(current_action->action_data.ca.description.mc.length);
                //should be the content of basereg
                if (current_action->action_data.ca.description.mc.base_reg == -1)
                {
                    base_reg_val=0;
                }
                else
                {
                    registers = (unsigned char *)malloc(current_reg_type->register_bytes);

                    fetch_inferior_registers (current_action->action_data.ca.description.mc.base_reg, registers);
                    base_reg_val=registers[current_reg_type->register_byte (current_action->action_data.ca.description.mc.base_reg)];
                    free (registers);

                }
                current_collect_record->collect_data_length=sim_read (base_reg_val+current_action->action_data.ca.description.mc.offset, current_collect_record->collect_data, current_action->action_data.ca.description.mc.length);
                current_collect_record->ca=&(current_action->action_data.ca);
                current_collect_record->next=NULL;
            }
            break;;
            case COLLECT_EXPRESSION :
                ;
            default :
                break;

            }
        }
        break;

        case ACTION_WHILE :
            ;
        default :
            break;

        }
    }
}