public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "theojehl76 at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/29155] New: After disabling "detach-on-fork" , syscalls are not catched in both parent and child
Date: Wed, 18 May 2022 11:12:44 +0000	[thread overview]
Message-ID: <bug-29155-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 29155
           Summary: After disabling "detach-on-fork" , syscalls are not
                    catched in both parent and child
           Product: gdb
           Version: 12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: theojehl76 at gmail dot com
  Target Milestone: ---

When "detach-on-fork" is set to off, GDB is not able to catch syscalls anymore,
this behavior started from GDB 10, GDB 9.2 is still able to track syscalls with
"detach-on-fork" disabled

example:

#include<stdio.h>
#include<stdlib.h>
#include<sys/mman.h>
#include<unistd.h>
#include<sys/ptrace.h>
int main(){
        pid_t pid = fork();

        if(pid == 0){
                write(1, "child", 5);
                while(1);
        }
        if(pid > 0){
                write(1, "parent", 6);
        }
        return 0;
}


Expected behavior:

(gdb) set detach-on-fork off
(gdb) catch syscall write
Catchpoint 1 (syscall 'write' [64])
(gdb) r
Starting program
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[Detaching after fork from child process 2167]
child
Catchpoint 1 (call to syscall write), 0x0000fffff7ee7c50 in __GI___libc_write
(fd=1, buf=0xaaaaaaaa0858, nbytes=6) at ../sysdeps/unix/sysv/linux/write.c:26
26      ../sysdeps/unix/sysv/linux/write.c: No such file or directory.



Actual behavior:

(gdb) set detach-on-fork off
(gdb) catch syscall write
Catchpoint 1 (syscall 'write' [64])
(gdb) r
Starting program
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New inferior 2 (process 2184)]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
parent[Inferior 1 (process 2182) exited normally]


This was tested on Linux running on X86_64 and AARCH64 with the same results

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

             reply	other threads:[~2022-05-18 11:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18 11:12 theojehl76 at gmail dot com [this message]
2024-05-03 15:41 ` [Bug breakpoints/29155] " tromey at sourceware dot org
2024-05-04  4:22 ` sam at gentoo dot 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-29155-4717@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).