omniverse theirix's Thoughts About Research and Development

pstack for OS X

Unfortunately OS X does not have a wonderful Linux-world utility pstack that helps to inspect a running process with a shell one-liner:

pstack `pgrep myprogram`

So I wrote a replacement based on system gdb. Please use it if you find it useful.

I discovered a few interesting things while writing this utility. Homebrew gdb sometimes leaves a process in a sleep state after attaching and detaching. Okay, let’s use system gdb. But it is very old (version 6), non-standard and compiled without python support so we cannot use nice python scripting (initially I found a python script to run inside gdb). Okay, there is a nice native `gdb command

thread apply all bt

that does everything we need. The next problem with gdb was a lack of --ex command-line argument that allows to specify a gdb script inline. So we need to create a temporary file with a gdb script. And finally OS X lacks /proc filesystem so to determine a process binary it’s needed to consult with ps command.

The moral of this story. OS X and Linux are POSIX-compatible but differences environments, different flavors of developer tools and well-known bugs became nightmare to port even so simple utilities.

Amazon AWS SDK v2

Recently I noticed that my hobby project usbunfreeze uses AWS SDK version 1. It was fresh vesion when I wrote it at New Year holidays. But a few weeks later the Version 2 became available. It was a challenge to explore a new API without any good up-to-date examples and tutorials. Older SDK contains a lot of official working examples inside. All Ruby service mappings were standard classes with well-defined methods without metaprogramming magic. Then Amazon moved to description of their services via JSON manifests (i.e. EC2.api.json). It is definitely more generic approach but there is no way to look inside the code and check an implementation. Only rubydocs. It looks like YARD docs are also automatically generated from JSON manifests…

All things became clearer when you understand the logic behind the mappings for each service. API is more flexible than v1, allows pagination, advanced async mechanics, provides more structured responses with automatic deserialization. The best reference to hack the new API is an official AWS SDK Ruby blog with a few examples and service descriptions in SDK. Very few projects moved to the new API so GitHub is not the best helper. Hope my project will be usefuly for someone who hacking new SDK right now :)