Debugging tools for bitstreams?

Status
Not open for further replies.

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
I'm doing some work with generating raw bit streams programmatically (as opposed to streaming something abstract like a file as a bit stream). As I tested the generated bits, I realized I don't know any modern tools for visualizing bits streams for debugging.

Of course I can write my own visualizers and testers from scratch, but are there any existing tools that if I passed in a blob of binary data, it would help debug things like:
  • Is the binary data filled reasonably, or are there big chunks of ones or big chunks of zeros?
  • Is the binary data looking like information or are there large repetitive filler chunks? (E.G. Is there a 3k block of 0x4C bytes repeating?
  • Diffing over time. (What chunks in the new data are different from the data prior to that code change I made.)

I haven't worked with raw binary data since the mid '80s, so my knowledge of debugging tools for binary data is beyond obsolete.
 
I don't know "what's available" off the shelf. I can't imagine visualizing bit streams would be very useful. (I am just imaging rows of black and white boxes streaming like tickertape across my screen). It seems like you've got to interpret the stream into something higher level before you can do much useful with it. E.G., you can visualize PCM as a line chart, because PCM can be interpreted as signed ints.

The "reasonableness" of binary data is entirely dependent on what that data is supposed to mean. I think the problem in what you're looking for is that you have a common sense notion of reasonableness that is actually far more provincial than you realize. For instance, if your stream represented a genome, seeing 3k blocks of byte-sized repeats would be reasonable. If your stream represented an rgb framebuffer depicting a red square, it would also be reasonable to see 3k blocks of repeating bytes.

Diffing over time is again only feasible if you've interpreted the data as blocks of some size. Otherwise, what can you reasonably hope to get?

"Here are the diffs for 2-bit sized chunks, starting at position 0".
"Here are the diffs for 2-bit sized chunks, starting at position 1".
"Here are the diffs for 3-bit sized chunks, starting at position 0".
"Here are the diffs for 3-bit sized chunks, starting at position 1".
"Here are the diffs for 3-bit sized chunks, starting at position 2".
.
.
.


It's the library of babel.

There's only one positive suggestion I can make for you. A very generic test that you can perform is to examine the information content of your bitstream by checking its compression ratio. Figure out how much reasonable data for your use case typically compresses, and then have a diagnostic which tells you the compression ratio for the data under inspection.
 

Nimdok

Ars Scholae Palatinae
1,214
So is this something you can write to a file, or you have to check it in real-time?

When I need to go to the bit level I use hex-mode in Emacs and diff buffers. Debugged an issue in Gstreamer today doing just that.

Another technique I use is to write a simple parser for the bitstream. Then I can pipe it to the parser anytime and get a readout.

Code:
bits | bits2ascii

Mind filling us in about what you're working on?
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Another technique I use is to write a simple parser for the bitstream.

this. make the code you're using to consume the stream something that feeds into your usage.

Makes it nice and easy to debug things, including dumps of the relevant sections of whatever buffer you are working with at the time, you don't repeat yourself etc. It will likely lead to you making your parsing code produce *way* better and more detailed exceptions, and add sanity checking to values (so if you start getting crazy later values because someone put in a 4 byte value when it was meant to be 2 bytes you can trap it neatly and crucially *early*).
 
Status
Not open for further replies.