OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [corefile.c] - Diff between revs 827 and 840

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/* Core dump and executable file functions above target vector, for GDB.
/* Core dump and executable file functions above target vector, for GDB.
 
 
   Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
   Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
   1999, 2000, 2001, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
   1999, 2000, 2001, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
#include "defs.h"
#include "defs.h"
#include "gdb_string.h"
#include "gdb_string.h"
#include <errno.h>
#include <errno.h>
#include <signal.h>
#include <signal.h>
#include <fcntl.h>
#include <fcntl.h>
#include "inferior.h"
#include "inferior.h"
#include "symtab.h"
#include "symtab.h"
#include "command.h"
#include "command.h"
#include "gdbcmd.h"
#include "gdbcmd.h"
#include "bfd.h"
#include "bfd.h"
#include "target.h"
#include "target.h"
#include "gdbcore.h"
#include "gdbcore.h"
#include "dis-asm.h"
#include "dis-asm.h"
#include "gdb_stat.h"
#include "gdb_stat.h"
#include "completer.h"
#include "completer.h"
#include "exceptions.h"
#include "exceptions.h"
 
 
/* Local function declarations.  */
/* Local function declarations.  */
 
 
extern void _initialize_core (void);
extern void _initialize_core (void);
static void call_extra_exec_file_hooks (char *filename);
static void call_extra_exec_file_hooks (char *filename);
 
 
/* You can have any number of hooks for `exec_file_command' command to
/* You can have any number of hooks for `exec_file_command' command to
   call.  If there's only one hook, it is set in exec_file_display
   call.  If there's only one hook, it is set in exec_file_display
   hook.  If there are two or more hooks, they are set in
   hook.  If there are two or more hooks, they are set in
   exec_file_extra_hooks[], and deprecated_exec_file_display_hook is
   exec_file_extra_hooks[], and deprecated_exec_file_display_hook is
   set to a function that calls all of them.  This extra complexity is
   set to a function that calls all of them.  This extra complexity is
   needed to preserve compatibility with old code that assumed that
   needed to preserve compatibility with old code that assumed that
   only one hook could be set, and which called
   only one hook could be set, and which called
   deprecated_exec_file_display_hook directly.  */
   deprecated_exec_file_display_hook directly.  */
 
 
typedef void (*hook_type) (char *);
typedef void (*hook_type) (char *);
 
 
hook_type deprecated_exec_file_display_hook;    /* the original hook */
hook_type deprecated_exec_file_display_hook;    /* the original hook */
static hook_type *exec_file_extra_hooks;        /* array of additional hooks */
static hook_type *exec_file_extra_hooks;        /* array of additional hooks */
static int exec_file_hook_count = 0;     /* size of array */
static int exec_file_hook_count = 0;     /* size of array */
 
 
/* Binary file diddling handle for the core file.  */
/* Binary file diddling handle for the core file.  */
 
 
bfd *core_bfd = NULL;
bfd *core_bfd = NULL;


 
 
/* Backward compatability with old way of specifying core files.  */
/* Backward compatability with old way of specifying core files.  */
 
 
void
void
core_file_command (char *filename, int from_tty)
core_file_command (char *filename, int from_tty)
{
{
  struct target_ops *t;
  struct target_ops *t;
 
 
  dont_repeat ();               /* Either way, seems bogus. */
  dont_repeat ();               /* Either way, seems bogus. */
 
 
  t = find_core_target ();
  t = find_core_target ();
  if (t == NULL)
  if (t == NULL)
    error (_("GDB can't read core files on this machine."));
    error (_("GDB can't read core files on this machine."));
 
 
  if (!filename)
  if (!filename)
    (t->to_detach) (filename, from_tty);
    (t->to_detach) (filename, from_tty);
  else
  else
    (t->to_open) (filename, from_tty);
    (t->to_open) (filename, from_tty);
}
}


 
 
/* If there are two or more functions that wish to hook into
/* If there are two or more functions that wish to hook into
   exec_file_command, this function will call all of the hook
   exec_file_command, this function will call all of the hook
   functions.  */
   functions.  */
 
 
static void
static void
call_extra_exec_file_hooks (char *filename)
call_extra_exec_file_hooks (char *filename)
{
{
  int i;
  int i;
 
 
  for (i = 0; i < exec_file_hook_count; i++)
  for (i = 0; i < exec_file_hook_count; i++)
    (*exec_file_extra_hooks[i]) (filename);
    (*exec_file_extra_hooks[i]) (filename);
}
}
 
 
/* Call this to specify the hook for exec_file_command to call back.
/* Call this to specify the hook for exec_file_command to call back.
   This is called from the x-window display code.  */
   This is called from the x-window display code.  */
 
 
void
void
specify_exec_file_hook (void (*hook) (char *))
specify_exec_file_hook (void (*hook) (char *))
{
{
  hook_type *new_array;
  hook_type *new_array;
 
 
  if (deprecated_exec_file_display_hook != NULL)
  if (deprecated_exec_file_display_hook != NULL)
    {
    {
      /* There's already a hook installed.  Arrange to have both it
      /* There's already a hook installed.  Arrange to have both it
       * and the subsequent hooks called. */
       * and the subsequent hooks called. */
      if (exec_file_hook_count == 0)
      if (exec_file_hook_count == 0)
        {
        {
          /* If this is the first extra hook, initialize the hook array.  */
          /* If this is the first extra hook, initialize the hook array.  */
          exec_file_extra_hooks = (hook_type *) xmalloc (sizeof (hook_type));
          exec_file_extra_hooks = (hook_type *) xmalloc (sizeof (hook_type));
          exec_file_extra_hooks[0] = deprecated_exec_file_display_hook;
          exec_file_extra_hooks[0] = deprecated_exec_file_display_hook;
          deprecated_exec_file_display_hook = call_extra_exec_file_hooks;
          deprecated_exec_file_display_hook = call_extra_exec_file_hooks;
          exec_file_hook_count = 1;
          exec_file_hook_count = 1;
        }
        }
 
 
      /* Grow the hook array by one and add the new hook to the end.
      /* Grow the hook array by one and add the new hook to the end.
         Yes, it's inefficient to grow it by one each time but since
         Yes, it's inefficient to grow it by one each time but since
         this is hardly ever called it's not a big deal.  */
         this is hardly ever called it's not a big deal.  */
      exec_file_hook_count++;
      exec_file_hook_count++;
      new_array =
      new_array =
        (hook_type *) xrealloc (exec_file_extra_hooks,
        (hook_type *) xrealloc (exec_file_extra_hooks,
                                exec_file_hook_count * sizeof (hook_type));
                                exec_file_hook_count * sizeof (hook_type));
      exec_file_extra_hooks = new_array;
      exec_file_extra_hooks = new_array;
      exec_file_extra_hooks[exec_file_hook_count - 1] = hook;
      exec_file_extra_hooks[exec_file_hook_count - 1] = hook;
    }
    }
  else
  else
    deprecated_exec_file_display_hook = hook;
    deprecated_exec_file_display_hook = hook;
}
}
 
 
/* The exec file must be closed before running an inferior.
/* The exec file must be closed before running an inferior.
   If it is needed again after the inferior dies, it must
   If it is needed again after the inferior dies, it must
   be reopened.  */
   be reopened.  */
 
 
void
void
close_exec_file (void)
close_exec_file (void)
{
{
#if 0                           /* FIXME */
#if 0                           /* FIXME */
  if (exec_bfd)
  if (exec_bfd)
    bfd_tempclose (exec_bfd);
    bfd_tempclose (exec_bfd);
#endif
#endif
}
}
 
 
void
void
reopen_exec_file (void)
reopen_exec_file (void)
{
{
#if 0                           /* FIXME */
#if 0                           /* FIXME */
  if (exec_bfd)
  if (exec_bfd)
    bfd_reopen (exec_bfd);
    bfd_reopen (exec_bfd);
#else
#else
  char *filename;
  char *filename;
  int res;
  int res;
  struct stat st;
  struct stat st;
  long mtime;
  long mtime;
 
 
  /* Don't do anything if there isn't an exec file. */
  /* Don't do anything if there isn't an exec file. */
  if (exec_bfd == NULL)
  if (exec_bfd == NULL)
    return;
    return;
 
 
  /* If the timestamp of the exec file has changed, reopen it. */
  /* If the timestamp of the exec file has changed, reopen it. */
  filename = xstrdup (bfd_get_filename (exec_bfd));
  filename = xstrdup (bfd_get_filename (exec_bfd));
  make_cleanup (xfree, filename);
  make_cleanup (xfree, filename);
  mtime = bfd_get_mtime (exec_bfd);
  mtime = bfd_get_mtime (exec_bfd);
  res = stat (filename, &st);
  res = stat (filename, &st);
 
 
  if (mtime && mtime != st.st_mtime)
  if (mtime && mtime != st.st_mtime)
    exec_file_attach (filename, 0);
    exec_file_attach (filename, 0);
#endif
#endif
}
}


