* [patch] Fix warning: Invalid entry in .debug_gdb_scripts section
@ 2017-03-16 15:41 Jan Kratochvil
2017-03-16 17:03 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2017-03-16 15:41 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
Hi,
https://bugzilla.redhat.com/show_bug.cgi?id=1429598
there remains questionable whether bfd_get_section_by_name() should not return
an error for !SEC_LOAD but I haven't investigated that.
Also it could have a testcase.
OK for check-in?
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 661 bytes --]
gdb/ChangeLog
2017-03-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* auto-load.c (auto_load_section_scripts): Check also SEC_LOAD.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..63b54b8 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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_LOAD) == 0)
return;
if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-16 15:41 [patch] Fix warning: Invalid entry in .debug_gdb_scripts section Jan Kratochvil
@ 2017-03-16 17:03 ` Pedro Alves
2017-03-16 17:39 ` Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2017-03-16 17:03 UTC (permalink / raw)
To: Jan Kratochvil, gdb-patches
On 03/16/2017 03:41 PM, Jan Kratochvil wrote:
> Hi,
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1429598
>
> there remains questionable whether bfd_get_section_by_name() should not return
> an error for !SEC_LOAD but I haven't investigated that.
>
> Also it could have a testcase.
>
> OK for check-in?
I don't think you've supplied enough rationale.
Why is this the right thing to do?
Shouldn't we be able to load scripts from debug-only sections?
A testcase would indeed be good to have.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-16 17:03 ` Pedro Alves
@ 2017-03-16 17:39 ` Jan Kratochvil
2017-03-16 18:02 ` Pedro Alves
2017-03-19 22:39 ` [patchv3] " Jan Kratochvil
0 siblings, 2 replies; 7+ messages in thread
From: Jan Kratochvil @ 2017-03-16 17:39 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
On Thu, 16 Mar 2017 18:03:41 +0100, Pedro Alves wrote:
> I don't think you've supplied enough rationale.
I forgot to copy-paste prepared:
/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
> Shouldn't we be able to load scripts from debug-only sections?
I agree there is better to use SEC_HAS_CONTENTS, right?
> A testcase would indeed be good to have.
OK, I will update the patch later.
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 672 bytes --]
gdb/ChangeLog
2017-03-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..edaf264 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-16 17:39 ` Jan Kratochvil
@ 2017-03-16 18:02 ` Pedro Alves
2017-03-19 22:39 ` [patchv3] " Jan Kratochvil
1 sibling, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2017-03-16 18:02 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On 03/16/2017 05:39 PM, Jan Kratochvil wrote:
> On Thu, 16 Mar 2017 18:03:41 +0100, Pedro Alves wrote:
>> I don't think you've supplied enough rationale.
>
> I forgot to copy-paste prepared:
>
> /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
>
Well, that's just a tool output, not a self-contained
rationale/explanation. With only that, any reviewer will have to
guess things that you probably have already discovered while
debugging the issue. Josh said that the script is still loaded
fine. I guess that's because GDB actually tries to read the script
twice, once from rustc, which succeeds, and another time from
rustc.debug, which runs into a zero'ed script ID type, which is
invalid exactly to catch this type of problems.
>> Shouldn't we be able to load scripts from debug-only sections?
>
> I agree there is better to use SEC_HAS_CONTENTS, right?
Yes, I think so.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patchv3] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-16 17:39 ` Jan Kratochvil
2017-03-16 18:02 ` Pedro Alves
@ 2017-03-19 22:39 ` Jan Kratochvil
2017-03-29 14:11 ` Pedro Alves
1 sibling, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2017-03-19 22:39 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 130 bytes --]
On Thu, 16 Mar 2017 18:39:13 +0100, Jan Kratochvil wrote:
> OK, I will update the patch later.
Included.
OK for check-in?
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 2269 bytes --]
gdb/ChangeLog
2017-03-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.
gdb/testsuite/ChangeLog
2017-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.python/py-section-script.exp (sepdebug): New testcases.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..edaf264 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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))
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 52e1e3e..cf6b631 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -114,3 +114,38 @@ 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"
+
+
+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."
+}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patchv3] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-19 22:39 ` [patchv3] " Jan Kratochvil
@ 2017-03-29 14:11 ` Pedro Alves
2017-03-29 19:58 ` [commit] " Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2017-03-29 14:11 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On 03/19/2017 10:38 PM, Jan Kratochvil wrote:
> On Thu, 16 Mar 2017 18:39:13 +0100, Jan Kratochvil wrote:
>> > OK, I will update the patch later.
> Included.
>
> OK for check-in?
Thanks.
> gdb/ChangeLog
> 2017-03-16 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.
>
> gdb/testsuite/ChangeLog
> 2017-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.python/py-section-script.exp (sepdebug): New testcases.
>
> diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
> index 52e1e3e..cf6b631 100644
> --- a/gdb/testsuite/gdb.python/py-section-script.exp
> +++ b/gdb/testsuite/gdb.python/py-section-script.exp
> @@ -114,3 +114,38 @@ 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"
> +
> +
> +with_test_prefix "sepdebug" {
Please add a leading comment here, helping folks reading this understand
what the test is about. Something like "eu-strip creates NOBITS
.debug_gdb_scripts sections in the debug files. Make sure those are
ignored silently."
OK with that change.
Thanks,
Pedro Alves
> + 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."
> +}
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [commit] [patchv3] Fix warning: Invalid entry in .debug_gdb_scripts section
2017-03-29 14:11 ` Pedro Alves
@ 2017-03-29 19:58 ` Jan Kratochvil
0 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2017-03-29 19:58 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 105 bytes --]
On Wed, 29 Mar 2017 16:11:41 +0200, Pedro Alves wrote:
> OK with that change.
Checked in.
Thanks,
Jan
[-- Attachment #2: Type: message/rfc822, Size: 4393 bytes --]
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] Fix warning: Invalid entry in .debug_gdb_scripts section
Date: Wed, 29 Mar 2017 21:53:43 +0200
$ 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(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 23df636..bfa5358 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 56914c8..edaf264 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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))
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5241a27..eb543eb 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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.
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 52e1e3e..6707156 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -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."
+}
--
2.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-03-29 19:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 15:41 [patch] Fix warning: Invalid entry in .debug_gdb_scripts section Jan Kratochvil
2017-03-16 17:03 ` Pedro Alves
2017-03-16 17:39 ` Jan Kratochvil
2017-03-16 18:02 ` Pedro Alves
2017-03-19 22:39 ` [patchv3] " Jan Kratochvil
2017-03-29 14:11 ` Pedro Alves
2017-03-29 19:58 ` [commit] " Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).