GDB print variable inside breakpoint

If you want to print value each time breakpoint is hit you can use command inside gdb.

// main.c
#include 

int main() {
  for(int i=0;i<10;i++) {
    int b = i; // we want to print this value each time gdb hits the line
  }
}

we have to compile the code

gcc -g -o main main.c

and use gdb

gdb main
(gdb) list
1	#include 
2	
3	int main() {
4	  int i;
5	  int b;
6	  for(i=0;i<10;i++) {
7	    int b = i; // we want to print this value each time gdb hits the line
8	  }
9	}
10	
(gdb) break 7
Breakpoint 1 at 0x100000f1d: file main.c, line 7.
(gdb) command 
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>print i
>cont
>end
(gdb) run
Starting program: /Users/michalo/test/main 
Reading symbols for shared libraries +............................. done

Breakpoint 1, main () at main.c:7
7	    int b = i; // we want to print this value each time gdb hits the line
$1 = 0

Breakpoint 1, main () at main.c:7
7	    int b = i; // we want to print this value each time gdb hits the line
$2 = 1

Breakpoint 1, main () at main.c:7
7	    int b = i; // we want to print this value each time gdb hits the line
$3 = 2
...
...

How to get methods’ signatures from Java class file

Simply use javap tool

javap -classpath . my.package.MyClass

The Humble Indie Bundle 8

The Humble Indie Bundle 8 is already there and is waiting for your participation. When it comes to me, it is worth buying for the soundtracks themselves.

My favourite so far? “Wormhole Surfing” by SonicPicnic

https://www.humblebundle.com

Computer Science Programming Basics with Ruby by Ophir Frieder, Gideon Frieder, and David Grossman

bkt_computer_science_programming_basics_in_ruby

Summary: Computer Science 101

The book is a simple, short introduction to computer science and programming. It’s an unusual book as it is really short and concise (side note: compare it to The Art of Computer Programming by Donald E. Knuth – 3168 pages). However, this doesn’t mean it is unusable, contrary, it is a nice introduction for beginners.

If you are person who wants to learn some basics of Computer Science and programming, you don’t have strong attitude towards any particular programming language and you have some basic knowledge of algebra, you should definitely take this book into account.

After reading this book you will learn how to use most common programming constructs: conditional structures, loops, arrays, hash tables, some advanced sorting algorithms (read on my remarks on that), input and output operations. All that presented in a Ruby way. It’s hard for me to say whether Ruby is a good choice here as I grow up on Pascal and C, but I think it might be a good choice after all as it is a dynamic language.

In general, I think this book is worth considering. The only part I would consider hard to follow is a part covering sorting algorithms. In my opinion, explanations provided by authors will left readers in place where they know something but can not understand everything. I’d rather read something regarding standard sorting algorithms provided by Ruby framework.

Anyway. I think this book is worth considering if you have never ever done anything with Computer Science and programming.

O’Reilly (print): Computer Science Programming Basics in Ruby
O’Reilly (e-book): Computer Science Programming Basics in Ruby
Amazon (print):
Computer Science Programming Basics in Ruby

Amazon (e-book): Computer Science Programming Basics in Ruby
Safari Books Online: Computer Science Programming Basics in Ruby

Programming iOS 6, 3rd Edition by Matt Neuburg

bkt_programming_ios6

Summary: I simply like the style

This is the next release of the series related to iOS Programming. This time, Matt focuses on iOS 6 release. Comparing to previous releases, you will find here information regarding new APIs new configuration settings and new features in XCode 4.X version. This release is focused on LLVM and LLDB as they are de facto standard now – when it comes to XCode. You will also find, at last, some information regarding CoreData. The chapter is not too long, but for people who have never coded using CoreData ever before it will be a good overview. However, if you plan to do some serious CoreData coding, this book is not enough. The same refers to SQLite. There is only one page devoted to this topic in the book. Anyway, I still think this very good book for beginners as it covers most frequently used elements in iOS development and provides gentle introduction to Objective-C based development.

I would suggest to a friend. Definitely.

Product page:

