static void
kgdb_thr_add_procs(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int))
{
	struct gdbarch *gdbarch = target_gdbarch ();
	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
	enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
	struct kthr *kt;
	CORE_ADDR pcb, pnext, tdaddr, tdnext;
	ULONGEST oncpu;
	LONGEST pid, tid;

	while (paddr != 0) {
		TRY {
			tdaddr = read_memory_typed_address (paddr +
			    proc_off_p_threads, ptr_type);
			pid = read_memory_integer (paddr + proc_off_p_pid, 4,
			    byte_order);
			pnext = read_memory_typed_address (paddr +
			    proc_off_p_list, ptr_type);
		} CATCH(e, RETURN_MASK_ERROR) {
			break;
		} END_CATCH
		while (tdaddr != 0) {
			TRY {
				tid = read_memory_integer (tdaddr +
				    thread_off_td_tid, 4, byte_order);
				oncpu = read_memory_unsigned_integer (tdaddr +
				    thread_off_td_oncpu, thread_oncpu_size,
				    byte_order);
				pcb = read_memory_typed_address (tdaddr +
				    thread_off_td_pcb, ptr_type);
				tdnext = read_memory_typed_address (tdaddr +
				    thread_off_td_plist, ptr_type);
			} CATCH(e, RETURN_MASK_ERROR) {
				break;
			} END_CATCH
			kt = malloc(sizeof(*kt));
			kt->next = first;
			kt->kaddr = tdaddr;
			if (tid == dumptid)
				kt->pcb = dumppcb;
			else if (cpu_stopped(oncpu))
				kt->pcb = cpu_pcb_addr(oncpu);
			else
				kt->pcb = pcb;
			kt->tid = tid;
			kt->pid = pid;
			kt->paddr = paddr;
			kt->cpu = oncpu;
			first = kt;
			tdaddr = tdnext;
		}
		paddr = pnext;
	}
}
Exemple #2
0
int
f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
{
  CORE_ADDR current_frame_addr;
  CORE_ADDR ptr_to_lower_bound;

  switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
    {
    case BOUND_BY_VALUE_ON_STACK:
      current_frame_addr = get_frame_base (deprecated_selected_frame);
      if (current_frame_addr > 0)
	{
	  *lower_bound =
	    read_memory_integer (current_frame_addr +
				 TYPE_ARRAY_LOWER_BOUND_VALUE (type),
				 4);
	}
      else
	{
	  *lower_bound = DEFAULT_LOWER_BOUND;
	  return BOUND_FETCH_ERROR;
	}
      break;

    case BOUND_SIMPLE:
      *lower_bound = TYPE_ARRAY_LOWER_BOUND_VALUE (type);
      break;

    case BOUND_CANNOT_BE_DETERMINED:
      error ("Lower bound may not be '*' in F77");
      break;

    case BOUND_BY_REF_ON_STACK:
      current_frame_addr = get_frame_base (deprecated_selected_frame);
      if (current_frame_addr > 0)
	{
	  ptr_to_lower_bound =
	    read_memory_typed_address (current_frame_addr +
				       TYPE_ARRAY_LOWER_BOUND_VALUE (type),
				       builtin_type_void_data_ptr);
	  *lower_bound = read_memory_integer (ptr_to_lower_bound, 4);
	}
      else
	{
	  *lower_bound = DEFAULT_LOWER_BOUND;
	  return BOUND_FETCH_ERROR;
	}
      break;

    case BOUND_BY_REF_IN_REG:
    case BOUND_BY_VALUE_IN_REG:
    default:
      error ("??? unhandled dynamic array bound type ???");
      break;
    }
  return BOUND_FETCH_OK;
}
struct kthr *
kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int))
{
	struct gdbarch *gdbarch = target_gdbarch ();
	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
	enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
	struct kthr *kt;
	CORE_ADDR addr, paddr;
	
	while (first != NULL) {
		kt = first;
		first = kt->next;
		free(kt);
	}

	addr = kgdb_lookup("allproc");
	if (addr == 0)
		return (NULL);
	TRY {
		paddr = read_memory_typed_address (addr, ptr_type);
	} CATCH(e, RETURN_MASK_ERROR) {
		return (NULL);
	} END_CATCH

	dumppcb = kgdb_lookup("dumppcb");
	if (dumppcb == 0)
		return (NULL);

#if 1
	TRY {
		dumptid = parse_and_eval_long("dumptid");
	} CATCH(e, RETURN_MASK_ERROR) {
		dumptid = -1;
	} END_CATCH
#else
	addr = kgdb_lookup("dumptid");
	if (addr != 0) {
		TRY {
			dumptid = read_memory_integer (addr, 4, byte_order);
		} CATCH(e, RETURN_MASK_ERROR) {
			dumptid = -1;
		} END_CATCH
	} else
Exemple #4
0
int
f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
{
  CORE_ADDR current_frame_addr = 0;
  CORE_ADDR ptr_to_upper_bound;

  switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
    {
    case BOUND_BY_VALUE_ON_STACK:
      current_frame_addr = get_frame_base (deprecated_selected_frame);
      if (current_frame_addr > 0)
	{
	  *upper_bound =
	    read_memory_integer (current_frame_addr +
				 TYPE_ARRAY_UPPER_BOUND_VALUE (type),
				 4);
	}
      else
	{
	  *upper_bound = DEFAULT_UPPER_BOUND;
	  return BOUND_FETCH_ERROR;
	}
      break;

    case BOUND_SIMPLE:
      *upper_bound = TYPE_ARRAY_UPPER_BOUND_VALUE (type);
      break;

    case BOUND_CANNOT_BE_DETERMINED:
      /* we have an assumed size array on our hands. Assume that 
         upper_bound == lower_bound so that we show at least 
         1 element.If the user wants to see more elements, let 
         him manually ask for 'em and we'll subscript the 
         array and show him */
      f77_get_dynamic_lowerbound (type, upper_bound);
      break;

    case BOUND_BY_REF_ON_STACK:
      current_frame_addr = get_frame_base (deprecated_selected_frame);
      if (current_frame_addr > 0)
	{
	  ptr_to_upper_bound =
	    read_memory_typed_address (current_frame_addr +
				       TYPE_ARRAY_UPPER_BOUND_VALUE (type),
				       builtin_type_void_data_ptr);
	  *upper_bound = read_memory_integer (ptr_to_upper_bound, 4);
	}
      else
	{
	  *upper_bound = DEFAULT_UPPER_BOUND;
	  return BOUND_FETCH_ERROR;
	}
      break;

    case BOUND_BY_REF_IN_REG:
    case BOUND_BY_VALUE_IN_REG:
    default:
      error ("??? unhandled dynamic array bound type ???");
      break;
    }
  return BOUND_FETCH_OK;
}