Exemplo n.º 1
0
static int
gdb_regformat (ClientData clientData, Tcl_Interp *interp,
	       int objc, Tcl_Obj **objv)
{
  int fm, regno, numregs;
  struct type *type;

  if (objc != 3)
    {
      Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo regno type format");
      return TCL_ERROR;
    }

  if (Tcl_GetIntFromObj (interp, objv[0], &regno) != TCL_OK)
    return TCL_ERROR;

  type = (struct type *)strtol (Tcl_GetStringFromObj (objv[1], NULL), NULL, 16);  
  fm = (int)*(Tcl_GetStringFromObj (objv[2], NULL));

  numregs = (gdbarch_num_regs (get_current_arch ())
	     + gdbarch_num_pseudo_regs (get_current_arch ()));
  if (regno >= numregs)
    {
      gdbtk_set_result (interp, "Register number %d too large", regno);
      return TCL_ERROR;
    }
  
  regformat[regno] = fm;
  regtype[regno] = type;

  return TCL_OK;
}
Exemplo n.º 2
0
static int
map_arg_registers (Tcl_Interp *interp, int objc, Tcl_Obj **objv,
		   map_func func, map_arg arg)
{
  int regnum, numregs;

  /* Note that the test for a valid register must include checking the
     gdbarch_register_name because gdbarch_num_regs may be allocated for
     the union of the register sets within a family of related processors.
     In this case, some entries of gdbarch_register_name will change
     depending upon the particular processor being debugged.  */

  numregs = (gdbarch_num_regs (get_current_arch ())
	     + gdbarch_num_pseudo_regs (get_current_arch ()));

  if (objc == 0)		/* No args, just do all the regs */
    {
      result_ptr->flags |= GDBTK_MAKES_LIST;
      for (regnum = 0; regnum < numregs; regnum++)
	{
	  if (gdbarch_register_name (get_current_arch (), regnum) == NULL
	      || *(gdbarch_register_name (get_current_arch (), regnum)) == '\0')
	    continue;
	  func (regnum, arg);
	}      
      return TCL_OK;
    }

  if (objc == 1)
    if (Tcl_ListObjGetElements (interp, *objv, &objc, &objv ) != TCL_OK)
      return TCL_ERROR;

  if (objc > 1)
    result_ptr->flags |= GDBTK_MAKES_LIST;

  /* Else, list of register #s, just do listed regs */
  for (; objc > 0; objc--, objv++)
    {
      if (Tcl_GetIntFromObj (NULL, *objv, &regnum) != TCL_OK)
	{
	  result_ptr->flags |= GDBTK_IN_TCL_RESULT;
	  return TCL_ERROR;
	}

      if (regnum >= 0  && regnum < numregs)
	func (regnum, arg);
      else
	{
	  Tcl_SetStringObj (result_ptr->obj_ptr, "bad register number", -1);
	  return TCL_ERROR;
	}
    }
  return TCL_OK;
}
Exemplo n.º 3
0
static void
setup_architecture_data ()
{
  int numregs;

  xfree (old_regs);
  xfree (regformat);
  xfree (regtype);

  numregs = (gdbarch_num_regs (get_current_arch ())
	     + gdbarch_num_pseudo_regs (get_current_arch ()));
  old_regs = xcalloc (1, numregs * MAX_REGISTER_SIZE + 1);
  regformat = (int *)xcalloc (numregs, sizeof(int));
  regtype = (struct type **)xcalloc (numregs, sizeof(struct type **));
}
Exemplo n.º 4
0
Arquivo: tui-layout.c Projeto: 5kg/gdb
static void
extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
  enum tui_layout_type cur_layout = tui_current_layout ();
  struct gdbarch *gdbarch = get_current_arch ();
  CORE_ADDR addr;
  CORE_ADDR pc;
  struct symtab_and_line cursal = get_current_source_symtab_and_line ();

  switch (cur_layout)
    {
    case SRC_COMMAND:
    case SRC_DATA_COMMAND:
      gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
      find_line_pc (cursal.symtab,
		    TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
		    &pc);
      addr = pc;
      break;
    case DISASSEM_COMMAND:
    case SRC_DISASSEM_COMMAND:
    case DISASSEM_DATA_COMMAND:
      gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
      addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
      break;
    default:
      addr = 0;
      break;
    }

  *gdbarch_p = gdbarch;
  *addr_p = addr;
}
Exemplo n.º 5
0
static void
get_register_size (int regnum, map_arg arg)
{
  Tcl_ListObjAppendElement (gdbtk_interp, result_ptr->obj_ptr,
			    Tcl_NewIntObj (register_size (get_current_arch (),
							  regnum)));
}
Exemplo n.º 6
0
Arquivo: python.c Projeto: ILyoan/gdb
static void
python_command (char *arg, int from_tty)
{
  struct cleanup *cleanup;

  cleanup = ensure_python_env (get_current_arch (), current_language);

  make_cleanup_restore_integer (&interpreter_async);
  interpreter_async = 0;

  while (arg && *arg && isspace (*arg))
    ++arg;
  if (arg && *arg)
    {
      if (PyRun_SimpleString (arg))
	error (_("Error while executing Python code."));
    }
  else
    {
      struct command_line *l = get_command_line (python_control, "");

      make_cleanup_free_command_lines (&l);
      execute_control_command_untraced (l);
    }

  do_cleanups (cleanup);
}
Exemplo n.º 7
0
Arquivo: charset.c Projeto: abidh/gdb
/* This is the sfunc for the 'set charset' command.  */
static void
set_charset_sfunc (char *charset, int from_tty, 
		   struct cmd_list_element *c)
{
  /* CAREFUL: set the target charset here as well.  */
  target_charset_name = host_charset_name;
  validate (get_current_arch ());
}
Exemplo n.º 8
0
void
mi_cmd_catch_assert (char *cmd, char *argv[], int argc)
{
  struct gdbarch *gdbarch = get_current_arch();
  char *condition = NULL;
  int enabled = 1;
  int temp = 0;

  int oind = 0;
  char *oarg;

  enum opt
    {
      OPT_CONDITION, OPT_DISABLED, OPT_TEMP,
    };
  static const struct mi_opt opts[] =
    {
      { "c", OPT_CONDITION, 1},
      { "d", OPT_DISABLED, 0 },
      { "t", OPT_TEMP, 0 },
      { 0, 0, 0 }
    };

  for (;;)
    {
      int opt = mi_getopt ("-catch-assert", argc, argv, opts,
			   &oind, &oarg);

      if (opt < 0)
        break;

      switch ((enum opt) opt)
        {
	case OPT_CONDITION:
	  condition = oarg;
	  break;
	case OPT_DISABLED:
	  enabled = 0;
	  break;
	case OPT_TEMP:
	  temp = 1;
	  break;
        }
    }

  /* This command does not accept any argument.  Make sure the user
     did not provide any.  */
  if (oind != argc)
    error (_("Invalid argument: %s"), argv[oind]);

  setup_breakpoint_reporting ();
  /* create_ada_exception_catchpoint needs CONDITION to be xstrdup'ed,
     and will assume control of its lifetime.  */
  if (condition != NULL)
    condition = xstrdup (condition);
  create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
				   NULL, condition, temp, enabled, 0);
}
Exemplo n.º 9
0
static SCM
vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name)
{
  struct gdbarch *gdbarch = get_current_arch ();
  const struct language_defn *language = current_language;
  struct value *arg1;
  SCM result = SCM_BOOL_F;
  struct value *res_val = NULL;
  SCM except_scm;
  struct cleanup *cleanups;

  cleanups = make_cleanup_value_free_to_mark (value_mark ());

  arg1 = vlscm_convert_value_from_scheme (func_name, SCM_ARG1, x,
					  &except_scm, gdbarch, language);
  if (arg1 == NULL)
    {
      do_cleanups (cleanups);
      gdbscm_throw (except_scm);
    }

  TRY
    {
      switch (opcode)
	{
	case VALSCM_NOT:
	  /* Alas gdb and guile use the opposite meaning for "logical not".  */
	  {
	    struct type *type = language_bool_type (language, gdbarch);
	    res_val
	      = value_from_longest (type, (LONGEST) value_logical_not (arg1));
	  }
	  break;
	case VALSCM_NEG:
	  res_val = value_neg (arg1);
	  break;
	case VALSCM_NOP:
	  /* Seemingly a no-op, but if X was a Scheme value it is now
	     a <gdb:value> object.  */
	  res_val = arg1;
	  break;
	case VALSCM_ABS:
	  if (value_less (arg1, value_zero (value_type (arg1), not_lval)))
	    res_val = value_neg (arg1);
	  else
	    res_val = arg1;
	  break;
	case VALSCM_LOGNOT:
	  res_val = value_complement (arg1);
	  break;
	default:
	  gdb_assert_not_reached ("unsupported operation");
	}
    }
  CATCH (except, RETURN_MASK_ALL)
    {
      GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
    }
Exemplo n.º 10
0
Arquivo: corelow.c Projeto: Xilinx/gdb
static void
core_info_proc (struct target_ops *ops, char *args, enum info_proc_what request)
{
  struct gdbarch *gdbarch = get_current_arch ();

  /* Since this is the core file target, call the 'core_info_proc'
     method on gdbarch, not 'info_proc'.  */
  if (gdbarch_core_info_proc_p (gdbarch))
    gdbarch_core_info_proc (gdbarch, args, request);
}
Exemplo n.º 11
0
static void
register_changed_p (int regnum, map_arg arg)
{
  char raw_buffer[MAX_REGISTER_SIZE];

  if (!target_has_registers
      || !frame_register_read (get_selected_frame (NULL), regnum, raw_buffer))
    return;

  if (memcmp (&old_regs[regnum * MAX_REGISTER_SIZE], raw_buffer,
	      register_size (get_current_arch (), regnum)) == 0)
    return;

  /* Found a changed register.  Save new value and return its number. */

  memcpy (&old_regs[regnum * MAX_REGISTER_SIZE], raw_buffer,
	  register_size (get_current_arch (), regnum));

  Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, Tcl_NewIntObj (regnum));
}
Exemplo n.º 12
0
void
mi_cmd_catch_assert (const char *cmd, char *argv[], int argc)
{
  struct gdbarch *gdbarch = get_current_arch();
  std::string condition;
  int enabled = 1;
  int temp = 0;

  int oind = 0;
  char *oarg;

  enum opt
    {
      OPT_CONDITION, OPT_DISABLED, OPT_TEMP,
    };
  static const struct mi_opt opts[] =
    {
      { "c", OPT_CONDITION, 1},
      { "d", OPT_DISABLED, 0 },
      { "t", OPT_TEMP, 0 },
      { 0, 0, 0 }
    };

  for (;;)
    {
      int opt = mi_getopt ("-catch-assert", argc, argv, opts,
			   &oind, &oarg);

      if (opt < 0)
        break;

      switch ((enum opt) opt)
        {
	case OPT_CONDITION:
	  condition.assign (oarg);
	  break;
	case OPT_DISABLED:
	  enabled = 0;
	  break;
	case OPT_TEMP:
	  temp = 1;
	  break;
        }
    }

  /* This command does not accept any argument.  Make sure the user
     did not provide any.  */
  if (oind != argc)
    error (_("Invalid argument: %s"), argv[oind]);

  scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
  create_ada_exception_catchpoint (gdbarch, ada_catch_assert, std::string (),
				   condition, temp, enabled, 0);
}
Exemplo n.º 13
0
static int
gdb_reggroup (ClientData clientData, Tcl_Interp *interp,
	      int objc, Tcl_Obj **objv)
{
  struct reggroup *group;
  char *groupname;
  int regnum, num;

  if (objc != 1)
    {
      Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo group groupname");
      return TCL_ERROR;
    }
  
  groupname = Tcl_GetStringFromObj (objv[0], NULL);
  if (groupname == NULL)
    {
      gdbtk_set_result (interp, "could not read groupname");
      return TCL_ERROR;
    }

  for (group = reggroup_next (get_current_arch (), NULL);
       group != NULL;
       group = reggroup_next (get_current_arch (), group))
    {
      if (strcmp (groupname, reggroup_name (group)) == 0)
	break;
    }

  if (group == NULL)
    return TCL_ERROR;

  num = (gdbarch_num_regs (get_current_arch ())
	 + gdbarch_num_pseudo_regs (get_current_arch ()));
  for (regnum = 0; regnum < num; regnum++)
    {
      if (gdbarch_register_reggroup_p (get_current_arch (), regnum, group))
	Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, Tcl_NewIntObj (regnum));
    }
  return TCL_OK;
}
Exemplo n.º 14
0
static void
py_free_pspace (struct program_space *pspace, void *datum)
{
  struct cleanup *cleanup;
  pspace_object *object = datum;
  struct gdbarch *arch = get_current_arch ();

  cleanup = ensure_python_env (arch, current_language);
  object->pspace = NULL;
  Py_DECREF ((PyObject *) object);
  do_cleanups (cleanup);
}
Exemplo n.º 15
0
static void
show_architecture (struct ui_file *file, int from_tty,
		   struct cmd_list_element *c, const char *value)
{
  if (target_architecture_user == NULL)
    fprintf_filtered (file, _("The target architecture is set "
			      "automatically (currently %s)\n"),
		      gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
  else
    fprintf_filtered (file, _("The target architecture is assumed to be %s\n"),
		      set_architecture_string);
}
Exemplo n.º 16
0
bool
core_target::info_proc (const char *args, enum info_proc_what request)
{
  struct gdbarch *gdbarch = get_current_arch ();

  /* Since this is the core file target, call the 'core_info_proc'
     method on gdbarch, not 'info_proc'.  */
  if (gdbarch_core_info_proc_p (gdbarch))
    gdbarch_core_info_proc (gdbarch, args, request);

  return true;
}
Exemplo n.º 17
0
static SCM
gdbscm_register_breakpoint_x (SCM self)
{
    breakpoint_smob *bp_smob
        = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
    volatile struct gdb_exception except;

    /* We only support registering breakpoints created with make-breakpoint.  */
    if (!bp_smob->is_scheme_bkpt)
        scm_misc_error (FUNC_NAME, _("not a Scheme breakpoint"), SCM_EOL);

    if (bpscm_is_valid (bp_smob))
        scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL);