/* If we have both a core file and an exec file,
/* If we have both a core file and an exec file,
   print a warning if they don't go together.  */
   print a warning if they don't go together.  */
 
 
void
void
validate_files (void)
validate_files (void)
{
{
  if (exec_bfd && core_bfd)
  if (exec_bfd && core_bfd)
    {
    {
      if (!core_file_matches_executable_p (core_bfd, exec_bfd))
      if (!core_file_matches_executable_p (core_bfd, exec_bfd))
        warning (_("core file may not match specified executable file."));
        warning (_("core file may not match specified executable file."));
      else if (bfd_get_mtime (exec_bfd) > bfd_get_mtime (core_bfd))
      else if (bfd_get_mtime (exec_bfd) > bfd_get_mtime (core_bfd))
        warning (_("exec file is newer than core file."));
        warning (_("exec file is newer than core file."));
    }
    }
}
}
 
 
/* Return the name of the executable file as a string.
/* Return the name of the executable file as a string.
   ERR nonzero means get error if there is none specified;
   ERR nonzero means get error if there is none specified;
   otherwise return 0 in that case.  */
   otherwise return 0 in that case.  */
 
 
char *
char *
get_exec_file (int err)
get_exec_file (int err)
{
{
  if (exec_bfd)
  if (exec_bfd)
    return bfd_get_filename (exec_bfd);
    return bfd_get_filename (exec_bfd);
  if (!err)
  if (!err)
    return NULL;
    return NULL;
 
 
  error (_("No executable file specified.\n\
  error (_("No executable file specified.\n\
Use the \"file\" or \"exec-file\" command."));
Use the \"file\" or \"exec-file\" command."));
  return NULL;
  return NULL;
}
}


 
 
/* Report a memory error with error().  */
/* Report a memory error with error().  */
 
 
void
void
memory_error (int status, CORE_ADDR memaddr)
memory_error (int status, CORE_ADDR memaddr)
{
{
  struct ui_file *tmp_stream = mem_fileopen ();
  struct ui_file *tmp_stream = mem_fileopen ();
  make_cleanup_ui_file_delete (tmp_stream);
  make_cleanup_ui_file_delete (tmp_stream);
 
 
  if (status == EIO)
  if (status == EIO)
    {
    {
      /* Actually, address between memaddr and memaddr + len
      /* Actually, address between memaddr and memaddr + len
         was out of bounds. */
         was out of bounds. */
      fprintf_unfiltered (tmp_stream, "Cannot access memory at address ");
      fprintf_unfiltered (tmp_stream, "Cannot access memory at address ");
      fputs_filtered (paddress (memaddr), tmp_stream);
      fputs_filtered (paddress (memaddr), tmp_stream);
    }
    }
  else
  else
    {
    {
      fprintf_filtered (tmp_stream, "Error accessing memory address ");
      fprintf_filtered (tmp_stream, "Error accessing memory address ");
      fputs_filtered (paddress (memaddr), tmp_stream);
      fputs_filtered (paddress (memaddr), tmp_stream);
      fprintf_filtered (tmp_stream, ": %s.",
      fprintf_filtered (tmp_stream, ": %s.",
                       safe_strerror (status));
                       safe_strerror (status));
    }
    }
 
 
  error_stream (tmp_stream);
  error_stream (tmp_stream);
}
}
 
 
/* Same as target_read_memory, but report an error if can't read.  */
/* Same as target_read_memory, but report an error if can't read.  */
void
void
read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
{
  int status;
  int status;
  status = target_read_memory (memaddr, myaddr, len);
  status = target_read_memory (memaddr, myaddr, len);
  if (status != 0)
  if (status != 0)
    memory_error (status, memaddr);
    memory_error (status, memaddr);
}
}
 
 
/* Argument / return result struct for use with
/* Argument / return result struct for use with
   do_captured_read_memory_integer().  MEMADDR and LEN are filled in
   do_captured_read_memory_integer().  MEMADDR and LEN are filled in
   by gdb_read_memory_integer().  RESULT is the contents that were
   by gdb_read_memory_integer().  RESULT is the contents that were
   successfully read from MEMADDR of length LEN.  */
   successfully read from MEMADDR of length LEN.  */
 
 
