Monday, April 13, 2009

stacktrace


One of the quickest ways to debug code is to be able to tell how you got to a certain point in your code. So it is useful to be able to dump a backtrace/stacktrace at any point in your code.

I think you can find really good resources elsewhere to understand what a program stack is (for example this or this), so I won´t get into it. As a side note, those two links are some of the best ones I have found to understanding program memory and the difference between program heap and stack.

In C/C++:

This article gives really good information.
In summary, glibc provides backtrace() and backtrace_symbols() to do this quickly.

In JAVA:

Use the very useful Throwable class with your logging.

Example:
Throwable t = new Throwable();
Log.getStackTraceString(t));

ld-linux.so.2

When running your application, the shared libraries will be searched in wherever the LD_LIBRARY_PATH environment variable is pointing to.

However, sometimes when running applications that your receive with a specific library, you could use another way to indicate just that. ld-linux.so.2 is the Linux ELF program loader. It has a few options, but for our use, we need the --library-path option.

--list list all dependencies and how they are resolved
--verify verify that given object really is a dynamically linked
object we can handle
--library-path PATH use given PATH instead of content of the environment
variable LD_LIBRARY_PATH
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names
in LIST

Example:
# /lib/ld-linux.so.2 --library-path my/shared/libs my_app

Friday, March 6, 2009

write in C

Nerdy and funny.....he is right, 'Write in C'

Tuesday, March 3, 2009

wordpress - disable/enable comments on all posts

Since I finally got a chance to enable CAPTCHA on my personal blog which uses wordpress, I needed a quick to way to turn on comments that I had disabled for my posts.

This tutorial was good, but I do not have myPhpAdmin.

So, my steps were:

mysql -u -p
mysql> show tables;
+--------------------+
tables in ....
+--------------------+

....
mysql> UPDATE wp_posts p SET comment_status = 'open' ping_status = 'open' where comment_status = 'closed';

Of course, to reverse this:

mysql> UPDATE wp_posts p SET comment_status = 'closed' ping_status = 'closed' where comment_status = 'open';

worked like a charm.

--- Addition

Enabling comments was fine, but the SpamBots are now abusing the trackbacks option. So, I need to disable trackbacks too.

mysql> UPDATE wp_options SET option_value = 'closed' WHERE wp_options.option_id =20 AND wp_options.blog_id =0;

Tuesday, February 24, 2009

Ubuntu and Eclipse and svn

In the last two months, I have been spending some time developing phone applications in JAVA and using Eclipse as the IDE. Not having ever written in JAVA before, I cannot even imagine how long the whole development process would have taken was it not for the IDE.

So far in my development life, all my C/C++ code writing has required:
- a Linux system (i.e 'grep')
- ssh access to the build server (with right kernel, glibc, gcc version)
- vim + ctags for source code
- valgrind for finding memory leaks
- gdb for deugging

So the whole Eclipse+JAVA experience got me thinking if I could get any benefit from using a Eclipse for a large C++ project that I am involved with at work. Maybe it will at least help prevent carpal-tunnel from having to grep the life out of the project.

It seems the default Eclipse install for Ubuntu 8.04 is version 3.2 which is fairly old. So, it is best to download the newest version rather than use apt-get.

Next challenge was to get Subversion plugin.

Apparently, trying to add the svn plugin kept giving me an error
"
An error occured during provisioning.
Cannot connect to keystore.
JKS
"

Fortunately, some google searching pointed me to the fix. The plugin install needs Java 1.6 or newer. Also, the Java 1.6 has to be the default JRE which most likely it wont' be even after doing:

sudo apt-get install sun-java6-bin sun-java6-jdk

The Ubuntu Java Installation documentation explains how to select the default Java version on your system.

You could use
update-java-alternatives -l
or
manually pick the java-6-sun using sudo update-alternatives --config java

Oh well, I now finally have the C++ project under Eclipse pulled in from svn, I can at least browse the code.

Also, if anybody is looking for suggestions on what other developers perfer when doing C++ coding, check out this stackoverflow link.

Friday, February 20, 2009

testing software systems with a GUI

I am not a QA engineer or play one in my professional life, but I read/heard this somewhere recently and it makes sense.

If you are testing a software or a system with a GUI, don't test the software or the system functionality using the GUI. Develop alternate methods to do that. Just devote separate efforts to testing the GUI itself, since there is enough logic and code to build the GUI itself that need to be tested.

I believe a "Unix way of software development" is to build a command line interface as a first step to any future GUI enhancements. That gives you a perfect seperation between functionality and GUI and gives you a good avenue to do testing.

Also part of that same note was this nice line where the author said, the Unix-way of development does has its con in that it does not necessarily lead to a great app, because the GUI almost follows the comamnd line. The solution; if you disabled the command line access for all Unix programmers in the world, you will have a substantial imporvement in the GUI quality of those applications.

Thursday, February 19, 2009

open source venture funding

Since I am a sucker for all things open source, I found a recent post by Mark Cuban on his blog challenging anybody with an idea to submit a business plan and be funded instantly very interesting.

As he puts it.....
You must post your business plan here on my blog where I expect other people can and will comment on it. I also expect that other people will steal the idea and use it elsewhere. That is the idea. Call this an open source funding environment.

Pretty cool challenge. I expect a lot of phone applications that will meet the 13 criterias listed.