gdb tricks: printing arrays

January 20, 2011

int main(){
  int *a;
  int b[3] = {1,2,3};
  a = b;

  int *c[3] = {a, b, 0};
  int **d = c;
  return 0;
}

While debugging the above code if you do:


(gdb) print b
$4 = {1, 2, 3}

that works.


(gdb) print a
$5 = (int *) 0x7fffffffe0f0

that works too, but in order to print a as an array you must do:


(gdb) print (int []) *a
$7 = {1}

and when you specify the size it gets better:


(gdb) print (int [3]) *a
$8 = {1, 2, 3}

The same goes for c and d:


(gdb) p c
$9 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}
(gdb) p (int*[3]) *d
$10 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}
(gdb) 

And finally a very recently discovered short hand thanks to Jan Kratochvil:


(gdb) p *a@3
$11 = {1, 2, 3}
(gdb) p *d@3
$12 = {0x7fffffffe0f0, 0x7fffffffe0f0, 0x0}

Eclipse Tips (Open References to…)

January 5, 2011

One of my favourite eclipse features when reading and trying to understand it is Ctrl+Shift+G (Open References to). This creates a list in the ‘Search’ view of all references to the highlighted element.

Another thing that I discovered recently is that you can click on the little arrow next to the little pen symbol on the right hand side and open up the history what previous searches. These are of course important to your understanding of the current new code.

Eclipse tips (Call Hierarchy)

December 21, 2010

This is one of my favourite features. I had to retrofit some error checking into a function in a patch I am working on.
The function is

evpy_add_attribute

. I wanted to know the functions that call this function and the functions that call them. Once I figured that out. I went through and made sure that the return values where checked for errors and appropriate action was taken.

Surprisingly Free

December 14, 2010

I only discovered this awesome podcast recently:

http://surprisinglyfree.com/

I highly recommend it.

What’s with the Abridged Audiobooks

December 9, 2010

Audiobooks were an awesome discovery for me. I find it to be a much richer experience than reading a book. Especially if the book is read by the author. I think that in the same way that text files are smaller than audio files and audiobook carries that much more information. The subtleties of the readers intonation, their emphasis, where and how long they stop all of these carry important meaning.

Anyway, what is with the abridged audiobooks ? Who buys these ? I think abridged audiobooks come from a fundamental misunderstanding of what audiobooks are. I dont listen to an audiobook to save time. I listen to it because that is a better method of learning for me.

Publishers, please, no more abridged versions.

git tips

November 26, 2010

For a quick log of what I have on my branch/repo which I have not pushed upstream I do this:

git log --pretty=oneline --branches --not --remotes=origin

A tip I got from Dodji:

git-new-workdir

creates a new working directory that shares the repository of your original clone. If like me you like to create a new direcotry for each branch you are working on this is a much faster way to do it. It also has the added bonus of being awair of you other directories so you can share commits whithought having to git remote add

In my Fedora 13 installation. This is currently located at

/var/lib/mock/fedora-14-x86_64/root/usr/share/doc/git-1.7.2/contrib/workdir/git-new-workdir

Thundersearch

November 24, 2010

I am a big fan the of the Thunderbird search bar. It has definitely helped my productivity. The star is awesome.

Clever Advertising

November 17, 2010

I always stop and take notice when I see clever advertising. This I thought was really cool:

Just before I took the photo there was a kid finishing off an elaborate peanut butter master piece.

Bad User Interface

November 16, 2010

I am not a big fan of the twist switch. I actually took the shade of this lap to take the picture which improved the user interface a little bit.

“The [user] is always right”

November 15, 2010

Dilbert.com

The old saying goes “the customer is always right”. This saying, in a nice sound bight, summarizes the idea of good customer service. That you should always make your customer happy, because, in the end, it is her money that you seek.

I think this is far truer for users though. I believe that every mistake a user makes, their first attempt at something, and the questions they ask give the developer valuable insight into how they can improve the usability of their software. Always.


Follow

Get every new post delivered to your Inbox.