public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 02/14] Change gdb.base/skip-solib.exp deal with lack of epilogue information
Date: Thu, 9 Jun 2022 15:55:09 -0300	[thread overview]
Message-ID: <e2d377c5-3324-6440-f93c-d66b7c95e164@redhat.com> (raw)
In-Reply-To: <f458187a-0544-1c7d-ab61-a412af1f48cf@palves.net>


On 6/9/22 15:25, Pedro Alves wrote:
> On 2022-06-09 17:27, Bruno Larsen wrote:
>>
>> On 6/8/22 12:37, Pedro Alves wrote:
>>> On 2022-05-26 16:10, Bruno Larsen via Gdb-patches wrote:
>>>> When running gdb.base/skip-solib.exp, the backtrace tests could fail if
>>>> the compiler did not emit epilogue information for trivial epilogues,
>>>
>>> I found "emit epilogue information" very confusing FWIW.  When I read that the first time,
>>> I thought this was talking about unwind info for the prologue after the stack is destroyed,
>>> and I wondered why not fix clang instead.
>>>
>>> I think the following would be more accurate:
>>>
>>>    "fail with compilers that associate prologue insns with the function's last
>>>     statement line instead of the function's closing brace".
>>
>> Yeah, I think this is a better explanation, but s/prologue/epilogue, right?
> 
> Right.  That was a typo.  I meant:
> 
>    "fail with compilers that associate epilogue insns with the function's last
>     statement line instead of the function's closing brace".
> 
>> I tried to make this concept more specific by saying that clang doesn't emit epilogue information, Have I misunderstood or misnamed it?
> 
> To me "epilogue information" sounds like some special DWARF information specific to epilogues.
> It reminds of me of special epilogue unwinders that GDB has, like amd64_epilogue_frame_unwind,
> i386_epilogue_frame_unwind, rs6000_epilogue_frame_unwind, etc.  By not saying "line" anywhere,
> I have nothing to connect "epilogue information" to "line info".  Once you make the connection,
> you understand that there's nothing special about "epilogue information", it's just that clang
> and gcc choose different lines numbers for the epilogue instructions.

Ah, I see! Then  yes, I can change it to what you suggested. Just wanted to confirm my understanding :)

> 
> 
>>>> diff --git a/gdb/testsuite/gdb.base/skip-inline.exp b/gdb/testsuite/gdb.base/skip-inline.exp
>>>> index f6e9926b66c..327ea676140 100644
>>>> --- a/gdb/testsuite/gdb.base/skip-inline.exp
>>>> +++ b/gdb/testsuite/gdb.base/skip-inline.exp
>>>> @@ -35,16 +35,20 @@ gdb_test "skip function foo" "Function foo will be skipped when stepping\."
>>>>    gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main"
>>>>    gdb_test "step" ".*" "step into baz, since foo will be skipped"
>>>>    gdb_test "bt" "\\s*\\#0\\s+baz.*" "in the baz, since foo was skipped"
>>>> -gdb_test "step" ".*" "step in the baz"
>>>> -gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz"
>>>> -gdb_test "step" ".*" "step back to main"
>>>> +gdb_step_until_regexp ".*x = 0; x = baz \\(foo \\(\\)\\).*"
>>>
>>> FWIW, I'd remove the "regexp" from the function's name, just call it gdb_step_until.
>>
>> Alright, but this sounds more like a review of the first patch than this one.
> 
> It only stood out to me when I saw it in use, as in the function name is long
> and regexp stuck out like a sore thumb here.  :-)
> 
>>> Or even with a simple "just main" program, like so:
>>>
>>>    (gdb) list
>>>    1       int
>>>    2       main ()
>>>    3       {
>>>    4         return 0;
>>>    5       }
>>>
>>> we get this with gcc:
>>>
>>>    (gdb) info line 4
>>>    Line 4 of "main.c" starts at address 0x1131 <main+8> and ends at 0x1136 <main+13>.
>>>    (gdb) info line 5
>>>    Line 5 of "main.c" starts at address 0x1136 <main+13> and ends at 0x1138.
>>>    (gdb)
>>>
>>> and this with clang:
>>>
>>>    (gdb) info line 4
>>>    Line 4 of "main.c" starts at address 0x40111d <main+13> and ends at 0x40111f.
>>>    (gdb) info line 5
>>>    Line number 5 is out of range for "main.c".
>>>    (gdb)
>>>
>>> I think that we can use that to write a caching proc like:
>>>
>>>    # Return true if the compiler emits line information associating prologue insns with
>>>    # the function's closing brace.  Return false if not, meaning the prologue
>>>    # associates prologue instructions with function's last line with a statement.
>>>
>>>    gdb_caching_proc have_prologue_line_info {
>>>        use gdb_simple_compile the simple main program from above
>>>              use "info line 5", and return false if we get "out of range", otherwise return true.
>>>    }
>>>
>>
>> This sounds like a good idea, I would only change the default behavior to returning false, unless we saw specifically "start at address.*and ends at".
> 
> ...
> 
>> This would make GDB changes more pronounced, as GCC would start having different results.
> 
> Note sure what you mean here.
> 