struct captured_read_memory_integer_arguments
struct captured_read_memory_integer_arguments
{
{
  CORE_ADDR memaddr;
  CORE_ADDR memaddr;
  int len;
  int len;
  LONGEST result;
  LONGEST result;
};
};
 
 
/* Helper function for gdb_read_memory_integer().  DATA must be a
/* Helper function for gdb_read_memory_integer().  DATA must be a
   pointer to a captured_read_memory_integer_arguments struct.
   pointer to a captured_read_memory_integer_arguments struct.
   Return 1 if successful.  Note that the catch_errors() interface
   Return 1 if successful.  Note that the catch_errors() interface
   will return 0 if an error occurred while reading memory.  This
   will return 0 if an error occurred while reading memory.  This
   choice of return code is so that we can distinguish between
   choice of return code is so that we can distinguish between
   success and failure.  */
   success and failure.  */
 
 
static int
static int
do_captured_read_memory_integer (void *data)
do_captured_read_memory_integer (void *data)
{
{
  struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
  struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
  CORE_ADDR memaddr = args->memaddr;
  CORE_ADDR memaddr = args->memaddr;
  int len = args->len;
  int len = args->len;
 
 
  args->result = read_memory_integer (memaddr, len);
  args->result = read_memory_integer (memaddr, len);
 
 
  return 1;
  return 1;
}
}
 
 
/* Read memory at MEMADDR of length LEN and put the contents in
/* Read memory at MEMADDR of length LEN and put the contents in
   RETURN_VALUE.  Return 0 if MEMADDR couldn't be read and non-zero
   RETURN_VALUE.  Return 0 if MEMADDR couldn't be read and non-zero
   if successful.  */
   if successful.  */
 
 
