About This Blog

This is Chunhao's Blog

I'm writing something about life and technology here. As a practice of English writing.

My Chinese Blog: http://blog.chunhao.net

My Chinese Page: http://chunhao.net/index-cn.html

Subscribe

The books I’m reading

The items I’m interested in

License

20 March 2008 - 15:00Interesting Unix Time

If you set the preference of you system time, you will find a clock type called “UNIX time“.

screenshot16.png

If “UNIX time” is selected, what will happen?

screenshot17.png

Cool! This is the time here. Isn’t it interesting? Well, it may be confusing as hell, and you may ask what’s the time it is. Let’s investigate what’s Unix Time.

Unix time is displayed in seconds elapsed since January 1, 1970. It is stored in a 32-bits integer, time_t. So, it looks like this.

But there is a small issue there, say, as long as the largest integer a 31-bits(1 bit for sign bit) number can represent is 2^31 that is 2147483648. So large? What time it is? It is exactly 03:14:07am(GMT), January, 19th, 2038. This is the famous 2038 problem. After this time, the variable will turn into 10000000000000000000000000000000, which is -2147483648 in decimal. Is that tricky? What’s the time then? May be 8:45:52pm, December, 13rd, 1901. Wow, it’s really a big problem, almost all the computer will be crashed at that time. Is that true? Of course, but I don’t think that will be a critical problem, because after 30 years, almost all the computer will be upgraded in to 64-bits or even 128-bits(256-bits?). The problem will be easily fixed then. So, just think it as a tricky, rather a problem.

At last, I want to say, enjoy your Unix time! You know, developers are the primary users of it.

Not all 650-393 students are qualified for 642-446 or 642-503. They need to write 156-215 as well as 642-436 in order to prepare for 70-284.

1 Comment | Tags: OS, linux

19 March 2008 - 1:22How to connect vim with gdb — using clewn

screenshot3.png

First, I will show you the screen shot The screen of vim is divide into two sub windows, the top one can display the code and the bottom one shows the variable you want to watch. Well, this can be changed by you, you can split the window any way you like. You can use C-B to make a break, and press R to run your program, and press S to step, and C-J to add the variable you want to watch. You can download clewn here:

http://clewn.sourceforge.net/

How to install: first of all, you should have your gvim installed,

sudo apt-get install vim-gnome

as well as gdb And then download the source file of clewn; note here, not vimgdb. And extract the file, then use your terminal to enter the clewn folder

./configure make sudo make install

Note here, may be some one will be suffered from the dependency problem during their installing. If your machine tell you that you need readline, then install libreadline5-dev

sudo apt-get install libreadline5-dev

And then, copy some files to ~/.vim you can refer my folder:

cp /usr/local/share/vim/vimfiles/clewn.vim ~/.vim/plugin/

cp /usr/local/share/vim/vimfiles/doc/clewn.txt ~/.vim/doc/

cp /usr/local/share/vim/vimfiles/macros/clewn_mappings.vim ~/.vim/macros/

cp /usr/local/share/vim/vimfiles/syntax/gdbvar.vim ~/.vim/syntax/

Then, every thing is done. You can write a small program to test.

#include 
 
int main(int argc, char *argv[]) {
  int i;
  int s;
  s = 0;
  for (i = 0; i < 10; ++i) {
    s = s + 1;
  }
}

Save it as test.c , for example. And then,

gcc -g -o test test.c

If everything is right during compiling, then

clewn -va test.c

Then, gdb is opened on your terminal, and your gvim is opened at the same time Cool down now; input the following on your terminal(gdb):

file test

Now, you can debug your program on gvim. For example, you can click the line you want to set break point. And then press CTRL+B, then, break point is set. SHIFT+r(that is capital R)It will run and stop at your break point SHIFT+s(that is capital S)It will step And watch your variable, input following on gvim

:split

Then the window will be split, and then click the variable you want to watch, and press C+J, then you can see the variable appears in another window. To do this, you also can input the following on your terminal(gdb)

createvar yourvar

“youvar” represents the variable you want to watch. Following is the default shortcuts

List of default key mappings:

        CTRL-Z  send an interrupt to GDB and the program it is running
        B       info breakpoints
        L       info locals
        A       info args
        S       step
        I       stepi
        CTRL-N  next: next source line, skipping all function calls
        X       nexti
        F       finish
        R       run
        Q       quit
        C       continue
        W       where
        CTRL-U  up: go up one frame
        CTRL-D  down: go down one frame

cursor position: ~
        CTRL-B  set a breakpoint on the line where the cursor is located
        CTRL-E  clear all breakpoints on the line where the cursor is located

mouse pointer position: ~
        CTRL-P  print the value of the variable defined by the mouse pointer
                position
        CTRL-X  print the value that is referenced by the address whose
                value is that of the variable defined by the mouse pointer
                position
        CTRL-K  set a breakpoint at assembly address shown by mouse position
        CTRL-H  clear a breakpoint at assembly address shown by mouse position
        CTRL-J  add the selected variable at mouse position to the watched
                variables window

This is referred the official document, which is available here

http://clewn.sourceforge.net/doc.html

Hope this will help you somewhat. If you have some new or better idea, please contact me. chunhao86@gmail.com Thanks

5 Comments | Tags: linux, programming, vim

19 March 2008 - 0:39I am using Ubuntu 7.10 currently

Well, I have used ubuntu 6.06 before, but because my XP crashed some time, and I had to reinstall my XP. It cause my grub been destroyed. Unfortunately, I even didn’t know how to rewrite grub by live-cd. (which seems to simple today). I gave up ubuntu that time, about one and a half years ago. Half years ago, I saw ubuntu’s 3D desktop from google; it’s something like eye-candy, but really attracted me, and I installed it on my laptop. Since I have some experience about linux before, it wasn’t not very hard to install it. It took me about couple of days to configure the 3D desktop, due to which, I learned many things about config files and file structures of linux. That’s a good start, wasn’t it? After that, I walked into the world of linux, and found it was really wonderful! During that time, I learned something about vim, latex, and other useful tools on linux. It helps a lot in everyday’s study and work. Later, I will share some of my experience about that. Anyway, it ’s just a start. 

No Comments | Tags: linux

19 March 2008 - 0:16About my blog

This is Chunhao Wang, in Chinese, is 王春昊

I would like to share my experience and note about ubuntu/linux, vim, technology and other things with each other.

Also, if I make some project or write some articles, I will post it here to share them.

Competing in exams like 70-272 and 70-528 prepare one for 70-640 as well as 640-822, making it easier for one to clear 70-236 and 640-863 in the same go.

No Comments | Tags: other