public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: Carl Love <cel@us.ibm.com>,
	gdb-patches@sourceware.org,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	pedro@palves.net
Cc: luis.machado@arm.com
Subject: Re: [PATCH] Fix reverse stepping multiple contiguous PC ranges over the line table.
Date: Thu, 4 May 2023 11:24:47 +0200	[thread overview]
Message-ID: <f5961b89-4a6f-1e77-0445-74a2dc150830@redhat.com> (raw)
In-Reply-To: <7c596ccfc69b237a6094ead018f4a0b38b82a632.camel@us.ibm.com>

On 04/05/2023 04:55, Carl Love wrote:
> Bruno:
>
> On Wed, 2023-05-03 at 11:53 +0200, Bruno Larsen wrote:
>> On 27/04/2023 22:59, Carl Love wrote:
> <snip>
<snip>
>>> +
>>> +# This test uses the gcc no-column-info command.
>> Correct me if I'm wrong, but it seems to me that the other test is a
>> more generic version of this one, so this test could check for a gcc
>> recent enough to support this feature, instead of just generically
>> gcc.
>> That said, gcc added it on version
>> 7(
>> https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=0029b929c9719a
>>   ), is it
>> old enough that we don't care?
> GCC supports line tables, I don't know that clang or other compilers
> do.  So all we really need is to check for gcc.  The line table stuff
> was added a long time ago so not sure that we really need to check for
> version 7 at this point.  So just checked that we are using gcc.  The
> "other test" func-map-to-same-line.exp expects the line table so it
> should probably also be checking that we are using gcc.

GCC 7.1 (first gcc 7 release) was on May 2nd 2017, almost exactly 6 
years ago, and there was a gcc 6.8 release in october 2018. I don't know 
if 5 years is long enough to assume that everyone has abandoned the old 
version (especially seeing as we sometimes test for gcc 4 or 3, but that 
might just be old cruft). That said, it's not a blocker for me, so /shrug

Also, clang will have line tables - otherwise almost nothing on our test 
suite would work. It doesn't have column info, though, which is why I'm 
fine with it being ignored in the test that uses -gno-column-info.