int
int
safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
{
{
  int status;
  int status;
  struct captured_read_memory_integer_arguments args;
  struct captured_read_memory_integer_arguments args;
  args.memaddr = memaddr;
  args.memaddr = memaddr;
  args.len = len;
  args.len = len;
 
 
  status = catch_errors (do_captured_read_memory_integer, &args,
  status = catch_errors (do_captured_read_memory_integer, &args,
                        "", RETURN_MASK_ALL);
                        "", RETURN_MASK_ALL);
  if (status)
  if (status)
    *return_value = args.result;
    *return_value = args.result;
 
 
  return status;
  return status;
}
}
 
 
LONGEST
LONGEST
read_memory_integer (CORE_ADDR memaddr, int len)
read_memory_integer (CORE_ADDR memaddr, int len)
{
{
  gdb_byte buf[sizeof (LONGEST)];
  gdb_byte buf[sizeof (LONGEST)];
 
 
  read_memory (memaddr, buf, len);
  read_memory (memaddr, buf, len);
  return extract_signed_integer (buf, len);
  return extract_signed_integer (buf, len);
}
}
 
 
ULONGEST
ULONGEST
read_memory_unsigned_integer (CORE_ADDR memaddr, int len)
read_memory_unsigned_integer (CORE_ADDR memaddr, int len)
{
{
  gdb_byte buf[sizeof (ULONGEST)];
  gdb_byte buf[sizeof (ULONGEST)];
 
 
  read_memory (memaddr, buf, len);
  read_memory (memaddr, buf, len);
  return extract_unsigned_integer (buf, len);
  return extract_unsigned_integer (buf, len);
}
}
 
 
void
void
read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len)
read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len)
{
{
  char *cp;
  char *cp;
  int i;
  int i;
  int cnt;
  int cnt;
 
 
  cp = buffer;
  cp = buffer;
  while (1)
  while (1)
    {
    {
      if (cp - buffer >= max_len)
      if (cp - buffer >= max_len)
        {
        {
          buffer[max_len - 1] = '\0';
          buffer[max_len - 1] = '\0';
          break;
          break;
        }
        }
      cnt = max_len - (cp - buffer);
      cnt = max_len - (cp - buffer);
      if (cnt > 8)
      if (cnt > 8)
        cnt = 8;
        cnt = 8;
      read_memory (memaddr + (int) (cp - buffer), cp, cnt);
      read_memory (memaddr + (int) (cp - buffer), cp, cnt);
      for (i = 0; i < cnt && *cp; i++, cp++)
      for (i = 0; i < cnt && *cp; i++, cp++)
        ;                       /* null body */
        ;                       /* null body */
 
 
      if (i < cnt && !*cp)
      if (i < cnt && !*cp)
        break;
        break;
    }
    }
}
}
 
 
CORE_ADDR
CORE_ADDR
read_memory_typed_address (CORE_ADDR addr, struct type *type)
read_memory_typed_address (CORE_ADDR addr, struct type *type)
{
{
  gdb_byte *buf = alloca (TYPE_LENGTH (type));
  gdb_byte *buf = alloca (TYPE_LENGTH (type));
  read_memory (addr, buf, TYPE_LENGTH (type));
  read_memory (addr, buf, TYPE_LENGTH (type));
  return extract_typed_address (buf, type);
  return extract_typed_address (buf, type);
}
}
 
 
/* Same as target_write_memory, but report an error if can't write.  */
/* Same as target_write_memory, but report an error if can't write.  */
void
void
write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
{
{
  int status;
  int status;
  gdb_byte *bytes = alloca (len);
  gdb_byte *bytes = alloca (len);
 
 
  memcpy (bytes, myaddr, len);
  memcpy (bytes, myaddr, len);
  status = target_write_memory (memaddr, bytes, len);
  status = target_write_memory (memaddr, bytes, len);
  if (status != 0)
  if (status != 0)
    memory_error (status, memaddr);
    memory_error (status, memaddr);
}
}
 
 
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
void
void
write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
{
{
  gdb_byte *buf = alloca (len);
  gdb_byte *buf = alloca (len);
  store_unsigned_integer (buf, len, value);
  store_unsigned_integer (buf, len, value);
  write_memory (addr, buf, len);
  write_memory (addr, buf, len);
}
}
 
 
/* Store VALUE at ADDR in the inferior as a LEN-byte signed integer.  */
/* Store VALUE at ADDR in the inferior as a LEN-byte signed integer.  */
void
void
write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
{
{
  gdb_byte *buf = alloca (len);
  gdb_byte *buf = alloca (len);
  store_signed_integer (buf, len, value);
  store_signed_integer (buf, len, value);
  write_memory (addr, buf, len);
  write_memory (addr, buf, len);
}
}
 
 


 
 
#if 0
#if 0
/* Enable after 4.12.  It is not tested.  */
/* Enable after 4.12.  It is not tested.  */
 
 
/* Search code.  Targets can just make this their search function, or
/* Search code.  Targets can just make this their search function, or
   if the protocol has a less general search function, they can call this
   if the protocol has a less general search function, they can call this
   in the cases it can't handle.  */
   in the cases it can't handle.  */
void
void
generic_search (int len, char *data, char *mask, CORE_ADDR startaddr,
generic_search (int len, char *data, char *mask, CORE_ADDR startaddr,
                int increment, CORE_ADDR lorange, CORE_ADDR hirange,
                int increment, CORE_ADDR lorange, CORE_ADDR hirange,
                CORE_ADDR *addr_found, char *data_found)
                CORE_ADDR *addr_found, char *data_found)
{
{
  int i;
  int i;
  CORE_ADDR curaddr = startaddr;
  CORE_ADDR curaddr = startaddr;
 
 
  while (curaddr >= lorange && curaddr < hirange)
  while (curaddr >= lorange && curaddr < hirange)
    {
    {
      read_memory (curaddr, data_found, len);
      read_memory (curaddr, data_found, len);
      for (i = 0; i < len; ++i)
      for (i = 0; i < len; ++i)
        if ((data_found[i] & mask[i]) != data[i])
        if ((data_found[i] & mask[i]) != data[i])
          goto try_again;
          goto try_again;
      /* It matches.  */
      /* It matches.  */
      *addr_found = curaddr;
      *addr_found = curaddr;
      return;
      return;
 
 
    try_again:
    try_again:
      curaddr += increment;
      curaddr += increment;
    }
    }
  *addr_found = (CORE_ADDR) 0;
  *addr_found = (CORE_ADDR) 0;
  return;
  return;
}
}
#endif /* 0 */
#endif /* 0 */


