
Debug your programs like they're closed source - jvns
http://jvns.ca/blog/2014/04/20/debug-your-programs-like-theyre-closed-source/
======
greenyoda
_" Your program communicates with something on a network, but some of the
information it’s sending is wrong? It’s probably sending it with write,
sendto, or send."_

If you want to debug network traffic, a higher-level tool like Wireshark[1]
(which knows about the packet formats for all sorts of different wire
protocols and has sophisticated tools for filtering out just the packets
you're interested in seeing) would be much easier to use than looking at
system call traces.

Still, this is a great article, and I definitely agree that learning about
your operating system's debugging facilities is useful, but in many cases you
can save yourself a lot of time by using a tool that's optimized for a
particular task.

[1]
[https://en.wikipedia.org/wiki/Wireshark](https://en.wikipedia.org/wiki/Wireshark)

~~~
anaphor
Here is a good way I've found to debug network based code:

Step 1: write shell scripts to capture certain kinds of network traffic with
tcpdump and output a pcap file (e.g. have a certain function to capture HTTP
traffic of a certain kind)

Step 2: open with wireshark and split screen with source code

I'm sure wireshark has a nice way of doing step 1 but I prefer the workflow of
typing "foocap example.org" and then looking at the results in wireshark.

------
Pacabel
While I suppose this may be a "new way" of debugging for the author of this
article, it's hardly a new technique. strace, trace, truss and similar tools
have been around for decades now. They're the kind of tools that many
developers and sysadmins use without a second thought.

------
helper
If you find strace useful, you should check out sysdig[1]. Sysdig is like
strace but uses kernel trace points instead of ptrace so it has a lower probe
effect on the running process.

[1]: [http://www.sysdig.org/](http://www.sysdig.org/)

------
carey
Should I stop feeling guilty now about debugging Java programs on Windows
using Process Monitor?

~~~
greenyoda
On Windows, there's also Process Explorer[1], which can show you all your
processes' threads, file handles, etc. (plus all the stuff you can see in Task
Manager like memory and CPU usage). And it can search for which process has a
particular file open. Very useful.

[1]
[https://en.wikipedia.org/wiki/Process_Explorer](https://en.wikipedia.org/wiki/Process_Explorer)

------
cordite
strace with Haskell is really messy because of the run time scheduler for
green threads.

I would guess that it is similar for other run times that involve similar
concurrency management techniques.

