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

FreeBSD support #112

Closed
3 tasks done
akhramov opened this issue May 10, 2019 · 9 comments
Closed
3 tasks done

FreeBSD support #112

akhramov opened this issue May 10, 2019 · 9 comments
Labels
enhancement New feature or request

Comments

@akhramov
Copy link
Contributor

akhramov commented May 10, 2019

Hi, thanks for your awesome application, I really love it.

FreeBSD is a somewhat popular system among developers and it would be nice to have it supported.

Do you have any objections so far? If not, keep reading.

As far as I can tell, this application relies on few third-party libs which do not support FreeBSD yet.
So, if we were making a checklist it would be like this:

Am I missing something? What do you think?

@benfred
Copy link
Owner

benfred commented May 19, 2019

Awesome! This would be great to add.

I think you've done most of the hard work here already (proc-maps/read-process-memory changes). Most of the remaining changes here should be in the 'remoteprocess' subcrate here.

Minimally we're looking at adding code to:

  • lock the remote process (probably can use ptrace like in linux?)
  • get the executable name of the process
  • Add CI script (Cirrus?)
  • add feature flag to disable native extension code

Also - it would be great if we could also add code to do this (but isn't necessary to get basic python profiling working on freebsd):

  • list threads of the remote process
  • get if a thread is running or not
  • lock an individual thread

I haven't ever used freebsd - but I think the tricky thing here is that there isn't procfs that we can use reliably (please correct me if I'm wrong =).

@benfred benfred added the enhancement New feature or request label May 19, 2019
@akhramov
Copy link
Contributor Author

Thanks, Ben.

It shouldn't be a lot of hassle to implement all of this. In fact, I think that ptrace(2) would handle most of the cases.

Alright, I'm working on the remoteprocess subcrate. Will get back with the PR. 😃

@benfred
Copy link
Owner

benfred commented May 23, 2019

Awesome!

I thought about this a little more today - and I think there is some more work that needs to happen though. We'll need to get CI setup so that I don't accidentally break this in a future change, also we need to disable the native extension code otherwise this won't build easily.

I've been planning on adding a feature flag for the native extension code (also needed to re-enable the ARM build again #89), so you won't need to implement that code for freebsd. I will get this going this weekend and update here once it's done.

Finally, do you have any suggestions on how best to distribute w/ freedbsd? I don't think that there is a binary wheel format that will work with freebsd - making pip install py-spy probably a non-starter. :(

@akhramov
Copy link
Contributor Author

Cool, worry not, I will setup Cirrus-backed CI, the same I've set up for the proc-maps crate:
https://github.com/rbspy/proc-maps/pull/3/files

As for distribution... I will dig into this. If there's no appropriate wheel format, I think I'm going to create a FreeBSD port. How does that sound to you?

@benfred
Copy link
Owner

benfred commented Jun 23, 2019

I've fixed up the ARM build, and I believe that native extension code should be disabled for FreeBSD now (which should simplify things quite a bit).

For distribution, I looked into it quickly and I don't think we can distribute binary wheels. I was also thinking about just uploading compiled binaries to the releases page on github might work out pretty well too (like what rbspy does https://github.com/rbspy/rbspy/releases ).

akhramov added a commit to akhramov/py-spy that referenced this issue Jul 10, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
@akhramov
Copy link
Contributor Author

Uh, thanks! Sorry for the huge delay. PR Is up here #131.

Besides review, we need to settle things down with dependencies. I put details in the PR.

akhramov added a commit to akhramov/py-spy that referenced this issue Jul 10, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 10, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 11, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 11, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 14, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 14, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
akhramov added a commit to akhramov/py-spy that referenced this issue Jul 14, 2019
FreeBSD is a somewhat popular system among developers and it would be
nice to have it supported.
In order to support it, we have to patch the remoteprocess subcrate a
bit, as well as bump `proc-maps` and `read-process-memory`
crates version.

This change

[remoteprocess crate]

Adds FreeBSD support for

* process and thread locking (via ptrace)
* getting thread registers (via ptrace)
* getting process' executable and cwd (via libprocstat)
* read_process_memory contract has changed in the latest version, so
  OSX / Linux / Windows code has been adjusted accordingly.

The only thing that is left to be implemented is unwinder /
symbolificator. Therefore `py-spy` on FreeBSD does not support native
stack traces, yet.

[py-spy]

* Adds FreeBSD-specific versions of platform-dependent functions.
* Adds Cirrus CI configuration to run tests against FreeBSD
  platform. In order to set CI up, please refer to
  https://cirrus-ci.org/guide/quick-start/
benfred added a commit that referenced this issue Jul 20, 2019
@drozdowsky
Copy link

I see that FreeBSD support is merged (huge thanks btw!), can we have new release on PyPy so I can install py-spy on my workstation?

Thanks!

@akhramov
Copy link
Contributor Author

@drozdowsky py-spy will likely be distributed in binary form from the GH releases page, as @benfred suggested above.

We can create put py-spy to the ports tree as well, though...

@benfred does rbspy automate the build process or they build binaries manually?
If you need me to build the release artefact manually, just ping me.

@benfred
Copy link
Owner

benfred commented Jul 29, 2019

PyPi doesn't support binary freebsd wheels - so we won't be able to install via pip like @akhramov mentioned.

I've set up cirrus to upload a tarball to the GH releases page automatically in #135 - and from testing it out there is a freebsd tarball here: https://github.com/benfred/py-spy/releases/download/v0.2.0.dev3/py-spy-v0.2.0.dev3-x86_64-freebsd.tar.gz

You should be able to install it on your workstation from there (download the tarball, but the py-spy binary it contains somewhere on your path. It's a pre-release version, but should work pretty well.

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

No branches or pull requests

3 participants