I meant that if something changes in GDB and the epilogue detection fails, making gcc's test result different would be easier to detect than making clang's results different.

Cheers!
Bruno Larsen


  reply	other threads:[~2022-06-09 18:55 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 15:10 [PATCH v3 00/14] Clean gdb.base when testing with clang Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 01/14] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
2022-05-27 16:19   ` Andrew Burgess
2022-05-30 12:44     ` Bruno Larsen
2022-05-30 14:06       ` Andrew Burgess
2022-06-08 14:59     ` Pedro Alves
2022-05-26 15:10 ` [PATCH v3 02/14] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
2022-05-30 14:04   ` Andrew Burgess
2022-05-30 20:31     ` Bruno Larsen
2022-06-01 14:52     ` [PATCH] gdb/testsuite: Add test to step through function epilogue Bruno Larsen
2022-06-08 15:37   ` [PATCH v3 02/14] Change gdb.base/skip-solib.exp deal with lack of epilogue information Pedro Alves
2022-06-09 16:27     ` Bruno Larsen
2022-06-09 18:25       ` Pedro Alves
2022-06-09 18:55         ` Bruno Larsen [this message]
2022-06-13 15:32           ` Pedro Alves
2022-05-26 15:10 ` [PATCH v3 03/14] change gdb.base/symbol-alias to xfail with clang Bruno Larsen
2022-06-07  6:42   ` George, Jini Susan
2022-06-07 12:53     ` Bruno Larsen
2022-06-08  7:41       ` George, Jini Susan
2022-06-10 11:01       ` Andrew Burgess
2022-06-10 12:07         ` Bruno Larsen
2022-06-14  7:14         ` George, Jini Susan
2022-06-14  7:23           ` George, Jini Susan
2022-06-14 11:23             ` Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 04/14] change gdb.base/nodebug.c to not fail " Bruno Larsen
2022-06-10 18:24   ` Andrew Burgess
2022-05-26 15:10 ` [PATCH v3 05/14] update gdb.base/info-program.exp " Bruno Larsen
2022-06-30 14:45   ` Andrew Burgess
2022-05-26 15:10 ` [PATCH v3 06/14] fix gdb.base/access-mem-running.exp for clang testing Bruno Larsen
2022-06-30 15:06   ` Andrew Burgess
2022-05-26 15:10 ` [PATCH v3 07/14] Fix gdb.base/call-ar-st to work with Clang Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 08/14] add xfails to gdb.base/complex-parts.exp when testing with clang Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 09/14] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 10/14] explicitly test for stderr in gdb.base/dprintf.exp Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 11/14] gdb/testsuite: Update gdb.base/so-impl-ld.exp Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 12/14] [gdb/testsuite]: fix gdb.base/jit-elf.exp when testing with clang Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 13/14] gdb/testsuite: fix gdb.base/info-types-c++ " Bruno Larsen
2022-05-26 15:10 ` [PATCH v3 14/14] gdb.base/skip.exp: Use finish to exit functions Bruno Larsen

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=e2d377c5-3324-6440-f93c-d66b7c95e164@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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).