O’Reilly (print): Programming iOS 6
O’Reilly (e-book): Programming iOS 6
Amazon (print): Programming iOS 6
Amazon (e-book): Programming iOS 6
Safari Books Online: Programming iOS 6

PEM to P12 and P12 to PEM and PEM to JKS and P12 to JKS

PEM to P12

openssl pkcs12 -export -in usercert.pem -inkey userkey.pem -out mycert.p12



P12 to PEM

openssl pkcs12 -nocerts -in mycert.p12 -out userkey.pem
openssl pkcs12 -clcerts -nokeys -in mycert.p12 -out usercert.pem
chmod 0400 userkey.pem
chmod 0600 usercert.pem



PEM to JKS

keytool -import -file userkey.pem -keystore keystore.jks \
-storepass _store_password_comes_here_



P12 to JKS

keytool -v -importkeystore -srckeystore mycert.p12 \
-srcstoretype PKCS12 -destkeystore truststore.jks -deststoretype JKS

Designing Games – A Guide to Engineering Experiences by Tynan Sylvester

bkt_designing_games

Summary: broadly covering the topic, however, sometimes too shallow

This book is not about how to implement the game, or how to make graphics, or which software to use. This book covers topics that have to be addressed prior to any development starts at all. Designing Games is devoted to the topic of game mechanics development. It discusses ideas that are behind the scene but at the same time make the play worth spending the time on it.

Whenever you play the game you can tell whether it is a good game, that keeps you coming back to play again and again or is it the kind of game that makes you bored after few minutes spent playing it.

Sylvester goes through various ingredients that make up the game. He discusses the mechanics idea, the way games influence our emotions, how can we try to stimulate the emotions, how the game flow make players playing the game, what are the forces behind decisions and how to stimulate player’s action. At the end you get lots of different ideas and topics covered here that are important during game development process. He also tells how important it is to be aware of what players may do with the game mechanics if you have developed it for ideal players. I particularly enjoyed the quote – “a multiplayer design needs to be robust enough to handle the constant low-grade chaos caused by players dropping out, griefing, missing key skills, or deciding to play wrong”.

Even though the topic is really interesting there are few flaws in the book. First of all, I couldn’t get into the flow while reading it. I don’t know why. I simply couldn’t. But his statement is purely subjective. On the other hand, there are few issues that made me fell uncomfortable while I was trying to fully get into the topics. First of all, I felt that book covers everything too shallow. I would rather read more critical analysis of the topic, than the praise of good game design. Another issue is terminology. There are lots of terms used throughout the book but for me it is not clear whether these terms are the jargon of the industry or whether they are simply some definitions and terms created by the author. The last thing that was putting me of while reading were references. You get the list of recommended books at the end which contains brief summary of what you can find inside each book, however, throughout the text you have no references at all. This lefts you with no way of quick finding the source of particular information or idea.

Product page:

O’Reilly (print): Designing Games
O’Reilly (e-book): Designing Games
Amazon (print): Designing games
Amazon (e-book): Designing games
Safari Books Online: Designing games

GDB – redirecting input and output streams

Sometimes, the easiest solutions are the best :) If you want to redirect input/output in gdb session it is as simple as that:

(gdb) run < input_stream_file > output_stream_file

Bash/C like gg status

This is quite silly application that I wrote for fun some time ago. It can be regarded as cryptic one. Just put following lines into ‘program.c’ file and you can enjoy running it as described below:

echo =1/*"beat that ;)" | tail -c13
#*/;main(){printf("beat that ;)\n");}
shell>gcc -o program program.c
shell>./program
beat that ;)
shell>bash program.c
beat that ;)

As you can see it runs from both: bash interpreter and C compiler

Enjoy!

Safari OS X 6.0 – how to view the page source

At some point Apple decided to remove source view of the page within Safari. At least, my default installation in Mountain Lion doesn’t allow to show Page Content directly from the page/menu level.

If you want to see page source, you have to enable development menu (Preferences -> Advanced)


show_develop

Then, you will be able to use Development features implemented within Safari


develop_menu

←Older