>
>>> +if ![is_c_compiler_gcc] {
>>> +    unsupported "gcc is required for this test"
>>> +    return 0
>>> +}
>>> +
>>> +set srcfile  func-map-to-same-line.c
>>> +set executable func-map-to-same-line
>>> +
>>> +set options [list debug additional_flags=-gno-column-info]
>>> +
>>> +if {[build_executable "failed to prepare" $executable $srcfile
>>> $options] == -1}\
>>> + {
>>> +    return -1
>>> +}
>>> +
>>> +clean_restart $executable
>>> +
>>> +runto_main
>>> +set target_remote [gdb_is_target_remote]
>>> +
>>> +if [supports_process_record] {
>>> +    # Activate process record/replay.
>>> +    gdb_test_no_output "record" "turn on process record for test1"
>>> +}
>>> +
>>> +# This regression test verifies the reverse-step and reverse-next
>>> commands
>>> +# work properly when executing backwards thru a source line
>>> containing
>>> +# two function calls on the same source line, i.e. func1 (); func2
>>> ();
>>> +# This test is compiled so the dwarf info not contain the line
>>> table
>>> +# information.
>>> +
>>> +# Test 1, reverse-next command
>>> +# Set breakpoint at the line after the function calls.
>>> +set bp_start_reverse_test [gdb_get_line_number "START REVERSE
>>> TEST" $srcfile]
>>> +gdb_breakpoint $srcfile:$bp_start_reverse_test temporary
>>> +
>>> +# Continue to break point for reverse-next test.
>>> +# Command definition:  reverse-next [count]
>>> +#   Run backward to the beginning of the previous line executed in
>>> the current
>>> +#   (innermost) stack frame. If the line contains function calls,
>>> they will be
>>> +#   “un-executed” without stopping. Starting from the first line
>>> of a function,
>>> +#   reverse-next will take you back to the caller of that
>>> function, before the
>>> +#   function was called, just as the normal next command would
>>> take you from
>>> +#   the last line of a function back to its return to its caller 2
>>> .
>>> +
>>> +gdb_continue_to_breakpoint \
>>> +    "stopped at command reverse-next test start location" \
>>> +    ".*$srcfile:$bp_start_reverse_test\r\n.*"
>>> +
>>> +# The reverse-next should step all the way back to the beginning
>>> of the line,
>>> +# i.e. at the beginning of the func1 call.
>>> +gdb_test "reverse-next" ".*func1 \\(\\); func2 \\(\\);.*" \
>>> +    "reverse-next to line with two functions"
>>> +
>>> +# A reverse-step should step back and stop at the beginning
>>> +# of the previous line b = 2, i.e. not in func1 ().
>>> +gdb_test "reverse-step" ".*b = 2;.*" \
>>> +    "reverse-step to previous line b = 2"
>> The point of this test is to confirm that we are at the very first
>> instruction of the line, right? So I would think it is better to do
>> a
>> reverse-stepi here, to make sure that even walking a single
>> instruction
>> we reach a different line.
> Yes, we should be on the first instruction of the line so stepi would
> be a better test to prove we are really on the first instruction.
> Changed the reverse-step to reverse-stepi.
>
>> Either that or doing what Pedro did in his
>> email: save the PC before executing the line, then do and undo the
>> line
>> and confirm that PCs match exactly.
>>> +
>>> +
>>> +# Setup for test 2
>>> +# Go back to the start of the function
>>> +gdb_test "reverse-continue" "a = 1;" "At start of main, setup for
>>> test 2"
>>> +
>>> +# Turn off record to clear logs and turn on again
>>> +gdb_test "record stop"  "Process record is stopped.*" \
>>> +    "turn off process record for test1"
>>> +gdb_test_no_output "record" "turn on process record for test2"
>> Since you don't require process record for this test, you can't
>> assume
>> these to work. I think its better to clean restart and record if the
>> process supports recording, this way you're sure to reset history no
>> matter the inferior.
> No, the test requires process record.  If record is not supported, we
> can't do reverse execution.  That said, doing a "clean restart" and
> then record would be another way, probably better way, of clearing the
> history.  Put in a clean restart rather than turning off/on the
> recording to clear the log file.

 From my understanding, you could have architectures or inferiors that 
support reverse execution without needing to record, that's why 
"supports_reverse" and "supports_process_record" are different.

However, if you want to restrict this to record-only, that's fine, I 
just think it should be a requirement at the top of the test, not in the 
middle of the execution.

-- 
Cheers,
Bruno


  reply	other threads:[~2023-05-04  9:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 20:59 Carl Love
2023-05-02 14:15 ` Bruno Larsen
2023-05-02 15:40   ` Carl Love
2023-05-02 15:42     ` Bruno Larsen
2023-05-11 15:11   ` Simon Marchi
2023-05-03  9:53 ` Bruno Larsen
2023-05-04  2:55   ` Carl Love
2023-05-04  9:24     ` Bruno Larsen [this message]
2023-05-04 14:52       ` Carl Love
2023-05-04  2:55   ` [PATCH v2] " Carl Love
2023-05-04 15:59     ` [PATCH v3] " Carl Love
2023-05-05 14:59       ` Luis Machado
2023-05-05 16:10         ` Carl Love
2023-05-10 13:47       ` Bruno Larsen
2023-05-10 17:16         ` Carl Love
2023-05-10 17:32           ` [PATCH v4] " Carl Love
2023-05-11 16:01             ` Simon Marchi
2023-05-11 16:23               ` Bruno Larsen
2023-05-11 17:28                 ` Simon Marchi
2023-05-16 22:54                   ` [PATCH 1/2] " Carl Love
2023-06-19 17:11                     ` Simon Marchi
2023-06-22 16:52                       ` Carl Love
2023-06-23 17:44                         ` Simon Marchi
2023-06-23 19:41                           ` Carl Love
2023-06-23 20:04                           ` [PATCH 1/2 ver 2] " Carl Love
2023-07-06 15:07                             ` Carl Love
2023-05-16 22:54                   ` [PATCH 2/2 v5] " Carl Love
2023-05-25 15:08                     ` Carl Love
2023-06-08 16:36                       ` Carl Love
2023-06-19 17:58                     ` Simon Marchi
2023-06-22 20:38                       ` Carl Love
2023-06-22 20:39                         ` Carl Love
2023-06-23 17:49                         ` Simon Marchi
2023-06-23 20:04                       ` Carl Love
2023-06-23 20:04                       ` [PATCH 2/2 v6] " Carl Love
2023-05-16 22:54               ` [PATCH v4] " Carl Love
2023-05-11  7:52           ` [PATCH v3] " 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=f5961b89-4a6f-1e77-0445-74a2dc150830@redhat.com \
    --to=blarsen@redhat.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=cel@us.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    --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).