2002-01-09 08:37:02 +08:00
|
|
|
/* Generate a core file for the inferior process.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 08:49:06 +08:00
|
|
|
|
2014-01-01 11:54:24 +08:00
|
|
|
Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
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
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-01-09 08:37:02 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
#include "defs.h"
|
2003-09-05 05:05:49 +08:00
|
|
|
#include "elf-bfd.h"
|
|
|
|
#include "infcall.h"
|
2002-01-09 08:37:02 +08:00
|
|
|
#include "inferior.h"
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "objfiles.h"
|
2009-12-02 06:46:15 +08:00
|
|
|
#include "solib.h"
|
2003-09-05 05:05:49 +08:00
|
|
|
#include "symfile.h"
|
2009-10-23 03:36:06 +08:00
|
|
|
#include "arch-utils.h"
|
|
|
|
#include "completer.h"
|
|
|
|
#include "gcore.h"
|
2003-09-05 05:05:49 +08:00
|
|
|
#include "cli/cli-decode.h"
|
|
|
|
#include "gdb_assert.h"
|
2009-10-23 03:36:06 +08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include "regcache.h"
|
|
|
|
#include "regset.h"
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-19 03:33:34 +08:00
|
|
|
#include "gdb_bfd.h"
|
2013-08-09 01:00:42 +08:00
|
|
|
#include "readline/tilde.h"
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2006-10-21 06:06:28 +08:00
|
|
|
/* The largest amount of memory to read from the target at once. We
|
|
|
|
must throttle it to limit the amount of memory used by GDB during
|
|
|
|
generate-core-file for programs with large resident data. */
|
|
|
|
#define MAX_COPY_BYTES (1024 * 1024)
|
|
|
|
|
2009-06-18 02:48:26 +08:00
|
|
|
static const char *default_gcore_target (void);
|
2003-09-05 05:05:49 +08:00
|
|
|
static enum bfd_architecture default_gcore_arch (void);
|
|
|
|
static unsigned long default_gcore_mach (void);
|
|
|
|
static int gcore_memory_sections (bfd *);
|
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
/* create_gcore_bfd -- helper for gcore_command (exported).
|
|
|
|
Open a new bfd core file for output, and return the handle. */
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
bfd *
|
2013-05-15 04:30:48 +08:00
|
|
|
create_gcore_bfd (const char *filename)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
2013-08-09 23:30:48 +08:00
|
|
|
bfd *obfd = gdb_bfd_openw (filename, default_gcore_target ());
|
2010-05-15 04:17:37 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
if (!obfd)
|
2009-10-23 03:36:06 +08:00
|
|
|
error (_("Failed to open '%s' for output."), filename);
|
2002-01-09 08:37:02 +08:00
|
|
|
bfd_set_format (obfd, bfd_core);
|
|
|
|
bfd_set_arch_mach (obfd, default_gcore_arch (), default_gcore_mach ());
|
2009-10-23 03:36:06 +08:00
|
|
|
return obfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write_gcore_file -- helper for gcore_command (exported).
|
|
|
|
Compose and write the corefile data to the core file. */
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
write_gcore_file (bfd *obfd)
|
|
|
|
{
|
|
|
|
void *note_data = NULL;
|
|
|
|
int note_size = 0;
|
|
|
|
asection *note_sec = NULL;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* An external target method must build the notes section. */
|
2012-01-20 17:56:56 +08:00
|
|
|
/* FIXME: uweigand/2011-10-06: All architectures that support core file
|
|
|
|
generation should be converted to gdbarch_make_corefile_notes; at that
|
|
|
|
point, the target vector method can be removed. */
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
if (!gdbarch_make_corefile_notes_p (target_gdbarch ()))
|
2012-01-20 17:56:56 +08:00
|
|
|
note_data = target_make_corefile_notes (obfd, ¬e_size);
|
|
|
|
else
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd, ¬e_size);
|
2012-01-20 17:56:56 +08:00
|
|
|
|
|
|
|
if (note_data == NULL || note_size == 0)
|
|
|
|
error (_("Target does not support core file generation."));
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Create the note section. */
|
2012-01-20 17:56:56 +08:00
|
|
|
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);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Now create the memory/load sections. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (gcore_memory_sections (obfd) == 0)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("gcore: failed to get corefile memory sections from target."));
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Write out the contents of the note section. */
|
2012-01-20 17:56:56 +08:00
|
|
|
if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size))
|
|
|
|
warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ()));
|
2009-10-23 03:36:06 +08:00
|
|
|
}
|
|
|
|
|
2010-02-17 04:48:52 +08:00
|
|
|
static void
|
|
|
|
do_bfd_delete_cleanup (void *arg)
|
|
|
|
{
|
|
|
|
bfd *obfd = arg;
|
|
|
|
const char *filename = obfd->filename;
|
|
|
|
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-19 03:33:34 +08:00
|
|
|
gdb_bfd_unref (arg);
|
2010-02-17 04:48:52 +08:00
|
|
|
unlink (filename);
|
|
|
|
}
|
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
/* gcore_command -- implements the 'gcore' command.
|
|
|
|
Generate a core file from the inferior process. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gcore_command (char *args, int from_tty)
|
|
|
|
{
|
2013-08-09 23:30:48 +08:00
|
|
|
struct cleanup *filename_chain;
|
|
|
|
struct cleanup *bfd_chain;
|
|
|
|
char *corefilename;
|
2009-10-23 03:36:06 +08:00
|
|
|
bfd *obfd;
|
|
|
|
|
|
|
|
/* No use generating a corefile without a target process. */
|
|
|
|
if (!target_has_execution)
|
|
|
|
noprocess ();
|
|
|
|
|
|
|
|
if (args && *args)
|
2013-08-09 23:30:48 +08:00
|
|
|
corefilename = tilde_expand (args);
|
2009-10-23 03:36:06 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Default corefile name is "core.PID". */
|
2013-09-30 19:50:12 +08:00
|
|
|
corefilename = xstrprintf ("core.%d", ptid_get_pid (inferior_ptid));
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
2013-08-09 23:30:48 +08:00
|
|
|
filename_chain = make_cleanup (xfree, corefilename);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
if (info_verbose)
|
|
|
|
fprintf_filtered (gdb_stdout,
|
|
|
|
"Opening corefile '%s' for output.\n", corefilename);
|
|
|
|
|
|
|
|
/* Open the output file. */
|
|
|
|
obfd = create_gcore_bfd (corefilename);
|
|
|
|
|
2010-02-17 04:48:52 +08:00
|
|
|
/* Need a cleanup that will close and delete the file. */
|
2013-08-09 23:30:48 +08:00
|
|
|
bfd_chain = make_cleanup (do_bfd_delete_cleanup, obfd);
|
2009-10-23 03:36:06 +08:00
|
|
|
|
|
|
|
/* Call worker function. */
|
|
|
|
write_gcore_file (obfd);
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Succeeded. */
|
2013-08-09 23:30:48 +08:00
|
|
|
discard_cleanups (bfd_chain);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-19 03:33:34 +08:00
|
|
|
gdb_bfd_unref (obfd);
|
2013-08-09 23:30:48 +08:00
|
|
|
|
|
|
|
fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);
|
|
|
|
do_cleanups (filename_chain);
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long
|
|
|
|
default_gcore_mach (void)
|
|
|
|
{
|
2003-09-05 05:05:49 +08:00
|
|
|
#if 1 /* See if this even matters... */
|
2002-02-14 09:57:36 +08:00
|
|
|
return 0;
|
|
|
|
#else
|
2007-06-14 01:53:51 +08:00
|
|
|
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch ());
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
if (bfdarch != NULL)
|
|
|
|
return bfdarch->mach;
|
|
|
|
if (exec_bfd == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Can't find default bfd machine type (need execfile)."));
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
return bfd_get_mach (exec_bfd);
|
2002-02-14 09:57:36 +08:00
|
|
|
#endif /* 1 */
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum bfd_architecture
|
|
|
|
default_gcore_arch (void)
|
|
|
|
{
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch ());
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
if (bfdarch != NULL)
|
|
|
|
return bfdarch->arch;
|
|
|
|
if (exec_bfd == NULL)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
error (_("Can't find bfd architecture for corefile (need execfile)."));
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
return bfd_get_arch (exec_bfd);
|
|
|
|
}
|
|
|
|
|
2009-06-18 02:48:26 +08:00
|
|
|
static const char *
|
2002-01-09 08:37:02 +08:00
|
|
|
default_gcore_target (void)
|
|
|
|
{
|
2009-06-18 02:48:26 +08:00
|
|
|
/* The gdbarch may define a target to use for core files. */
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
if (gdbarch_gcore_bfd_target_p (target_gdbarch ()))
|
|
|
|
return gdbarch_gcore_bfd_target (target_gdbarch ());
|
2009-06-18 02:48:26 +08:00
|
|
|
|
|
|
|
/* Otherwise, try to fall back to the exec_bfd target. This will probably
|
|
|
|
not work for non-ELF targets. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (exec_bfd == NULL)
|
2002-02-14 09:57:36 +08:00
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return bfd_get_target (exec_bfd);
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Derive a reasonable stack segment by unwinding the target stack,
|
|
|
|
and store its limits in *BOTTOM and *TOP. Return non-zero if
|
|
|
|
successful. */
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
static int
|
2002-08-08 22:59:35 +08:00
|
|
|
derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
|
|
|
struct frame_info *fi, *tmp_fi;
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
gdb_assert (bottom);
|
|
|
|
gdb_assert (top);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Can't succeed without stack and registers. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (!target_has_stack || !target_has_registers)
|
2003-09-05 05:05:49 +08:00
|
|
|
return 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Can't succeed without current frame. */
|
|
|
|
fi = get_current_frame ();
|
|
|
|
if (fi == NULL)
|
|
|
|
return 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Save frame pointer of TOS frame. */
|
2003-01-09 06:47:46 +08:00
|
|
|
*top = get_frame_base (fi);
|
2003-09-05 05:05:49 +08:00
|
|
|
/* If current stack pointer is more "inner", use that instead. */
|
2007-11-16 Markus Deuling <deuling@de.ibm.com>
* m32r-rom.c (m32r_supply_register): Use get_regcache_arch to get at
the current architecture by regcache.
* ppcnbsd-nat.c (ppcnbsd_supply_pcb): Likewise.
* ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register)
(fetch_register, supply_vrregset, fetch_ppc_registers)
(store_altivec_register, store_spe_register, store_register)
(fill_vrregset, store_ppc_registers): Likewise.
* ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise.
* win32-nat.c (do_win32_fetch_inferior_registers)
(do_win32_store_inferior_registers): Likewise.
* procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise.
* remote-m32r-sdi.c (m32r_fetch_registers)
(m32r_store_registers): Likewise.
* remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): Likewise.
* trad-frame.c (trad_frame_alloc_saved_regs): Replace current_gdbarch by
gdbarch.
* user-regs.c (user_reg_map_name_to_regnum): Likewise.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call)
(do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call)
(ppc64_sysv_abi_return_value): Likewise.
* m32c-tdep.c (m32c_register_reggroup_p): Likewise.
* m2-lang.c (build_m2_types): Likewise.
* ppc-linux-tdep.c (ppc_linux_sigtramp_cache
* ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise.
* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise.
* rs6000-tdep.c (ppc_dwarf2_frame_init_reg): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Use get_frame_arch to
get at the current architecture by frame_info.
* gcore.c (derive_stack_segment): Likewise.
* shnbsd-nat.c (GETREGS_SUPPLIES): Add gdbarch parameter.
(shnbsd_fetch_inferior_registers, shnbsd_store_inferior_registers): Add
gdbarch to GETREGS_SUPPLIES call.
2007-11-16 12:53:46 +08:00
|
|
|
if (gdbarch_inner_than (get_frame_arch (fi), get_frame_sp (fi), *top))
|
2007-05-13 20:27:30 +08:00
|
|
|
*top = get_frame_sp (fi);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Find prev-most frame. */
|
2002-01-09 08:37:02 +08:00
|
|
|
while ((tmp_fi = get_prev_frame (fi)) != NULL)
|
|
|
|
fi = tmp_fi;
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Save frame pointer of prev-most frame. */
|
2003-01-09 06:47:46 +08:00
|
|
|
*bottom = get_frame_base (fi);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Now canonicalize their order, so that BOTTOM is a lower address
|
|
|
|
(as opposed to a lower stack frame). */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (*bottom > *top)
|
|
|
|
{
|
2003-09-05 05:05:49 +08:00
|
|
|
bfd_vma tmp_vma;
|
|
|
|
|
2002-01-09 08:37:02 +08:00
|
|
|
tmp_vma = *top;
|
|
|
|
*top = *bottom;
|
|
|
|
*bottom = tmp_vma;
|
|
|
|
}
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
return 1;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
/* call_target_sbrk --
|
|
|
|
helper function for derive_heap_segment. */
|
|
|
|
|
|
|
|
static bfd_vma
|
|
|
|
call_target_sbrk (int sbrk_arg)
|
|
|
|
{
|
|
|
|
struct objfile *sbrk_objf;
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
bfd_vma top_of_heap;
|
|
|
|
struct value *target_sbrk_arg;
|
|
|
|
struct value *sbrk_fn, *ret;
|
|
|
|
bfd_vma tmp;
|
|
|
|
|
|
|
|
if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
|
|
|
|
{
|
|
|
|
sbrk_fn = find_function_in_inferior ("sbrk", &sbrk_objf);
|
|
|
|
if (sbrk_fn == NULL)
|
|
|
|
return (bfd_vma) 0;
|
|
|
|
}
|
|
|
|
else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
|
|
|
|
{
|
|
|
|
sbrk_fn = find_function_in_inferior ("_sbrk", &sbrk_objf);
|
|
|
|
if (sbrk_fn == NULL)
|
|
|
|
return (bfd_vma) 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (bfd_vma) 0;
|
|
|
|
|
|
|
|
gdbarch = get_objfile_arch (sbrk_objf);
|
|
|
|
target_sbrk_arg = value_from_longest (builtin_type (gdbarch)->builtin_int,
|
|
|
|
sbrk_arg);
|
|
|
|
gdb_assert (target_sbrk_arg);
|
|
|
|
ret = call_function_by_hand (sbrk_fn, 1, &target_sbrk_arg);
|
|
|
|
if (ret == NULL)
|
|
|
|
return (bfd_vma) 0;
|
|
|
|
|
|
|
|
tmp = value_as_long (ret);
|
|
|
|
if ((LONGEST) tmp <= 0 || (LONGEST) tmp == 0xffffffff)
|
|
|
|
return (bfd_vma) 0;
|
|
|
|
|
|
|
|
top_of_heap = tmp;
|
|
|
|
return top_of_heap;
|
|
|
|
}
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Derive a reasonable heap segment for ABFD by looking at sbrk and
|
|
|
|
the static data sections. Store its limits in *BOTTOM and *TOP.
|
|
|
|
Return non-zero if successful. */
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
static int
|
2002-08-08 22:59:35 +08:00
|
|
|
derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
|
|
|
bfd_vma top_of_data_memory = 0;
|
|
|
|
bfd_vma top_of_heap = 0;
|
|
|
|
bfd_size_type sec_size;
|
|
|
|
bfd_vma sec_vaddr;
|
|
|
|
asection *sec;
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
gdb_assert (bottom);
|
|
|
|
gdb_assert (top);
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* This function depends on being able to call a function in the
|
|
|
|
inferior. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (!target_has_execution)
|
2003-09-05 05:05:49 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* The following code assumes that the link map is arranged as
|
|
|
|
follows (low to high addresses):
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
---------------------------------
|
|
|
|
| text sections |
|
|
|
|
---------------------------------
|
|
|
|
| data sections (including bss) |
|
|
|
|
---------------------------------
|
|
|
|
| heap |
|
|
|
|
--------------------------------- */
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
for (sec = abfd->sections; sec; sec = sec->next)
|
|
|
|
{
|
2003-09-05 05:05:49 +08:00
|
|
|
if (bfd_get_section_flags (abfd, sec) & SEC_DATA
|
|
|
|
|| strcmp (".bss", bfd_section_name (abfd, sec)) == 0)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
|
|
|
sec_vaddr = bfd_get_section_vma (abfd, sec);
|
2004-06-15 09:04:20 +08:00
|
|
|
sec_size = bfd_get_section_size (sec);
|
2002-01-09 08:37:02 +08:00
|
|
|
if (sec_vaddr + sec_size > top_of_data_memory)
|
|
|
|
top_of_data_memory = sec_vaddr + sec_size;
|
|
|
|
}
|
|
|
|
}
|
2003-09-05 05:05:49 +08:00
|
|
|
|
2009-10-23 03:36:06 +08:00
|
|
|
top_of_heap = call_target_sbrk (0);
|
|
|
|
if (top_of_heap == (bfd_vma) 0)
|
2002-01-09 08:37:02 +08:00
|
|
|
return 0;
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Return results. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (top_of_heap > top_of_data_memory)
|
|
|
|
{
|
|
|
|
*bottom = top_of_data_memory;
|
|
|
|
*top = top_of_heap;
|
2003-09-05 05:05:49 +08:00
|
|
|
return 1;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
2003-09-05 05:05:49 +08:00
|
|
|
|
|
|
|
/* No additional heap space needs to be saved. */
|
|
|
|
return 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
make_output_phdrs (bfd *obfd, asection *osec, void *ignored)
|
|
|
|
{
|
|
|
|
int p_flags = 0;
|
2009-10-23 03:36:06 +08:00
|
|
|
int p_type = 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
/* FIXME: these constants may only be applicable for ELF. */
|
2002-04-13 07:09:48 +08:00
|
|
|
if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
|
2002-01-09 08:37:02 +08:00
|
|
|
p_type = PT_LOAD;
|
2009-10-23 03:36:06 +08:00
|
|
|
else if (strncmp (bfd_section_name (obfd, osec), "note", 4) == 0)
|
2002-01-09 08:37:02 +08:00
|
|
|
p_type = PT_NOTE;
|
2009-10-23 03:36:06 +08:00
|
|
|
else
|
|
|
|
p_type = PT_NULL;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
p_flags |= PF_R; /* Segment is readable. */
|
|
|
|
if (!(bfd_get_section_flags (obfd, osec) & SEC_READONLY))
|
|
|
|
p_flags |= PF_W; /* Segment is writable. */
|
|
|
|
if (bfd_get_section_flags (obfd, osec) & SEC_CODE)
|
|
|
|
p_flags |= PF_X; /* Segment is executable. */
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
bfd_record_phdr (obfd, p_type, 1, p_flags, 0, 0, 0, 0, 1, &osec);
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
2012-08-07 21:26:33 +08:00
|
|
|
/* find_memory_region_ftype implementation. DATA is 'bfd *' for the core file
|
|
|
|
GDB is creating. */
|
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
static int
|
2012-08-07 21:26:33 +08:00
|
|
|
gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
|
|
|
|
int write, int exec, int modified, void *data)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
2003-10-11 09:56:53 +08:00
|
|
|
bfd *obfd = data;
|
2002-01-09 08:37:02 +08:00
|
|
|
asection *osec;
|
2003-10-11 09:56:53 +08:00
|
|
|
flagword flags = SEC_ALLOC | SEC_HAS_CONTENTS | SEC_LOAD;
|
|
|
|
|
2004-01-15 02:39:08 +08:00
|
|
|
/* If the memory segment has no permissions set, ignore it, otherwise
|
|
|
|
when we later try to access it for read/write, we'll get an error
|
|
|
|
or jam the kernel. */
|
2012-08-07 21:26:33 +08:00
|
|
|
if (read == 0 && write == 0 && exec == 0 && modified == 0)
|
2004-01-15 02:39:08 +08:00
|
|
|
{
|
|
|
|
if (info_verbose)
|
|
|
|
{
|
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter.
* utils.c (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter, use it instead of current_gdbarch.
* ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter.
* ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter,
use it instead of current_gdbarch.
Update calls to ui_out_field_core_addr to pass architecture:
* ada-lang.c (print_one_exception): Update.
* breakpoint.c (print_one_breakpoint_location,
print_one_exception_catchpoint): Update.
* disasm.c (dump_insns): Update.
* darwin-nat-info.c (darwin_debug_regions_recurse): Update.
* mi/mi-main.c (mi_cmd_data_read_memory): Update.
* mi/mi-symbol-cmds.c: Include "objfiles.h".
(mi_cmd_symbol_list_lines): Update.
* stack.c (print_frame_info, print_frame): Update.
Update callers of paddress to pass architecture:
* ada-tasks.c (info_task): Update.
* ada-valprint.c (ada_val_print_1): Update.
* annotate.c (annotate_source, annotate_frame_begin): Update.
* breakpoint.c (insert_bp_location, describe_other_breakpoints,
mention): Update.
* cli/cli-cmds.c (edit_command, list_command, print_disassembly):
Update.
* corefile.c (memory_error): Update.
* c-valprint.c (print_function_pointer_address, c_val_print): Update.
* disasm.c (dis_asm_print_address): Update.
* exec.c (print_section_info): Update.
* f-valprint.c (f_val_print): Update.
* infcmd.c: Include "arch-utils.h".
(jump_command, program_info): Update.
* linux-fork.c: Include "arch-utils.h".
(info_forks_command): Update.
* m2-valprint.c (print_function_pointer_address,
print_unpacked_pointer, print_variable_at_address,
m2_val_print): Update.
* m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command):
Update.
* printcmd.c (print_address, print_address_demangle, address_info):
Update.
* p-valprint.c (pascal_val_print): Update.
* source.c: Include "arch-utils.h".
(line_info): Update.
* stack.c (frame_info, print_block_frame_labels): Update.
* symfile.c (add_symbol_file_command, list_overlays_command): Update.
* symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1,
print_symbol, print_partial_symbols, maintenance_info_psymtabs,
maintenance_check_symtabs): Update.
* symtab.c (find_pc_sect_symtab): Update.
* target.c (deprecated_debug_xfer_memory): Update.
* tracepoint.c (scope_info): Update.
* tui/tui-stack.c (tui_make_status_line): Update.
* valprint.c (val_print_string): Update.
Update callers of paddr_nz to use paddress instead (keeping
user-visible output identical):
* alpha-tdep.c (alpha_heuristic_proc_start): Update.
* amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn,
amd64_displaced_step_fixup): Update.
* arch-utils.c (simple_displaced_step_copy_insn): Update.
* auxv.c (fprint_target_auxv): Update.
* breakpoint.c (insert_single_step_breakpoint): Update.
* buildsym.c (finish_block): Update.
* cli/cli-dump.c (restore_section_callback): Update.
* fbsd-nat.c (fbsd_find_memory_regions): Update.
* frame.c (frame_unwind_register_value): Update.
* gcore.c (gcore_create_callback): Update.
* hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update.
* i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm,
i386_record_lea_modrm_addr, i386_record_lea_modrm,
i386_process_record): Update.
* ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id,
ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id,
ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update.
* infrun.c (displaced_step_prepare, displaced_step_fixup,
handle_inferior_event, insert_step_resume_breakpoint_at_sal,
insert_longjmp_resume_breakpoint): Update.
* linux-nat.c (linux_nat_find_memory_regions): Update.
* linux-record.c (record_linux_system_call): Update.
* mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call,
mips_n32n64_push_dummy_call, mips_o32_push_dummy_call,
mips_o64_push_dummy_call): Update.
* monitor.c (monitor_error, monitor_remove_breakpoint): Update.
* record.c (record_arch_list_add_mem, record_wait,
record_xfer_partial): Update.
* remote-mips.c (mips_fetch_word, mips_check_lsi_error,
mips_common_breakpoint): Update.
* remote-sim.c (gdbsim_xfer_inferior_memory): Update.
* rs6000-tdep.c (ppc_displaced_step_fixup): Update.
* solib-som.c (som_current_sos): Update.
* symfile.c (load_progress, generic_load): Update.
* symfile-mem.c (add_vsyscall_page): Update.
* valops.c (value_fetch_lazy): Update.
* windows-tdep.c (windows_xfer_shared_library): Update.
Update callers of paddr_nz to use paddress instead (changing
user-visible output to make it more correct):
* dwarf2loc.c (locexpr_describe_location): Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint,
ia64_memory_remove_breakpoint): Update.
* jv-valprint.c (java_value_print): Update.
* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
* monitor.c (monitor_read_memory): Update.
Update callers of paddr to use paddress instead (changing
user-visible output to make it more correct):
* arm-tdep.c (arm_push_dummy_call): Update.
* breakpoint.c (insert_bp_location, create_thread_event_breakpoint,
create_breakpoint): Update.
* darwin-nat-info.c (darwin_debug_regions): Update.
* dcache.c (dcache_info): Update.
* dsrec.c (load_srec, make_srec): Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program,
dwarf2_frame_cache): Update.
* gcore.c (gcore_copy_callback): Update.
* gnu-nat.c (gnu_xfer_memory): Update.
* mips-linux-nat.c (mips_show_dr): Update.
* monitor.c (monitor_write_memory, monitor_insert_breakpoint,
monitor_remove_breakpoint): Update.
* remote.c (compare_sections_command): Update.
* remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint,
m32r_remove_breakpoint, m32r_insert_watchpoint,
m32r_remove_watchpoint): Update.
* sol-thread.c (info_cb): Update.
* symfile.c (load_progress): Update.
Update callers of paddress or paddr_nz to use hex_string instead
(changes output of internal/error/debug messages only):
* dwarf2read.c (dump_die_shallow): Update.
* frame.c (fprint_field, fprint_frame, frame_pc_unwind,
get_frame_func, create_new_frame): Update.
* hppa-tdep.c (find_unwind_entry, unwind_command): Update.
* ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x,
ia64_get_dyn_info_list): Update.
* maint.c (maintenance_translate_address): Update.
* mi/mi-cmd-var.c (mi_cmd_var_create): Update.
* target.c (target_flash_erase): Update.
Update callers of paddr/paddr_nz to use phex/phex_nz instead,
using an appropriate address size. Remove use of strlen_paddr.
* exec.c (exec_files_info): Update.
* i386-nat.c (i386_show_dr): Update.
* remote.c (remote_flash_erase): Update.
* m32r-rom.c (m32r_load_section): Update.
* monitor.c (monitor_vsprintf, monitor_store_register): Update.
* remote.c (remote_check_symbols, remote_search_memory): Update.
* remote-mips.c (mips_request, mips_common_breakpoint): Update.
* scm-valprint.c (scm_ipruk, scm_scmval_print): Update.
* sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update.
* sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs,
sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs,
sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs,
sh_dsp_show_regs): Update.
* xcoffsolib.c (sharedlibrary_command): Update.
* maint.c (maint_print_section_info): Add ADDR_SIZE parameter.
Use hex_string_custom instead of paddr.
(print_bfd_section_info): Pass address size.
(print_objfile_section_info): Likewise.
* annotate.h (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* annotate.c (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* source.c (identify_source_line): Update call to annotate_source.
* stack.c (print_frame_info, print_frame): Update call to
annotate_frame_begin.
* breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter.
(create_breakpoint, create_ada_exception_breakpoint): Update call.
* stack.c (print_block_frame_labels): Add GDBARCH parameter.
(print_frame_label_vars): Update call.
* symmisc.c (print_partial_symbols): Add GDBARCH parameter.
(dump_psymtab): Update call to print_partial_symbols.
(struct print_symbol_args): Add GDBARCH member.
(dump_symtab_1): Set print_symbol_args architecture member.
(print_symbol): Use it.
* windows-tdep.h (windows_xfer_shared_library): Add GDBARCH
parameter.
* windows-tdep.c (windows_xfer_shared_library): Likewise.
* i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member.
(core_process_module_section): Pass architecture from cpms_data to
windows_xfer_shared_library.
(windows_core_xfer_shared_libraries): Initialize cmps_data
architecture member.
* windows-nat.c (windows_xfer_shared_libraries): Pass architecture
to windows_xfer_shared_library.
* defs.h (print_address): Add GDBARCH parameter.
* printcmd.c (print_address): Add GDBARCH parameter.
(print_scalar_formatted, do_examine): Update call.
* findcmd.c (find_command): Update call.
* tracepoint.c: Include "arch-utils.h".
(trace_find_line_command): Update call.
* tui/tui-disasm.c (tui_disassemble): Update call.
* value.h (print_address_demangle): Add GDBARCH parameter.
* printcmd.c (print_address_demangle): Add GDBARCH parameter.
* c-valprint.c (print_function_pointer_address, c_val_print):
Update call.
* f-valprint.c (f_val_print): Update call.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update call.
* jv-valprint.c (java_val_print): Update call.
* m2-valprint.c (print_function_pointer_address, m2_val_print):
Update call.
* p-valprint.c (pascal_val_print): Update call.
* disasm.c (gdb_disassemble_info): Install architecture into
di.application_data field.
testsuite/ChangeLog:
* gdb.threads/tls-shared.exp: Update to locexpr_describe_location
change to prefix TLS offset in hex with 0x.
doc/ChangeLog:
* gdbint.texinfo (Item Output Functions): Update signature
for ui_out_field_core_addr.
2009-07-03 01:21:10 +08:00
|
|
|
fprintf_filtered (gdb_stdout, "Ignore segment, %s bytes at %s\n",
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
plongest (size), paddress (target_gdbarch (), vaddr));
|
2004-01-15 02:39:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-07 21:26:33 +08:00
|
|
|
if (write == 0 && modified == 0 && !solib_keep_data_in_core (vaddr, size))
|
2003-10-11 09:56:53 +08:00
|
|
|
{
|
|
|
|
/* See if this region of memory lies inside a known file on disk.
|
|
|
|
If so, we can avoid copying its contents by clearing SEC_LOAD. */
|
|
|
|
struct objfile *objfile;
|
|
|
|
struct obj_section *objsec;
|
|
|
|
|
|
|
|
ALL_OBJSECTIONS (objfile, objsec)
|
|
|
|
{
|
|
|
|
bfd *abfd = objfile->obfd;
|
|
|
|
asection *asec = objsec->the_bfd_section;
|
|
|
|
bfd_vma align = (bfd_vma) 1 << bfd_get_section_alignment (abfd,
|
|
|
|
asec);
|
2008-08-20 19:21:44 +08:00
|
|
|
bfd_vma start = obj_section_addr (objsec) & -align;
|
|
|
|
bfd_vma end = (obj_section_endaddr (objsec) + align - 1) & -align;
|
2010-05-15 04:17:37 +08:00
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
/* Match if either the entire memory region lies inside the
|
|
|
|
section (i.e. a mapping covering some pages of a large
|
|
|
|
segment) or the entire section lies inside the memory region
|
|
|
|
(i.e. a mapping covering multiple small sections).
|
|
|
|
|
|
|
|
This BFD was synthesized from reading target memory,
|
|
|
|
we don't want to omit that. */
|
2013-05-07 09:38:04 +08:00
|
|
|
if (objfile->separate_debug_objfile_backlink == NULL
|
|
|
|
&& ((vaddr >= start && vaddr + size <= end)
|
|
|
|
|| (start >= vaddr && end <= vaddr + size))
|
2003-10-11 09:56:53 +08:00
|
|
|
&& !(bfd_get_file_flags (abfd) & BFD_IN_MEMORY))
|
|
|
|
{
|
2010-09-15 11:30:30 +08:00
|
|
|
flags &= ~(SEC_LOAD | SEC_HAS_CONTENTS);
|
2011-01-08 03:36:19 +08:00
|
|
|
goto keep; /* Break out of two nested for loops. */
|
2003-10-11 09:56:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 21:26:33 +08:00
|
|
|
keep:;
|
2003-10-11 09:56:53 +08:00
|
|
|
}
|
|
|
|
|
2012-08-07 21:26:33 +08:00
|
|
|
if (write == 0)
|
|
|
|
flags |= SEC_READONLY;
|
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
if (exec)
|
|
|
|
flags |= SEC_CODE;
|
|
|
|
else
|
|
|
|
flags |= SEC_DATA;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2007-06-21 02:32:10 +08:00
|
|
|
osec = bfd_make_section_anyway_with_flags (obfd, "load", flags);
|
2003-09-05 05:05:49 +08:00
|
|
|
if (osec == NULL)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 12:06:14 +08:00
|
|
|
warning (_("Couldn't make gcore segment: %s"),
|
2002-01-09 08:37:02 +08:00
|
|
|
bfd_errmsg (bfd_get_error ()));
|
2003-10-11 09:56:53 +08:00
|
|
|
return 1;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (info_verbose)
|
|
|
|
{
|
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter.
* utils.c (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter, use it instead of current_gdbarch.
* ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter.
* ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter,
use it instead of current_gdbarch.
Update calls to ui_out_field_core_addr to pass architecture:
* ada-lang.c (print_one_exception): Update.
* breakpoint.c (print_one_breakpoint_location,
print_one_exception_catchpoint): Update.
* disasm.c (dump_insns): Update.
* darwin-nat-info.c (darwin_debug_regions_recurse): Update.
* mi/mi-main.c (mi_cmd_data_read_memory): Update.
* mi/mi-symbol-cmds.c: Include "objfiles.h".
(mi_cmd_symbol_list_lines): Update.
* stack.c (print_frame_info, print_frame): Update.
Update callers of paddress to pass architecture:
* ada-tasks.c (info_task): Update.
* ada-valprint.c (ada_val_print_1): Update.
* annotate.c (annotate_source, annotate_frame_begin): Update.
* breakpoint.c (insert_bp_location, describe_other_breakpoints,
mention): Update.
* cli/cli-cmds.c (edit_command, list_command, print_disassembly):
Update.
* corefile.c (memory_error): Update.
* c-valprint.c (print_function_pointer_address, c_val_print): Update.
* disasm.c (dis_asm_print_address): Update.
* exec.c (print_section_info): Update.
* f-valprint.c (f_val_print): Update.
* infcmd.c: Include "arch-utils.h".
(jump_command, program_info): Update.
* linux-fork.c: Include "arch-utils.h".
(info_forks_command): Update.
* m2-valprint.c (print_function_pointer_address,
print_unpacked_pointer, print_variable_at_address,
m2_val_print): Update.
* m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command):
Update.
* printcmd.c (print_address, print_address_demangle, address_info):
Update.
* p-valprint.c (pascal_val_print): Update.
* source.c: Include "arch-utils.h".
(line_info): Update.
* stack.c (frame_info, print_block_frame_labels): Update.
* symfile.c (add_symbol_file_command, list_overlays_command): Update.
* symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1,
print_symbol, print_partial_symbols, maintenance_info_psymtabs,
maintenance_check_symtabs): Update.
* symtab.c (find_pc_sect_symtab): Update.
* target.c (deprecated_debug_xfer_memory): Update.
* tracepoint.c (scope_info): Update.
* tui/tui-stack.c (tui_make_status_line): Update.
* valprint.c (val_print_string): Update.
Update callers of paddr_nz to use paddress instead (keeping
user-visible output identical):
* alpha-tdep.c (alpha_heuristic_proc_start): Update.
* amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn,
amd64_displaced_step_fixup): Update.
* arch-utils.c (simple_displaced_step_copy_insn): Update.
* auxv.c (fprint_target_auxv): Update.
* breakpoint.c (insert_single_step_breakpoint): Update.
* buildsym.c (finish_block): Update.
* cli/cli-dump.c (restore_section_callback): Update.
* fbsd-nat.c (fbsd_find_memory_regions): Update.
* frame.c (frame_unwind_register_value): Update.
* gcore.c (gcore_create_callback): Update.
* hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update.
* i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm,
i386_record_lea_modrm_addr, i386_record_lea_modrm,
i386_process_record): Update.
* ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id,
ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id,
ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update.
* infrun.c (displaced_step_prepare, displaced_step_fixup,
handle_inferior_event, insert_step_resume_breakpoint_at_sal,
insert_longjmp_resume_breakpoint): Update.
* linux-nat.c (linux_nat_find_memory_regions): Update.
* linux-record.c (record_linux_system_call): Update.
* mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call,
mips_n32n64_push_dummy_call, mips_o32_push_dummy_call,
mips_o64_push_dummy_call): Update.
* monitor.c (monitor_error, monitor_remove_breakpoint): Update.
* record.c (record_arch_list_add_mem, record_wait,
record_xfer_partial): Update.
* remote-mips.c (mips_fetch_word, mips_check_lsi_error,
mips_common_breakpoint): Update.
* remote-sim.c (gdbsim_xfer_inferior_memory): Update.
* rs6000-tdep.c (ppc_displaced_step_fixup): Update.
* solib-som.c (som_current_sos): Update.
* symfile.c (load_progress, generic_load): Update.
* symfile-mem.c (add_vsyscall_page): Update.
* valops.c (value_fetch_lazy): Update.
* windows-tdep.c (windows_xfer_shared_library): Update.
Update callers of paddr_nz to use paddress instead (changing
user-visible output to make it more correct):
* dwarf2loc.c (locexpr_describe_location): Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint,
ia64_memory_remove_breakpoint): Update.
* jv-valprint.c (java_value_print): Update.
* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
* monitor.c (monitor_read_memory): Update.
Update callers of paddr to use paddress instead (changing
user-visible output to make it more correct):
* arm-tdep.c (arm_push_dummy_call): Update.
* breakpoint.c (insert_bp_location, create_thread_event_breakpoint,
create_breakpoint): Update.
* darwin-nat-info.c (darwin_debug_regions): Update.
* dcache.c (dcache_info): Update.
* dsrec.c (load_srec, make_srec): Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program,
dwarf2_frame_cache): Update.
* gcore.c (gcore_copy_callback): Update.
* gnu-nat.c (gnu_xfer_memory): Update.
* mips-linux-nat.c (mips_show_dr): Update.
* monitor.c (monitor_write_memory, monitor_insert_breakpoint,
monitor_remove_breakpoint): Update.
* remote.c (compare_sections_command): Update.
* remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint,
m32r_remove_breakpoint, m32r_insert_watchpoint,
m32r_remove_watchpoint): Update.
* sol-thread.c (info_cb): Update.
* symfile.c (load_progress): Update.
Update callers of paddress or paddr_nz to use hex_string instead
(changes output of internal/error/debug messages only):
* dwarf2read.c (dump_die_shallow): Update.
* frame.c (fprint_field, fprint_frame, frame_pc_unwind,
get_frame_func, create_new_frame): Update.
* hppa-tdep.c (find_unwind_entry, unwind_command): Update.
* ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x,
ia64_get_dyn_info_list): Update.
* maint.c (maintenance_translate_address): Update.
* mi/mi-cmd-var.c (mi_cmd_var_create): Update.
* target.c (target_flash_erase): Update.
Update callers of paddr/paddr_nz to use phex/phex_nz instead,
using an appropriate address size. Remove use of strlen_paddr.
* exec.c (exec_files_info): Update.
* i386-nat.c (i386_show_dr): Update.
* remote.c (remote_flash_erase): Update.
* m32r-rom.c (m32r_load_section): Update.
* monitor.c (monitor_vsprintf, monitor_store_register): Update.
* remote.c (remote_check_symbols, remote_search_memory): Update.
* remote-mips.c (mips_request, mips_common_breakpoint): Update.
* scm-valprint.c (scm_ipruk, scm_scmval_print): Update.
* sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update.
* sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs,
sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs,
sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs,
sh_dsp_show_regs): Update.
* xcoffsolib.c (sharedlibrary_command): Update.
* maint.c (maint_print_section_info): Add ADDR_SIZE parameter.
Use hex_string_custom instead of paddr.
(print_bfd_section_info): Pass address size.
(print_objfile_section_info): Likewise.
* annotate.h (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* annotate.c (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* source.c (identify_source_line): Update call to annotate_source.
* stack.c (print_frame_info, print_frame): Update call to
annotate_frame_begin.
* breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter.
(create_breakpoint, create_ada_exception_breakpoint): Update call.
* stack.c (print_block_frame_labels): Add GDBARCH parameter.
(print_frame_label_vars): Update call.
* symmisc.c (print_partial_symbols): Add GDBARCH parameter.
(dump_psymtab): Update call to print_partial_symbols.
(struct print_symbol_args): Add GDBARCH member.
(dump_symtab_1): Set print_symbol_args architecture member.
(print_symbol): Use it.
* windows-tdep.h (windows_xfer_shared_library): Add GDBARCH
parameter.
* windows-tdep.c (windows_xfer_shared_library): Likewise.
* i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member.
(core_process_module_section): Pass architecture from cpms_data to
windows_xfer_shared_library.
(windows_core_xfer_shared_libraries): Initialize cmps_data
architecture member.
* windows-nat.c (windows_xfer_shared_libraries): Pass architecture
to windows_xfer_shared_library.
* defs.h (print_address): Add GDBARCH parameter.
* printcmd.c (print_address): Add GDBARCH parameter.
(print_scalar_formatted, do_examine): Update call.
* findcmd.c (find_command): Update call.
* tracepoint.c: Include "arch-utils.h".
(trace_find_line_command): Update call.
* tui/tui-disasm.c (tui_disassemble): Update call.
* value.h (print_address_demangle): Add GDBARCH parameter.
* printcmd.c (print_address_demangle): Add GDBARCH parameter.
* c-valprint.c (print_function_pointer_address, c_val_print):
Update call.
* f-valprint.c (f_val_print): Update call.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update call.
* jv-valprint.c (java_val_print): Update call.
* m2-valprint.c (print_function_pointer_address, m2_val_print):
Update call.
* p-valprint.c (pascal_val_print): Update call.
* disasm.c (gdb_disassemble_info): Install architecture into
di.application_data field.
testsuite/ChangeLog:
* gdb.threads/tls-shared.exp: Update to locexpr_describe_location
change to prefix TLS offset in hex with 0x.
doc/ChangeLog:
* gdbint.texinfo (Item Output Functions): Update signature
for ui_out_field_core_addr.
2009-07-03 01:21:10 +08:00
|
|
|
fprintf_filtered (gdb_stdout, "Save segment, %s bytes at %s\n",
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
plongest (size), paddress (target_gdbarch (), vaddr));
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bfd_set_section_size (obfd, osec, size);
|
2003-10-11 09:56:53 +08:00
|
|
|
bfd_set_section_vma (obfd, osec, vaddr);
|
2003-09-05 05:05:49 +08:00
|
|
|
bfd_section_lma (obfd, osec) = 0; /* ??? bfd_set_section_lma? */
|
2003-10-11 09:56:53 +08:00
|
|
|
return 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-09-01 02:08:43 +08:00
|
|
|
objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
|
2002-01-09 08:37:02 +08:00
|
|
|
{
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Use objfile data to create memory sections. */
|
2002-01-09 08:37:02 +08:00
|
|
|
struct objfile *objfile;
|
|
|
|
struct obj_section *objsec;
|
|
|
|
bfd_vma temp_bottom, temp_top;
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Call callback function for each objfile section. */
|
2002-01-09 08:37:02 +08:00
|
|
|
ALL_OBJSECTIONS (objfile, objsec)
|
|
|
|
{
|
|
|
|
bfd *ibfd = objfile->obfd;
|
|
|
|
asection *isec = objsec->the_bfd_section;
|
|
|
|
flagword flags = bfd_get_section_flags (ibfd, isec);
|
|
|
|
|
2012-08-07 21:26:33 +08:00
|
|
|
/* Separate debug info files are irrelevant for gcore. */
|
|
|
|
if (objfile->separate_debug_objfile_backlink != NULL)
|
|
|
|
continue;
|
|
|
|
|
2002-01-09 08:37:02 +08:00
|
|
|
if ((flags & SEC_ALLOC) || (flags & SEC_LOAD))
|
|
|
|
{
|
|
|
|
int size = bfd_section_size (ibfd, isec);
|
|
|
|
int ret;
|
|
|
|
|
2010-05-07 10:09:55 +08:00
|
|
|
ret = (*func) (obj_section_addr (objsec), size,
|
2003-09-05 05:05:49 +08:00
|
|
|
1, /* All sections will be readable. */
|
|
|
|
(flags & SEC_READONLY) == 0, /* Writable. */
|
|
|
|
(flags & SEC_CODE) != 0, /* Executable. */
|
2012-08-07 21:26:33 +08:00
|
|
|
1, /* MODIFIED is unknown, pass it as true. */
|
2003-09-05 05:05:49 +08:00
|
|
|
obfd);
|
|
|
|
if (ret != 0)
|
2002-01-09 08:37:02 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Make a stack segment. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (derive_stack_segment (&temp_bottom, &temp_top))
|
2003-10-11 09:56:53 +08:00
|
|
|
(*func) (temp_bottom, temp_top - temp_bottom,
|
2003-09-05 05:05:49 +08:00
|
|
|
1, /* Stack section will be readable. */
|
|
|
|
1, /* Stack section will be writable. */
|
|
|
|
0, /* Stack section will not be executable. */
|
2012-08-07 21:26:33 +08:00
|
|
|
1, /* Stack section will be modified. */
|
2002-01-09 08:37:02 +08:00
|
|
|
obfd);
|
|
|
|
|
2011-01-08 03:36:19 +08:00
|
|
|
/* Make a heap segment. */
|
2002-01-09 08:37:02 +08:00
|
|
|
if (derive_heap_segment (exec_bfd, &temp_bottom, &temp_top))
|
2003-09-05 05:05:49 +08:00
|
|
|
(*func) (temp_bottom, temp_top - temp_bottom,
|
|
|
|
1, /* Heap section will be readable. */
|
|
|
|
1, /* Heap section will be writable. */
|
|
|
|
0, /* Heap section will not be executable. */
|
2012-08-07 21:26:33 +08:00
|
|
|
1, /* Heap section will be modified. */
|
2002-01-09 08:37:02 +08:00
|
|
|
obfd);
|
2003-09-05 05:05:49 +08:00
|
|
|
|
2002-01-09 08:37:02 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gcore_copy_callback (bfd *obfd, asection *osec, void *ignored)
|
|
|
|
{
|
2006-10-21 06:06:28 +08:00
|
|
|
bfd_size_type size, total_size = bfd_section_size (obfd, osec);
|
|
|
|
file_ptr offset = 0;
|
2002-01-09 08:37:02 +08:00
|
|
|
struct cleanup *old_chain = NULL;
|
|
|
|
void *memhunk;
|
|
|
|
|
2003-10-11 09:56:53 +08:00
|
|
|
/* Read-only sections are marked; we don't have to copy their contents. */
|
|
|
|
if ((bfd_get_section_flags (obfd, osec) & SEC_LOAD) == 0)
|
2003-09-05 05:05:49 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Only interested in "load" sections. */
|
2002-04-13 07:09:48 +08:00
|
|
|
if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
|
2003-09-05 05:05:49 +08:00
|
|
|
return;
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2006-10-21 06:06:28 +08:00
|
|
|
size = min (total_size, MAX_COPY_BYTES);
|
2003-09-05 05:05:49 +08:00
|
|
|
memhunk = xmalloc (size);
|
2002-01-09 08:37:02 +08:00
|
|
|
old_chain = make_cleanup (xfree, memhunk);
|
|
|
|
|
2006-10-21 06:06:28 +08:00
|
|
|
while (total_size > 0)
|
|
|
|
{
|
|
|
|
if (size > total_size)
|
|
|
|
size = total_size;
|
|
|
|
|
|
|
|
if (target_read_memory (bfd_section_vma (obfd, osec) + offset,
|
|
|
|
memhunk, size) != 0)
|
|
|
|
{
|
2011-01-06 06:22:53 +08:00
|
|
|
warning (_("Memory read failed for corefile "
|
|
|
|
"section, %s bytes at %s."),
|
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter.
* utils.c (strlen_paddr, paddr, paddr_nz): Remove.
(paddress): Add GDBARCH parameter, use it instead of current_gdbarch.
* ui-out.h (ui_out_field_core_addr): Add GDBARCH parameter.
* ui-out.c (ui_out_field_core_addr): Add GDBARCH parameter,
use it instead of current_gdbarch.
Update calls to ui_out_field_core_addr to pass architecture:
* ada-lang.c (print_one_exception): Update.
* breakpoint.c (print_one_breakpoint_location,
print_one_exception_catchpoint): Update.
* disasm.c (dump_insns): Update.
* darwin-nat-info.c (darwin_debug_regions_recurse): Update.
* mi/mi-main.c (mi_cmd_data_read_memory): Update.
* mi/mi-symbol-cmds.c: Include "objfiles.h".
(mi_cmd_symbol_list_lines): Update.
* stack.c (print_frame_info, print_frame): Update.
Update callers of paddress to pass architecture:
* ada-tasks.c (info_task): Update.
* ada-valprint.c (ada_val_print_1): Update.
* annotate.c (annotate_source, annotate_frame_begin): Update.
* breakpoint.c (insert_bp_location, describe_other_breakpoints,
mention): Update.
* cli/cli-cmds.c (edit_command, list_command, print_disassembly):
Update.
* corefile.c (memory_error): Update.
* c-valprint.c (print_function_pointer_address, c_val_print): Update.
* disasm.c (dis_asm_print_address): Update.
* exec.c (print_section_info): Update.
* f-valprint.c (f_val_print): Update.
* infcmd.c: Include "arch-utils.h".
(jump_command, program_info): Update.
* linux-fork.c: Include "arch-utils.h".
(info_forks_command): Update.
* m2-valprint.c (print_function_pointer_address,
print_unpacked_pointer, print_variable_at_address,
m2_val_print): Update.
* m32r-rom.c (m32r_load_section, m32r_load, m32r_upload_command):
Update.
* printcmd.c (print_address, print_address_demangle, address_info):
Update.
* p-valprint.c (pascal_val_print): Update.
* source.c: Include "arch-utils.h".
(line_info): Update.
* stack.c (frame_info, print_block_frame_labels): Update.
* symfile.c (add_symbol_file_command, list_overlays_command): Update.
* symmisc.c (dump_msymbols, dump_psymtab, dump_symtab_1,
print_symbol, print_partial_symbols, maintenance_info_psymtabs,
maintenance_check_symtabs): Update.
* symtab.c (find_pc_sect_symtab): Update.
* target.c (deprecated_debug_xfer_memory): Update.
* tracepoint.c (scope_info): Update.
* tui/tui-stack.c (tui_make_status_line): Update.
* valprint.c (val_print_string): Update.
Update callers of paddr_nz to use paddress instead (keeping
user-visible output identical):
* alpha-tdep.c (alpha_heuristic_proc_start): Update.
* amd64-tdep.c (fixup_riprel, amd64_displaced_step_copy_insn,
amd64_displaced_step_fixup): Update.
* arch-utils.c (simple_displaced_step_copy_insn): Update.
* auxv.c (fprint_target_auxv): Update.
* breakpoint.c (insert_single_step_breakpoint): Update.
* buildsym.c (finish_block): Update.
* cli/cli-dump.c (restore_section_callback): Update.
* fbsd-nat.c (fbsd_find_memory_regions): Update.
* frame.c (frame_unwind_register_value): Update.
* gcore.c (gcore_create_callback): Update.
* hppa-tdep.c (hppa_frame_cache, hppa_skip_trampoline_code): Update.
* i386-tdep.c (i386_displaced_step_fixup, i386_record_modrm,
i386_record_lea_modrm_addr, i386_record_lea_modrm,
i386_process_record): Update.
* ia64-tdep.c (ia64_frame_this_id, ia64_sigtramp_frame_this_id,
ia64_libunwind_frame_this_id, ia64_libunwind_sigtramp_frame_this_id,
ia64_dummy_id, ia64_access_reg, ia64_access_rse_reg): Update.
* infrun.c (displaced_step_prepare, displaced_step_fixup,
handle_inferior_event, insert_step_resume_breakpoint_at_sal,
insert_longjmp_resume_breakpoint): Update.
* linux-nat.c (linux_nat_find_memory_regions): Update.
* linux-record.c (record_linux_system_call): Update.
* mips-tdep.c (heuristic_proc_start, mips_eabi_push_dummy_call,
mips_n32n64_push_dummy_call, mips_o32_push_dummy_call,
mips_o64_push_dummy_call): Update.
* monitor.c (monitor_error, monitor_remove_breakpoint): Update.
* record.c (record_arch_list_add_mem, record_wait,
record_xfer_partial): Update.
* remote-mips.c (mips_fetch_word, mips_check_lsi_error,
mips_common_breakpoint): Update.
* remote-sim.c (gdbsim_xfer_inferior_memory): Update.
* rs6000-tdep.c (ppc_displaced_step_fixup): Update.
* solib-som.c (som_current_sos): Update.
* symfile.c (load_progress, generic_load): Update.
* symfile-mem.c (add_vsyscall_page): Update.
* valops.c (value_fetch_lazy): Update.
* windows-tdep.c (windows_xfer_shared_library): Update.
Update callers of paddr_nz to use paddress instead (changing
user-visible output to make it more correct):
* dwarf2loc.c (locexpr_describe_location): Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint,
ia64_memory_remove_breakpoint): Update.
* jv-valprint.c (java_value_print): Update.
* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
* monitor.c (monitor_read_memory): Update.
Update callers of paddr to use paddress instead (changing
user-visible output to make it more correct):
* arm-tdep.c (arm_push_dummy_call): Update.
* breakpoint.c (insert_bp_location, create_thread_event_breakpoint,
create_breakpoint): Update.
* darwin-nat-info.c (darwin_debug_regions): Update.
* dcache.c (dcache_info): Update.
* dsrec.c (load_srec, make_srec): Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program,
dwarf2_frame_cache): Update.
* gcore.c (gcore_copy_callback): Update.
* gnu-nat.c (gnu_xfer_memory): Update.
* mips-linux-nat.c (mips_show_dr): Update.
* monitor.c (monitor_write_memory, monitor_insert_breakpoint,
monitor_remove_breakpoint): Update.
* remote.c (compare_sections_command): Update.
* remote-m32r-sdi.c (m32r_xfer_memory, m32r_insert_breakpoint,
m32r_remove_breakpoint, m32r_insert_watchpoint,
m32r_remove_watchpoint): Update.
* sol-thread.c (info_cb): Update.
* symfile.c (load_progress): Update.
Update callers of paddress or paddr_nz to use hex_string instead
(changes output of internal/error/debug messages only):
* dwarf2read.c (dump_die_shallow): Update.
* frame.c (fprint_field, fprint_frame, frame_pc_unwind,
get_frame_func, create_new_frame): Update.
* hppa-tdep.c (find_unwind_entry, unwind_command): Update.
* ia64-tdep.c (get_kernel_table, ia64_find_proc_info_x,
ia64_get_dyn_info_list): Update.
* maint.c (maintenance_translate_address): Update.
* mi/mi-cmd-var.c (mi_cmd_var_create): Update.
* target.c (target_flash_erase): Update.
Update callers of paddr/paddr_nz to use phex/phex_nz instead,
using an appropriate address size. Remove use of strlen_paddr.
* exec.c (exec_files_info): Update.
* i386-nat.c (i386_show_dr): Update.
* remote.c (remote_flash_erase): Update.
* m32r-rom.c (m32r_load_section): Update.
* monitor.c (monitor_vsprintf, monitor_store_register): Update.
* remote.c (remote_check_symbols, remote_search_memory): Update.
* remote-mips.c (mips_request, mips_common_breakpoint): Update.
* scm-valprint.c (scm_ipruk, scm_scmval_print): Update.
* sh64-tdep.c (sh64_show_media_regs, sh64_show_compact_regs): Update.
* sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs,
sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs,
sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs,
sh_dsp_show_regs): Update.
* xcoffsolib.c (sharedlibrary_command): Update.
* maint.c (maint_print_section_info): Add ADDR_SIZE parameter.
Use hex_string_custom instead of paddr.
(print_bfd_section_info): Pass address size.
(print_objfile_section_info): Likewise.
* annotate.h (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* annotate.c (annotate_source): Add GDBARCH parameter.
(annotate_frame_begin): Likewise.
* source.c (identify_source_line): Update call to annotate_source.
* stack.c (print_frame_info, print_frame): Update call to
annotate_frame_begin.
* breakpoint.c (describe_other_breakpoints): Add GDBARCH parameter.
(create_breakpoint, create_ada_exception_breakpoint): Update call.
* stack.c (print_block_frame_labels): Add GDBARCH parameter.
(print_frame_label_vars): Update call.
* symmisc.c (print_partial_symbols): Add GDBARCH parameter.
(dump_psymtab): Update call to print_partial_symbols.
(struct print_symbol_args): Add GDBARCH member.
(dump_symtab_1): Set print_symbol_args architecture member.
(print_symbol): Use it.
* windows-tdep.h (windows_xfer_shared_library): Add GDBARCH
parameter.
* windows-tdep.c (windows_xfer_shared_library): Likewise.
* i386-cygwin-tdep.c (struct cpms_data): Add GDBARCH member.
(core_process_module_section): Pass architecture from cpms_data to
windows_xfer_shared_library.
(windows_core_xfer_shared_libraries): Initialize cmps_data
architecture member.
* windows-nat.c (windows_xfer_shared_libraries): Pass architecture
to windows_xfer_shared_library.
* defs.h (print_address): Add GDBARCH parameter.
* printcmd.c (print_address): Add GDBARCH parameter.
(print_scalar_formatted, do_examine): Update call.
* findcmd.c (find_command): Update call.
* tracepoint.c: Include "arch-utils.h".
(trace_find_line_command): Update call.
* tui/tui-disasm.c (tui_disassemble): Update call.
* value.h (print_address_demangle): Add GDBARCH parameter.
* printcmd.c (print_address_demangle): Add GDBARCH parameter.
* c-valprint.c (print_function_pointer_address, c_val_print):
Update call.
* f-valprint.c (f_val_print): Update call.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update call.
* jv-valprint.c (java_val_print): Update call.
* m2-valprint.c (print_function_pointer_address, m2_val_print):
Update call.
* p-valprint.c (pascal_val_print): Update call.
* disasm.c (gdb_disassemble_info): Install architecture into
di.application_data field.
testsuite/ChangeLog:
* gdb.threads/tls-shared.exp: Update to locexpr_describe_location
change to prefix TLS offset in hex with 0x.
doc/ChangeLog:
* gdbint.texinfo (Item Output Functions): Update signature
for ui_out_field_core_addr.
2009-07-03 01:21:10 +08:00
|
|
|
plongest (size),
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
paddress (target_gdbarch (), bfd_section_vma (obfd, osec)));
|
2006-10-21 06:06:28 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!bfd_set_section_contents (obfd, osec, memhunk, offset, size))
|
|
|
|
{
|
|
|
|
warning (_("Failed to write corefile contents (%s)."),
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
total_size -= size;
|
|
|
|
offset += size;
|
|
|
|
}
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
do_cleanups (old_chain); /* Frees MEMHUNK. */
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gcore_memory_sections (bfd *obfd)
|
|
|
|
{
|
2012-01-20 17:59:15 +08:00
|
|
|
/* Try gdbarch method first, then fall back to target method. */
|
* gdbarch.sh (target_gdbarch): Remove macro.
(get_target_gdbarch): Rename to target_gdbarch.
* gdbarch.c, gdbarch.h: Rebuild.
* ada-tasks.c, aix-thread.c, amd64-linux-nat.c, arch-utils.c,
arm-tdep.c, auxv.c, breakpoint.c, bsd-uthread.c, corefile.c,
darwin-nat-info.c, dcache.c, dsrec.c, exec.c, fbsd-nat.c,
filesystem.c, gcore.c, gnu-nat.c, i386-darwin-nat.c, i386-nat.c,
ia64-vms-tdep.c, inf-ptrace.c, infcmd.c, jit.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, m32r-rom.c, memattr.c,
mep-tdep.c, microblaze-tdep.c, mips-linux-nat.c,
mips-linux-tdep.c, mips-tdep.c, monitor.c, moxie-tdep.c,
nto-procfs.c, nto-tdep.c, ppc-linux-nat.c, proc-service.c,
procfs.c, progspace.c, ravenscar-thread.c, record.c,
remote-m32r-sdi.c, remote-mips.c, remote-sim.c, remote.c,
rl78-tdep.c, rs6000-nat.c, rx-tdep.c, s390-nat.c, sol-thread.c,
solib-darwin.c, solib-dsbt.c, solib-frv.c, solib-ia64-hpux.c,
solib-irix.c, solib-pa64.c, solib-som.c, solib-spu.c,
solib-sunos.c, solib-svr4.c, solib.c, spu-linux-nat.c,
spu-multiarch.c, spu-tdep.c, symfile-mem.c, symfile.c, symtab.c,
target-descriptions.c, target.c, target.h, tracepoint.c,
windows-nat.c, windows-tdep.c, xcoffsolib.c, cli/cli-dump.c,
common/agent.c, mi/mi-interp.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/python.c: Update.
2012-11-10 03:58:03 +08:00
|
|
|
if (!gdbarch_find_memory_regions_p (target_gdbarch ())
|
|
|
|
|| gdbarch_find_memory_regions (target_gdbarch (),
|
2012-01-20 17:59:15 +08:00
|
|
|
gcore_create_callback, obfd) != 0)
|
|
|
|
{
|
|
|
|
if (target_find_memory_regions (gcore_create_callback, obfd) != 0)
|
|
|
|
return 0; /* FIXME: error return/msg? */
|
|
|
|
}
|
2002-01-09 08:37:02 +08:00
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Record phdrs for section-to-segment mapping. */
|
2002-01-09 08:37:02 +08:00
|
|
|
bfd_map_over_sections (obfd, make_output_phdrs, NULL);
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
/* Copy memory region contents. */
|
2002-01-09 08:37:02 +08:00
|
|
|
bfd_map_over_sections (obfd, gcore_copy_callback, NULL);
|
|
|
|
|
2003-09-05 05:05:49 +08:00
|
|
|
return 1;
|
2002-01-09 08:37:02 +08:00
|
|
|
}
|
|
|
|
|
2008-02-21 Pedro Alves <pedro@codesorcery.com>
Silence a few -Wmissing-prototypes warnings.
PR build/9877:
* amd64-nat.c: Include "amd64-nat.h".
* fork-child.c (_initialize_fork_child): Ditto.
* gcore.c (_initialize_gcore): Ditto.
* inf-ptrace.c: Include "inf-ptrace.h".
(inf_ptrace_store_registers): Make it static.
* linux-nat.c (linux_nat_terminal_ours): Make it static.
(_initialize_linux_nat): Declare before definition.
* linux-tdep.c: Include "linux-tdep.h".
* linux-thread-db.c (_initialize_thread_db): Declare before
definition.
* proc-service.c (_initialize_proc_service): Ditto.
* remote.c (remote_send_printf): Make it static.
* solib.c: Include "solib.h".
* symfile-mem.c (_initialize_symfile_mem): Declare before
definition.
* ada-lang.c (ada_la_decode, ada_match_name)
(ada_suppress_symbol_printing, ada_is_array_type)
(ada_value_ptr_subscript, ada_array_length)
(ada_to_static_fixed_value): Make them static.
(_initialize_ada_language): Declare before definition.
* ada-tasks.c (ada_get_task_number, ada_get_environment_task)
(ada_task_list_changed, ada_new_objfile_observer): Make them
static.
(_initialize_tasks): Declare before definition.
* addrmap.c (_initialize_addrmap): Declare before definition.
* auxv.c (default_auxv_parse): Make it static.
* bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make
them static.
* breakpoint.c (remove_sal): Add line break.
(expand_line_sal_maybe): Make it static.
* cp-name-parser.y: Include "cp-support.h".
* cp-valprint.c (cp_find_class_member): Make it static.
* eval.c (value_f90_subarray): Ditto.
* exceptions.c (print_any_exception): Ditto.
* findcmd.c (_initialize_mem_search): Declare before definition.
* frame.c (frame_observer_target_changed): Make it static.
* gnu-v3-abi.c (gnuv3_find_method_in): Make it static.
* inf-child.c: Include "inf-child.h".
* inferior.h (valid_inferior_id): Rename to ...
(valid_gdb_inferior_id): ... this.
* infrun.c (infrun_thread_stop_requested, siginfo_make_value):
Make them static.
* jv-lang.c (java_language_arch_info): Make it static.
* m2-typeprint.c (m2_get_discrete_bounds): Ditto.
* osdata.c (info_osdata_command): Make it static.
* regcache.c (regcache_observer_target_changed): Make it static.
* reverse.c (_initialize_reverse): Declare before definition.
* stabsread.c (cleanup_undefined_types_noname)
(cleanup_undefined_types_1): Make them static.
* symfile.c (place_section): Make it static.
* symtab.c (find_pc_sect_psymtab_closer): Make it static.
* target-descriptions.c (_initialize_target_descriptions): Declare
before definition.
* target.c (default_get_ada_task_ptid, find_default_can_async_p)
(find_default_is_async_p, find_default_supports_non_stop): Make
them static.
(target_supports_non_stop): Add prototype.
(dummy_pid_to_str): Make it static.
* utils.c (_initialize_utils): Declare before definition.
* ada-exp.y (_initialize_ada_exp): Declare before definition.
* solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype.
* target.h (struct target_ops): Add a prototype to the
to_can_execute_reverse callback.
* macroscope.c (_initialize_macroscope): Declare before definition.
* cp-namespace.c (_initialize_cp_namespace): Declare before definition.
* python/python.c (_initialize_python): Declare before definition.
* tui/tui-command.c: Include "tui/tui-command.h".
* tui/tui-data.c (init_content_element, init_win_info): Make them
static.
* tui/tui-disasm.c: Include "tui/tui-disasm.h".
* tui/tui-interp.c (_initialize_tui_interp): Declare before
definition.
* tui/tui-layout.c: Include "tui/tui-layout.h".
(_initialize_tui_layout): Declare before definition.
* tui/tui-regs.c: Include "tui/tui-regs.h".
(tui_display_reg_element_at_line): Make it static.
(_initialize_tui_regs): Declare before definition.
* tui/tui-stack.c (_initialize_tui_stack): Declare before
definition.
* tui/tui-win.c: Include "tui/tui-win.h".
(_initialize_tui_win): Declare before definition.
(tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH.
* tui/tui-win.h (tui_sigwinch_handler): Delete declaration.
(tui_get_cmd_list): Add a prototype.
* tui/tui-windata.c: Include tui-windata.h.
* tui/tui-wingeneral.c (box_win): Make it static.
* cli/cli-logging.c (show_logging_command): Make it static.
(_initialize_cli_logging): Declare before definition.
* mi/mi-common.c (_initialize_gdb_mi_common): Declare before
definition.
2009-02-22 00:14:50 +08:00
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
|
|
extern initialize_file_ftype _initialize_gcore;
|
|
|
|
|
2002-01-09 08:37:02 +08:00
|
|
|
void
|
|
|
|
_initialize_gcore (void)
|
|
|
|
{
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 23:49:28 +08:00
|
|
|
add_com ("generate-core-file", class_files, gcore_command, _("\
|
2003-09-05 05:05:49 +08:00
|
|
|
Save a core file with the current state of the debugged process.\n\
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 23:49:28 +08:00
|
|
|
Argument is optional filename. Default filename is 'core.<process_id>'."));
|
2002-01-09 08:37:02 +08:00
|
|
|
|
|
|
|
add_com_alias ("gcore", "generate-core-file", class_files, 1);
|
|
|
|
exec_set_find_memory_regions (objfile_find_memory_regions);
|
|
|
|
}
|