# SOURCES=my_main.cpp INC_PATH=~/tools/ImageMagick-6.6.5-4/Magick++/lib LIBRARY_PATH=~/tools/ImageMagick-6.6.5-4/Magick++/bin all: g++ -g -L$(LIBRARY_PATH) -O0 -o my_main $(SOURCES)
Sunday, November 28, 2010
sample Makefile
gdb
(gdb) kill ---> kill the session and keep your breakpoints...
(gdb) run ---> restart a new session
(gdb) info locals ---> local variables
(gdb) quit ---> exit gdb, lose your breakpoints...
(gdb) bt or backtrace ---> call stack
(gdb) bt full ---> call stack + all variables
(gdb) x/200s 0x89b8a8 ---> display mem as string
A blank line repeat the previous command
Debugging STL
Add a file .gdbinit to debug STL, see this link:
http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF
Then you can use it like this:
pmap params char* char*
See "Run / Debug Configurations" and debugger tab to specify a particular .gdbinit. Note that I had to add the .gdbinit full path, otherwise it would not work
gdb with arguments
gdb --args your_bin -c ~/2.2.25/etc -t 16
Debugging a core dump:
- gdb MyBin core.14694
and then bt for backtrace
.
(gdb) run ---> restart a new session
(gdb) info locals ---> local variables
(gdb) quit ---> exit gdb, lose your breakpoints...
(gdb) bt or backtrace ---> call stack
(gdb) bt full ---> call stack + all variables
(gdb) x/200s 0x89b8a8 ---> display mem as string
A blank line repeat the previous command
Add a file .gdbinit to debug STL, see this link:
http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF
Then you can use it like this:
pmap params char* char*
See "Run / Debug Configurations" and debugger tab to specify a particular .gdbinit. Note that I had to add the .gdbinit full path, otherwise it would not work
gdb --args your_bin -c ~/2.2.25/etc -t 16
- gdb MyBin core.14694
and then bt for backtrace
.
Thursday, November 25, 2010
Sorting
from wikipedia:
Name | Best | Average | Worst | Memory | Stable | Method | Other notes |
---|---|---|---|---|---|---|---|
Insertion sort | 15 ! | 25 ! | 25 ! | 00 ! | Yes | Insertion | Average case is also , where d is the number of inversions |
Binary tree sort | 50 !— | 20 ! | 20 ! | 15 ! | Yes | Insertion | When using a self-balancing binary search tree |
Cycle sort | 50 !— | 25 ! | 25 ! | 00 ! | No | Insertion | In-place with theoretically optimal number of writes |
Selection sort | 25 ! | 25 ! | 25 ! | 00 ! | No | Selection | Its stability depends on the implementation. Used to sort this table in Safari or other Webkit web browser [2]. |
Bubble sort | 15 ! | 25 ! | 25 ! | 00 ! | Yes | Exchanging | Tiny code |
Merge sort | 20 ! | 20 ! | 20 ! | 50 !Depends | Yes | Merging | Used to sort this table in Firefox [3]. |
Quicksort | 20 ! | 20 ! | 25 ! | 05 ! | Depends | Partitioning | Can be implemented as a stable sort depending on how the pivot is handled. Naïve variants use space |
Saturday, November 13, 2010
Quotes
Subscribe to:
Posts (Atom)