This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Avoid producing broken non-native core files


Hi,

 We don't have complete non-native core file generation support across all 
the supported targets.  We have explicit support for some targets that is 
implemented differently depending on how general core file support has 
been wired in for a given target, either in GDB proper (the old scheme, 
such as with mips-linux-gnu) or in BFD (the new scheme, such as with 
i686-linux-gnu).  Unfortunately where non-native core file support is 
missing the results are inconsistent between the two cases.

 The two paths diverge in linux_make_corefile_notes_1, the old defaults to 
exec_make_note_section and fails mostly gracefully (an unfinished dump is 
left behind).  The new path does not fail, but an incomplete dump is 
produced with no register information, that GDB itself does not handle 
('"foo" is not a core dump: File format not recognized') and that scores a 
number of failures in the test suite across various cases, e.g.:

(gdb) PASS: gdb.base/auxv.exp: continue
info auxv
32   AT_SYSINFO           Special system info/entry points 0xb7fdd400
33   AT_SYSINFO_EHDR      System-supplied DSO's ELF header 0xb7fdd000
16   AT_HWCAP             Machine-dependent CPU capability hints 0xbfe9fbf7
6    AT_PAGESZ            System page size               4096
17   AT_CLKTCK            Frequency of times()           100
3    AT_PHDR              Program headers for program    0x8048034
4    AT_PHENT             Size of program header entry   32
5    AT_PHNUM             Number of program headers      8
7    AT_BASE              Base address of interpreter    0xb7fde000
8    AT_FLAGS             Flags                          0x0
9    AT_ENTRY             Entry point of program         0x8048590
11   AT_UID               Real user ID                   49869
12   AT_EUID              Effective user ID              49869
13   AT_GID               Real group ID                  280
14   AT_EGID              Effective group ID             280
23   AT_SECURE            Boolean, was exec setuid-like? 0
15   AT_PLATFORM          String identifying platform    0xbffff9cb "i686"
0    AT_NULL              End of vector                  0x0
(gdb) PASS: gdb.base/auxv.exp: info auxv on live process
gcore .../gdb.base/auxv.gcore
Saved corefile .../gdb.base/auxv.gcore
(gdb) PASS: gdb.base/auxv.exp: gcore
continue
Continuing.

Program received signal SIGABRT, Aborted.
0xb7fdd410 in __kernel_vsyscall ()
(gdb) PASS: gdb.base/auxv.exp: continue
continue
Continuing.

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) PASS: gdb.base/auxv.exp: continue
UNSUPPORTED: gdb.base/auxv.exp: generate native core dump
Executing on build: rm -rf .../gdb.base/coredir.4310    (timeout = 3000)

Child terminated with signal = 0x6 (SIGABRT)
GDBserver exiting
UNSUPPORTED: gdb.base/auxv.exp: info auxv on native core dump
UNSUPPORTED: gdb.base/auxv.exp: matching auxv data from live and core
core .../gdb.base/auxv.gcore
".../gdb.base/auxv.gcore" is not a core dump: File format not recognized
(gdb) FAIL: gdb.base/auxv.exp: load core file for info auxv on gcore-created dump
info auxv
The program has no auxiliary information now.
(gdb) FAIL: gdb.base/auxv.exp: info auxv on gcore-created dump
FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore
testcase .../gdb/testsuite/gdb.base/auxv.exp completed in 3 seconds

		=== gdb Summary ===

# of expected passes		8
# of unexpected failures	3
# of unsupported tests		3

The cause of missing register information is elfcore_write_prstatus in BFD 
that writes no data (and returns NULL) on non-native targets that have no 
explicit support (bed->elf_backend_write_core_note is NULL), because 
HAVE_PRSTATUS_T and HAVE_PRSTATUS32_T are both forcibly undefined for 
non-native BFD configurations.

 Given that such core files produced are useless anyway I propose that for 
targets where elfcore_write_prstatus is indeed used and returns NULL an 
error message was printed and core file preparation aborted.  This is 
implemented in linux_corefile_thread_callback where signal information is 
also stored and currently overwrites any unsuccessful return status from 
the register store worker function (linux_collect_thread_registers).  The 
test framework is updated accordingly to handle the alternative error 
message produced in that case.

 This change removes the failure shown above:

(gdb) PASS: gdb.base/auxv.exp: continue
info auxv
32   AT_SYSINFO           Special system info/entry points 0xb7fdd400
33   AT_SYSINFO_EHDR      System-supplied DSO's ELF header 0xb7fdd000
16   AT_HWCAP             Machine-dependent CPU capability hints 0xbfe9fbf7
6    AT_PAGESZ            System page size               4096
17   AT_CLKTCK            Frequency of times()           100
3    AT_PHDR              Program headers for program    0x8048034
4    AT_PHENT             Size of program header entry   32
5    AT_PHNUM             Number of program headers      8
7    AT_BASE              Base address of interpreter    0xb7fde000
8    AT_FLAGS             Flags                          0x0
9    AT_ENTRY             Entry point of program         0x8048590
11   AT_UID               Real user ID                   49869
12   AT_EUID              Effective user ID              49869
13   AT_GID               Real group ID                  280
14   AT_EGID              Effective group ID             280
23   AT_SECURE            Boolean, was exec setuid-like? 0
15   AT_PLATFORM          String identifying platform    0xbffff9cb "i686"
0    AT_NULL              End of vector                  0x0
(gdb) PASS: gdb.base/auxv.exp: info auxv on live process
gcore .../gdb.base/auxv.gcore
Target does not support core file generation.
(gdb) UNSUPPORTED: gdb.base/auxv.exp: gcore
continue
Continuing.

Program received signal SIGABRT, Aborted.
0xb7fdd410 in __kernel_vsyscall ()
(gdb) PASS: gdb.base/auxv.exp: continue
continue
Continuing.

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) PASS: gdb.base/auxv.exp: continue
UNSUPPORTED: gdb.base/auxv.exp: generate native core dump
Executing on build: rm -rf .../gdb.base/coredir.5217    (timeout = 3000)

Child terminated with signal = 0x6 (SIGABRT)
GDBserver exiting
UNSUPPORTED: gdb.base/auxv.exp: info auxv on native core dump
UNSUPPORTED: gdb.base/auxv.exp: matching auxv data from live and core
UNSUPPORTED: gdb.base/auxv.exp: info auxv on gcore-created dump
UNSUPPORTED: gdb.base/auxv.exp: matching auxv data from live and gcore
testcase .../gdb/testsuite/gdb.base/auxv.exp completed in 1 seconds

		=== gdb Summary ===

# of expected passes		7
# of unsupported tests		6

-- tested with the i686-linux-gnu target.

 OK to apply?

2013-10-15  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* linux-tdep.c (linux_corefile_thread_callback): Propagate any
	failure from register information collection.

	gdb/testsuite/
	* lib/gdb.exp (gdb_gcore_cmd): Also handle a "Target does not 
	support core file generation" reply.

  Maciej

gdb-core-note-data.diff
Index: gdb-fsf-trunk-quilt/gdb/linux-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/linux-tdep.c	2013-10-14 22:44:49.868756722 +0100
+++ gdb-fsf-trunk-quilt/gdb/linux-tdep.c	2013-10-14 22:46:21.887601484 +0100
@@ -1211,7 +1211,9 @@ linux_corefile_thread_callback (struct t
 				       args->stop_signal);
       args->num_notes++;
 
-      if (siginfo_data != NULL)
+      /* Don't return anything if we got no register information above,
+         such a core file is useless.  */
+      if (args->note_data != NULL && siginfo_data != NULL)
 	{
 	  args->note_data = elfcore_write_note (args->obfd,
 						args->note_data,
Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/gdb.exp	2013-10-14 22:44:44.867662030 +0100
+++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp	2013-10-14 22:46:21.887601484 +0100
@@ -3183,7 +3183,7 @@ proc gdb_gcore_cmd {core test} {
 	    verbose -log "'gcore' command undefined in gdb_gcore_cmd"
 	}
 
-	-re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+	-re "(?:Can't create a corefile|Target does not support core file generation\\.)\[\r\n\]+$gdb_prompt $" {
 	    unsupported $test
 	}
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]