Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <palves@redhat.com>,
	Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH][gdb/testsuite] Fix .debug_aranges in watch-loc.c
Date: Mon, 06 May 2019 16:37:00 -0000	[thread overview]
Message-ID: <20190506163738.GA16778@delia> (raw)

Hi,

When running gdb.dlang/watch-loc.exp with target board cc-with-debug-names, we
run into:
...
FAIL: gdb.dlang/watch-loc.exp: disassemble _Dmain (GDB internal error)
...
in more detail:
...
(gdb) disassemble _Dmain
gdb/dwarf2read.c:5293: internal-error: \
  compunit_symtab* dw2_find_pc_sect_compunit_symtab(objfile*, \
  bound_minimal_symbol, CORE_ADDR, obj_section*, int): \
  Assertion `result != NULL' failed.
...

The problem is that the .debug_aranges section in watch-loc.c contains a
debug_info_offset which is set to 0:
...
asm (
  "      .pushsection    .debug_aranges,\"\",%progbits\n"
  "      .4byte  .Laranges_end - .Laranges_start\n"
  ".Laranges_start:\n"
  "      .2byte  0x2\n"
  "      .4byte  0\n"
...
while the compilation unit at offset 0 in the .debug_section in the executable
is in fact not the compilation unit generated from watch-loc-dw.S.

[ Note: this is a non-trivial test-case.  The file watch-loc-dw.S contains a
.debug_info section, but not an .debug_aranges section or any actual code.
The file watch-loc.c contains code and a .debug_aranges section, but no other
debug section.  So, the intent for the .debug_aranges section in watch-loc.c
is to refer to a compilation unit in the .debug_info section in
watch-loc-dw.S. ]

This happens when linked in object files contain dwarf info and are placed in
the .debug_info section before the compilation units generated from
watch-loc.c and watch-loc-dw.S.

Fix this by defining the debug_info_offset field using a label .Lcu1_begin
that defines the start of an empty .debug_section compilation unit:
...
 asm (
+  "      .pushsection    .debug_info,\"\",%progbits\n"
+  ".Lcu1_begin:"
+  "      .popsection\n"
   "      .pushsection    .debug_aranges,\"\",%progbits\n"
   "      .4byte  .Laranges_end - .Laranges_start \n"
   ".Laranges_start:\n"
   "      .2byte  0x2\n"
-  "      .4byte  0\n"
+  "      .4byte  .Lcu1_begin\n"
...
which during linking merges with the start of the .debug_info section of
watch-loc-dw.S.

Tested on x86_64-linux with native, cc-with-gdb-index and cc-with-debug-names.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Fix .debug_aranges in watch-loc.c

gdb/testsuite/ChangeLog:

2019-05-06  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24522
	* gdb.dlang/watch-loc.c: Fix debug_info_offset in .debug_aranges
	section.

---
 gdb/testsuite/gdb.dlang/watch-loc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.dlang/watch-loc.c b/gdb/testsuite/gdb.dlang/watch-loc.c
index b0af2fcc67..5dd05b4dfe 100644
--- a/gdb/testsuite/gdb.dlang/watch-loc.c
+++ b/gdb/testsuite/gdb.dlang/watch-loc.c
@@ -38,11 +38,14 @@ main (void)
    generated by GCC.  (.gdb_index includes a gdb-generated map
    instead.)  */
 asm (
+"	.pushsection	.debug_info,\"\",%progbits \n"
+".Lcu1_begin:"
+"	.popsection \n"
 "	.pushsection	.debug_aranges,\"\",%progbits \n"
 "	.4byte	.Laranges_end - .Laranges_start \n"	// Length of Address Ranges Info
 ".Laranges_start: \n"
 "	.2byte	0x2 \n"	// DWARF Version
-"	.4byte	0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info
+"	.4byte	.Lcu1_begin\n" // .Ldebug_info0 - Offset of Compilation Unit Info
 "	.byte	4 \n"	// Size of Address
 "	.byte	0 \n"	// Size of Segment Descriptor
 "	.2byte	0 \n"	// Pad to 16 byte boundary


             reply	other threads:[~2019-05-06 16:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 16:37 Tom de Vries [this message]
2019-05-06 17:21 ` Jan Kratochvil
2019-05-07  9:03   ` Tom de Vries

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=20190506163738.GA16778@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=palves@redhat.com \
    /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