public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/31071] [gdb/tdep, arm] FAIL: gdb.base/catch-syscall.exp: execve: syscall execve has returned
Date: Tue, 21 Nov 2023 10:42:17 +0000	[thread overview]
Message-ID: <bug-31071-4717-yk6LV9XK0K@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31071-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31071

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eb42bb148956c283d485bbd182606a851280149d

commit eb42bb148956c283d485bbd182606a851280149d
Author: Tom de Vries <tdevries@suse.de>
Date:   Tue Nov 21 11:44:07 2023 +0100

    [gdb/tdep] Fix catching syscall execve exit for arm

    When running test-case gdb.base/catch-syscall.exp on a pinebook (64-bit
    aarch64 kernel, 32-bit userland) I run into:
    ...
    (gdb) PASS: $exp: execve: syscall(s) execve appears in 'info breakpoints'
    continue^M
    Continuing.^M
    ^M
    Catchpoint 18 (call to syscall execve), 0xf7726318 in execve () from \
      /lib/arm-linux-gnueabihf/libc.so.6^M
    (gdb) PASS: gdb.base/catch-syscall.exp: execve: program has called execve
    continue^M
    Continuing.^M
    process 32392 is executing new program: catch-syscall^M
    Cannot access memory at address 0xf77c6a7c^M
    (gdb) FAIL: $exp: execve: syscall execve has returned
    ...

    The memory error is thrown by arm_linux_get_syscall_number, when doing:
    ...
         /* PC gets incremented before the syscall-stop, so read the
             previous instruction.  */
          unsigned long this_instr =
            read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code);
    ...

    The reason for the error is that we're stopped at the syscall exit of
syscall
    execve, and the pc is at the first insn of the new exec, which also happens
to
    be the first insn in the code segment, so consequently we cannot read the
    previous insn.

    Fix this by detecting the situation by looking at the register state,
similar
    to what is done in aarch64_linux_get_syscall_number.

    Furthermore, catch the memory error by using
safe_read_memory_unsigned_integer
    and return -1 instead, matching the documented behaviour of
    arm_linux_get_syscall_number.

    Finally, rather than using a hardcoded constant 11, introduce an ad-hoc
    arm_sys_execve.

    Tested on pinebook.

    PR tdep/31071
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31071

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-11-21 10:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16  9:29 [Bug tdep/31071] New: " vries at gcc dot gnu.org
2023-11-16  9:49 ` [Bug tdep/31071] " vries at gcc dot gnu.org
2023-11-16  9:53 ` vries at gcc dot gnu.org
2023-11-16 10:04 ` vries at gcc dot gnu.org
2023-11-16 10:07 ` vries at gcc dot gnu.org
2023-11-16 10:07 ` vries at gcc dot gnu.org
2023-11-16 10:31 ` luis.machado at arm dot com
2023-11-16 10:32 ` vries at gcc dot gnu.org
2023-11-16 11:57 ` luis.machado at arm dot com
2023-11-16 17:41 ` vries at gcc dot gnu.org
2023-11-21 10:42 ` cvs-commit at gcc dot gnu.org [this message]
2023-11-21 10:43 ` vries at gcc dot gnu.org

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=bug-31071-4717-yk6LV9XK0K@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).