Tuesday, August 25, 2009

gdb debugger introduction

  1. Compile your program using debug. If you want to use gdb, you have to compile your code using '-g' flag. It will tell the compiler to store the debug information in object file. It describes the data type of each variable or function.

    g++ -g test.cxx -o test

  2. Run your program.

    gdb test
    Quit your program.

    quit ; or Ctrl + D
  3. Set up break points.

    > b 19 // break at line 19 at a file
    > b func1 // break at func1
    > b testClass::testFunc(int) // C++ is polymorphic. you must tell break which version of the function you want to break on
    > info breakpoints // can print out all the break points
  4. Use backtrace.

    backtrace

    You can see many frames related the point.

    #0 std::string::assign (this=0xd3d704c, __str=@0xfd0d05)
    #1 0x00e4e524 in std::string::operator= (this=0xd3d704c, __str=@0xfd0d05)
    #2 0x065692d4 in IssueSeverity (this=0xd3d7048, rhs=@0xfd0d01)
    #3 0x0656831f in StatusCode::cloneSeverity (sev=0xfd0d01) at ../src/Lib/StatusCode.cpp:28
    #4 0x0317eb29 in StatusCode (this=0xbff07888, rhs=@0xbff077a4)
    #5 0xb7947250 in ?? ()
    #6 0xbff07888 in ?? ()
    #7 0xbff077a4 in ?? ()
    #8 0x00000000 in ?? ()

    You can take a look at the detail of one frame.

    frame 1
    info frame
    info locals
    info args


links

  1. RMS's gdb Debugger Tutorial
  2. Debugging with GDB
  3. Valgrind- memory management tool

Thursday, August 13, 2009

Gmail : How to mark all the unread email to read

Maybe you have many emails you don't care. So you just want to mark these emails to read and don't want to read them. In Gmail, if you just click the button "unread" at the top of mail, it will just select the unread email in this page(less than 50 conversation). You have to go to next page to select unread and mark as read. That is not convenient. What you can do is to type"is:unread" in search email frame.

Then you can see all the unread emails(not in one page). Now you can click "select All". In this case, you just select the unread emails in one page. Gmail will ask you whether you want to select all the unread emails. You choose yes. Then all your unread emails have been selected. The last step is click mark as read.

  1. Type"is:unread" in search email frame.
  2. Select All
  3. Gmail will ask you whether you want to select all the unread emails. You choose yes.
  4. Click "Mark as read".

Monday, August 10, 2009

xterm

If you use xmanager, maybe you need this setting to make your terminal look better.

/usr/bin/X11/xterm -bg black -fg gray -fn 10x20 +cm +dc -ls -display $DISPLAY