Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdbserver doesn't work on macOS (guest) #298

Open
0x3c3e opened this issue Mar 30, 2023 · 2 comments
Open

gdbserver doesn't work on macOS (guest) #298

0x3c3e opened this issue Mar 30, 2023 · 2 comments

Comments

@0x3c3e
Copy link

0x3c3e commented Mar 30, 2023

Currently, gdbserver doesn't work on macOS (guest) as it uses eventfd, which isn't available on BSD.

@jevinskie
Copy link

Ah-ha! This is what I couldn’t remember what I wanted to try epoll-shim on to fix, thank you! It may need some Python configure.ac massaging though, I’m not sure.

@jevinskie
Copy link

Try branch jev/smol-clean-macos.

Build:

cmake -W Dev -G Ninja ../git/epoll-shim -DCMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/epoll-shim/git -DCMAKE_BUILD_TYPE=RelWithDebugInfo --fresh -DBUILD_SHARED_LIBS=OFF -DCMAKE_OSX_ARCHITECTURES="arm64e;arm64;x86_64;x86_64h"
ninja install
brew link epoll-shim

ctest for interposer will fail when built statically.

Build Python with shim using pyenv:

env PYTHON_CONFIGURE_OPTS="--enable-shared" CPPFLAGS="-I/opt/homebrew/opt/epoll-shim/include/libepoll-shim" CFLAGS="-I/opt/homebrew/opt/epoll-shim/include/libepoll-shim" CXXFLAGS="-I/opt/homebrew/opt/epoll-shim/include/libepoll-shim" LDFLAGS="-L/opt/homebrew/opt/epoll-shim/lib -lepoll-shim" pyenv install -v 3.11

I don't have a machine with m1n1 set up right now but this stupid test seems to indicate some life:

#!/usr/bin/env python3

import os
import selectors
import time

class Foo:
    def __init__(self):
        self.efd = os.eventfd(0, flags=os.EFD_CLOEXEC | os.EFD_NONBLOCK)
        self.selector = selectors.DefaultSelector()
        self.selector.register(self.efd, selectors.EVENT_READ)

    def wait_shell(self):
        try:
            os.eventfd_read(self.efd)
            print("os.eventfd_read pass")
        except BlockingIOError:
            print("os.eventfd_read fail")
            pass

    def notify_in_shell(self):
        os.eventfd_write(self.efd, 1)


foo = Foo()

while True:
    foo.wait_shell()
    time.sleep(0.1)
    foo.notify_in_shell()

Results:

 ->  % ./epoll-shim-eventfd.py
os.eventfd_read fail
os.eventfd_read pass
os.eventfd_read pass
os.eventfd_read pass
os.eventfd_read pass

More testing needs to be done...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants