Usual Introductory Blah

About a year ago I wanted to dump Microsoft Visual C++ in favour of MinGW, since I'd have really liked to use 'modern' C++11 features.

However, the promises of out-of-band compiler updates with better C++11 support and the fact that it is easy to create minidumps via dbghelp.dll's functionality and debug them with windbg were enough to delay this move.

Until now.

With the announcement of MSVC 2013 and its - still - lackluster support for C++11 I gave in.
However losing the debugging support for crashdumps really hurts. But every search on the web only turned up other unsuccessful inquiries about a working post-mortem debug facility with MinGW.

The Problem

The only sane way to create crash-dumps under Windows is to use dbghelp.dll's Minidump functionality.
This minidump can then be loaded with windbg (or Visual Studio). However, both applications need a PDB file to show useful information (unless assembly and memory addresses instead of function names is sufficiently informative for you).
A file, gcc does not create, since it stores its debug information in DWARF format. A format neither of those programs can handle.

So how about the other side?
gdb can of course handle DWARF files. But it can not load minidump files.

Bummer.

The Solution

Luckily(?) the ecosystem of the D programming language faced a similar problem.
So that is where the solution can be found: cv2pdb, which can not only convert CodeView files to PDB, but also the DWARFen ones!

Create the Debug Info

  1. Compile/link your project with debug information (gcc -g)
  2. Use cv2pdb to convert the DWARF debug info into PDB format (cv2pdb -C program.exe)
  3. Strip the executable from any debug info (strip -g program.exe)
  4. Distribute the executable and keep the PDB file

The PDB file and the executable cannot be matched automatically based on their checksum, since the strip changed it. So you need an out-of-band way to match the correct files.

The way I do it: on an actual crash I create the minidump and pack it together with the logfile, which contains the application's version number, into a zip or tar file before sending it off. That way I can match the minidump to the correct PDB file.

Actual Debugging

Since the executable was stripped of any link to the PDB file windbg tries to load a generic image00400000.pdb file (or image00000000`00400000.pdb for 64bit executables).
So make sure that is the PDB's file name.
I for one just archive the PDB files named this way and put them in a directory for each version.

  • The directory containing this file needs to be added to windbg's symbol search path. (-y <path>)
  • Further more, since the PDB file and executable cannot be matched .symopt needs to be changed, to include 0x40 (SYMOPT_LOAD_ANYTHING).
    Combined with the default symopts this is 0x80030377. (-sflags 0x80030377)
  • And finally the actual dump file needs to be specified with the -z argument.
  • While I'm at it: I also add -g to skip the initial breakpoint.

All in all I end up with a command line like this to start windbg to do post-mortem debugging with a minidump:

windbg -sflags 0x80030377 -g -y <directory_containing_correct_pdb_file> -z <path_to_dumpfile> <path_of_correct_executable>

Dancing Desk
02013-Mar-15, Fri 22:00 in /blah [permalink]

It's nothing new that sitting a lot isn't beneficial to your health. That's why more and more people jump onto the standing desk bandwagon. Over 2 years ago I wanted to do the same. But I didn't. I kept my complacent ass conveniently situated on a chair in front of my computer. But then I developed a rather annoying case of runner's knee, which hurt more while sitting than standing. This was enough motivation for me to start standing while working at the computer. Hooray!

Making a stand

I started like so many others do: I put my screens, keyboard and trackball on cardboard boxes. Which was nice. Cheap. But sucked, because it forced me to stand still while typing. And when I'm in the flow, then.. things can take a while. After the first few days my legs became more muscular and everything was gr.. well, no, it was actually fluid building up in my legs.
Standing still sucks.
Furthermore 'professional' solutions of standing desks cost an arm and two legs. Though the sheer size of my swollen legs may have brought the price down to both legs only and no arms, but that was still more than I was willing to spend on something less than optimal.

I immediately dismissed a treadmill desk, because I want to be in control of my movement while I'm in the flow, without having to interface with another device. Regulating speed is a great flow-breaker, I guess. But I quickly realised that some way to walk freely while typing would be my preferred solution.

Epic FAiL

My stupid first shot at this, was hanging my MS Natural Keyboard 4000 with a strap around my neck. ... It doesn't work. It's heavy, hurts the neck, wobbles around, and typing on it is what the real definition of Gorilla Arms should be. Nonetheless, I tried it for 2 or 3 days and while it was painful I enjoyed the freedom to move around while typing, so I knew I was onto something. It only needed to suck less.

Mark 1

Instead of Gorilla Arms I wanted the keyboard to be where my hands fall naturally when they are relaxed. Which is, not suprisingly, at the outside of my legs instead of in the front. That's where the keys needed to be. So I needed a real split keyboard and a way to mount it on my legs. A saw for the keyboard and titanium screws to mount it were not an option, but thanks to Kinesis (Freestyle) and the military (leg bases) both problems could be solved easily. See exhibit #1 to the right.

For an alpha version it worked remarkably well and I enjoyed using it. Getting used to the fact that I could actually move around while wearing the keyboard and type at the same time took a while.
Of course there were still a few annoyances I had to take care of. First of all the trackball was located at an inconvenient spot. I had to move my elbow quite far to the back to reach it. Not very ergonomic. Quite the opposite to what I set out to achieve. It was also in the way when I wanted to sit or lay down. Like on a couch, at the psychiatrist's they sent me to: OMG, a nutjob wearing a keyboard. Hide the children!
Well, in fact it was a neurologist and I went there because of my Carpal tunnel, which turned out to be perfectly fine. Anyway, he told me that he sees more and more patients who have problems with their Nervus Ulnaris because they have to bend their elbows while sitting and working at a computer. Ever had a tingling or numb sensation in your pinky? That's most likely the culprit.
But not so with the Dancing Desk. No bending or stretching of this nerve. He commented that this Dancing Desk might very well be the best solution for your arms while working with a computer.
Thank you very much.

The first improvement I made, was moving the trackball to the belt, which is a much better location. In fact it's freely movable along the belt to where it feels most comfortable.
This does reintroduce bending the elbow however, but at a larger angle. The resting position of my hands is still the keyboard, hence no bending. After all, I am a command-line/Vim/Pentadactyl kinda guy, so I only use the trackball for games and photo editing anyway.

Mark 2

As noted in another post, I was addicted to the back button on my mouse. Since the old Logitech Trackball Marble didn't have one, I decided to buy the current Logitech Trackball, despite my dislike of wireless stuff (changing batteries, etc.).
Quick note: I only had to change the battery once, after 1.5yrs. Impressive!

With the wired trackball gone and the new receiver plugged directly into the computer, there was no need for the USB-hub anymore.

Regarding the USB hub I'd like to add, that a tiny 3 port hub might not be such a bad idea, as it would allow connecting the keyboard and trackball to different computers by changing one cable only. But as I don't do that very often I simply dis-/connect the keyboard and trackball-receiver separately. However, one free USB port right there at your disposal can be very handy indeed. Say to connect a USB headset or load your mobile phone while talking, etc.

Dances With Cable

And with this configuration I lived happily ever after. Not really. One thing I haven't talked about is the cable connecting the two parts of the keyboard. While I bought the one with the longer cable, it was still rather short. Well, for what I used the keyboard anyway. I'm not sure anyone at Kinesis had ever considered this usage scenario. Massive oversight of them!

I dubbed the whole thing Dancing Desk, in analogy to Standing and Treadmill Desks, because it allows you to dance, among other things. I know that numerous programmers use music to help them enter the flow. So do I. And if I'm in the flow I sometimes like to move to the music. As do the best of us:

But while he has to move back to the keyboard to type I can type wherever and whenever I want. Even while dancing! Ha, eat this you and your multi-headed hydra!

The result of this dancing is a lot of wiggling of the cable. Sometimes rather harsh dragging. And sometimes even close to ripping the thing apart. Surprisingly enough the cable survived the torture for about 6 months. Then suddenly the keys T, G and B stopped working. But only occasionally and depending on my pose. Then the next column started to malfunction. And after a few days I was standing in most awkward poses just to make the left half of the keyboard work at all.
The cable needed to be replaced.

I wasted too many hours looking for a matching connector online, trying to solder/crimp a cable with this TINY connector from scratch, until I dumped this approach. Instead I decided to simply take the old connectors with a bit of cable and put the new cable in between. I was not sure if this would work, because I didn't know where the cable was broken exactly. Luckily for me the broken part of the cable was not near the connectors.

Mark 3

Of course I did not only repair the cable, but made it much longer in the process. In fact, long enough to have the cable run along the belt. From then on there were no more restrictions on the freedom of movement, nor any wiggling.

And this is what I'm using today and have been using for the last 2 years. I still enjoy it and love the ability to move around freely, dance, jump, run, .. while being able to type.

Word of caution

Let me just add a final word of caution: Simply standing up/dancing doesn't solve problems with your posture or results thereof. In fact it might increase or accelerate any damage done because of bad posture. I had my fair share of problems while sitting, and things spiralled out of control when I started to stand. But it's not like standing was the source of the problems, it just accelerated what would have happened anyway. Maybe a few months or a year later. So I had a few sessions with a great physiotherapist who taught me a lot about my body. It enhanced my awareness in regards to my muscles, tendons and bones and increased my health and well-being overall, in addition to teaching me how to stand or sit correctly. I can only advice you strongly, that whatever you do, find a professional who can teach you those things and help you prevent any long lasting negative effects on your health.

Further improvements

  • Kinesis introduced a successor to the Freestyle, aptly called Freestyle2, which is thinner. But I don't know if it is any lighter. After all, normally a heavy keyboard is better, as it prevents it from sliding around.
    However, the heaviest part of the keyboard is the metal plate seen on the picture. I guess it could be replaced by something else (e.g. aluminium).
  • Even better would be a matrix-style keyboard like the TypeMatrix. Sadly there is no split variant available.
  • Don't be connected to a stationary computer, but use a notebook in a backpack. Or even just a Raspberry Pi directly on the belt, connected to the actual machine via WiFi and SSH.
    The only problem remaining is the visual output. I don't know how good Google Glasses will be for a lot of text, but at a price of 1500USD I don't really care anyway.
    I'm much more interested to know how the Occulus Rift can handle text and if it could be used to replace a screen for programming or actual work. Of course a camera would be needed to underlay your surrounding on your desktop, screen, .. thingy, while wearing the Rift, to prevent you from running headlong into the nearest wall. Or fall of a cliff, heck, I don't know where you would use a setup like this...
    Update 2013-03-23 08:37: Sounds like it won't be any good for working with text, according to ryg. :(

Because I dislike having to move my fingers far from the homerow, I created a custom keyboard layout.
My goal was not to achieve a faster typing speed, but reducing the distance my fingers had to move from the homerow. Everything should be at the homerow ±1.

Keep in mind, that the alphabetic characters and even numbers stay right where they are on the standard US layout. Nothing is changed there, making the switch easier. This also means, that it doesn't interfere with any alternative keyboard layouts like Dvorak, Colemak or Workman, much. It should be easy to adapt it to those.

Sanitising the physical keyboard layout

Left Shift


I like the wide shift key of the US layout. But the US International and German layouts (as well as others) introduce another key right right of the left shift key. Hitting the left shift key is therefore not just moving the pinky down, but also moving it to the left. Not comfortable at all. Making this key my actual shift key is #1 on my list.

Return


Likewise the return key on the German layout may be taller, but is still farther away from the homerow than on the US or US International layout. So on German keyboards I immediately map the #/' key to return.

Remapping special keys

Escape

Because I'm an avid Vim user and the escape key is on another planet entirely, I map it to the capslock key. Members of the Church of Emacs might prefer to map control there.

Return & Backspace

As you will see later, I don't need the left and right bracket keys anymore, so I decided to map the return key (as it is such an important key and still 2 keys away!) to, what used to be, the left bracket key.
Lastly I map backspace to the right bracket key. For me that's close enough that I can reach it without having to move my hand. While it is still further away than my target of homerow ±1, it's a key tahtitsn' nedeed ina prefect wrld anhywa.

Right Shift

I considered mapping the right shift key to the former return key, as it is the last key that is awkwardly to hit. Moving the poor pinky not only down or to the right, but diagonally. This feels very uncomfortable to me. A major downside of this is, that as soon as this becomes muscle memory, I'll hit enter all the time on regular keyboard layouts. And this can be really dangerous on the command line, or, basically everywhere.

Moving to a new layer

Now that everything is at the homerow ±1 except for the digits and all the symbols, it's time to take care of those keys. Since I grew up with the German keyboard layout I was always used to the idea of using AltGr (the right Alt key) in combination with some other key for some symbols. So why not introduce a new layer to the US layout with all the symbols a programmer could ever need?
Note: On a Mac's keyboard the right Cmd and Alt key are swapped, so those two keys need to be remapped to make the right alt key easier to hit.

Symbols

There are 3*10 keys at the homerow, up and down. Enough space to map all the symbols right there. This means: not having to stretch my fingers as far as the row of digits and in addition to that, not having to use my weakest finger, the pinky, to press shift, but use the strongest one, the thumb, to press AltGr. In addition to the symbols, the most used digits (at least in my code) are also included.

I tried to arrange them logically instead of based on some metric like same-finger or what-have-you ratio.
e.g. o = 0, i = 1, / = \
Opening and closing braces are right next to each other and under the strongest fingers.
+ and = directly on the homerow, while the considerably less used - is off the homerow, etc.
^ is to the left, as it marks the beginning of a line in a regular expression, while $ is to the right, because it marks the end of a line.
And . becomes -> because it's used to access members in C++ like . just for pointers. It's also the same finger as *, which is used to dereference pointers. Those things made it easy for me to learn and remember this layout.

Having _ off the homerow was okay when I created the layout, but since then I've moved from CamelCase to using _ in variable names, so I'm not really happy with where it is now. I consider swapping it with *.
But that's why the layout is called 2013.02. I don't rule out making minor changes over time.

Going digital

With the symbols taken care of, it was time to find new keys for the digits. Since the AltGr layer was already full, I moved them to Shift+AltGr.

The arrangement might look odd, but its actually based on the numbers (not just digits) found in my code and the 3rd party libs I use.
The most frequent single-digit numbers (0, 1, 2, 8) are already covered on the first layer, so I tried to make the multi-digit numbers as easy to type as possible. Not surprisingly those numbers were 32, 255, 64 and 16. All those combinations are easy to type by simply rolling your hand from left to right, with the most common combinations on the homerow and the other two on the row above. 0 is used on its own most of the time and already covered on the first layer. 7, for some reason, is barely used at all so I moved it to the least desirable location. 9 is also barely used. And 8, well, I had to stuff it somewhere. I also added a decimal separator to conveniently type decimal numbers.
Yes, this arrangement takes some time getting used to when typing regular numbers. But typing those aforementioned most used combinations slips into muscle memory rather quickly.

The AltGr+Shift layer with its numbers is a rather new addition and for typing regular numbers I still fall back to the row with the digits quite often. I guess I would have to remove the original digits to force me getting used to their new placement. But I won't do that, because a lot of applications use combinations of modifier keys with a digit as hotkey and without the original digit-keys those hotkeys would be unavailable.

Conclusion

I've been using this layout (and its previous iterations) for the last 6 years and it's only when I'm forcefully put in front of regular layouts, strapped down while screaming and shouting, that I realize how much more comfortable this setup is.

Downloads

Windows

Keyboard layout: mld1302.zip.
Use SharpKeys with the following settings to remap the special keys:

OS X

Save the keyboard layout mld201302.keylayout to ~/Library/Keyboard Layouts.
Configure PCKeyboardHack as follows:

And use this configuration (private.xml) for KeyRemap4MacBook. Enable: Wide Left Shift, Left Bracket as Return and Right Bracket as Backspace.

X11

Add this to your ~/.XCompose file:
<U30000> : "->"
If this file doesn't exist yet, add include "%L" at its beginning.

Save this layout file to your X11 keyboard layout directory and activate it with

setxkbmap -layout mld -variant 105