コード例 #1
0
ファイル: record-btrace.c プロジェクト: embecosm/binutils-gdb
static void
record_btrace_store_registers (struct target_ops *ops,
			       struct regcache *regcache, int regno)
{
  struct target_ops *t;

  if (record_btrace_is_replaying (ops))
    error (_("This record target does not allow writing registers."));

  gdb_assert (may_write_registers != 0);

  for (t = ops->beneath; t != NULL; t = t->beneath)
    if (t->to_store_registers != NULL)
      {
	t->to_store_registers (t, regcache, regno);
	return;
      }

  noprocess ();
}
コード例 #2
0
ファイル: gcore.c プロジェクト: atgreen/binutils-gdb
static void
gcore_command (char *args, int from_tty)
{
  struct cleanup *filename_chain;
  struct cleanup *bfd_chain;
  char *corefilename;
  bfd *obfd;

  /* No use generating a corefile without a target process.  */
  if (!target_has_execution)
    noprocess ();

  if (args && *args)
    corefilename = tilde_expand (args);
  else
    {
      /* Default corefile name is "core.PID".  */
      corefilename = xstrprintf ("core.%d", ptid_get_pid (inferior_ptid));
    }
  filename_chain = make_cleanup (xfree, corefilename);

  if (info_verbose)
    fprintf_filtered (gdb_stdout,
		      "Opening corefile '%s' for output.\n", corefilename);

  /* Open the output file.  */
  obfd = create_gcore_bfd (corefilename);

  /* Need a cleanup that will close and delete the file.  */
  bfd_chain = make_cleanup (do_bfd_delete_cleanup, obfd);

  /* Call worker function.  */
  write_gcore_file (obfd);

  /* Succeeded.  */
  discard_cleanups (bfd_chain);
  gdb_bfd_unref (obfd);

  fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);
  do_cleanups (filename_chain);
}
コード例 #3
0
ファイル: gcore.c プロジェクト: GoldStoneProd2010/gdb-7.6
static void
gcore_command (char *args, int from_tty)
{
  struct cleanup *old_chain;
  char *corefilename, corefilename_buffer[40];
  bfd *obfd;

  /* No use generating a corefile without a target process.  */
  if (!target_has_execution)
    noprocess ();

  if (args && *args)
    corefilename = args;
  else
    {
      /* Default corefile name is "core.PID".  */
      xsnprintf (corefilename_buffer, sizeof (corefilename_buffer),
		 "core.%d", PIDGET (inferior_ptid));
      corefilename = corefilename_buffer;
    }

  if (info_verbose)
    fprintf_filtered (gdb_stdout,
		      "Opening corefile '%s' for output.\n", corefilename);

  /* Open the output file.  */
  obfd = create_gcore_bfd (corefilename);

  /* Need a cleanup that will close and delete the file.  */
  old_chain = make_cleanup (do_bfd_delete_cleanup, obfd);

  /* Call worker function.  */
  write_gcore_file (obfd);

  /* Succeeded.  */
  fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);

  discard_cleanups (old_chain);
  gdb_bfd_unref (obfd);
}
コード例 #4
0
ファイル: gcore.c プロジェクト: gygy/asuswrt
static void
gcore_command (char *args, int from_tty)
{
  struct cleanup *old_chain;
  char *corefilename, corefilename_buffer[40];
  asection *note_sec = NULL;
  bfd *obfd;
  void *note_data = NULL;
  int note_size = 0;

  /* No use generating a corefile without a target process.  */
  if (!target_has_execution)
    noprocess ();

  if (args && *args)
    corefilename = args;
  else
    {
      /* Default corefile name is "core.PID".  */
      sprintf (corefilename_buffer, "core.%d", PIDGET (inferior_ptid));
      corefilename = corefilename_buffer;
    }

  if (info_verbose)
    fprintf_filtered (gdb_stdout,
		      "Opening corefile '%s' for output.\n", corefilename);

  /* Open the output file.  */
  obfd = bfd_openw (corefilename, default_gcore_target ());
  if (!obfd)
    error (_("Failed to open '%s' for output."), corefilename);

  /* Need a cleanup that will close the file (FIXME: delete it?).  */
  old_chain = make_cleanup_bfd_close (obfd);

  bfd_set_format (obfd, bfd_core);
  bfd_set_arch_mach (obfd, default_gcore_arch (), default_gcore_mach ());

  /* An external target method must build the notes section.  */
  note_data = target_make_corefile_notes (obfd, &note_size);

  /* Create the note section.  */
  if (note_data != NULL && note_size != 0)
    {
      note_sec = bfd_make_section_anyway_with_flags (obfd, "note0",
						     SEC_HAS_CONTENTS
						     | SEC_READONLY
						     | SEC_ALLOC);
      if (note_sec == NULL)
	error (_("Failed to create 'note' section for corefile: %s"),
	       bfd_errmsg (bfd_get_error ()));

      bfd_set_section_vma (obfd, note_sec, 0);
      bfd_set_section_alignment (obfd, note_sec, 0);
      bfd_set_section_size (obfd, note_sec, note_size);
    }

  /* Now create the memory/load sections.  */
  if (gcore_memory_sections (obfd) == 0)
    error (_("gcore: failed to get corefile memory sections from target."));

  /* Write out the contents of the note section.  */
  if (note_data != NULL && note_size != 0)
    {
      if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size))
	warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ()));
    }

  /* Succeeded.  */
  fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);

  /* Clean-ups will close the output file and free malloc memory.  */
  do_cleanups (old_chain);
  return;
}
コード例 #5
0
ファイル: cli-dump.c プロジェクト: cooljeanius/apple-gdb-1824
static void
restore_command(const char *args, int from_tty)
{
  char *filename;
  struct callback_data data;
  bfd *ibfd;
  int binary_flag = 0;

  if (!target_has_execution)
    noprocess();

  data.load_offset = 0;
  data.load_start = 0;
  data.load_end = 0;

  /* Parse the input arguments.  First is filename (required). */
  filename = scan_filename_with_cleanup(&args, NULL);
  if ((args != NULL) && (*args != '\0'))
    {
      const char *binary_string = "binary";

      /* Look for optional "binary" flag: */
      if (strncmp(args, binary_string, strlen(binary_string)) == 0)
	{
	  binary_flag = 1;
	  args += strlen(binary_string);
	  args = skip_spaces(args);
	}
      /* Parse offset (optional). */
      if ((args != NULL) && (*args != '\0'))
        data.load_offset =
          ((unsigned long)
           parse_and_eval_long(scan_expression_with_cleanup(&args, NULL)));
      if ((args != NULL) && (*args != '\0'))
	{
	  /* Parse start address (optional): */
	  data.load_start =
	    parse_and_eval_long(scan_expression_with_cleanup(&args, NULL));
	  if ((args != NULL) && (*args != '\0'))
	    {
	      /* Parse end address (optional): */
	      data.load_end = parse_and_eval_long(args);
	      if (data.load_end <= data.load_start)
		error(_("Start must be less than end."));
	    }
	}
    }

  if (info_verbose)
    printf_filtered("Restore file %s offset 0x%lx start 0x%lx end 0x%lx\n",
		    filename, (unsigned long)data.load_offset,
		    (unsigned long)data.load_start,
		    (unsigned long)data.load_end);

  if (binary_flag)
    {
      restore_binary_file(filename, &data);
    }
  else
    {
      /* Open the file for loading: */
      ibfd = bfd_openr_with_cleanup(filename, NULL);

      /* Process the sections: */
      bfd_map_over_sections(ibfd, restore_section_callback, &data);
    }
  return;
}