Skip to content

Support executing past execve with gdb #2381

Open

Description

@neon12345

I get a "Program stopped" (Suspended: Signal : 0:Signal 0) on execve calls in rr replays and a continue results in a stop loop with no progress. I was unable to find out how this stop signal is generated. A normal gdb run of the program without rr works fine.

Activity

  1. rocallahan commented on Aug 7, 2019

    @rocallahan
    Collaborator

    You can't continue past the execve point. To debug after the execve, get the current event number with when, add some small number to it, and then try rr replay -g <event> -p <pid>.

  2. neon12345 commented on Aug 7, 2019

    @neon12345
    Author

    I see now that this is done in GdbServer.cc. Would it be possible to do this step automatically from there to get a user experience similar to normal gdb?

  3. rocallahan commented on Aug 7, 2019

    @rocallahan
    Collaborator

    Maybe. I'm not sure if the remote agent protocol can handle it.

  4. neon12345 commented on Aug 7, 2019

    @neon12345
    Author

    When I use only gdb and set a breakpoint for the executable after execve, it is possible to step over execve and halt at the breakpoint. Would it not be possible to make a small change to GdbServer.cc to get this behaviour or is there something else? I would try to add it then.

  5. rocallahan commented on Aug 7, 2019

    @rocallahan
    Collaborator

    The problem is that gdb talks to rr using the gdb remote protocol. That works differently from gdb just running by itself.

  6. neon12345 commented on Aug 7, 2019

    @neon12345
    Author

    Using gdbserver+gdb has the same behaviour. So it should be possible I guess.

  7. rocallahan commented on Aug 7, 2019

    @rocallahan
    Collaborator

    Great!

  8. neon12345 commented on Aug 9, 2019

    @neon12345
    Author

    I have implemented a first version but have to give up now. In theory one has to implement the exec-events extension sending a different stop reply on execve. (This can be found in gdb/gdbserver/remote-utils.c) The register definitions can be found in gdb/gdbserver/x86-tdesc.h and gdb/amd64-tdep.c.
    Plus advance execution to the next event after the execve and wait for the next cont. This kind of works when running rr replay normally but not in interpreter mode with eclipse.

    There are possibly multiple bugs in the gdb communication.

    1. I sometimes get errors from gdb complaining about more bytes received than expected for example when sending registers.

    2. GDB protocol error when interrupting reverse execution with rr 5.2 and gdb 8.1 #2239 also seems to be a problem here and just sending '3' makes gdb happy.

    3. While running in normal rr replay mode I can set a breakpoint after execve and continue to step from there. With eclipse I can see the stop at the breakpoint but at the same time the program continues to execute until the final kill signal.

    I guess this is because of the handling of stop signals which should be batched. Meaning that

    stop
    stop
    cont

    should probably be translated to

    stop
    cont + stop

    but this is just a guess.

  9. changed the title [-]execve stop loop[/-] [+]Support executing past execve with gdb[/+] on Jul 16, 2021
  10. rocallahan commented on Jul 16, 2021

    @rocallahan
    Collaborator

    Summary: we don't support gdb executing past execve. You can work around it by digging event numbers out of the trace and doing rr replay -g .

    gdb might have some feature to debug past execve but I haven't looked into it. We would accept patches if someone figures it out. But even if this can be made to work with gdb somehow, I'm almost certain it won't be able to reverse-execute through an execve, which is one reason I think Pernosco is a much better long-term approach than trying to squeeze a little bit more functionality out of gdb.

    If someone does want to work on this, this issue is where we will discuss that.

  11. neon12345 commented on Jul 17, 2021

    @neon12345
    Author

    With our work on shared memory recording, we created a method to record our executables individually and bypass the execve issue.

  12. Hi-Angel commented on Jul 2, 2023

    @Hi-Angel
    Contributor

    FTR, in the meantime I added an entry about execve to FAQ, hopefully it will help if someone potentially stumbles upon it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions