Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [PATCH/RFA] Don't gdbarch_init for core files
@ 2002-05-17  6:58 m.m.kettenis
  2002-05-17 10:47 ` Jason R Thorpe
  2002-05-17 10:54 ` Michael Snyder
  0 siblings, 2 replies; 14+ messages in thread
From: m.m.kettenis @ 2002-05-17  6:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: msnyder, drow, ac131313, thorpej

Michael Snyder wrote:
> > > I guess I really do need to know why the change was added in the first
> > > place (the message with the original patch doesn't describe the problem
> > > the patch is trying to solve).
> > > Just a guess - debugging a core file without an original binary?
>
> Bingo!   ;-)

Ah, but in that case, why not call set_gdbarch_from_file() only when exec_bfd is NULL?  As in:

  if (!exec_bfd)
    set_gdbarch_from_file (core_bfd);

I tested this, and it seems to solve the problems for me when testing my pending i386 multi-arch patches on Linux.

Mark




^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH/RFA] Don't gdbarch_init for core files
@ 2002-05-09 18:58 Jason R Thorpe
  2002-05-09 20:04 ` Andrew Cagney
  0 siblings, 1 reply; 14+ messages in thread
From: Jason R Thorpe @ 2002-05-09 18:58 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

As discussed on gdb@, there is a problem involving gdbarch and core
files.

At least GNU/Linux and NetBSD identify executables using note sections.
Many targets use this to select the OS/ABI variant for the target.

The problem is that if you are debugging a core file, the core file is
loaded after the executable, and the current code re-initializes the
current gdbarch based on the core file.

Since the core file lacks the same markings as the executable, the
gdbarch that results is unable to debug the executable+core.

There are other problems, as well.  The core file often doesn't have
the same flags as an executable -- consider the flags the MIPS target
uses to decide between o32, o64, n32, etc.  These flags may not be
present in the core file (indeed -- the core file is just a memory image,
and doens't really have an "ABI", per se).  The ABI, again, really comes
from the executable.

At the very least, it has befuddled Daniel and me :-)

The following patch fixes this problem (which can be easily demonstrated
by simply doing "gdb a.out a.out.core" on any target that supports OS/ABI
variants).

	* corelow.c (core_open): Don't reinitialize the current
	gdbarch.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

[-- Attachment #2: core-patch --]
[-- Type: text/plain, Size: 506 bytes --]

Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.21
diff -u -r1.21 corelow.c
--- corelow.c	5 May 2002 01:15:13 -0000	1.21
+++ corelow.c	10 May 2002 01:40:13 -0000
@@ -321,8 +321,6 @@
     error ("\"%s\": Can't find sections: %s",
 	   bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
 
-  set_gdbarch_from_file (core_bfd);
-
   ontop = !push_target (&core_ops);
   discard_cleanups (old_chain);
 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-05-17 23:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-17  6:58 [PATCH/RFA] Don't gdbarch_init for core files m.m.kettenis
2002-05-17 10:47 ` Jason R Thorpe
2002-05-17 10:59   ` Michael Snyder
2002-05-17 16:06     ` Mark Kettenis
2002-05-17 10:54 ` Michael Snyder
  -- strict thread matches above, loose matches on Subject: below --
2002-05-09 18:58 Jason R Thorpe
2002-05-09 20:04 ` Andrew Cagney
2002-05-09 21:21   ` Jason R Thorpe
2002-05-11 19:48     ` Andrew Cagney
2002-05-11 20:30       ` Jason R Thorpe
2002-05-11 20:46         ` Daniel Jacobowitz
2002-05-16 16:24           ` Michael Snyder
2002-05-16 16:24       ` Michael Snyder
2002-05-16 17:33         ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox