From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/testsuite] Add missing terminator in Dwarf::_macro_unit
Date: Thu, 16 May 2024 11:45:01 +0200 [thread overview]
Message-ID: <20240516094501.7782-1-tdevries@suse.de> (raw)
When printing complaints with one of the execs from test-case
gdb.dwarf2/macro-source-path.exp, we run into:
...
$ gdb -q -batch \
-iex "set complaints 100" \
macro-source-path-clang14-dw4-absolute-cwd-32 \
-ex "p main"
During symbol reading: debug info runs off end of .debug_macro section \
[in module macro-source-path-clang14-dw4-absolute-cwd-32]
$1 = {int ()} 0x4004b7 <main>
...
and readelf complains more specifically:
...
Contents of the .debug_macro section:
Offset: 0
Version: 5
Offset size: 4
Offset into .debug_line: 0xe3
DW_MACRO_define - lineno : 0 macro : ONE 1
DW_MACRO_define_strp - lineno : 0 macro : THREE 3
DW_MACRO_start_file - lineno: 0 filenum: 1 filename: test.c
DW_MACRO_define - lineno : 1 macro : TWO 2
DW_MACRO_end_file
readelf: Error: .debug_macro section not zero terminated
...
Fix this by adding the missing terminator in Dwarf::_macro_unit.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.dwarf2/macro-source-path.exp | 11 +++++++++++
gdb/testsuite/lib/dwarf.exp | 2 ++
2 files changed, 13 insertions(+)
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
index b6b7b0bd2fd..fccfabdebb1 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp
@@ -139,6 +139,17 @@ proc do_test { test_name lines_version DW_AT_name main_file_idx directories
return
}
+ with_complaints 5 {
+ gdb_test_multiple "print main" "no complaints" {
+ -wrap -re "During symbol reading: .*" {
+ fail $gdb_test_name
+ }
+ -wrap -re "" {
+ pass $gdb_test_name
+ }
+ }
+ }
+
if ![runto_main] {
return
}
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 5b23a60af8e..995cdcac941 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -2252,6 +2252,8 @@ namespace eval Dwarf {
with_override Dwarf::end_file Dwarf::_macro_unit_end_file {
uplevel $body
}}}}
+
+ _op .byte 0x0 "# End macro unit"
}
# Emit a DW_MACRO_define entry.
base-commit: 9c54f520db35bea9d02d121d4f368a5d196c5a8c
--
2.35.3
next reply other threads:[~2024-05-16 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-16 9:45 Tom de Vries [this message]
2024-05-16 16:07 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240516094501.7782-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).