/* The current default bfd target.  Points to storage allocated for
/* The current default bfd target.  Points to storage allocated for
   gnutarget_string.  */
   gnutarget_string.  */
char *gnutarget;
char *gnutarget;
 
 
/* Same thing, except it is "auto" not NULL for the default case.  */
/* Same thing, except it is "auto" not NULL for the default case.  */
static char *gnutarget_string;
static char *gnutarget_string;
static void
static void
show_gnutarget_string (struct ui_file *file, int from_tty,
show_gnutarget_string (struct ui_file *file, int from_tty,
                       struct cmd_list_element *c, const char *value)
                       struct cmd_list_element *c, const char *value)
{
{
  fprintf_filtered (file, _("The current BFD target is \"%s\".\n"), value);
  fprintf_filtered (file, _("The current BFD target is \"%s\".\n"), value);
}
}
 
 
static void set_gnutarget_command (char *, int, struct cmd_list_element *);
static void set_gnutarget_command (char *, int, struct cmd_list_element *);
 
 
static void
static void
set_gnutarget_command (char *ignore, int from_tty, struct cmd_list_element *c)
set_gnutarget_command (char *ignore, int from_tty, struct cmd_list_element *c)
{
{
  if (strcmp (gnutarget_string, "auto") == 0)
  if (strcmp (gnutarget_string, "auto") == 0)
    gnutarget = NULL;
    gnutarget = NULL;
  else
  else
    gnutarget = gnutarget_string;
    gnutarget = gnutarget_string;
}
}
 
 
/* Set the gnutarget.  */
/* Set the gnutarget.  */
void
void
set_gnutarget (char *newtarget)
set_gnutarget (char *newtarget)
{
{
  if (gnutarget_string != NULL)
  if (gnutarget_string != NULL)
    xfree (gnutarget_string);
    xfree (gnutarget_string);
  gnutarget_string = savestring (newtarget, strlen (newtarget));
  gnutarget_string = savestring (newtarget, strlen (newtarget));
  set_gnutarget_command (NULL, 0, NULL);
  set_gnutarget_command (NULL, 0, NULL);
}
}
 
 
void
void
_initialize_core (void)
_initialize_core (void)
{
{
  struct cmd_list_element *c;
  struct cmd_list_element *c;
  c = add_cmd ("core-file", class_files, core_file_command, _("\
  c = add_cmd ("core-file", class_files, core_file_command, _("\
Use FILE as core dump for examining memory and registers.\n\
Use FILE as core dump for examining memory and registers.\n\
No arg means have no core file.  This command has been superseded by the\n\
No arg means have no core file.  This command has been superseded by the\n\
`target core' and `detach' commands."), &cmdlist);
`target core' and `detach' commands."), &cmdlist);
  set_cmd_completer (c, filename_completer);
  set_cmd_completer (c, filename_completer);
 
 
 
 
  add_setshow_string_noescape_cmd ("gnutarget", class_files,
  add_setshow_string_noescape_cmd ("gnutarget", class_files,
                                   &gnutarget_string, _("(\
                                   &gnutarget_string, _("(\
Set the current BFD target."), _("\
Set the current BFD target."), _("\
Show the current BFD target."), _("\
Show the current BFD target."), _("\
Use `set gnutarget auto' to specify automatic detection."),
Use `set gnutarget auto' to specify automatic detection."),
                                   set_gnutarget_command,
                                   set_gnutarget_command,
                                   show_gnutarget_string,
                                   show_gnutarget_string,
                                   &setlist, &showlist);
                                   &setlist, &showlist);
 
 
  if (getenv ("GNUTARGET"))
  if (getenv ("GNUTARGET"))
    set_gnutarget (getenv ("GNUTARGET"));
    set_gnutarget (getenv ("GNUTARGET"));
  else
  else
    set_gnutarget ("auto");
    set_gnutarget ("auto");
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.