Wednesday, June 14, 2006
Using GDB to Debug Linux Applications
First, understand how the application is normally executed; normally the MTA will pipe in the email content to the deliver process, but we can fake it by using simple re-direction.
>deliver -d kevin@boebel.us < email.txt
But we want to step through the code, so we need to run it through gdb.
>gdb deliver
Before we issue the 'run' command, we need to set a breakpoint, so let's say we are trying to debug this portion of code in deliver.c (lines 540-546)
env_tz = getenv("TZ");
home = getenv("HOME");
env_clean();
if (env_tz != NULL)
env_put(t_strconcat("TZ=", env_tz, NULL));
if (home != NULL)
env_put(t_strconcat("HOME=", home, NULL));
(gdb) break deliver.c:540
Breakpoint 1 at 0x8056e72: file deliver.c, line 540.
Ok, the breakpoint is set, let's run the program, giving it the correct command line arguments:
(gdb) run -d kevin@boebel.us < email.txt
Starting program: /var/home/kminnick/dovecot/dovecot-lda-0.1/src/deliver -d kevin@boebel.us < email.txt
Breakpoint 1, main (argc=3, argv=0xbfffb3b4) at deliver.c:540
540 env_tz = getenv("TZ");
Cool, the program is now getting ready to execute this line of code, let's run some commands to get the value and type of 'home' variable both before and after the line is executed.
First, we need to skip this line of code and get to the next one:
(gdb) n
541 home = getenv("HOME");
Now we can examine the variable:
(gdb) pt home
type = const char *
(gdb) p home
$4 = 0x3f1cd8 "ä[\023"
As you can see, 'pt' prints the type of the variable, and 'p' prints the actual value. The variable is currently pointing to some garbage in memory. Let's execute the line of code and find the value of the variable after it's execution:
(gdb) n
542 env_clean();
(gdb) p home
$5 = 0xbfffdf44 "/root"
This was a very simple example of how to use gdb to debug your applications, next time we will discuss a more complex example on how to debug a program that uses forks and threads. I'm sure you can't wait... :)
Friday, June 09, 2006
Review of 2006 Goals
Here are the goals I blogged about in January for this year and the results thus far:
1. Blog More
I'm definitely doing this, probably boring everyone a bit. :)
2. Go to the Doctor
Hmm...still six months left.
3. Get my weight to 175 lbs
I'm at 167 (I probably started the year around 163), only 8 pounds to go.
4. Oversee the creation the fastest webmail client on the market.
We are very close...
5. Become the best hitter on my baseball team.
We've only had 2 games so far, but our team captain is kicking butt. I'm hitting .375 with 2 RBI and 2 runs scored. That puts me tied for third (with my brother) on the team. We are 1-1 as a team. Mannin, our captain, is hitting .778 with a homer and 4 RBI. I have a long way to go, perhaps second best hitter on the team will be a good goal.
6. Shoot a round of golf under 110.
I've only played 3 rounds of golf this year. All at The Hill in Blacksburg. I have only had time to play 9 holes each time, but I think my scores have been fairly good, 51, 55, and 60. They are actually terrible scores, but I've made a lot of progress since last year. I think I definitely have a shot of getting a round under 110 if I ever find time to play a full 18 holes.
7. Take my family to Disney World.
Done, we had a great time.
8. Successfully manage our ever growing group of developers.
Ask Pat.
9. Bench Press 200 lbs one time
Today I did this, next up 225.
10. Find more time to spend alone with my wife.
Still working on this, but my favorite memory so far this year has to be the great time we had at Bill and Beth's wedding. We also had a great 5th year anniversary weekend. It's amazing how hard it is to find time alone when you have two kids. I'll keep working on it though.
Windows Vista Tips
--------
Just a quick note to say that you can change the default search provider in IE7. Click the drop-down arrow at the edge of the search box in the upper right. Select "Find more providers" and see if your favorite is available (most are). Then click the drop-down again and choose Change Search Defaults.
For the admin popups (It's called UAP or UAC depending who you ask), run secpol.msc. Navigate to Local Policies->Security Options. Set UAC:Behavior of Elevation Prompt for Admins to "No Prompt" and UAC:Run All Admins in Approval Mode to disabled. (Use at your own risk!)
---------
I'm not sure how you figured out the UAC issue but what a life-saver that is for me. Thanks! Now if someone could figure out how to get my transparent windows back I'll be all set.
Thursday, June 08, 2006
Windows Vista Beta 2 Review
After my computer decided to stop booting Windows XP Pro I decided to download and install Windows Vista Beta 2. It's been an interesting trial and error experience but I finally have it installed and running. I first had to ditch my old computer (Vista doesn't support the IDE driver that was built in 2001). I was able to install it on a brand new Dell, but I wasn't able to upgrade Windows XP Pro, I had to install from scratch. I'll probably be better off in the long run, I still hate how Dell insists on installing four million applications by default.
My first impression of Vista: "Cool Stuff". I like the visual changes they have made, I like the fading, the new transparency, the new start menu, the new explorer. I also like the gadget side bar, the new task bar, and the new task switcher. I also like IE 7, but there is no way to change the default search bar. It looks like it just hasn't been added yet, I am sure they will let me change it to Google eventually.
It comes with a few new apps like Windows Calendar and Windows Contact Manager, but they don't seem very useful. There is also some sort of collaboration app built-in, but that doesn't seem very useful either. Perhaps I need a few other users to help me test. The built-in search bar in the start menu seems to be a Google Desktop wannabe, but it appears to work rather well (I don't have a lot of data to test with yet).
I have only needed to install the following applications so far (they all work great w/ Vista):
Firefox
OpenOffice (Site doesn't work w/ IE 7 yet)
GAIM
Putty
Programmers Notepad
TurtoiseSVN
Thunderbird (for testing)
One really annoying "feature" that took two days to figure out is how to make my fonts look like crisp and clear. I was about to give up when I stumbled upon this setting:
Start->Control Panel->System and Maintenance->System->Advanced System Settings->Performance Settings->Click "Custom"->Uncheck "Smooth edges of screen fonts"
That setting has made all the difference in the world. Maybe today I can go home without a headache from my monitor.
Another issue is that I upgraded the video driver to the recommended version and I lost all of the cool transparency and window effects that I had on day one. :( I also haven't figured out how to turn off the annoying security pop-ups that open anytime I try to access an "Admin-Only" section of Windows.
I am finding the new control panel very complicated. It reminds me a lot of Perl in the fact that there are 50 ways to accomplish the same task. Navigating around the new control panel is frustrating, especially with the annoying "Admin Only, Are you really sure you want to do this?" pop-ups everywhere.
Overall, it looks like Microsoft has security as a top priority for this release. They are also finally catching up to Apple's cool windowing effects. And it won't take much more before they are caught up to Google on their desktop search capabilities. I can't think of any real compelling reason for anyone to upgrade besides the improved security features. Perhaps I'll find more in the coming days...
Thursday, June 01, 2006
A Semi-Solution for My Internet Based File System Problem
1. All of my files are backed up automatically.
2. Have a history of every revision for all of my documents.
3. Access my files from any location that has a web browser.
4. Check out files locally for airplane trips, vacations, etc.
Not a bad solution, it was easy to setup and doesn't require a local hard disk for file storage.
Dead Computer
This thought has really made the wheels turn this morning. I really need the following:
1. A web-based central repository that I can put / get files (any file type).
2. It should work like any good version control system (subversion), meaning it keeps track automatically of revision numbers, and I can view old revisions easily.
3. It would be great if I could open the files using “File, Open” from any application such as Open Office, Photoshop, etc. I shouldn't need to download the file first locally. I imagine this would require some sort of add-on to Windows Explorer. It needs to be fast though, so the plug-in should pull it down to a local temporary location, but automatically save it on the Internet when I click “File, Save”.
4. It should support sharing, so instead of having to email a document to everyone, I could simply email a note to everyone I want to share the document with and they can pull it down after entering an email / password. The link should always point to the latest revision so that timing isn't an issue. You should also be able to setup who can make modifications to the document.
5. You should have the ability to setup notifications so that you know when the document has been changed / modified.
6. It should be integrated inside of webmail.
For now, all I really need is #1. I think to solve that I'll setup a subversion server for myself and put all of my documents into subversion. I will be able to access it from home and work, the only downside is that I won't be able to open / save documents without the help of a subversion client. But at least everything will be backed up automatically and all of my documents will be accessible from the Internet.
If anyone knows of a solution that will meet the first five requirements above please let me know. I honestly haven't researched it yet.
