Unassisted GDB Sessions

December 13th, 2008 by Tastic

Bugs can be hard to find, but I guess if it were easy, I might be out of a job. Nah…. they still need someone to fix those bugs. However, the point being that because dev machines are tainted, sometimes you can’t find the bugs, sometimes it’s because you never take the right path in the software to cause bugs, and almost every time no one can tell you anything relevant about how they ran into the bugs. Ok, the last part might not be fair.

We’ve found a large number of times that we’ve had to resort to running a debugger, gdb in our case, and a debug build of the software in question on a client box to find errors. Usually, this sucks as a developer has to babysit the software while waiting for the user to trigger something interesting. Recently, I’ve found myself in a situation where I need to do this for multiple machines and I’m severely lacking the patience to follow that. So like all lazy programmers, I’ve been obsessed with finding a way to take myself out of the loop.

The solution was simple once I got it right. Set gdb to launch in batch mode, set some interesting breakpoints, and a loop to backtrace and continue until quit. Get the log file at the end of a few days of testing. Getting that to actually work was a little rough though. 

First off, I knew I needed a separate gdbinit file than my normal one and a easy way to launch. I’m in Windows here, so a shortcut could easily handle the launching. A shortcut like the one below works well.

“C:\Program Files\Your Debug Software\gdb.exe” –batch -nx –command=unassisted.gdbinit

This assumes you’ve bundled gdb, that you don’t want it to attempt to use the normal .gdbinit, and you’ve created a unassisted.gdbinit. The “–batch” option will prevent gdb from prompting the user, and will automatically quit when the command file ends I then named the shortcut something like “Unassisted Debug Session”

Now, to the guts of the gdb batch file:
# Logs will append to gdb.txt in the working directory by default
set logging on
file YourApp.exe

# Settings good for logging in this case
set height 0
set new-console off

# Seems nicer in Windows.
set mapexceptionstosignals off
set debugevents off
set debugexceptions off

# Set first break and run
break main

# For DLLs, I've had problems setting breakpoints before the app actually starts.
break error_log_function

# I program ObjC in windows... yeah, that's weird
break '-[NSException raise]'
break '-[DatabaseConnection postError:]'

# autorelease with no pool in my copy of Foundation framework
break NSAutoreleasePool.m:250

# HERE! This is were the real fun is - $_exitcode gets set in gdb when your app exits
set $_exitcode = 9999

# Corrupt stacks frames break the batch command loop or user-defined function, so continues happen separately from the backtrace. We'll do the backtrace at all stop on a hook instead, as long as the program has not quit
define hook-stop
  if ($_exitcode == 9999)
    backtrace full

# The continue loop - this will occur until the program exits
while ($_exitcode == 9999)


Now, just run on multiple machine and grab the logs afterward. Hopefully, the backtrace full will be enough to track down your bugs. Happy Hacking.

Stacks & Segfaults

GTK+ Framework

September 24th, 2008 by Tastic

Richard Hult of Imendio and GTK+ announced on his blog that a native framework for GTK+ on OSX is now available on its own dedicated site.

It’s in beta at the moment, but it works. My previous attempts to compile and run the native port never worked out too well, but a little testing on it (just gtk-demo) makes it seem like I should be able to run most GTK+ applications without too much pain.

I mostly look forward to a version of Gimp being linked against this framework. Current builds for OSX include everything, are a fairly large, and of course depend on X11.

Universal Pain

August 14th, 2008 by Tastic

As of recently, Pentagram has received more of my attention. I maintain the Mac OS X builds, and I’ve been wanting to change the process for quite some time. A little over two years ago, I set up the builds with Xcode, used the pre-built copies of the SDL and SDL_ttf frameworks, and created an Xcode project to build libpng as a framwork. The finished application bundle included these and all was well, but still I was unhappy.

I would prefer to simply use configure and make like all the normal linux users and yet still create my application bundles with all the universal goodness that is now expected on Macs. This would also allow me to have tighter control over build settings, a well know list of dependencies, and the ability to provide x86_64 binaries sooner.

So I worked out a fairly complex but slick way to build all of my dependencies from source and Pentagram itself for multiple architectures. What I got a the end of the day… um… er… couple of weeks was a few new shiny Pentagram.app bundles for each supported architecture (i386 and ppc for now).

And now for the combining of them. Well, slightly easier said than done. The lipo command used to create universal binaries only deals with the individual Mach-O files in your bundles. I wanted a future-proof method to combine any generic bundles. Surely some sort of script like that exists, but I was not successful in finding one.

So I did what all evil SOBs like me do and made one. I wrote a somewhat complete bash script and dubbed it “uberlipo”. Version 1.0 is up on the downloads page and it has a BSD-style license. I’ll put up a static page describing it in more detail shortly. Enjoy.

Bread & Butter

Comments Now Open

August 14th, 2008 by Tastic

I turned on Akismet and opened the comments up to all instead of just users. I figured that registering just to make a comment is a pain. The previous policy was only there to control spam, but that’s what plugins like Akismet are for.

I’ll still keep a tight reign over the comments, so I reserve the right to remove comments that are off-topic, offensive, or are overly-argumentative.

Flames & Rants

Finishing the Fight [Updated]

July 8th, 2008 by Tastic

Halo 3 really sunk its teeth into me. I wasn’t interested in it before launch, but after playing it a little at a friend’s place, I became a fanatic for the series. After a long stretch of gaming, this subsided and I could once again function normally.

Well, the bastards are sinking me back in this weekend since I just learned about a goal to make seven billion kills in the campaign by July 7. Bungie keeps a running count of confirmed kills in campaign, and at wowunited.net they have this nifty stats page. I ran through the campaign on normal last night and this morning. I’ll undoubtedly do it at least once more before Monday. I’d also encourage anyone out there to do the game.

Guns & Ammo

Update: Bungie Day has come and passed. Didn’t make the seven billion goal, but it was a valiant effort. I checked the count with a little less than 30 minutes before it ran out and the kill count was an impressive 6.951,005,525. Also, that nifty stats page wasn’t meant to be viewed after the countdown, so the numbers got a little funny.

Chain Letter Email

July 1st, 2008 by Tastic

Seriously? This stuff still exists? Today I got one of the old-timey chain letter emails. It had a sob story and a rigged moral choice at the end to “Do the Right Thing” and forward to all of your coworkers and friends. If you didn’t, you are clearly a cold-hearted son-of-a-bitch and I’m sure you’ll get your comeuppance. Well, yes. Yes, I am, and undoubtedly I will. The moral choice of forward like a good little sheep or delete like a cruel bastard was a clear choice to me, and my trash can gets a new entry.

I thought this stuff died in the 90s as I certainly yelled enough at anyone doing it then, but it appears I’m not done yelling yet. It might be the spread of good will or it might be a vicious trap to get a bunch of confirmed working email address to target spam at. Either way, I don’t care. This is something that has always annoyed me, and I won’t participate. You hear me out there? Do you?

Ok. I’m calm now. Anyways, been a while since I posted an update. The theme got a few improvements, namely PNGs with transparency. That’ll require IE 7 or greater to display properly… or any other vendor’s browser made in the last decade. A friend of mine pointed out that it’s not a big deal as most IE users already have upgraded and this aims to be a techie site. It does make the gradients flow better and the image size smaller, so I’m somewhat happy about that.

Popcorn & Sunshine

Revised First Post

May 22nd, 2008 by Tastic

Just to drop a quick note, I updated my first post to have a different title and link. There was originally going to be a naming convention for posts that I ultimately decided against. So I thought it might be good to pretend it never happened.

In other news, I’m considering a few more theme changes and will likely get hung up on a few of them before posing anything else “real”. A few things like text sizes and column widths could be adjusted. I’ll post more when I implement them.

Cowboys & Indians

Is Subversion Too Hard?

May 21st, 2008 by Tastic

Subversion seems makes a very good amount of sense. It has some drawbacks and some benefits. Some developers prefer different models of source control, some companies only use certain source control systems, but everybody on the same page that it is simple enough to understand and use, right?

Well, maybe not. People who are not familiar with the concept sometimes have a great deal of difficulty getting over the first few steps. There are tools like Tortoise SVN can help a great deal in instructing users, but there still remains the question of if it is suitable people who are not developers. Ah, there’s the key. You were probably wondering why someone wouldn’t suck it up and go read the book. Well, at the company I work at we exposed subversion to everyone, not just programmers. People who work with the software configuration, the reporting tools, and files used in data conversion are all instructed to use the repositories. We had to create rules to were the files go, I’ve had to help people with sandboxes they’ve broken, instruct them on how to use the tools, and fix their mistakes. The company is pretty small so I’m not sure we could handle a more controlled process that doesn’t require giving them control of the files, but I’m becoming less sure that introducing the concept of a code repository was a good thing.

Before we had file shares to hold most of this data. That had problems with tracking what was changed or accidentally deleted, but it was simple. Well, it was simple until they decided to start “versioning” the files with dates in the name or having more than one person working on the configuration at a time. So we brilliant developers smacked them and told them to just use the repository instead. However, it still took time to break them of putting dates in the filename, and they are not putting in meaningful log messages, so tracking changes is still a problem.

Now I’m wondering if the file share was a better concept and just have a nightly automated task suck the files into the repository, but I’d lose the ability to see who done what. What I think I really want is to have a single developer to be the point of contact for all official product configuration changes. This would cause much better review and tracking ability, but that’s more resources than we can afford to spend.

One thing I am sure on is that you should maintain separate repositories. The muck is also in the same repository as the code, which might be why this is my problem instead of the technical leads in implementation. Sigh.

Cops & Robbers


May 11th, 2008 by Tastic

I’ve been working on the theme for the site over the last month, and I think it’s finally at a state that I can start posting some content.
The look was designed mostly around Apple’s Safari web browser, so I took advantage of some of the features available in it.
I plan on making a few changes over the next few months to make the look consistent everywhere, but it is usable enough for the moment.

A TODO file in the theme lists the following:

  • Search bar: I’m not sure I like the look of this yet, and the image could use some improvement
  • Logo: the site does not have one
  • Borders: Safari rounds and shadows well, but it would be good to find a more cross-browser approach like border images
  • Images: the images could use some work, the pinstripes don’t scale well and some of the gradients could be smoother
  • Image Format: choose jpegs at first, consider switching to pngs

The theme itself is available for download on the Downloads page.

If you have any suggestions or improvements to the style sheet that you would like to suggest, please do so in the comments for this and future posts regarding the theme.
You will need to register a username with the site for make comments.

Puppies & Kittens


April 6th, 2008 by Tastic

Welcome to my humble blog. I’m starting to play around with it to see if it’ll work out for me. I’ve been feeling the need to start a site. I’ve also been lazy, so whatever is quickest will likely be my solution. I’ll be messing around with the format a bit until I get something I like. Expect changes.

Hugs & Kisses