Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PING][PATCH][gdb/testsuite] Fix error message test in dw2-error.exp
Date: Tue, 03 Jul 2018 14:21:00 -0000	[thread overview]
Message-ID: <f3ea1a3f-720f-7275-7b96-13d9b9ac6acf@suse.de> (raw)
In-Reply-To: <20180619090024.c2yqabvk6oujs6dm@localhost.localdomain>

On 06/19/2018 11:00 AM, Tom de Vries wrote:
> Hi,
> 
> the executable used in dw2-error.exp is compiled from a .s that was generated
> with dwarf2 debug information but has been hand-edited to set the version in
> the compilation unit header to 0x99:
> ...
> .Ldebug_info0:
>         .long   0x4e    # Length of Compilation Unit Info
>         .value  0x99    # DWARF version number
>         .long   .Ldebug_abbrev0 # Offset Into Abbrev. Section
> ...
> 
> Consequently, dwarf2read.c:read_comp_unit_head() interprets the compilation
> unit header as dwarf5, which starts with fields unit_length (4 or 12 byte
> unsigned), version (uhalf), and unit_type (ubyte). So, the unit_type
> field is initialized from the first byte of .Ldebug_abbrev0 offset.
> 
> Using objdump, we find that the value of that byte is 0x64.
> ...
> Contents of section .debug_info:
>  ...
>  00c0 00450000 0001804e 00000099 00640000  .E.....N.....d..
> ...
> 
> And indeed gdb errors out accordingly (note: 0x64 == 100):
> ...
> (gdb) file outputs/gdb.dwarf2/dw2-error/dw2-error
> Reading symbols from outputs/gdb.dwarf2/dw2-error/dw2-error...
> Dwarf Error: wrong unit_type in compilation unit header
>              (is 100, should be 1 or 2)
> 	     [in module outputs/gdb.dwarf2/dw2-error/dw2-error]
> (no debugging symbols found)...done.
> ...
> 
> The test fails however because it expects the error message to contain 0
> instead of the 100 we're seeing.
> 
> This patch fixes the failure by allowing any value for the unit_type in the
> error message.
> 
> Tested on x86_64-linux.
> 
> OK for trunk?
> 
> Thanks,
> - Tom
> 
> [gdb/testsuite] Fix error message test in dw2-error.exp
> 
> 2018-06-19  Tom de Vries  <tdevries@suse.de>
> 
> 	* gdb.dwarf2/dw2-error.exp: Allowing any value for the unit_type in
>         the "wrong unit_type in compilation unit header" error message.
> 
> ---
>  gdb/testsuite/gdb.dwarf2/dw2-error.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-error.exp b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
> index e22667dea5..441e0f8db5 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-error.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
> @@ -41,7 +41,7 @@ gdb_test_no_output "set breakpoint pending off"
>  
>  # First test that reading symbols fails.
>  gdb_test "file $binfile" \
> -    {Reading symbols.*Dwarf Error: wrong unit_type in compilation unit header \(is 0, should be 1 or 2\).*} \
> +    {Reading symbols.*Dwarf Error: wrong unit_type in compilation unit header \(is [0-9]+, should be 1 or 2\).*} \
>      "file $testfile"
>  
>  # Now check that we can still break given the minimal symbol.
> 


  reply	other threads:[~2018-07-03 14:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19  9:03 [PATCH][gdb/testsuite] " Tom de Vries
2018-07-03 14:21 ` Tom de Vries [this message]
2018-07-03 14:59 ` Pedro Alves
2018-07-04  6:54   ` [PATCH][gdb/symtab] Fix version check in dwarf compilation unit header Tom de Vries
2018-07-04  9:36     ` Pedro Alves

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=f3ea1a3f-720f-7275-7b96-13d9b9ac6acf@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