* gdb 6.5 does not open linux kernel core file properly
@ 2007-05-01 10:42 Vivek Goyal
2007-06-03 9:35 ` Bernhard Walle
0 siblings, 1 reply; 3+ messages in thread
From: Vivek Goyal @ 2007-05-01 10:42 UTC (permalink / raw)
To: gdb; +Cc: Eric W. Biederman, Andi Kleen, Kexec Mailing List
Hi,
I am using gdb to open a linux kernel core file generated for x86_64
platform. But gdb is not analyzing the dumps properly. Its getting the
wrong symbol values. For example, following case prints two different values
for same symbol panic_timeout.
#gdb vmlinux
(gdb) p &panic_timeout
$1 = (int *) 0xffffffff808a1fa8
#gdb vmlinux vmcore
(gdb) p &panic_timeout
$1 = (int *) 0xffffffff008aaebf
First one is the right value. Why gdb is giving incorrect results while
opened with vmcore?
I am using GNU gdb Red Hat Linux (6.5-5.fc6rh).
This problem is not present in gdb 6.4. It works perfectly fine.
Note, this vmlinux file is of ET_DYN type. It has been compiled as an
executable and then an external program changes elf type to ET_DYN because
this is a fully relocatable executable and can be loaded at any physical
address.
Any idea, what's wrong.
vmlinux ELF header is as follows.
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x200000
Start of program headers: 64 (bytes into file)
Start of section headers: 61579848 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 5
Size of section headers: 64 (bytes)
Number of section headers: 51
Section header string table index: 48
vmcore ELF header and PT_LOAD headers are as follows.
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: CORE (Core file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 6
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NOTE 0x0000000000000190 0x0000000000000000 0x0000000000000000
0x0000000000000b20 0x0000000000000b20 0
LOAD 0x0000000000000cb0 0xffffffff80200000 0x0000000000200000
0x0000000000742000 0x0000000000742000 RWE 0
LOAD 0x0000000000742cb0 0xffff810000000000 0x0000000000000000
0x00000000000a0000 0x00000000000a0000 RWE 0
LOAD 0x00000000007e2cb0 0xffff810000100000 0x0000000000100000
0x0000000000f00000 0x0000000000f00000 RWE 0
LOAD 0x00000000016e2cb0 0xffff810009000000 0x0000000009000000
0x00000000c6f8dc80 0x00000000c6f8dc80 RWE 0
LOAD 0x00000000c8670930 0xffff810100000000 0x0000000100000000
0x0000000130000000 0x0000000130000000 RWE 0
Thanks
Vivek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gdb 6.5 does not open linux kernel core file properly
2007-05-01 10:42 gdb 6.5 does not open linux kernel core file properly Vivek Goyal
@ 2007-06-03 9:35 ` Bernhard Walle
2007-06-03 16:37 ` Bernhard Walle
0 siblings, 1 reply; 3+ messages in thread
From: Bernhard Walle @ 2007-06-03 9:35 UTC (permalink / raw)
To: gdb
Hello,
Vivek Goyal wrote:
> I am using GNU gdb Red Hat Linux (6.5-5.fc6rh).
>
> This problem is not present in gdb 6.4. It works perfectly fine.
I found out that the error appeared with following change:
cvs diff -u -D "2006-01-24 22:30:00 -0000" -D "2006-01-24 22:40:00 -0000"
The problem is svr4_solib_create_inferior_hook() -> svr4_relocate_main_executable().
If I comment out this function, everything works fine. ;-)
Index: gdb/ChangeLog
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/ChangeLog,v
retrieving revision 1.7569
retrieving revision 1.7570
diff -u -r1.7569 -r1.7570
--- gdb/ChangeLog 24 Jan 2006 22:09:27 -0000 1.7569
+++ gdb/ChangeLog 24 Jan 2006 22:34:34 -0000 1.7570
@@ -1,5 +1,32 @@
2006-01-24 Daniel Jacobowitz <dan@codesourcery.com>
+ PR gdb/1914
+ * fork-child.c (fork_inferior): Don't call
+ solib_create_inferior_hook.
+ * infcmd.c (post_create_inferior): Call solib_add,
+ solib_create_inferior_hook, and re_enable_breakpoints_in_shlibs.
+ (attach_command): Don't call solib_add or
+ re_enable_breakpoints_in_shlibs. Call post_create_inferior
+ instead.
+ * remote.c (remote_open_1): Don't call solib_create_inferior_hook
+ or observer_notify_inferior_created. Call post_create_inferior
+ instead.
+ * corelow.c: Don't include "observer.h".
+ (solib_add_stub): Deleted.
+ (core_open): Don't call observer_notify_inferior_created or
+ solib_add_stub. Call post_create_inferior instead.
+ * inf-ptrace.c: Don't include "observer.h".
+ (inf_ptrace_attach): Don't call observer_notify_inferior_created.
+ * inf-ttrace.c: Don't include "observer.h".
+ (inf_ttrace_attach): Don't call observer_notify_inferior_created.
+ * inferior.h (solib_create_inferior_hook): Remove redundant
+ prototype.
+ * inftarg.c: Don't include "observer.h".
+ (child_attach): Don't call observer_notify_inferior_created.
+ * Makefile.in: Update dependencies.
+
+2006-01-24 Daniel Jacobowitz <dan@codesourcery.com>
+
* infcmd.c: Include "observer.h".
(post_create_inferior): New function.
(run_command_1): Call it. Also call proceed.
Index: gdb/Makefile.in
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/Makefile.in,v
retrieving revision 1.779
retrieving revision 1.780
diff -u -r1.779 -r1.780
--- gdb/Makefile.in 24 Jan 2006 22:09:28 -0000 1.779
+++ gdb/Makefile.in 24 Jan 2006 22:34:34 -0000 1.780
@@ -1831,7 +1831,7 @@
corelow.o: corelow.c $(defs_h) $(arch_utils_h) $(gdb_string_h) $(frame_h) \
$(inferior_h) $(symtab_h) $(command_h) $(bfd_h) $(target_h) \
$(gdbcore_h) $(gdbthread_h) $(regcache_h) $(regset_h) $(symfile_h) \
- $(exec_h) $(readline_h) $(observer_h) $(gdb_assert_h) \
+ $(exec_h) $(readline_h) $(gdb_assert_h) \
$(exceptions_h) $(solib_h)
core-regset.o: core-regset.c $(defs_h) $(command_h) $(gdbcore_h) \
$(inferior_h) $(target_h) $(gdb_string_h) $(gregset_h)
@@ -2129,7 +2129,7 @@
$(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \
$(inflow_h)
inf-ptrace.o: inf-ptrace.c $(defs_h) $(command_h) $(inferior_h) $(inflow_h) \
- $(gdbcore_h) $(observer_h) $(regcache_h) $(gdb_assert_h) \
+ $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \
$(gdb_string_h) $(gdb_ptrace_h) $(gdb_wait_h) $(inf_child_h)
infptrace.o: infptrace.c $(defs_h) $(command_h) $(frame_h) $(gdbcore_h) \
$(inferior_h) $(regcache_h) $(target_h) $(gdb_assert_h) \
@@ -2141,10 +2141,10 @@
$(value_h) $(observer_h) $(language_h) $(solib_h) $(gdb_assert_h) \
$(mi_common_h) $(main_h)
inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
- $(gdbcore_h) $(command_h) $(gdb_stat_h) $(observer_h) $(gdb_wait_h) \
+ $(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h) \
$(inflow_h)
inf-ttrace.o: inf-ttrace.c $(defs_h) $(command_h) $(gdbcore_h) \
- $(gdbthread_h) $(inferior_h) $(observer_h) $(target_h) \
+ $(gdbthread_h) $(inferior_h) $(target_h) \
$(gdb_assert_h) $(gdb_string_h) $(inf_child_h) $(inf_ttrace_h)
interps.o: interps.c $(defs_h) $(gdbcmd_h) $(ui_out_h) $(event_loop_h) \
$(event_top_h) $(interps_h) $(completer_h) $(gdb_string_h) \
Index: gdb/corelow.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/corelow.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- gdb/corelow.c 17 Dec 2005 22:33:59 -0000 1.53
+++ gdb/corelow.c 24 Jan 2006 22:34:34 -0000 1.54
@@ -1,7 +1,7 @@
/* Core dump and executable file functions below target vector, for GDB.
Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+ 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GDB.
@@ -43,7 +43,6 @@
#include "symfile.h"
#include "exec.h"
#include "readline/readline.h"
-#include "observer.h"
#include "gdb_assert.h"
#include "exceptions.h"
#include "solib.h"
@@ -236,21 +235,6 @@
core_close (0/*ignored*/);
}
-/* Stub function for catch_errors around shared library hacking. FROM_TTYP
- is really an int * which points to from_tty. */
-
-static int
-solib_add_stub (void *from_ttyp)
-{
-#ifdef SOLIB_ADD
- SOLIB_ADD (NULL, *(int *) from_ttyp, ¤t_target, auto_solib_add);
-#else
- solib_add (NULL, *(int *)from_ttyp, ¤t_target, auto_solib_add);
-#endif
- re_enable_breakpoints_in_shlibs ();
- return 0;
-}
-
/* Look for sections whose names start with `.reg/' so that we can extract the
list of threads in a core file. */
@@ -372,7 +356,7 @@
/* This is done first, before anything has a chance to query the
inferior for information such as symbols. */
- observer_notify_inferior_created (&core_ops, from_tty);
+ post_create_inferior (&core_ops, from_tty);
p = bfd_core_file_failing_command (core_bfd);
if (p)
@@ -398,9 +382,6 @@
/* Fetch all registers from core file. */
target_fetch_registers (-1);
- /* Add symbols and section mappings for any shared libraries. */
- catch_errors (solib_add_stub, &from_tty, (char *) 0, RETURN_MASK_ALL);
-
/* Now, set up the frame cache, and print the top of stack. */
flush_cached_frames ();
select_frame (get_current_frame ());
Index: gdb/fork-child.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/fork-child.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- gdb/fork-child.c 17 Dec 2005 22:33:59 -0000 1.28
+++ gdb/fork-child.c 24 Jan 2006 22:34:34 -0000 1.29
@@ -1,7 +1,7 @@
/* Fork a Unix child process, and set up to debug it, for GDB.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
- 2000, 2001, 2004 Free Software Foundation, Inc.
+ 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Cygnus Support.
@@ -403,12 +403,6 @@
might be used to have target-specific code initialize a variable
in the new process prior to executing the first instruction. */
TARGET_CREATE_INFERIOR_HOOK (pid);
-
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
- SOLIB_CREATE_INFERIOR_HOOK (pid);
-#else
- solib_create_inferior_hook ();
-#endif
}
/* Accept NTRAPS traps from the inferior. */
Index: gdb/inf-ptrace.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/inf-ptrace.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- gdb/inf-ptrace.c 24 Jan 2006 22:09:28 -0000 1.31
+++ gdb/inf-ptrace.c 24 Jan 2006 22:34:34 -0000 1.32
@@ -26,7 +26,6 @@
#include "inferior.h"
#include "inflow.h"
#include "gdbcore.h"
-#include "observer.h"
#include "regcache.h"
#include "gdb_assert.h"
@@ -222,10 +221,6 @@
inferior_ptid = pid_to_ptid (pid);
push_target (ptrace_ops_hack);
-
- /* Do this first, before anything has had a chance to query the
- inferior's symbol table or similar. */
- observer_notify_inferior_created (¤t_target, from_tty);
}
#ifdef PT_GET_PROCESS_STATE
Index: gdb/inf-ttrace.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/inf-ttrace.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- gdb/inf-ttrace.c 24 Jan 2006 22:09:28 -0000 1.19
+++ gdb/inf-ttrace.c 24 Jan 2006 22:34:34 -0000 1.20
@@ -29,7 +29,6 @@
#include "gdbcore.h"
#include "gdbthread.h"
#include "inferior.h"
-#include "observer.h"
#include "target.h"
#include "gdb_assert.h"
@@ -721,10 +720,6 @@
inferior_ptid = pid_to_ptid (pid);
push_target (ttrace_ops_hack);
-
- /* Do this first, before anything has had a chance to query the
- inferior's symbol table or similar. */
- observer_notify_inferior_created (¤t_target, from_tty);
}
static void
Index: gdb/infcmd.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/infcmd.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -r1.142 -r1.143
--- gdb/infcmd.c 24 Jan 2006 22:09:28 -0000 1.142
+++ gdb/infcmd.c 24 Jan 2006 22:34:34 -0000 1.143
@@ -405,6 +405,30 @@
void
post_create_inferior (struct target_ops *target, int from_tty)
{
+ if (exec_bfd)
+ {
+ /* Sometimes the platform-specific hook loads initial shared
+ libraries, and sometimes it doesn't. Try to do so first, so
+ that we can add them with the correct value for FROM_TTY. */
+#ifdef SOLIB_ADD
+ SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
+#else
+ solib_add (NULL, from_tty, target, auto_solib_add);
+#endif
+
+ /* Create the hooks to handle shared library load and unload
+ events. */
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
+ SOLIB_CREATE_INFERIOR_HOOK (pid);
+#else
+ solib_create_inferior_hook ();
+#endif
+
+ /* Enable any breakpoints which were disabled when the
+ underlying shared library was deleted. */
+ re_enable_breakpoints_in_shlibs ();
+ }
+
observer_notify_inferior_created (target, from_tty);
}
@@ -1899,18 +1923,12 @@
reread_symbols ();
}
-#ifdef SOLIB_ADD
- /* Add shared library symbols from the newly attached process, if any. */
- SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
-#else
- solib_add (NULL, from_tty, ¤t_target, auto_solib_add);
-#endif
- re_enable_breakpoints_in_shlibs ();
-
/* Take any necessary post-attaching actions for this platform.
*/
target_post_attach (PIDGET (inferior_ptid));
+ post_create_inferior (¤t_target, from_tty);
+
/* Install inferior's terminal modes. */
target_terminal_inferior ();
Index: gdb/inferior.h
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/inferior.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- gdb/inferior.h 24 Jan 2006 22:09:28 -0000 1.74
+++ gdb/inferior.h 24 Jan 2006 22:34:34 -0000 1.75
@@ -213,8 +213,6 @@
extern void fetch_inferior_registers (int);
-extern void solib_create_inferior_hook (void);
-
extern void child_terminal_info (char *, int);
extern void term_info (char *, int);
Index: gdb/inftarg.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/Attic/inftarg.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- gdb/inftarg.c 24 Jan 2006 22:09:28 -0000 1.46
+++ gdb/inftarg.c 24 Jan 2006 22:34:34 -0000 1.47
@@ -34,7 +34,6 @@
#include <signal.h>
#include <sys/types.h>
#include <fcntl.h>
-#include "observer.h"
#include "gdb_wait.h"
#include "inflow.h"
@@ -210,10 +209,6 @@
inferior_ptid = pid_to_ptid (pid);
push_target (&deprecated_child_ops);
-
- /* Do this first, before anything has had a chance to query the
- inferior's symbol table or similar. */
- observer_notify_inferior_created (¤t_target, from_tty);
}
#if !defined(CHILD_POST_ATTACH)
Index: gdb/remote.c
===================================================================
RCS file: /mounts/users-space/schwab/repro/src-cvs/src/gdb/remote.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -r1.199 -r1.200
--- gdb/remote.c 24 Jan 2006 22:09:28 -0000 1.199
+++ gdb/remote.c 24 Jan 2006 22:34:34 -0000 1.200
@@ -2295,24 +2295,10 @@
getpkt (buf, rs->remote_packet_size, 0);
}
- /* FIXME: need a master target_open vector from which all
- remote_opens can be called, so that stuff like this can
- go there. Failing that, the following code must be copied
- to the open function for any remote target that wants to
- support svr4 shared libraries. */
+ post_create_inferior (¤t_target, from_tty);
- /* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
- {
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
- SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
-#else
- solib_create_inferior_hook ();
-#endif
- remote_check_symbols (symfile_objfile);
- }
-
- observer_notify_inferior_created (¤t_target, from_tty);
+ remote_check_symbols (symfile_objfile);
}
/* This takes a program previously attached to and detaches it. After
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gdb 6.5 does not open linux kernel core file properly
2007-06-03 9:35 ` Bernhard Walle
@ 2007-06-03 16:37 ` Bernhard Walle
0 siblings, 0 replies; 3+ messages in thread
From: Bernhard Walle @ 2007-06-03 16:37 UTC (permalink / raw)
To: gdb
* Bernhard Walle <bernhard.walle@gmx.de> [2007-06-03 11:27]:
> Vivek Goyal wrote:
> > I am using GNU gdb Red Hat Linux (6.5-5.fc6rh).
> >
> > This problem is not present in gdb 6.4. It works perfectly fine.
>
> I found out that the error appeared with following change:
>
> cvs diff -u -D "2006-01-24 22:30:00 -0000" -D "2006-01-24 22:40:00 -0000"
>
> The problem is svr4_solib_create_inferior_hook() -> svr4_relocate_main_executable().
> If I comment out this function, everything works fine. ;-)
Should the kernel not mark it's ELF type to ET_DYN (but then it's
difficult to distinguish between a relocatable kernel and a
unrelocatable kernel)? Or should we add a .interp section to the
kernel (but I don't think it's a good idea, it would be more a
workaround, IMO).
However, the PC which is used to relocate the binary is completely
wrong because it's in physical virtual space and the start address
is in physical address space. And even if it would be transferred to
physical address space, it would not mark the beginning of the kernel
(entry point), so it's unusable for relocation.
Thanks,
Bernhard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-03 16:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-01 10:42 gdb 6.5 does not open linux kernel core file properly Vivek Goyal
2007-06-03 9:35 ` Bernhard Walle
2007-06-03 16:37 ` Bernhard Walle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox