@@ -1,3 +1,7 @@
+2017-03-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.
+
2017-03-29 Yao Qi <yao.qi@linaro.org>
* gdbthread.h (struct thread_info): Declare constructor and
@@ -1174,7 +1174,8 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
bfd_byte *data = NULL;
scripts_sect = bfd_get_section_by_name (abfd, section_name);
- if (scripts_sect == NULL)
+ if (scripts_sect == NULL
+ || (bfd_get_section_flags (abfd, scripts_sect) & SEC_HAS_CONTENTS) == 0)
return;
if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
@@ -1,3 +1,7 @@
+2017-03-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.python/py-section-script.exp (sepdebug): New testcases.
+
2017-03-28 Anton Kolesov <anton.kolesov@synopsys.com>
* gdb.arch/arc-analyze-prologue.S: New file.
@@ -114,3 +114,41 @@ gdb_test "continue" ".*Breakpoint.*"
gdb_test "print ss" " = a=<1> b=<2>"
gdb_test "test-cmd 1 2 3" "test-cmd output, arg = 1 2 3"
+
+
+# eu-strip creates NOBITS .debug_gdb_scripts sections in the debug files.
+# Make sure those are ignored silently.
+
+with_test_prefix "sepdebug" {
+ gdb_exit
+
+ set result [catch "exec eu-strip -g -f ${binfile}.debug ${binfile}" output]
+ verbose "result is $result"
+ verbose "output is $output"
+ if {$result != 0 || $output != ""} {
+ unsupported "cannot produce separate debug info files"
+ return
+ }
+
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_no_output "set auto-load safe-path ${remote_python_file}:${binfile}" \
+ "set auto-load safe-path"
+ set test "load sepdebug"
+ gdb_test_multiple "file $binfile" $test {
+ -re "\r\nwarning: Invalid entry in \\.debug_gdb_scripts section.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "done\\.\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+
+ # Again, with a regexp this time.
+ gdb_test "info auto-load python-scripts ${testfile}" "Yes.*${testfile}.py.*"
+
+ # Again, with a regexp that matches no scripts.
+ gdb_test "info auto-load python-scripts no-script-matches-this" \
+ "No auto-load scripts matching no-script-matches-this."
+}
On Wed, 29 Mar 2017 16:11:41 +0200, Pedro Alves wrote: > OK with that change. Checked in. Thanks, Jan $ gdb rustc Reading symbols from rustc...Reading symbols from /usr/lib/debug/usr/bin/rustc.debug...done. done. warning: Invalid entry in .debug_gdb_scripts section /usr/bin/rustc Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [15] .debug_gdb_scripts PROGBITS 00000000000008ed 0008ed 000022 00 AMS 0 0 1 /usr/lib/debug/usr/bin/rustc.debug Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [15] .debug_gdb_scripts NOBITS 00000000000008ed 000280 000022 00 AMS 0 0 1 There remains questionable whether bfd_get_section_by_name() should not return an error for !SEC_LOAD but I haven't investigated that. gdb/ChangeLog 2017-03-29 Jan Kratochvil <jan.kratochvil@redhat.com> * auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS. gdb/testsuite/ChangeLog 2017-03-29 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.python/py-section-script.exp (sepdebug): New testcases. --- gdb/ChangeLog | 4 +++ gdb/auto-load.c | 3 +- gdb/testsuite/ChangeLog | 4 +++ gdb/testsuite/gdb.python/py-section-script.exp | 38 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-)