    pending_breakpoint_scm = self;

    TRY_CATCH (except, RETURN_MASK_ALL)
    {
        char *location = bp_smob->spec.location;
        int internal = bp_smob->spec.is_internal;

        switch (bp_smob->spec.type)
        {
        case bp_breakpoint:
        {
            create_breakpoint (get_current_arch (),
                               location, NULL, -1, NULL,
                               0,
                               0, bp_breakpoint,
                               0,
                               AUTO_BOOLEAN_TRUE,
                               &bkpt_breakpoint_ops,
                               0, 1, internal, 0);
            break;
        }
        case bp_watchpoint:
        {
            enum target_hw_bp_type access_type = bp_smob->spec.access_type;

            if (access_type == hw_write)
                watch_command_wrapper (location, 0, internal);
            else if (access_type == hw_access)
                awatch_command_wrapper (location, 0, internal);
            else if (access_type == hw_read)
                rwatch_command_wrapper (location, 0, internal);
            else
                gdb_assert_not_reached ("invalid access type");
            break;
        }
        default:
            gdb_assert_not_reached ("invalid breakpoint type");
        }
    }
Exemplo n.º 18
0
Arquivo: charset.c Projeto: abidh/gdb
static void
show_target_charset_name (struct ui_file *file, int from_tty,
			  struct cmd_list_element *c, const char *value)
{
  if (!strcmp (value, "auto"))
    fprintf_filtered (file,
		      _("The target character set is \"auto; "
		        "currently %s\".\n"),
		      gdbarch_auto_charset (get_current_arch ()));
  else
    fprintf_filtered (file, _("The target character set is \"%s\".\n"),
		      value);
}
Exemplo n.º 19
0
static int
gdb_reggrouplist (ClientData clientData, Tcl_Interp *interp,
		  int objc, Tcl_Obj **objv)
{
  struct reggroup *group;
  int i = 0;

  if (objc != 0)
    {
      Tcl_WrongNumArgs (interp, 0, objv, "gdb_reginfo grouplist");
      return TCL_ERROR;
    }

  for (group = reggroup_next (get_current_arch (), NULL);
       group != NULL;
       group = reggroup_next (get_current_arch (), group))
    {
      if (reggroup_type (group) == USER_REGGROUP)
	Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, Tcl_NewStringObj (reggroup_name (group), -1));
    }
  return TCL_OK;
}
Exemplo n.º 20
0
static void
get_register_types (int regnum, map_arg arg)
{ 
  struct type *reg_vtype;
  int i,n;

  reg_vtype = register_type (get_current_arch (), regnum);
  
  if (TYPE_CODE (reg_vtype) == TYPE_CODE_UNION)
    {
      n = TYPE_NFIELDS (reg_vtype);
      /* limit to 16 types */
      if (n > 16) 
	n = 16;
      
      for (i = 0; i < n; i++)
	{
	  Tcl_Obj *ar[3], *list;
	  char *buff;
	  buff = xstrprintf ("%lx", (long)TYPE_FIELD_TYPE (reg_vtype, i));
	  ar[0] = Tcl_NewStringObj (TYPE_FIELD_NAME (reg_vtype, i), -1);
	  ar[1] = Tcl_NewStringObj (buff, -1);
	  if (TYPE_CODE (TYPE_FIELD_TYPE (reg_vtype, i)) == TYPE_CODE_FLT)
	    ar[2] = Tcl_NewStringObj ("float", -1);
	  else
	    ar[2] = Tcl_NewStringObj ("int", -1);	    
	  list = Tcl_NewListObj (3, ar);
	  Tcl_ListObjAppendElement (gdbtk_interp, result_ptr->obj_ptr, list);
	  xfree (buff);
	}
    }
  else
    {
      Tcl_Obj *ar[3], *list;
      char *buff;
      buff = xstrprintf ("%lx", (long)reg_vtype);
      ar[0] = Tcl_NewStringObj (TYPE_NAME(reg_vtype), -1);
      ar[1] = Tcl_NewStringObj (buff, -1);
      if (TYPE_CODE (reg_vtype) == TYPE_CODE_FLT)
	ar[2] = Tcl_NewStringObj ("float", -1);
      else
	ar[2] = Tcl_NewStringObj ("int", -1);	    
      list = Tcl_NewListObj (3, ar);
      xfree (buff);
      Tcl_ListObjAppendElement (gdbtk_interp, result_ptr->obj_ptr, list);
    }
}
Exemplo n.º 21
0
void
mi_cmd_info_ada_exceptions (char *command, char **argv, int argc)
{
  struct ui_out *uiout = current_uiout;
  struct gdbarch *gdbarch = get_current_arch ();
  char *regexp;
  struct cleanup *old_chain;
  VEC(ada_exc_info) *exceptions;
  int ix;
  struct ada_exc_info *info;

  switch (argc)
    {
    case 0:
      regexp = NULL;
      break;
    case 1:
      regexp = argv[0];
      break;
    default:
      error (_("Usage: -info-ada-exceptions [REGEXP]"));
      break;
    }

  exceptions = ada_exceptions_list (regexp);
  old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions);

  make_cleanup_ui_out_table_begin_end
    (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions");
  ui_out_table_header (uiout, 1, ui_left, "name", "Name");
  ui_out_table_header (uiout, 1, ui_left, "address", "Address");
  ui_out_table_body (uiout);

  for (ix = 0; VEC_iterate(ada_exc_info, exceptions, ix, info); ix++)
    {
      struct cleanup *sub_chain;

      sub_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
      ui_out_field_string (uiout, "name", info->name);
      ui_out_field_core_addr (uiout, "address", gdbarch, info->addr);

      do_cleanups (sub_chain);
    }

  do_cleanups (old_chain);
}
Exemplo n.º 22
0
static void
show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c,
	    const char *value)
{
  if (user_osabi_state == osabi_auto)
    fprintf_filtered (file,
		      _("The current OS ABI is \"auto\" "
			"(currently \"%s\").\n"),
		      gdbarch_osabi_name (gdbarch_osabi (get_current_arch ())));
  else
    fprintf_filtered (file, _("The current OS ABI is \"%s\".\n"),
		      gdbarch_osabi_name (user_selected_osabi));

  if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN)
    fprintf_filtered (file, _("The default OS ABI is \"%s\".\n"),
		      gdbarch_osabi_name (GDB_OSABI_DEFAULT));
}
Exemplo n.º 23
0
static void
tui_reg_next_command (char *arg, int from_tty)
{
    struct gdbarch *gdbarch = get_current_arch ();

    if (TUI_DATA_WIN != 0)
    {
        struct reggroup *group
                = TUI_DATA_WIN->detail.data_display_info.current_group;

        group = reggroup_next (gdbarch, group);
        if (group == 0)
            group = reggroup_next (gdbarch, 0);

        if (group)
            tui_show_registers (group);
    }
}
Exemplo n.º 24
0
static void
show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
	     const char *value)
{
  if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
    if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
      fprintf_unfiltered (file, _("The target endianness is set automatically "
				  "(currently big endian)\n"));
    else
      fprintf_unfiltered (file, _("The target endianness is set automatically "
				  "(currently little endian)\n"));
  else
    if (target_byte_order_user == BFD_ENDIAN_BIG)
      fprintf_unfiltered (file,
			  _("The target is assumed to be big endian\n"));
    else
      fprintf_unfiltered (file,
			  _("The target is assumed to be little endian\n"));
}
Exemplo n.º 25
0
Arquivo: python.c Projeto: ILyoan/gdb
void
eval_python_from_control_command (struct command_line *cmd)
{
  int ret;
  char *script;
  struct cleanup *cleanup;

  if (cmd->body_count != 1)
    error (_("Invalid \"python\" block structure."));

  cleanup = ensure_python_env (get_current_arch (), current_language);

  script = compute_python_string (cmd->body_list[0]);
  ret = PyRun_SimpleString (script);
  xfree (script);
  if (ret)
    error (_("Error while executing Python code."));

  do_cleanups (cleanup);
}
Exemplo n.º 26
0
static void
python_on_normal_stop (struct bpstats *bs, int print_frame)
{
  struct cleanup *cleanup;
  enum gdb_signal stop_signal;

  if (!gdb_python_initialized)
    return;

  if (!find_thread_ptid (inferior_ptid))
      return;

  stop_signal = inferior_thread ()->suspend.stop_signal;

  cleanup = ensure_python_env (get_current_arch (), current_language);

  if (emit_stop_event (bs, stop_signal) < 0)
    gdbpy_print_stack ();

  do_cleanups (cleanup);
}
Exemplo n.º 27
0
static void
python_interactive_command (char *arg, int from_tty)
{
  struct cleanup *cleanup;
  int err;

  cleanup = make_cleanup_restore_integer (&interpreter_async);
  interpreter_async = 0;

  arg = skip_spaces (arg);

  ensure_python_env (get_current_arch (), current_language);

  if (arg && *arg)
    {
      int len = strlen (arg);
      char *script = xmalloc (len + 2);

      strcpy (script, arg);
      script[len] = '\n';
      script[len + 1] = '\0';
      err = eval_python_command (script);
      xfree (script);
    }
  else
    {
      err = PyRun_InteractiveLoop (instream, "<stdin>");
      dont_repeat ();
    }

  if (err)
    {
      gdbpy_print_stack ();
      error (_("Error while executing Python code."));
    }

  do_cleanups (cleanup);
}
Exemplo n.º 28
0
bfd *
open_bfd_matching_arch (bfd *archive_bfd, bfd_format expected_format)
{
  enum gdb_osabi osabi;
  bfd *abfd;
  
  osabi = GDB_OSABI_UNINITIALIZED;
  abfd = NULL;

  osabi = gdbarch_osabi (get_current_arch ());
  if ((osabi <= GDB_OSABI_UNKNOWN) || (osabi >= GDB_OSABI_INVALID))
    osabi = gdbarch_lookup_osabi (archive_bfd);
  
  // FIXME: gdbarch_lookup_osabi() doesn't work yet on archive_bfd, hardcode
  if ((osabi <= GDB_OSABI_UNKNOWN) || (osabi >= GDB_OSABI_INVALID))
    osabi = GDB_OSABI_DARWIN;
  
  for (;;)
    {
      abfd = bfd_openr_next_archived_file (archive_bfd, abfd);
      if (abfd == NULL)
        break;
      if (! bfd_check_format (abfd, expected_format))
        continue;
      if (osabi == gdbarch_lookup_osabi_from_bfd (abfd))
        break;
    }
    
  // Copy the filename of the archive to the binary bfd.
  if (abfd)
  {
    xfree(abfd->filename);
    abfd->filename = archive_bfd->filename;
  }
  
  return abfd;
}
Exemplo n.º 29
0
void
tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
{
  struct tui_gen_win_info *locator;
  struct tui_locator_element *element;
  struct gdbarch *gdbarch = get_current_arch ();
  CORE_ADDR addr;

  locator = tui_locator_win_info_ptr ();
  element = &((struct tui_win_element *)
	      locator->content[0])->which_element.locator;

  if (element->addr == 0)
    {
      struct minimal_symbol *main_symbol;

      /* Find address of the start of program.
         Note: this should be language specific.  */
      main_symbol = lookup_minimal_symbol ("main", NULL, NULL);
      if (main_symbol == 0)
        main_symbol = lookup_minimal_symbol ("MAIN", NULL, NULL);
      if (main_symbol == 0)
        main_symbol = lookup_minimal_symbol ("_start", NULL, NULL);
      if (main_symbol)
        addr = SYMBOL_VALUE_ADDRESS (main_symbol);
      else
        addr = 0;
    }
  else				/* The target is executing.  */
    {
      gdbarch = element->gdbarch;
      addr = element->addr;
    }

  *gdbarch_p = gdbarch;
  *addr_p = addr;
}
Exemplo n.º 30
0
static void
get_register_name (int regnum, map_arg arg)
{
  /* Non-zero if the caller wants the register numbers, too.  */
  int numbers = arg.integer;
  Tcl_Obj *name
    = Tcl_NewStringObj (gdbarch_register_name (get_current_arch (), regnum), -1);
  Tcl_Obj *elt;

  if (numbers)
    {
      /* Build a tuple of the form "{REGNAME NUMBER}", and append it to
	 our result.  */
      Tcl_Obj *array[2];

      array[0] = name;
      array[1] = Tcl_NewIntObj (regnum);
      elt = Tcl_NewListObj (2, array);
    }
  else
    elt = name;

  Tcl_ListObjAppendElement (NULL, result_ptr->obj_ptr, elt);
}